/* Health record — stylesheet.
   One typeface (Source Sans 3, vendored), one brand blue, red reserved for clinical danger (documented severe
   risks, critical results) and always paired with a word. Light is the default on every device; dark applies
   only when chosen in Settings (html[data-theme="dark"]). Borders separate things; nothing casts a shadow.
   Radius: 4px on controls, 6px on panels, 0 on clinical blocks, tables, bars and print. Spacing is a 4px grid. */

/* ---------- Typeface (SIL OFL 1.1, see vendor/fonts/OFL.txt) ---------- */
@font-face { font-family: "Source Sans 3"; font-style: normal; font-weight: 400; font-display: swap; src: url("vendor/fonts/source-sans-3-latin-400-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Source Sans 3"; font-style: normal; font-weight: 600; font-display: swap; src: url("vendor/fonts/source-sans-3-latin-600-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Source Sans 3"; font-style: normal; font-weight: 700; font-display: swap; src: url("vendor/fonts/source-sans-3-latin-700-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Source Sans 3"; font-style: italic; font-weight: 400; font-display: swap; src: url("vendor/fonts/source-sans-3-latin-400-italic.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Source Sans 3"; font-style: normal; font-weight: 400; font-display: swap; src: url("vendor/fonts/source-sans-3-latin-ext-400-normal.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Source Sans 3"; font-style: normal; font-weight: 600; font-display: swap; src: url("vendor/fonts/source-sans-3-latin-ext-600-normal.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Source Sans 3"; font-style: normal; font-weight: 700; font-display: swap; src: url("vendor/fonts/source-sans-3-latin-ext-700-normal.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
/* Metric-matched fallback so text does not jump while the webfont arrives (x-height 486 vs Arial 519). */
@font-face { font-family: "Source Sans Fallback"; src: local("Helvetica Neue"), local("Arial"), local("Roboto"); size-adjust: 93.6%; ascent-override: 109%; descent-override: 43%; line-gap-override: 0%; }

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  /* surfaces (cool, brand-tinted neutrals; never cream) */
  --page: #f5f7f9;
  --surface: #ffffff;
  --surface-2: #f0f3f6;
  --rule: #dde0e4;
  --rule-strong: #7b8187;        /* control borders: 3.94:1 on white */
  /* text */
  --ink: #161b21;                /* 17.3:1 on white */
  --ink-2: #43484f;              /* 9.2:1 */
  --ink-3: #595e64;              /* 6.5:1 white, 5.9:1 on surface-2 */
  /* brand */
  --brand: #2c5a9d;              /* app bar, links (6.9:1), primary button, focus */
  --brand-strong: #184687;       /* pressed / hover */
  --brand-tint: #e6eefa;         /* selected navigation row */
  --on-brand: #ffffff;
  --bar: var(--brand);
  --band: #dce7f5;               /* chart "standard range" fill */
  /* clinical danger — the only red; text ≥ 7.6:1 on every surface */
  --critical: #99151d;
  --focus: var(--brand);
  /* compare-chart series (identity, not decoration; dashed/dotted as the second channel) */
  --series-1: var(--brand); --series-2: #a35a0f; --series-3: #7a3b7d; --series-4: #4d7a3a;   /* validated: CVD ΔE ≥ 15, all ≥ 5:1 on white */
  /* type */
  --font: "Source Sans 3", "Source Sans Fallback", "Helvetica Neue", Arial, sans-serif;
  --t-name: 1.875rem;            /* 30px patient name */
  --t-h1: 1.5rem;                /* 24px page titles */
  --t-h2: 1.25rem;               /* 20px section headings */
  --t-h3: 1.0625rem;             /* 17px sub-headings (600) */
  --t-body: 1.0625rem;           /* 17px */
  --t-meta: 0.9375rem;           /* 15px */
  --t-small: 0.875rem;           /* 14px — tab-bar labels only */
  --t-axis: 0.875rem;            /* 14px — chart axes and point labels */
  /* spacing (4px grid) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  /* shape */
  --r-control: 4px;
  --r-panel: 6px;
  /* layout */
  --gutter: 16px;
  --bar-h: 56px;
  --tab-h: 64px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --head-h: calc(var(--bar-h) + var(--sat));
  /* z-index scale */
  --z-sticky: 10; --z-bar: 20; --z-toast: 30; --z-overlay: 40; --z-curtain: 100;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #101317;
  --surface: #171b20;
  --surface-2: #20252b;
  --rule: #30363d;
  --rule-strong: #737a83;        /* 3.99:1 */
  --ink: #eceff2;                /* 15:1 */
  --ink-2: #b9bec4;              /* 9.3:1 */
  --ink-3: #a0a5ab;              /* 6.2:1 on surface-2 */
  --brand: #84b4f3;              /* links 8.1:1 */
  --brand-strong: #a6c8f7;
  --brand-tint: #1d2f47;
  --on-brand: #0c121a;           /* dark text on the light-blue button, 8.8:1 */
  --bar: #17273c;                /* app bar; white 15:1 */
  --band: #223349;
  --critical: #f89a92;           /* 8.3:1 on surface, 7.4:1 on surface-2 */
  --series-1: #5f94da; --series-2: #c18434; --series-3: #b16ec0; --series-4: #50a064;   /* validated against the dark surface */
}
html { font-size: 100%; -webkit-text-size-adjust: 100%; height: 100%; }
html[data-textsize="large"] { font-size: 112.5%; }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--t-body);
  line-height: 1.5;
  min-height: 100%;
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
a { color: var(--brand); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.14em; }
a:hover { color: var(--brand-strong); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: var(--r-control); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.2; text-wrap: balance; }
h1 { font-size: var(--t-h1); }
h2 { font-size: var(--t-h2); line-height: 1.25; }
h3 { font-size: var(--t-h3); }
p { margin: 0 0 var(--s3); text-wrap: pretty; }
p:last-child { margin-bottom: 0; }
ul, ol { margin: 0 0 var(--s3); padding-left: 1.3em; }
small, .small { font-size: var(--t-meta); }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.num { font-variant-numeric: tabular-nums lining-nums; }
.nowrap { white-space: nowrap; }
.prose { max-width: 70ch; }
.measure { max-width: 70ch; }
.id { overflow-wrap: anywhere; letter-spacing: 0.01em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: var(--s2); background: var(--surface); color: var(--ink); padding: var(--s2) var(--s3); z-index: var(--z-curtain); border: 1px solid var(--rule-strong); border-radius: var(--r-control); }
.skip:focus { left: var(--s2); }
.noscript { padding: var(--s5); }
hr { border: 0; border-top: 1px solid var(--rule); margin: var(--s4) 0; }

/* ---------- App shell ---------- */
.app { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-rows: auto 1fr; grid-template-columns: minmax(0, 1fr); }
.appbar {
  position: sticky; top: 0; z-index: var(--z-bar);
  min-height: var(--head-h);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s2);
  padding: var(--sat) calc(var(--gutter) - 6px + var(--sar)) 0 calc(var(--gutter) + var(--sal));
  background: var(--bar); color: #fff;
}
.appbar__title { color: #fff; font-weight: 600; font-size: var(--t-body); text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; }
.appbar__title:hover { color: #fff; text-decoration: underline; }
.appbar__actions { display: flex; align-items: center; gap: var(--s1); }
.iconbtn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: var(--r-control); color: inherit; background: transparent; border: 0; text-decoration: none; }
.iconbtn:hover { background: rgba(255, 255, 255, 0.14); color: inherit; }
.appbar .iconbtn:focus-visible { outline-color: #fff; }
.iconbtn svg { width: 24px; height: 24px; }
.offline-strip { margin: 0; padding: var(--s2) calc(var(--gutter) + var(--sar)) var(--s2) calc(var(--gutter) + var(--sal)); background: var(--surface-2); color: var(--ink); border-bottom: 1px solid var(--rule); font-size: var(--t-meta); }

.sidebar { display: none; }
.view { padding: var(--s5) calc(var(--gutter) + var(--sar)) calc(var(--tab-h) + var(--sab) + var(--s6)) calc(var(--gutter) + var(--sal)); max-width: 100%; min-width: 0; }
.view:focus { outline: none; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-bar);
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tab-h) + var(--sab));
  padding: 0 var(--sar) var(--sab) var(--sal);
  background: var(--surface); border-top: 1px solid var(--rule);
}
.tabbar a { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--ink-2); font-size: var(--t-small); line-height: 1.2; font-weight: 600; text-decoration: none; min-height: 44px; }
.tabbar a:hover { color: var(--ink); }
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a[aria-current="page"] { color: var(--brand); }
.tabbar a[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 50%; width: 48px; height: 2px; transform: translateX(-50%); background: var(--brand); }

@media (min-width: 900px) {
  :root { --gutter: 32px; }
  .app { grid-template-columns: 248px minmax(0, 1fr); }
  .appbar, .offline-strip { grid-column: 1 / -1; }
  .sidebar { display: block; position: sticky; top: var(--head-h); height: calc(100vh - var(--head-h)); height: calc(100dvh - var(--head-h)); overflow: auto; padding: var(--s4) var(--s3) var(--s4) calc(var(--s3) + var(--sal)); background: var(--surface); border-right: 1px solid var(--rule); }
  .view { padding: var(--s6) calc(var(--gutter) + var(--sar)) var(--s7) var(--gutter); max-width: 1040px; }
  .tabbar { display: none; }
}
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav a { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s3); border-radius: var(--r-control); color: var(--ink); text-decoration: none; font-size: var(--t-meta); min-height: 44px; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--brand-tint); color: var(--brand); font-weight: 600; }
.nav a svg { width: 20px; height: 20px; flex: none; }
.nav__group { margin: var(--s4) var(--s3) var(--s1); font-size: var(--t-meta); color: var(--ink-3); font-weight: 600; }
.nav__group:first-child { margin-top: 0; }

.loading { padding: var(--s6) 0; color: var(--ink-2); }

/* ---------- Page scaffolding ---------- */
.page-head { margin-bottom: var(--s5); }
.page-head h1 { margin-bottom: var(--s1); }
.page-head__sub { color: var(--ink-2); margin: 0; max-width: 70ch; }
.page-head__actions { margin-top: var(--s3); }
.backlink { display: inline-flex; align-items: center; gap: 2px; min-height: 44px; margin: calc(-1 * var(--s2)) 0 0 -4px; font-size: var(--t-meta); font-weight: 600; }
.backlink svg { width: 18px; height: 18px; }
.section { margin: 0 0 var(--s6); }
.section__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s3); }
.section__head .count { font-weight: 400; color: var(--ink-3); }
summary.section__head { cursor: pointer; list-style: none; min-height: 44px; align-items: center; }
summary.section__head::-webkit-details-marker { display: none; }
.section__head .panel__title { margin: 0; }
.section__more { font-size: var(--t-meta); font-weight: 600; white-space: nowrap; min-height: 44px; display: inline-flex; align-items: center; }
.section__note { color: var(--ink-2); font-size: var(--t-meta); margin: 0 0 var(--s3); max-width: 70ch; }
.section__head + .section__note { margin-top: calc(-1 * var(--s2)); }
.note { color: var(--ink-2); margin: 0 0 var(--s4); max-width: 70ch; }
.note strong { color: var(--ink); }
.grid-2 { display: grid; gap: var(--s5); }
@media (min-width: 760px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-panel); }
.panel--pad { padding: var(--s4); }
.panel--pad > :last-child { margin-bottom: 0; }
.panel__title { font-size: var(--t-h3); margin-bottom: var(--s2); }
.empty { color: var(--ink-2); margin: 0; max-width: 70ch; }
.empty strong { color: var(--ink); }
.empty__action { margin-top: var(--s3); }

