/* =====================================================================
   ระบบยืม-คืนอุปกรณ์ — Modern UI
   - Design tokens (สว่าง/มืด) • Mobile-first • Bottom nav บนมือถือ • ตาราง -> การ์ดบนจอเล็ก
   ===================================================================== */

:root {
  --font: 'Noto Sans Thai', 'IBM Plex Sans Thai', 'Leelawadee UI', 'Leelawadee', 'Sarabun', Tahoma, system-ui, -apple-system, sans-serif;

  --bg: #f5f6fb;
  --bg-grad-1: rgba(99, 102, 241, .14);
  --bg-grad-2: rgba(236, 72, 153, .08);
  --surface: #ffffff;
  --surface-2: #f7f8fc;
  --surface-3: #eef0f7;
  --glass: rgba(255, 255, 255, .72);
  --text: #141824;
  --muted: #6b7286;
  --line: #e6e8f0;
  --line-strong: #d5d9e5;

  --primary: #5b5bf0;
  --primary-2: #8b5cf6;
  --primary-ink: #ffffff;
  --primary-soft: #eef0ff;
  --primary-soft-fg: #4338ca;
  --ring: rgba(91, 91, 240, .35);

  --ok: #16a34a;   --ok-bg: #dcfce7;   --ok-fg: #166534;
  --warn: #d97706; --warn-bg: #fef3c7; --warn-fg: #92400e;
  --bad: #e11d48;  --bad-bg: #ffe4e6;  --bad-fg: #9f1239;
  --info: #2563eb; --info-bg: #dbeafe; --info-fg: #1e40af;
  --violet-bg: #ede9fe; --violet-fg: #5b21b6;
  --neutral-bg: #f1f5f9; --neutral-fg: #64748b;

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 6px 24px rgba(16, 24, 40, .06);
  --shadow-lg: 0 20px 60px rgba(16, 24, 40, .18);
  --topbar-h: 64px;
  --bottomnav-h: 64px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}

