/* ============================================================================
   FORWARD FURNITURE — SHARED DESIGN TOKENS (the single source of truth)
   ============================================================================
   Created 2026-08-27 per the owner ("make it one shared stylesheet so it never
   drifts"). This ONE physical file defines every color, font size, spacing
   step, radius and shadow for BOTH apps, in BOTH themes:

     - the tracker admin  (po-tracker + po-tracker-web pages, ports 8791/8792,
       forwardfurnitureadmin.vercel.app) — loads it as /design-tokens.css from
       its own static root, which is this directory;
     - Forward Inventory  (inventory app, port 8850) — its server.js has an
       explicit route that serves THIS SAME FILE from this path, so there is
       no copy to fall out of date.

   HOW THE TWO VOCABULARIES COEXIST: the two apps grew different token names
   for the same ideas (inventory says --surface/--hairline/--ink, the tracker
   says --panel/--border/--text). The CANONICAL names below are inventory's;
   the tracker's names are declared as var() aliases of them. Because aliases
   resolve at use time, the DARK blocks at the bottom only redefine canonical
   names — every alias follows automatically. To restyle anything, change a
   canonical value here once; never re-declare these tokens in either app's
   component stylesheet again — that is exactly the drift this file exists to
   end.

   THEME MODEL (identical in both apps): light is defined on :root; dark
   applies when the user's OS prefers dark AND no explicit choice was made
   (the :not([data-theme="light"]) media block), or when the app's toggle
   stamps data-theme="dark" (tracker: theme.js / 'ff-theme'; inventory:
   app.js / 'inv_theme').
   ========================================================================== */

:root {
  font-size: 15px;
  color-scheme: light;

  /* ---- surfaces & ink (canonical) ---- */
  --bg: #fafafa;                 /* the page */
  --surface: #ffffff;            /* cards, tables, inputs */
  --surface-2: #fafbfc;          /* table headers, quiet panels, row hover */
  --chart-surface: #fcfcfb;
  --ink: #14161a;                /* primary text */
  --ink-2: #4a4f58;              /* secondary text */
  --muted: #7b8291;              /* labels, helper lines */
  --hairline: #e7e8eb;           /* standard border */
  --hairline-2: #eef0f4;         /* row separators — lighter than a border */
  --border-strong: #d6dae1;      /* a division that must read as a real line */
  --grid: #e1e0d9;
  --ink-block: #1f2937;          /* inverse blocks: toasts, dark group-row headers */

  /* ---- sidebar ---- */
  --sidebar-bg: #fcfcfd;
  --sidebar-ink: #565d6a;
  --sidebar-active: var(--ink);
  --sidebar-hover: rgba(20, 22, 26, .045);
  --sidebar-w: 236px;

  /* ---- accent ---- */
  --accent: #2e6ee0;
  --accent-hover: #2359ba;
  --accent-soft: #e8f1fc;
  --accent-ink: #1c5cab;         /* accent darkened to pass AA for small text */
  --series-1: #2a78d6;
  --series-2: #eb6834;

  /* ---- status: each has a base hue, a text colour and a soft pair ---- */
  --good: #0ca30c;     --good-text: #04660f;     --good-soft: #e6f6e9;
  --warning: #fab219;  --warn-text: #8a5a00;     --warn-soft: #fdf3d9;
  --serious: #ec835a;  --serious-text: #9c4520;  --serious-soft: #fdece4;
  --critical: #d03b3b; --crit-text: #b02020;     --crit-soft: #fceaea;
  --purple: #7c5cbf;

  /* ---- scales ---- */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lift: 0 6px 20px rgba(16, 24, 40, .08);
  --ring: 0 0 0 3px var(--accent-soft);

  /* ======================================================================
     TRACKER VOCABULARY — aliases only. Never give these literal values:
     they exist so ~1500 lines of tracker CSS keep working without edits,
     and pointing them anywhere but the canonical tokens re-opens drift.
     ====================================================================== */
  --panel: var(--surface);
  --panel-2: var(--surface-2);
  --border: var(--hairline);
  --text: var(--ink);
  --text-dim: var(--ink-2);
  --green: var(--good-text);
  --yellow: var(--warn-text);
  --orange: var(--serious-text);
  --red: var(--crit-text);
  --r-sm: var(--radius-sm);
  --r-md: var(--radius-sm);
  --r-lg: var(--radius);
  --r-pill: 999px;
  --shadow-sm: var(--shadow);
  --shadow-md: var(--shadow-lift);

  /* tracker type scale (px-based; the tracker predates rem sizing) */
  --fs-2xs: 11px; --fs-xs: 12px; --fs-sm: 13px; --fs-md: 14px;
  --fs-lg: 16px; --fs-xl: 19px; --fs-2xl: 22px; --fs-3xl: 26px; /* big figures (KPI values, counters), added 2026-10-02 */
  /* tracker spacing scale (has a 20px step inventory's scale skips) */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px;
  --topbar-h: 73px; /* fallback; measured live and overridden per-page where needed */
}

