/* brand-tokens.css — the one token set the console and the sign-in funnel share: the accent, the type
 * stack, the brand radii and both themes' text tokens. Not every colour in the console — `css/postlogin.css`
 * keeps its own frozen budget of literals (the ratchet at the bottom of `tests/brand-tokens.test.mjs`) —
 * but the set that must never fork again.
 *
 * Why this file exists. Until 2026-10-15 the palette was declared twice: once in `css/app.css`
 * (the signed-out funnel) and again under a second naming scheme in `css/postlogin.css` (the
 * console), with the accent written out a third time. Two declarations of one palette is the
 * mechanism by which the sign-in funnel and the console drift apart, and the rebrand of
 * 2026-09-29 settled that they must not:
 *
 *   "The green accent. The direction proposed blue for the arrow and the active step; the
 *    console, the marketing site and the docs share green, and a second accent would fork the
 *    product's identity."        — docs/design/REBRAND-2026-09-29.md
 *
 * So the accent below is the landing's own (`css/landing.css` `.npl`), byte for byte, and the
 * console consumes it instead of carrying its own green. `tests/brand-tokens.test.mjs` fails if either
 * console sheet (`css/app.css`, `css/postlogin.css`) writes a house accent literal of its own, and
 * fails if the contrast the two usages need ever stops holding. The scope of that claim is stated
 * there too: `css/landing.css` still writes the accent out, because that is the house's own source.
 *
 * Loaded before `css/app.css` in index.html, so every later sheet — including `css/postlogin.css`,
 * which app.js appends on demand — resolves these names.
 */

