/* MedStack — hand-written CSS, no build step (works on shared hosting).
   Desktop-first clinical look; still usable at 360 px. English screens only:
   Urdu appears on the prescription, styled with .ur. */

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #0f1b2d;
  --ink-2: #26364a;
  --muted: #5b6878;          /* 5.5:1 on white */
  --line: #e1e6ed;
  --line-2: #eef1f5;
  --control: #cfd6df;

  --brand: #0b6e79;          /* buttons, selection, current menu item */
  --brand-dark: #08525a;
  --brand-soft: #e3f2f3;
  --focus: #1849a9;

  --doctor: #1e3a8a;         /* "with doctor" status */
  --doctor-soft: #eef4ff;
  --ok: #05603a;
  --ok-soft: #dcfae6;
  --warn: #7a2e0e;           /* emergency, out-of-range vitals, needs attention */
  --warn-soft: #fef0c7;
  --warn-line: #f5b54a;
  --danger: #912018;         /* allergies and clinical danger ONLY */
  --danger-soft: #fee4e2;
  --danger-solid: #b42318;

  --radius: 12px;
  --radius-sm: 8px;
  --tap: 44px;
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-num: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --font-ur: "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", serif;
  --nav-w: 232px;
  --nav-h: 64px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 var(--font); min-height: 100dvh;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