/* lists & rows: one system everywhere */
.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-top: 1px solid var(--rule); }
.row { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); min-height: 56px; color: inherit; width: 100%; text-align: left; background: none; border: 0; text-decoration: none; }
a.row:hover, button.row:hover { background: var(--surface-2); color: inherit; }
a.row:active, button.row:active { background: var(--surface-2); }
.row--compact { min-height: 48px; padding: var(--s2) var(--s4); }
.row__lead { flex: none; width: 24px; color: var(--brand); display: inline-flex; }
.row__lead svg { width: 24px; height: 24px; }
.row__main { flex: 1 1 auto; min-width: 0; }
.row__title { font-weight: 600; line-height: 1.3; }
.row__sub { line-height: 1.35; margin-top: var(--s1); font-weight: 600; }
.row__meta { color: var(--ink-2); font-size: var(--t-meta); margin-top: 2px; line-height: 1.35; }
.row__kind { color: var(--ink); font-weight: 600; }
.row__aside { flex: none; text-align: right; color: var(--ink); font-variant-numeric: tabular-nums; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; max-width: 44%; }
.row__chev { flex: none; color: var(--ink-3); width: 18px; height: 18px; }
.row--dim .row__title { color: var(--ink-2); font-weight: 400; }
.row--flush { padding-left: 0; padding-right: 0; }
/* a row whose main area navigates, with a separate trailing target (phone number) */
.row-split { display: flex; align-items: stretch; }
.row-split > .row { flex: 1 1 auto; min-width: 0; }
.row__call { flex: none; display: inline-flex; align-items: center; min-height: 44px; padding: 0 var(--s4); font-variant-numeric: tabular-nums; white-space: nowrap; border-left: 1px solid var(--rule); }
.row__call:hover { background: var(--surface-2); }
.panel__foot { color: var(--ink-2); font-size: var(--t-meta); padding: var(--s2) var(--s4); margin: 0; border-top: 1px solid var(--rule); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 48px; padding: var(--s2) var(--s4); border-radius: var(--r-control); border: 1px solid var(--rule-strong); background: var(--surface); color: var(--ink); font-weight: 600; text-decoration: none; transition: background-color 150ms var(--ease), border-color 150ms var(--ease); }
.btn:hover:not([disabled]):not([aria-disabled="true"]) { background: var(--surface-2); color: var(--ink); }
.btn:active:not([disabled]):not([aria-disabled="true"]) { background: var(--surface-2); border-color: var(--ink-3); }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn--primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn--primary:hover:not([disabled]):not([aria-disabled="true"]) { background: var(--brand-strong); border-color: var(--brand-strong); color: var(--on-brand); }
.btn--primary:active:not([disabled]):not([aria-disabled="true"]) { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn--block { width: 100%; }
.btn--tall { min-height: 52px; font-size: 1.125rem; }
.btn--link { background: transparent; border-color: transparent; color: var(--brand); text-decoration: underline; text-underline-offset: 0.14em; padding-left: var(--s2); padding-right: var(--s2); }
.btn--link:hover:not([disabled]) { background: transparent; color: var(--brand-strong); }
.btn--small { min-height: 44px; padding: var(--s1) var(--s3); font-size: var(--t-meta); }
.btn[disabled], .btn[aria-disabled="true"] { cursor: default; color: var(--ink-3); background: var(--surface-2); border-color: var(--rule); opacity: 1; }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s3); align-items: center; }
.btn-note { color: var(--ink-2); font-size: var(--t-meta); margin: var(--s2) 0 0; max-width: 70ch; }
.app--locked .appbar__actions { display: none; }
/* the hand-over action: full width on a phone, capped on a desk */
.cta { margin: var(--s4) 0 var(--s5); }
.cta .btn { width: 100%; }
@media (min-width: 900px) { .cta .btn { width: auto; min-width: 320px; max-width: 440px; } }

