/* Atiyeh design tokens and components — minimal system (v5, clinical teal).
   One flat surface language for both panels: neutral page, white cards with a 1px border, no gradients,
   no glass, shadow only on overlays. The primary teal is reserved for the primary action and the current item.
   Patient panel: single 440px column, 48px controls, standard bottom tab bar on panel pages only.
   Support/admin panel: grouped sidebar, 40px controls, dense tables.
   Kept rules: text contrast 4.5:1, 44px touch targets on mobile, visible focus, status never by colour alone.
   Persian: Vazirmatn. */
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700&display=swap');

:root {
  --primary: #0E7490;
  --primary-strong: #155E75;
  --primary-soft: #E6F3F5;
  --sky: #B9DCE3;
  --indigo: #8091B8;
  --ink: #12262B;
  --text: #33454A;
  --muted: #586B70;
  --line: #DFE5E6;
  --line-strong: #B1BDC0;
  --bg: #F5F7F7;
  --card: #FFFFFF;
  --subtle: #F8FAFA;
  --ok: #0E7A47; --ok-soft: #E7F6EE;
  --warn: #8A5300; --warn-soft: #FFF4DC;
  --danger: #B42318; --danger-soft: #FDECEA;
  --neutral-soft: #EEF1F2;
  --ring: #0E7490;

  /* Type scale (ratio ~1.2 from 16px): the only font sizes pages may use */
  --text-2xs: .75rem; --text-xs: .8125rem; --text-sm: .875rem; --text-md: .9375rem; --text-base: 1rem;
  --text-lg: 1.125rem; --text-xl: 1.375rem; --text-2xl: 1.625rem; --text-3xl: 2rem;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 24px; --space-6: 32px; --space-7: 48px;
  --radius-sm: 6px; --radius-md: 10px; --radius-lg: 14px; --radius-full: 999px;
  --shadow-float: 0 12px 32px rgba(16, 24, 40, .14);
  --font: 'Vazirmatn', 'Noto Sans Arabic', Tahoma, sans-serif;
  --ease: 180ms cubic-bezier(.2, 0, 0, 1);
  /* aliases used by the index board */
  --color-muted-foreground: var(--muted); --shadow-md: 0 4px 16px rgba(16, 24, 40, .10);
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; font-family: var(--font); line-height: 1.7; color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased; }
h1, h2, h3, p, dl, hr { margin: 0; }
h1, h2, .lead { text-wrap: balance; }
h1 { font-size: var(--text-2xl); line-height: 1.4; font-weight: 700; }
h2 { font-size: var(--text-base); line-height: 1.6; font-weight: 600; }
h3 { font-size: var(--text-md); font-weight: 600; }
a { color: var(--primary-strong); text-underline-offset: 4px; }
.muted { color: var(--muted); }
.small { font-size: var(--text-sm); }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.num { white-space: nowrap; }
.stack > * + * { margin-block-start: var(--space-4); }
.stack-sm > * + * { margin-block-start: var(--space-2); }
.row { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }
.ic { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none;
  stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.ic-lg { width: 24px; height: 24px; }
.small > .ic, p > .ic { width: 16px; height: 16px; vertical-align: -3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; inset-inline-start: var(--space-4); top: -60px; z-index: 100;
  background: var(--card); padding: var(--space-2) var(--space-4); border-radius: var(--radius-sm); }
.skip:focus { top: var(--space-2); }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 48px; padding: 0 20px; border-radius: var(--radius-md); border: 1px solid transparent;
  font: 600 1rem/1 var(--font); text-decoration: none; white-space: nowrap; cursor: pointer; touch-action: manipulation;
  transition: background var(--ease), border-color var(--ease), color var(--ease); }
