/* ChemTrust design system: the Green Trust "deep green" palette (chosen by
 * the owner on 2026-11-09, replacing the Storm / Cyan one).
 *
 *   #051F20  green-950  page text, the dark-mode floor
 *   #0B2B26  green-900  shell chrome (sidebar, top bar, tab bar)
 *   #163832  green-800  primary action (light), dark surfaces
 *   #235347  green-700  links / accents on light, dark glass
 *   #8EB69B  sage       highlight, "you are here", dark primary action
 *   #DAF1DE  mint       light ground, text on dark
 *   Ground: a vertical mint -> deep green gradient, as in the palette card.
 *
 * The token NAMES below are structural and older than this palette:
 * "storm" = the deep green ink/chrome family, "cyan" = the sage highlight
 * family. Every rule reads the names, so the palette lives only here and in
 * dark.css. Status colours (red / amber / green for hazards, errors and
 * success) stay semantic, the one deliberate exception.
 *
 * Contrast (WCAG 2.x, computed): green-900 on white 15.1 · green-800 12.8 ·
 * green-700 8.8 · sage on white only 2.25 and mint 1.19, so in LIGHT mode sage
 * and mint are fills and washes, never text or thin lines on white. On dark:
 * mint on green-800 10.7, sage on green-900 6.7.
 *
 * Glass follows the EUDR phone recipe: a translucent tint + a top "lit"
 * gradient + a hairline inner edge + a soft shadow over a FIXED gradient
 * ground. No live backdrop-filter on panels (it traps position:fixed popups);
 * only the modal scrim blurs.
 *
 * Legacy variable names (--primary-color, --card-bg, ...) stay as aliases.
 */

