/* Design system (adapted from the SML Platform).
 *
 * Two colour layers:
 *   --platform  the platform's own green (staff and admin screens);
 *   --brand     the lender's colour (their website and borrower portal), set per
 *               lender on <html> by templates/base.html, with --on-brand (button
 *               text) and --brand-text (links) worked out for contrast in
 *               apps/core/branding.py.
 * Every size is in rem, so the text size control (html[data-text]) and the
 * browser's own zoom/text settings scale the whole page together.
 */

@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 400; font-style: normal; font-display: swap; src: url("../fonts/atkinson-hyperlegible-latin-400-normal.f1f8a8210104.woff2") format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 400; font-style: italic; font-display: swap; src: url("../fonts/atkinson-hyperlegible-latin-400-italic.de4c0c22fd4e.woff2") format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 700; font-style: normal; font-display: swap; src: url("../fonts/atkinson-hyperlegible-latin-700-normal.13a58e05dfd2.woff2") format("woff2"); }
@font-face { font-family: "Schibsted Grotesk"; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/schibsted-grotesk-latin-600-normal.979c93d531b9.woff2") format("woff2"); }
@font-face { font-family: "Schibsted Grotesk"; font-weight: 700; font-style: normal; font-display: swap; src: url("../fonts/schibsted-grotesk-latin-700-normal.70a47f952873.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 400; font-style: normal; font-display: swap; src: url("../fonts/jetbrains-mono-latin-400-normal.caf0dfde4e44.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 500; font-style: normal; font-display: swap; src: url("../fonts/jetbrains-mono-latin-500-normal.a21e038a03f7.woff2") format("woff2"); }

/* ---------- tokens ---------- */
:root {
  --canvas: #f2f5f4;
  --surface: #ffffff;
  --sunken: #e8eeec;
  --ink: #15232a;
  --muted: #56666c;
  --line: #d6dfdd;
  --line-strong: #8a9a97;
  --platform: #15606f;
  --platform-soft: #e1eff2;
  --on-platform: #ffffff;
  --brand: #1f5fbf;
  --on-brand: #ffffff;
  --brand-link: #1f5fbf; /* set per lender: the brand darkened until readable on white */
  --brand-text: var(--brand-link);
  --brand-soft: color-mix(in oklab, var(--brand) 9%, var(--surface));
  --ok: #1b7343;   --ok-soft: #e3f2e8;
  --warn: #8f5200; --warn-soft: #fbf0dc;
  --bad: #b3261e;  --bad-soft: #fbe6e4;
  --info: #24569f; --info-soft: #e4ecf8;
  --focus: #e0a100;

  --font-display: "Schibsted Grotesk", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;

  --step--1: 0.875rem;
  --step-0: 1rem;
  --step-1: 1.125rem;
  --step-2: 1.375rem;
  --step-3: 1.75rem;
  --step-4: 2.25rem;
  --radius: 0.625rem;
  --radius-sm: 0.375rem;
  --shadow: 0 1px 2px rgb(21 35 42 / .06), 0 4px 16px rgb(21 35 42 / .06);
  --gutter: max(1rem, env(safe-area-inset-left, 0px));
  --gutter-r: max(1rem, env(safe-area-inset-right, 0px));
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #0e1416; --surface: #151d20; --sunken: #1c2629;
    --ink: #e3ebe9; --muted: #9babaa; --line: #29363a; --line-strong: #5d6f72;
    --platform: #5bbccc; --platform-soft: #14303a; --on-platform: #0e1416;
    --brand-text: color-mix(in oklab, var(--brand) 50%, white);
    --brand-soft: color-mix(in oklab, var(--brand) 20%, var(--surface));
    --ok: #5cc48a; --ok-soft: #15301f; --warn: #e7a84a; --warn-soft: #33260f;
    --bad: #f08a80; --bad-soft: #3a1a17; --info: #8db2ee; --info-soft: #172640;
    --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 6px 20px rgb(0 0 0 / .3);
    color-scheme: dark;
  }
}

/* Text size control (apps/core/preferences.py). */
html[data-text="2"] { font-size: 118.75%; }
html[data-text="3"] { font-size: 137.5%; }

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--canvas); color: var(--ink);
  font: var(--step-0)/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; line-height: 1.2; text-wrap: balance; margin: 0; }
h1 { font-size: var(--step-4); letter-spacing: -.01em; }
h2 { font-size: var(--step-3); }
h3 { font-size: var(--step-2); }
h4 { font-size: var(--step-1); }
p, ul, ol, dl, figure { margin: 0; }
a { color: var(--brand-text); text-underline-offset: 0.15em; }
img { max-width: 100%; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 1rem; top: -4rem; background: var(--surface); color: var(--ink); padding: .5rem 1rem; border-radius: var(--radius-sm); z-index: 100; }
.skip-link:focus { top: 1rem; }

.num { font-variant-numeric: tabular-nums; }
.ref { font-family: var(--font-mono); font-size: .9em; letter-spacing: .01em; }
.eyebrow { font: 600 var(--step--1)/1.3 var(--font-display); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: var(--step--1); }
.lead { font-size: var(--step-1); color: var(--muted); }
.prose { max-width: 65ch; }
.stack { display: flex; flex-direction: column; gap: 0.75rem; }
.stack-lg { display: flex; flex-direction: column; gap: 1.5rem; }
.row { display: flex; flex-wrap: wrap; gap: 0.625rem; align-items: center; }
.spread { display: flex; flex-wrap: wrap; gap: 0.75rem; justify-content: space-between; align-items: center; }