/* ============================================================================
   NIGHT — canonical names only; every alias above follows automatically.
   The same block appears twice on purpose: once under the OS-preference guard
   (dark OS + no explicit choice), once under the explicit toggle attribute.
   Keep the two lists IDENTICAL — edit both or neither.
   ========================================================================== */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #101318;
    --surface: #171b22;
    --surface-2: #1d222b;
    --chart-surface: #171b22;
    --ink: #e7eaf0;
    --ink-2: #aeb5c2;
    --muted: #7d8595;
    --hairline: #2a303b;
    --hairline-2: #232833;
    --border-strong: #3a4150;
    --grid: #2a303b;
    --sidebar-bg: #14171e;
    --sidebar-ink: #9aa2b1;
    --sidebar-active: #e7eaf0;
    --sidebar-hover: rgba(255, 255, 255, .06);
    --accent: #5b9ce6;
    --accent-hover: #7ab0ec;
    --accent-soft: #1c2c40;
    --accent-ink: #8db8ef;
    --good-text: #5ecb72;   --good-soft: #14301c;
    --warn-text: #e3b341;   --warn-soft: #33290f;
    --serious-text: #ec9a76; --serious-soft: #38200f;
    --crit-text: #ef7070;   --crit-soft: #3a1717;
    --purple: #ab92e2;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 1px 3px rgba(0, 0, 0, .5);
    --shadow-lift: 0 4px 12px rgba(0, 0, 0, .5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101318;
  --surface: #171b22;
  --surface-2: #1d222b;
  --chart-surface: #171b22;
  --ink: #e7eaf0;
  --ink-2: #aeb5c2;
  --muted: #7d8595;
  --hairline: #2a303b;
  --hairline-2: #232833;
  --border-strong: #3a4150;
  --grid: #2a303b;
  --sidebar-bg: #14171e;
  --sidebar-ink: #9aa2b1;
  --sidebar-active: #e7eaf0;
  --sidebar-hover: rgba(255, 255, 255, .06);
  --accent: #5b9ce6;
  --accent-hover: #7ab0ec;
  --accent-soft: #1c2c40;
  --accent-ink: #8db8ef;
  --good-text: #5ecb72;   --good-soft: #14301c;
  --warn-text: #e3b341;   --warn-soft: #33290f;
  --serious-text: #ec9a76; --serious-soft: #38200f;
  --crit-text: #ef7070;   --crit-soft: #3a1717;
  --purple: #ab92e2;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 1px 3px rgba(0, 0, 0, .5);
  --shadow-lift: 0 4px 12px rgba(0, 0, 0, .5);
}

/* High-contrast accessibility override (moved from the tracker sheet 2026-08-27, now expressed
   on canonical names so BOTH apps honour it). */
@media (prefers-contrast: more) {
  :root {
    --ink-2: #55554f;
    --muted: #55554f;
    --hairline: #b9b6ad;
    --border-strong: #8d8a80;
  }
}