.btn .ic { width: 18px; height: 18px; }
.btn:active:not([disabled]) { filter: brightness(.94); }
.btn-primary, .btn-accent { background: var(--primary); color: #fff; }
.btn-primary:hover, .btn-accent:hover { background: var(--primary-strong); }
.btn-outline { background: var(--card); color: var(--ink); border-color: var(--line-strong); }
.btn-outline:hover { background: var(--subtle); }
.btn-danger { background: transparent; color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-destructive { background: var(--danger); color: #fff; }
.btn-destructive:hover { background: #912018; }
.btn-ghost { background: transparent; color: var(--primary-strong); padding: 0 var(--space-3); }
.btn-ghost:hover { background: var(--primary-soft); }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 var(--space-3); font-size: var(--text-sm); border-radius: var(--radius-sm); }
.btn[disabled], .btn.is-disabled { color: var(--muted); background: transparent; cursor: not-allowed; }
.btn-outline[disabled] { border-color: var(--line); opacity: .7; }
.actions { display: grid; gap: var(--space-2); }

/* Shared pieces */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-5); }
.divider { border: 0; border-top: 1px solid var(--line); }
.alert, .note { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md); font-size: var(--text-sm); background: var(--primary-soft); color: var(--primary-strong); }
.alert .ic, .note .ic { margin-block-start: 2px; }
.alert-warn, .note { background: var(--warn-soft); color: var(--warn); }
.alert-danger { background: var(--danger-soft); color: #9B1C12; }
.alert-ok { background: var(--ok-soft); color: #0A5F37; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 10px var(--space-4); }
.kv dt { color: var(--muted); font-size: var(--text-sm); }
.kv dd { margin: 0; font-weight: 500; text-align: end; }
.kv dd.ltr { display: block; text-align: start; }
.field { display: block; }
.field > label, .label { display: block; font-size: var(--text-sm); font-weight: 600; margin-block-end: 6px; }
.input, .select { width: 100%; min-height: 48px; padding: 0 var(--space-4); font: 400 1rem var(--font);
  color: var(--ink); background: var(--card); border: 1px solid var(--line-strong); border-radius: var(--radius-md);
  transition: border-color var(--ease), box-shadow var(--ease); }
.input::placeholder { color: #8A94A6; }
.input:focus, .select:focus { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.help { font-size: var(--text-xs); color: var(--muted); margin-block-start: 6px; }
.error-text { font-size: var(--text-xs); color: var(--danger); margin-block-start: 6px;
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.error-text.center { justify-content: center; }
.error-text .ic { width: 16px; height: 16px; }
.input.is-error { border-color: var(--danger); }
.danger-text { color: var(--danger); }
.req { color: var(--danger); }
.check { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; vertical-align: middle; }
.plain { border: 0; padding: 0; margin: 0; min-width: 0; }

/* Status: tinted label for the appointment state, plain icon + text for the link state */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 6px;
  font-size: var(--text-xs); font-weight: 500; line-height: 1.7; white-space: nowrap; background: var(--neutral-soft); color: #414B5C; }
.badge .ic { width: 13px; height: 13px; }
.badge-info { background: var(--primary-soft); color: var(--primary-strong); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-ok { background: var(--ok-soft); color: #0A5F37; }
.badge-danger { background: var(--danger-soft); color: #9B1C12; }
.ls { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-xs); white-space: nowrap; color: var(--muted); }
.ls .ic { width: 15px; height: 15px; }
.ls-ok { color: #0A5F37; } .ls-warn { color: var(--warn); } .ls-info { color: var(--primary-strong); }

.hero-icon { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center;
  margin: 0 auto var(--space-4); background: var(--primary-soft); color: var(--primary); }
.hero-icon.ok { background: var(--ok-soft); color: var(--ok); }
.hero-icon.danger { background: var(--danger-soft); color: var(--danger); }
.hero-icon.warn { background: var(--warn-soft); color: var(--warn); }
.tile { width: 44px; height: 44px; border-radius: var(--radius-md); background: var(--primary-soft); color: var(--primary);
  display: grid; place-items: center; flex: none; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: var(--text-lg);
  color: var(--ink); text-decoration: none; line-height: 1.4; }
.brand small { display: block; font-size: var(--text-2xs); font-weight: 400; color: var(--muted); }
.brand-mark { width: 20px; height: 20px; border-radius: 50%; border: 6px solid var(--primary); flex: none; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(16, 24, 40, .5);
  display: grid; place-items: center; padding: var(--space-4); z-index: 40; }
.modal { background: var(--card); border-radius: var(--radius-lg); padding: var(--space-5);
  width: 100%; max-width: 420px; max-height: calc(100dvh - 2 * var(--space-4)); overflow-y: auto;
  box-shadow: var(--shadow-float); }
.modal h2 { font-size: var(--text-lg); }

/* Therapist / person row */
.who { display: flex; align-items: center; gap: var(--space-3); min-width: 0; line-height: 1.6; }
.who b { display: block; font-weight: 600; }
.who .small { display: block; }

/* ------------------------------------------------------------------ Patient panel (mobile) */
.patient { min-height: 100dvh; }
.p-main { display: flex; flex-direction: column; width: 100%; max-width: 440px; min-height: 100dvh; margin: 0 auto;
  padding: max(var(--space-3), env(safe-area-inset-top)) var(--space-4) max(var(--space-5), env(safe-area-inset-bottom)); }
.patient.has-bottom-nav .p-main { padding-block-end: calc(88px + env(safe-area-inset-bottom)); }
.hdr { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  min-height: 44px; margin-block-end: var(--space-5); }
.icon-btn { width: 44px; height: 44px; border-radius: var(--radius-md); background: var(--card); color: var(--ink);
  border: 1px solid var(--line); display: grid; place-items: center; cursor: pointer; text-decoration: none;
  transition: background var(--ease); }
.icon-btn:hover { background: var(--subtle); }
.hdr:has(> .brand:only-child) { justify-content: center; }
.user-chip .ic { width: 18px; height: 18px; color: var(--muted); }
.user-chip { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); font-weight: 500; color: var(--text); }
.title { font-size: var(--text-2xl); line-height: 1.4; font-weight: 700; }
.lead { color: var(--muted); font-size: var(--text-md); }
.title + .lead { margin-block-start: var(--space-2); }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; list-style: none; padding: 0; margin: 0 0 var(--space-5); }
.steps::before { content: attr(aria-label); grid-column: 1 / -1; font-size: var(--text-xs); color: var(--muted); }
.steps li { height: 4px; border-radius: var(--radius-full); background: var(--line); }
.steps li.done { background: var(--primary); }
.total { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-4); }
.price { font-size: var(--text-xl); font-weight: 700; }
.price .small { font-weight: 400; color: var(--muted); }
.choice { display: flex; gap: var(--space-3); align-items: center; padding: var(--space-4); background: var(--card);
  border: 1px solid var(--line-strong); border-radius: var(--radius-md); cursor: pointer; min-height: 76px; line-height: 1.6;
  transition: border-color var(--ease), background var(--ease); }
.choice:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); box-shadow: inset 0 0 0 1px var(--primary); }
.choice:has(input:checked) .tile { background: var(--card); }
.choice input { width: 20px; height: 20px; accent-color: var(--primary); }
.otp { display: flex; gap: var(--space-2); justify-content: center; direction: ltr; }
.otp input { width: 52px; height: 56px; text-align: center; font: 600 1.375rem var(--font); padding: 0; min-height: 0;
  background: var(--card); border: 1px solid var(--line-strong); border-radius: var(--radius-md); color: var(--ink); }
.otp input.is-error { border-color: var(--danger); }
.otp input:focus { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.appt { display: grid; grid-template-columns: auto 1fr auto; gap: var(--space-3); align-items: center; padding: var(--space-4);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg);
  text-decoration: none; color: inherit; line-height: 1.6; transition: border-color var(--ease); }
a.appt:hover { border-color: var(--line-strong); }
.appt b { display: block; font-weight: 600; }
.appt .small { display: block; }
.appt .go { color: var(--muted); }
.appt-foot { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
  flex-wrap: wrap; padding-block-start: var(--space-3); border-top: 1px solid var(--line); }
.nav { position: fixed; inset-inline: 0; bottom: 0; z-index: 20; background: var(--card); border-top: 1px solid var(--line);
  padding-block-end: env(safe-area-inset-bottom); }
.nav ul { display: grid; grid-template-columns: repeat(3, 1fr); list-style: none; margin: 0 auto; padding: 0; max-width: 440px; }
.nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 60px;
  color: var(--muted); text-decoration: none; font-weight: 500; font-size: var(--text-2xs); transition: color var(--ease); }
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { color: var(--primary); font-weight: 600; }
/* Centred screens (sign-in, code, appointment): content sits in the middle of the viewport */
.p-center { width: 100%; margin-block: auto; text-align: center; }
.p-center .field { text-align: start; }
.p-center .lead { max-width: 34ch; margin-inline: auto; }
.display { font-size: var(--text-3xl); font-weight: 700; line-height: 1.3; }
.display span { font-size: var(--text-base); font-weight: 400; color: var(--muted); padding-inline: var(--space-1); }
.display-sm { font-size: var(--text-xl); font-weight: 700; line-height: 1.5; }
.overline { font-size: var(--text-sm); font-weight: 600; color: var(--primary-strong); }
.warn-text { color: var(--warn); }
.ticket { padding: 0; }
.ticket > * { padding: var(--space-5); }
.ticket > * + * { border-top: 1px solid var(--line); }
.ticket-name { font-size: var(--text-lg); font-weight: 600; line-height: 1.5; }
.group-title { font-size: var(--text-sm); font-weight: 600; color: var(--muted); margin-block-end: var(--space-3); }
.date-block { width: 52px; flex: none; display: grid; justify-items: center; padding-block: 6px; line-height: 1.3;
  border-radius: var(--radius-md); background: var(--primary-soft); color: var(--primary-strong); }
.date-block b { font-size: var(--text-xl); font-weight: 700; }
.date-block span { font-size: var(--text-2xs); font-weight: 500; }
.date-block.is-past { background: var(--neutral-soft); color: var(--text); }
.p-support { margin-block-start: auto; padding-block-start: var(--space-6); text-align: center; font-size: var(--text-xs); color: var(--muted); }

/* ------------------------------------------------------------------ Support / admin panel (desktop) */
.admin { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100dvh; font-size: var(--text-sm); }
.side { position: sticky; top: 0; height: 100dvh; overflow-y: auto; display: flex; flex-direction: column; gap: var(--space-5);
  padding: var(--space-5) var(--space-3); background: var(--card); border-inline-end: 1px solid var(--line); }
.side .brand { padding-inline: var(--space-2); }
.side-nav { display: grid; gap: var(--space-4); }
.mobile-menu { display: contents; }
.mobile-menu > summary { display: none; }
.side-nav h2 { padding-inline: var(--space-3); margin-block-end: var(--space-1); font-size: var(--text-2xs); font-weight: 500; color: var(--muted); }
.side-nav a, .side-user a { display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 0 var(--space-3);
  border-radius: var(--radius-sm); color: var(--text); text-decoration: none; font-weight: 500;
  transition: background var(--ease), color var(--ease); }
.side-nav a .ic, .side-user a .ic { width: 18px; height: 18px; color: var(--muted); }
.side-nav a:hover, .side-user a:hover { background: var(--subtle); color: var(--ink); }
.side-nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary-strong); font-weight: 600; }
.side-nav a[aria-current="page"] .ic { color: var(--primary); }
.side-nav .badge { margin-inline-start: auto; }
.side-user { margin-block-start: auto; padding-block-start: var(--space-3); border-top: 1px solid var(--line); }
.side-user p { padding: var(--space-1) var(--space-3) var(--space-2); line-height: 1.5; font-weight: 600; }
.side-user small { display: block; font-size: var(--text-2xs); font-weight: 400; color: var(--muted); }
.stage { min-width: 0; padding: var(--space-6); }
.a-main { min-width: 0; }
.a-top { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4);
  margin-block-end: var(--space-5); flex-wrap: wrap; }
