/* ==========================================================================
   DESIGN TOKENS
   Single source of truth for colour, type, spacing, radius, shadow, motion.
   Light theme is the default; [data-theme="dark"] overrides the palette.
   ========================================================================== */

:root {
  /* ---- Typography scale ------------------------------------------------ */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;

  --text-xs: 0.75rem;    /* 12px — meta, table captions */
  --text-sm: 0.8125rem;  /* 13px — labels, badges */
  --text-base: 0.875rem; /* 14px — body, table cells */
  --text-nav: 0.9375rem; /* 15px — navigation items (spec) */
  --text-md: 1rem;       /* 16px — emphasised body */
  --text-lg: 1.25rem;    /* 20px — brand mark, card titles (spec) */
  --text-xl: 1.5rem;     /* 24px — page titles */
  --text-2xl: 1.875rem;  /* 30px — KPI values */
  --text-3xl: 2.25rem;   /* 36px — hero numerals */

  --weight-regular: 400;
  --weight-medium: 500;  /* navigation */
  --weight-semibold: 600; /* buttons, brand */
  --weight-bold: 700;    /* headings */

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

  /* ---- Spacing system (4px base) --------------------------------------- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-9: 36px;  /* nav item gap (spec) */
  --space-10: 40px; /* header horizontal padding (spec) */
  --space-12: 48px;
  --space-16: 64px;

  /* ---- Radius ----------------------------------------------------------- */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-card: 16px; /* spec: rounded cards */
  --radius-pill: 999px;

  /* ---- Layout ----------------------------------------------------------- */
  --header-height: 76px;
  --container-width: 1320px;
  --header-blur: 12px;
  --sidebar-width: 296px;
  --sidebar-collapsed-width: 72px;

  /* ---- Motion ----------------------------------------------------------- */
  --duration-fast: 150ms;
  --duration-hover: 250ms;
  --duration-theme: 300ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);

  /* ---- Z-index ---------------------------------------------------------- */
  --z-header: 100;
  --z-dropdown: 200;
  --z-drawer: 300;
  --z-modal: 350;
  --z-toast: 400;

  /* ======================= LIGHT THEME PALETTE ========================== */
  --bg: #ffffff;
  --bg-subtle: #f9fafb;
  --bg-elevated: #ffffff;
  --header-bg: rgba(255, 255, 255, 0.8);

  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-tertiary: #9ca3af;
  --text-inverse: #ffffff;

  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --hover: #f3f4f6;

  --btn-primary-bg: #111827;
  --btn-primary-text: #ffffff;
  --btn-primary-hover: #1f2937;

  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.1);

  --success: #059669;
  --success-soft: rgba(5, 150, 105, 0.1);
  --warning: #d97706;
  --warning-soft: rgba(217, 119, 6, 0.1);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.1);
  --info: #0891b2;
  --info-soft: rgba(8, 145, 178, 0.1);

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-card: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.12);

  /* Chart series — colour-blind safe, distinct in both themes */
  --chart-1: #2563eb;
  --chart-2: #059669;
  --chart-3: #d97706;
  --chart-4: #dc2626;
  --chart-5: #7c3aed;
  --chart-grid: #e5e7eb;
}

/* ========================== DARK THEME PALETTE =========================== */
[data-theme="dark"] {
  --bg: #0b1220;
  --bg-subtle: #111a2e;
  --bg-elevated: #131d33;
  --header-bg: rgba(11, 18, 32, 0.8);

  --text-primary: #f9fafb;
  --text-secondary: #9ca3af;
  --text-tertiary: #6b7280;
  --text-inverse: #ffffff;

  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --hover: rgba(255, 255, 255, 0.06);

  --btn-primary-bg: #3b82f6;
  --btn-primary-text: #ffffff;
  --btn-primary-hover: #2563eb;

  --accent: #60a5fa;
  --accent-soft: rgba(96, 165, 250, 0.14);

  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.14);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.14);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.14);
  --info: #22d3ee;
  --info-soft: rgba(34, 211, 238, 0.14);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.5);

  --chart-1: #60a5fa;
  --chart-2: #34d399;
  --chart-3: #fbbf24;
  --chart-4: #f87171;
  --chart-5: #a78bfa;
  --chart-grid: rgba(255, 255, 255, 0.08);
}