/* flags & values: words, never squares. Ordinary High / Low are ink; critical is the only red. */
.flag { color: var(--ink); font-weight: 600; white-space: nowrap; }
.flag--critical { color: var(--critical); font-weight: 700; }
.val { font-variant-numeric: tabular-nums lining-nums; }
.val--abn { font-weight: 600; }
.val--critical { font-weight: 700; }
.sev { color: var(--critical); font-weight: 700; }
.cites { color: var(--ink-2); font-size: var(--t-meta); }
.cites a { color: var(--ink-2); }
.cites a:hover { color: var(--ink); }

/* ---------- Critical information: a safety-card block, not a banner ---------- */
.crit { border-top: 2px solid var(--critical); padding-top: var(--s3); margin: 0 0 var(--s5); background: transparent; }
.crit__title { color: var(--critical); font-size: var(--t-h2); font-weight: 600; margin: 0 0 var(--s2); }
.crit__list { list-style: none; margin: 0; padding: 0; counter-reset: crit; }
.crit__list > li { counter-increment: crit; display: grid; grid-template-columns: 2rem minmax(0, 1fr); gap: 0 var(--s2); padding: var(--s3) 0; border-top: 1px solid var(--rule); }
.crit__list > li:first-child { border-top: 0; padding-top: 0; }
.crit__list > li:last-child { padding-bottom: 0; }
.crit__list > li::before { content: counter(crit); font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }
.crit__list--plain > li { grid-template-columns: minmax(0, 1fr); }
.crit__list--plain > li::before { content: none; }
.crit__text { font-weight: 400; line-height: 1.4; max-width: 70ch; }
.crit__text strong { font-weight: 700; }
.crit__label { font-weight: 700; }
.crit__label--critical { color: var(--critical); }
.crit__sub { color: var(--ink-2); font-size: var(--t-meta); margin-top: 2px; line-height: 1.4; }
.crit__sub a { color: var(--ink-2); }
.crit__none { font-weight: 600; margin: var(--s1) 0 0; }
.crit__none--unknown { color: var(--critical); }
.crit__more { margin: var(--s2) 0 0; font-size: var(--t-meta); }
.crit details { margin-top: var(--s2); font-size: var(--t-meta); color: var(--ink-2); }
.crit summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 600; color: var(--ink-2); }
/* shrinkable safety block: the whole bar toggles it; the red rule and red heading stay, so it is not a generic accordion */
details.crit--fold { padding-top: 0; }
details.crit--fold > summary.crit__bar { list-style: none; cursor: pointer; display: flex; align-items: center; flex-wrap: wrap; gap: var(--s1) var(--s3); min-height: 52px; padding: var(--s2) 0; margin: 0; color: var(--ink); font-weight: 600; }
details.crit--fold > summary.crit__bar::-webkit-details-marker { display: none; }
details.crit--fold > summary.crit__bar:hover { background: var(--surface-2); }
details.crit--fold > summary.crit__bar:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: var(--r-control); }
details.crit--fold .crit__title { margin: 0; flex: none; }
.crit__count { flex: 1 1 auto; min-width: 0; color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.crit__toggle { flex: none; display: inline-flex; align-items: center; gap: var(--s1); color: var(--brand); font-size: var(--t-meta); font-weight: 600; min-height: 44px; }
.crit__toggle svg { width: 20px; height: 20px; transition: transform 150ms var(--ease); }
details.crit--fold[open] .crit__toggle svg { transform: rotate(180deg); }
details.crit--fold[open] .crit__show, details.crit--fold:not([open]) .crit__hide { display: none; }
details.crit--fold > .crit__body { padding: var(--s1) 0 0; }
/* neutral tone for non-clinical sections (the Conditions problem list): ink rule and heading, same bar */
.crit--neutral { border-top-color: var(--ink); }
.crit--neutral .crit__title { color: var(--ink); }
.crit--neutral > .crit__body > .section__note { margin: var(--s1) 0 var(--s3); }

/* ---------- Patient header (hospital-style banner) ---------- */
.banner { padding: 0 0 var(--s4); margin: 0 0 var(--s5); border-bottom: 2px solid var(--ink); }
.banner__name { font-size: var(--t-name); font-weight: 700; line-height: 1.15; letter-spacing: -0.01em; margin: 0 0 var(--s1); }
.banner__sub { color: var(--ink-2); margin: 0; }
.banner__pairs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s1) var(--s4); margin: var(--s3) 0 0; }
@media (min-width: 600px) { .banner__pairs { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s5); } }
.pair { margin: 0; }
.pair--wide { grid-column: 1 / -1; }
.pair dt { display: inline; color: var(--ink-2); font-size: var(--t-meta); }
.pair dd { display: inline; margin: 0 0 0 var(--s1); font-weight: 600; font-variant-numeric: tabular-nums; }
.banner__alink { display: block; width: 100%; min-height: 44px; margin: var(--s2) 0 calc(-1 * var(--s2)); padding: 10px 0; border: 0; background: none; font-weight: 600; color: var(--ink); text-align: left; line-height: 1.4; font-size: var(--t-body); font-family: inherit; }
.banner__alink .label { margin-right: var(--s1); }
.banner__alink .label { color: var(--critical); font-weight: 700; }
.banner__alink .go { color: var(--brand); text-decoration: underline; font-weight: 600; }
.banner__alink--unknown .go { color: var(--critical); }
.sub { display: block; font-weight: 400; color: var(--ink-2); font-size: var(--t-meta); line-height: 1.35; }
.legend-key { display: inline-block; width: 20px; height: 0; border-top: 3px solid var(--k); vertical-align: middle; margin-right: var(--s2); }
.legend-key.dash { border-top-style: dashed; }
.legend-key.dot { border-top-style: dotted; }
.table td.date { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* quick links (Home, phone only: the desktop menu already lists them) */
.quick { display: grid; grid-template-columns: repeat(4, 1fr); }
.quick a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s1); padding: var(--s3) var(--s1); min-height: 76px; color: var(--ink); text-decoration: none; font-size: var(--t-meta); font-weight: 600; text-align: center; line-height: 1.2; }
.quick a + a { border-left: 1px solid var(--rule); }
.quick a:hover { background: var(--surface-2); color: var(--ink); }
.quick a svg { width: 26px; height: 26px; color: var(--brand); }
@media (min-width: 900px) { .quick { display: none; } }