.a-top h1, h2, .lead { text-wrap: balance; }
h1 { font-size: var(--text-xl); }
.crumbs { font-size: var(--text-xs); color: var(--muted); margin-block-end: 2px; }
.crumbs a { color: inherit; text-decoration: none; }
.crumbs a:hover { color: var(--primary-strong); }
.crumbs span { padding-inline: 4px; }
.section-title { margin-block: var(--space-6) var(--space-3); }
.a-main > section { margin-block-end: var(--space-6); }
.a-main > .alert, .a-main > .grid-2 { margin-block-end: var(--space-4); }
.narrow { max-width: 720px; }
.admin .card { border-radius: var(--radius-md); padding: var(--space-5); }
.admin .btn { min-height: 40px; padding: 0 var(--space-4); font-size: var(--text-sm); border-radius: var(--radius-sm); }
.admin .btn-sm { min-height: 32px; padding: 0 10px; font-size: var(--text-xs); }
.admin .btn .ic { width: 16px; height: 16px; }
.admin .input, .admin .select { min-height: 40px; padding: 0 var(--space-3); font-size: var(--text-sm); border-radius: var(--radius-sm); }
.admin .select { padding-inline-end: var(--space-2); }
.toolbar { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; margin-block-end: var(--space-4); }
.toolbar .input, .toolbar .select { width: auto; }
.toolbar .input.num { width: 124px; text-align: center; }
.toolbar .label { margin: 0; color: var(--muted); font-weight: 500; }
.filter-menu { position: relative; }
.filter-menu > summary { display: flex; align-items: center; min-height: 40px; padding: 0 var(--space-3); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--card); color: var(--text); cursor: pointer; list-style: none; }
.filter-menu > summary::-webkit-details-marker { display: none; }
.filter-menu[open] .filter-fields { position: absolute; z-index: 10; inset-inline-end: 0; top: calc(100% + 6px); display: grid; grid-template-columns: repeat(2, minmax(150px, 1fr)); gap: var(--space-2); width: min(440px, calc(100vw - 32px)); padding: var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--card); box-shadow: var(--shadow-float); }
.search { position: relative; flex: 1; min-width: 220px; }
.search .ic { position: absolute; inset-inline-start: 12px; top: 50%; translate: 0 -50%; width: 16px; height: 16px; color: var(--muted); }
.search .input, .toolbar .search .input { width: 100%; padding-inline-start: 36px; }
.chips { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.chip { min-height: 36px; padding: 0 var(--space-3); border-radius: var(--radius-sm); border: 1px solid var(--line-strong); cursor: pointer;
  background: var(--card); color: var(--text); font: 500 .8125rem var(--font);
  display: inline-flex; align-items: center; gap: 6px; transition: background var(--ease), border-color var(--ease); }
.chip .ic { width: 15px; height: 15px; }
.chip:hover { background: var(--subtle); }
.chip[aria-pressed="true"], .chip.is-on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-strong); font-weight: 600; }
/* Summary strip: one bordered row of figures, hairlines between cells */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; margin-block-end: var(--space-4);
  background: var(--line); border: 1px solid var(--line); border-radius: var(--radius-md); overflow: hidden; }