/* ---------- Dark theme ---------- */
:root[data-theme="dark"] {
  --bg: #0b0d14;
  --bg-grad-1: rgba(99, 102, 241, .20);
  --bg-grad-2: rgba(236, 72, 153, .10);
  --surface: #141826;
  --surface-2: #1a1f30;
  --surface-3: #232a3f;
  --glass: rgba(20, 24, 38, .72);
  --text: #e8eaf2;
  --muted: #9aa1b5;
  --line: #262c40;
  --line-strong: #323a52;
  --primary: #7c7cff;
  --primary-2: #a78bfa;
  --primary-soft: rgba(124, 124, 255, .16);
  --primary-soft-fg: #c7c9ff;
  --ring: rgba(124, 124, 255, .45);
  --ok-bg: rgba(34, 197, 94, .16);   --ok-fg: #86efac;
  --warn-bg: rgba(245, 158, 11, .16); --warn-fg: #fcd34d;
  --bad-bg: rgba(244, 63, 94, .16);   --bad-fg: #fda4af;
  --info-bg: rgba(59, 130, 246, .18); --info-fg: #93c5fd;
  --violet-bg: rgba(139, 92, 246, .2); --violet-fg: #c4b5fd;
  --neutral-bg: rgba(148, 163, 184, .14); --neutral-fg: #a5b0c2;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 28px rgba(0, 0, 0, .35);
  --shadow-lg: 0 24px 70px rgba(0, 0, 0, .6);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0d14; --bg-grad-1: rgba(99, 102, 241, .20); --bg-grad-2: rgba(236, 72, 153, .10);
    --surface: #141826; --surface-2: #1a1f30; --surface-3: #232a3f; --glass: rgba(20, 24, 38, .72);
    --text: #e8eaf2; --muted: #9aa1b5; --line: #262c40; --line-strong: #323a52;
    --primary: #7c7cff; --primary-2: #a78bfa; --primary-soft: rgba(124, 124, 255, .16); --primary-soft-fg: #c7c9ff; --ring: rgba(124, 124, 255, .45);
    --ok-bg: rgba(34, 197, 94, .16); --ok-fg: #86efac; --warn-bg: rgba(245, 158, 11, .16); --warn-fg: #fcd34d;
    --bad-bg: rgba(244, 63, 94, .16); --bad-fg: #fda4af; --info-bg: rgba(59, 130, 246, .18); --info-fg: #93c5fd;
    --violet-bg: rgba(139, 92, 246, .2); --violet-fg: #c4b5fd; --neutral-bg: rgba(148, 163, 184, .14); --neutral-fg: #a5b0c2;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 28px rgba(0, 0, 0, .35); --shadow-lg: 0 24px 70px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100dvh; font-family: var(--font); font-size: 15px; line-height: 1.55; color: var(--text);
  background:
    radial-gradient(900px 500px at 0% -10%, var(--bg-grad-1), transparent 60%),
    radial-gradient(700px 400px at 100% 0%, var(--bg-grad-2), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
small { color: var(--muted); font-weight: 400; }
code { background: var(--surface-3); padding: .1rem .4rem; border-radius: 6px; font-size: .85rem; word-break: break-all; }
::selection { background: var(--ring); }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

.muted { color: var(--muted); } .small { font-size: .82rem; } .mt { margin-top: 1.2rem; } .pre { white-space: pre-line; }
.note { color: var(--muted); font-size: .8rem; }
body:not(.is-admin) .admin-only { display: none !important; }   /* is-admin = เจ้าหน้าที่ขึ้นไป */
body:not(.is-super) .super-only { display: none !important; }   /* is-super = ผู้ดูแลระบบเท่านั้น */
body.is-admin .user-only { display: none !important; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  border: 1px solid transparent; border-radius: 12px; padding: .62rem 1.1rem; min-height: 42px;
  font: inherit; font-weight: 600; line-height: 1.2; cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: transform .12s var(--ease), box-shadow .2s var(--ease), background .2s, border-color .2s, filter .2s;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn.primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: var(--primary-ink); box-shadow: 0 6px 18px -6px var(--primary); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.07); box-shadow: 0 10px 24px -8px var(--primary); }
.btn.ghost { background: var(--surface); color: var(--text); border-color: var(--line-strong); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); border-color: var(--primary); }
.btn.ok { background: var(--ok); color: #fff; } .btn.bad { background: var(--bad); color: #fff; } .btn.info { background: var(--info); color: #fff; }
.btn.ok:hover, .btn.bad:hover, .btn.info:hover { filter: brightness(1.08); }
.btn.sm { padding: .38rem .8rem; min-height: 34px; font-size: .84rem; border-radius: 10px; }
.btn.block { width: 100%; margin-top: .6rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.linkish { background: none; border: 0; color: var(--primary); font: inherit; font-size: .85rem; cursor: pointer; padding: .2rem 0; margin: -.4rem 0 .6rem; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Forms ---------- */
label { display: block; margin-bottom: .95rem; font-weight: 500; font-size: .9rem; }
input, select, textarea {
  width: 100%; margin-top: .35rem; padding: .7rem .85rem; min-height: 44px;
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--ring); }
input:disabled { background: var(--surface-3); color: var(--muted); }
.check { display: inline-flex; align-items: center; gap: .45rem; margin: 0; font-weight: 500; white-space: nowrap; cursor: pointer; }
.check input { width: 18px; height: 18px; min-height: 0; margin: 0; accent-color: var(--primary); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.otp { font-size: 1.45rem; letter-spacing: .45rem; text-align: center; font-variant-numeric: tabular-nums; }
.meter { height: 6px; background: var(--surface-3); border-radius: 99px; margin: -.45rem 0 .95rem; overflow: hidden; }
.meter span { display: block; height: 100%; width: 0; transition: width .25s var(--ease); border-radius: 99px; }
.meter span.s1 { width: 25%; background: var(--bad); } .meter span.s2 { width: 50%; background: var(--warn); }
.meter span.s3 { width: 75%; background: #65a30d; } .meter span.s4 { width: 100%; background: var(--ok); }

/* ---------- Message boxes ---------- */
.hint, .warn-box, .form-error, .verify-ok, .verify-bad { padding: .75rem .95rem; border-radius: 12px; font-size: .88rem; margin: 0 0 1rem; }
.hint { background: var(--primary-soft); color: var(--primary-soft-fg); }
.warn-box { background: var(--warn-bg); color: var(--warn-fg); }
.form-error, .verify-bad { background: var(--bad-bg); color: var(--bad-fg); }
.verify-bad { font-weight: 600; }
.verify-ok { background: var(--ok-bg); color: var(--ok-fg); }
.alert-box { background: var(--bad-bg); color: var(--bad-fg); border-radius: var(--radius); padding: .95rem 1.15rem; margin-bottom: 1.2rem; font-size: .9rem; border: 1px solid color-mix(in srgb, var(--bad) 25%, transparent); }
.alert-box ul { margin: .4rem 0 0; padding-left: 1.2rem; }

/* ---------- Tags / status ---------- */
.tag { display: inline-block; font-size: .72rem; padding: .12rem .5rem; border-radius: 999px; background: var(--ok-bg); color: var(--ok-fg); font-weight: 600; white-space: nowrap; }
.tag.off { background: var(--neutral-bg); color: var(--neutral-fg); } .tag.bad { background: var(--bad-bg); color: var(--bad-fg); }
.tag.warn { background: var(--warn-bg); color: var(--warn-fg); } .tag.admin { background: var(--violet-bg); color: var(--violet-fg); } .tag.staff { background: var(--info-bg); color: var(--info-fg); }
.role-select { width: auto; min-height: 34px; padding: .3rem .5rem; margin: 0; font-size: .85rem; }
.status { display: inline-flex; align-items: center; gap: .35rem; padding: .22rem .65rem; border-radius: 999px; font-size: .77rem; font-weight: 600; white-space: nowrap; }
.status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.status.pending { background: var(--warn-bg); color: var(--warn-fg); }
.status.approved { background: var(--violet-bg); color: var(--violet-fg); }
.status.borrowed { background: var(--info-bg); color: var(--info-fg); }
.status.returned { background: var(--ok-bg); color: var(--ok-fg); }
.status.rejected, .status.overdue { background: var(--bad-bg); color: var(--bad-fg); }
.status.cancelled { background: var(--neutral-bg); color: var(--neutral-fg); }
.count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 .35rem; background: var(--bad); color: #fff; border-radius: 99px; font-size: .68rem; font-weight: 700; line-height: 1; }
.late { color: var(--bad); font-weight: 600; font-size: .8rem; }
.ontime { color: var(--ok); font-size: .8rem; }
.overdue { color: var(--bad); font-weight: 600; }
.act-sec { color: var(--bad); font-weight: 600; }
.ext-tag { display: inline-block; margin-top: .3rem; font-size: .75rem; background: var(--warn-bg); color: var(--warn-fg); padding: .15rem .5rem; border-radius: 8px; }

/* ---------- Auth ---------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 1.5rem 1rem calc(1.5rem + env(safe-area-inset-bottom, 0px)); }
.auth-card {
  width: 100%; max-width: 420px; background: var(--glass); backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border: 1px solid var(--line); padding: 2rem 1.75rem; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  animation: rise .5s var(--ease);
}
.brand { display: flex; align-items: center; gap: .6rem; }
.auth .brand { flex-direction: column; text-align: center; margin-bottom: 1.6rem; gap: .7rem; }
.auth h1 { font-size: 1.35rem; }
.logo { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; font-size: 1.3rem;
  background: linear-gradient(135deg, var(--primary), var(--primary-2)); box-shadow: 0 8px 20px -8px var(--primary); }
.auth .logo { width: 64px; height: 64px; border-radius: 20px; font-size: 2rem; }
.seg { display: flex; background: var(--surface-3); border-radius: 14px; padding: 4px; margin-bottom: 1.3rem; }
.seg button { flex: 1; border: 0; background: transparent; padding: .6rem; border-radius: 11px; font: inherit; cursor: pointer; color: var(--muted); transition: .2s var(--ease); }
.seg button.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm); }
.secure-note { text-align: center; color: var(--muted); font-size: .76rem; margin: 1.3rem 0 0; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 1rem;
  padding: calc(.7rem + env(safe-area-inset-top, 0px)) 1.5rem .7rem; min-height: var(--topbar-h);
  background: var(--glass); backdrop-filter: blur(16px) saturate(1.5); -webkit-backdrop-filter: blur(16px) saturate(1.5);
  border-bottom: 1px solid var(--line);
}
.topbar .brand strong { font-size: 1rem; white-space: nowrap; }
.topbar .logo { width: 36px; height: 36px; font-size: 1.1rem; border-radius: 11px; }
#tabs { display: flex; gap: .2rem; flex: 1; flex-wrap: wrap; justify-content: center; }
#tabs button { display: inline-flex; align-items: center; gap: .35rem; border: 0; background: transparent; padding: .5rem .8rem; border-radius: 11px; font: inherit; font-size: .9rem; cursor: pointer; color: var(--muted); transition: .2s var(--ease); }
#tabs button:hover { color: var(--text); background: var(--surface-3); }
#tabs button.active { background: var(--primary-soft); color: var(--primary-soft-fg); font-weight: 600; }
.ti { font-size: 1rem; line-height: 1; }
.user { display: flex; align-items: center; gap: .55rem; font-size: .88rem; }
#user-name { font-weight: 600; white-space: nowrap; }
.icon-btn { position: relative; display: inline-grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; font-size: 1.1rem; cursor: pointer; transition: .2s var(--ease); color: var(--text); }
.icon-btn:hover { border-color: var(--primary); }
.icon-btn .count { position: absolute; top: -6px; right: -6px; }
.bell { position: relative; }

/* ---------- Bottom nav (mobile) ---------- */
.bottom-nav { display: none; }
.sheet-list { display: grid; gap: .4rem; }
.sheet-list button { display: flex; align-items: center; gap: .8rem; width: 100%; padding: .85rem 1rem; border: 1px solid var(--line); background: var(--surface-2); border-radius: 14px; font: inherit; font-size: 1rem; color: var(--text); cursor: pointer; text-align: left; }
.sheet-list button.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-soft-fg); font-weight: 600; }
.sheet-list .ti { font-size: 1.25rem; width: 1.6rem; text-align: center; }
.sheet-list .danger { color: var(--bad); }

/* ---------- Layout ---------- */
.container { max-width: 1240px; margin: 0 auto; padding: 1.6rem 1.25rem 3rem; }
main.container > section { animation: fade .35s var(--ease); }
.page-title { font-size: 1.55rem; font-weight: 700; margin-bottom: .3rem; }
.toolbar { display: flex; gap: .7rem; margin-bottom: 1.2rem; flex-wrap: wrap; align-items: center; }
.toolbar input, .toolbar select { margin: 0; max-width: 320px; }
#user-filters select { width: auto; max-width: 210px; }
#user-filters input[type="search"] { flex: 1 1 240px; }
.toolbar input[type="search"] { padding-left: 2.4rem; background: var(--surface) no-repeat .85rem center / 16px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a90a2' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E"); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem 1.4rem; box-shadow: var(--shadow); min-width: 0; }
.panel h3 { margin: 0 0 1rem; font-size: 1rem; }
.panel h3.mt { margin-top: 1.6rem; }
.load-row.warn strong { color: var(--bad, #dc2626); }
.todo.clickable { cursor: pointer; } .todo.clickable:hover { background: var(--hover, rgba(127,127,127,.08)); }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }
.empty { color: var(--muted); text-align: center; padding: 3rem 1rem; grid-column: 1 / -1; }

/* ---------- Dashboard ---------- */
#last-login { margin: 0 0 1.1rem; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .9rem; margin-bottom: 1.2rem; }
.tile { position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.15rem; box-shadow: var(--shadow); transition: transform .2s var(--ease); }
.tile:hover { transform: translateY(-2px); }
.tile::after { content: ''; position: absolute; inset: auto -20px -30px auto; width: 90px; height: 90px; border-radius: 50%; background: var(--primary-soft); opacity: .7; }
.tile .num { position: relative; z-index: 1; font-size: 1.75rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.tile .lbl { position: relative; z-index: 1; color: var(--muted); font-size: .84rem; }
.tile.alert .num { color: var(--bad); } .tile.alert::after { background: var(--bad-bg); }
.tile.warn .num { color: var(--warn); } .tile.warn::after { background: var(--warn-bg); }
.todo { display: flex; justify-content: space-between; align-items: center; gap: .6rem; padding: .7rem 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.todo:last-child { border-bottom: 0; }
.top-list { margin: 0; padding-left: 1.2rem; } .top-list li { padding: .32rem 0; }
.tips { margin: 0; padding-left: 1.2rem; color: var(--muted); font-size: .9rem; } .tips li { padding: .25rem 0; }
.bars { display: flex; align-items: flex-end; gap: .6rem; height: 160px; padding-top: 1rem; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: .3rem; font-size: .75rem; color: var(--muted); }
.bar .fill { width: 100%; max-width: 42px; background: linear-gradient(180deg, var(--primary-2), var(--primary)); border-radius: 8px 8px 4px 4px; min-height: 3px; transition: height .6s var(--ease); }
.bar .val { color: var(--text); font-weight: 700; }
.load-grid { display: grid; }
.load-row { display: flex; justify-content: space-between; gap: 1rem; padding: .42rem 0; border-bottom: 1px solid var(--line); font-size: .88rem; }

/* ---------- Item cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; }
.card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.15rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .5rem; transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s; }
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--primary) 35%, var(--line)); }
.card .thumb { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 16px; font-size: 1.6rem; background: linear-gradient(135deg, var(--primary-soft), color-mix(in srgb, var(--primary-2) 18%, transparent)); }
/* รูปอุปกรณ์ (จาก Google Drive ผ่านเซิร์ฟเวอร์) */
.card .thumb.has-photo { padding: 0; border: 0; overflow: hidden; cursor: zoom-in; width: 64px; height: 64px; }
.card .thumb.has-photo img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .3s var(--ease); }
.card .thumb.has-photo:hover img { transform: scale(1.08); }
.card button.thumb:disabled { padding: 0; border: 0; color: inherit; cursor: default; }
.photo-big { display: block; max-width: 100%; max-height: 70vh; margin: 0 auto; border-radius: 12px; }
.card .head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.card .cat { font-size: .74rem; color: var(--primary-soft-fg); background: var(--primary-soft); padding: .18rem .6rem; border-radius: 999px; font-weight: 600; }
.card h3 { margin: .2rem 0 0; font-size: 1.05rem; }
.card p { margin: 0; color: var(--muted); font-size: .87rem; flex: 1; }
.card .foot { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-top: .55rem; padding-top: .75rem; border-top: 1px dashed var(--line); }
.stock { font-size: .84rem; font-weight: 600; display: inline-flex; align-items: center; gap: .35rem; }
.stock::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.stock.none { color: var(--bad); } .stock.some { color: var(--ok); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.table-wrap.flat { box-shadow: none; border: 0; background: transparent; }
table { width: 100%; border-collapse: collapse; min-width: 640px; }
th, td { padding: .85rem 1rem; text-align: left; border-bottom: 1px solid var(--line); font-size: .9rem; vertical-align: middle; }
th { background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .02em; position: sticky; top: 0; }
tbody tr { transition: background .15s; }
tbody tr:hover { background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
td .row-actions { display: flex; gap: .4rem; justify-content: flex-end; flex-wrap: wrap; }
.dates { white-space: nowrap; }
.dates .arrow { color: var(--muted); margin: 0 .3rem; }
.history-table { width: 100%; min-width: 0; font-size: .82rem; }
.history-table th, .history-table td { padding: .5rem .55rem; }

/* ---------- Account ---------- */
.sec-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .85rem 0; border-bottom: 1px solid var(--line); }
.sec-row small { display: block; }
.session { display: flex; justify-content: space-between; align-items: center; gap: .8rem; padding: .7rem 0; border-bottom: 1px solid var(--line); font-size: .86rem; }
.session .ua, .ua { color: var(--muted); font-size: .77rem; word-break: break-word; }
.alert-item { display: flex; justify-content: space-between; gap: 1rem; padding: .6rem 0; border-bottom: 1px solid var(--line); font-size: .88rem; }
.alert-item:last-child { border-bottom: 0; }
.alert-item.danger strong { color: var(--bad); }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: .45rem; font-family: ui-monospace, Consolas, monospace; font-size: 1rem; background: var(--surface-3); padding: 1rem; border-radius: 12px; user-select: all; text-align: center; }
.temp-pass { font-size: 1.2rem; text-align: center; padding: .9rem; background: var(--surface-3); border-radius: 12px; user-select: all; font-family: ui-monospace, monospace; }
.qr.big { width: 240px; height: 240px; }
/* เข้าสู่ระบบด้วย Google */
.or { display: flex; align-items: center; gap: .75rem; margin: 1rem 0 .2rem; color: var(--muted); font-size: .85rem; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line-strong); }
.btn.google { display: flex; align-items: center; justify-content: center; gap: .6rem; background: var(--surface); color: var(--text); border: 1px solid var(--line-strong); }
.btn.google:hover { background: var(--surface-3); }
.btn.google svg { width: 20px; height: 20px; }
#open-forgot { margin: -.3rem 0 .4rem; }
/* ปุ่มตาแสดง/ซ่อนรหัสผ่าน */
.pw-wrap { position: relative; display: block; margin-top: .35rem; }
.pw-wrap input { margin-top: 0; padding-right: 3rem; }
.pw-eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; display: grid; place-items: center;
  border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; padding: 0; }
.pw-eye:hover, .pw-eye:focus-visible { color: var(--text); background: var(--surface-3); outline: none; }
.pw-eye svg { width: 20px; height: 20px; }
.otp-choice { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: .25rem 0 .75rem; }
.scan-box { position: relative; width: 100%; max-width: 360px; aspect-ratio: 1; margin: .5rem auto; border-radius: 14px; overflow: hidden; background: #000; }
.scan-box video { width: 100%; height: 100%; object-fit: cover; }
.scan-frame { position: absolute; inset: 18%; border: 3px solid rgba(255,255,255,.85); border-radius: 12px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); pointer-events: none; }
.file-btn { text-align: center; cursor: pointer; }
.center { text-align: center; }
.qr { display: block; margin: .5rem auto; width: 200px; height: 200px; image-rendering: pixelated; border-radius: 12px; background: #fff; padding: 6px; }

/* ---------- Borrow dialog ---------- */
.avail-box { align-self: end; margin-bottom: .95rem; padding: .7rem .85rem; border-radius: 12px; background: var(--surface-3); font-size: .86rem; color: var(--muted); min-height: 44px; display: flex; align-items: center; }
.avail-box.ok { background: var(--ok-bg); color: var(--ok-fg); }
.avail-box.bad { background: var(--bad-bg); color: var(--bad-fg); }

/* ---------- Dialogs ---------- */
dialog {
  border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1.6rem; width: min(460px, calc(100vw - 2rem));
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); max-height: calc(100dvh - 2rem); overflow-y: auto;
}
dialog[open] { animation: pop .25s var(--ease); }
dialog::backdrop { background: rgba(10, 12, 22, .5); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
dialog h2 { font-size: 1.15rem; margin-bottom: 1.1rem; }
#info-dialog { width: min(760px, calc(100vw - 2rem)); }
.actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: .6rem; flex-wrap: wrap; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; inset: auto auto calc(1.5rem + env(safe-area-inset-bottom, 0px)) 50%; margin: 0; border: 0; transform: translateX(-50%);
  background: #1b1f2e; color: #fff; padding: .8rem 1.25rem; border-radius: 14px; box-shadow: var(--shadow-lg);
  max-width: calc(100vw - 2rem); width: max-content; font: inherit; font-size: .92rem; animation: toast .3s var(--ease);
}
#toast:not(:popover-open) { display: none; }
#toast.error { background: var(--bad); }

/* ---------- Notifications ---------- */
.notif-panel {
  position: fixed; top: calc(var(--topbar-h) + env(safe-area-inset-top, 0px) + .4rem); right: 1rem; width: min(390px, calc(100vw - 2rem)); max-height: 72vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 40; animation: pop .2s var(--ease);
}
.notif-head { position: sticky; top: 0; display: flex; justify-content: space-between; align-items: center; padding: .8rem 1rem; border-bottom: 1px solid var(--line); background: var(--surface); }
.notif-head .linkish { margin: 0; }
.notif { padding: .75rem 1rem; border-bottom: 1px solid var(--line); font-size: .88rem; cursor: pointer; transition: background .15s; }
.notif:last-child { border-bottom: 0; }
.notif:hover { background: var(--surface-2); }
.notif.unread { background: var(--primary-soft); }
.notif.reminder { border-left: 4px solid var(--info); }
.notif.reminder.bad { border-left-color: var(--bad); } .notif.reminder.warn { border-left-color: var(--warn); }
.notif .when { color: var(--muted); font-size: .74rem; margin-top: .2rem; }

/* ---------- Calendar ---------- */
.cal-toolbar { align-items: center; }
.cal-title { font-size: 1.1rem; min-width: 9.5rem; text-align: center; }
.cal-legend { display: flex; flex-wrap: wrap; gap: .9rem; font-size: .8rem; color: var(--muted); margin-bottom: .8rem; }
.dot { display: inline-block; width: .7rem; height: .7rem; border-radius: 4px; margin-right: .3rem; vertical-align: -1px; }
.dot.pending, .ev.pending { background: var(--warn-bg); color: var(--warn-fg); }
.dot.approved, .ev.approved { background: var(--violet-bg); color: var(--violet-fg); }
.dot.borrowed, .ev.borrowed { background: var(--info-bg); color: var(--info-fg); }
.dot.returned, .ev.returned { background: var(--ok-bg); color: var(--ok-fg); }
.cal-wrap { overflow-x: auto; border-radius: var(--radius); }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.cal-dow { background: var(--surface-2); padding: .55rem; text-align: center; font-size: .78rem; color: var(--muted); font-weight: 600; }
.cal-day { background: var(--surface); min-height: 104px; padding: .4rem; font-size: .74rem; display: flex; flex-direction: column; gap: 3px; cursor: pointer; transition: background .15s; min-width: 0; }
.cal-day:hover { background: var(--surface-2); }
.cal-day.out { background: var(--surface-2); color: var(--muted); opacity: .6; }
.cal-day.today .dnum-n { color: #fff; background: linear-gradient(135deg, var(--primary), var(--primary-2)); }
.cal-day.sel { box-shadow: inset 0 0 0 2px var(--primary); }
.cal-day .dnum { font-weight: 700; font-size: .85rem; display: flex; justify-content: space-between; align-items: center; gap: .2rem; }
.dnum-n { display: inline-grid; place-items: center; min-width: 24px; height: 24px; border-radius: 8px; }
.cal-day .free { font-weight: 600; font-size: .68rem; padding: 0 .4rem; border-radius: 6px; background: var(--ok-bg); color: var(--ok-fg); white-space: nowrap; }
.cal-day .free.none { background: var(--bad-bg); color: var(--bad-fg); }
.ev { border-radius: 6px; padding: 1px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev.mine { font-weight: 700; }
.cal-day .more { color: var(--muted); }
.cal-day-list { margin-top: 1rem; }
.cal-day-list .todo strong { font-size: .92rem; }

/* ---------- QR label ---------- */
.label-card { text-align: center; border: 2px dashed var(--line-strong); border-radius: 16px; padding: 1rem; margin-bottom: .8rem; }
.label-name { font-weight: 700; font-size: 1.1rem; margin-top: .3rem; }
.label-sub { color: var(--muted); font-size: .85rem; }

/* ---------- Theme toggle ---------- */
.theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .moon { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .moon { display: inline; }
}

/* ---------- Animations ---------- */
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes sheet { from { transform: translateY(100%); } to { transform: none; } }
@keyframes toast { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

.cv { min-width: 0; }
#tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
#tabs::-webkit-scrollbar { display: none; }
#tabs button { flex-shrink: 0; white-space: nowrap; }

/* =====================================================================
   จอกลาง / แท็บเล็ต: ย่อเมนูบน ไม่ให้ขึ้นสองบรรทัด
   ===================================================================== */
@media (max-width: 1440px) {
  #user-name { display: none; }
  #tabs button { padding: .5rem .65rem; font-size: .86rem; }
}
@media (max-width: 1240px) {
  .topbar .brand strong { display: none; }
  body.is-admin #tabs button:not(.active) .tl { display: none; }  /* ผู้ดูแลมีแท็บเยอะ: แสดงชื่อเฉพาะแท็บที่เลือก */
  body.is-admin #tabs button .ti { font-size: 1.15rem; }
}
@media (max-width: 960px) {
  #tabs button:not(.active) .tl { display: none; }
  #tabs button .ti { font-size: 1.15rem; }
}

/* =====================================================================
   Mobile (≤ 768px): bottom nav, การ์ดแทนตาราง, bottom sheet
   ===================================================================== */
@media (max-width: 768px) {
  body { font-size: 15px; }
  input, select, textarea { font-size: 16px; } /* กัน iOS ซูมอัตโนมัติ */

  .topbar { padding: calc(.55rem + env(safe-area-inset-top, 0px)) 1rem .55rem; gap: .6rem; min-height: 58px; }
  .topbar .brand strong { display: inline; font-size: .98rem; }
  .topbar .brand { flex: 1; }
  #tabs, #logout { display: none; }

  .bottom-nav {
    position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr);
    padding: .35rem .4rem calc(.35rem + env(safe-area-inset-bottom, 0px));
    background: var(--glass); backdrop-filter: blur(18px) saturate(1.5); -webkit-backdrop-filter: blur(18px) saturate(1.5);
    border-top: 1px solid var(--line);
  }
  .bottom-nav button {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1rem;
    min-height: 52px; border: 0; background: transparent; border-radius: 14px; font: inherit; font-size: .7rem; color: var(--muted); cursor: pointer;
  }
  .bottom-nav button .ti { font-size: 1.3rem; transition: transform .2s var(--ease); }
  .bottom-nav button.active { color: var(--primary); font-weight: 700; }
  .bottom-nav button.active .ti { transform: translateY(-2px) scale(1.1); }
  .bottom-nav button.active::before { content: ''; position: absolute; top: 2px; width: 22px; height: 3px; border-radius: 3px; background: var(--primary); }
  .bottom-nav .count { position: absolute; top: 4px; right: calc(50% - 22px); }

  .container { padding: 1.1rem .9rem calc(var(--bottomnav-h) + 1.5rem + env(safe-area-inset-bottom, 0px)); }
  .page-title { font-size: 1.3rem; }
  .toolbar { gap: .5rem; }
  .toolbar input, .toolbar select { max-width: none; flex: 1 1 100%; }
  .toolbar .btn { flex: 1; }
  .two-col { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, 1fr); gap: .65rem; }
  .tile { padding: .85rem .95rem; }
  .tile .num { font-size: 1.45rem; }
  .grid { grid-template-columns: 1fr; gap: .75rem; }
  .card { padding: 1rem; }
  .card:hover { transform: none; }
  .panel { padding: 1.05rem 1.1rem; }
  .row2 { grid-template-columns: 1fr; gap: 0; }

  /* ตาราง -> การ์ด */
  .table-wrap { overflow: visible; background: transparent; border: 0; box-shadow: none; }
  table { min-width: 0; }
  table, thead, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tbody tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: .8rem 1rem; margin-bottom: .75rem; }
  tbody tr:hover { background: var(--surface); }
  td { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding: .38rem 0; border: 0; font-size: .9rem; text-align: right; }
  td::before { content: attr(data-label); color: var(--muted); font-size: .78rem; font-weight: 500; text-align: left; flex-shrink: 0; padding-top: .1rem; }
  td:first-child { display: block; text-align: left; font-size: 1rem; padding-bottom: .55rem; margin-bottom: .3rem; border-bottom: 1px solid var(--line); }
  td:first-child::before { display: none; }
  td:last-child:has(.row-actions) { display: block; padding-top: .6rem; }
  td:last-child:has(.row-actions)::before { display: none; }
  td .row-actions { justify-content: stretch; }
  td .row-actions .btn { flex: 1 1 auto; min-height: 40px; }
  td.empty, td[colspan] { display: block; text-align: center; }
  td.empty::before, td[colspan]::before { display: none; }
  td:empty { display: none; }
  .table-wrap.flat tbody tr { box-shadow: none; background: var(--surface-2); }
  .dates { white-space: normal; }

  /* dialog -> bottom sheet */
  dialog {
    width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 24px 24px 0 0; border-bottom: 0;
    padding: 1.3rem 1.15rem calc(1.2rem + env(safe-area-inset-bottom, 0px)); max-height: 92dvh;
  }
  dialog[open] { animation: sheet .3s var(--ease); }
  dialog::before { content: ''; display: block; width: 42px; height: 5px; border-radius: 5px; background: var(--line-strong); margin: -.4rem auto 1rem; }
  #info-dialog { width: 100%; }
  .actions { position: sticky; bottom: calc(-1.2rem - env(safe-area-inset-bottom, 0px)); background: var(--surface); padding: .8rem 0 .2rem; margin-bottom: -.2rem; }
  .actions .btn { flex: 1; min-height: 48px; }

  .notif-panel { left: .6rem; right: .6rem; width: auto; top: calc(58px + env(safe-area-inset-top, 0px) + .3rem); max-height: calc(100dvh - 58px - var(--bottomnav-h) - 2rem); }
  #toast { bottom: calc(var(--bottomnav-h) + 1rem + env(safe-area-inset-bottom, 0px)); }

  /* ปฏิทินแบบย่อ */
  .cal-toolbar { display: grid; grid-template-columns: auto 1fr auto auto; }
  .cal-toolbar select { grid-column: 1 / -1; }
  .cal-title { min-width: 0; font-size: 1rem; }
  .cal-grid { border-radius: 14px; }
  .cal-dow { padding: .4rem 0; font-size: .7rem; }
  .cal-day { min-height: 62px; padding: .25rem; gap: 2px; align-items: stretch; }
  .cal-day .dnum { flex-direction: column; align-items: center; font-size: .8rem; gap: 1px; }
  .cal-day .free { font-size: .6rem; padding: 0 .25rem; }
  .ev { height: 5px; padding: 0; font-size: 0; border-radius: 3px; }
  .cal-day .more { font-size: .6rem; text-align: center; }
  .cal-legend { gap: .6rem; font-size: .74rem; }
}

@media (max-width: 380px) {
  .tiles { grid-template-columns: 1fr 1fr; }
  .tile .num { font-size: 1.25rem; }
  .bottom-nav button { font-size: .64rem; }
}

/* ---------- v5: ใช้งานสะดวก ---------- */
/* ปุ่มเลือกช่วงวันเร็ว */
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: -.35rem 0 .95rem; }
.chip { border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); border-radius: 999px; padding: .35rem .8rem; font: inherit; font-size: .82rem; cursor: pointer; transition: .15s var(--ease); min-height: 34px; }
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-soft-fg); font-weight: 600; }
.waitlist-btn { margin: -.3rem 0 1rem; border-style: dashed; }