/* key-value */
.kv { display: grid; grid-template-columns: minmax(96px, 36%) 1fr; gap: var(--s2) var(--s4); margin: 0; }
.kv dt { color: var(--ink-2); font-size: var(--t-meta); padding-top: 1px; }
.kv dd { margin: 0; }
.kv--tight { gap: var(--s1) var(--s3); }
.kv--links dd { line-height: 1.6; }

/* tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: var(--t-meta); font-weight: 600; color: var(--ink); background: var(--surface-2); padding: var(--s2) var(--s3); border-bottom: 1px solid var(--rule-strong); white-space: nowrap; }
.table td { padding: var(--s2) var(--s3); border-bottom: 1px solid var(--rule); vertical-align: top; overflow-wrap: anywhere; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table--dense td, .table--dense th { padding: 6px var(--s2); }
.table--clean { font-size: var(--t-body); }
.table--clean th { background: transparent; border-bottom-width: 1px; border-bottom-color: var(--rule-strong); padding-left: 0; }
.table--clean td { padding-left: 0; }
.table--clean td:last-child, .table--clean th:last-child { padding-right: 0; }
.panel .table-wrap .table th:first-child, .panel .table-wrap .table td:first-child { padding-left: var(--s4); }
.panel .table-wrap .table th:last-child, .panel .table-wrap .table td:last-child { padding-right: var(--s4); }
/* a history table that stacks into labelled rows on a narrow phone */
@media (max-width: 599px) {
  .table--stack thead { display: none; }
  .table--stack, .table--stack tbody { display: block; }
  .table--stack tr { display: block; padding: var(--s3) var(--s4); border-bottom: 1px solid var(--rule); }
  .table--stack tr:last-child { border-bottom: 0; }
  .table--stack td { display: block; padding: 0 !important; border: 0; text-align: left !important; white-space: normal !important; font-size: var(--t-meta); line-height: 1.35; }
  .table--stack td.lead { font-size: var(--t-body); font-weight: 600; }
  .table--stack td[data-th]::before { content: attr(data-th) ": "; color: var(--ink-2); }
  .table--stack td:empty { display: none; }
}

/* forms: every control has a visible label */
.field { display: block; margin-bottom: var(--s4); }
.field__label { display: block; font-weight: 600; font-size: var(--t-meta); margin-bottom: var(--s1); }
.field__hint { color: var(--ink-2); font-size: var(--t-meta); margin: var(--s1) 0 0; max-width: 70ch; }
.input { width: 100%; min-height: 48px; padding: var(--s2) var(--s3); border-radius: var(--r-control); border: 1px solid var(--rule-strong); background: var(--surface); color: var(--ink); }
.input:focus { border-color: var(--brand); outline: 3px solid var(--focus); outline-offset: 0; }
.input::placeholder { color: var(--ink-3); opacity: 1; }
.filters { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s3); align-items: flex-end; margin-bottom: var(--s4); }
.filters .field { flex: 1 1 calc(50% - 8px); min-width: 0; margin: 0; }
.filters .field--wide { flex: 1 1 100%; }
.filters .field--search { flex: 1 1 260px; }
@media (min-width: 700px) { .filters .field { flex: 0 1 auto; min-width: 180px; } .filters .field--search { flex: 1 1 260px; } }
.select { -webkit-appearance: none; appearance: none; width: 100%; min-height: 44px; padding: var(--s2) 36px var(--s2) var(--s3); border-radius: var(--r-control); border: 1px solid var(--rule-strong); background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23595e64' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center / 18px; color: var(--ink); font-size: var(--t-meta); max-width: 100%; text-overflow: ellipsis; }
:root[data-theme="dark"] .select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a0a5ab' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
.select--active { border-color: var(--brand); color: var(--brand); font-weight: 600; }
.searchbox__wrap { position: relative; }
.searchbox input { width: 100%; min-height: 48px; padding: var(--s2) 44px var(--s2) 44px; border-radius: var(--r-control); border: 1px solid var(--rule-strong); background: var(--surface); color: var(--ink); }
.searchbox input:focus { border-color: var(--brand); outline: 3px solid var(--focus); outline-offset: 0; }
.searchbox input::placeholder { color: var(--ink-3); opacity: 1; }
.searchbox__wrap > svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 22px; height: 22px; color: var(--ink-3); pointer-events: none; }
.searchbox .clear { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); color: var(--ink-2); }
.searchbox .clear:hover { background: var(--surface-2); }
.seg { display: flex; flex-wrap: wrap; gap: 0 var(--s4); border-bottom: 1px solid var(--rule); margin-bottom: var(--s4); }
.seg button, .seg a { flex: none; padding: var(--s2) 2px; margin-bottom: -1px; border: 0; border-bottom: 2px solid transparent; background: none; font-weight: 600; color: var(--ink-2); white-space: nowrap; min-height: 44px; text-decoration: none; }
.seg button:hover, .seg a:hover { color: var(--ink); }
.seg button:active, .seg a:active { color: var(--ink); background: var(--surface-2); }
.seg button[aria-pressed="true"], .seg a[aria-current="true"], .seg a[aria-current="page"] { color: var(--brand); border-bottom-color: var(--brand); }
.seg .count { color: var(--ink-3); font-weight: 400; }
.seg--inline { display: inline-flex; margin-bottom: 0; }
.seg__note { color: var(--ink-2); font-size: var(--t-meta); line-height: 1.4; margin: calc(-1 * var(--s2)) 0 var(--s4); max-width: 70ch; }
.check { display: inline-flex; align-items: center; gap: var(--s2); min-height: 44px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--brand); margin: 0; }
.count { color: var(--ink-3); font-weight: 400; }
details.more { margin: 0 0 var(--s4); }
details.more > summary { cursor: pointer; font-weight: 600; color: var(--brand); min-height: 44px; display: flex; align-items: center; list-style: none; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: ""; display: inline-block; width: 8px; height: 8px; margin: 0 10px 2px 4px; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg); transition: transform 150ms var(--ease); }
details.more[open] > summary::before { transform: rotate(-135deg); margin-top: 6px; }
details.more > summary .count { margin-left: var(--s2); }
details.more--ink > summary { color: var(--ink); font-size: var(--t-h3); }
.filters__active { color: var(--ink-2); font-size: var(--t-meta); margin: 0 0 var(--s3); }
.filters__active a { margin-left: var(--s2); }

