/* ==========================================================================
   Design tokens — CRM (module M2)
   Light is the default; dark is tuned separately, never an inversion.
   Every colour is OKLCH. Components may only use these names — no literals.
   Proven by tests/tokens.test.mjs (contrast + completeness + no-literals).
   ========================================================================== */

:root {
  /* --- Warm linen surfaces (neutrals derived from the accent hue) --------- */
  --canvas: oklch(0.981 0.006 78);
  --surface: oklch(0.996 0.003 78);
  --surface-raised: oklch(1 0 0);
  --surface-sunken: oklch(0.955 0.008 78);
  --sidebar: oklch(0.968 0.007 80);

  --border: oklch(0.905 0.008 78);
  --border-subtle: oklch(0.94 0.006 78);
  --border-strong: oklch(0.82 0.01 78);
  --border-input: oklch(0.65 0.012 78);

  /* --- Ink --------------------------------------------------------------- */
  --ink: oklch(0.27 0.012 60);
  --ink-muted: oklch(0.475 0.012 60);
  --ink-faint: oklch(0.6 0.01 60); /* decoration only, never body text */

  /* --- One accent: calm sage/teal, interactive only ---------------------- */
  --accent: oklch(0.5 0.075 185);
  --accent-strong: oklch(0.43 0.075 185);
  --accent-ink: oklch(0.41 0.07 185);
  --accent-soft: oklch(0.945 0.022 185);
  --accent-soft-border: oklch(0.88 0.03 185);
  --on-accent: oklch(0.99 0.004 185);

  /* --- Semantic state (marks, badges, money) ----------------------------- */
  --ok: oklch(0.44 0.09 150);
  --ok-ink: oklch(0.39 0.085 150);
  --ok-soft: oklch(0.95 0.025 150);
  --ok-soft-border: oklch(0.885 0.04 150);

  --warn: oklch(0.6 0.11 75); /* mark/signature only — text uses --warn-ink */
  --warn-ink: oklch(0.44 0.1 75);
  --warn-soft: oklch(0.955 0.03 80);
  --warn-soft-border: oklch(0.89 0.05 80);

  --danger: oklch(0.54 0.14 27); /* clay */
  --danger-ink: oklch(0.44 0.15 27);
  --danger-soft: oklch(0.955 0.025 27);
  --danger-soft-border: oklch(0.89 0.04 27);

  /* --- Stages: one dot colour each, the label always carries the meaning -- */
  --stage-lead: oklch(0.68 0.012 250);
  --stage-intake-booked: oklch(0.6 0.05 245);
  --stage-documents-collected: oklch(0.56 0.06 215);
  --stage-prep: oklch(0.5 0.075 185);
  --stage-client-review: oklch(0.58 0.08 95);
  --stage-invoice-sent: oklch(0.62 0.1 70);
  --stage-invoice-paid: oklch(0.48 0.09 155);
  --stage-filed: oklch(0.4 0.07 160);

  /* --- Focus, selection, overlay ----------------------------------------- */
  --ring: oklch(0.56 0.09 185);
  --ring-offset: oklch(0.996 0.003 78);
  --selection: oklch(0.9 0.04 185);
  --overlay: oklch(0.27 0.012 60 / 0.38);

  /* --- Chart marks (M7 will read these) ---------------------------------- */
  --chart-1: oklch(0.5 0.075 185);
  --chart-2: oklch(0.62 0.09 95);
  --chart-3: oklch(0.44 0.09 150);
  --chart-4: oklch(0.54 0.14 27);
  --chart-grid: oklch(0.92 0.006 78);

  /* --- Depth: barely there ------------------------------------------------ */
  --shadow-1: 0 1px 2px oklch(0.27 0.012 60 / 0.05), 0 1px 1px oklch(0.27 0.012 60 / 0.03);
  --shadow-2: 0 2px 4px oklch(0.27 0.012 60 / 0.05), 0 8px 16px -4px oklch(0.27 0.012 60 / 0.08);
  --shadow-dialog: 0 12px 32px -8px oklch(0.27 0.012 60 / 0.22), 0 2px 6px oklch(0.27 0.012 60 / 0.08);
  --shadow-toast: 0 8px 24px -6px oklch(0.27 0.012 60 / 0.2);

  /* --- Shape -------------------------------------------------------------- */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 999px;

  /* --- Space: 4px grid, 8px rhythm --------------------------------------- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
  --space-9: 48px;
  --space-10: 64px;
  --space-11: 80px;
  --space-12: 96px;

  /* --- Type --------------------------------------------------------------- */
  --font-ui: Inter, 'Segoe UI Variable Text', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-display: Inter, 'Segoe UI Variable Display', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-num: Inter, 'Segoe UI Variable Text', 'Segoe UI', system-ui, -apple-system, sans-serif;

  --text-xs: 0.75rem; /* 12 — labels, metadata */
  --text-sm: 0.8125rem; /* 13 — table body, secondary */
  --text-base: 0.9375rem; /* 15 — body */
  --text-md: 1rem; /* 16 — emphasised body */
  --text-lg: 1.125rem; /* 18 — card titles */
  --text-xl: 1.375rem; /* 22 — page subtitle */
  --text-2xl: 1.75rem; /* 28 — stat numbers */
  --text-3xl: 2.25rem; /* 36 — hero numbers */

  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;

  --leading-tight: 1.2;
  --leading-normal: 1.5;
  --leading-relaxed: 1.6;

  --tracking-tight: -0.011em;
  --tracking-wide: 0.06em;

  /* --- Layout ------------------------------------------------------------- */
  --sidebar-w: 248px;
  --topbar-h: 64px;
  --page-max: 1280px;
  --page-pad: 32px;

  /* --- Motion ------------------------------------------------------------- */
  --dur-fast: 120ms;
  --dur: 160ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);

  /* --- Layers ------------------------------------------------------------- */
  --z-sticky: 10;
  --z-overlay: 40;
  --z-dialog: 50;
  --z-toast: 60;
}