/* ---------- site layout (lender website and portal) ---------- */
.wrap { width: 100%; max-width: 46rem; margin: 0 auto; padding-left: var(--gutter); padding-right: var(--gutter-r); }
.wrap-wide { max-width: 72rem; }
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding-block: 0.75rem; min-height: 4rem; }
.logo { display: inline-flex; align-items: center; gap: 0.6rem; font: 700 var(--step-1)/1.15 var(--font-display); color: var(--ink); text-decoration: none; min-width: 0; }
.logo-mark { flex: none; width: 2rem; height: 2rem; border-radius: 0.5rem; background: var(--brand); color: var(--on-brand); display: grid; place-items: center; font-size: 0.8rem; letter-spacing: .02em; }
.header-tools { display: flex; align-items: center; gap: 0.5rem; flex: none; }
.site-main { flex: 1; padding-block: 1.75rem 3rem; }
.site-footer { background: var(--surface); border-top: 1px solid var(--line); color: var(--muted); font-size: var(--step--1); }
.site-footer .wrap { padding-block: 1.5rem 2rem; display: flex; flex-direction: column; gap: 1rem; }

/* ---------- text size menu ---------- */
.textsize { position: relative; }
.textsize > summary { list-style: none; cursor: pointer; font: 700 var(--step--1)/1 var(--font-display); border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm); padding: 0.5rem 0.65rem; color: var(--ink); background: var(--surface); min-height: 2.5rem; display: inline-flex; align-items: center; }
.textsize > summary::-webkit-details-marker { display: none; }
.textsize[open] > summary { border-color: var(--ink); }
.textsize-menu { position: absolute; right: 0; top: calc(100% + 0.4rem); z-index: 20; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: var(--shadow); padding: 0.75rem; width: 15rem; max-width: calc(100vw - 2rem); display: flex; flex-direction: column; gap: 0.5rem; }
.textsize-menu form { display: flex; flex-direction: column; gap: 0.375rem; }
.textsize-menu button { font: 700 var(--step-0)/1.2 var(--font-body); text-align: left; background: none; border: 1.5px solid var(--line); border-radius: var(--radius-sm); color: var(--ink); padding: 0.6rem 0.75rem; cursor: pointer; display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; }
.textsize-menu button[aria-pressed="true"] { border-color: var(--brand); box-shadow: inset 0 0 0 1.5px var(--brand); }
.textsize-menu button .sample { font-family: var(--font-display); }

/* ---------- buttons ---------- */
.btn {
  font: 700 var(--step-0)/1.1 var(--font-body); display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; text-align: center;
  min-height: 2.875rem; padding: 0.6rem 1.25rem; border-radius: var(--radius-sm); border: 1.5px solid transparent; cursor: pointer; text-decoration: none;
}
.btn-primary { background: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: color-mix(in oklab, var(--brand) 86%, black); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover { border-color: var(--ink); }
.btn-quiet { background: none; color: var(--brand-text); padding-inline: 0.375rem; text-decoration: underline; text-underline-offset: 0.2em; }
.btn-danger { background: var(--surface); color: var(--bad); border-color: currentColor; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-sm { min-height: 2.25rem; padding: 0.4rem 0.875rem; font-size: var(--step--1); }
.inline-form { display: inline; }

/* ---------- forms ---------- */
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="color"]),
select, textarea {
  font: var(--step-0)/1.3 var(--font-body); color: var(--ink); background: var(--surface);
  border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm);
  min-height: 2.875rem; padding: 0.625rem 0.75rem; width: 100%; max-width: 100%;
}
textarea { min-height: 6rem; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--focus); outline-offset: 0; border-color: var(--ink); }
input[type="checkbox"], input[type="radio"] { width: 1.375rem; height: 1.375rem; accent-color: var(--brand); margin: 0; flex: none; }
.field { display: flex; flex-direction: column; gap: 0.375rem; }
.field > label, .field-label { font-weight: 700; }
.field .help { font-size: var(--step--1); color: var(--muted); }
.field .error, .error-text { color: var(--bad); font-size: var(--step--1); font-weight: 700; display: flex; gap: 0.375rem; align-items: flex-start; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--bad); }
.field .optional { font-weight: 400; color: var(--muted); }
.fields { display: flex; flex-direction: column; gap: 1.25rem; }
.fields-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
.affix { display: flex; align-items: stretch; }
.affix > span { display: grid; place-items: center; padding: 0 0.75rem; border: 1.5px solid var(--line-strong); border-right: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); background: var(--sunken); font-weight: 700; }
.affix > input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0 !important; font-variant-numeric: tabular-nums; }
.check { display: flex; gap: 0.75rem; align-items: flex-start; }
.check input { margin-top: 0.1rem; }
.check label { font-weight: 400; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; }

