/* =========================================================
   TrayCheck Rx — design system
   Colors come from the logo: navy #0a4168, teal #0aa092, green #5ab452
   ========================================================= */

@font-face {
  font-family: "Inter";
  src: url("/fonts/inter-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ---------- Light (default) ---------- */
:root, [data-theme="light"], [data-theme="auto"] {
  --logo-tagline: #0a4168;
  --bg: #f5f7fb;
  --bg-glow: radial-gradient(1200px 500px at 15% -10%, rgba(10, 160, 146, .10), transparent 60%),
             radial-gradient(900px 400px at 95% -20%, rgba(10, 65, 104, .10), transparent 60%);
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-glass: rgba(255, 255, 255, .78);
  --border: #e4e9f0;
  --border-strong: #d2dae5;
  --text: #0f1f33;
  --muted: #5b6b80;
  --accent: #0a4168;          /* primary actions */
  --accent-2: #0d5a8c;
  --accent-text: #ffffff;
  --teal: #0aa092;
  --green: #5ab452;
  --accent-soft: #e3f4f1;     /* active tab, soft buttons */
  --accent-soft-text: #08506b;
  --ring: rgba(10, 160, 146, .32);
  --link: #0b6aa2;
  --head: #f3f6fa;
  --head-text: #5b6b80;
  --row-hover: #f7fafd;
  --ok-bg: #e7f6ec;  --ok-fg: #1d7a3c;
  --warn-bg: #f59e0b; --warn-fg: #2e1b00;
  --warn-soft: #fff3dc; --warn-soft-fg: #93560a;
  --danger-bg: #fdeceb; --danger-fg: #c3362b;
  --info-bg: #e8f1fb; --info-fg: #1d5c9f;
  --none-bg: #eef2f6; --none-fg: #5b6b80;
  --hero: linear-gradient(135deg, #07304f 0%, #0a4168 40%, #0a7f87 80%, #0aa092 100%);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 6px 20px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, .16);
  --radius: 14px;
  --radius-sm: 10px;
  color-scheme: light;
}

/* ---------- Dark ---------- */
[data-theme="dark"] {
  --logo-tagline: #cfe3f5;
  --bg: #0a111d;
  --bg-glow: radial-gradient(1200px 500px at 15% -10%, rgba(10, 160, 146, .16), transparent 60%),
             radial-gradient(900px 400px at 95% -20%, rgba(56, 130, 200, .14), transparent 60%);
  --surface: #111a29;
  --surface-2: #0e1624;
  --surface-glass: rgba(14, 22, 36, .78);
  --border: #1e2a3c;
  --border-strong: #2a3850;
  --text: #e6edf6;
  --muted: #93a3b8;
  --accent: #2ab3a4;
  --accent-2: #3cc4b4;
  --accent-text: #04161a;
  --accent-soft: rgba(42, 179, 164, .14);
  --accent-soft-text: #7fe0d4;
  --ring: rgba(42, 179, 164, .38);
  --link: #6cc8f0;
  --head: #0f1828;
  --head-text: #93a3b8;
  --row-hover: #142033;
  --ok-bg: rgba(52, 168, 83, .16); --ok-fg: #7fdc9a;
  --warn-bg: #f2a33a; --warn-fg: #1e1200;
  --warn-soft: rgba(242, 163, 58, .15); --warn-soft-fg: #f6c27a;
  --danger-bg: rgba(229, 72, 60, .16); --danger-fg: #ff8b80;
  --info-bg: rgba(66, 140, 220, .16); --info-fg: #8fc2f5;
  --none-bg: #1a2536; --none-fg: #93a3b8;
  --shadow-sm: none;
  --shadow: 0 1px 0 rgba(255, 255, 255, .02), 0 8px 24px rgba(0, 0, 0, .35);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

/* No theme chosen yet (and the sign-in page): follow the device setting */
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] {
    --logo-tagline: #cfe3f5;
    --bg: #0a111d;
    --bg-glow: radial-gradient(1200px 500px at 15% -10%, rgba(10, 160, 146, .16), transparent 60%),
               radial-gradient(900px 400px at 95% -20%, rgba(56, 130, 200, .14), transparent 60%);
    --surface: #111a29; --surface-2: #0e1624; --surface-glass: rgba(14, 22, 36, .78);
    --border: #1e2a3c; --border-strong: #2a3850; --text: #e6edf6; --muted: #93a3b8;
    --accent: #2ab3a4; --accent-2: #3cc4b4; --accent-text: #04161a;
    --accent-soft: rgba(42, 179, 164, .14); --accent-soft-text: #7fe0d4; --ring: rgba(42, 179, 164, .38);
    --link: #6cc8f0; --head: #0f1828; --head-text: #93a3b8; --row-hover: #142033;
    --ok-bg: rgba(52, 168, 83, .16); --ok-fg: #7fdc9a; --warn-bg: #f2a33a; --warn-fg: #1e1200;
    --warn-soft: rgba(242, 163, 58, .15); --warn-soft-fg: #f6c27a; --danger-bg: rgba(229, 72, 60, .16); --danger-fg: #ff8b80;
    --info-bg: rgba(66, 140, 220, .16); --info-fg: #8fc2f5; --none-bg: #1a2536; --none-fg: #93a3b8;
    --shadow-sm: none; --shadow: 0 1px 0 rgba(255, 255, 255, .02), 0 8px 24px rgba(0, 0, 0, .35); --shadow-lg: 0 16px 48px rgba(0, 0, 0, .55);
      color-scheme: dark;
  }
}

/* =========================================================
   Base
   ========================================================= */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg-glow), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.55 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
a.plain { color: inherit; }
h1 { font-size: 1.75rem; font-weight: 750; letter-spacing: -0.025em; margin: 4px 0 16px; line-height: 1.2; }
h2 { font-size: 1.08rem; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 12px; }
h3 { font-size: .98rem; font-weight: 650; margin: 12px 0 8px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
code { background: var(--surface-2); border: 1px solid var(--border); padding: 1px 6px; border-radius: 6px; font-size: .88em; word-break: break-word; }
.icon { flex: none; display: inline-block; vertical-align: -0.2em; }
.container { width: 100%; max-width: 1320px; margin: 0 auto; padding: 24px 20px 48px; flex: 1; }
.footer { text-align: center; color: var(--muted); font-size: 12.5px; padding: 20px 16px 28px; letter-spacing: .01em; }
.muted { color: var(--muted); }
.thin { font-weight: 400; }
.small { font-size: 12.5px; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.inline { display: inline; margin: 0; }
.empty { color: var(--muted); margin: 4px 0; padding: 18px; text-align: center; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-2); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.crumbs { margin: 0 0 2px; font-size: 13px; color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row input { flex: 1; min-width: 160px; }
::selection { background: var(--ring); }

/* =========================================================
   Top bar
   ========================================================= */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: var(--surface-glass);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { max-width: 1320px; margin: 0 auto; padding: 0 20px; height: 64px; display: flex; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none !important; flex: none; }
.brand-icon { height: 34px; width: auto; display: block; }
.brand-name { font-weight: 750; font-size: 17px; letter-spacing: -0.02em; white-space: nowrap; }
.nav { display: flex; align-items: center; gap: 2px; }
.tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 11px; border-radius: 10px;
  color: var(--muted); font-size: 14px; font-weight: 550; white-space: nowrap;
  text-decoration: none !important; transition: background .15s, color .15s;
}
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.active { background: var(--accent-soft); color: var(--accent-soft-text); font-weight: 650; }
.tab.active .icon { color: var(--teal); }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  height: 38px; padding: 0 10px 0 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow-sm); white-space: nowrap;
}
.chip span { max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.chip:hover { border-color: var(--border-strong); }
.chip .icon:last-child { color: var(--muted); }
.site-chip .icon:first-child { color: var(--teal); }
.user-chip { padding-left: 4px; }
.avatar {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, #0a4168, #0aa092); color: #fff; font-size: 11.5px; font-weight: 700; letter-spacing: .02em;
}
.who { color: var(--text); }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; width: 250px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 8px;
  box-shadow: var(--shadow-lg); animation: pop .14s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.menu-pop label { display: block; font-weight: 600; font-size: 13px; margin: 6px 6px 10px; }
.menu-pop select { margin-top: 6px; }
.menu-pop form { margin: 0; }
.menu-head { display: flex; flex-direction: column; padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 8px;
  background: none; border: 0; font: inherit; font-size: 14px; color: var(--text); cursor: pointer; text-align: left; text-decoration: none !important;
}
.menu-item:hover { background: var(--surface-2); }
.nav-toggle, .nav-toggle-btn { display: none; }
.topbar:has(.nav-toggle:checked) { background: var(--surface); }
body:has(.auth-split) { overflow-x: hidden; }
body:has(.auth-split) .footer { position: relative; margin-top: -54px; color: color-mix(in srgb, var(--muted) 85%, transparent); }

@media (max-width: 1260px) { .tab .icon { display: none; } .tab { padding: 8px 9px; } }
@media (max-width: 1060px) {
  .topbar-inner { flex-wrap: wrap; height: auto; min-height: 60px; padding: 10px 16px; gap: 10px; }
  .nav-toggle-btn { display: inline-grid; place-items: center; order: 3; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border); cursor: pointer; color: var(--text); background: var(--surface); }
  .nav-right { order: 2; }
  .nav { order: 4; display: none; width: 100%; flex-direction: column; align-items: stretch; padding: 6px 0 4px; }
  .nav-toggle:checked ~ .nav { display: flex; }
  .tab .icon { display: inline-block; }
  .tab { padding: 11px 12px; font-size: 15px; }
  .who { display: none; }
}
@media (max-width: 520px) {
  .brand-name { display: none; }
  .site-chip span { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* =========================================================
   Page structure
   ========================================================= */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { margin-bottom: 2px; }
.page-head p { margin: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.section { margin: 30px 0; }
.section > h2 { margin-bottom: 12px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.section-head h2 { margin: 0; }
.card, .panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.panel > h2:first-child, .card > h2:first-child { margin-top: 0; }
.card.tight { padding: 14px 16px; }
.card.narrow { max-width: 520px; margin: 48px auto; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.card-head h3 { margin: 0; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.three-col { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.admin-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
@media (max-width: 960px) { .two-col, .three-col, .admin-grid { grid-template-columns: 1fr; } }

/* ---------- Dashboard tiles ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat {
  position: relative; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 12px;
  align-items: center; padding: 16px; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow); color: var(--text); text-decoration: none !important;
  transition: transform .15s, box-shadow .15s, border-color .15s; overflow: hidden;
}
.stat:hover { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: var(--shadow-lg); }
.stat-icon { grid-row: span 2; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-soft-text); }
.stat-num { font-size: 1.7rem; font-weight: 750; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: 13px; font-weight: 500; }
.stat-ok .stat-icon { background: var(--ok-bg); color: var(--ok-fg); }
.stat-warn .stat-icon { background: var(--warn-soft); color: var(--warn-soft-fg); }
.stat-danger .stat-icon { background: var(--danger-bg); color: var(--danger-fg); }
.stat-danger .stat-num { color: var(--danger-fg); }

/* ---------- Scan box ---------- */
.scan-box {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 18px 20px; margin-bottom: 18px; border-radius: var(--radius);
  background: linear-gradient(var(--surface), var(--surface)) padding-box,
              linear-gradient(120deg, rgba(10, 65, 104, .35), rgba(10, 160, 146, .55), rgba(90, 180, 82, .45)) border-box;
  border: 1.5px solid transparent; box-shadow: var(--shadow);
}
.scan-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; color: #fff; background: linear-gradient(135deg, #0a4168, #0aa092); flex: none; box-shadow: 0 6px 16px rgba(10, 120, 140, .3); }
.scan-box label { font-weight: 700; display: flex; flex-direction: column; gap: 2px; }
.scan-box label .hint { margin: 0; }
.scan-field { display: flex; gap: 8px; flex: 1 1 360px; max-width: 560px; margin-left: auto; }
.scan-field input { flex: 1; min-width: 0; height: 48px; font-size: 16px; border-radius: 12px; }
.scan-field .btn { height: 48px; border-radius: 12px; }
.scan-box > input { flex: 1 1 320px; max-width: 460px; height: 48px; font-size: 16px; border-radius: 12px; margin-left: auto; }
.cam-launch .icon { color: var(--teal); }
.scan-box > .hint { flex-basis: 100%; margin: 0; }
.scan-result { font-weight: 600; flex-basis: 100%; }
.scan-result:empty { display: none; }
.scan-result.ok { color: var(--ok-fg); }
.scan-result.bad { color: var(--danger-fg); }

/* ---------- Filters ---------- */
.filter-panel {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 16px; box-shadow: var(--shadow-sm);
}
.filter-panel label { display: flex; flex-direction: column; font-weight: 600; font-size: 13px; gap: 5px; color: var(--muted); }
.filter-panel input, .filter-panel select { width: auto; min-width: 160px; }
.filters-toggle summary { cursor: pointer; color: var(--muted); font-size: 13px; margin-bottom: 8px; }

/* ---------- Notices ---------- */
.notice {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; margin-bottom: 10px;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--teal);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-sm);
}
.notice-important { border-left-color: var(--warn-bg); }
.notice-urgent { border-left-color: var(--danger-fg); }
.notice-body { white-space: pre-wrap; }
.tag { display: inline-flex; align-items: center; gap: 4px; background: var(--accent-soft); color: var(--accent-soft-text); font-size: 11.5px; padding: 3px 9px; border-radius: 999px; white-space: nowrap; font-weight: 650; letter-spacing: .01em; }
.tag-important { background: var(--warn-soft); color: var(--warn-soft-fg); }
.tag-urgent { background: var(--danger-bg); color: var(--danger-fg); }
.count { font-size: 11px; font-weight: 650; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; margin-left: 6px; }

/* =========================================================
   Tables
   ========================================================= */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
.table {
  width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow-sm);
}
.table th, .table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th {
  background: var(--head); color: var(--head-text); font-weight: 650; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: .06em; white-space: nowrap;
}
.table tbody tr { transition: background .12s; }
.table tbody tr:hover td { background: var(--row-hover); }
.table tbody tr:last-child td { border-bottom: 0; }
.table th.num, .table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.table th.right { text-align: right; }
.table input { padding: 7px 9px; height: 36px; }
.card .table, .panel .table { box-shadow: none; }
.qty-col { width: 96px; }
.restock-table .qty { width: 84px; }
.restock-table tr.row-hit td { background: var(--ok-bg) !important; transition: background .3s; }
tr.row-expired td:first-child { box-shadow: inset 3px 0 0 var(--danger-fg); }
tr.row-warning td:first-child { box-shadow: inset 3px 0 0 var(--warn-bg); }
.row-flash td { animation: flash 1.8s ease-out; }
@keyframes flash { from { background: var(--ok-bg); } }
tr.inactive td { color: var(--muted); }
.products td:nth-child(1) { min-width: 220px; }
.products td:nth-child(2) { min-width: 140px; }

/* =========================================================
   Status chips
   ========================================================= */
.badge, .due {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 650; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.badge::before, .due::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge-ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge-expiring { background: var(--warn-soft); color: var(--warn-soft-fg); }
.badge-expired { background: var(--danger-bg); color: var(--danger-fg); }
.badge-none { background: var(--none-bg); color: var(--none-fg); }
.date-ok { font-variant-numeric: tabular-nums; color: var(--text); }
.due-overdue { background: var(--danger-bg); color: var(--danger-fg); }
.due-due_soon { background: var(--warn-soft); color: var(--warn-soft-fg); }
.due-open { background: var(--none-bg); color: var(--none-fg); }
.due-done { background: var(--ok-bg); color: var(--ok-fg); }
.pill-status { font-weight: 700; padding: 5px 14px; border-radius: 999px; font-size: 13px; }
.pill-status.on { background: var(--ok-bg); color: var(--ok-fg); }
.pill-status.off { background: var(--none-bg); color: var(--none-fg); }
.kpi-met { background: var(--ok-bg) !important; color: var(--ok-fg); font-weight: 600; }
.kpi-miss { background: var(--danger-bg) !important; color: var(--danger-fg); font-weight: 600; }
.kpi-input { width: 76px; text-align: right; }
.scorecard td, .scorecard th { padding: 9px 10px; }
.bar { position: relative; background: var(--none-bg); border-radius: 999px; height: 22px; min-width: 140px; overflow: hidden; }
.bar::before { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--pct); background: linear-gradient(90deg, var(--teal), var(--green)); border-radius: 999px; opacity: .85; }
.bar span { position: relative; padding-left: 10px; font-size: 12px; font-weight: 700; line-height: 22px; color: var(--text); }

/* =========================================================
   Alerts
   ========================================================= */
.alert { display: flex; gap: 10px; padding: 12px 16px; border-radius: 12px; margin-bottom: 14px; font-size: 14px; border: 1px solid transparent; font-weight: 500; }
.alert ul { margin: 0; padding-left: 18px; }
.alert-success { background: var(--ok-bg); color: var(--ok-fg); border-color: color-mix(in srgb, var(--ok-fg) 20%, transparent); }
.alert-error { background: var(--danger-bg); color: var(--danger-fg); border-color: color-mix(in srgb, var(--danger-fg) 20%, transparent); }
.alert-warning { background: var(--warn-soft); color: var(--warn-soft-fg); border-color: color-mix(in srgb, var(--warn-soft-fg) 20%, transparent); }
.alert-info { background: var(--info-bg); color: var(--info-fg); border-color: color-mix(in srgb, var(--info-fg) 20%, transparent); }

/* =========================================================
   Forms
   ========================================================= */
.form label { display: block; margin-bottom: 16px; font-weight: 600; font-size: 13.5px; }
.form label > input, .form label > select, .form label > textarea, .form .input-suffix { margin-top: 6px; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 14.5px; font-weight: 400; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 9px 12px; min-height: 40px; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 80px; }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--teal) 45%, var(--border-strong)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 4px var(--ring); }
input[type="checkbox"], input[type="radio"] { width: 17px; height: 17px; min-height: 0; accent-color: var(--teal); margin: 2px 0 0; flex: none; box-shadow: none; }
input:disabled, select:disabled { background: var(--surface-2); color: var(--muted); }
.form label.checkbox, .form label.switch, .form label.radio, label.checkbox { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; }
.form label.switch { font-weight: 650; font-size: 15px; padding: 14px 16px; background: var(--accent-soft); color: var(--accent-soft-text); border-radius: 12px; }
fieldset { border: 0; padding: 0; margin: 0 0 16px; }
legend { font-weight: 650; font-size: 13.5px; margin-bottom: 10px; padding: 0; }
.form label.radio { padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 8px; cursor: pointer; }
.form label.radio:has(input:checked) { border-color: var(--teal); background: var(--accent-soft); }
.hint { display: block; font-weight: 400; color: var(--muted); font-size: 12.5px; margin-top: 5px; }
.input-suffix { display: flex; align-items: center; gap: 8px; }
.input-suffix input { max-width: 110px; }
.input-suffix span { font-weight: 400; color: var(--muted); }
.grid-2, .grid-3, .grid-4 { display: grid; gap: 0 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
@media (max-width: 720px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.row-form { display: flex; flex-wrap: wrap; gap: 0 12px; align-items: flex-end; }
.row-form label { flex: 1 1 180px; }
.row-form label.grow { flex: 3 1 260px; }
.row-form .btn, .row-form label.checkbox { margin-bottom: 16px; }
.row-form .hint.full { flex-basis: 100%; margin: -8px 0 0; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px 16px; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.add-box { margin-top: 10px; }
.add-box summary, details.card > summary { cursor: pointer; font-weight: 650; }
details.card > summary { margin: -4px 0; }
details.card[open] > summary { margin-bottom: 12px; }
.danger-zone { margin-top: 18px; color: var(--muted); font-size: 14px; }
.danger-zone summary { cursor: pointer; }
.danger-zone form { margin-top: 10px; }

/* Audit checklist */
.checklist { padding-left: 22px; }
.checklist li { margin-bottom: 20px; }
.checklist .q { margin: 0 0 8px; font-weight: 600; }
.yn { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.form .yn-opt { display: inline-flex; align-items: center; gap: 8px; margin: 0; padding: 7px 16px; border: 1px solid var(--border-strong); border-radius: 999px; font-weight: 600; cursor: pointer; background: var(--surface); }
.yn-opt:has(input:checked).yn-yes { background: var(--ok-bg); border-color: var(--ok-fg); color: var(--ok-fg); }
.yn-opt:has(input:checked).yn-no { background: var(--danger-bg); border-color: var(--danger-fg); color: var(--danger-fg); }
.yn-opt:has(input:checked).yn-na { background: var(--none-bg); border-color: var(--muted); }

/* Lists */
.plain-list { list-style: none; padding: 0; margin: 0; }
.plain-list li { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.plain-list li:last-child { border-bottom: 0; }
.plain-list li.done > span:first-child { text-decoration: line-through; color: var(--muted); }
.link-list { list-style: none; padding: 0; margin: 0; }
.link-list li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.link-list li:last-child { border-bottom: 0; }
.link-list a { font-weight: 650; }
.link-list span { display: block; color: var(--muted); font-size: 13px; }

/* =========================================================
   Buttons
   ========================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 40px; padding: 0 16px; border-radius: var(--radius-sm);
  font: inherit; font-size: 14px; font-weight: 650; letter-spacing: -0.005em;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  text-decoration: none !important; cursor: pointer; white-space: nowrap;
  box-shadow: var(--shadow-sm); transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.btn:hover { border-color: var(--teal); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--ring); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(180deg, var(--accent-2), var(--accent)); border-color: var(--accent); color: var(--accent-text);
  box-shadow: 0 1px 2px rgba(10, 40, 70, .2), inset 0 1px 0 rgba(255, 255, 255, .12);
}
.btn-primary:hover { filter: brightness(1.08); border-color: var(--accent); color: var(--accent-text); }
.btn-soft { background: var(--accent-soft); border-color: transparent; color: var(--accent-soft-text); box-shadow: none; }
.btn-soft:hover { border-color: color-mix(in srgb, var(--teal) 50%, transparent); }
.btn-outline { background: var(--surface); }
.btn-danger { color: var(--danger-fg); border-color: color-mix(in srgb, var(--danger-fg) 45%, transparent); background: transparent; box-shadow: none; }
.btn-danger:hover { background: var(--danger-bg); border-color: var(--danger-fg); }
.btn-small { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-lg { height: 46px; font-size: 15px; }
.btn-block { width: 100%; }
.linklike { background: none; border: 0; font: inherit; cursor: pointer; color: var(--link); padding: 0; }
.linklike.danger { color: var(--danger-fg); }

/* Tabs (in-page) */
.tabs { display: inline-flex; gap: 4px; padding: 4px; margin-bottom: 16px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; }
.tabs a { padding: 7px 14px; color: var(--muted); font-size: 14px; font-weight: 600; border-radius: 9px; text-decoration: none !important; }
.tabs a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* =========================================================
   Sign-in / setup
   ========================================================= */
.auth-split { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: calc(100vh - 66px); width: 100vw; margin: -24px 0 0 calc(50% - 50vw); }
.auth-hero { position: relative; background: var(--hero); color: #fff; border-radius: 0 28px 28px 0; overflow: hidden; display: flex; align-items: center; }
.auth-hero::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(600px 400px at 80% 10%, rgba(90, 180, 82, .35), transparent 60%),
              radial-gradient(500px 500px at 0% 100%, rgba(255, 255, 255, .10), transparent 60%);
}
.auth-hero::after {
  content: ""; position: absolute; inset: 0; opacity: .12;
  background-image: linear-gradient(rgba(255,255,255,.6) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.6) 1px, transparent 1px);
  background-size: 44px 44px; mask-image: linear-gradient(180deg, transparent, #000 40%, transparent);
}
.hero-inner { position: relative; z-index: 1; padding: 56px; max-width: 560px; }
.eyebrow { text-transform: uppercase; letter-spacing: .16em; font-size: 12px; font-weight: 700; color: rgba(255, 255, 255, .75); margin: 0 0 14px; }
.auth-hero h2 { font-size: 2.6rem; line-height: 1.1; letter-spacing: -0.035em; font-weight: 800; margin: 0 0 28px; }
.hero-points { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.hero-points li { display: flex; align-items: center; gap: 12px; font-size: 15.5px; color: rgba(255, 255, 255, .92); }
.hero-points .icon { width: 34px; height: 34px; padding: 8px; border-radius: 10px; background: rgba(255, 255, 255, .14); box-sizing: border-box; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth { width: 100%; max-width: 420px; margin: 0 auto; }
.auth.wide { max-width: 760px; margin-top: 32px; }
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-brand h1 { margin: 14px 0 4px; }
.auth h2 { font-size: 1rem; margin-top: 6px; }
.form-title { font-size: 1.25rem !important; margin: 0 0 16px !important; letter-spacing: -0.02em; }
.motto { text-align: center; color: var(--muted); font-size: 13px; margin: 18px 0 0; letter-spacing: .02em; }
.logo-tile { display: inline-block; padding: 12px 0; }
.logo-full { width: 100%; max-width: 360px; height: auto; display: block; margin: 0 auto; }
.logo-tagline { display: block; margin-top: 8px; color: var(--logo-tagline); font-size: 12.5px; font-weight: 650; letter-spacing: .2em; text-transform: uppercase; text-align: center; }
/* Dark mode swaps in the light-lettered logo, shown straight on the dark background */
.logo-dark { display: none !important; }
[data-theme="dark"] .logo-light { display: none !important; }
[data-theme="dark"] .logo-dark { display: block !important; }
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] .logo-light { display: none !important; }
  [data-theme="auto"] .logo-dark { display: block !important; }
}
@media (max-width: 900px) {
  .auth-split { grid-template-columns: 1fr; min-height: 0; }
  .auth-hero { display: none; }
}

/* Support access banner */
.support-bar { background: #b45309; color: #fff; }
.support-inner { max-width: 1320px; margin: 0 auto; padding: 8px 20px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; font-size: 13.5px; }
.support-bar .btn { background: #fff; color: #7c2d12; border-color: transparent; }

/* Invitations & platform */
.invite-link { border-color: var(--teal); background: var(--accent-soft); }
.invite-link input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.menu-org { padding: 0 10px 6px; }
/* Platform: one organization */
.org-manage { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.org-main, .org-side { display: grid; gap: 18px; }
.org-manage .card { margin: 0; }
.org-manage h3 { font-size: 14px; margin: 18px 0 4px; }
.org-list { list-style: none; padding: 0; margin: 0; }
.org-list li { padding: 9px 0; border-bottom: 1px solid var(--border); line-height: 1.4; }
.org-list li:last-child { border-bottom: 0; }
@media (max-width: 860px) { .org-manage { grid-template-columns: 1fr; } }

/* Drug approval */
.attention { display: flex; align-items: center; gap: 14px; padding: 14px 18px; margin-bottom: 16px; border-radius: var(--radius); background: var(--warn-soft); color: var(--warn-soft-fg); border: 1px solid color-mix(in srgb, var(--warn-soft-fg) 25%, transparent); text-decoration: none !important; }
.attention > span:nth-child(2) { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.attention .muted { color: inherit; opacity: .85; }
.attention-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: color-mix(in srgb, var(--warn-soft-fg) 15%, transparent); flex: none; }
.review-card .row-form { margin-top: 8px; }
.reject-form { border-top: 1px dashed var(--border); padding-top: 12px; }
td .badge { margin-top: 6px; }
.hint.ok { color: var(--ok-fg); font-weight: 600; }
.hint.warn { color: var(--warn-soft-fg); font-weight: 600; }

/* =========================================================
   Camera scanner
   ========================================================= */
html.cam-open, html.cam-open body { overflow: hidden; }
.cam { position: fixed; inset: 0; z-index: 200; background: #000; color: #fff; display: flex; flex-direction: column; }
.cam-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cam-frame {
  position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%);
  width: min(78vw, 420px); height: min(48vh, 300px); border-radius: 22px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .5); border: 3px solid rgba(255, 255, 255, .9);
}
.cam-frame::after { content: ""; position: absolute; left: 8%; right: 8%; top: 50%; height: 2px; background: linear-gradient(90deg, transparent, #5ab452, transparent); animation: scanline 1.8s ease-in-out infinite; }
@keyframes scanline { 0%, 100% { transform: translateY(-90px); } 50% { transform: translateY(90px); } }
.cam-frame.hit { border-color: #5ab452; animation: hit .35s ease-out; }
@keyframes hit { from { transform: translate(-50%, -50%) scale(1.04); } }
.cam-top, .cam-bottom { position: relative; z-index: 1; display: flex; align-items: center; gap: 12px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.cam-top { padding-top: calc(14px + env(safe-area-inset-top, 0px)); padding-bottom: 14px; justify-content: space-between; background: linear-gradient(rgba(0,0,0,.55), transparent); }
.cam-title { font-weight: 700; font-size: 16px; text-align: center; flex: 1; }
.cam-btn-round { width: 44px; height: 44px; border-radius: 50%; border: 0; display: grid; place-items: center; background: rgba(255, 255, 255, .16); color: #fff; cursor: pointer; backdrop-filter: blur(6px); }
.cam-btn-round.on { background: #f5c542; color: #1b1300; }
.cam-top .cam-torch[hidden] { visibility: hidden; display: grid !important; }
.cam-bottom { margin-top: auto; flex-direction: column; padding-top: 24px; padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)); background: linear-gradient(transparent, rgba(0,0,0,.7)); }
.cam-status { font-size: 15px; font-weight: 600; text-align: center; max-width: 520px; text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.cam-status.bad { color: #ffb4ab; }
.cam-count { font-size: 13px; color: rgba(255, 255, 255, .75); min-height: 18px; }
.cam-done { width: min(100%, 420px); }
@media (prefers-reduced-motion: reduce) { .cam-frame::after { animation: none; } }

/* =========================================================
   Phones
   ========================================================= */
@media (max-width: 640px) {
  .container { padding: 16px 14px 40px; }
  h1 { font-size: 1.45rem; }
  input, select, textarea { font-size: 16px; }            /* stops iPhone zooming into fields */
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 12px; column-gap: 10px; }
  .stat-icon { width: 34px; height: 34px; border-radius: 10px; }
  .stat-num { font-size: 1.4rem; }
  .scan-box { padding: 14px; gap: 12px; }
  .scan-icon { width: 40px; height: 40px; border-radius: 12px; }
  .scan-box label { flex: 1 1 0; min-width: 0; }
  .scan-field { flex-basis: 100%; max-width: none; margin-left: 0; }
  .scan-field input, .scan-field .btn { height: 52px; }
  .page-head .actions { width: 100%; }
  .section-head .actions .btn, .section-head > .btn { height: 34px; }
  .card, .panel { padding: 16px; }
  .filter-panel label, .filter-panel input, .filter-panel select { width: 100%; min-width: 0; }
  .row-form label { flex-basis: 100%; }
  .row-form .btn { flex: 1 1 auto; }

  /* Tables become a stack of cards with labeled fields */
  .table:not(.no-stack) { border: 0; background: none; box-shadow: none; border-radius: 0; overflow: visible; }
  .table:not(.no-stack) thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table:not(.no-stack) tbody { display: grid; gap: 10px; }
  .table:not(.no-stack) tr { display: grid; gap: 8px; padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-sm); }
  .table:not(.no-stack) tbody tr:hover td { background: none; }
  .table:not(.no-stack) td { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0; border: 0; text-align: right; min-width: 0; }
  .table:not(.no-stack) td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; text-align: left; flex: none; }
  .table:not(.no-stack) td:first-child { display: block; text-align: left; font-weight: 650; font-size: 15px; }
  .table:not(.no-stack) td:first-child::before { content: none; }
  .table:not(.no-stack) td[data-label=""]::before, .table:not(.no-stack) td:not([data-label])::before { content: none; }
  .table:not(.no-stack) td.num { text-align: right; }
  .table:not(.no-stack) td:empty { display: none; }
  .table:not(.no-stack) td.right:last-child { justify-content: flex-end; }
  .table:not(.no-stack) td.right:last-child .btn { flex: 1; }
  .table:not(.no-stack) td.right:last-child form { display: flex; flex: 1; }
  .table:not(.no-stack) td input:not([type="checkbox"]):not([type="radio"]), .table:not(.no-stack) td select { flex: 1; max-width: 70%; }
  tr.row-expired td:first-child, tr.row-warning td:first-child { box-shadow: none; }
  .table:not(.no-stack) tr.row-expired { border-left: 4px solid var(--danger-fg); }
  .table:not(.no-stack) tr.row-warning { border-left: 4px solid var(--warn-bg); }
  .card .table:not(.no-stack) tr, .panel .table:not(.no-stack) tr { box-shadow: none; }
  .restock-table td .qty { max-width: 90px; }
  .table-wrap:has(.table:not(.no-stack)) { overflow: visible; }
}

/* =========================================================
   Print
   ========================================================= */
.print-only { display: none; }
@media print {
  .no-print, .topbar, .footer, .btn, form .form-actions { display: none !important; }
  .print-only { display: table-cell; }
  body { background: #fff; color: #000; }
  .container { max-width: none; padding: 0; }
  .card, .panel, .table { border-color: #999; box-shadow: none; }
  .table th { background: #eee !important; color: #000; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .kpi-met, .kpi-miss, .badge, .due { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.print-page { padding: 24px; display: block; background: #fff; }
.print-page .sign { min-width: 90px; }
