/* ClinicDesk — layout: fixed left rail + work area; the token queue is the hero; patient card styled as an OPD slip with QR. */
:root {
  --bg: #F2F5F4;
  --surface: #FFFFFF;
  --surface-2: #F7FAF9;
  --ink: #13221F;
  --muted: #5B6B68;
  --faint: #8A9996;
  --line: #DCE4E1;
  --brand: #0E6B5C;
  --brand-strong: #0A5246;
  --brand-ink: #FFFFFF;
  --brand-soft: #E0F0EB;
  --accent: #D9822B;
  --accent-text: #9A5410;
  --accent-soft: #FCEEDC;
  --info: #3556A8;
  --info-soft: #E6ECFA;
  --ok: #1F7A4D;
  --ok-soft: #E1F3E8;
  --danger: #B3261E;
  --danger-soft: #FBE7E5;
  --shadow: 0 1px 2px rgba(19, 34, 31, .06), 0 8px 24px -12px rgba(19, 34, 31, .18);
  --radius: 12px;
  --tok-on-brand: #F6B566;

  --f-display: "Manrope", "Noto Sans Devanagari", "Segoe UI", system-ui, sans-serif;
  --f-body: "Figtree", "Noto Sans Devanagari", "Segoe UI", system-ui, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --rail-w: 248px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0D1615; --surface: #142120; --surface-2: #192927; --ink: #E2ECE9; --muted: #98AAA6; --faint: #6F817D;
    --line: #253735; --brand: #3FBFA5; --brand-strong: #5FD3BB; --brand-ink: #04201A; --brand-soft: #16362F;
    --accent: #F0A54A; --accent-text: #F4BB72; --accent-soft: #3A2A14; --info: #8FA9F2; --info-soft: #1D2846;
    --ok: #5BCB92; --ok-soft: #15362A; --danger: #F2887B; --danger-soft: #3E1D1A; --tok-on-brand: #04201A;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -14px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0D1615; --surface: #142120; --surface-2: #192927; --ink: #E2ECE9; --muted: #98AAA6; --faint: #6F817D;
  --line: #253735; --brand: #3FBFA5; --brand-strong: #5FD3BB; --brand-ink: #04201A; --brand-soft: #16362F;
  --accent: #F0A54A; --accent-text: #F4BB72; --accent-soft: #3A2A14; --info: #8FA9F2; --info-soft: #1D2846;
  --ok: #5BCB92; --ok-soft: #15362A; --danger: #F2887B; --danger-soft: #3E1D1A; --tok-on-brand: #04201A;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -14px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 var(--f-body); -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
h1, h2, h3 { font-family: var(--f-display); margin: 0; text-wrap: balance; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; font-weight: 800; line-height: 1.2; }
h2 { font-size: 1.12rem; font-weight: 700; }
h3 { font-size: .98rem; font-weight: 700; }
.mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
svg.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); min-height: 100%; }
.rail {
  position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 4px;
  padding: max(18px, env(safe-area-inset-top, 0px)) 14px 16px max(14px, env(safe-area-inset-left, 0px));
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--brand); display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 7px; }
.brand-mark i { background: var(--brand-ink); border-radius: 2px; }
.brand-mark i:last-child { background: var(--accent); border-radius: 50%; }
.brand-name { font: 800 1.08rem/1.1 var(--f-display); }
.brand-clinic { font-size: .78rem; color: var(--muted); line-height: 1.25; }
.nav-label { font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); padding: 14px 10px 4px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 9px;
  color: var(--muted); text-decoration: none; font-weight: 600;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand-strong); }
.nav a .kbd { margin-left: auto; }
.rail-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 8px; }
.me { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); display: grid; place-items: center; font: 700 .85rem var(--f-display); flex: none; }
.me-name { font-weight: 600; font-size: .9rem; line-height: 1.2; }
.role-chip { font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
  padding-block: 10px; padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(24px, env(safe-area-inset-right, 0px));
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--bg); }
.menu-btn { display: none; }
.gsearch { position: relative; flex: 1; max-width: 560px; }
.gsearch input {
  width: 100%; padding: 10px 44px 10px 40px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); outline: none;
}
.gsearch input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.gsearch > svg.i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.gsearch .kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); }
.kbd { font: 600 .72rem var(--f-mono); color: var(--muted); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; background: var(--surface-2); }
.suggest {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); padding: 6px; z-index: 40; max-height: 70vh; overflow: auto;
}
.suggest button { width: 100%; text-align: left; display: flex; gap: 12px; align-items: center; padding: 9px 10px; border: 0; background: none; border-radius: 8px; cursor: pointer; }
.suggest button:hover, .suggest button.active { background: var(--surface-2); }
.top-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.icon-btn:hover { color: var(--ink); border-color: var(--faint); }
.lang-btn { width: auto; padding: 0 12px; font-weight: 700; font-size: .85rem; }