/* Yes/No and other choice tiles (radio inputs rendered as big buttons). */
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); gap: 0.625rem; }
.choice { position: relative; display: block; }
.choice input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; cursor: pointer; margin: 0; }
.choice span { display: flex; align-items: center; justify-content: center; min-height: 3.625rem; padding: 0.5rem 1rem; text-align: center; border: 1.5px solid var(--line-strong); border-radius: var(--radius); font: 700 var(--step-1)/1.2 var(--font-body); background: var(--surface); }
.choice input:checked + span { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1.5px var(--brand); }
.choice input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.has-error .choice span { border-color: var(--bad); }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list > * { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; padding: 0.875rem 1rem; color: var(--ink); text-decoration: none; }
.list > * + * { border-top: 1px solid var(--line); }
.list a:hover { background: var(--sunken); }
.list .chev { color: var(--muted); flex: none; }
.list form { margin: 0; }
.list button.list-btn { all: unset; box-sizing: border-box; display: flex; width: 100%; justify-content: space-between; align-items: center; gap: 0.75rem; cursor: pointer; }
.list button.list-btn:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 0.625rem; }
.fact { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0.75rem 0.875rem; }
.fact b { display: block; font: 700 var(--step-2)/1.2 var(--font-display); }
.fact span { font-size: var(--step--1); color: var(--muted); }
.hero { background: var(--brand-soft); border-radius: var(--radius); padding: 1.5rem; display: flex; flex-direction: column; gap: 0.875rem; }
.hero h1 { font-size: var(--step-4); }
.empty { border: 1.5px dashed var(--line-strong); border-radius: var(--radius); padding: 1.75rem 1.25rem; text-align: center; display: flex; flex-direction: column; gap: 0.5rem; align-items: center; }
details.disclosure { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
details.disclosure > summary { cursor: pointer; padding: 0.875rem 1rem; font-weight: 700; list-style: none; display: flex; justify-content: space-between; gap: 0.75rem; }
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary::after { content: "+"; font: 700 var(--step-2)/1 var(--font-display); color: var(--muted); }
details.disclosure[open] > summary::after { content: "–"; }
details.disclosure > .body { padding: 0 1rem 1rem; display: flex; flex-direction: column; gap: 1rem; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 0.375rem; font: 700 0.8125rem/1 var(--font-body); padding: 0.3rem 0.625rem 0.3rem 0.5rem; border-radius: 999px; white-space: nowrap; background: var(--sunken); color: var(--muted); }
.badge::before { content: ""; width: 0.45rem; height: 0.45rem; border-radius: 50%; background: currentColor; }
.b-ok { background: var(--ok-soft); color: var(--ok); }
.b-warn { background: var(--warn-soft); color: var(--warn); }
.b-bad { background: var(--bad-soft); color: var(--bad); }
.b-info { background: var(--info-soft); color: var(--info); }

/* ---------- alerts ---------- */
.alert { display: flex; gap: 0.75rem; padding: 0.875rem 1rem; border-radius: var(--radius-sm); background: var(--info-soft); color: var(--ink); align-items: flex-start; }
.alert > svg { flex: none; margin-top: 0.15rem; color: var(--info); }
.alert-text { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.alert-text > strong { font-family: var(--font-display); }
.alert.ok { background: var(--ok-soft); } .alert.ok > svg { color: var(--ok); }
.alert.warn { background: var(--warn-soft); } .alert.warn > svg { color: var(--warn); }
.alert.bad { background: var(--bad-soft); } .alert.bad > svg { color: var(--bad); }
.messages { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 1.25rem; }
.compliance { border: 1.5px dashed var(--line-strong); border-radius: var(--radius-sm); padding: 0.75rem 0.875rem; font-size: var(--step--1); display: flex; flex-direction: column; gap: 0.375rem; background: var(--surface); color: var(--ink); }
.compliance .eyebrow { display: flex; align-items: center; gap: 0.375rem; }

/* ---------- step-by-step forms (static/js/sml.js) ---------- */
.progress { display: flex; flex-direction: column; gap: 0.375rem; }
.progress .track { height: 0.375rem; background: var(--sunken); border-radius: 99px; overflow: hidden; }
.progress .fill { height: 100%; background: var(--brand); border-radius: 99px; transition: width .25s; }
.step { display: flex; flex-direction: column; gap: 1.25rem; }
.step + .step { border-top: 1px solid var(--line); padding-top: 1.75rem; margin-top: 1.75rem; }
.step-title { font-size: var(--step-2); }
.questions { gap: 1.75rem; }
.questions .field-label, .questions .field > label { font-size: var(--step-1); line-height: 1.35; }
.step-nav { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.5rem; }
.js-steps .step + .step { border-top: 0; padding-top: 0; margin-top: 0; }
.js-steps .step-nav-static { display: none; }

/* ---------- borrower portal ---------- */
.loan-card { background: var(--brand); color: var(--on-brand); border-radius: var(--radius); padding: 1.25rem; display: flex; flex-direction: column; gap: 1rem; }
.loan-card .top { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; font-size: var(--step--1); }
.loan-card .bal { font: 700 2.5rem/1 var(--font-display); letter-spacing: -.01em; }
.loan-card .lab { font-size: var(--step--1); opacity: .9; }
.loan-card .pill { border: 1.5px solid currentColor; border-radius: 99px; padding: 0.2rem 0.625rem; font-weight: 700; }
.loan-card .bar { height: 0.375rem; border-radius: 99px; background: color-mix(in srgb, currentColor 25%, transparent); overflow: hidden; }
.loan-card .bar > div { height: 100%; background: currentColor; border-radius: 99px; }
.next { display: flex; justify-content: space-between; gap: 0.75rem; padding: 0.875rem 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); align-items: center; flex-wrap: wrap; }
.next b { font: 700 var(--step-2)/1 var(--font-display); }
.payout { border: 2px solid var(--brand); }
dl.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.5rem 1rem; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.helpline { font-size: var(--step--1); color: var(--muted); }

/* Code entry: one box, big spaced digits. */
input.code-input { font: 600 var(--step-3)/1 var(--font-mono) !important; letter-spacing: 0.5em; text-align: center; padding-left: 1em !important; }

@media (max-width: 40rem) {
  h1, .hero h1 { font-size: var(--step-3); }
  .fields-2 { grid-template-columns: minmax(0, 1fr); }
  .hero { padding: 1.25rem; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn, .choice span, .textsize-menu button, .list a { transition: background-color .15s, border-color .15s, color .15s; }
}
@media (prefers-reduced-motion: reduce) {
  .progress .fill { transition: none; }
}

/* =====================================================================
 * Staff site and platform admin (templates/app_base.html)
 * Sidebar + content. Plain tables, forms and headings inside .app-content
 * are styled automatically, so older pages look right without classes.
 * ===================================================================== */
.app { flex: 1; display: grid; grid-template-columns: 15.5rem minmax(0, 1fr); min-height: 100vh; }
.app-side { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 0.25rem; padding: 1rem 0.75rem 1.5rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.app-brand { display: flex; align-items: center; gap: 0.6rem; padding: 0.25rem 0.5rem 1rem; border-bottom: 1px solid var(--line); margin-bottom: 0.5rem; text-decoration: none; color: var(--ink); }
.app-brand .logo-mark { background: var(--platform); color: var(--on-platform); }
.app-brand b { font: 700 var(--step-0)/1.2 var(--font-display); display: block; }
.app-brand span.small { color: var(--muted); display: block; }
.app-nav { display: flex; flex-direction: column; gap: 0.125rem; }
.app-nav a { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; padding: 0.5rem 0.625rem; border-radius: var(--radius-sm); color: var(--ink); text-decoration: none; font-weight: 700; font-size: 0.9375rem; }
.app-nav a:hover { background: var(--sunken); }
.app-nav a[aria-current="page"] { background: var(--platform-soft); color: var(--platform); }
.app-nav .count { font: 700 0.75rem/1 var(--font-body); background: var(--platform); color: var(--on-platform); padding: 0.25rem 0.45rem; border-radius: 99px; font-variant-numeric: tabular-nums; }
.app-nav .count.bad { background: var(--bad); color: var(--surface); }
.app-nav-group { padding: 0.875rem 0.625rem 0.25rem; }
.app-user { margin-top: auto; padding: 0.875rem 0.5rem 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 0.5rem; font-size: var(--step--1); }
.app-user .who { color: var(--muted); overflow-wrap: anywhere; }
.app-user .row { gap: 0.5rem; }
.app-menu-btn { display: none; }
.app-side-top { display: block; }

.app-main { min-width: 0; display: flex; flex-direction: column; }
.app-top { display: flex; justify-content: flex-end; align-items: center; gap: 0.5rem; padding: 0.75rem max(1.5rem, env(safe-area-inset-right, 0px)) 0 1.5rem; }
.app-content { padding: 0.5rem max(1.5rem, env(safe-area-inset-right, 0px)) 3rem 1.5rem; display: flex; flex-direction: column; gap: 1.25rem; max-width: 80rem; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.page-head h1 { font-size: var(--step-3); }
.page-head .sub { color: var(--muted); margin-top: 0.25rem; }

/* Plain elements inside the content area. */
.app-content > h1 { font-size: var(--step-3); }
.app-content h2 { font-size: var(--step-2); margin-top: 0.75rem; }
.app-content h3 { font-size: var(--step-1); margin-top: 0.5rem; }
.app-content ul:not([class]), .app-content ol:not([class]) { padding-left: 1.25rem; display: flex; flex-direction: column; gap: 0.375rem; }
.app-content table:not([class]) {
  border-collapse: collapse; width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  font-size: 0.9375rem; display: block; overflow-x: auto;
}
.app-content table:not([class]) > tbody, .app-content table:not([class]) > thead { display: table; width: 100%; border-collapse: collapse; }
.app-content table:not([class]) th { text-align: left; font: 600 0.75rem/1.2 var(--font-display); letter-spacing: .07em; text-transform: uppercase; color: var(--muted); padding: 0.625rem 0.875rem; border-bottom: 1px solid var(--line); background: var(--surface); white-space: nowrap; }
.app-content table:not([class]) td { padding: 0.625rem 0.875rem; border-bottom: 1px solid var(--line); vertical-align: top; font-variant-numeric: tabular-nums; }
.app-content table:not([class]) tr:last-child td { border-bottom: 0; }
.app-content table:not([class]) td:first-child { color: var(--ink); }
.app-content table:not([class]) tr:has(td):hover { background: var(--sunken); }
.app-content table:not([class]) a { font-weight: 700; }
.app-content code { font-family: var(--font-mono); font-size: 0.875em; }

/* Inline forms (label + input on one line) stay compact; .field forms stack. */
.app-content form:not(.fields):not(.stack):not(.stack-lg) input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="color"]),
.app-content form:not(.fields):not(.stack):not(.stack-lg) select { width: auto; min-width: 10rem; min-height: 2.5rem; padding: 0.4rem 0.6rem; }
.app-content form:not(.fields):not(.stack):not(.stack-lg) input[size] { min-width: 0; }
.app-content form:not(.fields):not(.stack):not(.stack-lg) textarea { width: 100%; max-width: 40rem; }
.app-content form:not(.fields):not(.stack):not(.stack-lg) { display: flex; flex-wrap: wrap; gap: 0.625rem 0.875rem; align-items: flex-end; }
.app-content form:not(.fields):not(.stack):not(.stack-lg) > p, .app-content form:not(.fields):not(.stack):not(.stack-lg) > br { flex-basis: 100%; }
.app-content form:not(.fields):not(.stack):not(.stack-lg) > br { content: ""; height: 0; }
.app-content form label { display: inline-flex; flex-direction: column; gap: 0.25rem; font-weight: 700; font-size: 0.9375rem; max-width: 100%; min-width: 0; }
.app-content form label:has(> input[type="checkbox"]), .app-content form label:has(> input[type="radio"]) { flex-direction: row; align-items: center; gap: 0.5rem; font-weight: 400; }
.app-content form > p { display: flex; flex-direction: column; gap: 0.25rem; }
.app-content form > p > label { font-weight: 700; }
.app-content .helptext { font-size: var(--step--1); color: var(--muted); font-weight: 400; }
.app-content ul.errorlist { list-style: none; padding: 0; margin: 0; color: var(--bad); font-weight: 700; font-size: var(--step--1); }
.app-content form.inline-form, .app-content td form { display: inline-flex; }

/* Unclassed buttons look like secondary buttons; the main action in a form can add .btn-primary. */
.app-content button:not([class]) {
  font: 700 0.9375rem/1.1 var(--font-body); display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 2.5rem; padding: 0.5rem 1rem; border-radius: var(--radius-sm); border: 1.5px solid var(--line-strong);
  background: var(--surface); color: var(--ink); cursor: pointer;
}
.app-content button:not([class]):hover { border-color: var(--ink); }
.app-content button:not([class])[value="approved"], .app-content button:not([class])[value="approve"] { background: var(--platform); border-color: var(--platform); color: var(--on-platform); }
.app-content button:not([class])[value="declined"], .app-content button:not([class])[value="reject"] { color: var(--bad); border-color: currentColor; }

.notice { display: block; padding: 0.875rem 1rem; border-radius: var(--radius-sm); background: var(--info-soft); color: var(--ink); border-left: 4px solid var(--info); }
.app-content details:not([class]) { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0; }
.app-content details:not([class]) > summary { cursor: pointer; padding: 0.75rem 1rem; font-weight: 700; color: var(--brand-text); }
.app-content details:not([class]) > :not(summary) { margin: 0 1rem 1rem; }
.app-content fieldset:not([class]) { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; display: flex; flex-direction: column; gap: 0.75rem; }
.app-content fieldset:not([class]) > legend { font: 700 var(--step-0)/1.2 var(--font-display); padding: 0 0.375rem; }

/* Staff components. */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; padding: 0.875rem 1.125rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-head h2, .panel-head h3 { font-size: var(--step-1); margin: 0; }
.panel-body { padding: 1rem 1.125rem; display: flex; flex-direction: column; gap: 1rem; }
.panel > table.tbl { border: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: 0.75rem; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.875rem 1rem; display: flex; flex-direction: column; gap: 0.25rem; }
.kpi b { font: 700 var(--step-3)/1.1 var(--font-display); }
.kpi .small { color: var(--muted); }
.attn { list-style: none; margin: 0; padding: 0; }
.attn li { display: grid; grid-template-columns: 0.25rem minmax(0, 1fr) auto; gap: 0 1rem; align-items: center; padding: 0.75rem 1.125rem 0.75rem 0; }
.attn li + li { border-top: 1px solid var(--line); }
.attn .sev { align-self: stretch; border-radius: 0 3px 3px 0; background: var(--info); }
.attn .sev.bad { background: var(--bad); } .attn .sev.warn { background: var(--warn); }
.attn .what b { display: block; }
.attn .count { font: 700 var(--step-1)/1 var(--font-display); font-variant-numeric: tabular-nums; min-width: 2ch; text-align: right; }
.tbl-wrap { overflow-x: auto; }
table.tbl { border-collapse: collapse; width: 100%; font-size: 0.9375rem; }
.tbl th { text-align: left; font: 600 0.75rem/1.2 var(--font-display); letter-spacing: .07em; text-transform: uppercase; color: var(--muted); padding: 0.625rem 1.125rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 0.75rem 1.125rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: var(--sunken); }
.tbl .r { text-align: right; font-variant-numeric: tabular-nums; }
.tbl td.nowrap, .tbl .nowrap { white-space: nowrap; }
.tbl a { color: var(--ink); font-weight: 700; }
.tbl .empty-row td { color: var(--muted); text-align: center; padding: 1.5rem; }
.filters { display: flex; flex-wrap: wrap; gap: 0.375rem; }
.filters a { font: 700 var(--step--1)/1 var(--font-body); color: var(--ink); text-decoration: none; border: 1.5px solid var(--line-strong); border-radius: 999px; padding: 0.5rem 0.75rem; background: var(--surface); }
.filters a[aria-current="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
dl.facts-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: 0.875rem 1.25rem; margin: 0; }
dl.facts-list dt { font-size: var(--step--1); color: var(--muted); }
dl.facts-list dd { margin: 0.125rem 0 0; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Loan journey (stepper). */
.journey { list-style: none; margin: 0; padding: 1rem 1.125rem; display: flex; overflow-x: auto; }
.journey li { flex: 1 0 7rem; display: flex; flex-direction: column; gap: 0.5rem; font-size: var(--step--1); position: relative; padding-right: 0.5rem; }
.journey li::before { content: ""; position: absolute; top: 0.7rem; left: 1.5rem; right: 0; height: 2px; background: var(--line-strong); }
.journey li:last-child::before { display: none; }
.journey .dot { width: 1.5rem; height: 1.5rem; border-radius: 50%; border: 2px solid var(--line-strong); background: var(--surface); display: grid; place-items: center; position: relative; z-index: 1; color: var(--on-platform); }
.journey .done .dot { background: var(--platform); border-color: var(--platform); }
.journey .done::before { background: var(--platform); }
.journey .now .dot { border-color: var(--platform); box-shadow: 0 0 0 4px var(--platform-soft); }
.journey b { display: block; color: var(--ink); }

/* Sign-in pages for staff and admin. */
.auth { flex: 1; display: grid; place-items: center; padding: 2rem var(--gutter-r) 3rem var(--gutter); }
.auth-card { width: 100%; max-width: 26rem; background: var(--surface); border: 1px solid var(--line); border-radius: 0.875rem; padding: 1.75rem; display: flex; flex-direction: column; gap: 1.25rem; box-shadow: var(--shadow); }
.auth-card h1 { font-size: var(--step-3); }
.auth-card form { display: flex; flex-direction: column; gap: 1rem; }
.auth-card form p { display: flex; flex-direction: column; gap: 0.375rem; }
.auth-card form label { font-weight: 700; }
.auth-card ul.errorlist { list-style: none; padding: 0; margin: 0; color: var(--bad); font-weight: 700; font-size: var(--step--1); }
.auth-top { display: flex; justify-content: space-between; align-items: center; padding: 1rem var(--gutter-r) 0 var(--gutter); }

@media (max-width: 56rem) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .app-side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 0.75rem var(--gutter-r) 0.75rem var(--gutter); }
  .app-side-top { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; }
  .app-brand { border-bottom: 0; margin: 0; padding: 0; }
  .js .app-menu-btn { display: inline-flex; }
  .js .app-side:not(.open) .app-nav, .js .app-side:not(.open) .app-user { display: none; }
  .app-side.open .app-nav { margin-top: 0.75rem; }
  .app-top { padding-inline: var(--gutter) var(--gutter-r); }
  .app-content { padding-left: var(--gutter); padding-right: var(--gutter-r); }
  .attn li { grid-template-columns: 0.25rem minmax(0, 1fr) auto; }
}

/* Forms made of whole fields ({{ form.as_p }} or public/_field.html) stack in one column. */
.app-content form:not(.fields):not(.stack):not(.stack-lg):not(.filters):has(> p, > .field, > fieldset > .field) { flex-direction: column; align-items: stretch; max-width: 42rem; gap: 1rem; flex-wrap: nowrap; }
.app-content form:not(.fields):not(.stack):not(.stack-lg):has(> p, > .field, > fieldset > .field) > p { flex-basis: auto; }
.app-content form:not(.fields):not(.stack):not(.stack-lg):has(> p, > .field, > fieldset > .field) :is(input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="color"]), select) { width: 100%; min-width: 0; }
.app-content form:not(.fields):not(.stack):not(.stack-lg):has(> p, > .field, > fieldset > .field) > button { align-self: flex-start; }
.app-content form:not(.fields):not(.stack):not(.stack-lg):has(> p, > .field, > fieldset > .field) > button:not([class]):first-of-type { background: var(--platform); border-color: var(--platform); color: var(--on-platform); }
.app-content .field > label { display: block; }
.app-content .field .check label { display: inline; font-weight: 700; }
.app-content input[type="color"] { width: 3.5rem; height: 2.5rem; padding: 0.2rem; border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); }
/* Inputs inside table cells (e.g. arrears stages, chart of accounts) fit their column. */
.app-content table:not([class]):has(input, select) > tbody { table-layout: fixed; }
.app-content td :is(input:not([type="checkbox"]):not([type="radio"]), select) { min-width: 0 !important; width: 100%; }
.app-content form fieldset.group { width: 100%; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.125rem 1.25rem; display: flex; flex-direction: column; gap: 1rem; background: var(--surface); }
.app-content form fieldset.group > legend { font: 700 var(--step-1)/1.2 var(--font-display); padding: 0 0.375rem; }
.app-content form fieldset.group > p.help { margin-top: -0.25rem; }