.ur, [lang="ur"] { font-family: var(--font-ur); direction: rtl; line-height: 2; font-size: 1.05em; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.num, .mono { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
a { color: var(--brand); }
a:hover { color: var(--brand-dark); }
img, svg { max-width: 100%; }
h1, h2, h3 { font-weight: 600; line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.65rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.kbd {
  display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 24px; padding: 0 6px;
  border: 1px solid var(--control); border-bottom-width: 2px; border-radius: 5px; background: var(--surface);
  font: 500 13px var(--font-num); color: #445266;
}

/* ---- App shell ---------------------------------------------------------------- */
.siderail { display: none; }
.topbar {
  position: sticky; top: 0; z-index: 30; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; padding: .6rem .75rem; min-height: 60px;
}
.clinic-btn {
  display: inline-flex; align-items: center; gap: .6rem; padding: .25rem .5rem; border-radius: var(--radius-sm);
  text-decoration: none; color: var(--ink); min-height: var(--tap); min-width: 0;
}
.clinic-btn:hover { background: var(--bg); color: var(--ink); }
.clinic-btn .name { font-weight: 600; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clinic-btn .sub { display: block; font-size: .85rem; color: var(--muted); font-weight: 400; }
.clinic-btn .caret { color: var(--muted); flex: none; }
.logo-mark {
  width: 32px; height: 32px; border-radius: 8px; background: var(--brand); color: #fff;
  display: grid; place-items: center; font: 600 1rem/1 var(--font); flex: none;
}
.clinic-btn .logo-mark { width: 28px; height: 28px; background: var(--brand-soft); color: var(--brand-dark); font-size: .9rem; }
.topsearch { position: relative; flex: 1 1 320px; max-width: 560px; }
.topsearch .input { background: var(--bg); border-color: var(--line); padding-inline-end: 44px; }
.topsearch .kbd { position: absolute; inset-inline-end: 10px; top: 10px; }
.topsearch .input:not(:placeholder-shown) ~ .kbd { display: none; } /* make room for the browser's clear button */
.search-pop { position: absolute; inset-inline: 0; top: 52px; z-index: 50; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(15,27,45,.16); overflow: hidden; min-width: 420px; }
.search-pop .kbd { position: static; }
.search-res { display: flex; gap: .6rem; align-items: center; padding: .65rem .9rem; border-top: 1px solid var(--line-2); }
.search-res:hover { background: var(--surface-2); }
.top-right { display: flex; align-items: center; gap: 1rem; margin-inline-start: auto; }
.userchip { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--ink); padding: .2rem .4rem; border-radius: var(--radius-sm); min-height: var(--tap); }
.userchip:hover { background: var(--bg); color: var(--ink); }
.userchip .avatar { width: 36px; height: 36px; border-radius: 50%; background: #e8ecf2; color: var(--ink-2); display: grid; place-items: center; font-weight: 600; font-size: .85rem; flex: none; }
.userchip .who { line-height: 1.25; }
.userchip .who b { display: block; font-weight: 500; }
.userchip .who span { font-size: .85rem; color: var(--muted); }

.pill { display: inline-flex; align-items: center; gap: .4rem; border-radius: 999px; padding: .2rem .7rem; font-size: .85rem; font-weight: 500; white-space: nowrap; }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill-open { background: var(--ok-soft); color: var(--ok); }
.pill-closing { background: var(--doctor-soft); color: var(--doctor); }
.pill-closed, .pill-none { background: #f0f3f7; color: var(--ink-2); }
.sync-online { display: none; }
.sync-offline { background: var(--warn-soft); color: var(--warn); }

.banner { padding: .65rem 1.75rem; font-size: .95rem; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.banner-warn { background: #fffaeb; color: var(--warn); }
.banner-alert { background: #fffaeb; color: var(--warn); border-bottom-color: var(--warn-line); font-weight: 500; }
.banner-info { background: var(--surface); color: var(--ink-2); }

main.page { padding: 1.25rem .75rem 2rem; max-width: 1400px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: .75rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head .date { color: var(--muted); font-size: 1rem; font-weight: 400; }

.bottomnav {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 40; background: var(--surface);
  border-top: 1px solid var(--line); display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding-bottom: env(safe-area-inset-bottom); height: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
.bottomnav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: .8rem; font-weight: 500; }
.bottomnav a svg { width: 22px; height: 22px; }
.bottomnav a[aria-current="page"] { color: var(--brand); }

@media (min-width: 1024px) {
  body { padding-bottom: 0; padding-inline-start: var(--nav-w); }
  .bottomnav { display: none; }
  .siderail {
    display: flex; flex-direction: column; gap: 2px; position: fixed; inset-block: 0; inset-inline-start: 0; overflow-y: auto;
    width: var(--nav-w); background: var(--surface); border-inline-end: 1px solid var(--line); padding: 20px 14px; z-index: 35;
  }
  .siderail .brand { display: flex; gap: .6rem; align-items: center; font-weight: 600; font-size: 1.15rem; color: var(--ink); padding: 4px 8px 12px; }
  .siderail .nav-h { margin: 14px 12px 4px; font-size: .85rem; font-weight: 500; color: var(--muted); }
  .siderail a { display: flex; gap: .75rem; align-items: center; min-height: var(--tap); padding: 0 12px; border-radius: var(--radius-sm); text-decoration: none; color: var(--ink-2); font-weight: 500; }
  .siderail a:hover { background: #f0f3f7; color: var(--ink); }
  .siderail a svg { width: 20px; height: 20px; flex: none; }
  .siderail a[aria-current="page"] { background: var(--brand-soft); color: var(--brand-dark); }
  .siderail .count { margin-inline-start: auto; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--doctor); color: #fff; font-size: .8rem; display: inline-grid; place-items: center; }
  .topbar { padding: .6rem 1.75rem; }
  main.page { padding: 1.5rem 1.75rem 3rem; }
}

/* ---- Surfaces -------------------------------------------------------------------- */
.panel, .card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1rem; }
.card { margin-bottom: 0; }
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.panel-flush { padding: 0; overflow: hidden; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .75rem; flex-wrap: wrap; }
.panel-flush > .panel-head { padding: 1rem 1.25rem 0; }
.panel-head h2, .panel-head h3 { margin: 0; }
.grid { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 1fr); }
.grid > * { min-width: 0; }
@media (min-width: 760px) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .split { grid-template-columns: minmax(0, 1.6fr) minmax(340px, 1fr); align-items: start; } }
.stack > * + * { margin-top: .75rem; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: .5rem; align-items: center; justify-content: space-between; }
.spacer { flex: 1; }

/* ---- Buttons --------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: var(--tap);
  padding: 0 1rem; border-radius: var(--radius-sm); border: 1px solid var(--control); background: var(--surface);
  color: var(--ink); font: 500 15px/1.2 var(--font); text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: #f0f3f7; color: var(--ink); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn-primary, .btn-slip, .btn-ok { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover, .btn-slip:hover, .btn-ok:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-primary .kbd, .btn-slip .kbd { background: transparent; border-color: #6fb3ba; color: #fff; }
.btn-danger { color: var(--danger-solid); border-color: #f3b3ad; }
.btn-danger:hover { background: #fef3f2; color: var(--danger); }
.btn-danger-solid { background: var(--danger-solid); border-color: var(--danger-solid); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--brand); }
.btn-block { width: 100%; }
.btn-lg { min-height: 50px; font-size: 1rem; padding-inline: 1.3rem; }
.btn-sm { min-height: 38px; padding: 0 .75rem; font-size: .9rem; }
.btn-icon { width: var(--tap); padding: 0; }
.fab {
  position: fixed; inset-inline-end: 1rem; bottom: calc(var(--nav-h) + 1rem + env(safe-area-inset-bottom)); z-index: 45;
  min-height: 52px; padding-inline: 1.3rem; border-radius: 999px; box-shadow: 0 6px 18px rgba(11,110,121,.3);
}
@media (min-width: 1024px) { .fab { bottom: 1.5rem; } }

/* ---- Forms ------------------------------------------------------------------------- */
label { display: block; font-weight: 500; font-size: .93rem; margin-bottom: .35rem; color: var(--ink-2); }
.field { margin-bottom: .9rem; }
.field-row { display: grid; gap: .75rem; grid-template-columns: 1fr 1fr; }
.input, select.input, textarea.input {
  width: 100%; min-height: var(--tap); padding: .5rem .75rem; border: 1px solid var(--control); border-radius: var(--radius-sm);
  background: var(--surface); font: 15px/1.4 var(--font); color: var(--ink);
}
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.input[aria-invalid="true"] { border-color: var(--danger-solid); }
.input-lg { min-height: 50px; font-size: 1.05rem; }
textarea.input { min-height: 84px; resize: vertical; }
.prefix-input { display: flex; align-items: stretch; direction: ltr; }
.prefix-input span { display: grid; place-items: center; padding: 0 .75rem; border: 1px solid var(--control); border-inline-end: 0; border-start-start-radius: var(--radius-sm); border-end-start-radius: var(--radius-sm); background: var(--bg); color: #445266; }
.prefix-input .input { border-start-start-radius: 0; border-end-start-radius: 0; }
.error, .err { color: var(--danger-solid); font-size: .9rem; font-weight: 500; margin-top: .3rem; }
.hint { color: var(--muted); font-size: .9rem; margin-top: .3rem; }
.check { display: flex; gap: .6rem; align-items: center; font-weight: 500; min-height: var(--tap); }
.check input { width: 20px; height: 20px; accent-color: var(--brand); }

/* ---- Chips, badges ------------------------------------------------------------------ */
.chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.chip {
  display: inline-flex; align-items: center; gap: .35rem; min-height: 40px; padding: 0 .9rem; border-radius: 999px;
  border: 1px solid var(--control); background: var(--surface); font: 500 14px var(--font); color: var(--ink-2); cursor: pointer;
}
.chip:hover { background: #f8fafc; }
.chip[aria-pressed="true"], .chip.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-dark); box-shadow: inset 0 0 0 1px var(--brand); }
.chip-dose { font: 500 14px var(--font-num); min-width: 60px; justify-content: center; border-radius: 6px; }
.chip-add { border-style: dashed; color: var(--brand); }
.chip .x { opacity: .7; font-size: 1.1em; line-height: 1; }
.tag, .badge { display: inline-flex; align-items: center; gap: .35rem; padding: .15rem .6rem; border-radius: 999px; font-size: .82rem; font-weight: 500; vertical-align: middle; white-space: nowrap; }
.tag-new, .tag-fu, .tag-review, .tag-muted { background: #f0f3f7; color: var(--ink-2); }
.tag-emergency, .tag-warn { background: var(--warn-soft); color: var(--warn); }
.tag-alert { background: var(--danger-soft); color: var(--danger); }
.tag-ok { background: var(--ok-soft); color: var(--ok); }
.tag-doctor { background: var(--doctor-soft); color: var(--doctor); }
.tag-outline { background: var(--surface); color: var(--ink-2); box-shadow: inset 0 0 0 1px #9aa5b1; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.dot-paid, .dot-waived { background: #12b76a; }
.dot-partial { background: var(--warn-line); }
.dot-unpaid { background: transparent; box-shadow: inset 0 0 0 2px #445266; }

/* ---- Token + queue ------------------------------------------------------------------- */
.now {
  background: var(--surface); color: var(--ink); border: 1px solid var(--brand); box-shadow: inset 0 0 0 1px var(--brand);
  border-radius: var(--radius); padding: 1rem 1.25rem; display: grid; grid-template-columns: auto 1fr; gap: .25rem 1rem; align-items: center;
}
.now .big { font: 500 3.2rem/.95 var(--font-num); grid-row: span 2; color: var(--brand-dark); }
.now .who { font-weight: 600; font-size: 1.15rem; }
.now .meta { font-size: .95rem; color: var(--muted); }
.now-empty { border: 1px dashed var(--control); box-shadow: none; color: var(--muted); }
.strip { display: flex; gap: .5rem; overflow-x: auto; padding: .75rem 0 .25rem; scrollbar-width: none; }
.strip::-webkit-scrollbar { display: none; }
.strip .t { flex: none; min-width: 52px; padding: .25rem .6rem; border-radius: var(--radius-sm); background: #f0f3f7; text-align: center; font: 500 1.2rem var(--font-num); }
.strip .t.em { background: var(--warn-soft); color: var(--warn); }
.tokenno { font: 500 1.35rem/1 var(--font-num); min-width: 2.4rem; text-align: center; color: var(--ink); }

/* ---- Lists and tables ---------------------------------------------------------------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-bottom: 1px solid var(--line-2); }
.list > li:last-child { border-bottom: 0; }
.item { display: flex; align-items: center; gap: .75rem; padding: .75rem 1.25rem; min-height: 60px; text-decoration: none; color: inherit; width: 100%; background: none; border: 0; font: inherit; text-align: start; }
button.item { cursor: pointer; }
.item:hover { background: var(--surface-2); color: inherit; }
.item .main { flex: 1; min-width: 0; }
.item .title { font-weight: 500; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .sub { color: var(--muted); font-size: .9rem; display: block; }
.item-actions { display: flex; gap: .4rem; flex-wrap: wrap; padding: 0 1.25rem .75rem; }
.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }
.empty strong { display: block; color: var(--ink); margin-bottom: .25rem; font-weight: 600; }

table.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th, .table td { padding: .7rem 1rem; border-bottom: 1px solid var(--line-2); text-align: start; vertical-align: middle; }
.table th { font-size: .85rem; color: var(--muted); font-weight: 500; background: var(--surface-2); border-bottom-color: var(--line); white-space: nowrap; }
.table td.num, .table th.num { text-align: end; }
.table-wrap { overflow-x: auto; }
.queue-table td:nth-child(1), .queue-table td:nth-child(4), .queue-table td:nth-child(5), .queue-table td:nth-child(6) { white-space: nowrap; }
.queue-table td:nth-child(2) { min-width: 200px; }

/* ---- Sheets ---------------------------------------------------------------------------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(15,27,45,.45); z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--surface); width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto;
  border-radius: 16px 16px 0 0; padding: 1.1rem 1.25rem calc(1.1rem + env(safe-area-inset-bottom));
  animation: sheet-in .16s ease-out;
}
.sheet .grab { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 0 auto .75rem; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .75rem; }
.sheet-head h2 { margin: 0; }
@media (min-width: 760px) { .sheet-backdrop { align-items: center; } .sheet { border-radius: 16px; } .sheet .grab { display: none; } }
@keyframes sheet-in { from { transform: translateY(16px); opacity: .7; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } * { transition: none !important; } }

.flash { position: fixed; z-index: 80; inset-inline: .75rem; top: 72px; max-width: 520px; margin: 0 auto; padding: .8rem 1rem; border-radius: 10px; background: var(--ok-soft); color: var(--ok); font-weight: 500; border: 1px solid #a6e4bf; box-shadow: 0 8px 24px rgba(15,27,45,.12); }
.flash-error { background: var(--danger-soft); color: var(--danger); border-color: #f3b3ad; }
.devcode { background: #fffaeb; border: 1px dashed var(--warn-line); border-radius: var(--radius-sm); padding: .6rem .8rem; font-size: .95rem; margin-bottom: 1rem; color: var(--warn); }
.devcode b { font: 500 1.25rem var(--font-num); letter-spacing: .15em; }

/* ---- Consultation ----------------------------------------------------------------------- */
.pt-head { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 1rem; }
.pt-head .name { font-weight: 600; font-size: 1.3rem; line-height: 1.25; }
.allergy { background: var(--danger-soft); color: var(--danger); border-radius: 999px; padding: .15rem .7rem; font-size: .88rem; font-weight: 600; }
.lastvisit { display: flex; align-items: center; gap: .5rem; margin-top: .6rem; padding: .55rem .8rem; background: var(--bg); border-radius: var(--radius-sm); font-size: .95rem; color: var(--ink-2); }
.section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 1rem; }
.section > summary { list-style: none; display: flex; align-items: center; gap: .6rem; padding: .9rem 1.25rem; cursor: pointer; font-weight: 600; min-height: var(--tap); }
.section > summary::-webkit-details-marker { display: none; }
.section > summary .count { margin-inline-start: auto; color: var(--muted); font-weight: 400; font-size: .9rem; }
.section > summary::after { content: "⌄"; color: var(--muted); }
.section[open] > summary::after { transform: rotate(180deg); }
.section .body { padding: 0 1.25rem 1.1rem; }
.vitals { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; }
@media (min-width: 560px) { .vitals { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .vitals { grid-template-columns: repeat(6, 1fr); } }
.vitals .input { font: 500 1.05rem var(--font-num); text-align: center; }
.v-warn .input { border-color: var(--warn-line); background: #fffaeb; }
.v-alert .input { border-color: var(--danger-solid); background: var(--danger-soft); }
.rx-row { border: 1px solid var(--line); border-radius: 10px; padding: .9rem 1rem; margin-bottom: .75rem; }
.rx-row .drug { font-weight: 600; font-size: 1rem; }
.rx-row .gen { color: var(--muted); font-size: .9rem; }
.rx-row .chips { gap: .35rem; }
.rx-row .chip { min-height: 38px; padding: 0 .7rem; font-size: .9rem; }
.rx-line { margin-top: .6rem; padding: .5rem .75rem; background: var(--surface-2); border-radius: 8px; font-size: .95rem; display: flex; flex-wrap: wrap; justify-content: space-between; gap: .25rem 1.5rem; }
.rx-line .ur { text-align: right; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--control); border-radius: var(--radius-sm); }
.stepper button { width: 40px; height: 40px; border: 0; background: none; font-size: 1.2rem; cursor: pointer; color: var(--brand); }
.stepper span { min-width: 3.25rem; text-align: center; font: 500 1rem var(--font-num); }
.warnline { background: var(--danger-soft); color: var(--danger); border-radius: 8px; padding: .5rem .7rem; font-size: .93rem; font-weight: 500; margin-top: .5rem; }
.results { border: 1px solid var(--line); border-radius: var(--radius-sm); margin-top: .35rem; max-height: 340px; overflow-y: auto; background: var(--surface); }
.results button { display: block; width: 100%; text-align: start; padding: .6rem .85rem; border: 0; border-bottom: 1px solid var(--line-2); background: none; font: inherit; cursor: pointer; min-height: var(--tap); }
.results button:hover, .results button:focus { background: var(--brand-soft); }
.sticky-foot {
  position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); z-index: 20; background: var(--surface);
  padding: .7rem 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; border-top: 1px solid var(--line);
}
.sticky-foot .btn { white-space: normal; padding-inline: .5rem; line-height: 1.2; }
@media (min-width: 1024px) { .sticky-foot { bottom: 0; } }
.consult-foot {
  position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); z-index: 20; margin-top: 1rem;
  display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; padding: .75rem 1rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 -4px 16px rgba(15,27,45,.06);
}
@media (min-width: 1024px) { .consult-foot { bottom: .75rem; } }
.finish-menu { position: absolute; inset-inline-end: 0; bottom: calc(100% + 8px); width: 320px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(15,27,45,.16); overflow: hidden; z-index: 30; }
.finish-menu button { display: flex; align-items: center; width: 100%; min-height: var(--tap); padding: 0 .9rem; border: 0; background: none; font: 500 15px var(--font); color: var(--ink); cursor: pointer; text-align: start; }
.finish-menu button:hover { background: var(--surface-2); }

/* ---- Numbers, charts -------------------------------------------------------------------- */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1.25rem; }
@media (min-width: 900px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; text-decoration: none; color: inherit; display: block; }
.kpi .v { font-size: 1.75rem; font-weight: 600; line-height: 1.2; }
.kpi .v.num { font-weight: 500; }
.kpi .l { color: var(--muted); font-size: .9rem; }
.bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: .5rem; align-items: end; height: 140px; padding-top: .5rem; }
.bars .b { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: .3rem; font-size: .8rem; color: var(--muted); }
.bars .b i { display: block; width: 100%; max-width: 40px; background: #7fb8be; border-radius: 4px 4px 0 0; min-height: 3px; }
.bars .b.today i { background: var(--brand); }
.meter { height: 8px; background: #e8ecf2; border-radius: 8px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--brand); }

/* ---- Sign-in and guest pages --------------------------------------------------------------- */
body.guest { padding: 0; }
.auth { max-width: 440px; margin: 0 auto; padding: 2rem 1rem 3rem; }
.auth-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; }
.wordmark { display: flex; gap: .6rem; align-items: center; font-weight: 600; font-size: 1.3rem; color: var(--ink); text-decoration: none; }
.auth h1 { font-size: 1.75rem; }
.steps { display: flex; gap: .4rem; margin-bottom: 1.25rem; }
.steps i { height: 6px; flex: 1; border-radius: 6px; background: var(--line); }
.steps i.done { background: var(--brand); }
.steps i.current { background: #7fb8be; }

.denoms { display: grid; grid-template-columns: auto 1fr auto; gap: .4rem .75rem; align-items: center; }
.denoms .note { font: 500 1.05rem var(--font-num); }
.denoms .input { max-width: 110px; text-align: center; }
.variance { font: 500 1.4rem var(--font-num); }

@media print {
  .topbar, .bottomnav, .siderail, .fab, .no-print, .banner { display: none !important; }
  body { padding: 0 !important; background: #fff; }
}
[x-cloak] { display: none !important; }

/* Tabs (Cash: Today's bills / Close the day) */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1.25rem; }
.tabs a { padding: .6rem .9rem; color: var(--ink-2); text-decoration: none; font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--brand); border-bottom-color: var(--brand); }
.denoms.denoms-sub { grid-template-columns: auto auto 110px 1fr; }
.tabs button { padding: .7rem .2rem; margin-inline-end: 1.25rem; border: 0; background: none; color: var(--ink-2); font: 500 .95rem var(--font, inherit); border-bottom: 3px solid transparent; margin-bottom: -1px; cursor: pointer; }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-pressed="true"] { color: var(--brand); border-bottom-color: var(--brand); }

/* Patient record quick facts */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .75rem 1.25rem; margin: 1rem 0 0; padding-top: 1rem; border-top: 1px solid var(--line-2); }
.facts dt { font-size: .85rem; color: var(--muted, #5b6878); }
.facts dd { margin: 0; font-weight: 500; }

/* ---- Sign-in, sign-up and invite (auth layout) ------------------------------------------ */
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.lead { font-size: 1rem; line-height: 1.55; margin-bottom: 1.5rem; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--brand); font-weight: 500; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.linkbtn:hover { color: var(--brand-dark); }
.spinner { display: inline-block; width: 1em; height: 1em; vertical-align: -.15em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

body.auth-page { background: var(--surface); }
.auth-shell { min-height: 100dvh; display: grid; grid-template-columns: 1fr; }
.auth-brand { display: none; }
.auth-main { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1.5rem 1rem 2rem; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card h1 { font-size: 1.75rem; letter-spacing: -.01em; margin-bottom: .4rem; }
.auth-mobile-logo { margin-bottom: 2.25rem; }
.auth-foot { margin-top: 2rem; color: var(--muted); font-size: .9rem; text-align: center; }
.auth-alt { display: flex; align-items: center; gap: .75rem; color: var(--muted); font-size: .85rem; margin: 1.25rem 0; }
.auth-alt::before, .auth-alt::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.back-link { display: inline-flex; align-items: center; gap: .3rem; background: none; border: 0; padding: .25rem 0; margin-bottom: 1rem; color: var(--muted); font: 500 .93rem var(--font); cursor: pointer; }
.back-link:hover { color: var(--ink); }
.back-link svg { width: 18px; height: 18px; }

@media (min-width: 960px) {
  .auth-shell { grid-template-columns: minmax(380px, 44%) 1fr; }
  .auth-brand {
    display: flex; flex-direction: column; justify-content: space-between; padding: 2.5rem 3rem; color: #e8f4f5;
    background: radial-gradient(120% 90% at 0% 0%, #12909c 0%, var(--brand) 45%, #063f46 100%);
    position: relative; overflow: hidden;
  }
  .auth-brand::after {   /* soft "pulse" ring */
    content: ""; position: absolute; width: 520px; height: 520px; right: -180px; bottom: -200px; border-radius: 50%;
    border: 1px solid rgba(255,255,255,.12); box-shadow: 0 0 0 60px rgba(255,255,255,.04), 0 0 0 140px rgba(255,255,255,.03);
  }
  .auth-pitch { position: relative; z-index: 1; max-width: 420px; }
  .auth-pitch h2 { font-size: 2.1rem; line-height: 1.2; font-weight: 600; color: #fff; margin-bottom: 1.5rem; letter-spacing: -.01em; }
  .auth-pitch ul { list-style: none; padding: 0; margin: 0; display: grid; gap: .9rem; font-size: 1.02rem; }
  .auth-pitch li { display: flex; gap: .65rem; align-items: flex-start; }
  .auth-pitch li svg { flex: none; width: 22px; height: 22px; padding: 3px; border-radius: 50%; background: rgba(255,255,255,.16); color: #fff; margin-top: 1px; }
  .auth-trust { position: relative; z-index: 1; margin: 0; font-size: .9rem; color: #b9dfe3; }
  .wordmark-light { color: #fff; position: relative; z-index: 1; }
  .wordmark-light .logo-mark { background: #fff; color: var(--brand); }
  .auth-mobile-logo { display: none; }
  .auth-main { padding: 3rem 2rem; background: var(--surface); }
}

/* Phone number with fixed +92 */
.phone-input { display: flex; align-items: stretch; direction: ltr; }
.phone-input .cc { display: grid; place-items: center; padding: 0 .9rem; border: 1px solid var(--control); border-inline-end: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); background: var(--surface-2); color: var(--ink-2); font: 500 1.05rem var(--font-num); }
.phone-input .input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-family: var(--font-num); letter-spacing: .03em; }
.phone-input:focus-within .cc { border-color: var(--brand); }

/* Six-box code entry over one real input */
.otp { position: relative; direction: ltr; cursor: text; }
.otp-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; border: 0; font-size: 16px; color: transparent; caret-color: transparent; z-index: 1; }
.otp-cells { display: grid; grid-template-columns: repeat(6, 1fr); gap: .5rem; }
.otp-cell {
  height: 58px; display: grid; place-items: center; border: 1px solid var(--control); border-radius: 10px; background: var(--surface);
  font: 500 1.6rem var(--font-num); color: var(--ink); transition: border-color .12s, box-shadow .12s;
}
.otp-cell.filled { border-color: #9fc9cd; background: var(--surface-2); }
.otp-cell.active { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.otp-cell.active:empty::after { content: ""; width: 2px; height: 26px; background: var(--brand); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.resend { text-align: center; font-size: .93rem; min-height: 1.5rem; }

/* Password with show/hide */
.pw-input { position: relative; }
.pw-input .input { padding-inline-end: 4.5rem; }
.pw-toggle { position: absolute; inset-inline-end: .4rem; top: 50%; transform: translateY(-50%); background: none; border: 0; padding: .4rem .6rem; color: var(--brand); font: 500 .9rem var(--font); cursor: pointer; border-radius: 6px; }
.pw-toggle:hover { background: var(--brand-soft); }

/* Grouped sign-up fields */
.formgroup { border: 0; padding: 0; margin: 0 0 1.25rem; }
.formgroup legend { font-size: .78rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: .75rem; padding: 0; }
@media (max-width: 480px) { .formgroup .field-row { grid-template-columns: 1fr; gap: 0; } }
@media (prefers-reduced-motion: reduce) { .spinner, .otp-cell.active:empty::after { animation: none; } }
.auth-mobile-logo p { margin: .4rem 0 0; }