:root {
  /* ── Palette ── */
  --brand-white: #ffffff;
  --brand-storm: #0b2b26;
  --brand-cyan: #8eb69b;
  --storm-rgb: 11 43 38;
  --cyan-rgb: 142 182 155;

  /* Deep-green (900) tints over white (percent = share of green). On-white contrast in
     brackets: 88 (10.6) · 78 (7.4) · 72 (6.2) · 64 (5.1) · 56 (4.2). */
  --storm-88: #284440;
  --storm-78: #415a56;
  --storm-72: #4f6663;
  --storm-64: #5e7370;
  --storm-56: #6d807d;
  --storm-40: #9daaa8;
  --storm-25: #c2cac9;
  --storm-14: #dde3e0;
  --storm-08: #eaf0ec;
  --storm-05: #f1f6f2;
  --storm-03: #f7faf7;
  /* green-950 and darker: the bottom of the dark ground. */
  --storm-deep: #051f20;
  --storm-deeper: #031617;
  /* green-800 / 700: raised dark surfaces. */
  --storm-lift: #163832;
  --storm-lift-2: #1f403a;
  --storm-lift-3: #235347;

  /* Sage tints over white; cyan-deep / cyan-ink = green-700 (8.8:1 on white). */
  --cyan-75: #aac8b4;
  --cyan-50: #c6dacd;
  --cyan-25: #dde9e1;
  --cyan-12: #e8f0eb;
  --cyan-06: #f4f9f5;
  --cyan-deep: #235347;   /* 55% cyan over storm: 3.6:1 on white (non-text, large text) */
  --cyan-ink: #235347;    /* 40% cyan over storm: 5.3:1 on white (body text, links) */

  /* ── Ground (the page background) ──
     Light: a pale storm-to-white wash with the cyan glow in the two corners
     the brand gradient uses (top-right, bottom-left). Dark mode (dark.css)
     paints the full brand gradient. Painted by a fixed body::before layer
     (layout.css), so it never scrolls and never repaints. */
  --ground: #e6f4e9;
  --ground-art:
    radial-gradient(90% 60% at 100% 0%, rgb(var(--cyan-rgb) / 0.22), transparent 62%),
    radial-gradient(80% 50% at 0% 100%, rgb(35 83 71 / 0.10), transparent 60%),
    linear-gradient(180deg, #f4fbf5 0%, #e9f6ec 55%, #daf1de 100%);

  /* ── Glass ── */
  --glass: rgb(255 255 255 / 0.82);
  --glass-lit: linear-gradient(180deg, rgb(255 255 255 / 0.55), rgb(255 255 255 / 0) 42%);
  --glass-strong: #ffffff;               /* sheets, dialogs, menus: solid */
  --glass-edge: rgb(var(--storm-rgb) / 0.09);
  --glass-shadow: 0 1px 2px rgb(var(--storm-rgb) / 0.05), 0 10px 28px rgb(var(--storm-rgb) / 0.07);
  --scrim: rgb(var(--storm-rgb) / 0.45);

  /* Old names for the ground, kept for existing rules. */
  --canvas: var(--ground);
  --canvas-art: var(--ground-art);

  /* Text painted directly on the ground (page titles, filter labels, the
     back link) rather than inside a card. Flips with the ground (dark.css). */
  --canvas-text: var(--brand-storm);
  --canvas-text-muted: var(--storm-72);
  --canvas-text-subtle: var(--storm-64);

  /* ── Surfaces ── */
  --bg: var(--ground);
  --surface: #ffffff;
  --surface-2: var(--storm-03);   /* table heads, insets, hover */
  --surface-3: var(--storm-05);
  --surface-raised: #ffffff;      /* menus, dropdowns, popovers: always opaque */
  --border: var(--storm-14);
  --border-strong: var(--storm-25);

  /* ── The page card (EUDR .admin-content-card + .assess-header) ──
     Every list and record screen is one large card filling the content area
     (layout.css .ct-page-card). Its head: a round green badge, the title over
     an accent rule, the screen's main action. Inside it, glass panels go
     flat (--page-panel) and tables carry a solid head band. */
  --page-card: var(--surface);
  --page-card-edge: var(--border);
  --page-card-shadow: var(--shadow-md);
  --page-panel: var(--surface);
  --page-rule: var(--cyan-deep);
  --page-badge: linear-gradient(135deg, var(--storm-lift-3) 0%, var(--brand-storm) 100%);
  --page-badge-ink: var(--chrome-ink);
  --table-head: var(--storm-08);
  --table-head-ink: var(--brand-storm);
  --table-head-edge: var(--storm-25);
  --field-soft: var(--storm-05);         /* toolbar search and filters */

  /* ── Text ── */
  --text: #051f20;
  --text-muted: var(--storm-72);
  --text-subtle: var(--storm-64);
  --text-invert: #ffffff;

  /* ── Brand roles ── */
  --primary: var(--brand-storm);        /* titles, icons, strong UI ink */
  --primary-hover: var(--storm-88);
  --primary-soft: var(--cyan-12);       /* selected rows, soft brand wash */
  --accent: var(--cyan-deep);           /* accents that must be visible on white */
  --accent-light: var(--cyan-50);
  --link: var(--cyan-ink);
  --link-hover: var(--brand-storm);
  --focus: var(--cyan-deep);
  --focus-ring: 0 0 0 3px rgb(var(--cyan-rgb) / 0.45);
  --highlight: var(--brand-cyan);       /* active indicators, progress fills, dots */
  --highlight-ink: var(--brand-storm);  /* text drawn on a --highlight fill */

  /* ── Actions ──
     Primary: solid green-800 with mint ink in light mode; dark mode flips it
     to a glowing sage fill with deep-green ink (dark.css). Secondary: glass. */
  --action: #163832;
  --action-ink: #f4fbf5;
  --action-hover: #235347;
  --action-glow: 0 1px 2px rgb(var(--storm-rgb) / 0.12), 0 6px 16px rgb(var(--storm-rgb) / 0.14);
  --action-2: #ffffff;
  --action-2-ink: var(--brand-storm);
  --action-2-edge: var(--storm-25);
  --action-2-hover: #e8f0eb;
  --danger-hover-bg: #fbedeb;

  /* ── Shell chrome: sidebar, top bar, phone tab bar ──
     Solid green-900 in BOTH themes, as EUDR keeps its bars solid; mint ink,
     sage marks where you are. --chrome-dim is OPAQUE on purpose:
     translucent strokes double up where icon lines cross. */
  --chrome-bg: var(--brand-storm);
  --chrome-bg-2: var(--storm-lift);       /* fields and hovers inside the chrome */
  --chrome-line: rgb(218 241 222 / 0.08);
  --chrome-ink: #daf1de;
  --chrome-sec: rgb(218 241 222 / 0.74);
  --chrome-dim: #7d988b;
  --chrome-hover: rgb(218 241 222 / 0.06);
  --chrome-active: rgb(var(--cyan-rgb) / 0.16);
  --chrome-active-ink: var(--brand-cyan);

  --header-bg: var(--chrome-bg);
  --header-text: var(--storm-14);

  --sidebar-width: clamp(200px, 3.13vw + 160px, 260px);
  --sidebar-collapsed-width: 60px;
  --sidebar-bg: var(--chrome-bg);
  --sidebar-border: var(--chrome-line);
  --sidebar-hover: var(--chrome-hover);
  --sidebar-active: var(--chrome-active);
  --sidebar-active-border: var(--chrome-active-ink);
  --sidebar-text: var(--chrome-sec);
  --sidebar-text-active: var(--chrome-ink);
  --topbar-bg: var(--chrome-bg);

  /* ── Regulatory status signals (the semantic exception) ──
     hazard = red, attention = amber, unknown = storm slate, clear = green.
     Muted so a table of chips reads as a list, not a warning light.
     On-white contrast: confirmed 5.6 · potential 4.7 · indeterminate 6.0 · clear 5.3 */
  --confirmed: #b0443a;      --confirmed-tint: #fbedeb;   --confirmed-edge: #efcdc8;
  --potential: #9a6b00;      --potential-tint: #fbf3df;   --potential-edge: #ebd8a8;
  --indeterminate: #4f676d;  --indeterminate-tint: #eef2f3; --indeterminate-edge: #d3dcde;
  --clear: #1f7a4d;          --clear-tint: #e6f4ec;       --clear-edge: #badfcb;
  --neutral-status: #5f7177; --neutral-tint: #eef1f2;
  --on-status: #ffffff;      /* text on a solid status fill (toasts) */

  /* Legacy semantic aliases */
  --danger: var(--confirmed);
  --warning: var(--potential);
  --ok: var(--clear);

  /* ── Typography: the EUDR house stack. "Nunito" is Nunito for Latin and
        M PLUS Rounded 1c for Greek under the one family name (fonts.css,
        self-hosted), then the system ramp. ── */
  --font-sans: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  --font-body: var(--font-sans);
  --font-display: var(--font-sans);

  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.9375rem;
  --text-md: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.75rem;

  /* ── Spacing ── */
  --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
  --space-5: 24px; --space-6: 32px; --space-7: 48px; --space-8: 64px;

  /* ── Radii ── */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-pill: 999px;
  --radius-glass: 14px;

  /* Fluid radii + house transition (EUDR operator-react.css:25-34). */
  --radius-fluid: clamp(12px, 0.42vw + 6.6px, 18px);
  --radius-fluid-sm: clamp(8px, 0.21vw + 5.3px, 12px);
  --radius-fluid-xs: clamp(5px, 0.16vw + 3px, 8px);
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);

  /* ── Elevation (storm-based in light mode, black-based in dark) ── */
  --shadow-sm: 0 1px 2px rgb(var(--storm-rgb) / 0.05), 0 1px 3px rgb(var(--storm-rgb) / 0.06);
  --shadow-md: 0 1px 3px rgb(var(--storm-rgb) / 0.06), 0 8px 20px rgb(var(--storm-rgb) / 0.07);
  --shadow-lg: 0 14px 36px rgb(var(--storm-rgb) / 0.14);

  /* Legacy aliases (untouched rules keep working) */
  --bg-color: var(--bg);
  --card-bg: var(--surface);
  --border-color: var(--border);
  --text-color: var(--text);
  --muted-color: var(--text-muted);
  --primary-color: var(--primary);
  --secondary-color: var(--accent);
}

* {
  box-sizing: border-box;
}

/* Fluid root font-size (EUDR style.css:45-49): the rem-based UI scales
   13.74px @1366 → 14.05px @1440 → 16.06px @1920 → 18px @2560 (ceiling).
   Phones (≤768px) are excluded so inputs keep the 16px anchor that prevents
   iOS focus-zoom. */
@media (min-width: 769px) {
  html {
    font-size: clamp(13px, 0.42vw + 8px, 18px);
  }
}

html {
  /* The ground's base colour shows during overscroll and under the iOS
     status bar; it must match the ground, not default white. */
  background: var(--ground);
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4 {
  line-height: 1.2;
  letter-spacing: -0.012em;
  color: var(--text);
}

a {
  color: var(--link);
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}
a:hover {
  color: var(--link-hover);
}

/* Technical identifiers (CAS, EC, H-codes, request IDs, UUIDs) read as data. */
.ct-mono,
code {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.92em;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

::selection {
  background: rgb(var(--cyan-rgb) / 0.35);
  color: var(--text);
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