/* Feedback screenshots and conversation. */
.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: 0.75rem; }
.shots a { display: block; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--sunken); }
.shots img { display: block; width: 100%; height: 9rem; object-fit: cover; object-position: top left; }
.comment { border-left: 3px solid var(--line-strong); padding: 0.25rem 0 0.25rem 0.875rem; display: flex; flex-direction: column; gap: 0.25rem; }
.comment.from-platform { border-left-color: var(--platform); }
.app-top .feedback-link { margin-right: auto; }

/* ---------- help: "?" panel, ⓘ tips, help centre ---------- */
.help-q { display: inline-grid; place-items: center; width: 1.25rem; height: 1.25rem; border-radius: 50%; background: var(--platform); color: var(--on-platform); font-size: 0.8rem; }
.help-panel {
  position: fixed; inset: 0 0 0 auto; margin: 0; width: min(28rem, 100vw); height: 100vh; max-height: none;
  border: 0; border-left: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  padding: max(1.25rem, env(safe-area-inset-top, 0px)) max(1.25rem, env(safe-area-inset-right, 0px)) 2rem 1.25rem;
  overflow-y: auto; box-shadow: -8px 0 32px rgb(0 0 0 / .15); flex-direction: column; gap: 1rem;
}
.help-panel:popover-open { display: flex; }
.help-panel::backdrop { background: rgb(0 0 0 / .25); }
.help-panel-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.help-panel h2 { font-size: var(--step-2); }
.help-panel-foot { border-top: 1px solid var(--line); padding-top: 0.75rem; font-size: var(--step--1); }
.help-body { display: flex; flex-direction: column; gap: 0.75rem; }
.help-body h2 { font-size: var(--step-1); margin-top: 0.5rem; }
.help-body h3 { font-size: var(--step-0); }
.help-body ul, .help-body ol { padding-left: 1.25rem; display: flex; flex-direction: column; gap: 0.375rem; }
.help-body table { border-collapse: collapse; width: 100%; font-size: 0.9375rem; display: block; overflow-x: auto; }
.help-body th, .help-body td { text-align: left; vertical-align: top; padding: 0.5rem 0.625rem; border-bottom: 1px solid var(--line); }
.help-body th { font: 600 0.75rem/1.2 var(--font-display); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.help-body code { font-family: var(--font-mono); font-size: 0.875em; background: var(--sunken); padding: 0.05rem 0.3rem; border-radius: 4px; }
.help-search input[type="search"] { flex: 1; min-width: 12rem; width: auto; }
dl.glossary { display: flex; flex-direction: column; gap: 0; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
dl.glossary > div { padding: 0.875rem 1.125rem; scroll-margin-top: 1rem; }
dl.glossary > div + div { border-top: 1px solid var(--line); }
dl.glossary > div:target { background: var(--platform-soft); }
dl.glossary dt { font: 700 var(--step-1)/1.3 var(--font-display); }
dl.glossary dd { margin: 0.25rem 0 0; }

.tip {
  display: inline-grid; place-items: center; width: 1.25rem; height: 1.25rem; margin-left: 0.25rem; vertical-align: 0.1em;
  border-radius: 50%; border: 1.5px solid currentColor; background: none; color: var(--brand-text);
  font: 700 0.75rem/1 var(--font-display); font-style: italic; cursor: pointer; padding: 0;
}
.tip-pop {
  margin: 0; position: fixed; inset: auto auto max(1rem, env(safe-area-inset-bottom, 0px)) 50%; transform: translateX(-50%);
  width: min(26rem, calc(100vw - 2rem)); border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); padding: 0.875rem 1rem; box-shadow: var(--shadow);
  font: var(--step--1)/1.5 var(--font-body); font-weight: 400; text-transform: none; letter-spacing: 0;
}
.tip-pop strong { display: block; font-family: var(--font-display); margin-bottom: 0.25rem; }
.tip-pop a { display: block; margin-top: 0.375rem; }

/* ---------- veterinary platform additions ---------- */
.fields-2 .span-2 { grid-column: 1 / -1; }
@media (max-width: 40rem) { .fields-2 { grid-template-columns: minmax(0, 1fr); } }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.tbl td.num, .tbl th.num { text-align: right; }
.flag { display: inline-block; min-width: 1.75rem; text-align: center; font: 700 0.8125rem/1.4 var(--font-mono); border-radius: 4px; padding: 0 0.25rem; }
.flag-H, .flag-HH { background: var(--bad-soft); color: var(--bad); }
.flag-L, .flag-LL { background: var(--info-soft); color: var(--info); }
.flag-A { background: var(--warn-soft); color: var(--warn); }
.result-H td.val, .result-HH td.val { color: var(--bad); font-weight: 700; }
.result-L td.val, .result-LL td.val { color: var(--info); font-weight: 700; }
.result-no_result td.val { color: var(--muted); }
.orig { color: var(--muted); font-size: var(--step--1); }
pre.raw { background: var(--sunken); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0.875rem; overflow-x: auto; font: 0.8125rem/1.5 var(--font-mono); white-space: pre; max-height: 32rem; }
pre.json { white-space: pre-wrap; }
textarea.code { font: 0.8125rem/1.5 var(--font-mono); min-height: 28rem; }
.images { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 0.75rem; }
.images figure { margin: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0.5rem; }
.images img { width: 100%; height: auto; image-rendering: pixelated; }
.images figcaption { font-size: var(--step--1); color: #333; }
.charts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 24rem), 1fr)); gap: 0.875rem; }
.chart { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.75rem 0.875rem; }
.chart h3 { font-size: var(--step-0); margin: 0 0 0.25rem; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .band { fill: var(--ok-soft); }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .gridline { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 3; }
.chart .line { fill: none; stroke: var(--platform); stroke-width: 2; }
.chart .pt { fill: var(--surface); stroke: var(--platform); stroke-width: 2; }
.chart .pt-H, .chart .pt-HH { stroke: var(--bad); fill: var(--bad); }
.chart .pt-L, .chart .pt-LL { stroke: var(--info); fill: var(--info); }
.chart text { fill: var(--muted); font: 11px var(--font-body); }
.chart .lbl { fill: var(--ink); font-weight: 700; }
.pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 0.25rem 1rem; }
.pick .check label { font-size: var(--step--1); }
.filters { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; }
.filters .field { min-width: 10rem; }
.pager { display: flex; gap: 0.5rem; align-items: center; justify-content: flex-end; padding: 0.75rem 1.125rem; }
.dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0.375rem 1.25rem; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; overflow-wrap: anywhere; }
.warnlist { margin: 0; padding-left: 1.25rem; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); gap: 1rem; align-items: start; }
details.disclose > summary { cursor: pointer; font-weight: 700; padding: 0.25rem 0; }
.manual-rows td { padding: 0.375rem 0.5rem; }
.manual-rows input, .manual-rows select { min-height: 2.5rem; }