/* skeleton rows while the big data files load */
.skeleton { list-style: none; margin: 0; padding: 0; }
.skeleton li { padding: var(--s3) var(--s4); min-height: 56px; border-top: 1px solid var(--rule); }
.skeleton li:first-child { border-top: 0; }
.skeleton i { display: block; height: 0.9em; border-radius: 2px; background: var(--surface-2); margin: 5px 0; }
.skeleton i + i { width: 55%; }
.skeleton__note { padding: var(--s3) var(--s4); color: var(--ink-2); font-size: var(--t-meta); border-top: 1px solid var(--rule); margin: 0; }

/* toasts: a docked bar, not a floating pill */
.toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--tab-h) + var(--sab)); display: flex; flex-direction: column; z-index: var(--z-toast); }
@media (min-width: 900px) { .toasts { left: auto; right: var(--s5); bottom: var(--s5); width: min(92vw, 440px); } }
.toast { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s3) var(--gutter); background: var(--surface); color: var(--ink); border-top: 1px solid var(--rule-strong); font-size: var(--t-meta); }
@media (min-width: 900px) { .toast { border: 1px solid var(--rule-strong); border-radius: var(--r-control); margin-top: var(--s2); } }
.toast button { background: transparent; border: 0; color: var(--brand); font-weight: 600; text-decoration: underline; min-height: 44px; padding: 0 var(--s2); white-space: nowrap; }

/* sticky compare bar */
.sticky-bar { position: sticky; top: calc(var(--head-h) + var(--s2)); z-index: var(--z-sticky); display: flex; justify-content: space-between; align-items: center; gap: var(--s3); padding: var(--s2) var(--s4); margin-bottom: var(--s4); }

/* ---------- Results ---------- */
.result-row { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); min-height: 56px; color: inherit; text-decoration: none; }
a.result-row:hover { background: var(--surface-2); color: inherit; }
.result-row__main { flex: 1 1 auto; min-width: 0; }
.result-row__name { font-weight: 600; line-height: 1.3; }
.result-row__meta { font-size: var(--t-meta); color: var(--ink-2); margin-top: 2px; }
.result-row__value { flex: none; text-align: right; font-variant-numeric: tabular-nums; max-width: 44%; overflow-wrap: anywhere; line-height: 1.3; }
.result-row__unit { color: var(--ink-2); font-size: var(--t-meta); }
.result-row__flag { display: block; font-size: var(--t-meta); }
.result-row .check { flex: none; }
.lab-latest { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s1) var(--s2); margin: 0 0 var(--s2); }
.lab-latest__value { font-size: var(--t-name); font-weight: 700; line-height: 1.1; }
.lab-latest__unit { color: var(--ink-2); font-size: var(--t-body); }
.lab-latest__flag { font-weight: 600; font-size: var(--t-h2); }
.lab-latest__flag--critical { color: var(--critical); font-weight: 700; }
.lab-latest__meta { width: 100%; color: var(--ink-2); font-size: var(--t-meta); margin: 0; }
.rangebar { margin: var(--s5) 0 var(--s2); }
.rangebar__value { position: relative; height: 1.5em; font-size: var(--t-meta); font-weight: 600; font-variant-numeric: tabular-nums; }
.rangebar__value span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.rangebar__value span.start { transform: none; }
.rangebar__value span.end { transform: translateX(-100%); }
.rangebar__track { position: relative; height: 16px; background: var(--surface); border: 1px solid var(--rule); border-radius: 2px; }
.rangebar__band { position: absolute; top: -1px; bottom: -1px; background: var(--band); border: 1px solid var(--rule-strong); }
.rangebar__marker { position: absolute; top: -6px; width: 4px; height: 26px; margin-left: -2px; background: var(--ink); border-radius: 1px; }
.rangebar__marker--critical { background: var(--critical); }
.rangebar__labels { position: relative; height: 1.4em; font-size: var(--t-meta); color: var(--ink-2); font-variant-numeric: tabular-nums; margin-top: var(--s1); }
.rangebar__labels span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.rangebar__labels span.start { transform: none; }
.rangebar__labels span.end { transform: translateX(-100%); }
.rangebar__caption { margin: var(--s2) 0 0; }

/* ---------- Health summary (the clinician's one-pager) ---------- */
.summary { max-width: 860px; }
.summary a:not(.btn):not(.backlink) { color: var(--ink); text-decoration: none; }
.summary a:not(.btn):not(.backlink):hover, .summary a:not(.btn):not(.backlink):focus-visible { text-decoration: underline; }
.summary .cites a, .summary .crit__sub a { color: var(--ink-2); text-decoration: underline; }
.summary .since a { color: var(--brand); text-decoration: underline; }
.summary__section { margin: 0 0 var(--s5); }
.summary__section > h2 { margin-bottom: var(--s2); display: flex; justify-content: space-between; align-items: baseline; gap: var(--s3); flex-wrap: wrap; }
.summary__section > h2 .count { font-size: var(--t-meta); }
.summary-list { list-style: none; margin: 0; padding: 0; }
.summary-list li { padding: var(--s3) 0; border-top: 1px solid var(--rule); display: flex; justify-content: space-between; gap: var(--s3); align-items: baseline; }
.summary-list li:first-child { border-top: 0; padding-top: 0; }
.summary-list .main { font-weight: 600; flex: 1 1 auto; min-width: 0; }
.summary-list .sub { display: block; font-weight: 400; color: var(--ink-2); font-size: var(--t-meta); line-height: 1.35; }
.summary-list .since { flex: 0 1 auto; max-width: 44%; font-size: var(--t-meta); color: var(--ink-2); text-align: right; font-variant-numeric: tabular-nums; }
.summary-results .value { flex: none; text-align: right; font-variant-numeric: tabular-nums; max-width: 44%; line-height: 1.3; }
.summary-results .value .unit { color: var(--ink-2); font-size: var(--t-meta); }
.summary-results .value .flag { display: block; font-size: var(--t-meta); }
.summary-meds td.dose { font-weight: 600; font-variant-numeric: tabular-nums; width: 44%; }
.summary__footer { color: var(--ink-2); font-size: var(--t-meta); margin-top: var(--s4); max-width: 70ch; }
@media (min-width: 900px) {
  .summary__cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 var(--s6); }
}