.stat { background: var(--card); padding: var(--space-3) var(--space-4); line-height: 1.6; }
.stat .muted { display: block; font-size: var(--text-xs); }
.stat b { display: block; font-size: var(--text-xl); font-weight: 700; line-height: 1.5; }
.stat.hl b { color: var(--primary); }
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-md); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
th, td { padding: 10px 12px; text-align: start; white-space: nowrap; }
th:first-child, td:first-child { padding-inline-start: var(--space-4); }
th:last-child, td:last-child { padding-inline-end: var(--space-4); }
th { font-size: var(--text-2xs); color: var(--muted); font-weight: 600; background: var(--subtle); border-bottom: 1px solid var(--line); }
td { height: 48px; color: var(--text); border-bottom: 1px solid var(--line); }
td:first-child { color: var(--ink); }
td a:not(.btn) { color: var(--ink); font-weight: 600; text-decoration: none; }
td a:not(.btn):hover { color: var(--primary-strong); text-decoration: underline; }
td > .ic { width: 16px; height: 16px; vertical-align: -3px; color: var(--muted); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background var(--ease); }
tbody tr:hover { background: var(--subtle); }
tr.is-error td { background: var(--danger-soft); }
tr.is-error td:last-child, tr.is-error td:last-child .badge { white-space: normal; }
tfoot td { font-weight: 700; color: var(--ink); background: var(--subtle); border-top: 1px solid var(--line); border-bottom: 0; }
.bulk { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm); margin-block-end: var(--space-3); background: var(--primary-soft); color: var(--primary-strong); }
.pager { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); padding: 10px var(--space-4);
  font-size: var(--text-xs); color: var(--muted); border-top: 1px solid var(--line); }