/* public website */
.site { --brand: var(--platform); --on-brand: var(--on-platform); --brand-link: var(--platform); }
.site-nav { display: flex; gap: 1.25rem; align-items: center; flex-wrap: wrap; }
.site-nav a { color: var(--ink); text-decoration: none; font-weight: 700; }
.site-nav a:hover { color: var(--platform); }
.band-hero { background: linear-gradient(160deg, var(--platform-soft), var(--canvas)); padding: 4rem 0 3rem; }
.band-hero h1 { font-size: clamp(2rem, 5vw, 3.25rem); line-height: 1.08; max-width: 18ch; }
.band-hero .lead { max-width: 52ch; margin-top: 1rem; }
.section { padding: 3rem 0; }
.section + .section { border-top: 1px solid var(--line); }
.section h2 { font-size: var(--step-3); margin-bottom: 1rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); gap: 1rem; }
.cards .card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }
.cards .card h3 { font-size: var(--step-1); margin-bottom: 0.375rem; }
.faq details { border-bottom: 1px solid var(--line); padding: 0.875rem 0; }
.faq summary { font-weight: 700; cursor: pointer; }
.faq details p { margin-top: 0.5rem; color: var(--muted); }
.machine-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.625rem; }
.machine-list li { padding-left: 1.25rem; position: relative; }
.machine-list li::before { content: ""; position: absolute; left: 0; top: 0.55em; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--platform); }

