/* Design tokens (plan 4.4). The ONLY place a colour literal may appear
   (hygiene rule css.hex-literal-outside-tokens). Two layers:

   1. Semantic tokens — the :root block moved verbatim from base.css. Use these first.
   2. Palette tokens — raw colours the stylesheets already use (Tailwind names where the
      value is a Tailwind colour, else --palette-c-<hex>). They exist so every literal has
      a name and one home; mapping them onto the semantic layer (7 greens → --success, …)
      is a design decision that changes pixels and is owned by the product owner.

   Loaded first by _CoreCss.cshtml. */

/* =============================================================================
   Base Styles - CSS Variables, Reset, Typography, Layout Shell
   ============================================================================= */

:root {
  color-scheme: dark;

  /* ===== Z-INDEX SCALE =====
   * 1-10     : Component-internal layers (chart overlays, badges)
   * 100-300  : Drawing tools, chart interactions
   * 900-1100 : Panels (chat, watchlist, sidebars)
   * 1000     : Modals (base)
   * 2000-3000: Full-screen overlays (cook mode, AI studio panels)
   * 9998-10060: Popovers, tooltips, dropdowns (document.body)
   * ========================= */

  /* Colors */
  --bg: #04050b;
  --bg-elevated: #0a0c16;
  --card: #0c0f1c;
  --border: rgba(60, 194, 255, 0.3);
  --text: #f5f7ff;
  /* WCAG AA on dark backgrounds (#04050b–#1a1a2e). Bumped from #94a3b8 (slate-400)
     to #cbd5e1 (slate-300) in #594 to clear axe color-contrast on /graphs,
     /dashboard tab labels, /signal-studio sidebar, and /Settings hint text. */
  --text-dim: #cbd5e1;
  --accent: #3cc2ff;
  --accent-hot: #ff4fd8;
  --accent-primary: #8b5cf6;  /* Purple - AI features */
  --accent-secondary: #3b82f6;  /* Blue - secondary accents */
  --primary: var(--accent);            /* maps to #3cc2ff */
  --primary-hover: #2fb3e6;
  --primary-rgb: 60, 194, 255;
  --success: #60f7a8;
  --warning: #facc15;
  --danger: #ef4444;
  /* WCAG AA on dark backgrounds — bumped #594 from #94a3b8 → #cbd5e1.
     Also defines --text-muted globally so components that fell back to #64748b
     (slate-500, fails 4.5:1 against --card) inherit a compliant value.
     PR #618 deferred fix: alias to --text-dim — three names, one canonical
     value. Future re-tunes (e.g. WCAG bump) only need to update one var. */
  --text-secondary: var(--text-dim);
  --text-muted: var(--text-dim);
  --card-bg: #1a1a2e;
  /* Aliases for names that pages/widgets already reference (review finding on the 2026-09
     stack: 55 var() uses fell through to their inline fallback or to `initial`). They point
     at the canonical token so a theme override of the canonical one carries through. */
  --text-primary: var(--text);
  --text-tertiary: var(--text-dim);
  /* `--muted` is the fourth spelling of this value and the only one that was never
     aliased. signal-studio.css defines it on its own container and uses it 55 times, so it
     resolved THERE and nowhere else — dashboard-toolbar.css (.period-picker-btn, its label)
     and components/signal-picker.css (loading / empty / error) referenced a token defined by
     an unrelated page. An unresolvable var() is not an error: the declaration dies at
     computed-value time and falls back to inheritance, so those three surfaces rendered at
     FULL BODY BRIGHTNESS while reading as a deliberate choice. Measured before the alias:
     rgb(245,247,255) on all three, against --text-dim's rgb(203,213,225). */
  --muted: var(--text-dim);
  /* Same story as --muted, same two innocent files. signal-studio.css defines
     `--foreground: var(--text, …)` and `--background: var(--bg, …)` on its own container, so
     the canonical mapping is written in the code rather than chosen here — and
     dashboard-toolbar.css and signal-picker.css referenced them from outside that container.
     --background is used for `background:`, so unresolved it computed to `initial`:
     MEASURED rgba(0, 0, 0, 0). A dropdown panel and the period picker have been fully
     TRANSPARENT, with whatever is behind them showing through. */
  --background: var(--bg);
  --foreground: var(--text);
  --bg-secondary: var(--bg-elevated);
  --bg-tertiary: var(--card);
  --bg-card: var(--card-bg);

  /* AI Rating Colors */
  --rating-strong-buy: #10B981;
  --rating-buy: #34D399;
  --rating-hold: #FBBF24;
  --rating-sell: #F87171;
  --rating-strong-sell: #EF4444;
  
  /* Typography */
  font-family: "Space Grotesk", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  /* The monospace stack, DEFINED HERE because eighteen places already ask for it.
     `var(--font-mono, …)` was referenced in nine files and set in none, so every one of
     them rendered its own fallback — and they did not agree:

        16x  monospace
         1x  ui-monospace, SFMono-Regular, Menlo, monospace
         1x  'SF Mono', monospace

     Generic `monospace` is Courier on most machines while `ui-monospace` is the system UI
     mono, so a tabular figure in one widget did not match the same figure in the next.
     Defining the variable fixes all eighteen without touching one of them: a fallback is
     inert once its variable resolves. The stack below is the widest of the three that were
     already in use, which is the one choice here that is not mine to invent. */
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  
  /* Spacing */
  --space-2xs: 0.125rem;
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  
  /* Border Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-full: 999px;
  
  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.35);
  --shadow-xl: var(--shadow-lg);
  --shadow-glow-accent: 0 0 20px rgba(60, 194, 255, 0.25);
  --shadow-glow-success: 0 0 20px rgba(96, 247, 168, 0.25);
  --shadow-glow-danger: 0 0 20px rgba(239, 68, 68, 0.3);
  
  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.2s ease;
  --transition-slow: 0.3s ease;
}

/* ---- palette (raw values in use; see header) ---- */
:root {
  --palette-amber-500: #f59e0b;  /* 38 uses */
  --palette-blue-200: #bfdbfe;  /* 4 uses */
  --palette-blue-300: #93c5fd;  /* 8 uses */
  --palette-blue-400: #60a5fa;  /* 18 uses */
  --palette-blue-600: #2563eb;  /* 6 uses */
  --palette-c-001425: #001425;  /* 2 uses */
  --palette-c-0f121e: #0f121e;  /* 2 uses */
  --palette-c-10a37f: #10a37f;  /* 2 uses */
  --palette-c-16162a: #16162a;  /* 5 uses */
  --palette-c-20c997: #20c997;  /* 5 uses */
  --palette-c-2d2d4a: #2d2d4a;  /* 12 uses */
  --palette-c-5dd2ff: #5dd2ff;  /* 2 uses */
  --palette-c-e74c3c: #e74c3c;  /* 4 uses */
  --palette-c-ff6b6b: #ff6b6b;  /* 4 uses */
  --palette-gray-500: #6b7280;  /* 2 uses */
  --palette-green-300: #86efac;  /* 2 uses */
  --palette-green-400: #4ade80;  /* 2 uses */
  --palette-green-500: #22c55e;  /* 91 uses */
  --palette-green-600: #16a34a;  /* 2 uses */
  --palette-indigo-500: #6366f1;  /* 2 uses */
  --palette-orange-400: #fb923c;  /* 2 uses */
  --palette-orange-500: #f97316;  /* 8 uses */
  --palette-pink-500: #ec4899;  /* 3 uses */
  --palette-purple-500: #a855f7;  /* 11 uses */
  --palette-red-300: #fca5a5;  /* 3 uses */
  --palette-red-600: #dc2626;  /* 4 uses */
  --palette-sky-500: #0ea5e9;  /* 2 uses */
  --palette-slate-100: #f1f5f9;  /* 14 uses */
  --palette-slate-200: #e2e8f0;  /* 39 uses */
  --palette-slate-400: #94a3b8;  /* 65 uses */
  --palette-slate-500: #64748b;  /* 28 uses */
  --palette-slate-600: #475569;  /* 3 uses */
  --palette-slate-700: #334155;  /* 6 uses */
  --palette-slate-800: #1e293b;  /* 6 uses */
  --palette-slate-900: #0f172a;  /* 5 uses */
  --palette-violet-400: #a78bfa;  /* 12 uses */
  --palette-yellow-500: #eab308;  /* 11 uses */
}