/* การ์ดอุปกรณ์: ดาว + ปุ่มตะกร้า */
.card .star { position: absolute; top: .9rem; right: .9rem; width: 36px; height: 36px; border-radius: 50%; border: 0; background: transparent; font-size: 1.25rem; cursor: pointer; color: var(--muted); filter: grayscale(1); opacity: .45; transition: .2s var(--ease); }
.card .star:hover { opacity: .9; transform: scale(1.1); }
.card .star.on { filter: none; opacity: 1; }
.card .head .cat { margin-right: 2.4rem; }
.card .foot .btns { display: flex; gap: .4rem; }
.card .in-cart { background: var(--ok-bg); color: var(--ok-fg); border-color: transparent; }

/* ปุ่มตะกร้าลอย */
.cart-fab {
  position: fixed; z-index: 25; right: 1.5rem; bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
  width: 60px; height: 60px; border-radius: 20px; border: 0; cursor: pointer; font-size: 1.6rem;
  background: linear-gradient(135deg, var(--primary), var(--primary-2)); box-shadow: 0 12px 30px -8px var(--primary); color: #fff;
  animation: pop .3s var(--ease); transition: transform .15s var(--ease);
}
.cart-fab:active { transform: scale(.94); }
.cart-fab .count { position: absolute; top: -6px; right: -6px; min-width: 22px; height: 22px; font-size: .75rem; box-shadow: 0 0 0 3px var(--bg); }
.cart-fab.bump { animation: bump .4s var(--ease); }
@keyframes bump { 30% { transform: scale(1.18); } 60% { transform: scale(.95); } }
.cart-list { display: grid; gap: .5rem; margin-bottom: 1rem; }
.cart-row { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: .65rem; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); }
.cart-row .thumb { font-size: 1.4rem; }
.cart-row .nm { font-weight: 600; font-size: .92rem; line-height: 1.3; }
.cart-row .av { font-size: .78rem; }
.cart-row .av.ok { color: var(--ok); } .cart-row .av.bad { color: var(--bad); font-weight: 600; }
.cart-row.bad { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); background: var(--bad-bg); }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; background: var(--surface); }
.stepper button { width: 32px; height: 32px; border: 0; background: transparent; font: inherit; font-size: 1.05rem; cursor: pointer; color: var(--text); }
.stepper span { min-width: 26px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.cart-row .rm { border: 0; background: transparent; font-size: 1.1rem; cursor: pointer; color: var(--muted); width: 32px; height: 32px; border-radius: 8px; }
.cart-row .rm:hover { background: var(--bad-bg); color: var(--bad); }

/* แถบเลือกหลายรายการ (ผู้ดูแล) */
.bulk-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .9rem; padding: .55rem .7rem; border: 1px dashed var(--line-strong); border-radius: 14px; background: var(--surface); }
.bulk-bar .spacer { flex: 1; }
.bulk-bar.has-sel { border-style: solid; border-color: var(--primary); background: var(--primary-soft); }
.sel-box { width: 20px; height: 20px; min-height: 0; margin: 0 .5rem 0 0; vertical-align: -4px; accent-color: var(--primary); cursor: pointer; }
.group-tag { display: inline-block; margin-left: .35rem; font-size: .7rem; padding: .08rem .45rem; border-radius: 999px; background: var(--info-bg); color: var(--info-fg); font-weight: 600; vertical-align: 2px; }