:root {
  /* ---- The house accent -------------------------------------------------
     Copied from the landing's own token block (css/landing.css `.npl`), which stays the house's source
     of truth for it. What this file exists to stop is narrower than "one literal": the console sheets
     (css/app.css, css/postlogin.css) writing out an accent of their own, which is how the funnel and
     the console forked. tests/brand-tokens.test.mjs holds that line. */
  --nx-accent: #0f9d63;
  --nx-accent-ink: #086b43;
  --nx-accent-soft: rgba(15, 157, 99, 0.1);

  /* ---- Type: house stack, Inter first ----------------------------------
     The console used to write the OS stack first with Inter as the last resort, so Inter — which
     css/fonts.css does load — never won. The CJK tail is the landing's `--nx-cjk` moved inline so
     this file does not restate a token the landing already owns. */
  --nx-font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Noto Sans TC",
    "PingFang TC", "Hiragino Sans TC", "Microsoft JhengHei", sans-serif;

  /* ---- Brand radii ------------------------------------------------------ */
  --nx-r-sm: 10px;
  --nx-r-md: 14px;
  --nx-r-lg: 16px;
  --nx-r-xl: 22px;
  --nx-focus-ring: rgba(109, 164, 142, 0.75);

  /* ---- The console surface, declared once -------------------------------
     Warm ink-on-paper, deliberately not the landing's cooler `#f6f7f9`: the console is a work
     surface and the funnel is the marketing surface. The accent is the shared part, not the canvas. */
  --canvas: #f4f3ef;
  --surface: #ffffff;
  --surface-subtle: #f8f8f5;
  --ink: #19211e;
  --ink-muted: #69736e;
  --border-subtle: #e1e5e1;

  /* ---- Console chrome and the rail mark, added 2026-10-21 ----------------
     The console refinement keeps the dashboard's forest/warm-paper pairing and adds
     no new accent. These members are the chrome around it — sidebar, hairlines,
     the metallic rail in the mark, and the quiet separators in the topbar. They
     live here so `css/postlogin.css` does not grow a second literal palette. */
  --nx-sidebar: #111d19;
  --nx-sidebar-deep: #0c1512;
  --nx-hairline-warm: #e6e5df;
  --nx-on-dark: #f4f7f5;
  --nx-on-dark-strong: #edf2ef;
  --nx-separator: #c9cfca;
  /* The rail-N is the one metallic object in the system. Four stops per ground,
     because a chrome line that reads as chrome on forest goes flat on silver. */
  --nx-chrome-hi: #f7faf8;
  --nx-chrome-mid: #a6b3ac;
  --nx-chrome-lo: #eef3ef;
  --nx-chrome-dark-hi: #101712;
  --nx-chrome-dark-mid: #48574f;
  --nx-chrome-dark-lo: #1a2620;
  /* The refined shell's translucent layers. Kept here for the same reason as the
     opaque members above: one file owns every colour the console draws. */
  --nx-sidebar-glow: rgba(15, 157, 99, 0.1);
  --nx-sidebar-border: rgba(255, 255, 255, 0.06);
  --nx-sidebar-border-strong: rgba(255, 255, 255, 0.1);
  --nx-sidebar-input: rgba(255, 255, 255, 0.045);
  --nx-sidebar-hover: rgba(255, 255, 255, 0.06);
  --nx-sidebar-active: rgba(255, 255, 255, 0.075);
  --nx-sidebar-mark: rgba(255, 255, 255, 0.13);
  --nx-sidebar-rule: rgba(255, 255, 255, 0.28);
  --nx-on-dark-46: rgba(244, 247, 245, 0.46);
  --nx-on-dark-56: rgba(244, 247, 245, 0.56);
  --nx-on-dark-68: rgba(244, 247, 245, 0.68);
  --nx-avatar-ring: rgba(0, 0, 0, 0.08);
  /* A neutral highlight for the dashboard hero. Green is an event, not a texture,
     so the hero's depth comes from ink on paper rather than a second accent wash. */
  --nx-hero-wash: rgba(25, 33, 30, 0.035);

  /* The accent under the console's own names. `--accent-deep` was declared in app.css and used
     nowhere; it is dropped rather than carried forward. `--console-green` used to be a second,
     darker green; it is now the house ink, which is the member of the family that still clears AA
     in both of the roles it is asked to play (text on a soft tint, and white text on a fill). */
  /* Only the member the console actually consumes: --console-green is used as both text on a tint
     and a fill behind white text, and that is the ink. An unused --accent/--accent-soft pair would
     be the same defect as the --accent-deep this file deletes. */
  --accent-ink: var(--nx-accent-ink);

  /* The fill the console's primary darkens to on hover. It was a literal in `css/postlogin.css`,
     where the shell cannot hold one: `.btn-primary` reads `--cta`, and `--cta` is re-pointed inside
     `.shell` to `--console-green`, so app.css's own hover (`#f2f2f2`, the funnel's way of lightening
     a white pill on a dark ground) would leave white text on a near-white fill. One declaration,
     read by both the ops primary and the shell's. */
  --accent-ink-hover: #17483c;

  /* Amber and blue, moved down to the ink their tints need. The measured worst case is the tint the
     colour is drawn on, not the canvas: #a87838 on --review-amber-soft was 3.31:1 and #55718a on
     --info-blue-soft 4.44:1 — both under the 4.5:1 ordinary text needs, at the 10px/700 the console
     actually sets these status labels in (measured 2026-10-15, per screen, in the review's sweep).
     #8a531f is 5.37:1 there and 5.67:1 on the canvas; #456077 is 5.72:1 on its tint. */
  --review-amber: #8a531f;
  --review-amber-soft: #f5ecdd;
  --info-blue: #456077;
  --info-blue-soft: #eaf0f4;

  /* Mode A risk states. The alert tint and its border are deliberately quieter than the
     review amber above: a high flag must be legible without turning the case screen into an
     alarm panel. The ink pairs are measured against their own tint, not the canvas. */
  --console-risk-high-border: #d9aaa6;
  --console-risk-high-soft: #fbebe9;
  --console-risk-high-ink: #8a2722;
  --console-risk-high-accent: #a83b34;
  --console-warning-border: #e5c998;
  --console-warning-ink: #825b1f;
  --console-warning-ink-strong: #6f4a12;

  /* ---- The two roles the funnel's dark theme cannot lend -----------------
     `--link` and `--warn` are declared for the signed-out funnel, whose shell is `--bg` #010d19.
     Reused unmodified on the console's warm canvas they fail: #3d8bff is 2.99:1 on #f4f3ef and
     #e8a85e is 1.86:1, against the 4.5:1 ordinary text needs. This cannot be fixed by choosing
     better values for the shared names, and that is arithmetic rather than taste: to clear AA on
     #f4f3ef a colour needs a relative luminance of 0.1602 or less, and to clear it on #010d19 it
     needs 0.1914 or more, so no single value serves both themes. The console therefore gets its own
     member for the link role — the same idea as --accent-ink above — and maps `--warn` to the review
     amber rather than declaring a third amber. `css/postlogin.css` does the mapping, inside `.shell`
     only. Of the dark regions this comment used to name as "staying dark", only `#modal-root` is
     genuinely outside that scope: the sidebar and the activate hero both live INSIDE `.shell` and
     inherit its light-ground members, so a repair scoped to `.shell` is a repair of the light ground,
     not of "everything except the funnel" — the hero's `.act-task .done` is the one that draws one,
     and `css/postlogin.css` re-points it there (`.shell .act-hero`). */
  --link-ink: #0b57b0;

  /* ---- The status, primary and badge roles the shell draws itself ---------
     D-005 gave the console its own link ink because no single value clears AA on both grounds. The
     same is true of three more roles the funnel supplies out of its dark theme, and `.shell` maps
     each to a console member rather than to a new value. Every ratio below is a measured pair, not
     arithmetic: `docs/audit/console-review-2026-10/d002/q2-tokens-probe.mjs` flips the screens that
     draw these roles into the shell in a copy of the tree and walks them with the real sweep, and
     the shipped screens' pairs come out of `/tmp/Q2`'s sweep JSON.

       status   `--ok`   #2ee59d: 1.48:1 on --canvas, 1.64:1 on --surface   → --console-green
       primary  `--cta`  #ffffff: 1.11:1 against --canvas, i.e. an invisible
                         white pill (its #0a0a0a ink is 19.8:1 ON it, which
                         is why no failing text pair ever showed)           → --console-green
       badge    `.ai-label`  #8ab8ff on rgba(61,139,255,.16): no shell-scoped
                         equivalent at all; the screens that write it also
                         write `.muted-badge`, which wins, so the pill as drawn
                         was #5f6a64 on a white 8% tint (5.63:1)             → --console-blue

     --console-green is the member of the accent family that clears both roles it is asked to play
     there: #ffffff on #086b43 is 6.57:1 and #086b43 on #f4f3ef is 5.92:1 (and 5.65:1 on its own
     `--console-green-soft` tint, the pair `.badge.ok` already draws, measured on `approvalDetail`
     and `mcp`). --console-blue on --console-blue-soft is the 5.72:1 pair `.status-badge.status-neutral`
     already uses — measured on `home`.

     One role had no console member at all: the form error. `--danger` #ff465c is 3.34:1 on
     --surface, under AA at the 12px `css/app.css` sets `.error-text` in, and the console carries no
     darker red to map to. --danger-ink is that member: #c62828 is 5.62:1 on --surface, 5.28:1 on
     --surface-subtle and 5.06:1 on --canvas, and it is the same red the country flag already fills
     with (`css/app.css` `.flag`), so the console's red does not fork either.

     `css/postlogin.css` does the mapping, inside `.shell` only — same rule as `--link` and `--warn`
     above. A region that stays dark INSIDE that scope does not keep the funnel's members by itself:
     the activate hero (`.act-hero`, a navy gradient) inherits `--ok` and drew its completed-task
     label in --console-green, 2.10:1 / 2.52:1 / 2.71:1 against the gradient's three stops, so
     `css/postlogin.css` re-points `--ok` back to `--ok-dark` on `.shell .act-hero` — the funnel's
     own status member, 8.44 / 10.09 / 10.86 there. The sidebar inherits too and draws none of these
     roles today; the sign-in funnel and `#modal-root` are outside `.shell` altogether. */
  --danger-ink: #c62828;
  --nx-shadow: 0 12px 30px rgba(24, 34, 29, 0.08);
  --radius-control: var(--nx-r-sm);
  --radius-panel: var(--nx-r-md);
  --font: var(--nx-font);

  /* ---- The signed-out funnel's dark shell -------------------------------
     Its own theme, but still declared in one place so a fix to either side is made once. Five tokens
     that came across from app.css are deliberately absent: --bg-deep, --glow-blue, --cta-disabled-fg,
     --side-bg and --error-red are referenced by nothing in the live tree (measured with
     `grep -rn "var(--name[,)]"` over css/, js/ and the documents), so carrying them forward would be
     the same dead weight this file removes. tests/brand-tokens.test.mjs now enforces that. */
  --bg: #010d19;
  --input: #1a1c1e;
  --input-2: #26282a;
  /* The ink a DARK ground draws, named for the same reason --ok-dark below is: `.shell` re-points
     `--text` to --console-ink for the light workspace, and that is a scope, not a ground. The activate
     hero — a navy gradient inside the scope — inherits it, and `.act-left h1` declares no colour of its
     own (`css/postlogin.css:303`), so the screen's own title drew #19211e on #121f33..#1a2d4a:
     **1.00-1.17:1** over the pixels under it, a dark ghost on dark navy, and invisible to the sweep
     because a gradient leaves no opaque layer for the walk to measure (D-007, `hero-probe.mjs`).
     `--text` IS this member (one literal, not two), exactly as `--ok` is --ok-dark; the name is what
     the hero's own re-point reads. */
  --text-dark: #ffffff;
  --text: var(--text-dark);
  --muted: #8b959e;
  /* The second muted ink sat at 3.39:1 on --card and 3.55:1 on --input — under AA, measured on the `fx`
     and `kycDocument` screens (D-005); --input-2 carries the same ink at 3.07:1, though no rendered node
     in the 2026-10-15 sweep sat on it. #9aa4ad is 6.44:1, 6.74:1 and 5.84:1 there.

     One consequence is appearance, not ratio, and is stated rather than hidden: #9aa4ad is LIGHTER than
     --muted #8b959e, so the "second" muted ink now reads brighter than the first on a dark ground. The
     independent review flagged the inversion. Both clear AA wherever they are drawn, it is a design-intent
     call rather than a defect, and the value is left exactly as reviewed instead of re-tuned behind the
     review's back. */
  --muted2: #9aa4ad;
  --link: #3d8bff;
  --cta: #ffffff;
  --cta-text: #0a0a0a;
  --cta-disabled-bg: #3a3d40;
  --warn: #e8a85e;
  /* The status ink as a DARK ground draws it, named so a dark region that lives inside `.shell` can
     re-point `--ok` back to it: `.shell` maps `--ok` to --console-green for the light workspace, and
     the activate hero — a navy gradient inside that scope — draws `.act-task .done` in it. `--ok` IS
     this member (one literal, not two); the name is what the re-point reads. */
  --ok-dark: #2ee59d;
  --ok: var(--ok-dark);
  --danger: #ff465c;
  --side-active: #b8d4ff;
  --card: #152033;
  --line: rgba(255, 255, 255, 0.08);
}