/* Live search: dim the old results briefly while new ones load. */
[data-live-search] ~ [aria-busy], #alloc-results, #patient-results { transition: opacity 0.12s; }
[aria-busy="true"] { opacity: 0.55; }

/* The patient number (P-00042): readable at a glance, clearly not part of the name. */
.patient-no { display: inline-block; font: 600 0.8em/1 var(--font-body); font-variant-numeric: tabular-nums; letter-spacing: 0.02em; color: var(--muted); background: var(--sunken); border: 1px solid var(--line); border-radius: 6px; padding: 0.2em 0.45em; vertical-align: 0.15em; white-space: nowrap; }
h1 .patient-no { font-size: 0.45em; vertical-align: 0.35em; }
.patient-no:empty { display: none; }
.patient-no-cell { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--muted); }

/* Numbered how-to steps (Connect a new machine). */
ol.steps { margin: 0; padding-left: 1.5rem; display: flex; flex-direction: column; gap: 0.875rem; }
ol.steps > li { padding-left: 0.25rem; }
ol.steps > li::marker { font-weight: 700; color: var(--muted); }
ol.steps .tbl-wrap { margin-top: 0.625rem; }
.settings-tbl th[scope="row"] { width: 16rem; font-weight: 700; text-align: left; }
.settings-tbl code { font-size: 1.05em; font-weight: 700; }
.settings-tbl tr:last-child > * { border-bottom: 0; }

