  :root{
    /* -- Base tokens (light theme, comfortable density, default palette) -- */
    --bg-page:#F4F5F7;--bg-card:#FFF;--bg-secondary:#EEF0F3;
    --text-primary:#1A1A2E;--text-secondary:#5A5A6E;--text-tertiary:#8A8A9A;
    --border-t:rgba(17,0,56,0.12);--border-s:rgba(17,0,56,0.22);
    --font-sans:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;
    --font-mono:"SF Mono",ui-monospace,"Cascadia Mono",Menlo,monospace;
    --r:12px;--ep:#463490;--eo:#E87825;--green:#1A9B5A;--amber:#D97706;--red:#DC2626;--violet:#6D28D9;
    --bg-ok:#E3F4EC;--bg-warn:#FBEFD9;--bg-bad:#FBE5E5;--bg-info:#E6EDFA;--bg-purp:#EDE9FE;
    --t-ok:#0F6E3F;--t-warn:#9A5B08;--t-bad:#A32D2D;--t-info:#2D4B8A;--t-purp:#5B21B6;
    --header-bg:#110038;
    /* Font scale (dashboard/js/03-prefs.js writes this inline as a decimal, e.g. 1.15) */
    --font-scale:1;
    /* Density spacing -- comfortable defaults; only the highest-traffic layout
       rules (.card/.dt cells/.rside-sec) read these, not every rule in the app. */
    --space-card:18px 20px;--space-cell:8px 9px;--space-cell-hd:6px 9px;--space-sec:12px 16px;
    /* Chart series ramp, shared by every hand-rolled SVG chart (see
       dashboard/js/00-format.js chartPalette()). Default palette matches the
       existing ad hoc colors those charts already used. */
    --chart-1:#463490;--chart-2:#7B9FD4;--chart-3:#E87825;--chart-4:#1A9B5A;
    --chart-5:#0EA5E9;--chart-6:#C62828;--chart-7:#B85C00;--chart-8:#6D28D9;
    --chart-positive:#1A9B5A;--chart-negative:#DC2626;
  }
  [data-theme="dark"], [data-theme="system"]{
    --bg-page:#0E0E18;--bg-card:#1A1A2A;--bg-secondary:#242438;
    --text-primary:#E8EAF0;--text-secondary:#A0A2B5;--text-tertiary:#70728A;
    --border-t:rgba(255,255,255,0.12);--border-s:rgba(255,255,255,0.22);
    --bg-ok:#13321F;--bg-warn:#3A2A0C;--bg-bad:#3A1717;--bg-info:#1A2540;--bg-purp:#2A1A4A;
    --t-ok:#4ECB89;--t-warn:#F0A93F;--t-bad:#F08585;--t-info:#85A8E8;--t-purp:#B79CF0;
  }
  /* An explicit choice always wins over the OS setting; [data-theme="system"]
     above supplies the dark values as its base, this media query only ever
     reverts a system-mode page back to light when the OS itself is light. */
  @media(prefers-color-scheme:light){
    [data-theme="system"]{
      --bg-page:#F4F5F7;--bg-card:#FFF;--bg-secondary:#EEF0F3;
      --text-primary:#1A1A2E;--text-secondary:#5A5A6E;--text-tertiary:#8A8A9A;
      --border-t:rgba(17,0,56,0.12);--border-s:rgba(17,0,56,0.22);
      --bg-ok:#E3F4EC;--bg-warn:#FBEFD9;--bg-bad:#FBE5E5;--bg-info:#E6EDFA;--bg-purp:#EDE9FE;
      --t-ok:#0F6E3F;--t-warn:#9A5B08;--t-bad:#A32D2D;--t-info:#2D4B8A;--t-purp:#5B21B6;
    }
  }
  /* High contrast: near-black/white text, opaque solid-color borders instead of
     low-alpha ones, and a punchier palette so RAG status never washes out. */
  [data-contrast="high"]{
    --text-primary:#000;--text-secondary:#1A1A1A;--text-tertiary:#3A3A3A;
    --border-t:rgba(0,0,0,0.55);--border-s:rgba(0,0,0,0.75);
    --green:#0B6B33;--amber:#8A4B00;--red:#A30000;
  }
  [data-theme="dark"][data-contrast="high"]{
    --text-primary:#FFF;--text-secondary:#F0F0F5;--text-tertiary:#D0D0DC;
    --border-t:rgba(255,255,255,0.55);--border-s:rgba(255,255,255,0.75);
    --green:#4ECB89;--amber:#FFC24D;--red:#FF8A8A;
  }
  /* [data-theme="system"][data-contrast="high"] must resolve per OS scheme rather
     than unconditionally, since it otherwise ties/loses against the light-mode
     revert above by cascade order alone -- see the wash-out this fixed. */
  @media(prefers-color-scheme:dark){
    [data-theme="system"][data-contrast="high"]{
      --text-primary:#FFF;--text-secondary:#F0F0F5;--text-tertiary:#D0D0DC;
      --border-t:rgba(255,255,255,0.55);--border-s:rgba(255,255,255,0.75);
      --green:#4ECB89;--amber:#FFC24D;--red:#FF8A8A;
    }
  }
  @media(prefers-color-scheme:light){
    [data-theme="system"][data-contrast="high"]{
      --text-primary:#000;--text-secondary:#1A1A1A;--text-tertiary:#3A3A3A;
      --border-t:rgba(0,0,0,0.55);--border-s:rgba(0,0,0,0.75);
      --green:#0B6B33;--amber:#8A4B00;--red:#A30000;
    }
  }
  [data-density="compact"]{
    --space-card:12px 14px;--space-cell:5px 7px;--space-cell-hd:4px 7px;--space-sec:8px 12px;
  }
  /* Colorblind-safe series (Okabe-Ito): distinguishable under all three common
     forms of color vision deficiency. Positive/negative kept as green/red
     (with a redundant text/icon cue at every call site -- color is never the
     only signal) since that convention is expected regardless of palette. */
  [data-palette="cb-safe"]{
    --chart-1:#0072B2;--chart-2:#56B4E9;--chart-3:#E69F00;--chart-4:#009E73;
    --chart-5:#F0E442;--chart-6:#D55E00;--chart-7:#CC79A7;--chart-8:#000000;
    --chart-positive:#009E73;--chart-negative:#D55E00;
  }