/* ---------- Charts ---------- */
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; font-family: var(--font); }
.chart .grid line { stroke: var(--rule); stroke-width: 1; }
.chart .axis text { fill: var(--ink-3); font-size: 14px; font-variant-numeric: tabular-nums; }
.chart .axis line { stroke: var(--rule-strong); }
.chart .band { fill: var(--band); }
.chart .band-edge { fill: none; stroke: var(--rule-strong); stroke-width: 1; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .pt { stroke: var(--surface); stroke-width: 2; }
.chart .pt--abn { fill: var(--surface) !important; stroke: var(--ink); stroke-width: 2; }
.chart .pt--critical { fill: var(--critical) !important; stroke: var(--surface); stroke-width: 2; }
.chart .pt--selected { stroke: var(--ink); stroke-width: 3; }
.chart .ptlabel { font-size: 14px; font-weight: 600; fill: var(--ink); font-variant-numeric: tabular-nums; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.chart .ptlabel--critical { fill: var(--critical); }
.chart .plot-title { font-size: 14px; font-weight: 600; fill: var(--ink); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:focus { outline: none; }
.chart .single-note { fill: var(--ink-2); font-size: 14px; }
.chart .bar { fill: var(--brand); }
.chart .barlabel { font-size: 14px; fill: var(--ink-2); font-variant-numeric: tabular-nums; }
.chart .catlabel { font-size: 14px; fill: var(--ink); }
.chart .endlabel { font-size: 14px; font-weight: 600; fill: var(--ink); }
.chart__tip { position: absolute; pointer-events: none; background: var(--surface); color: var(--ink); border: 1px solid var(--rule-strong); padding: var(--s1) var(--s2); border-radius: var(--r-control); font-size: var(--t-meta); line-height: 1.35; max-width: min(280px, calc(100vw - 32px)); white-space: normal; transform: translate(-50%, calc(-100% - 10px)); opacity: 0; transition: opacity 120ms; z-index: 2; }
.chart__tip.on { opacity: 1; }
.chart__tip .v { font-weight: 700; font-variant-numeric: tabular-nums; }
.chart-detail { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); margin-top: var(--s3); padding: var(--s3) 0 0; border-top: 1px solid var(--rule); }
.chart-detail__text { flex: 1 1 220px; min-width: 0; line-height: 1.4; }
.chart-detail__text b { font-variant-numeric: tabular-nums; }
.chart-detail__nav { display: inline-flex; gap: var(--s1); }
.chart-detail .iconbtn { color: var(--ink); border: 1px solid var(--rule-strong); }
.chart-detail .iconbtn:hover:not([disabled]) { background: var(--surface-2); }
.chart-detail .iconbtn[disabled] { color: var(--ink-3); border-color: var(--rule); cursor: default; }
.chart-detail__src { min-height: 44px; display: inline-flex; align-items: center; }
.chart-keys { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); font-size: var(--t-meta); color: var(--ink-2); margin: var(--s2) 0 0; list-style: none; padding: 0; }
.chart-keys li { display: inline-flex; align-items: center; gap: var(--s2); }
.chart-keys .key { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--brand); }
.chart-keys .key--abn { background: var(--surface); border: 2px solid var(--ink); box-shadow: none; }
.chart-keys .key--critical { background: var(--critical); border-radius: 0; transform: rotate(45deg); width: 9px; height: 9px; border: 0; box-shadow: none; }
.legend { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); font-size: var(--t-meta); margin: 0 0 var(--s2); list-style: none; padding: 0; }
.legend li { display: inline-flex; align-items: center; gap: var(--s2); }
.legend i { display: inline-block; width: 20px; height: 0; border-top: 3px solid var(--k); }
.legend i.dash { border-top-style: dashed; }
.legend i.dot { border-top-style: dotted; }
.chart-multi { display: grid; gap: var(--s4); }
.chart-multi h3 { margin-bottom: var(--s1); }
.chart-caption { color: var(--ink-2); font-size: var(--t-meta); margin: var(--s2) 0 0; max-width: 70ch; }
details.tableview > summary { cursor: pointer; font-weight: 600; color: var(--brand); min-height: 44px; display: flex; align-items: center; }

