/* =====================================================================
   theme.css — design tokens for the app (light + dark mode)
   ---------------------------------------------------------------------
   The single source of truth for color. Works with public/css/ds.css
   (component layer). Every stylesheet/inline style is being migrated from
   hardcoded hex/rgb to var(--token) references.

   PALETTE: "Ink" (2026-10-06). Light = Sellevry blue #0350a6 (the blue of the
   se. logo tile), violet #6337ad as its second colour, on neutrals tinted
   toward the brand navy — white topbar, pale table headers, flat cards.
   Dark = midnight navy with the same blue lifted to #7fb2f6 → violet #a688e8;
   the logo's orange (#ec9a3a) marks the active nav item. Shared token values
   here mirror docs/UI rules/app-ds/ds.css so ds.css components and legacy
   pages render on one palette.

   NOTE: as of the 2026-06-14 reskin, light mode is intentionally NOT the
   old literal palette — it adopts the refined primary blue tokens globally.

   data-theme is set on <html> before paint by a tiny inline head script
   (no FOUC); the toggle lives in the user-avatar menu (see theme.js).
   ===================================================================== */

:root {
  color-scheme: light;

  /* — surfaces — */
  --bg:           #f3f6fd;   /* Ink canvas — a light brand-blue cast under the white cards (owner, 2026-10-22: "the grey background is not really the best" → #ebf0f7 with the glow below, then twice "still too grey" → #f3f6fd, the cards set off by their border and shadow). Was #e3e9f3 (2026-10-15). */
  /* The approved mock's light at the top of the page: a blue glow at the top right and a
     violet one at the top left, over the canvas (body, app.css). Fixed px from the top, so
     a long page keeps it under its top bar, not above the screen. Dark: none. */
  /* THE switch's option in force (.seg / .segmented, app.css "THE SWITCH LOOK"): the accent,
     light — on the canvas and on a card alike. */
  --switch-on-bg:   color-mix(in srgb, var(--accent) 11%, var(--surface));
  --switch-on-ring: inset 0 0 0 1px color-mix(in srgb, var(--accent) 32%, transparent);
  --bg-glow:      radial-gradient(900px 520px at 88% -60px, rgba(3, 80, 166, .14), transparent 62%), radial-gradient(760px 460px at 18% -50px, rgba(99, 55, 173, .10), transparent 60%);
  --surface:      #ffffff;   /* cards, panels, modals, inputs */
  --logo-tile-bg: #ffffff;   /* behind a marketplace's logo (eBay, Shopify…): the light ground every logo is drawn for */
  --surface-2:    #eef2f9;   /* hover rows, soft containers, locked inputs */
  --surface-3:    #dfe6f1;   /* meta tags, subtle fills */
  --input-bg:     #ffffff;
  --info-widget-bg:     var(--surface);  /* dashboard info widgets — same fill as tiles, set apart by a bold accent frame */
  --info-widget-border: var(--accent);
  --dash-divider:       #dde4ef;  /* dashboard section divider — a quiet rule */

  /* — text — */
  --text:         #1b2742;   /* Ink — body / default text */
  --text-strong:  #0b1530;   /* headings */
  --text-subtle:  #3f4e6e;   /* secondary labels */
  --text-muted:   #5b6987;   /* helper text, metadata */
  --text-faint:   #8d99b0;   /* disabled, decorative — 2.9:1, never text someone must read (placeholders are --text-muted) */
  --text-inverse: #ffffff;   /* text on dark/colored surfaces — stays light */

  /* — borders — */
  --border:        #d6deea;  /* default borders / dividers / grid lines */
  --border-subtle: #cdd6e5;  /* input borders */
  --border-light:  #e9edf4;  /* faint dividers */
  --rule:          1px solid var(--border-light);
  /* A tab strip (app.css "TABS"): owner, 2026-10-25 — "when we have these rails in light mode,
     the page looks more blunt and less structured than in dark mode", tuned in a playground.
     The line under the strip is 20% Ink into the canvas at 1.5px, the icons are full Ink, the
     current tab 800. Dark keeps its look (below). */
  --tabs-line:     #c8cdd8;
  --tabs-line-w:   1.5px;
  --tab-icon:      var(--text);
  --tab-current-weight: 800;

  /* — accents / state — */
  --accent:        #0350a6;  /* Sellevry blue (logo) — primary action, links, focus */
  --accent-strong: #023f86;  /* Sellevry blue dark — header base, button hover */
  --brand:         var(--accent);
  --info:          #1f88c7;
  /* Accent gradients — shared by CTA buttons and progress fills (never a card
     bar: cards are plain since 2026-10-15). --accent-end is the far end of every filled accent gradient (primary
     buttons included). Light = blue → violet, the first leg of the se. logo;
     dark lifts both ends so they read on navy. */
  --accent-end:      #6337ad;
  --accent-gradient: linear-gradient(135deg, var(--accent), var(--accent-end));
  --accent-bar:      linear-gradient(90deg, var(--accent), var(--info), var(--info-light));
  --success:       #1a7a4e;
  /* Presence badge (the "who's online" count in the topbar). Picked against the
     TOPBAR, not a page surface: white in light (a solid green disc + white
     label), midnight navy in dark (the dark block swaps in a mint disc + dark
     label). Checked by src/ui/ink-palette.browser.test.js. */
  --presence-bg:   #157a49;
  --presence-text: #ffffff;
  --danger:        #d23b2e;
  --pri-mag:       #d81b9a;   /* the magenta of a tray type (.tt-magenta / .pill.magenta) — the same in both themes */
  --warning:       #b97e09;
  --signal:        #f6a31c;  /* Trimble Yellow — attention/secondary signal */
  --on-brand:      #ffffff;  /* text on accent fills */
  --link:          #0350a6;
  --accent-focus-ring: rgba(3, 80, 166, 0.22);
  /* Sign in with Google / Microsoft (.btn.provider): the providers' own colours, the same in both
     themes. Google's rules are a condition of its app verification, so these never join a theme. */
  --signin-bg:          #ffffff;
  --signin-hover:       #f6f7f8;
  --signin-google-line: #747775;
  --signin-google-ink:  #1f1f1f;
  --signin-ms-line:     #8c8c8c;
  --signin-ms-ink:      #5e5e5e;
  --font-signin-google: "Google Sans", var(--font-body);
  --chat-out-bg:   #0350a6;  /* outbound (our) chat bubble — Sellevry blue, white text */
  --chat-out-text: #ffffff;
  /* A conversation (app.css "CHAT THREAD"): a WHITE thread and reply box, incoming
     bubbles on a soft blue fill with strong text (owner 10-07: the grey thread was
     "greyish" and "hard to read"). src/ui/chat-thread-colors.browser.test.js */
  --chat-bg:        #ffffff;
  --chat-in-bg:     #eaf0fa;
  --chat-in-border: #d3ddee;
  --chat-in-text:   var(--text-strong);
  --chat-compose-bg: #ffffff;
  --sig-paper:      #ffffff;  /* an email signature is drawn on white, as a mail program shows it (.sig-paper) */
  --sig-ink:        #1f2328;
  /* An email as the customer sees it (the signature editor, app.css "RICH TEXT
     EDITOR"): white paper and dark ink in BOTH themes — a signature's own colours
     are chosen for a white mail, so editing it on a dark card would mislead. */
  --mail-paper: #ffffff;
  --mail-ink:   #1f2328;
  /* A variable label on that paper (app.css "VARIABLE LABELS"): the light blue pill. */
  --mail-var:    #0350a6;
  --mail-var-bg: #e3ecf8;

  /* — effects (layered for depth so cards read dimensional, not flat) — */
  --shadow-sm: 0 1px 2px rgba(11, 21, 48, 0.06);
  --shadow-md: 0 1px 2px rgba(11, 21, 48, 0.06), 0 12px 30px -14px rgba(3, 40, 110, 0.30);
  --shadow-lg: 0 2px 6px rgba(11, 21, 48, 0.06), 0 16px 40px -12px rgba(3, 40, 110, 0.22);
  /* a card lifted off its board under the pointer (CRM → Leads drag, the approved mock) */
  --shadow-lift: 0 34px 60px -22px rgba(3, 40, 110, 0.55), 0 8px 18px rgba(11, 21, 48, 0.14);
  --overlay:   rgba(12, 23, 40, 0.45);

  /* — type & shape — */
  /* The Apple font (owner, 2026-10-21: "i like the new font"): the real San
     Francisco on a Mac / iPhone / iPad, and Inter everywhere else — SF may not be
     served to other systems (Apple's licence), Inter is the open look-alike, loaded
     from the same font link as before. Mono: SF Mono where the system has it,
     JetBrains Mono otherwise. --font-system has NO downloaded font: text in the
     fixed top bar uses it, so the bar never changes size when a font arrives. */
  --font-display:-apple-system,BlinkMacSystemFont,"SF Pro Display","Inter",system-ui,"Segoe UI",Roboto,sans-serif;
  --font-body:-apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,"Segoe UI",Roboto,sans-serif;
  --font-system:-apple-system,BlinkMacSystemFont,system-ui,"Segoe UI",Roboto,sans-serif;
  --font-mono:ui-monospace,"SF Mono",SFMono-Regular,"JetBrains Mono",Menlo,monospace;
  --radius:12px; --radius-lg:16px; --radius-sm:8px;

  /* — shell size — the fixed top bar's height, the closed side rail's width and
     the logo tile in the bar. Everything that clears the bar or the rail (.main,
     sticky headers, scroll margins, the CoPilot panel, toasts) reads these, so
     the shell is resized HERE and nowhere else (owner, 2026-10-12: a narrower
     rail and a lower bar, more room for the page; was 68px / 60px / 44px, then
     60 / 52 / 38 — "a tiny bit smaller" again the same day). */
  --topbar-h:48px;
  --rail-w:52px;
  /* the open rail — and the page's margin while it is pinned (the new layout, step 2, 2026-10-21) */
  --rail-open:224px;
  /* the rail floats: this far in from the window's left and bottom edges, and under
     the top bar (the new layout, step 3, 2026-10-21) */
  --rail-inset:8px;
  /* the room between the folded rail and the page (the mock: the page starts 76px in,
     owner 2026-10-22 "the width is not the same"); a pinned rail keeps --rail-inset */
  --rail-gap:16px;
  /* the glass rail's corners: half the folded strip, so folded it is a capsule (owner, 2026-11-01) */
  --rail-radius:26px;
  --topbar-logo:36px;
  /* the page's margin on a computer: .view's sides and bottom (the scanner's
     container follows the sides); phones keep their own in mobile.css
     (owner, 2026-10-12: smaller, was 34px sides / 60px bottom) */
  --view-pad-x:24px;
  --view-pad-b:32px;
  /* — density — the sizes every page is built from (app.css + the page sheets read
     them): body text, a button, a field / filter chip, a small button, the inset of a
     box, a table cell, a KPI number, the page title. A LAPTOP-SIZED display (≤1600px
     wide — a 13-16" MacBook) gets the smaller set below (owner, 2026-10-12: "shrink it
     on small displays slightly more"); a big monitor keeps these. Phones keep their own
     (mobile.css), and a finger still gets 36px targets (pointer:coarse). */
  --fs-body:13px;
  --btn-h:34px;
  --btn-h-sm:30px;
  --ctl-h:32px;
  --box-pad:16px;
  --cell-py:9px;
  --cell-px:14px;
  --kpi-val:26px;
  --h1:22px;

  /* — toast anchor (THE one corner: TOP-RIGHT, on every page) —
     Every transient notice in the app renders in the shared .toast-region
     (app.css) anchored here: the fixed .topbar's height + 12px breathing
     room, so a toast never hides behind it. Not theme-dependent — declared once
     in :root so a page with no topbar (login/2fa) can override the ONE token
     instead of re-implementing a corner. */
  --toast-top:   calc(var(--topbar-h) + 12px);
  --toast-right: 22px;
  --toast-gap:   10px;
  --toast-width: min(420px, calc(100vw - 44px));

  /* — dropdown arrow — THE one chevron every single-value <select> paints
     (app.css "ONE DROPDOWN ARROW"), and the .inv-dropdown checkbox dropdown
     mirrors. Lucide chevron-down, 14px. A data URI cannot read a CSS variable,
     so its stroke is a fixed mid-grey that reads on BOTH themes' input
     surfaces — declared once in :root, not per theme. */
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23808a99' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");

  /* — header band on the CUSTOMER-facing pages (consignor portal, agreements,
     marketing preferences): stays deep → Sellevry blue, dark in BOTH themes.
     The operator app's own topbar is --topbar-* in app.css. — */
  --header-bg:   linear-gradient(135deg, #023f86 0%, #0350a6 100%);
  --header-text: #ffffff;
  /* table / column header band — Ink: the side rail's twin (app.css carries the
     same values as --th-fg / --th-border) */
  --th-bg: #283668;  --th-text: color-mix(in srgb,var(--sidebar-fg) 75%,#fff);  /* the side rail's twin: its navy (lifted a shade) + its icon colour (owner) */
  /* The sort-column arrows — the same colour as the labels, in both themes (owner). */
  --th-accent: color-mix(in srgb,var(--sidebar-fg) 75%,#fff);
  /* tray editor (edit-tray.css): the panel tab strip, the Items list head and the
     panel's section labels wear the table header's navy (owner's pick, 2026-10-15:
     "A with B's navy band"). The active tab is a white tab joined to the panel, so
     it needs no underline. Dark keeps its own look (below). */
  --panel-tabs-bg: var(--th-bg);  --panel-tabs-border: var(--th-bg);
  --panel-tabs-fg: var(--th-fg);  --panel-tabs-fg-hover: #ffffff;  --panel-tab-ink: transparent;
  --rail-head-bg: var(--th-bg);   --rail-head-fg: var(--th-fg);   --rail-head-border: var(--th-bg);
  --panel-sec: var(--th-bg);

  /* — status pills: bg / text / border — */
  --pill-green-bg: #e3f3ec;  --pill-green-text: #15663f;  --pill-green-border: #b3ddc6;
  --pill-blue-bg:  #e3ecf8;  --pill-blue-text:  #0350a6;  --pill-blue-border:  #b8cdea;
  --pill-amber-bg: #fdf0d6;  --pill-amber-text: #8a5a08;  --pill-amber-border: #f1d79c;
  --pill-red-bg:   #fbeae8;  --pill-red-text:   #b3271a;  --pill-red-border:   #f1c2bc;
  --pill-gray-bg:  #eceef1;  --pill-gray-text:  #505b66;  --pill-gray-border:  #ced5dd;
  /* — a status colour as TEXT: a pill's word, a danger button's label, a KPI note, a
     coloured figure. ≥ 4.5:1 on a card, on the page and on the status's own tint (the
     raw --green/--blue/--amber/--red are fills, dots and icons: as 11-13px text they
     read 3.1-4.4:1 in light — Apple review 2026-10-23, src/ui/status-contrast.browser.test.js).
     Dark keeps the status colours themselves: they already read 5-8:1 there. — */
  --green-text: var(--pill-green-text);  --blue-text: var(--pill-blue-text);  --amber-text: var(--pill-amber-text);
  --red-text:   var(--pill-red-text);    --gray-text: var(--pill-gray-text);

  /* — CHART colours (public/js/chart-factory.js). ONE categorical palette in a
     fixed order — Sellevry blue, orange, green, yellow, pink, green, logo
     violet, red — validated colour-blind-safe with the dataviz validator (adjacent
     CVD ΔE ≥ 8.3, normal-vision ΔE ≥ 18.6, every slot ≥ 3:1 on the white card).
     Slots 2-5 were stepped darker on 2026-10-23 (Apple review, reports H2: the
     sales green read 2.82:1, the yellow 2.17:1 on white): same hue families, the
     orange pulled toward red and the yellow toward gold so the two stay apart at
     card contrast (all-pairs normal-vision ΔE 6.1 → 8.5). Charts use it by MEANING: a
     metric keeps one slot everywhere, an entity (channel, category, stage) keeps
     one slot in every chart, and an ORDERED set (age buckets, funnel, A/B/C) runs
     the one-hue ramp --chart-seq-1..5 light → dark, its lightest step ≥ 3:1 on the
     card. The UI accent is NOT a chart colour. Dark mode has its own steps
     (validated on the dark card). src/ui/chart-colors.client.test.js — */
  --chart-1: #1f66c4;  --chart-2: #dd764f;  --chart-3: #2ba681;  --chart-4: #bf8101;
  --chart-5: #e9679b;  --chart-6: #008300;  --chart-7: #6337ad;  --chart-8: #e34948;
  --chart-seq-1: #6995d3;  --chart-seq-2: #437bca;  --chart-seq-3: #2261ba;  --chart-seq-4: #154a97;  --chart-seq-5: #11366e;
  /* — Colour system (owner, 2026-10-21: one colour, one meaning). Decoration is
     neutral: a figure tile's trend line (--spark) and a person's initials
     (--mono-*) carry no colour of their own — a person is not a status. White
     initials stay ≥ 4.5:1 across the whole gradient. — */
  --spark: #7d8aa8;
  --mono-bg: linear-gradient(180deg, #6b7488, #565f73);  --mono-fg: #ffffff;
  /* — The glass rail on a computer (app.css SIDEBAR, owner 2026-11-01). --sidebar-bg stays the
     solid navy: a phone's drawer, Reduce Transparency and Increase Contrast wear it. The tint is
     dense enough, and the blur darkens enough, that its text keeps 4.5:1 over a white page
     (rail-glass.browser.test.js reads the pixels). — */
  --rail-glass: linear-gradient(155deg, rgb(255 255 255 / .07), transparent 30%), linear-gradient(180deg, rgb(14 29 92 / .72), rgb(11 22 72 / .77));
  --rail-glass-filter: blur(14px) saturate(140%) brightness(.74);
  --rail-glass-fg: #e9eefa;
  --rail-glass-ink: rgb(8 14 34 / .28);
  --rail-glass-hover: rgb(255 255 255 / .14);
  --rail-glass-rim: rgb(255 255 255 / .24);
  --rail-glass-rim-top: rgb(255 255 255 / .16);
  --rail-glass-sheen: rgb(255 255 255 / .24);
  --rail-lens-bg: linear-gradient(180deg, rgb(255 255 255 / .09), rgb(255 255 255 / 0)) rgb(255 255 255 / .02);
  --rail-lens-rim: inset 0 0 0 1px rgb(255 255 255 / .34), inset 0 1px 1px rgb(255 255 255 / .16), 0 5px 14px -5px rgb(6 12 32 / .45);
  --rail-lens-away: rgb(255 255 255 / .07);
  --rail-glow: radial-gradient(135px 520px at 0 20%, rgb(3 110 230 / .38), transparent 74%), radial-gradient(135px 460px at 0 58%, rgb(120 60 215 / .33), transparent 74%), radial-gradient(135px 300px at 0 98%, rgb(240 150 40 / .36), transparent 74%);
  /* — Data World (Reports → Data World, public/js/data-world-scene.js): the 3D place's
     sky, ground, slabs, structures and light. Read by the scene on every theme switch. — */
  --w-sky: #dde8f4;  --w-ground: #c5d9b4;  --w-grid: #d8e0ec;  --w-pad: #f1f4f8;  --w-pad-edge: #c3cee0;
  --w-floor: #e9eef6;  --w-block: #ffffff;  --w-frame: #a7b5ca;  --w-dim: #d3dbe8;  --w-glass: #a9c3e8;
  --w-hemi-sky: #ffffff;  --w-hemi-ground: #7f8f6c;  --w-amb: .58;  --w-sun: .72;
  /* the small world: sky, land, water, streets, trees, lit windows (night windows glow: --w-glow) */
  --w-sky-top: #a6c4e8;  --w-water: #86afd8;  --w-earth: #b39b78;  --w-lawn: #b4cfa0;  --w-road: #dfe3e9;  --w-road-line: #ffffff;
  --w-tree-1: #73a562;  --w-tree-2: #568b58;  --w-tree-3: #94bd74;  --w-trunk: #8a6e55;  --w-window: #a9c3e8;  --w-glow: 0;
  --w-cloud: #ffffff;  --w-sun-color: #fff3df;  --w-wall: #f3f5f8;

  /* — listing-goal result cells: solid, high-contrast fills (both themes) — */
  --goal-achieved-bg: #2e9e63;  --goal-over-bg: #14653d;  --goal-missed-bg: #cf3b2e;  --goal-avg-bg: #1f88c7;  --goal-fg: #ffffff;
  --pill-purple-bg:#efe9f8;  --pill-purple-text:#6337ad;  --pill-purple-border:#d5c6ee;  /* the logo's violet */

  /* — extended tokens (added during the 2026-06-14 reskin sweep) — */
  /* soft accent fill/border for chips & icon badges */
  --accent-soft:   #e3ecf8;  --accent-border: #b8cdea;
  /* selected text (app.css ::selection) — its OWN token: --accent-soft is a hover
     tint, and as a selection it was invisible on the chat bubbles (2026-10-11) */
  --selection-bg:  #a9c7f0;
  /* a hover/emphasis border darker than --border */
  --border-strong: #b3bfd3;
  /* light frosted scrim (e.g. lock overlay) — becomes a dark scrim in dark mode */
  --scrim-light:   rgba(255, 255, 255, 0.9);
  /* state-color light/strong variants for gradients & button hovers */
  --success-light: #2a9a66;  --success-strong: #15663f;
  --danger-light:  #e05546;  --danger-strong:  #a31f14;
  --info-light:    #5aa9e0;
  /* soft callout surfaces: bg + (darker) text + border, per state */
  --warning-surface: #fdf0d6;  --warning-surface-text: #7a5208;  --warning-surface-border: #f1d79c;
  --danger-surface:  #fbeae8;  --danger-surface-text:  #7a1c12;  --danger-surface-border:  #f1c2bc;
  --success-surface: #e3f3ec;  --success-surface-text: #13502f;  --success-surface-border: #b3ddc6;
}
/* the laptop-sized tier of the density tokens above (≤1600px wide) */
@media (min-width:769px) and (max-width:1600px){
  :root{
    --fs-body:12.5px; --btn-h:32px; --btn-h-sm:28px; --ctl-h:30px; --box-pad:14px;
    --cell-py:8px; --cell-px:12px; --kpi-val:24px;
    --view-pad-x:20px; --view-pad-b:28px;
  }
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg-glow: none;

  /* — surfaces (Ink: ONE muted slate-navy family, half the blue of the first
     navy; rail + table headers in app.css are steps of the same family) — */
  --bg:           #10141c;
  --surface:      #171c26;
  --logo-tile-bg: #eef2f9;   /* a logo keeps a light ground in dark too — the eBay b, the Pinterest red and the Woo letters vanish on navy */
  --surface-2:    #1c222d;
  --surface-3:    #262d3a;
  --input-bg:     #12161f;   /* recessed below cards so fields are distinct */
  --info-widget-bg:     var(--surface);  /* same fill as tiles, set apart by a bold accent frame */
  --info-widget-border: var(--accent);

  /* — text — */
  --text:         #dce1ea;
  --text-strong:  #f4f6fa;
  --text-subtle:  #b5bdcc;
  --text-muted:   #98a1b3;
  --text-faint:   #646d80;
  --text-inverse: #ffffff;

  /* — borders (kept clearly visible on dark so sections keep structure) — */
  --border:        #2a3140;
  --border-subtle: #313949;
  --border-light:  #212734;
  --tabs-line:     var(--border);
  --tabs-line-w:   1px;
  --tab-icon:      currentColor;
  --tab-current-weight: 600;

  /* — accents / state (Ink: the logo blue → violet, lifted to read on dark).
     --on-brand is DARK text since the lifted accent is light. Amber stays the
     warning / signal colour only. — */
  --accent:        #7fb2f6;
  --accent-strong: #a5c9fa;
  --info:          #5aa9ef;
  --accent-end:      #a688e8;
  --accent-gradient: linear-gradient(135deg, var(--accent), var(--accent-end));
  --accent-bar:      linear-gradient(90deg, var(--accent), var(--accent-end));
  --success:       #3fb46b;
  --danger:        #f0746b;
  --warning:       #e6a32e;
  --signal:        #e6a32e;
  --on-brand:      #0b1530;
  --link:          #7fb2f6;
  --accent-focus-ring: rgba(127, 178, 246, 0.35);
  --presence-bg:   #6fdca8;  /* mint disc on the navy bar */
  --presence-text: #0b3d26;
  --chat-out-bg:   #2c6cb8;  /* outbound chat stays blue so white bubble text reads */
  --chat-out-text: #ffffff;
  /* dark keeps its look: cards-colour bubbles on the raised thread */
  --chat-bg:        var(--surface-2);
  --chat-in-bg:     var(--surface);
  --chat-in-border: var(--border);
  --chat-in-text:   var(--text);
  --chat-compose-bg: var(--surface-2);
  --sig-paper:      #ffffff;  /* still white: a signature's own colours are made for a white email */
  --sig-ink:        #1f2328;
  --mail-paper: #ffffff;   /* same paper as light: see the light block */
  --mail-ink:   #1f2328;
  --mail-var:    #0350a6;
  --mail-var-bg: #e3ecf8;

  /* — effects (deeper; soft light-mode shadows vanish on dark) — */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.65);
  --shadow-lift: 0 34px 60px -18px rgba(0, 0, 0, 0.8), 0 8px 18px rgba(0, 0, 0, 0.5);
  --overlay:   rgba(0, 0, 0, 0.65);

  /* — header / topbar (graphite gradient) — */
  --header-bg:   linear-gradient(135deg, #151b22 0%, #232d38 100%);
  --header-text: #e9eef4;
  /* table / column header band (a raised navy so it separates on dark) */
  --th-bg: #232a37;  --th-text: color-mix(in srgb,var(--sidebar-fg) 75%,#fff);
  --th-accent: color-mix(in srgb,var(--sidebar-fg) 75%,#fff);
  /* tray editor: dark keeps the plain strip with the accent underline */
  --panel-tabs-bg: var(--surface-2);  --panel-tabs-border: var(--border-light);
  --panel-tabs-fg: var(--text-muted); --panel-tabs-fg-hover: var(--text-strong);  --panel-tab-ink: var(--brand);
  --rail-head-bg: transparent;        --rail-head-fg: var(--text-muted);  --rail-head-border: var(--border-light);
  --panel-sec: var(--muted);

  /* — status pills: translucent dark fills + lighter text — */
  --pill-green-bg: rgba(63, 180, 107, 0.16);  --pill-green-text: #86e0a8;  --pill-green-border: rgba(63, 180, 107, 0.42);
  --pill-blue-bg:  rgba(90, 169, 239, 0.16);  --pill-blue-text:  #9cc8f5;  --pill-blue-border:  rgba(90, 169, 239, 0.42);
  --pill-amber-bg: rgba(230, 163, 46, 0.20);  --pill-amber-text: #f3c969;  --pill-amber-border: rgba(230, 163, 46, 0.5);
  --pill-red-bg:   rgba(240, 116, 107, 0.16); --pill-red-text:   #f4a59d;  --pill-red-border:   rgba(240, 116, 107, 0.42);
  --pill-gray-bg:  rgba(132, 147, 162, 0.16); --pill-gray-text:  #c3ccd6;  --pill-gray-border:  rgba(132, 147, 162, 0.4);
  --pill-purple-bg:rgba(128, 90, 213, 0.20);  --pill-purple-text:#d6bcfa;  --pill-purple-border:rgba(128, 90, 213, 0.45);
  /* status colour as TEXT (see the light block): dark's status colours already pass */
  --green-text: var(--green);  --blue-text: var(--blue);  --amber-text: var(--amber);
  --red-text:   var(--red);    --gray-text: var(--gray);

  /* — CHART colours: the same eight hues stepped for the dark card (validated on
     #171c26: adjacent CVD ΔE ≥ 8.4, normal-vision ΔE ≥ 19.3, all ≥ 3:1); the
     ordinal ramp flips its anchor — higher = brighter, its darkest step ≥ 3:1 on
     the card (2026-10-23: #2c5191 read 2.19:1). — */
  --chart-1: #4a8ee8;  --chart-2: #d96c1c;  --chart-3: #199e70;  --chart-4: #c98500;
  --chart-5: #d55181;  --chart-6: #008300;  --chart-7: #9a7fe6;  --chart-8: #e66767;
  --chart-seq-1: #4168aa;  --chart-seq-2: #507dc8;  --chart-seq-3: #6294de;  --chart-seq-4: #7eabee;  --chart-seq-5: #a3c2f0;
  --spark: #8c96ab;
  --mono-bg: linear-gradient(180deg, #5f687a, #454d5c);  --mono-fg: #eef1f6;
  /* (a dark page still holds bright things, a product photo above all: the words keep 4.5:1 with white behind them here too) */
  --rail-glass: linear-gradient(155deg, rgb(255 255 255 / .025), transparent 30%), linear-gradient(180deg, rgb(27 32 45 / .71), rgb(18 22 31 / .75));
  --rail-glass-filter: blur(14px) saturate(125%) brightness(.56);
  --rail-glass-rim: rgb(255 255 255 / .12);
  --rail-glass-rim-top: rgb(255 255 255 / .08);
  --rail-glass-sheen: rgb(255 255 255 / .12);
  --rail-lens-bg: linear-gradient(180deg, rgb(255 255 255 / .07), rgb(255 255 255 / 0)) rgb(255 255 255 / .02);
  --rail-lens-rim: inset 0 0 0 1px rgb(255 255 255 / .24), inset 0 1px 1px rgb(255 255 255 / .12), 0 5px 14px -5px rgb(0 0 0 / .5);
  --rail-glow: radial-gradient(135px 520px at 0 20%, rgb(50 120 240 / .18), transparent 74%), radial-gradient(135px 460px at 0 58%, rgb(130 85 225 / .16), transparent 74%), radial-gradient(135px 300px at 0 98%, rgb(240 150 40 / .12), transparent 74%);
  --w-sky: #101a29;  --w-ground: #15211c;  --w-grid: #19202b;  --w-pad: #151b25;  --w-pad-edge: #2b3546;
  --w-floor: #1b2231;  --w-block: #252e3e;  --w-frame: #4a5870;  --w-dim: #283041;  --w-glass: #5b7fb8;
  --w-hemi-sky: #b8c8e8;  --w-hemi-ground: #1a2130;  --w-amb: .78;  --w-sun: .55;
  --w-sky-top: #04070d;  --w-water: #0b1829;  --w-earth: #2b2520;  --w-lawn: #1a2a23;  --w-road: #222a37;  --w-road-line: #3b475a;
  --w-tree-1: #2d4b3b;  --w-tree-2: #223f30;  --w-tree-3: #365641;  --w-trunk: #3a2e26;  --w-window: #f2c26b;  --w-glow: .9;
  --w-cloud: #2a3447;  --w-sun-color: #b9c8ef;  --w-wall: #283142;

  /* — listing-goal result cells: solid, high-contrast fills (both themes) — */
  --goal-achieved-bg: #2f9b5e;  --goal-over-bg: #1c6e44;  --goal-missed-bg: #cf4034;  --goal-avg-bg: #2b86c4;  --goal-fg: #ffffff;

  /* — extended tokens (dark variants) — */
  --accent-soft:   rgba(127, 178, 246, 0.14);  --accent-border: rgba(127, 178, 246, 0.4);
  --selection-bg:  #34567f;
  --border-strong: #3c4558;
  --scrim-light:   rgba(16, 20, 28, 0.85);   /* light scrim flips to a dark scrim on dark */
  --success-light: #5cc283;  --success-strong: #2f9d5d;
  --danger-light:  #f4938b;  --danger-strong:  #d9544b;
  --info-light:    #7cbcf3;
  --warning-surface: rgba(230, 163, 46, 0.14);  --warning-surface-text: #f3c969;  --warning-surface-border: rgba(230, 163, 46, 0.4);
  --danger-surface:  rgba(240, 116, 107, 0.14); --danger-surface-text:  #f4a59d;  --danger-surface-border:  rgba(240, 116, 107, 0.4);
  --success-surface: rgba(63, 180, 107, 0.14);  --success-surface-text: #86e0a8;  --success-surface-border: rgba(63, 180, 107, 0.4);
}

/* Native checkboxes/radios: keep them clearly visible + on-brand in dark. */
html[data-theme="dark"] input[type="checkbox"],
html[data-theme="dark"] input[type="radio"] {
  accent-color: var(--accent);
}

/* =====================================================================
   VIEWPORT HEIGHT — `--vh` is THE unit for anything sized to the screen
   (a fixed panel, a modal's ceiling, a scroll box inside the page).
   `100vh` is the LARGEST viewport on a phone: it ignores the browser's
   collapsible address/toolbar, so a panel sized with it runs under that
   bar and its bottom row of buttons is unreachable (iOS Safari, Chrome
   Android). `100dvh` follows the bar as it shows and hides. Write
   `calc(var(--vh) - var(--topbar-h))` / `calc(var(--vh) * .9)`, never a bare `100vh`
   or `90vh`, and every panel fits the screen the operator actually has.
   Page-height minimums (body / .main min-height) may keep `100vh` — a page
   that grows when the bar collapses is fine; a panel that hides its
   buttons is not. (2026-09-26)
   ===================================================================== */
:root { --vh: 100vh; }
@supports (height: 100dvh) {
  :root { --vh: 100dvh; }
}

/* =====================================================================
   PHOTO VIEWER — the full-screen image viewer's scrim and its buttons (×,
   Rotate, Download, ‹ ›), the SAME in both themes (owner, 2026-10-11: "in
   non dark mode … the x or rotate buttons as well as the prev and next are
   hard to see"). The product viewer sat on the theme's --overlay, a pale 45%
   tint in light mode, and every button was white on a 14% white wash — lost
   on a light page and on any light photo under it (a phone's arrows always
   sit over the photo). So: the scrim is always near-black, and a button is
   a SOLID dark chip with a light ring + shadow — readable over the scrim
   and over a white product shot alike. Every viewer reads these:
   .x-modal-backdrop.is-full, .x-modal__nav, .lightbox-tool,
   .close-button.lightbox (app.css), .inv-image-viewer (inventory.css) and
   #lightboxOverlay / .lightbox-prev/-next (edit-panels.css). */
:root {
  --viewer-scrim:        rgba(8, 11, 18, 0.92);
  --viewer-ctl-bg:       rgba(16, 20, 28, 0.72);
  --viewer-ctl-bg-hover: rgba(40, 47, 60, 0.92);
  --viewer-ctl-fg:       #ffffff;
  --viewer-ctl-ring:     rgba(255, 255, 255, 0.28);
  --viewer-ctl-shadow:   0 1px 4px rgba(0, 0, 0, 0.45);
}
/* =====================================================================
   MOTION — THE durations and curves for every transition and short
   animation in the app (2026-10-06). The sheets had ~25 different
   speed/curve pairs (.12s, .13s, .14s, .15s, 0.3s, plain `ease`…), so
   nothing moved alike. Pick by what is moving, never a literal:
     --dur-instant  a press going down (.btn:active) — must feel immediate
     --dur-fast     hover / focus / colour / border changes
     --dur          things that appear or move: menus, popovers, the rail,
                    content arriving after its skeleton, the page-change fade
     --dur-slow     big moves: the phone drawer, a page's entrance (.view)
     --ease         everything that enters or responds (a soft ease-out)
     --ease-in-out  something that goes and comes back (drawer, rail width)
     --ease-exit    something LEAVING (a menu or dialog closing): it holds,
                    then speeds away. On --ease the first third of a fade-out
                    already took 80% of it, so a closing menu read as a snap
                    (owner, 2026-10-07: "I don't see it")
   0.5s and longer is a deliberate effect, not UI motion (a chart bar
   morphing to new data, a "here it is" row highlight, a spinner) — those
   keep their own timing. Motion never makes anyone wait: nothing is
   longer than --dur-slow, and no script waits for an animation.
   The page's entrance (the new layout, step 3 — owner, 2026-10-21: "adopt the
   mock's motion"; app.css "PAGE ENTRANCE"):
     --dur-entrance  the content settling in (scale .985 → 1) as a page opens
     --dur-count     a figure counting up, a sparkline drawing, a bar filling
     --cascade-step  the gap between two table rows fading in (first 10 only)
   It never holds anything back: the content is there and clickable at once.
   Reduced motion: every token drops to 1ms (not 0, so `animationend` /
   `transitionend` still fire for any script listening), which turns all
   of it off in one place. Tested by src/ui/motion-tokens.test.js and
   src/ui/motion.browser.test.js.
   ===================================================================== */
:root {
  --dur-instant: 70ms;
  --dur-fast:    120ms;
  --dur:         180ms;
  --dur-slow:    260ms;
  --ease:        cubic-bezier(.2, .8, .2, 1);
  --ease-in-out: cubic-bezier(.4, 0, .2, 1);
  --ease-exit:   cubic-bezier(.4, 0, 1, 1);
  --dur-entrance: 560ms;
  --dur-count:    900ms;
  --cascade-step: 35ms;
  /* Sally's panel sliding in beside the page while the page makes room — the mock's
     "glide" (owner, 2026-10-22: opening Sally "is not smooth like in the mock") */
  --dur-panel:    340ms;
  --ease-glide:   cubic-bezier(.32, .72, 0, 1);
}
/* TABLE KIT (/js/table-kit.js, app.css "TABLE KIT"): a pinned column's line under
   its header and its edge once the table scrolls sideways, and the column being
   resized. Built from the theme's own colours, so both themes follow. */
:root {
  --tk-pin-line: inset 0 -2px 0 var(--accent);
  --tk-pin-edge: 10px 0 14px -10px color-mix(in srgb, var(--text) 30%, transparent);
  --tk-tint: color-mix(in srgb, var(--accent-soft) 70%, transparent);
}
@media (prefers-reduced-motion: reduce) {
  :root { --dur-instant: 1ms; --dur-fast: 1ms; --dur: 1ms; --dur-slow: 1ms; --dur-entrance: 1ms; --dur-count: 1ms; --cascade-step: 0ms; --dur-panel: 1ms; }
}

/* ============================== INCREASE CONTRAST ==============================
   The system's Increase Contrast (macOS / iOS Accessibility › Display, Windows'
   contrast themes' "more"): every token a reader leans on steps up — text and muted
   text to 7:1 on a card, borders and the glass line to 3:1 (they are the edge of a
   control), each status pill's text to 7:1 on its fill, the focus ring near solid.
   The Apple design review, 2026-10-23 (HIG accessibility.md › Vision: "provide a
   higher contrast color scheme when the system setting Increase Contrast is turned
   on"). Tokens only — every component follows. `html:root…` with the theme's own
   attribute outranks both theme.css and app.css's :root blocks, one theme each.
   Tested by src/ui/increase-contrast.browser.test.js. */
@media (prefers-contrast: more) {
  html:root:not([data-theme="dark"]) {
    --text-subtle: #2a3754;  --text-2: #2a3754;
    --text-muted:  #3f4e6e;  --muted:  #3f4e6e;
    --border: #8592ab;  --border-subtle: #8592ab;  --border-light: #a7b2c6;  --border-strong: #6b7891;
    --glass-line: #8592ab;  --tabs-line: #8592ab;
    --rail-glass: var(--sidebar-bg);  --rail-glass-filter: none;  --rail-glow: none;  --rail-glass-fg: #ffffff;  --rail-glass-rim: rgb(255 255 255 / .7);  --rail-lens-rim: inset 0 0 0 1.25px rgb(255 255 255 / .8);
    --accent-focus-ring: rgba(3, 80, 166, 0.6);
    --pill-green-text: #0f4f30;  --pill-blue-text: #023f86;  --pill-amber-text: #6b4505;
    --pill-red-text:   #8a1d12;  --pill-gray-text: #3a434d;
  }
  html:root[data-theme="dark"] {
    --text-subtle: #d3d9e4;  --text-2: #d3d9e4;
    --text-muted:  #b5bdcc;  --muted:  #b5bdcc;
    --border: #5f6b82;  --border-subtle: #5f6b82;  --border-light: #48526a;  --border-strong: #7a869d;
    --glass-line: #5f6b82;  --tabs-line: #5f6b82;
    --rail-glass: var(--sidebar-bg);  --rail-glass-filter: none;  --rail-glow: none;  --rail-glass-fg: #ffffff;  --rail-glass-rim: rgb(255 255 255 / .6);  --rail-lens-rim: inset 0 0 0 1.25px rgb(255 255 255 / .8);
    --accent-focus-ring: rgba(127, 178, 246, 0.7);
    --pill-red-text: #f8bdb6;
  }
}