/* รายการรอของว่าง */
.waitlist-box { margin-bottom: 1rem; padding-top: 1rem; padding-bottom: .6rem; }
.waitlist-box h3 { margin-bottom: .4rem; }

body.has-cart .container { padding-bottom: 6.5rem; }
@media (max-width: 768px) { body.has-cart .container { padding-bottom: calc(var(--bottomnav-h) + 6rem + env(safe-area-inset-bottom, 0px)); } }

/* ใบยืม (แสดงเฉพาะตอนพิมพ์) */
.slip { display: none; }

@media (max-width: 768px) {
  .cart-fab { right: 1rem; bottom: calc(var(--bottomnav-h) + 1rem + env(safe-area-inset-bottom, 0px)); width: 56px; height: 56px; }
  .bulk-bar .spacer { display: none; }
  .bulk-bar .btn { flex: 1; }
  .card .foot .btns .btn { min-height: 40px; }
}

/* ---------- Print: ป้าย QR หรือ ใบยืม ---------- */
@media print {
  @page { margin: 12mm; }
  body { background: #fff !important; }
  body * { visibility: hidden !important; }
  body:not(.print-slip) #print-area, body:not(.print-slip) #print-area * { visibility: visible !important; }
  body:not(.print-slip) #print-area { position: fixed; left: 0; top: 0; border: 2px dashed #999; width: 7cm; background: #fff; color: #000; }
  body.print-slip #slip, body.print-slip #slip * { visibility: visible !important; }
  body.print-slip #slip { display: block; position: absolute; left: 0; top: 0; width: 100%; color: #000; font-size: 12pt; }
  .slip h1 { font-size: 18pt; margin: 0 0 2mm; }
  .slip .meta { display: flex; justify-content: space-between; gap: 6mm; margin-bottom: 5mm; color: #333; }
  .slip table { width: 100%; min-width: 0; border-collapse: collapse; margin: 3mm 0 6mm; }
  .slip th, .slip td { border: 1px solid #999; padding: 2mm 3mm; font-size: 11pt; text-align: left; color: #000; background: #fff; position: static; text-transform: none; }
  .slip .sig { display: grid; grid-template-columns: 1fr 1fr; gap: 14mm; margin-top: 16mm; text-align: center; }
  .slip .sig div { border-top: 1px dotted #000; padding-top: 2mm; }
  .slip .foot { margin-top: 8mm; font-size: 9pt; color: #555; }
}
.auth-card .check { white-space: normal; flex-wrap: wrap; margin: 0 0 .9rem; }

/* ตัวแบ่งหน้า (ผู้ใช้ / บันทึกระบบ) */
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: 1rem; }
.pager .pages { display: flex; gap: .3rem; align-items: center; flex-wrap: wrap; }
.pager .gap { color: var(--muted); padding: 0 .2rem; }
.pager .per { width: auto; margin: 0 0 0 auto; }
.pager .btn[data-page] { min-width: 2.3rem; }
.date-filter { display: flex; align-items: center; gap: .4rem; margin: 0; font-size: .85rem; color: var(--muted); }
.date-filter input { width: auto; margin: 0; }
#audit-filters select { width: auto; max-width: 260px; }
#audit-filters input[type="search"] { flex: 1 1 220px; }
/* รูปอุปกรณ์: ในตารางจัดการ + ตัวอย่างในหน้าต่างแก้ไข */
.name-cell { display: flex; align-items: center; gap: .65rem; }
.mini-photo { width: 44px; height: 44px; object-fit: cover; border-radius: 10px; flex: none; background: var(--primary-soft); }
.img-preview { display: flex; align-items: center; gap: .75rem; margin: -.3rem 0 .6rem; }
.img-preview img { width: 120px; height: 75px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); background: var(--primary-soft); }
.img-preview.bad img { display: none; }
.img-preview.bad span { color: var(--bad, #c0392b); }
@media (max-width: 760px) {
  .pager .per { margin-left: 0; }
  .date-filter { flex: 1 1 45%; }
  .date-filter input { flex: 1; }
}

/* ชุดที่ยืมพร้อมกัน (ตะกร้า): แถวหัว + รายการย่อย */
.group-row td { background: color-mix(in srgb, var(--primary-soft) 45%, transparent); }
.group-toggle { display: inline-flex; align-items: center; gap: .35rem; padding: .15rem .2rem; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; min-height: 0; }
.group-toggle .chev { display: inline-block; font-size: .7rem; transition: transform .2s var(--ease); color: var(--primary); }
.group-row.open .group-toggle .chev { transform: rotate(90deg); }
.group-row .status { margin: .1rem .15rem .1rem 0; }
.group-child td:first-child { padding-left: 1.6rem; }
.group-child .tree { color: var(--muted); margin-right: .35rem; }
@media (max-width: 760px) { .group-child td:first-child { padding-left: inherit; } }
