:root {
  /* Primary Colors */
  --color-primary: #FA4F55;
  --color-primary-light: #FF7E83;
  --color-primary-dark: #E03A40;
  --color-primary-rgb: 250, 79, 85;

  /* Merlot (header nav theme) */
  --color-merlot: #FA4F55;
  --color-merlot-mid: #FA4F55;
  --color-merlot-deep: #E03A40;
  --color-merlot-tint: #FFE7E8;

  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #FA4F55 0%, #FF9296 100%);
  --gradient-primary-hover: linear-gradient(135deg, #E03A40 0%, #FA4F55 100%);
  --gradient-background: linear-gradient(135deg, #FA4F55 0%, #FFC2C4 50%, #ffffff 100%);
  --gradient-merlot: linear-gradient(135deg, #FA4F55 0%, #FA4F55 55%, #E03A40 100%);

  /* Neutrals — tinted toward the brand navy/slate theme (from design palette) */
  --color-white: #ffffff;
  --color-black: #000000;
  /* Text that sits on a colored/primary background — ALWAYS white (never theme-flipped) */
  --color-on-primary: #ffffff;
  --color-gray-50: #F8F9FF;   /* page background (soft blue-white) */
  --color-gray-100: #EFF1F9;  /* soft panels / fills */
  --color-gray-200: #e5e7eb;  /* borders */
  --color-gray-300: #d1d5db;
  --color-gray-400: #9ca3af;
  --color-gray-500: #7A8194;  /* muted slate */
  --color-gray-600: #565E74;  /* secondary text */
  --color-gray-700: #3D4A5C;
  --color-gray-800: #232F3E;  /* strong text / dark bands */
  --color-gray-900: #0B1C30;  /* headings (deep navy) */

  /* Brand theme accents (from design palette) */
  --color-accent: #007185;       /* teal — links / secondary actions */
  --color-accent-dark: #005965;
  --color-gold: #FEBD69;         /* gold — badges / highlights */
  --color-navy: #232F3E;         /* dark bands / footer */
  --color-panel: #EFF4FF;        /* soft blue panel background */
  --color-surface: #F8F9FF;      /* page background */

  /* Status Colors */
  --color-success: #10b981;
  --color-success-light: #d1fae5;
  --color-warning: #f59e0b;
  --color-warning-light: #fef3c7;
  --color-error: #ef4444;
  --color-error-light: #fee2e2;
  --color-info: #3b82f6;
  --color-info-light: #dbeafe;

  /* ============================================================
     TYPOGRAPHY — change the app-wide font HERE (one place)
     To switch fonts: (1) change --font-primary below, AND
     (2) update the Google Fonts <link> in templates/base.html
     ============================================================ */
  --font-primary: 'DM Sans';                                  /* <-- THE master knob */
  --font-fallback: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  --font-family:         var(--font-primary), var(--font-fallback);  /* body text     */
  --font-family-heading: var(--font-primary), var(--font-fallback);  /* headings      */
  --font-family-brand:   var(--font-primary), var(--font-fallback);  /* logo/wordmark */
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 1.875rem;
  --font-size-4xl: 2.25rem;

  /* Spacing */
  --spacing-1: 0.25rem;
  --spacing-2: 0.5rem;
  --spacing-3: 0.75rem;
  --spacing-4: 1rem;
  --spacing-5: 1.25rem;
  --spacing-6: 1.5rem;
  --spacing-8: 2rem;
  --spacing-10: 2.5rem;
  --spacing-12: 3rem;
  --spacing-16: 4rem;

  /* Border Radius */
  --radius-sm: 0.25rem;
  --radius-md: 0.375rem;
  --radius-lg: 0.5rem;
  --radius-xl: 0.75rem;
  --radius-2xl: 1rem;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --shadow-primary: 0 4px 14px 0 rgba(250, 79, 85, 0.39);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 300ms ease;
  --transition-slow: 500ms ease;

  /* Extended status - dark text variants */
  --color-error-dark: #dc2626;
  --color-success-dark: #16a34a;
  --color-warning-dark: #d97706;
  --color-info-dark: #2563eb;

  /* Extended status - subtle backgrounds */
  --color-error-subtle: #fef2f2;
  --color-success-subtle: #f0fdf4;
  --color-warning-subtle: #fffbeb;
  --color-info-subtle: #eff6ff;

  /* Extended status - border colors */
  --color-error-border: #fecaca;
  --color-success-border: #a7f3d0;
  --color-warning-border: #fde68a;
  --color-info-border: #bfdbfe;

  /* Purple */
  --color-purple: #8b5cf6;
  --color-purple-light: #ede9fe;
  --color-purple-subtle: #faf5ff;

  /* Layout */
  --sidebar-width: 200px;
  --sidebar-collapsed-width: 60px;
  --mobile-header-height: 56px;
  --touch-target-min: 44px;
  --container-padding-mobile: var(--spacing-3);
  --container-padding-tablet: var(--spacing-4);
  --container-padding-desktop: var(--spacing-6);

  /* Premium Color Scale */
  --color-primary-50: #fff1f1;
  --color-primary-100: #ffe1e1;
  --color-primary-200: #ffc7c7;
  --color-primary-500: #FA4F55;
  --color-primary-600: #E03A40;
  --color-primary-700: #C32D33;
  --color-primary-900: #7f1d1d;

  /* Premium Gradients */
  --gradient-premium: linear-gradient(135deg, #FA4F55 0%, #FA4F55 50%, #FF7E83 100%);
  --gradient-hero: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  --gradient-dark: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  --gradient-accent: linear-gradient(135deg, #FA4F55 0%, #f97316 100%);
  --gradient-subtle: linear-gradient(135deg, #fff1f1 0%, #fef2f2 50%, #ffffff 100%);

  /* Glassmorphism */
  --glass-bg: rgba(255, 255, 255, 0.72);
  --glass-bg-strong: rgba(255, 255, 255, 0.85);
  --glass-border: rgba(255, 255, 255, 0.18);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
  --glass-blur: blur(20px);

  /* Enhanced Shadows */
  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --card-shadow-hover: 0 10px 25px rgba(0, 0, 0, 0.07), 0 4px 10px rgba(0, 0, 0, 0.04);
  --card-radius: var(--radius-xl);
  --input-shadow-focus: 0 0 0 3px rgba(var(--color-primary-rgb), 0.12);
}

/* ============================================================
   DARK THEME — toggled by the topbar button via <html data-theme="dark">.
   Inverts the neutral ramp so token-based UI flips and stays readable.
   Primary coral and status colors are kept.
   ============================================================ */
html[data-theme="dark"] {
  /* Neutral black/gray surfaces + white text + coral (#FA4F55) accent */
  --color-white: #1e1e1e;        /* cards / surfaces */
  --color-black: #ffffff;
  --color-gray-50:  #121212;     /* page background */
  --color-gray-100: #242424;     /* soft fills */
  --color-gray-200: #333333;     /* borders */
  --color-gray-300: #404040;
  --color-gray-400: #5c5c5c;
  --color-gray-500: #8a8a8a;
  --color-gray-600: #adadad;     /* secondary text */
  --color-gray-700: #cccccc;
  --color-gray-800: #e8e8e8;
  --color-gray-900: #ffffff;     /* headings (white) */
  --color-panel: #242424;
  --color-surface: #121212;
  /* Coral accent stays the brand color */
  --color-merlot: #FA4F55;
  --color-merlot-mid: #FA4F55;
  --color-merlot-deep: #FF7E83;  /* lighter so it reads on dark */
  --color-merlot-tint: rgba(250, 79, 85, 0.22);
  --color-primary-50: rgba(250, 79, 85, 0.16);
  --color-primary-100: rgba(250, 79, 85, 0.24);
  --color-info-subtle: #1a2230;
  --color-success-subtle: #16241c;
  --color-warning-subtle: #2a2310;
  --color-error-subtle: #2a1718;
  --color-purple-subtle: #1e1a2e;
  --color-purple-light: #2a2342;
  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.6), 0 1px 2px rgba(0, 0, 0, 0.5);
  --card-shadow-hover: 0 12px 28px rgba(0, 0, 0, 0.6);
  --glass-bg: rgba(30, 30, 30, 0.72);
  --glass-bg-strong: rgba(30, 30, 30, 0.85);
  color-scheme: dark;
}
html[data-theme="dark"] body { background: var(--color-surface); color: var(--color-gray-800); }
