/* ==========================================================================
   Pulse Health — Design Tokens
   Single source of truth for colour, type, spacing, elevation and motion.
   ========================================================================== */

:root {
  /* ---- Brand ---------------------------------------------------------- */
  --brand-primary:       #2563EB;
  --brand-primary-hover: #1D4ED8;
  --brand-primary-active:#1E40AF;
  --brand-secondary:     #3B82F6;
  --brand-accent:        #06B6D4;

  /* Tint ladder for the primary hue (fills, hovers, rails) */
  --brand-50:  #EFF6FF;
  --brand-100: #DBEAFE;
  --brand-200: #BFDBFE;
  --brand-300: #93C5FD;
  --brand-400: #60A5FA;
  --brand-500: #3B82F6;
  --brand-600: #2563EB;
  --brand-700: #1D4ED8;
  --brand-800: #1E40AF;
  --brand-900: #1E3A8A;

  /* ---- Status (reserved meaning — never reused as a chart series) ------ */
  --success:     #10B981;
  --success-ink: #047857;
  --success-bg:  #ECFDF5;
  --warning:     #F59E0B;
  --warning-ink: #B45309;
  --warning-bg:  #FFFBEB;
  --danger:      #EF4444;
  --danger-ink:  #B91C1C;
  --danger-bg:   #FEF2F2;
  --info:        #06B6D4;
  --info-ink:    #0E7490;
  --info-bg:     #ECFEFF;

  /* ---- Surfaces ------------------------------------------------------- */
  --bg:          #F8FAFC;
  --surface:     #FFFFFF;
  --surface-2:   #F8FAFC;
  --surface-3:   #F1F5F9;
  --sidebar:     #FFFFFF;
  --card:        #FFFFFF;
  --overlay:     rgba(15, 23, 42, .45);

  /* Light glassmorphism */
  --glass-bg:     rgba(255, 255, 255, .72);
  --glass-border: rgba(255, 255, 255, .6);
  --glass-blur:   blur(16px) saturate(160%);

  /* ---- Ink ------------------------------------------------------------ */
  --text:        #111827;
  --text-2:      #6B7280;
  --text-3:      #9CA3AF;
  --text-invert: #FFFFFF;
  --border:      #E5E7EB;
  --border-2:    #D1D5DB;
  --ring:        rgba(37, 99, 235, .35);

  /* ---- Gradients (hero, CTA, stat cards, icons, charts only) ---------- */
  --grad-primary: linear-gradient(135deg, #2563EB 0%, #3B82F6 100%);
  --grad-accent:  linear-gradient(135deg, #3B82F6 0%, #06B6D4 100%);
  --grad-hero:    linear-gradient(150deg, #1E3A8A 0%, #2563EB 45%, #06B6D4 100%);
  --grad-mesh:
    radial-gradient(1000px 520px at 12% -8%,  rgba(59,130,246,.20), transparent 62%),
    radial-gradient(760px  460px at 92% 4%,   rgba(6,182,212,.18),  transparent 60%),
    radial-gradient(680px  520px at 50% 108%, rgba(37,99,235,.12),  transparent 62%);

  /* ---- Chart palette ---------------------------------------------------
     Validated with the dataviz validator (six checks, light + dark):
     lightness band, chroma floor, CVD separation, normal-vision floor,
     3:1 contrast on surface. Order is FIXED — assign in sequence, never cycle.
     Adjacent-safe order (lines, stacks, legends): worst adjacent ΔE 10.2. */
  --c1: #2563EB;  /* blue    */
  --c2: #059669;  /* green   */
  --c3: #7C3AED;  /* violet  */
  --c4: #B45309;  /* amber   */
  --c5: #DB2777;  /* pink    */
  --c6: #4D7C0F;  /* lime    */
  --c7: #0891B2;  /* cyan    */
  --c8: #DC2626;  /* red     */

  /* Wrapping forms (donuts/rings) need all-pairs separation — these subsets
     are the validated ones. 5+ slices cannot pass, so they fold to "Other". */
  --ring3-a: #2563EB;  --ring3-b: #DB2777;  --ring3-c: #4D7C0F;
  --ring4-a: #2563EB;  --ring4-b: #0891B2;  --ring4-c: #DB2777;  --ring4-d: #B45309;

  --chart-grid:  #EEF2F7;
  --chart-axis:  #9CA3AF;
  --chart-track: #DBEAFE;   /* meter track = lighter step of the same ramp */

  /* ---- Typography ------------------------------------------------------ */
  --font-sans: "Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont,
               "Segoe UI Variable Display", "Segoe UI", Roboto, "Helvetica Neue",
               Arial, sans-serif;
  --font-mono: "SF Mono", ui-monospace, SFMono-Regular, "Cascadia Code",
               Consolas, monospace;

  /* Type scale (1.250 major third, clamped for fluid desktop-first) */
  --fs-display: clamp(2.75rem, 1.6rem + 3.4vw, 4.25rem);  /* 44 → 68 */
  --fs-h1:      clamp(2rem,   1.4rem + 1.9vw, 3rem);      /* 32 → 48 */
  --fs-h2:      clamp(1.5rem, 1.2rem + 1.0vw, 2rem);      /* 24 → 32 */
  --fs-h3:      1.375rem;   /* 22 */
  --fs-h4:      1.125rem;   /* 18 */
  --fs-lg:      1.0625rem;  /* 17 */
  --fs-base:    0.9375rem;  /* 15 */
  --fs-sm:      0.8125rem;  /* 13 */
  --fs-xs:      0.75rem;    /* 12 */
  --fs-2xs:     0.6875rem;  /* 11 */

  --lh-tight: 1.15;
  --lh-snug:  1.3;
  --lh-base:  1.6;

  --fw-regular:  400;
  --fw-medium:   500;
  --fw-semibold: 600;
  --fw-bold:     700;
  --fw-extra:    800;

  --tracking-tight: -.022em;
  --tracking-wide:  .08em;

  /* ---- Spacing — strict 8-point system (4 = half step) ---------------- */
  --s-1:  4px;
  --s-2:  8px;
  --s-3:  12px;
  --s-4:  16px;
  --s-5:  24px;
  --s-6:  32px;
  --s-7:  40px;
  --s-8:  48px;
  --s-9:  64px;
  --s-10: 80px;
  --s-11: 96px;
  --s-12: 128px;

  /* ---- Radius --------------------------------------------------------- */
  --r-xs:   6px;
  --r-sm:   10px;
  --r-md:   14px;
  --r-lg:   20px;   /* default card radius */
  --r-xl:   28px;
  --r-full: 999px;

  /* ---- Elevation — soft, layered, never harsh ------------------------- */
  --e-0: none;
  --e-1: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --e-2: 0 2px 4px rgba(16, 24, 40, .04), 0 4px 12px rgba(16, 24, 40, .06);
  --e-3: 0 4px 8px rgba(16, 24, 40, .04), 0 12px 28px rgba(16, 24, 40, .08);
  --e-4: 0 8px 16px rgba(16, 24, 40, .06), 0 24px 48px rgba(16, 24, 40, .10);
  --e-brand: 0 8px 24px rgba(37, 99, 235, .28);

  /* ---- Motion --------------------------------------------------------- */
  --ease:        cubic-bezier(.4, 0, .2, 1);
  --ease-out:    cubic-bezier(.16, 1, .3, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  --t-fast:   140ms;
  --t-base:   220ms;
  --t-slow:   380ms;
  --t-slower: 640ms;

  /* ---- Layout --------------------------------------------------------- */
  --sidebar-w:          268px;
  --sidebar-w-collapsed: 76px;
  --topbar-h:           68px;
  --container:          1440px;
  --content-max:        1240px;
  --z-sticky:  100;
  --z-drawer:  200;
  --z-modal:   300;
  --z-toast:   400;
}

/* ==========================================================================
   Dark theme — deliberately re-selected steps, not an inverted flip.
   ========================================================================== */

[data-theme="dark"] {
  --bg:        #0B1120;
  --surface:   #111A2E;
  --surface-2: #16203A;
  --surface-3: #1C2843;
  --sidebar:   #0E1728;
  --card:      #111A2E;
  --overlay:   rgba(2, 6, 23, .7);

  --glass-bg:     rgba(17, 26, 46, .72);
  --glass-border: rgba(148, 163, 184, .14);

  --text:      #E8EDF7;
  --text-2:    #94A3B8;
  --text-3:    #64748B;
  --border:    #23304C;
  --border-2:  #33415F;
  --ring:      rgba(96, 165, 250, .45);

  --brand-primary:       #3B82F6;
  --brand-primary-hover: #60A5FA;
  --brand-50:  #0E1D3A;
  --brand-100: #12264A;
  --brand-200: #17305C;
  --brand-300: #1E4A8C;

  --success-bg: rgba(16, 185, 129, .12);
  --success-ink:#6EE7B7;
  --warning-bg: rgba(245, 158, 11, .12);
  --warning-ink:#FCD34D;
  --danger-bg:  rgba(239, 68, 68, .12);
  --danger-ink: #FCA5A5;
  --info-bg:    rgba(6, 182, 212, .12);
  --info-ink:   #67E8F9;

  --chart-grid:  #1E293B;
  --chart-axis:  #64748B;
  --chart-track: #1E3A5F;

  --grad-mesh:
    radial-gradient(1000px 520px at 12% -8%,  rgba(37,99,235,.26), transparent 62%),
    radial-gradient(760px  460px at 92% 4%,   rgba(6,182,212,.18), transparent 60%),
    radial-gradient(680px  520px at 50% 108%, rgba(59,130,246,.14), transparent 62%);

  --e-1: 0 1px 2px rgba(0,0,0,.30), 0 1px 3px rgba(0,0,0,.24);
  --e-2: 0 2px 4px rgba(0,0,0,.30), 0 4px 12px rgba(0,0,0,.28);
  --e-3: 0 4px 8px rgba(0,0,0,.32), 0 12px 28px rgba(0,0,0,.34);
  --e-4: 0 8px 16px rgba(0,0,0,.36), 0 24px 48px rgba(0,0,0,.40);
  --e-brand: 0 8px 24px rgba(37, 99, 235, .40);
}