.pager strong { color: var(--text); font-weight: 600; }
.drop { background: var(--card); border: 1.5px dashed var(--line-strong); border-radius: var(--radius-md);
  padding: var(--space-6) var(--space-5); text-align: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); align-items: start; }
.grid-aside { grid-template-columns: 2fr 1fr; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4) var(--space-5); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 96px 9px 1fr; gap: var(--space-3); }
.timeline li > span { padding-block: 6px; }
.timeline .dot { padding: 0; background: linear-gradient(var(--line), var(--line)) center / 1px 100% no-repeat; }
.timeline .dot::before { content: ""; display: block; width: 9px; height: 9px; margin-block-start: 13px; border-radius: 50%;
  background: var(--card); border: 2px solid var(--primary); }
.timeline li:last-child .dot { background-size: 1px 16px; background-position: top center; }
.timeline li:first-child .dot { background-position: center 16px; }
/* Charts: values are always printed next to the marks */
.bento { display: grid; grid-template-columns: repeat(12, 1fr); gap: var(--space-4); }
.bento > .stat { border: 1px solid var(--line); border-radius: var(--radius-md); align-self: stretch; }
.span-2 { grid-column: span 2; } .span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; } .span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-12 { grid-column: span 12; }
.vbars { display: flex; align-items: flex-end; gap: var(--space-4); height: 220px; padding-block-start: var(--space-4); }
.vbar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px;
  font-size: var(--text-2xs); color: var(--muted); }