.page {
  width: 100%; max-width: 1280px; margin: 0 auto; display: grid; gap: 20px; align-content: start;
  padding-block: 24px 96px; padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(24px, env(safe-area-inset-right, 0px));
}
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.eyebrow { font-size: .72rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--brand); margin-bottom: 4px; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 16px;
  border-radius: 10px; border: 1px solid transparent; font-weight: 700; cursor: pointer; text-decoration: none; white-space: nowrap;
  background: var(--brand); color: var(--brand-ink); transition: background .15s, transform .05s;
}
.btn:hover { background: var(--brand-strong); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn.secondary:hover { border-color: var(--faint); background: var(--surface-2); }
.btn.ghost { background: transparent; color: var(--brand); }
.btn.ghost:hover { background: var(--brand-soft); }
.btn.accent { background: var(--accent); color: #2A1702; }
.btn.accent:hover { filter: brightness(1.05); background: var(--accent); }
.btn.sm { min-height: 32px; padding: 4px 11px; font-size: .85rem; border-radius: 8px; }
.btn.lg { min-height: 48px; padding: 10px 22px; font-size: 1.02rem; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font-size: .82rem; font-weight: 600; color: var(--muted); }
.field > span b { color: var(--danger); font-weight: 700; }
.input, .field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { resize: vertical; min-height: 84px; line-height: 1.45; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.field input[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.field .hint { font-size: .8rem; color: var(--faint); }
.field .err { font-size: .8rem; color: var(--danger); font-weight: 600; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.grid-5 { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.span-2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }

.seg { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--line); border-radius: 10px; padding: 3px; background: var(--surface-2); gap: 3px; }
.seg label { cursor: pointer; position: relative; }
.seg input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; padding: 6px 12px; border-radius: 7px; font-weight: 600; font-size: .9rem; color: var(--muted); }
.seg input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.seg input:focus-visible + span { outline: 2px solid var(--brand); }

.check { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--brand); margin-top: 1px; flex: none; }
.check.on { border-color: var(--brand); background: var(--brand-soft); }
.card.dim { opacity: .6; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 3px 10px; font-size: .8rem; font-weight: 600; cursor: pointer; color: var(--muted); }
.chip:hover { border-color: var(--brand); color: var(--brand); }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card-pad { padding: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-body { padding: 18px; display: grid; gap: 14px; }
.layout-main { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.stack { display: grid; gap: 20px; align-content: start; min-width: 0; }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: .75rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.waiting { background: var(--info-soft); color: var(--info); }
.pill.in_consult { background: var(--accent-soft); color: var(--accent-text); }
.pill.done { background: var(--ok-soft); color: var(--ok); }
.tag { display: inline-block; font: 700 .66rem/1 var(--f-body); letter-spacing: .07em; text-transform: uppercase; padding: 4px 6px; border-radius: 5px; vertical-align: middle; }
.tag.new { background: var(--brand-soft); color: var(--brand-strong); }
.tag.old { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }

/* ---------- today ---------- */
.stats { display: grid; grid-template-columns: 1.4fr repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 4px; min-width: 0; }
.stat .k { font-size: .78rem; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat .v { font: 800 1.8rem/1.1 var(--f-display); font-variant-numeric: tabular-nums; }
.stat .split { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; display: flex; margin-top: 6px; }
.stat .split i { display: block; height: 100%; background: var(--brand); }
.stat .split i + i { background: var(--accent); }
.stat .legend { display: flex; gap: 12px; font-size: .78rem; color: var(--muted); }
.stat .legend b { color: var(--ink); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; font-weight: 600; color: var(--muted); cursor: pointer; font-size: .9rem; }
.tabs button[aria-selected="true"] { background: var(--ink); color: var(--surface); }
.tabs button .n { font-family: var(--f-mono); font-size: .8rem; opacity: .7; margin-left: 4px; }

.queue { display: grid; }
.q-row {
  display: grid; grid-template-columns: 76px minmax(0, 1.4fr) minmax(0, 1fr) auto; gap: 16px; align-items: center;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.q-row:last-child { border-bottom: 0; }
.q-row.is-consult { background: linear-gradient(90deg, var(--accent-soft), transparent 60%); }
.q-row.is-done { opacity: .62; }
.q-token { font: 800 2rem/1 var(--f-mono); color: var(--accent); text-align: center; letter-spacing: -.04em; }
.q-token small { display: block; font: 700 .62rem var(--f-body); letter-spacing: .1em; color: var(--faint); margin-bottom: 3px; text-transform: uppercase; }
.q-name { font-weight: 700; font-size: 1rem; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.q-name a { color: inherit; text-decoration: none; }
.q-name a:hover { color: var(--brand); text-decoration: underline; }
.q-meta { font-size: .82rem; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.q-complaint { font-size: .9rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.q-actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }

.empty { padding: 36px 20px; text-align: center; color: var(--muted); display: grid; gap: 12px; justify-items: center; }
.empty svg.i { width: 34px; height: 34px; color: var(--faint); }

.fu { display: grid; }
.fu a { display: flex; justify-content: space-between; gap: 10px; padding: 11px 18px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; align-items: center; }
.fu a:last-child { border-bottom: 0; }
.fu a:hover { background: var(--surface-2); }

.bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; height: 128px; padding: 4px 4px 0; }
.bar { display: grid; gap: 4px; justify-items: center; align-content: end; height: 100%; }
.bar i { display: block; width: 100%; max-width: 28px; border-radius: 6px 6px 2px 2px; background: var(--brand-soft); border: 1px solid color-mix(in srgb, var(--brand) 30%, transparent); min-height: 3px; }
.bar.today i { background: var(--brand); border-color: var(--brand); }
.bar b { font: 700 .75rem var(--f-mono); }
.bar span { font-size: .7rem; color: var(--faint); }

/* ---------- register ---------- */
.reg-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.section-title { display: flex; align-items: center; gap: 10px; font: 700 .78rem var(--f-body); letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.dup {
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line)); background: var(--accent-soft); border-radius: 12px; padding: 14px; display: grid; gap: 10px;
}
.dup-head { display: flex; gap: 8px; align-items: center; font-weight: 700; color: var(--accent-text); }
.dup-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--surface); border-radius: 10px; padding: 10px 12px; flex-wrap: wrap; }
details.more summary { cursor: pointer; font-weight: 600; color: var(--brand); list-style: none; display: flex; align-items: center; gap: 6px; }
details.more summary::-webkit-details-marker { display: none; }
details.more[open] summary { margin-bottom: 12px; }

/* live card preview */
.preview-wrap { position: sticky; top: 84px; display: grid; gap: 10px; }

/* ---------- OPD card ---------- */
.opd {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow);
}
.opd-top { background: var(--brand); color: var(--brand-ink); padding: 14px 16px; display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.opd-top .cn { font: 800 1.02rem/1.2 var(--f-display); }
.opd-top .dn { font-size: .8rem; opacity: .85; }
.opd-tok { text-align: right; }
.opd-tok small { display: block; font-size: .62rem; letter-spacing: .1em; text-transform: uppercase; opacity: .8; font-weight: 700; }
.opd-tok b { font: 800 1.8rem/1 var(--f-mono); color: var(--tok-on-brand); }
.opd-body { padding: 16px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: start; }
.opd-id { font: 700 1.08rem var(--f-mono); letter-spacing: .02em; }
.opd dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; margin: 10px 0 0; font-size: .88rem; }
.opd dt { color: var(--muted); }
.opd dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.qr-box { background: #fff; padding: 6px; border-radius: 8px; border: 1px solid var(--line); line-height: 0; }
.qr-box svg { width: 116px; height: 116px; display: block; }
.qr-box.tf-qr { width: max-content; margin: 0 auto 8px; }
.qr-box.tf-qr svg { width: 176px; height: 176px; }
.recovery-codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 16px; padding: 12px; border: 1px dashed var(--line); border-radius: 8px; font-size: 1rem; }
.qr-cap { font-size: .68rem; text-align: center; color: var(--muted); margin-top: 6px; line-height: 1.2; }
.opd-foot { border-top: 1px dashed var(--line); padding: 10px 16px; font-size: .78rem; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.placeholder { color: var(--faint); font-weight: 500; }

/* ---------- patient ---------- */
.p-hero { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 20px; align-items: center; padding: 20px; }
.p-avatar { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; font: 800 1.4rem var(--f-display); background: var(--brand-soft); color: var(--brand-strong); }
.p-name { font: 800 1.5rem/1.15 var(--f-display); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.p-facts { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 8px; color: var(--muted); font-size: .9rem; }
.p-facts span { display: inline-flex; gap: 6px; align-items: center; }
.p-facts b { color: var(--ink); font-weight: 600; }
.copy { border: 0; background: var(--surface-2); border-radius: 6px; padding: 2px 8px; font: 700 .9rem var(--f-mono); cursor: pointer; color: var(--ink); display: inline-flex; gap: 6px; align-items: center; }
.copy:hover { background: var(--brand-soft); }
.p-qr { display: grid; justify-items: center; gap: 6px; }
.p-actions { display: flex; gap: 8px; flex-wrap: wrap; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }

.timeline { display: grid; gap: 0; position: relative; }
.tl-item { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 16px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.tl-item:last-child { border-bottom: 0; }
.tl-date { display: grid; gap: 2px; align-content: start; }
.tl-date b { font: 700 .95rem var(--f-display); }
.tl-date span { font-size: .78rem; color: var(--faint); }
.tl-content { display: grid; gap: 8px; min-width: 0; }
.vitals { display: flex; flex-wrap: wrap; gap: 6px; }
.vital { font-size: .78rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 7px; padding: 2px 8px; color: var(--muted); }
.vital b { color: var(--ink); font-family: var(--f-mono); font-weight: 700; }
.rx { white-space: pre-wrap; font-size: .92rem; background: var(--surface-2); border-left: 3px solid var(--brand); padding: 8px 12px; border-radius: 0 8px 8px 0; }
.kv { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 4px 12px; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

.consult { border: 2px solid var(--accent); border-radius: 14px; background: var(--surface); }
.consult .card-head { background: var(--accent-soft); border-radius: 12px 12px 0 0; border-bottom-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.locked { font-size: .85rem; color: var(--muted); background: var(--surface-2); border: 1px dashed var(--line); border-radius: 10px; padding: 10px 12px; }

/* lab reports */
.tests { display: flex; gap: 8px; align-items: flex-start; font-size: .9rem; background: var(--info-soft); color: var(--ink); border-radius: 8px; padding: 7px 10px; }
.tests svg.i { color: var(--info); margin-top: 2px; }
.r-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.r-chip { display: inline-flex; gap: 5px; align-items: center; color: var(--brand-strong); border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); }
.r-chip svg.i { width: 14px; height: 14px; }
.pending { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line)); color: var(--accent-text); border-radius: var(--radius); padding: 12px 16px; font-weight: 600; }
.pending > span { flex: 1; min-width: 200px; }
.r-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; padding: 18px; }
.r-card { display: grid; gap: 8px; text-align: left; background: none; border: 1px solid var(--line); border-radius: 12px; padding: 8px; cursor: pointer; color: inherit; min-width: 0; }
.r-card:hover { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.r-thumb { aspect-ratio: 4 / 5; border-radius: 8px; overflow: hidden; background: var(--surface-2); display: grid; place-items: center; align-content: center; gap: 4px; color: var(--muted); }
.r-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.r-thumb svg.i { width: 34px; height: 34px; }
.r-meta { display: grid; gap: 1px; min-width: 0; }
.r-meta b { font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drop { border: 2px dashed var(--line); border-radius: 14px; padding: 22px 16px; display: grid; gap: 12px; justify-items: center; text-align: center; background: var(--surface-2); }
.drop > svg.i { width: 30px; height: 30px; color: var(--faint); }
.drop.over { border-color: var(--brand); background: var(--brand-soft); }
.u-previews { display: flex; gap: 10px; flex-wrap: wrap; }
.u-previews:empty { display: none; }
.u-prev { position: relative; width: 84px; height: 104px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); display: grid; place-items: center; align-content: center; color: var(--muted); }
.u-prev img { width: 100%; height: 100%; object-fit: cover; }
.u-prev .icon-btn { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 7px; }
.document-camera { width: 100%; display: grid; gap: 10px; text-align: left; }
.document-camera[hidden] { display: none; }
.document-camera video { width: 100%; max-height: 55vh; object-fit: contain; background: #111; border-radius: 8px; }
#w-prev .u-prev { width: 150px; height: 190px; }
#w-prev .u-prev img { object-fit: contain; }
.r-view { background: var(--surface-2); border-radius: 10px; overflow: auto; max-height: 70vh; text-align: center; }
.r-view img { max-width: 100%; display: block; margin: 0 auto; }
.btn.danger { background: var(--danger); color: #fff; }

/* advised tests */
.t-list { display: grid; gap: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.t-head { display: flex; gap: 8px; align-items: center; font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 8px 12px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.t-head svg.i { width: 15px; height: 15px; }
.t-row { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 10px 12px; border-bottom: 1px solid var(--line); border-left: 4px solid transparent; transition: background .3s; }
.t-row:last-child { border-bottom: 0; }
.t-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; background: var(--faint); display: inline-block; flex: none; }
.t-awaited { border-left-color: var(--accent); } .t-awaited .t-dot, .t-dot.t-awaited { background: var(--accent); }
.t-pending { border-left-color: var(--danger); background: var(--danger-soft); } .t-pending .t-dot, .t-dot.t-pending { background: var(--danger); }
.t-pending .t-status { color: var(--danger); font-weight: 700; }
.t-ok { border-left-color: var(--ok); } .t-ok .t-dot, .t-dot.t-ok { background: var(--ok); }
.t-ok .t-status { color: var(--ok); font-weight: 600; }
.t-closed { border-left-color: var(--line); } .t-closed .t-dot, .t-dot.t-closed { background: var(--faint); }
.t-closed b { color: var(--muted); }
.t-awaited .t-status { color: var(--accent-text); font-weight: 600; }
.t-main { min-width: 0; display: grid; gap: 4px; }
.t-status { font-size: .86rem; color: var(--muted); }
.t-values { font: 600 .85rem var(--f-mono); background: var(--surface-2); border-radius: 6px; padding: 3px 8px; width: fit-content; max-width: 100%; overflow-wrap: anywhere; }
.t-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.t-trail { font-size: .8rem; color: var(--muted); }
.t-trail summary { cursor: pointer; width: fit-content; }
.t-trail ol { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 2px; }
.t-row.flash { background: var(--accent-soft); }
.t-compact .t-row { padding: 8px 10px; }
.t-picks { display: grid; gap: 6px; }
.t-pick-row { display: flex; gap: 8px; align-items: center; }
.t-pick-row .t-pick { flex: 1; min-width: 0; }
.t-pick-row .btn { flex-shrink: 0; }
.t-pick { display: grid; grid-template-columns: auto 12px minmax(0, 1fr); gap: 10px; align-items: center; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.t-pick input { width: 18px; height: 18px; accent-color: var(--brand); margin: 0; }
.t-pick .t-dot { margin-top: 0; }
.t-pick:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.pending.red { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); color: var(--danger); }
.q-flag { display: inline-flex; gap: 3px; align-items: center; font: 700 .75rem var(--f-mono); color: var(--danger); background: var(--danger-soft); border-radius: 999px; padding: 2px 8px 2px 6px; }
.q-flag svg.i { width: 14px; height: 14px; }
.r-covers { display: flex; gap: 4px; align-items: center; font-size: .75rem; color: var(--ok); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-covers svg.i { width: 13px; height: 13px; flex: none; }
.reasons { display: grid; gap: 8px; }
.reasons .check { padding: 10px 12px; align-items: center; }
.reasons .check input { margin-top: 0; }
.slip-pend { font-size: 9pt; background: #FFF4E5; border-radius: 1.5mm; padding: 1.5mm 3mm; }
@media (max-width: 640px) {
  .t-row { grid-template-columns: 12px minmax(0, 1fr); }
  .t-actions { grid-column: 2; justify-content: flex-start; }
}

/* ---------- find ---------- */
.scan-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.big-search { position: relative; }
.big-search input { width: 100%; font-size: 1.1rem; padding: 16px 16px 16px 48px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); outline: none; }
.big-search input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.big-search svg.i { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); width: 22px; height: 22px; color: var(--faint); }
.camera { position: relative; aspect-ratio: 4 / 3; max-width: 100%; background: #0B1312; border-radius: 14px; overflow: hidden; display: grid; place-items: center; color: #CFE3DE; }
.camera video { width: 100%; height: 100%; object-fit: cover; }
.camera .reticle { position: absolute; inset: 18%; border-radius: 14px; box-shadow: 0 0 0 9999px rgba(0,0,0,.35); border: 2px solid rgba(255,255,255,.85); }
.camera .scanline { position: absolute; left: 18%; right: 18%; height: 2px; background: var(--accent); top: 50%; box-shadow: 0 0 12px var(--accent); }
@media (prefers-reduced-motion: no-preference) { .camera .scanline { animation: scan 2s ease-in-out infinite; } @keyframes scan { 0%, 100% { top: 22%; } 50% { top: 78%; } } }
.camera-idle { display: grid; gap: 12px; justify-items: center; text-align: center; padding: 20px; }
.camera-idle svg.i { width: 44px; height: 44px; opacity: .8; }
.results { display: grid; }
.res { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.res:last-child { border-bottom: 0; }
.res:hover { background: var(--surface-2); }
.res .avatar { background: var(--brand-soft); color: var(--brand-strong); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; font-variant-numeric: tabular-nums; }
th { text-align: left; font-size: .72rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--faint); padding: 10px 18px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
td { padding: 12px 18px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tr.link { cursor: pointer; }
tr.link:hover td { background: var(--surface-2); }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }

/* ---------- login ---------- */
.login { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.login-art {
  background: var(--brand); color: var(--brand-ink); padding: 48px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px;
  position: relative; overflow: hidden;
}
.login-art::after {
  content: ""; position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px; border-radius: 50%;
  border: 60px solid color-mix(in srgb, var(--brand-ink) 8%, transparent);
}
.login-art h1 { font-size: clamp(1.8rem, 3vw, 2.6rem); max-width: 16ch; color: var(--brand-ink); }
.login-art p { max-width: 42ch; opacity: .85; font-size: 1.02rem; }
.art-slip { background: #FFFDF7; color: #13221F; border-radius: 14px; padding: 16px; width: min(340px, 100%); box-shadow: 0 30px 60px -20px rgba(0,0,0,.45); transform: rotate(-3deg); position: relative; z-index: 1; display: grid; grid-template-columns: 1fr auto; gap: 12px; }
.art-slip .t { font: 800 2.2rem/1 var(--f-mono); color: #D9822B; }
.art-slip .qr-box { border-color: #E6E2D6; }
.art-slip .qr-box svg { width: 84px; height: 84px; }
.login-form { display: grid; place-items: center; padding: 32px max(20px, env(safe-area-inset-right, 0px)) 32px max(20px, env(safe-area-inset-left, 0px)); }
.login-box { width: min(400px, 100%); display: grid; gap: 18px; }
.demo-logins { display: grid; gap: 8px; }
.demo-logins .chips .chip { font-size: .85rem; padding: 6px 12px; }
.alert { border-radius: 10px; padding: 10px 12px; font-size: .9rem; font-weight: 600; display: flex; gap: 8px; align-items: flex-start; }
.alert.error { background: var(--danger-soft); color: var(--danger); }
.alert.info { background: var(--info-soft); color: var(--info); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }

/* ---------- modal & toast ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(8, 16, 15, .55); z-index: 100; display: grid; place-items: center; padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.modal { background: var(--surface); border-radius: 16px; width: min(560px, 100%); max-height: 100%; overflow: auto; box-shadow: 0 30px 80px -20px rgba(0,0,0,.5); }
.modal.wide { width: min(860px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-body { padding: 18px; display: grid; gap: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.success-burst { display: grid; justify-items: center; gap: 6px; text-align: center; padding: 6px 0 2px; }
.success-burst .tk { font: 800 3.4rem/1 var(--f-mono); color: var(--accent); }
.toasts { position: fixed; z-index: 200; bottom: max(20px, env(safe-area-inset-bottom, 0px)); right: max(20px, env(safe-area-inset-right, 0px)); display: grid; gap: 8px; }
.toast { background: var(--ink); color: var(--surface); padding: 11px 16px; border-radius: 10px; font-weight: 600; box-shadow: var(--shadow); display: flex; gap: 8px; align-items: center; max-width: min(420px, calc(100vw - 40px)); }
.toast.error { background: var(--danger); color: #fff; }
@media (prefers-reduced-motion: no-preference) { .toast { animation: up .2s ease-out; } @keyframes up { from { transform: translateY(8px); opacity: .4; } to { transform: none; opacity: 1; } } }

/* slip preview inside modal: always paper-white */
.paper { background: #E9EEEC; padding: 18px; border-radius: 10px; overflow: auto; }
.paper .slip { margin: 0 auto; box-shadow: 0 10px 30px -12px rgba(0,0,0,.35); }

/* ---------- waiting-room display (single dark look on purpose) ---------- */
.display { min-height: 100vh; min-height: 100dvh; background: #0A1413; color: #EAF3F1; display: grid; grid-template-rows: auto 1fr auto; font-family: var(--f-display); }
.display-top { display: flex; justify-content: space-between; align-items: center; padding: max(24px, env(safe-area-inset-top, 0px)) max(40px, env(safe-area-inset-right, 0px)) 24px max(40px, env(safe-area-inset-left, 0px)); border-bottom: 1px solid #1E302E; gap: 16px; flex-wrap: wrap; }
.display-top .cn { font-size: clamp(1.4rem, 3vw, 2.4rem); font-weight: 800; }
.display-top .clock { font: 700 clamp(1.4rem, 3vw, 2.4rem) var(--f-mono); color: #9FB8B3; }
.display-main { display: grid; grid-template-columns: 1.3fr 1fr; gap: 0; }
.now { display: grid; place-content: center; text-align: center; gap: 10px; padding: 40px; border-right: 1px solid #1E302E; }
.now .lbl { font-size: clamp(1.1rem, 2.2vw, 1.8rem); font-weight: 700; color: #9FB8B3; letter-spacing: .04em; }
.now .big { font: 800 clamp(7rem, 20vw, 17rem)/0.9 var(--f-mono); color: #F0A54A; letter-spacing: -.06em; }
.now .who { font-size: clamp(1.1rem, 2vw, 1.6rem); color: #CFE3DE; }
.next { padding: 40px; display: grid; align-content: start; gap: 18px; }
.next .lbl { font-size: clamp(1rem, 1.8vw, 1.4rem); font-weight: 700; color: #9FB8B3; }
.next-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.next-list div { background: #12211F; border: 1px solid #1E302E; border-radius: 16px; text-align: center; padding: 18px 8px; font: 800 clamp(2rem, 4.5vw, 3.6rem)/1 var(--f-mono); color: #EAF3F1; }
.display-foot { padding: 16px 40px max(16px, env(safe-area-inset-bottom, 0px)); display: flex; justify-content: space-between; gap: 12px; color: #6F8A85; font-family: var(--f-body); flex-wrap: wrap; align-items: center; }
.display-foot button { background: #12211F; color: #CFE3DE; border: 1px solid #1E302E; border-radius: 10px; padding: 8px 14px; cursor: pointer; font-weight: 600; }

/* ---------- mobile ---------- */
.bottom-bar { display: none; }
.scrim { display: none; }
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats .stat:first-child { grid-column: 1 / -1; }
  .layout-main, .reg-grid { grid-template-columns: minmax(0, 1fr); }
  .preview-wrap { position: static; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { position: fixed; z-index: 60; left: 0; top: 0; bottom: 0; width: min(300px, 86vw); transform: translateX(-102%); transition: transform .2s ease; box-shadow: var(--shadow); }
  .shell.nav-open .rail { transform: none; }
  .shell.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 55; }
  .menu-btn { display: grid; }
  .topbar { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .page { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-bottom: 110px; }
  .gsearch .kbd { display: none; }
  .bottom-bar {
    display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; z-index: 50; left: 0; right: 0; bottom: 0;
    background: var(--surface); border-top: 1px solid var(--line);
    padding: 6px max(8px, env(safe-area-inset-right, 0px)) max(8px, env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
  }
  .bottom-bar a { display: grid; justify-items: center; gap: 2px; padding: 6px 2px; font-size: .7rem; font-weight: 700; color: var(--muted); text-decoration: none; border-radius: 10px; }
  .bottom-bar a[aria-current="page"] { color: var(--brand); background: var(--brand-soft); }
  .bottom-bar svg.i { width: 22px; height: 22px; }
  .toasts { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); left: 16px; right: 16px; }
  .scan-grid { grid-template-columns: minmax(0, 1fr); }
  .login { grid-template-columns: minmax(0, 1fr); }
  .login-art { padding: 28px max(20px, env(safe-area-inset-right, 0px)) 28px max(20px, env(safe-area-inset-left, 0px)); }
  .login-art .art-slip { display: none; }
  .display-main { grid-template-columns: 1fr; }
  .now { border-right: 0; border-bottom: 1px solid #1E302E; }
}
@media (max-width: 640px) {
  h1 { font-size: 1.35rem; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .grid-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-2 { grid-column: auto; }
  .q-row { grid-template-columns: 56px minmax(0, 1fr); gap: 4px 12px; padding: 12px 14px; }
  .q-token { font-size: 1.6rem; grid-row: span 3; align-self: start; }
  .q-actions { justify-content: flex-start; }
  .p-hero { grid-template-columns: auto minmax(0, 1fr); padding: 16px; }
  .p-qr { grid-column: 1 / -1; justify-items: start; grid-auto-flow: column; align-items: center; }
  .tl-item { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .tl-date { grid-auto-flow: column; justify-content: start; gap: 8px; align-items: baseline; }
  .opd-body { grid-template-columns: minmax(0, 1fr); }
  .kv { grid-template-columns: 90px minmax(0, 1fr); }
  .next-list { grid-template-columns: repeat(2, 1fr); }
  .top-actions .btn .long { display: none; }
}

/* ---------- printing ---------- */
#print-root { display: none; }
.slip { background: #fff; color: #111; font-family: var(--f-body); }
.slip * { color: inherit; }
.slip-a5 { width: 148mm; min-height: 210mm; padding: 9mm 10mm; display: flex; flex-direction: column; gap: 4mm; font-size: 10pt; }
.slip-head { display: flex; justify-content: space-between; gap: 6mm; border-bottom: 2px solid #0E6B5C; padding-bottom: 3mm; }
.slip-head .cn { font: 800 16pt/1.15 var(--f-display); color: #0E6B5C; }
.slip-head .dr { font-weight: 700; font-size: 10.5pt; margin-top: 1mm; }
.slip-head .q { font-size: 8.5pt; color: #444; }
.slip-head .r { text-align: right; font-size: 8.5pt; color: #444; max-width: 55mm; }
.slip-band { display: flex; justify-content: space-between; align-items: center; background: #F1F6F4; border-radius: 2mm; padding: 2mm 3mm; font-size: 9pt; }
.slip-band b.tk { font: 800 18pt/1 var(--f-mono); color: #B8691C; }
.slip-pt { display: grid; grid-template-columns: 1fr auto; gap: 4mm; }
.slip-pt table { font-size: 9.5pt; border-collapse: collapse; width: 100%; }
.slip-pt td { padding: .8mm 0; border: 0; white-space: normal; vertical-align: top; }
.slip-pt td:first-child { color: #555; width: 24mm; }
.slip-pt td b { font-weight: 700; }
.slip-qr svg { width: 30mm; height: 30mm; display: block; }
.slip-qr div { font-size: 7pt; text-align: center; color: #555; margin-top: 1mm; }
.slip-vitals { display: grid; grid-template-columns: repeat(5, 1fr); gap: 2mm; font-size: 8.5pt; border-top: 1px solid #ddd; border-bottom: 1px solid #ddd; padding: 2mm 0; }
.slip-vitals span { color: #555; }
.slip-vitals b { display: block; font: 700 10pt var(--f-mono); min-height: 5mm; border-bottom: 1px dotted #bbb; }
.slip-rx { flex: 1; display: flex; flex-direction: column; gap: 2mm; min-height: 70mm; }
.slip-rx .sym { font: 700 22pt/1 Georgia, serif; color: #0E6B5C; }
.slip-rx .lines { flex: 1; background: repeating-linear-gradient(to bottom, transparent 0 7.4mm, #E3E8E6 7.4mm 7.6mm); white-space: pre-wrap; line-height: 7.6mm; font-size: 10pt; padding-left: 2mm; }
.slip-rx .lbl { font-size: 8pt; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #777; }
.slip-foot { display: flex; justify-content: space-between; font-size: 8pt; color: #555; border-top: 1px solid #ddd; padding-top: 2mm; gap: 4mm; }
.slip-foot .sign { text-align: right; padding-top: 8mm; min-width: 40mm; border-top: 0; }
.slip-80 { width: 72mm; padding: 3mm; font-size: 9pt; display: grid; gap: 2mm; text-align: center; }
.slip-80 .cn { font: 800 12pt/1.2 var(--f-display); }
.slip-80 .tk { font: 800 30pt/1 var(--f-mono); }
.slip-80 .row { display: flex; justify-content: space-between; text-align: left; gap: 2mm; }
.slip-80 svg { width: 34mm; height: 34mm; margin: 0 auto; display: block; }
.slip-80 hr { border: 0; border-top: 1px dashed #999; margin: 1mm 0; width: 100%; }

@media print {
  @page { margin: 0; }
  body { background: #fff !important; }
  body > *:not(#print-root) { display: none !important; }
  body::before { display: none; }
  #print-root { display: block !important; }
  #print-root .slip { box-shadow: none; }
}

/* ================================================================ newer screens (pro.js) */
.support-bar { display: flex; gap: 10px; align-items: center; padding: 8px 16px; background: var(--accent-soft, #FCEBD6); color: var(--ink); border-bottom: 1px solid var(--line); font-size: .9rem; }
.support-bar .i { color: var(--accent); }
.owner-shell .topbar { gap: 12px; }
.seg.wrap { display: flex; flex-wrap: wrap; grid-auto-flow: initial; }
.seg.wrap label { flex: 1 1 auto; }
.check.sm { padding: 6px 10px; font-size: .88rem; display: inline-flex; gap: 8px; align-items: center; margin: 3px 6px 3px 0; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.grid-2.wide { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 860px) { .grid-2.wide, .grid-3 { grid-template-columns: 1fr; } }
.hint.ok, .ok-text { color: var(--ok); font-weight: 600; }
.tag.verify { background: var(--danger-soft); color: var(--danger); }
.struck td { opacity: .55; }
.struck td:first-child { text-decoration: line-through; }
.section-h { font-size: 1.05rem; margin: 8px 0 0; }

.pay { display: grid; gap: 12px; }
.discount-grid > .field { align-self: start; }
.fee-box { display: flex; gap: 14px; align-items: center; justify-content: space-between; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); flex-wrap: wrap; }
.fee-box.free { border-color: var(--ok); background: var(--ok-soft, #E3F3EA); }
.fee-amt { font-weight: 800; font-size: 1.6rem; line-height: 1.1; }
.fee-box .lock { opacity: .6; }
.pay-total { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 14px; border-radius: var(--radius); background: var(--brand-soft); font-weight: 700; }
.pay-total b { font-size: 1.4rem; }
.approve-box { display: grid; gap: 8px; padding: 10px 12px; border: 1px dashed var(--accent); border-radius: var(--radius); }
.approvals .appr-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.approvals .appr-row:last-child { border-bottom: 0; }
.approvals h2 .i { margin-right: 6px; }

.alerts-box { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); background: var(--danger-soft); color: var(--ink); border: 1px solid var(--danger); }
.alerts-box > .i { color: var(--danger); flex: none; margin-top: 2px; }
.alerts-list { flex: 1; display: grid; gap: 4px; font-weight: 600; }

.folders { display: grid; }
.folder { border-top: 1px solid var(--line); }
.folder summary { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 12px 16px; cursor: pointer; list-style: none; }
.folder summary::-webkit-details-marker { display: none; }
.folder summary::before { content: "▸"; color: var(--muted); }
.folder[open] summary::before { content: "▾"; }
.folder .f-date { min-width: 150px; }
.f-body { padding: 0 16px 16px 34px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.f-sec { display: grid; gap: 8px; }
.f-body .f-sec { align-content: start; min-width: 0; }
.f-body .f-sec > .btn { justify-self: start; }
@media (max-width: 600px) {
  .f-body { grid-template-columns: 1fr; }
}
.f-h { font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.f-thumbs { display: flex; gap: 10px; flex-wrap: wrap; }
.f-thumb { width: 96px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 4px; cursor: pointer; display: grid; gap: 4px; justify-items: center; font-size: .72rem; color: var(--muted); }
.f-thumb img { width: 86px; height: 110px; object-fit: cover; border-radius: 6px; background: #fff; }
.f-thumb span { max-width: 86px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.report-advised { display: block; color: var(--muted); font-size: .72rem; line-height: 1.3; white-space: normal; overflow-wrap: anywhere; }
.f-thumb:hover { border-color: var(--brand); }
.f-links { display: flex; gap: 6px; flex-wrap: wrap; margin: -4px 0 6px 26px; }
.ar-row { display: flex; gap: 14px; padding: 8px 0; border-bottom: 1px solid var(--line); align-items: center; flex-wrap: wrap; }
.ar-row > b { min-width: 160px; }

.viewer { position: fixed; inset: 0; z-index: 90; background: #101a18; color: #fff; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.viewer .v-top, .viewer .v-bottom { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 16px; flex-wrap: wrap; }
.viewer .v-top { background: #1d2b28; }
.viewer .v-bottom { justify-content: center; }
.viewer .v-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.viewer .v-close { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px 14px; border: 1px solid #fff; border-radius: 9px; background: #fff; color: #10211d; font-weight: 700; cursor: pointer; }
.viewer .v-close:hover { background: #dcece7; }
.viewer .v-close:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.viewer .muted { color: #b8c6c3; }
.v-stage { overflow: auto; display: grid; place-items: center; padding: 0 56px; }
.v-stage img { max-width: 100%; max-height: calc(100vh - 130px); cursor: zoom-in; background: #fff; }
.v-stage.zoom { place-items: start center; }
.v-stage.zoom img { max-width: none; max-height: none; width: 180%; cursor: zoom-out; }
.v-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 64px; border: 0; border-radius: 10px; background: rgba(255,255,255,.12); color: #fff; font-size: 2rem; cursor: pointer; }
.v-prev { left: 8px; } .v-next { right: 8px; }
@media (max-width: 600px) {
  .viewer .v-top, .viewer .v-bottom { padding: 8px; }
  .viewer .v-actions .small { display: none; }
  .v-stage { padding: 0 42px; }
  .v-nav { width: 36px; }
}

.scan-bar { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border: 2px solid var(--brand); border-radius: var(--radius); background: var(--surface); }
.scan-bar input { flex: 1; border: 0; outline: 0; font-size: 1.1rem; background: transparent; color: var(--ink); }
.desk-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.desk-tab { display: grid; grid-template-columns: auto auto; gap: 2px 10px; align-items: center; text-align: left; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; color: var(--ink); }
.desk-tab.on { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.desk-tab .x { grid-row: 1 / span 2; grid-column: 2; color: var(--muted); padding: 2px 4px; }
.desk-tab .mono { grid-column: 1; }

.wide-tabs { flex-wrap: wrap; }
.feats { display: grid; gap: 6px; }
.feat { display: flex; gap: 8px; color: var(--muted); }
.feat.on { color: var(--ink); font-weight: 600; }
.feat.on span { color: var(--ok); }

/* layout editor */
.layout-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; min-width: 0; }
.layout-grid > * { min-width: 0; }
.f-sec > .btn { justify-self: start; }
.paper .lh-page { zoom: .8; }
@media (max-width: 1100px) { .layout-grid { grid-template-columns: 1fr; } }
.ly-canvas-wrap { overflow: auto; padding: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); }
.ly-canvas { position: relative; background: #fff; box-shadow: 0 2px 12px rgba(0,0,0,.15); margin: auto; color: #111; touch-action: none; }
.ly-pad { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; opacity: .55; pointer-events: none; }
.ly-full-pad { opacity: 1; }
.ly-head { position: absolute; left: 0; top: 0; width: 100%; object-fit: contain; pointer-events: none; }
.ly-head.ph { display: grid; place-items: center; background: #eef3f2; color: #789; border-bottom: 1px dashed #9ab; }
.ly-box { position: absolute; border: 1px dashed #0E6B5C; background: rgba(14,107,92,.07); padding: 0 2px; white-space: nowrap; overflow: hidden; cursor: move; font-family: Arial, sans-serif; line-height: 1.25; user-select: none; }
.ly-box.sel { border-style: solid; border-width: 2px; background: rgba(217,130,43,.15); border-color: #D9822B; z-index: 2; }
.ly-box.off { opacity: .3; }
.ly-qr { width: 100%; height: 100%; display: grid; place-items: center; font-weight: 700; background: repeating-linear-gradient(45deg, #ddd 0 4px, #fff 4px 8px); }

/* printed pages */
.lh-page { position: relative; background: #fff; color: #000; overflow: hidden; font-family: Arial, "Noto Sans Devanagari", sans-serif; }
.paper .lh-page { box-shadow: 0 1px 6px rgba(0,0,0,.2); margin: auto; transform-origin: top center; }
.lh-f { position: absolute; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lh-f.outline { outline: .2mm dashed #888; }
.lh-f .lh-l { font-weight: 600; }
.lh-token b { font-size: 1.3em; }
.lh-qr svg { width: 100%; height: 100%; display: block; }
.lh-header { position: absolute; left: 0; top: 0; width: 100%; object-fit: contain; }
.lh-full-pad { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; }
.lh-wm, .ly-wm { position: absolute; object-fit: contain; pointer-events: none; }
.field[hidden], .seg[hidden] { display: none; }
.lh-mark { position: absolute; width: 8mm; height: 8mm; margin: -4mm 0 0 -4mm; }
.lh-mark::before, .lh-mark::after { content: ""; position: absolute; background: #000; }
.lh-mark::before { left: 50%; top: 0; bottom: 0; width: .25mm; }
.lh-mark::after { top: 50%; left: 0; right: 0; height: .25mm; }
.lh-ruler { position: absolute; width: 100mm; height: 3mm; border-bottom: .25mm solid #000; }
.lh-ruler i { position: absolute; bottom: 0; width: .25mm; height: 3mm; background: #000; }
.lh-ruler span { position: absolute; top: 3.5mm; left: 0; font-size: 7pt; }
.lh-note { position: absolute; left: 10mm; bottom: 4mm; font-size: 7pt; color: #444; }

.receipt { background: #fff; color: #000; font-family: Arial, sans-serif; position: relative; overflow: hidden; }
.receipt.rc-80 { width: 72mm; padding: 3mm 4mm; font-size: 9pt; }
.receipt.rc-a5 { width: 148mm; min-height: 105mm; padding: 10mm 12mm; font-size: 10.5pt; box-sizing: border-box; }
.paper .receipt { margin: auto; box-shadow: 0 1px 6px rgba(0,0,0,.2); }
.rc-watermark { position: absolute; left: 50%; top: 50%; width: 70%; max-height: 60%; object-fit: contain; transform: translate(-50%, -50%); opacity: .10; pointer-events: none; }
.rc-content { position: relative; }
.rc-head { display: flex; gap: 8px; align-items: center; justify-content: center; text-align: center; }
.rc-logo { height: 12mm; }
.rc-cn { font-weight: 800; font-size: 1.15em; }
.rc-addr { font-size: .85em; }
.rc-title { text-align: center; font-weight: 800; letter-spacing: .12em; margin: 2mm 0; border-top: .3mm solid #000; border-bottom: .3mm solid #000; padding: 1mm 0; }
.rc-row { display: flex; justify-content: space-between; gap: 3mm; padding: .4mm 0; }
.rc-row span { color: #333; }
.rc-row b { text-align: right; min-width: 0; overflow-wrap: anywhere; }
.rc-row.rcm b { font-family: "JetBrains Mono", monospace; }
.rc-sep { border-top: .25mm dashed #000; margin: 1.5mm 0; }
.rc-note { font-size: .85em; font-style: italic; text-align: right; }
.rc-total { display: flex; justify-content: space-between; font-weight: 800; font-size: 1.25em; border-top: .3mm solid #000; margin-top: 1mm; padding-top: 1mm; }
.rc-words { font-size: .85em; font-style: italic; margin-bottom: 1mm; }
.rc-free { font-weight: 700; text-align: center; border: .3mm solid #000; padding: 1mm; margin-top: 1.5mm; }
.rc-foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 3mm; }
.rc-foot > div:first-child { flex: 1; }
.rc-small { font-size: .78em; color: #333; }
.rc-qr svg { width: 16mm; height: 16mm; display: block; }
.rc-void { position: absolute; top: 40%; left: -5%; right: -5%; text-align: center; transform: rotate(-18deg); font-size: 2.2em; font-weight: 900; color: rgba(179,38,30,.35); border: .6mm solid rgba(179,38,30,.35); }
.report-a4 { width: 100%; font-family: Arial, sans-serif; color: #000; font-size: 9pt; }
.report-a4 section { margin-bottom: 4mm; }
.report-a4 .stats { break-inside: avoid; }
.report-a4 .table-wrap { overflow: visible; }
.report-a4 table { table-layout: fixed; font-size: 8pt; }
.report-a4 th:first-child { width: 23%; }
.report-a4 .mono { font-family: Arial, sans-serif; }
.report-a4 th, .report-a4 td { white-space: normal; overflow-wrap: anywhere; padding: 2mm; }
.report-a4 tr { break-inside: avoid; }
.report-a4 .btn, .report-a4 input { display: none; }
.pick-search { position: relative; }
.pick-search input { width: 100%; }
.pick-search .suggest { position: absolute; left: 0; right: 0; top: 100%; z-index: 5; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.12); display: grid; }
.pick-search .suggest button { text-align: left; padding: 8px 12px; border: 0; background: none; color: var(--ink); cursor: pointer; }
.pick-search .suggest button:hover { background: var(--surface-2); }
.chip.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-strong); }
@media print { #print-root .lh-page, #print-root .receipt { box-shadow: none; margin: 0; } #print-root .pg { overflow: hidden; } }
.owner-shell { display: block; }
.owner-shell .topbar { padding: 10px 24px; }
.slip-tests { margin: 2mm 0 0; padding-top: 1mm; font-size: 10pt; display: flex; gap: 2mm; }
.slip-tests span { flex: 1; border-bottom: .25mm dashed #999; height: 5mm; }
.combo { position: relative; }
.combo input { width: 100%; }
.combo-list { position: static; margin-top: 4px; max-height: 240px; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.14); display: grid; }
.combo-list button { text-align: left; padding: 9px 12px; border: 0; background: none; color: var(--ink); cursor: pointer; font: inherit; }
.combo-list button.on, .combo-list button:hover:not([disabled]) { background: var(--brand-soft); }
.combo-list button.unsure { color: var(--danger); font-weight: 600; border-bottom: 1px solid var(--line); }
.combo-list button.add { color: var(--brand-strong); font-weight: 600; border-top: 1px solid var(--line); }
.combo-list button.hint { color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); cursor: default; }
.chip.warn { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.choose-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .choose-2 { grid-template-columns: 1fr; } }
.choice { display: grid; gap: 6px; justify-items: start; text-align: left; padding: 16px; border: 1.5px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); cursor: pointer; font: inherit; }
.choice:hover { border-color: var(--brand); background: var(--brand-soft); }
.choice span { color: var(--muted); font-size: .88rem; }
.choice .i { color: var(--brand); }
.combo-list[hidden], .pick-search .suggest[hidden] { display: none !important; }
.stats.four { grid-template-columns: 1.4fr repeat(3, minmax(0, 1fr)); }
.slip .kind, .kind { display: inline-block; font-weight: 800; letter-spacing: .06em; font-size: 9pt; padding: .4mm 2mm; border: .35mm solid #000; border-radius: 1mm; margin-left: 2mm; }
.slip .kind.new, .kind.new { background: #000; color: #fff; }
.dup-box { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--accent); background: var(--accent-soft, #FCEBD6); }
.dup-box .i { color: var(--accent); flex: none; margin-top: 2px; }
.dup-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 4px 0; }
.merge-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .merge-cols { grid-template-columns: 1fr; } }
.merge-card { border: 1.5px solid var(--line); border-radius: var(--radius); padding: 12px; display: grid; gap: 4px; cursor: pointer; }
.merge-card.keep { border-color: var(--brand); background: var(--brand-soft); }
.merge-card .lbl { font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.merge-card.keep .lbl { color: var(--brand-strong); }
.dup-links { margin: -4px 2px 0; } .dup-links a { color: var(--brand-strong); }

/* ---------- doctor's view (look only) ---------- */
.dv-card { padding: 20px 22px; }
.dv-head { display: flex; gap: 16px; align-items: center; }
.dv-qr { margin-left: auto; flex: 0 0 auto; }
.dv-qr .qr-box svg { width: 84px; height: 84px; }
.dv-name { font-size: 1.9rem; font-weight: 700; line-height: 1.15; }
.dv-name .tag { font-size: .75rem; padding: 5px 8px; vertical-align: 6px; }
.dv-info { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.dv-scan-actions { margin-top: 14px; }
.dv-info > div { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; font-size: 1.1rem; overflow-wrap: anywhere; }
.dv-info small { display: block; color: var(--muted); font-size: .78rem; margin-bottom: 3px; }
.dv-alert { display: flex; align-items: center; gap: 10px; margin-top: 14px; padding: 12px 14px; border-radius: 10px; background: var(--accent-soft, #fff4e0); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); font-size: 1.02rem; }
.dv-alert span { flex: 1; }
.dv-unlinked summary { cursor: pointer; }
.dv-unlinked summary b { white-space: nowrap; color: var(--brand); }
.dv-unlinked-list { display: grid; gap: 8px; padding: 10px 0 0; }
.dv-unlinked-report { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: inherit; font: inherit; text-align: left; cursor: pointer; overflow-wrap: anywhere; }
.dv-unlinked-report small { display: block; color: var(--muted); margin-top: 3px; }
.dv-unlinked-report b { color: var(--brand); }
.unlinked-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); overflow-wrap: anywhere; }
.unlinked-row small { display: block; color: var(--muted); margin-top: 3px; }
.dv-visit { padding: 0; overflow: hidden; }
.dv-vh { display: flex; align-items: center; gap: 12px; padding: 12px 18px; background: var(--surface-2); font-weight: 700; font-size: 1.05rem; cursor: pointer; list-style: none; }
.dv-vh::-webkit-details-marker { display: none; }
.dv-vh::before { content: "▸"; color: var(--muted); }
.dv-visit[open] > .dv-vh::before { content: "▾"; }
.dv-vh:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.dv-vh .muted { font-weight: 400; }
.dv-documents { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.dv-doc-section { min-width: 0; }
.dv-doc-title { padding: 14px 18px 0; font-weight: 700; }
.dv-thumbs { display: flex; flex-wrap: wrap; gap: 16px; padding: 16px 18px; }
.dv-thumb { width: 190px; background: none; border: 0; padding: 0; cursor: zoom-in; text-align: center; font: inherit; color: inherit; }
.dv-thumb img, .dv-pdf { width: 190px; height: 250px; object-fit: cover; object-position: top; border: 1px solid var(--line); border-radius: 10px; display: flex; align-items: center; justify-content: center; gap: 6px; background: var(--surface-2); margin-bottom: 6px; }
.dv-thumb:hover img { outline: 3px solid var(--brand); }
.dv-empty { padding: 40px; text-align: center; color: var(--muted); font-size: 1.1rem; border: 2px dashed var(--line); border-radius: 14px; }
@media (max-width: 720px) { .dv-info { grid-template-columns: 1fr 1fr; } .dv-name { font-size: 1.4rem; } .dv-thumb, .dv-thumb img, .dv-pdf { width: 140px; } .dv-thumb img, .dv-pdf { height: 185px; } }
@media (max-width: 600px) { .dv-documents { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 480px) { .dv-qr .qr-box svg { width: 64px; height: 64px; } }