/* Reports: an animal's name, number and species read as one block, not a stacked form label. */
.app-content form label.pick-label { display: block; font-weight: 400; font-size: inherit; }

/* ---------------------------------------------------------------- trends: one chart, many measurements
   Categorical colours in a fixed, validated order (light and dark each checked against this
   portal's surface); a 9th+ measurement reuses a colour with a dashed or dotted line. */
.app-content {
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
}
@media (prefers-color-scheme: dark) {
  .app-content {
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #0ca30c; --s7: #9085e9; --s8: #e66767;
  }
}
.trend { display: grid; grid-template-columns: minmax(14rem, 18rem) minmax(0, 1fr); gap: 0.875rem; align-items: start; }
@media (max-width: 62rem) { .trend { grid-template-columns: minmax(0, 1fr); } }
.trend-pick .panel-body { gap: 0.75rem; max-height: 34rem; overflow-y: auto; }
.trend-presets { display: flex; flex-wrap: wrap; gap: 0.375rem; align-items: center; }
.trend-group { border: 0; padding: 0; margin: 0 0 0.5rem; display: flex; flex-direction: column; gap: 0.125rem; }
.trend-group > legend { padding: 0 0 0.25rem; text-transform: uppercase; letter-spacing: 0.04em; }
.trend-opt { display: flex; align-items: center; gap: 0.5rem; min-height: 2rem; }
.trend-opt input { width: 1.125rem; height: 1.125rem; flex: none; }
.app-content .trend-opt label { display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 0.5rem; font-weight: 600; cursor: pointer; }
.app-content .trend-opt label .trend-opt-meta { grid-column: 2; font-weight: 400; line-height: 1.2; }
.trend .key line, #trend-table .key line { stroke-width: 2.5; stroke-linecap: round; }
.trend-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; font-size: var(--step--1); }
.trend-legend li { display: inline-flex; align-items: center; gap: 0.375rem; }
.trend-chart { position: relative; min-height: 16rem; }
.trend-chart svg { display: block; width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
.trend-empty { padding: 4rem 1rem; text-align: center; }
.t-band { fill: var(--sunken); }
.t-limit { stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: 4 4; }
.t-grid { stroke: var(--line); stroke-width: 1; }
.t-base { stroke: var(--line-strong); stroke-width: 1; }
.t-axis { fill: var(--muted); font: 600 12px/1 var(--font-body); }
.t-axis-soft { font-weight: 400; }
.t-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.t-pt { stroke: var(--surface); stroke-width: 2; }
.t-flag { stroke-width: 2; r: 5; }
.t-keyline { stroke-width: 2.5; stroke-linecap: round; }
.t-label { fill: var(--ink); font: 600 12px/1 var(--font-body); }
.t-hair { stroke: var(--line-strong); stroke-width: 1; }
.t-halo { fill: none; stroke-width: 2; }
.t-hit { fill: transparent; cursor: crosshair; outline: none; }
.t-hit:focus-visible { stroke: var(--focus, var(--platform)); stroke-width: 2; }
.t-tip { position: absolute; z-index: 5; pointer-events: none; min-width: 12rem; max-width: 24rem; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 0.5rem 0.625rem; font-size: var(--step--1); }
.t-tip-date { color: var(--muted); font-weight: 700; margin-bottom: 0.25rem; }
.t-tip-grid { display: grid; grid-template-columns: auto auto auto auto minmax(0, 1fr); align-items: center; gap: 0.25rem 0.5rem; white-space: nowrap; }
.t-tip-row { display: contents; }
.t-tip-row b { font-variant-numeric: tabular-nums; }
.t-tip-unit { font-weight: 400; color: var(--muted); }
.t-tip-name { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.t-tip-flag { font-weight: 700; }
.t-tip-range { color: var(--muted); font-variant-numeric: tabular-nums; }
.trend-tbl td:first-child, .trend-tbl td:nth-child(3) { white-space: nowrap; }

/* Date fields in filter rows (Reports, Trends, patient filters). Safari on iPad gives a date input a
   fixed built-in width that ignores its container, so it spilled over the next field and button.
   Give each date field a share of the row, let the input shrink, and turn off Safari's native sizing
   (tapping still opens the date picker). */
.filters .field:has(> input[type="date"]) { flex: 1 1 10rem; max-width: 15rem; min-width: 8.5rem; }
.filters input[type="date"] { -webkit-appearance: none; appearance: none; display: block; width: 100% !important; min-width: 0 !important; }
.filters input[type="date"]::-webkit-date-and-time-value { text-align: left; }
.filters > .btn, .filters > button { flex: none; }

/* One-tap periods (3 months ... All) under the From / To fields. */
.period-presets { display: flex; flex-wrap: wrap; gap: 0.375rem; flex-basis: 100%; }
.panel-body > .period-presets { margin-top: 0.75rem; }

/* ---------------------------------------------------------------- website: pricing and brand strip */
.trust { color: var(--muted); font-weight: 700; }
.brand-strip { padding-block: 1.25rem; border-bottom: 1px solid var(--line); }
.brands { list-style: none; margin: 0.5rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem 1.75rem; font: 700 var(--step-1)/1.2 var(--font-display, var(--font-body)); letter-spacing: 0.02em; }
.pricing { display: flex; flex-direction: column; gap: 1rem; }
.currency-pick { display: flex; align-items: center; gap: 0.5rem; font-weight: 700; }
.currency-pick select { width: auto; min-width: 6.5rem; min-height: 2.5rem; padding: 0.35rem 0.6rem; }
.price-cards { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 48rem) { .price-cards { grid-template-columns: minmax(0, 1fr); } }
.price-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; display: flex; flex-direction: column; gap: 0.75rem; }
.price-card-main { border: 2px solid var(--brand); box-shadow: var(--shadow); }
.price-card h3 { margin: 0; font-size: var(--step-1); }
.price-badge { align-self: flex-start; margin: 0; background: var(--brand); color: var(--on-brand); font-weight: 700; font-size: var(--step--1); padding: 0.25rem 0.625rem; border-radius: 999px; }
.price { margin: 0; display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; }
.price-amount { font: 800 clamp(2.5rem, 6vw, 3.5rem)/1 var(--font-display, var(--font-body)); font-variant-numeric: tabular-nums; }
.price-amount-sm { font-size: var(--step-3); }
.price-per { color: var(--muted); font-weight: 700; }
.price-note { margin: 0; color: var(--muted); }
.ticks { list-style: none; margin: 0.25rem 0; padding: 0; display: flex; flex-direction: column; gap: 0.375rem; }
.ticks li { padding-left: 1.5rem; position: relative; }
.ticks li::before { content: "✓"; position: absolute; left: 0; color: var(--brand); font-weight: 800; }
.price-card .btn { align-self: flex-start; }

/* Billing banner: the whole alert links to the Billing page */
a.banner-link { display: block; color: inherit; text-decoration: none; }
a.banner-link:hover .alert, a.banner-link:focus-visible .alert { outline: 2px solid var(--info); outline-offset: 2px; }
.app-content > .messages + .messages { margin-top: 0.5rem; }
.kpi.price-option { gap: 0.25rem; }

/* Website header on narrow screens: name on one line, menu on its own row below */
.site-header .logo { white-space: nowrap; }
@media (max-width: 760px) {
  .site-header .wrap { flex-wrap: wrap; }
  .site-nav { width: 100%; gap: 0.5rem 1rem; }
  .site-nav .btn { margin-left: auto; }
  .site-nav .btn + .btn { margin-left: 0; }
}