:root[data-theme='dark'] {
  --canvas: oklch(0.215 0.008 78);
  --surface: oklch(0.255 0.009 78);
  --surface-raised: oklch(0.295 0.01 78);
  --surface-sunken: oklch(0.19 0.008 78);
  --sidebar: oklch(0.235 0.008 80);

  --border: oklch(0.335 0.01 78);
  --border-subtle: oklch(0.295 0.009 78);
  --border-strong: oklch(0.46 0.012 78);
  --border-input: oklch(0.55 0.012 78);

  --ink: oklch(0.93 0.008 78);
  --ink-muted: oklch(0.72 0.01 78);
  --ink-faint: oklch(0.58 0.01 78);

  --accent: oklch(0.8 0.07 185);
  --accent-strong: oklch(0.86 0.07 185);
  --accent-ink: oklch(0.84 0.06 185);
  --accent-soft: oklch(0.32 0.035 185);
  --accent-soft-border: oklch(0.4 0.04 185);
  --on-accent: oklch(0.18 0.02 185);

  --ok: oklch(0.78 0.1 150);
  --ok-ink: oklch(0.84 0.08 150);
  --ok-soft: oklch(0.3 0.035 150);
  --ok-soft-border: oklch(0.38 0.05 150);

  --warn: oklch(0.86 0.11 75);
  --warn-ink: oklch(0.88 0.09 80);
  --warn-soft: oklch(0.34 0.045 75);
  --warn-soft-border: oklch(0.42 0.06 75);

  --danger: oklch(0.74 0.13 27);
  --danger-ink: oklch(0.82 0.11 27);
  --danger-soft: oklch(0.32 0.05 27);
  --danger-soft-border: oklch(0.4 0.07 27);

  --stage-lead: oklch(0.8 0.012 250);
  --stage-intake-booked: oklch(0.72 0.05 245);
  --stage-documents-collected: oklch(0.68 0.06 215);
  --stage-prep: oklch(0.64 0.075 185);
  --stage-client-review: oklch(0.72 0.08 95);
  --stage-invoice-sent: oklch(0.76 0.1 70);
  --stage-invoice-paid: oklch(0.6 0.09 155);
  --stage-filed: oklch(0.52 0.07 160);

  --ring: oklch(0.7 0.09 185);
  --ring-offset: oklch(0.255 0.009 78);
  --selection: oklch(0.4 0.05 185);
  --overlay: oklch(0.14 0.01 78 / 0.62);

  --chart-1: oklch(0.72 0.08 185);
  --chart-2: oklch(0.76 0.09 95);
  --chart-3: oklch(0.7 0.1 150);
  --chart-4: oklch(0.7 0.13 27);
  --chart-grid: oklch(0.32 0.01 78);

  --shadow-1: 0 1px 2px oklch(0.14 0.01 78 / 0.4), 0 1px 1px oklch(0.14 0.01 78 / 0.3);
  --shadow-2: 0 2px 4px oklch(0.14 0.01 78 / 0.4), 0 8px 16px -4px oklch(0.14 0.01 78 / 0.5);
  --shadow-dialog: 0 12px 32px -8px oklch(0.12 0.01 78 / 0.7), 0 2px 6px oklch(0.12 0.01 78 / 0.5);
  --shadow-toast: 0 8px 24px -6px oklch(0.12 0.01 78 / 0.6);
}