/* ---------- Timeline ---------- */
.tl-month { margin-bottom: var(--s5); }
.tl-month > h2 { position: sticky; top: var(--head-h); background: var(--page); padding: var(--s2) 0; z-index: var(--z-sticky); font-size: var(--t-h3); border-bottom: 1px solid var(--ink); margin-bottom: 0; }
.tl-month > h2 .faint { font-weight: 400; }
.tl-day { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 0 var(--s3); border-bottom: 1px solid var(--rule); }
.tl-day__date { padding: var(--s3) 0; text-align: left; line-height: 1.2; font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: var(--t-meta); }
.tl-day__date b { display: block; font-size: var(--t-h2); color: var(--ink); font-weight: 600; }
.tl-items { min-width: 0; }
.tl-item { display: flex; gap: var(--s2); align-items: flex-start; padding: var(--s3) 0; color: inherit; text-align: left; width: 100%; background: none; border: 0; border-top: 1px solid var(--rule); text-decoration: none; min-height: 44px; }
.tl-item:first-child { border-top: 0; }
a.tl-item:hover, button.tl-item:hover { background: var(--surface-2); color: inherit; }
.tl-item__body { flex: 1 1 auto; min-width: 0; }
.tl-item__title { display: block; font-weight: 600; line-height: 1.3; }
.tl-item__meta { display: block; font-size: var(--t-meta); color: var(--ink-2); margin-top: 2px; }
.tl-item__meta b { color: var(--ink); font-weight: 600; }
.tl-item__amt { flex: none; font-variant-numeric: tabular-nums; color: var(--ink); white-space: nowrap; }
.tl-item .row__chev { margin-top: 3px; }
.tl-claims { display: none; margin: 0 0 var(--s3); padding: 0; list-style: none; font-size: var(--t-meta); }
.tl-claims.open { display: block; }
.tl-claims li { display: flex; justify-content: space-between; gap: var(--s3); padding: var(--s1) 0; border-top: 1px solid var(--rule); }
.tl-claims .amt { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Documents ---------- */
.doc-view .page-head h1 { font-size: var(--t-h1); line-height: 1.25; }
.doc-img { max-width: 100%; height: auto; border: 1px solid var(--rule); display: block; background: #fff; }
.doc-text { white-space: pre-wrap; font-family: inherit; font-size: var(--t-meta); line-height: 1.5; background: var(--surface); border: 1px solid var(--rule); padding: var(--s4); max-height: 70vh; overflow: auto; margin: 0; }
.findings { margin: 0 0 var(--s3); }
.findings li { margin-bottom: var(--s1); }
.subhead { font-size: var(--t-h3); font-weight: 600; margin: var(--s4) 0 var(--s1); }
.subhead--critical { color: var(--critical); }
details.review { font-size: var(--t-meta); color: var(--ink-2); }
details.review > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 600; }
.pager { display: flex; justify-content: center; margin: var(--s4) 0; }

/* ---------- Medicines ---------- */
.med-event { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: var(--s1) var(--s3); padding: var(--s3) 0; border-top: 1px solid var(--rule); }
.med-event:first-child { border-top: 0; padding-top: 0; }
.med-event__date { font-size: var(--t-meta); color: var(--ink-2); font-variant-numeric: tabular-nums; padding-top: 2px; }
.med-event__action { font-weight: 600; }
.med-event__detail { color: var(--ink-2); font-size: var(--t-meta); }
.med-event__written { font-size: var(--t-meta); color: var(--ink-2); }

/* ---------- Status history ---------- */
.status-hist { list-style: none; margin: 0; padding: 0; }
.status-hist li { display: grid; grid-template-columns: 110px 1fr; gap: var(--s3); padding: var(--s2) 0; border-top: 1px solid var(--rule); }
.status-hist li:first-child { border-top: 0; padding-top: 0; }
.status-hist .d { color: var(--ink-2); font-size: var(--t-meta); font-variant-numeric: tabular-nums; }

/* ---------- Markdown ---------- */
.md h2 { font-size: var(--t-h3); margin: var(--s4) 0 var(--s1); }
.md h3 { font-size: var(--t-body); margin: var(--s3) 0 var(--s1); }
.md h2:first-child, .md h3:first-child { margin-top: 0; }
.md p { margin: 0 0 var(--s3); }
.md ul, .md ol { margin: 0 0 var(--s3); }
.md code { font-family: inherit; font-weight: 600; }
.md a.cite { color: var(--ink-2); font-size: var(--t-meta); text-decoration: underline; }

/* ---------- Progress ---------- */
.progress { height: 8px; background: var(--surface-2); border-radius: 2px; overflow: hidden; }
.progress > div { height: 100%; background: var(--brand); transform-origin: left; transform: scaleX(0); transition: transform 200ms var(--ease); }

/* ---------- Privacy curtain ---------- */
.curtain { position: fixed; inset: 0; z-index: var(--z-curtain); background: var(--page); display: none; }
body.is-hidden .curtain { display: block; }

/* ---------- Locked state & unlock screen ---------- */
.app--locked .sidebar, .app--locked .tabbar { display: none !important; }
.app--locked { grid-template-columns: minmax(0, 1fr) !important; }
.app--locked .view { padding-bottom: var(--s6); }
.unlock { max-width: 440px; margin: var(--s4) auto 0; }
.unlock h1 { margin-bottom: var(--s2); }
.unlock__form { margin-top: var(--s5); }
.unlock__field { display: flex; gap: var(--s2); align-items: stretch; }
.unlock__field .input { flex: 1 1 auto; min-width: 0; min-height: 52px; font-size: 1.125rem; }
.unlock__field .btn { min-height: 52px; }
.unlock__msg { margin: var(--s3) 0 0; font-weight: 600; }
.unlock__msg:empty { display: none; }
.unlock__msg--busy { color: var(--ink-2); font-weight: 400; }
.unlock__msg--error { color: var(--critical); }
.unlock__help { margin-top: var(--s5); }

/* ---------- PDF viewer ---------- */
.pdfview { border: 1px solid var(--rule); background: var(--surface-2); overflow: hidden; }
.pdfview__bar { display: flex; justify-content: space-between; align-items: center; gap: var(--s2); padding: var(--s1) var(--s2) var(--s1) var(--s3); border-bottom: 1px solid var(--rule); background: var(--surface); font-size: var(--t-meta); min-height: 52px; }
.pdfview__count { font-variant-numeric: tabular-nums; }
.pdfview__zoom { display: inline-flex; align-items: center; gap: 2px; }
.pdfview .iconbtn { color: var(--ink); font-size: 1.3rem; font-weight: 600; }
.pdfview .iconbtn:hover:not([disabled]) { background: var(--surface-2); }
.pdfview .iconbtn[disabled], .pdfview .btn[disabled] { color: var(--ink-3); cursor: default; background: transparent; border-color: var(--rule); }
.pdfview__scroll { max-height: 78vh; overflow: auto; -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y; overscroll-behavior: contain; }
.pdfview__pages { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s2); padding: var(--s2); width: max-content; min-width: 100%; }
.pdfview__page { background: #fff; border: 1px solid var(--rule); }
.pdfview__page canvas { display: block; }
/* full-screen reading: one scroll region under a 56px toolbar */
.pdfview--full { position: fixed; inset: 0; z-index: var(--z-overlay); border: 0; display: flex; flex-direction: column; }
.pdfview--full .pdfview__bar { min-height: calc(56px + var(--sat)); padding-top: calc(var(--s1) + var(--sat)); flex: none; }
.pdfview--full .pdfview__scroll { flex: 1 1 auto; max-height: none; height: calc(100dvh - 56px - var(--sat)); }
body.has-overlay { overflow: hidden; }

/* ---------- Dev fixture banner ---------- */
.devbanner { border: 2px solid var(--critical); color: var(--critical); font-weight: 700; padding: var(--s2) var(--s3); margin-bottom: var(--s4); text-align: center; }

/* ---------- Print views (wallet card and A4 sheet) ---------- */
.print-only { display: none; }
.print-page { background: #fff; border: 1px solid var(--rule); padding: var(--s4); color: #111; }
.print-stage { overflow: hidden; }
.print-fit { transform-origin: top left; }
.print-fit--card { width: max-content; }
/* A4 emergency summary: a fixed 186 × 272 mm box that is measured and never allowed to spill to a second page.
   Black and red on white only; body 9pt stepping down to 7.5pt; safety blocks never below 8.5pt. */
/* a continuation page (only when allergies + critical alerts alone do not fit on page 1): same box, same rules */
.sheet + .sheet { break-before: page; page-break-before: always; margin-top: 8mm; }
.sheet__pagefoot { position: absolute; left: 0; right: 0; bottom: 0; font-size: 8.5pt; font-weight: 700; color: #99151d; border-top: 1px solid #111; padding-top: 2px; background: #fff; }
.sheet__cont { font-size: 8.5pt; color: #333; margin: 0 0 2px; }
/* the page that prints when the safety information could not be laid out in full */
.sheet--blocked .sheet__blocked { margin-top: 8mm; font-size: 12pt; line-height: 1.4; max-width: 150mm; }
.sheet--blocked .sheet__blocked h2 { font-size: 15pt; margin-bottom: 3mm; }
.sheet { position: relative; width: 186mm; height: 272mm; overflow: hidden; overflow-wrap: anywhere; padding: 0 0 9mm; font-family: var(--font); font-size: var(--sheet-fs, 9pt); line-height: 1.25; color: #111; background: #fff; font-variant-numeric: lining-nums; break-inside: avoid; }
.sheet__head { border-bottom: 2px solid #111; padding-bottom: 3px; margin-bottom: 4px; }
.sheet__name { font-size: 15pt; font-weight: 700; line-height: 1.1; }
.sheet__id { font-size: 9pt; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.sheet__prov { font-size: 8pt; color: #333; margin-top: 1px; }
.sheet__safe { font-size: var(--sheet-safe-fs, 9pt); }
.sheet__h { font-size: 9.5pt; font-weight: 600; margin: 5px 0 2px; padding-bottom: 1px; border-bottom: 1px solid #111; break-after: avoid; }
.sheet__h--red { color: #99151d; border-bottom-color: #99151d; }
.sheet__red { color: #99151d; font-weight: 700; }
.sheet__allergies { margin: 0; padding-left: 1.1em; columns: 2; column-gap: 6mm; }
.sheet__allergies li { break-inside: avoid; margin-bottom: 1px; }
.sheet__alerts { margin: 0; padding-left: 1.5em; }
.sheet__alerts li { margin-bottom: 2px; break-inside: avoid; }
.sheet__imp { margin-top: 2px; }
.sheet__cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 6mm; margin-top: 2px; }
.sheet__meds { width: 100%; border-collapse: collapse; table-layout: fixed; }
.sheet__meds td { padding: 1px 4px 1px 0; vertical-align: top; border-bottom: 1px solid #ccc; overflow-wrap: anywhere; }
.sheet__meds td:first-child { width: 48%; }
.sheet__meds td:last-child { font-variant-numeric: tabular-nums; }
.sheet__inline { margin: 0; text-wrap: pretty; }
.sheet__list { margin: 0; padding-left: 1.1em; }
.sheet__list li { margin-bottom: 1px; break-inside: avoid; }
.sheet__num { font-variant-numeric: tabular-nums; }
.sheet__abn { font-weight: 700; }
.sheet__dim { color: #333; font-size: 0.92em; font-weight: 400; margin: 0; }
.sheet__p { margin: 0; }
.sheet__more { margin: 1px 0 0; color: #333; font-size: 0.92em; }
.sheet__foot { position: absolute; left: 0; right: 0; bottom: 0; font-size: 8pt; color: #333; border-top: 1px solid #111; padding-top: 2px; background: #fff; }

/* Wallet card: 85.6 × 54 mm faces; critical text 8 pt, supporting text 7.5 pt, name 11 pt, 3 mm margins. Nothing shrinks. */
.wallet { overflow-wrap: anywhere; display: flex; flex-wrap: nowrap; gap: 0; justify-content: center; }
.wallet__face { width: 85.6mm; height: 54mm; border: 1px solid #999; padding: 3mm; font-size: 8pt; line-height: 1.2; color: #111; background: #fff; overflow: hidden; position: relative; font-family: var(--font); box-sizing: border-box; font-variant-numeric: lining-nums tabular-nums; display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 1.5mm; }
.wallet__face + .wallet__face { border-left: 1px dashed #999; }
.wallet__body { min-height: 0; overflow: hidden; }
.wallet__face h1 { font-size: 11pt; font-weight: 700; margin: 0 0 0.6mm; letter-spacing: -0.01em; }
.wallet__face .k { font-size: 7.5pt; font-weight: 600; color: #333; display: block; margin-top: 0.8mm; }
.wallet__face .w-safe { margin: 0; padding: 0; list-style: none; }
.wallet__face .w-safe li { margin: 0 0 0.3mm; font-size: 8pt; line-height: 1.2; }
.wallet__face .w-safe li.w-head { font-weight: 700; color: #99151d; border-top: 1.5px solid #99151d; padding-top: 0.5mm; margin-top: 0.8mm; }
.wallet__face .w-safe li.w-head:first-child { margin-top: 0; }
.wallet__face .w-cont { color: #99151d; font-weight: 700; font-size: 7.5pt; margin-top: 0.5mm; }
.wallet__face .k--crit { color: #99151d; }
.wallet__face .dim { color: #333; font-size: 7.5pt; }
.wallet__face .allergy { border-top: 1.5px solid #99151d; padding: 0.6mm 0 0; margin: 1mm 0 0.5mm; }
.wallet__face .allergy b.t { color: #99151d; font-weight: 700; display: block; }
.wallet__face .allergy .sev { color: #99151d; font-weight: 700; }
.wallet__face ul { margin: 0; padding-left: 2.6mm; }
.wallet__face ol { margin: 0; padding-left: 3.2mm; }
.wallet__face li { margin: 0; }
.wallet__face li .important { font-weight: 700; }
.wallet__face li.more { list-style: none; margin-left: -2.6mm; font-weight: 700; color: #99151d; }
.wallet__face li.sens { color: #333; font-size: 7.5pt; }
.wallet__face .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.3mm 2mm; }
.wallet__face .grid .span { grid-column: 1 / -1; }
.wallet__face .foot { font-size: 7.5pt; color: #333; line-height: 1.15; }
.wallet__face .face-label { position: absolute; top: 1mm; right: 2.5mm; font-size: 7.5pt; color: #666; }
.crop { position: relative; padding: 6mm; display: block; width: max-content; }
.crop + .crop { margin-top: 2mm; }
.crop::before, .crop::after, .crop > .c1, .crop > .c2 { content: ""; position: absolute; width: 6mm; height: 6mm; border-style: solid; }
.crop::before { top: 0; left: 0; border-width: 0 1px 1px 0; border-color: transparent #333 #333 transparent; }
.crop::after { bottom: 0; right: 0; border-width: 1px 0 0 1px; border-color: #333 transparent transparent #333; }
.crop > .c1 { top: 0; right: 0; border-width: 0 0 1px 1px; border-color: transparent transparent #333 #333; }
.crop > .c2 { bottom: 0; left: 0; border-width: 1px 1px 0 0; border-color: #333 #333 transparent transparent; }
.print-note { font-size: var(--t-meta); color: var(--ink-2); max-width: 70ch; }
/* readable single-face preview on a phone */
.face-preview { overflow: auto; -webkit-overflow-scrolling: touch; background: var(--surface-2); border: 1px solid var(--rule); padding: var(--s4); }
.face-preview__scale { transform-origin: top left; }

/* ---------- Spacing utilities (last, so they win over component margins) ---------- */
.mt-2 { margin-top: var(--s2); } .mt-3 { margin-top: var(--s3); } .mt-4 { margin-top: var(--s4); } .mt-5 { margin-top: var(--s5); }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: var(--s2); } .mb-3 { margin-bottom: var(--s3); } .mb-4 { margin-bottom: var(--s4); }
.stack > * + * { margin-top: var(--s3); }

@media print {
  @page { size: A4; margin: 12mm; }
  html, body { background: #fff !important; color: #000 !important; }
  .appbar, .offline-strip, .tabbar, .sidebar, .toasts, .no-print, .skip, .face-preview { display: none !important; }
  .app { display: block; }
  .view { padding: 0 !important; max-width: none !important; }
  .print-page { border: 0; padding: 0; margin: 0 !important; }
  .print-stage { overflow: visible; height: auto !important; padding: 0; }
  .print-fit { transform: none !important; }
  .sheet { height: 272mm; overflow: hidden; break-inside: avoid; }
  .sheet + .sheet { break-before: page; page-break-before: always; margin-top: 0; }
  .print-only { display: block; }
  a { color: inherit; text-decoration: none; }
  .wallet__face, .sheet { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
