
  :root{
    /* PreSense Bedside — light, clinical, daytime-friendly. */
    --bg:#f1f5f9;
    --bg-soft:#f8fafc;
    --card:#ffffff;
    --card-2:#fcfdff;
    --card-3:#f1f5f9;
    --border:#e2e8f0;
    --border-2:#cbd5e1;
    --ink:#0f172a;
    --ink-2:#1e293b;
    /* Neutral text ramp, contrast-tuned. The old pair (--muted #64748b at
       4.34:1 on --bg, --faint #94a3b8 at 2.56:1 on --card) both fell under
       WCAG AA 4.5:1, and between them they carry most of the secondary text in
       the product — MRN, age/sex, timestamps, provenance and source labels.
       Both are deepened one step so each clears AA on --card and --bg, and the
       muted → faint hierarchy is preserved. */
    --muted:#5a6777;
    --faint:#627085;
    --hairline:#eef2f7;
    --surface-header:#f8fafc;
    --surface-sticky:#ffffff;
    --surface-hover:#f1f5f9;
    --surface-input:#f8fafc;
    --surface-now:#f0f7ff;
    --surface-edited:#fff7ed;
    --surface-disabled:#f1f5f9;
    --surface-crit:#ffffff;
    --surface-warn:#ffffff;
    --surface-ok:#ffffff;
    --surface-info:#ffffff;

    /* PreSense accent: System Blue (Apple HIG primary), both themes.
       #007AFF measured 4.02:1 both ways — as link/label text on white AND as
       the backing for white button text — so the primary action in the product
       failed AA in both roles. Deepened one step to clear 4.5:1; same hue
       family, same System-Blue reading. */
    --brand:#0069DB;
    --brand-2:#0051E0;
    /* Backing for white text (filled buttons, the chat launcher, sent chat
       bubbles). Light mode can reuse --brand because it now clears AA against
       white; dark mode cannot — see the dark block. */
    --brand-fill:var(--brand);
    --brand-fill-2:var(--brand-2);
    --brand-soft:#eff6ff;
    --brand-ring:rgba(0,122,255,.20);
    --crit-ring:rgba(214,34,34,.18);
    --glass-bg:rgba(255,255,255,.92);

    /* Tier color hierarchy: blue (resus) → red (stab) → yellow (enh) → green (std) → gray (inactive) */
    --resus:#2563eb;
    --stab:#dc2626;
    --enh:#d97706;
    --std:#16a34a;
    --inact:#94a3b8;

    /* Status colours are text in most of their uses (vital-status labels like
       HIGH/LOW, "Labs ok", sensitivity results), so they are tuned to clear
       WCAG AA 4.5:1 on --card and --bg rather than the 3:1 non-text bar. The
       previous amber #d97706 (3.19:1), green #16a34a (3.30:1) and cyan #0891b2
       (3.68:1) all failed as text on white — a real legibility cost on a
       bedside tablet in ICU lighting. Hue is unchanged; only depth. */
    /* #dc2626 cleared AA on white (4.83:1) but not on the page background
       (4.41:1). This is a one-step nudge, not a hue change — the alarm colour
       is the last thing that should be hard to read. */
    --crit:#d62222;
    --crit-soft:#fef2f2;
    --crit-border:#fecaca;
    --warn:#b45309;
    --warn-soft:#fffbeb;
    --warn-border:#fde68a;
    --ok:#15803d;
    --ok-soft:#f0fdf4;
    --ok-border:#bbf7d0;
    --info:#0e7490;
    --info-soft:#ecfeff;
    /* Graphic weight of the same two statuses, for strokes and fills that carry
       no text. Non-text contrast only needs 3:1, which the original brighter
       amber and green already cleared, and a vitals trace reads better vivid
       than deep. Only the sparkline uses these; every label stays on the
       AA-tuned --warn / --ok above. */
    --warn-graphic:#d97706;
    --ok-graphic:#16a34a;

    --purple:#7c3aed;
    /* The soft/border pair every purple chip in the product was hardcoding. */
    --purple-soft:#f5f3ff;
    --purple-border:#ddd6fe;
    --pink:#db2777;
    --teal:#0d9488;
    --indigo:#4f46e5;
    /* Wayfinding accents are drawn from the non-alarm hues only. Red and amber
       mean "this patient is deteriorating" everywhere else on the bedside page,
       so a red Prescription icon and three amber nav chips spent the alarm
       channel on chrome and diluted the vitals and overdue badges they sit
       beside. Alarm colour on this page now only ever comes from clinical
       state (vital status, overdue pill, the Rx due-count badge). */
    --accent-notes:var(--purple);
    --accent-assessment:var(--pink);
    --accent-orders:var(--indigo);
    --accent-monitoring:var(--info);
    --accent-labs:var(--brand);
    --accent-io:var(--teal);
    --accent-imaging:var(--indigo);
    --accent-upload:var(--teal);
    --accent-comms:var(--brand);
    --accent-reports:var(--purple);
    --accent-shift-report:var(--purple);
    --accent-rules:var(--brand);
    --accent-bundles:var(--teal);
    --accent-discharge:var(--crit);
    --topbar-height:55px;

    /* Fixed per-parameter trend trace colours (ICU monitor convention) — light. */
    --t-hr:#15803d; --t-bp:#dc2626; --t-map:#ea580c; --t-spo2:#0891b2; --t-rr:#ca8a04;
    --t-temp:#92826b; --t-o2:#0d9488; --t-vent:#2563eb; --t-neuro:#7c3aed; --t-pain:#db2777;
    --t-glu:#4338ca; --t-rhythm:#7c3aed; --t-cvp:#2563eb;

    --shadow-1:0 1px 2px rgba(15,23,42,.04), 0 1px 3px rgba(15,23,42,.05);
    --shadow-2:0 4px 12px rgba(15,23,42,.06), 0 2px 4px rgba(15,23,42,.04);
    --shadow-3:0 12px 32px rgba(15,23,42,.10), 0 4px 8px rgba(15,23,42,.05);

    --radius-1:6px;
    --radius-2:10px;
    --radius-3:14px;
    --radius-4:18px;

    /* ---------- Spacing scale ----------
       The 4px grid the layout already lands on most of the time. Named here so
       new work has a rung to reach for instead of inventing a 13 or a 17; the
       existing feature sheets are not being rewritten to use it, they migrate
       when a rule is touched for another reason. */
    --space-1:4px;
    --space-2:8px;
    --space-3:12px;
    --space-4:16px;
    --space-5:20px;
    --space-6:24px;
    --space-8:32px;
    --space-10:40px;

    /* ---------- Type scale ----------
       Steps derived from the sizes already in use, deduplicated. The product
       had 30+ distinct font-size values between 8.5px and 27px, several within
       half a pixel of each other (12px / 12.5px / 13px all doing "secondary
       text"). These are the rungs; --text-micro is for all-caps eyebrow labels,
       where the caps height carries legibility that the px value understates. */
    --text-micro:10.5px;
    --text-xs:11.5px;
    --text-sm:12.5px;
    --text-base:13.5px;
    --text-md:15px;
    --text-lg:18px;
    --text-xl:20px;
    --text-2xl:27px;

    /* Line heights: tight for headings and numerics, relaxed for prose. */
    --leading-tight:1.2;
    --leading-snug:1.35;
    --leading-normal:1.5;
    --leading-relaxed:1.65;
  }

  /* ===== OLED dark theme — token overrides (Approach A, Pass 1) ===== */
  :root[data-theme="dark"]{
    --bg:#000000;
    --bg-soft:#0b0b0d;
    --card:#1a1a1d;
    --card-2:#202024;
    --card-3:#26262b;
    --border:#2c2c33;
    --border-2:#3a3a42;
    --ink:#f4f4f6;
    --ink-2:#d6d6db;
    --muted:#a1a1aa;
    /* zinc-500 (#71717a) measured 3.59:1 on --card — under AA for the same
       secondary-text duty it carries in light mode. Lifted to clear 4.5:1. */
    --faint:#8a8a93;
    --hairline:#202024;
    --glass-bg:rgba(18,18,20,.82);
    --surface-header:#202024;
    --surface-sticky:#1a1a1d;
    --surface-hover:#26262b;
    --surface-input:#111114;
    --surface-now:rgba(10,132,255,.12);
    --surface-edited:rgba(251,191,36,.12);
    --surface-disabled:#141417;
    --surface-crit:var(--card);
    --surface-warn:var(--card);
    --surface-ok:var(--card);
    --surface-info:var(--card);

    --brand:#0A84FF;
    --brand-2:#5E9CFF;
    --brand-soft:rgba(10,132,255,.14);
    --brand-ring:rgba(10,132,255,.32);
    /* Dark's accent is bright so it reads as text on black (4.76:1 on --card),
       but white text ON it was only 3.65:1 — every filled primary button failed
       AA. Filled surfaces get their own deeper pair; text and borders keep the
       bright --brand above. */
    --brand-fill:#0A6FD8;
    --brand-fill-2:#0B62C4;

    /* tier hierarchy — lightened for contrast on black */
    --resus:#3b82f6;
    --stab:#f87171;
    --enh:#fbbf24;
    --std:#4ade80;
    --inact:#71717a;

    --crit:#f87171; --crit-soft:rgba(248,113,113,.13); --crit-border:rgba(248,113,113,.30);
    --crit-ring:rgba(248,113,113,.28);
    --warn:#fbbf24; --warn-soft:rgba(251,191,36,.12); --warn-border:rgba(251,191,36,.30);
    --ok:#4ade80;   --ok-soft:rgba(74,222,128,.12);   --ok-border:rgba(74,222,128,.30);
    --info:#22d3ee; --info-soft:rgba(34,211,238,.12);
    /* Dark's status colours already cleared AA as text, so graphic and text
       weight are the same value here. */
    --warn-graphic:var(--warn);
    --ok-graphic:var(--ok);

    --purple:#a78bfa; --pink:#f472b6; --teal:#2dd4bf; --indigo:#818cf8;
    --purple-soft:rgba(167,139,250,.14);
    --purple-border:rgba(167,139,250,.35);

    /* Fixed per-parameter trend trace colours (ICU monitor convention) — dark. */
    --t-hr:#4ade80; --t-bp:#f87171; --t-map:#fb923c; --t-spo2:#22d3ee; --t-rr:#fbbf24;
    --t-temp:#d9b892; --t-o2:#2dd4bf; --t-vent:#7aa2ff; --t-neuro:#a78bfa; --t-pain:#f472b6;
    --t-glu:#a5b4fc; --t-rhythm:#a78bfa; --t-cvp:#7aa2ff;

    --shadow-1:0 1px 2px rgba(0,0,0,.6);
    --shadow-2:0 6px 16px rgba(0,0,0,.5);
    --shadow-3:0 16px 40px rgba(0,0,0,.65);
  }
  /* Cross-fade only during an explicit toggle (kept off hover states). */
  html.theme-anim, html.theme-anim *{
    transition:background-color .3s ease, border-color .3s ease, color .3s ease, box-shadow .3s ease !important;
  }

  /* Dark surface sweep — neutralize hardcoded light card backgrounds (Pass 1: home + rx).
     Dark-only overrides so light mode stays pixel-identical. */
  :root[data-theme="dark"] .ppanel-head{ background:linear-gradient(180deg,var(--card-2),var(--card)); }
  /* OLED hairlines vanish on the near-black head — lift banner dividers one
     step so the identifier groups stay visibly separated in dark mode. */
  :root[data-theme="dark"] .pfact{ border-left-color:var(--border-2); }
  :root[data-theme="dark"] .ppanel-chips{ border-top-color:var(--border); }
  :root[data-theme="dark"] .rx-allergy-bar.has{ background:linear-gradient(180deg,var(--crit-soft),var(--card)); }
  :root[data-theme="dark"] .rx-table th{ background:var(--card-2); }
  :root[data-theme="dark"] .rx-tok.weak{ background:var(--card-2); }
  :root[data-theme="dark"] .o-card.allergy{ border-color:var(--crit-border); background:linear-gradient(180deg,var(--crit-soft),var(--card)); }
  :root[data-theme="dark"] .pri-item-aggregate{ background:var(--crit-soft); border-color:var(--crit-border); }
  :root[data-theme="dark"] .pri-item-aggregate:hover{ background:rgba(248,113,113,.20); }
  /* rx tray + suggested orders */
  :root[data-theme="dark"] .pill.auto{ background:rgba(129,140,248,.14); border-color:rgba(129,140,248,.32); }
  :root[data-theme="dark"] .rx-tray-head{ background:linear-gradient(180deg,var(--warn-soft),var(--card)); }
  :root[data-theme="dark"] .rx-tray.empty .rx-tray-head{ background:var(--card-2); }
  :root[data-theme="dark"] .rx-tray-input-row{ background:var(--card-2); }
  :root[data-theme="dark"] .rx-tray-btn:hover{ background:rgba(255,255,255,.06); }
  :root[data-theme="dark"] .rx-tray-btn.bundle{ color:#93c5fd; border-color:rgba(96,165,250,.35); background:rgba(96,165,250,.14); }
  :root[data-theme="dark"] .o-card.suggested{ border-color:rgba(167,139,250,.35); background:linear-gradient(180deg,rgba(167,139,250,.12),var(--card)); }
  :root[data-theme="dark"] .o-pill.typed{ background:var(--card-3); border-color:var(--border-2); }
  :root[data-theme="dark"] .o-pill.suggested{ background:rgba(167,139,250,.14); border-color:rgba(167,139,250,.35); color:#c4b5fd; }
  :root[data-theme="dark"] .o-pill.bundle{ background:rgba(96,165,250,.14); border-color:rgba(96,165,250,.35); color:#93c5fd; }
  :root[data-theme="dark"] .o-pill.titration, :root[data-theme="dark"] .o-pill.dar, :root[data-theme="dark"] .o-pill.prn{ color:var(--warn); }

  /* Product-wide dark compatibility sweep. Shared semantic surfaces keep
     clinical hierarchy consistent while leaving the light theme unchanged. */
  :root[data-theme="dark"]{color-scheme:dark}
  :root[data-theme="dark"] input,
  :root[data-theme="dark"] textarea,
  :root[data-theme="dark"] select{color-scheme:dark}
  :root[data-theme="dark"] input:focus,
  :root[data-theme="dark"] textarea:focus,
  :root[data-theme="dark"] select:focus,
  :root[data-theme="dark"] .sh-council input:focus,
  :root[data-theme="dark"] .lab-search input:focus,
  :root[data-theme="dark"] .narrative:focus,
  :root[data-theme="dark"] .ai-chat-input:focus-within,
  :root[data-theme="dark"] .field input:focus,
  :root[data-theme="dark"] .field textarea:focus,
  :root[data-theme="dark"] .field select:focus{background:var(--surface-input)}
  :root[data-theme="dark"] .btn-group .btn:hover,
  :root[data-theme="dark"] .check-grid label:hover,
  :root[data-theme="dark"] .nrv-chip:hover,
  :root[data-theme="dark"] .report-card:hover,
  :root[data-theme="dark"] .comms-type-switch button:hover{background:var(--surface-hover)}
  :root[data-theme="dark"] .btn.active-toggle:hover,
  :root[data-theme="dark"] .rx-due:hover,
  :root[data-theme="dark"] .o-edit.swap:hover{background:rgba(248,113,113,.20)}
  :root[data-theme="dark"] .pill.auto,
  :root[data-theme="dark"] .source-tag.auto{color:var(--indigo);background:rgba(129,140,248,.14);border-color:rgba(129,140,248,.32)}
  :root[data-theme="dark"] .pill.touch,
  :root[data-theme="dark"] .source-tag.touch{color:var(--warn);background:var(--warn-soft);border-color:var(--warn-border)}
  :root[data-theme="dark"] .pill.voice{background:rgba(244,114,182,.14);border-color:rgba(244,114,182,.32)}
  :root[data-theme="dark"] .pill.photo{background:var(--ok-soft);color:var(--ok);border-color:var(--ok-border)}
  :root[data-theme="dark"] .modal{border:1px solid var(--border-2)}
  :root[data-theme="dark"] .modal-bg{background:rgba(0,0,0,.72)}
  :root[data-theme="dark"] .toast{background:var(--card-3);color:var(--ink);border:1px solid var(--border-2)}
  :root[data-theme="dark"] .toast.ok{background:var(--ok-soft);color:var(--ok);border-color:var(--ok-border)}
  :root[data-theme="dark"] ::-webkit-scrollbar-thumb{background:var(--border-2)}
  :root[data-theme="dark"] ::-webkit-scrollbar-thumb:hover{background:var(--faint)}

  /* Home, roster, and shared dashboard surfaces. */
  :root[data-theme="dark"] .shift-band{background:linear-gradient(180deg,var(--card-2),var(--card))}
  :root[data-theme="dark"] .sh-council input,
  :root[data-theme="dark"] .roster-search input{background:var(--surface-input)}

  /* Labs use neutral sticky structure, a blue latest column, and restrained
     status tints that never erase the critical/warning rail. */
  :root[data-theme="dark"] .lab-section-head:hover{background:var(--surface-hover)}
  :root[data-theme="dark"] .lab-table th,
  :root[data-theme="dark"] .lab-table th.col-test{background:var(--surface-header)}
  :root[data-theme="dark"] .lab-table td.cell-test{background:var(--surface-sticky)}
  :root[data-theme="dark"] .lab-table th.col-latest,
  :root[data-theme="dark"] .lab-table td.cell-latest{background:var(--surface-now);border-left-color:var(--brand)}
  :root[data-theme="dark"] .lab-table tr.row-crit td:not(.cell-test){background:var(--crit-soft)}
  :root[data-theme="dark"] .lab-table tr.row-warn td:not(.cell-test){background:var(--warn-soft)}
  :root[data-theme="dark"] .sens-table th{background:var(--surface-header)}

  /* Monitoring keeps sticky labels neutral and layers current, edited, and
     abnormal meaning without returning to pale paper-chart fills. */
  :root[data-theme="dark"] .mon-table th,
  :root[data-theme="dark"] .mon-table th.col-row{background:var(--surface-header)}
  :root[data-theme="dark"] .mon-table td.cell-row{background:var(--surface-sticky)}
  :root[data-theme="dark"] .mon-table th.col-now,
  :root[data-theme="dark"] .mon-table td.cell-now{background:var(--surface-now);border-left-color:var(--brand)}
  :root[data-theme="dark"] .mon-cell.edited{background:var(--surface-edited)}
  :root[data-theme="dark"] .mon-section-row td,
  :root[data-theme="dark"] .mon-section-row td.cell-row{background:var(--card-3)}
  :root[data-theme="dark"] .mon-table td.mon-cell.cell-now.crit{background:var(--crit-soft)}
  :root[data-theme="dark"] .mon-table td.mon-cell.cell-now.warn{background:var(--warn-soft)}
  :root[data-theme="dark"] .mon-table tr.row-temp td.mon-cell,
  :root[data-theme="dark"] .mon-table tr.row-temp td.cell-row{background:linear-gradient(180deg,rgba(251,146,60,.10),var(--surface-sticky))}
  :root[data-theme="dark"] .mon-table tr.row-temp td.mon-cell.cell-now{background:rgba(251,146,60,.16)}
  :root[data-theme="dark"] .mon-table tr.row-temp td.mon-cell.crit{background:var(--crit-soft)}
  :root[data-theme="dark"] .mon-table tr.row-temp td.mon-cell.warn{background:var(--warn-soft)}
  :root[data-theme="dark"] .mon-table th.col-midnight,
  :root[data-theme="dark"] .mon-table td.cell-midnight{border-left-color:var(--border-2)}

  /* Input/output uses low-alpha intake, output, and balance lanes plus a
     stronger neutral totals row. */
  :root[data-theme="dark"] .io-grid thead th,
  :root[data-theme="dark"] .io-grid thead th.col-time{background:var(--surface-header)}
  :root[data-theme="dark"] .io-grid th.col-time,
  :root[data-theme="dark"] .io-grid td.col-time{background:var(--surface-sticky)}
  :root[data-theme="dark"] .io-grid th.grp-in,
  :root[data-theme="dark"] .io-grid td.col-tin,
  :root[data-theme="dark"] .io-grid th.col-tin{background:var(--brand-soft);border-color:var(--brand-ring)}
  :root[data-theme="dark"] .io-grid th.grp-out,
  :root[data-theme="dark"] .io-grid td.col-tout,
  :root[data-theme="dark"] .io-grid th.col-tout{background:var(--info-soft);border-color:rgba(34,211,238,.30)}
  /* No dark override for .col-bal: it is a sticky column now, so its background
     must be opaque in both themes, and the base rule mixes over --card to get
     that. --warn-soft is translucent here and would let the scrolling cells
     read straight through it. Same reason the row-now variant is mixed rather
     than patched. */
  /* :not(.col-bal) — --surface-now is translucent, and the balance column is
     sticky, so it has to keep the opaque background its own rule mixes. */
  :root[data-theme="dark"] .io-grid tr.row-now td:not(.col-bal){background:var(--surface-now)}
  :root[data-theme="dark"] .io-grid tr.row-now td.col-time,
  :root[data-theme="dark"] .io-grid tr.row-now td.col-tin{background:rgba(10,132,255,.20)}
  :root[data-theme="dark"] .io-grid tr.row-now td.col-tout{background:rgba(34,211,238,.18)}
  :root[data-theme="dark"] .io-grid tr.row-day td{border-top-color:var(--border-2)}
  :root[data-theme="dark"] .io-grid tr.row-totals td,
  :root[data-theme="dark"] .io-grid tr.row-totals td.col-time{background:var(--card-3)}
  :root[data-theme="dark"] .io-grid td.cell-num.edited{background:var(--surface-edited);color:var(--warn);border-color:var(--warn-border)}
  :root[data-theme="dark"] .io-table th,
  :root[data-theme="dark"] .io-table th.col-row{background:var(--surface-header)}
  :root[data-theme="dark"] .io-table tr.subhead td{background:var(--brand-soft)}
  :root[data-theme="dark"] .io-table tr.balance td{background:var(--warn-soft)}

  /* Prescriptions, orders, and dictation. */
  :root[data-theme="dark"] .rx-tray-title,
  :root[data-theme="dark"] .rx-tray-breakdown{color:var(--warn)}
  :root[data-theme="dark"] .rx-tray.empty .rx-tray-count{background:var(--card-3);color:var(--muted)}
  :root[data-theme="dark"] .rx-tray-sign:disabled,
  :root[data-theme="dark"] .rx-tray-sign:disabled:hover{background:var(--surface-disabled)}
  :root[data-theme="dark"] .rx-tok.drug{background:var(--brand-soft);border-color:var(--brand-ring);color:#93c5fd}
  :root[data-theme="dark"] .rx-tok.dose{color:var(--ok)}
  :root[data-theme="dark"] .rx-tok.route{color:var(--warn)}
  :root[data-theme="dark"] .rx-tok.freq,
  :root[data-theme="dark"] .o-pill.suggested{background:rgba(167,139,250,.14);border-color:rgba(167,139,250,.35);color:#c4b5fd}
  :root[data-theme="dark"] .o-card.bundle{border-color:var(--brand-ring);background:linear-gradient(180deg,var(--brand-soft),var(--card))}
  :root[data-theme="dark"] .o-card.heard{background:linear-gradient(180deg,var(--crit-soft),var(--card))}
  :root[data-theme="dark"] .o-card.titration{background:linear-gradient(180deg,var(--warn-soft),var(--card))}
  :root[data-theme="dark"] .o-prefix,
  :root[data-theme="dark"] .o-freq,
  :root[data-theme="dark"] .bp-item .bp-count{background:var(--card-3)}
  :root[data-theme="dark"] .o-indication{background:var(--warn-soft);color:var(--warn)}
  :root[data-theme="dark"] .o-why{color:var(--purple)}
  :root[data-theme="dark"] .o-edit:hover{background:var(--surface-hover)}
  :root[data-theme="dark"] .rx-admin-pill.new small{color:var(--ok)}
  :root[data-theme="dark"] .bp-item:hover{background:var(--brand-soft)}
  :root[data-theme="dark"] .rx-rate-stepper button{color:var(--warn)}
  :root[data-theme="dark"] .rx-rate-stepper button:hover{background:rgba(251,191,36,.20)}
  :root[data-theme="dark"] .dictate-panel{background:linear-gradient(135deg,rgba(244,114,182,.13),rgba(10,132,255,.14),rgba(129,140,248,.13));border-color:rgba(244,114,182,.32)}
  :root[data-theme="dark"] .dictate-btn{background:var(--card-2)}
  :root[data-theme="dark"] .dictate-btn:hover{background:rgba(244,114,182,.14)}
  :root[data-theme="dark"] .dictate-transcript-wrap{background:rgba(26,26,29,.92);border-color:var(--border)}

  /* Documentation, nursing, progress notes, and assisted drafts. */
  :root[data-theme="dark"] .check-grid label::before{background:var(--surface-input)}
  :root[data-theme="dark"] .nrv-mic-btn{background:rgba(244,114,182,.12);border-color:rgba(244,114,182,.32)}
  :root[data-theme="dark"] .nrv-mic-btn:hover{background:rgba(244,114,182,.20)}
  :root[data-theme="dark"] .body-region{fill:rgba(129,140,248,.18);stroke:var(--indigo)}
  :root[data-theme="dark"] .body-region:hover{fill:rgba(129,140,248,.30)}
  :root[data-theme="dark"] .body-extra-btn,
  :root[data-theme="dark"] .nrv-vitals-btn{background:rgba(129,140,248,.14);border-color:rgba(129,140,248,.32)}
  :root[data-theme="dark"] .section-action-btn.secondary{background:var(--card-2)}
  :root[data-theme="dark"] .shift-banner{background:linear-gradient(135deg,var(--warn-soft),rgba(251,191,36,.18))}
  :root[data-theme="dark"] .shift-banner.empty{background:linear-gradient(135deg,var(--card-3),var(--card-2))}
  :root[data-theme="dark"] .pn-tile{border-color:var(--border)}
  :root[data-theme="dark"] .pn-tile-src.green{background:var(--ok-soft);color:var(--ok)}
  :root[data-theme="dark"] .pn-tile-src.amber{background:var(--warn-soft);color:var(--warn)}
  :root[data-theme="dark"] .pn-tile-src.purple{background:rgba(167,139,250,.14);color:var(--purple)}
  :root[data-theme="dark"] .pn-tile-src.none{background:var(--card-3);color:var(--muted)}
  :root[data-theme="dark"] .pn-tile-ghost b{color:var(--ok)}
  :root[data-theme="dark"] .snap-head{background:linear-gradient(180deg,var(--card-2),var(--card))}
  :root[data-theme="dark"] .prefill-banner{background:linear-gradient(180deg,var(--brand-soft),var(--card))}
  :root[data-theme="dark"] .pn-asmt-draft{background:linear-gradient(90deg,rgba(167,139,250,.12),var(--card));border-color:rgba(167,139,250,.35)}
  :root[data-theme="dark"] .pn-asmt-draft-chip{background:rgba(167,139,250,.18);color:var(--purple)}
  :root[data-theme="dark"] .pn-asmt-draft-text{color:var(--ink-2)}
  :root[data-theme="dark"] .pn-asmt-draft-text mark.pn-cite{background:var(--warn-soft);color:var(--ink)}
  :root[data-theme="dark"] .pn-asmt-draft-skel,
  :root[data-theme="dark"] .ai-skeleton,
  :root[data-theme="dark"] .op-skeleton{background:linear-gradient(90deg,var(--card-2),var(--card-3),var(--card-2));background-size:200% 100%}
  :root[data-theme="dark"] .op-loading-card{background:linear-gradient(180deg,var(--card-2),var(--card));border-color:var(--border-2)}
  :root[data-theme="dark"] .op-step{background:var(--card-3);border-color:var(--border)}
  :root[data-theme="dark"] .op-step.active{background:var(--brand-soft);border-color:var(--brand-ring)}
  :root[data-theme="dark"] .pn-asmt-draft-err{background:var(--warn-soft);color:var(--warn)}
  :root[data-theme="dark"] .auto-fill-mark:hover{background:var(--card-2)}

  /* Insights, communications, and reports. */
  :root[data-theme="dark"] .ai-agent-pill{background:linear-gradient(90deg,rgba(10,132,255,.18),rgba(244,114,182,.16),rgba(251,146,60,.16));border-color:var(--brand-ring)}
  :root[data-theme="dark"] .ai-chat-btn.mic{background:rgba(244,114,182,.14)}
  :root[data-theme="dark"] .ai-chat-btn.mic:hover{background:rgba(244,114,182,.22)}
  :root[data-theme="dark"] .ai-chat-btn.send{background:linear-gradient(135deg,rgba(244,114,182,.22),rgba(251,146,60,.22));color:#fdba74}
  :root[data-theme="dark"] .ins5-traj.t-improving{background:var(--ok-soft);color:var(--ok);border-color:var(--ok-border)}
  :root[data-theme="dark"] .ins5-traj.t-stable{background:var(--brand-soft);color:var(--brand-2);border-color:var(--brand-ring)}
  :root[data-theme="dark"] .ins5-traj.t-worsening{background:var(--warn-soft);color:var(--warn);border-color:var(--warn-border)}
  :root[data-theme="dark"] .ins5-traj.t-critical{background:var(--crit-soft);color:var(--crit);border-color:var(--crit-border)}
  :root[data-theme="dark"] .ins5-traj.t-insufficient,
  :root[data-theme="dark"] .ins5-traj.t-null,
  :root[data-theme="dark"] .ins5-conf{background:var(--card-3);color:var(--muted);border-color:var(--border)}
  :root[data-theme="dark"] .comms-error-banner{background:var(--crit-soft);border-color:var(--crit-border);color:var(--crit)}
  :root[data-theme="dark"] .comms-error-banner b{color:var(--crit)}
  :root[data-theme="dark"] .comms-speaker-select,
  :root[data-theme="dark"] .comms-speaker-add{background:var(--card-2);border-color:var(--border-2)}

  /* Todo aggregates are intentionally conspicuous without becoming a bright
     block against OLED black. */
  :root[data-theme="dark"] .todo-rx-aggregate,
  :root[data-theme="dark"] .pri-item-aggregate{background:var(--crit-soft);border-color:var(--crit-border)}
  :root[data-theme="dark"] .todo-rx-aggregate:hover,
  :root[data-theme="dark"] .pri-item-aggregate:hover{background:rgba(248,113,113,.20);border-color:var(--crit)}

  @keyframes critPulseDark{
    0%,100%{box-shadow:0 0 0 0 rgba(248,113,113,.42);background-color:var(--crit-soft)}
    50%{box-shadow:0 0 0 4px rgba(248,113,113,0);background-color:rgba(248,113,113,.20)}
  }
  :root[data-theme="dark"] .lab-table td.cell-latest .v-crit,
  :root[data-theme="dark"] .mon-table td.mon-cell.cell-now.crit{animation-name:critPulseDark}

  /* ===================================================================
     DARK "SIGNAL FILL" PATCH — coordinated abnormal/status treatment for
     every screen. Dark-only; light mode unchanged. See design handoff.
     =================================================================== */
  /* 1 · Shared tokens — lift fills & borders for OLED black */
  :root[data-theme="dark"]{
    --crit-soft:rgba(248,113,113,.20);
    --crit-border:rgba(248,113,113,.50);
    --warn-soft:rgba(251,191,36,.18);
    --warn-border:rgba(251,191,36,.50);
    --ok-soft:rgba(74,222,128,.16);
    --ok-border:rgba(74,222,128,.45);
    --crit-on-fill:#fecaca;
    --warn-on-fill:#fde68a;
  }
  /* 2 · Monitoring flow sheet — text-only abnormal cells get fill + bar */
  :root[data-theme="dark"] .mon-table td.mon-cell.crit{background:var(--crit-soft);color:var(--crit-on-fill);box-shadow:inset 3px 0 0 var(--crit);font-weight:800}
  :root[data-theme="dark"] .mon-table td.mon-cell.warn{background:var(--warn-soft);color:var(--warn-on-fill);box-shadow:inset 3px 0 0 var(--warn);font-weight:800}
  :root[data-theme="dark"] .mon-table td.mon-cell.cell-now.crit{box-shadow:inset 3px 0 0 var(--crit)}
  /* 3 · Single-patient cockpit (Bedside home) */
  :root[data-theme="dark"] .cockpit-vital.crit .cv-v{color:var(--crit-on-fill)}
  :root[data-theme="dark"] .cockpit-vital.warn .cv-v{color:var(--warn-on-fill)}
  /* 4 · Monitoring board census cards */
  :root[data-theme="dark"] .monitoring-vital.vital-crit .monitoring-vital-value{color:var(--crit-on-fill)}
  :root[data-theme="dark"] .monitoring-vital.vital-warn .monitoring-vital-value{color:var(--warn-on-fill)}
  /* 5 · "Action needed now" rows */
  :root[data-theme="dark"] .now-item.crit,
  :root[data-theme="dark"] .now-item.warn{background:transparent}
  :root[data-theme="dark"] .now-item.crit .ni-label,
  :root[data-theme="dark"] .now-item.warn .ni-label{color:var(--ink)}
  /* 6 · Labs — brighten latest-column critical value */
  :root[data-theme="dark"] .lab-table td.cell-latest .v-crit{color:var(--crit-on-fill)}
  /* 7 · CMT vital strip */
  :root[data-theme="dark"] .vital-val.crit{color:var(--crit-on-fill)}
  :root[data-theme="dark"] .vital-val.warn{color:var(--warn-on-fill)}
  /* 8 · Solid status badges */
  :root[data-theme="dark"] .pri-count.crit,
  :root[data-theme="dark"] .ba-badge.crit,
  :root[data-theme="dark"] .chip.solid-crit{background:var(--crit);color:#1a0505;border-color:var(--crit)}
  /* --- light-mode leak fixes (hardcoded light bg, no prior dark rule) --- */
  /* 9 · Labs crit/warn body cells (#fef7f7 / #fffaeb beat the dark sweep) */
  :root[data-theme="dark"] .lab-table tr.row-crit td:not(.cell-test):not(.cell-latest){background:var(--crit-soft)}
  :root[data-theme="dark"] .lab-table tr.row-warn td:not(.cell-test):not(.cell-latest){background:var(--warn-soft)}
  /* 10 · Insights ins5-* flags / trajectory / interactions / conf / cite */
  :root[data-theme="dark"] .ins5-flag.critical{background:var(--crit-soft);color:var(--crit-on-fill);border-color:var(--crit-border)}
  :root[data-theme="dark"] .ins5-flag.high,
  :root[data-theme="dark"] .ins5-flag.low{background:var(--warn-soft);color:var(--warn-on-fill);border-color:var(--warn-border)}
  :root[data-theme="dark"] .ins5-flag.normal{background:var(--ok-soft);color:var(--ok);border-color:var(--ok-border)}
  :root[data-theme="dark"] .ins5-traj.t-improving{background:var(--ok-soft);color:var(--ok);border-color:var(--ok-border)}
  :root[data-theme="dark"] .ins5-traj.t-stable{background:var(--brand-soft);color:var(--brand-2);border-color:var(--brand-ring)}
  :root[data-theme="dark"] .ins5-traj.t-worsening{background:var(--warn-soft);color:var(--warn-on-fill);border-color:var(--warn-border)}
  :root[data-theme="dark"] .ins5-traj.t-critical{background:var(--crit-soft);color:var(--crit-on-fill);border-color:var(--crit-border)}
  :root[data-theme="dark"] .ins5-traj.t-insufficient,
  :root[data-theme="dark"] .ins5-traj.t-null,
  :root[data-theme="dark"] .ins5-conf{background:var(--card-3);color:var(--muted);border-color:var(--border-2)}
  :root[data-theme="dark"] .ins5-ddi.contraindicated{background:rgba(248,113,113,.24);border-color:var(--crit);border-left-color:var(--crit);color:#fecaca}
  :root[data-theme="dark"] .ins5-ddi.major{background:var(--crit-soft);border-color:var(--crit-border);border-left-color:var(--crit);color:#fecaca}
  :root[data-theme="dark"] .ins5-ddi.moderate{background:var(--warn-soft);border-color:var(--warn-border);border-left-color:var(--warn);color:#fde68a}
  /* 11 · Prescription indication + purple freq tokens */
  :root[data-theme="dark"] .o-indication{background:var(--warn-soft);color:var(--warn-on-fill);border-color:var(--warn-border)}
  :root[data-theme="dark"] .rx-tok.freq{background:rgba(168,85,247,.16);color:#c4b5fd;border-color:rgba(168,85,247,.4)}
  /* 12 · Legacy I/O table status rows */
  :root[data-theme="dark"] .io-table tr.subhead td{background:var(--brand-soft);color:var(--brand-2)}
  :root[data-theme="dark"] .io-table tr.balance td{background:var(--warn-soft);color:var(--warn-on-fill)}
  :root[data-theme="dark"] .io-table th.col-total{background:var(--card-2)}
  :root[data-theme="dark"] .io-grid td.cell-num.edited{background:var(--warn-soft);color:var(--warn-on-fill)}
  /* === end dark signal-fill patch === */

  *{box-sizing:border-box;margin:0;padding:0}
  svg{width:1em;height:1em;flex-shrink:0;vertical-align:-0.15em}
  html,body{
    background:var(--bg);
    color:var(--ink);
    /* Apple system font (SF Pro, with automatic Text/Display optical sizing) on
       Apple devices; Inter is the cross-platform fallback; Segoe UI Variable /
       system-ui cover Windows/Linux. */
    font-family:-apple-system,BlinkMacSystemFont,'Inter','Segoe UI Variable','Segoe UI',system-ui,sans-serif;
    font-feature-settings:'tnum' 1,'cv11' 1;
    font-optical-sizing:auto;
    -webkit-font-smoothing:antialiased;
    -moz-osx-font-smoothing:grayscale;
    text-rendering:optimizeLegibility;
    line-height:1.4;
    font-size:14px;
  }
  button{font:inherit;color:inherit;cursor:pointer;border:none;background:none}
  input,textarea,select{font:inherit;color:inherit}
  a{color:var(--brand);text-decoration:none}
  ::selection{background:var(--brand-soft);color:var(--brand-2)}