.vbar b { color: var(--ink); font-weight: 600; }
.vbar .col { width: 100%; max-width: 48px; min-height: 2px; border-radius: 4px 4px 0 0; background: var(--sky); position: relative; }
.vbar .col i { position: absolute; inset-inline: 0; bottom: 0; border-radius: 4px 4px 0 0; background: var(--primary); }
.chart-row { display: flex; align-items: center; gap: var(--space-6); }
.donut { width: 160px; height: 160px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.donut > div { width: 112px; height: 112px; border-radius: 50%; background: var(--card); display: grid; place-items: center; text-align: center; line-height: 1.4; }
.donut b { font-size: var(--text-2xl); display: block; }
.legend { display: flex; gap: var(--space-4); font-size: var(--text-xs); color: var(--muted); flex-wrap: wrap; }
.legend i, .key i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-inline-end: 6px; vertical-align: middle; }
.key span { display: inline-flex; align-items: center; gap: var(--space-2); }
.key i { margin-inline-end: 0; }
.key { display: grid; gap: var(--space-3); }
.key div { display: flex; justify-content: space-between; align-items: center; gap: var(--space-4); }
.c-blue { background: var(--primary); } .c-sky { background: var(--sky); } .c-indigo { background: var(--indigo); }

/* Staff sign-in */
.auth main { min-height: 100dvh; display: grid; place-items: center; padding: var(--space-5); }
.auth .card { width: 100%; max-width: 400px; padding: var(--space-6); }
.auth .brand { justify-content: center; }
.auth h1, h2, .lead { text-wrap: balance; }
h1 { font-size: var(--text-xl); }