/* ---- Console appearance: the dark ground (SET-06) ----------------------
   One palette, declared beside the light tokens. `js/app.js` writes the resolved
   preference into `data-theme`; System resolves the same way. Consuming sheets
   reference these members rather than re-declaring a hex literal. */
html[data-theme="dark"] {
  --canvas: #0b1220;
  --surface: #111a2b;
  --surface-subtle: #16223a;
  --ink: #eef2f7;
  --border-subtle: #2a3650;
  --accent-ink: #8fd3b4;
  --link-ink: #9cc4ff;
  --review-amber: #f3c46b;
  --review-amber-soft: #3a2f16;
  --info-blue: #9cc4ff;
  --info-blue-soft: #162a44;
  --console-risk-high-border: #8f544f;
  --console-risk-high-soft: #2b1918;
  --console-risk-high-ink: #ffb7b1;
  --console-risk-high-accent: #f08b81;
  --console-warning-border: #7b5c2d;
  --console-warning-ink: #f3c46b;
  --console-warning-ink-strong: #ffd99a;
  --nx-shadow: 0 1px 2px rgba(0, 0, 0, 0.45), 0 8px 24px rgba(0, 0, 0, 0.32);
  --console-muted-dark: #a8b3c2;
  --console-green-soft-dark: #1d3a2c;
  --input-dark: #0f1727;
  --input-2-dark: #16223a;
}