/* Patient directory and record */
.patients-lead { color: var(--muted); }
.patients-list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-md); overflow: hidden; }
.patients-list .table-wrap { border: 0; border-radius: 0; }
.patients-tools { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line); }
.patients-tools .search { max-width: 420px; }
.patients-total { color: var(--muted); font-size: var(--text-xs); white-space: nowrap; }
.patients-total strong { color: var(--ink); font-weight: 600; }
.patient-link { display: inline-flex; align-items: center; gap: 10px; }
.source-label { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 6px; line-height: 1.7;
  color: #414B5C; background: var(--neutral-soft); font-size: var(--text-xs); font-weight: 500; }
.patient-profile { margin-block-end: var(--space-6); padding: var(--space-5); background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius-md); }
.record-identity { display: flex; align-items: center; gap: var(--space-3); padding-block-end: var(--space-4); }
.record-identity p { color: var(--muted); font-size: var(--text-xs); }
.record-identity .source-label { margin-inline-start: auto; }
.record-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); margin: 0;
  padding-block-start: var(--space-4); border-top: 1px solid var(--line); }
.record-facts dt { color: var(--muted); font-size: var(--text-xs); }
.record-facts dd { margin: 0; font-weight: 600; }
.record-section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); margin-block-end: var(--space-3); }
.record-section-heading p { color: var(--muted); font-size: var(--text-xs); }

@media (max-width: 1100px) {
  .bento > * { grid-column: span 12; }
  .grid-2, .grid-form { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .admin { display: block; }
  .side { position: relative; height: auto; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: var(--space-2) var(--space-3);
    padding: var(--space-3) var(--space-4); border-inline-end: 0; border-bottom: 1px solid var(--line); overflow: visible; }
  .side .brand small { display: block; }
  .mobile-menu { display: block; position: relative; justify-self: end; }
  .mobile-menu > summary { display: flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: 44px; padding: 0 var(--space-3);
    border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--card); color: var(--ink); list-style: none; cursor: pointer; }
  .mobile-menu > summary::-webkit-details-marker { display: none; }
  .mobile-menu > summary .ic { width: 18px; height: 18px; }
  .mobile-menu[open] .side-nav { position: absolute; z-index: 30; inset-inline-end: 0; top: calc(100% + 8px); display: grid; width: min(320px, calc(100vw - 32px)); max-height: min(70dvh, 560px); overflow: auto;
    padding: var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--card); box-shadow: var(--shadow-float); }
  .mobile-menu .side-nav section { display: grid; gap: 2px; }
  .mobile-menu .side-nav h2 { display: block; padding-inline: var(--space-3); }
  .mobile-menu .side-nav a { min-height: 44px; white-space: normal; }
  .side-user { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; margin: 0; padding: var(--space-2) 0 0; border-top: 1px solid var(--line); }
  .side-user p { display: block; padding: 0; }
  .stage { padding: var(--space-4); }
  .filter-menu[open] .filter-fields { position: static; width: 100%; margin-block-start: var(--space-2); box-shadow: none; }
  .record-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .patients-tools { align-items: stretch; flex-direction: column; }
  .patients-tools .search { max-width: none; }
  .chart-row { flex-direction: column; align-items: stretch; }
  .donut { margin-inline: auto; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
