/* ==========================================================================
   Pilotage BRVM Pro — Design Tokens & Base Reset
   Fintech / Private Wealth Management aesthetic (Light & Dark Themes)
   Zero external fonts or dependencies.
   ========================================================================== */

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

  --text-xs: 0.75rem;      /* 12px */
  --text-sm: 0.8125rem;    /* 13px */
  --text-base: 0.9375rem;  /* 15px */
  --text-md: 1rem;         /* 16px */
  --text-lg: 1.125rem;     /* 18px */
  --text-xl: 1.375rem;     /* 22px */
  --text-2xl: 1.75rem;     /* 28px */
  --text-3xl: 2.125rem;    /* 34px */

  /* Radii */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-full: 9999px;

  /* Spacing & Layout Dimensions */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  --sidebar-w: 256px;
  --sidebar-collapsed-w: 72px;
  --topbar-h: 60px;
  --content-max: 1280px;
  --tabbar-h: 64px;

  /* Z-index layers */
  --z-sticky: 20;
  --z-sidebar: 30;
  --z-fab: 35;
  --z-drawer: 45;
  --z-modal: 50;
  --z-palette: 60;
  --z-toast: 70;

  /* Motion */
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --dur-fast: 140ms;
  --dur-base: 220ms;

  /* Light Theme Palette */
  --bg-canvas: #F7F8FA;
  --bg-surface: #FFFFFF;
  --bg-subtle: #F1F5F9;
  --bg-muted: #E2E8F0;
  --bg-elevated: #FFFFFF;
  --bg-hover: #F8FAFC;

  --border: #E5E7EB;
  --border-subtle: #F1F5F9;
  --border-strong: #CBD5E1;

  --text-primary: #0F172A;
  --text-secondary: #334155;
  --text-muted: #64748B;
  --text-faint: #94A3B8;

  /* Brand & Wealth Accents */
  --accent: #2563EB;
  --accent-deep: #1E40AF;
  --accent-hover: #1D4ED8;
  --accent-soft: #EFF6FF;
  --accent-border: #BFDBFE;
  --accent-ink: #FFFFFF;

  --gold: #D97706;
  --gold-soft: #FEF3C7;
  --gold-border: #FDE68A;
  --gold-ink: #92400E;

  /* Semantic Statuses */
  --ok: #059669;
  --ok-text: #047857;
  --ok-bg: #ECFDF5;
  --ok-border: #A7F3D0;

  --warn: #D97706;
  --warn-text: #B45309;
  --warn-bg: #FFFBEB;
  --warn-border: #FDE68A;

  --bad: #DC2626;
  --bad-text: #B91C1C;
  --bad-bg: #FEF2F2;
  --bad-border: #FECACA;

  --info: #0284C7;
  --info-text: #0369A1;
  --info-bg: #F0F9FF;
  --info-border: #BAE6FD;

  /* Inputs & Chrome */
  --input-bg: #FFFFFF;
  --input-editable: #FFFBEB;
  --input-border: #D1D5DB;
  --input-focus: #2563EB;
  --focus-ring: 0 0 0 3px rgba(37, 99, 235, 0.22);

  --sidebar-bg: #FFFFFF;
  --sidebar-border: #E5E7EB;
  --topbar-bg: rgba(255, 255, 255, 0.88);
  --backdrop: rgba(15, 23, 42, 0.48);

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.08), 0 2px 4px -1px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 14px 32px -6px rgba(15, 23, 42, 0.14), 0 4px 10px -2px rgba(15, 23, 42, 0.06);
  --shadow-xl: 0 24px 48px -12px rgba(15, 23, 42, 0.22);

  /* Charts */
  --chart-1: #2563EB;
  --chart-2: #D97706;
  --chart-3: #059669;
  --chart-4: #7C3AED;
  --chart-5: #0891B2;
  --chart-6: #64748B;
  --chart-grid: #E5E7EB;
  --chart-axis: #64748B;
  --chart-tooltip-bg: #0F172A;
  --chart-tooltip-fg: #F8FAFC;
  --chart-keltner-fill: rgba(37, 99, 235, 0.08);
  --chart-keltner-line: rgba(37, 99, 235, 0.48);

  /* Legacy aliases for smooth interoperability */
  --bg: var(--bg-canvas);
  --surface: var(--bg-surface);
  --surface-2: var(--bg-subtle);
  --fg: var(--text-primary);
  --muted: var(--text-muted);
  --line: var(--border);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-canvas: #0B0F19;
    --bg-surface: #111827;
    --bg-subtle: #182132;
    --bg-muted: #1F2937;
    --bg-elevated: #182132;
    --bg-hover: #1E293B;

    --border: #1F2937;
    --border-subtle: #182132;
    --border-strong: #374151;

    --text-primary: #F8FAFC;
    --text-secondary: #CBD5E1;
    --text-muted: #94A3B8;
    --text-faint: #64748B;

    --accent: #3B82F6;
    --accent-deep: #2563EB;
    --accent-hover: #60A5FA;
    --accent-soft: rgba(59, 130, 246, 0.14);
    --accent-border: rgba(59, 130, 246, 0.35);
    --accent-ink: #FFFFFF;

    --gold: #F59E0B;
    --gold-soft: rgba(245, 158, 11, 0.14);
    --gold-border: rgba(245, 158, 11, 0.32);
    --gold-ink: #FCD34D;

    --ok: #10B981;
    --ok-text: #34D399;
    --ok-bg: rgba(16, 185, 129, 0.14);
    --ok-border: rgba(16, 185, 129, 0.32);

    --warn: #F59E0B;
    --warn-text: #FBBF24;
    --warn-bg: rgba(245, 158, 11, 0.14);
    --warn-border: rgba(245, 158, 11, 0.32);

    --bad: #EF4444;
    --bad-text: #F87171;
    --bad-bg: rgba(239, 68, 68, 0.14);
    --bad-border: rgba(239, 68, 68, 0.32);

    --info: #38BDF8;
    --info-text: #7DD3FC;
    --info-bg: rgba(56, 189, 248, 0.14);
    --info-border: rgba(56, 189, 248, 0.32);

    --input-bg: #0F172A;
    --input-editable: rgba(245, 158, 11, 0.08);
    --input-border: #374151;
    --input-focus: #60A5FA;
    --focus-ring: 0 0 0 3px rgba(96, 165, 250, 0.28);

    --sidebar-bg: #0E1422;
    --sidebar-border: #1F2937;
    --topbar-bg: rgba(11, 15, 25, 0.86);
    --backdrop: rgba(2, 6, 23, 0.72);

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.28);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.24);
    --shadow-md: 0 6px 16px -2px rgba(0, 0, 0, 0.45), 0 2px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 16px 36px -6px rgba(0, 0, 0, 0.6), 0 6px 14px -2px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 24px 54px -12px rgba(0, 0, 0, 0.75);

    --chart-1: #60A5FA;
    --chart-2: #FBBF24;
    --chart-3: #34D399;
    --chart-4: #A78BFA;
    --chart-5: #22D3EE;
    --chart-6: #94A3B8;
    --chart-grid: #1F2937;
    --chart-axis: #94A3B8;
    --chart-tooltip-bg: #1E293B;
    --chart-tooltip-fg: #F8FAFC;
    --chart-keltner-fill: rgba(96, 165, 250, 0.11);
    --chart-keltner-line: rgba(96, 165, 250, 0.45);

    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg-canvas: #0B0F19;
  --bg-surface: #111827;
  --bg-subtle: #182132;
  --bg-muted: #1F2937;
  --bg-elevated: #182132;
  --bg-hover: #1E293B;

  --border: #1F2937;
  --border-subtle: #182132;
  --border-strong: #374151;

  --text-primary: #F8FAFC;
  --text-secondary: #CBD5E1;
  --text-muted: #94A3B8;
  --text-faint: #64748B;

  --accent: #3B82F6;
  --accent-deep: #2563EB;
  --accent-hover: #60A5FA;
  --accent-soft: rgba(59, 130, 246, 0.14);
  --accent-border: rgba(59, 130, 246, 0.35);
  --accent-ink: #FFFFFF;

  --gold: #F59E0B;
  --gold-soft: rgba(245, 158, 11, 0.14);
  --gold-border: rgba(245, 158, 11, 0.32);
  --gold-ink: #FCD34D;

  --ok: #10B981;
  --ok-text: #34D399;
  --ok-bg: rgba(16, 185, 129, 0.14);
  --ok-border: rgba(16, 185, 129, 0.32);

  --warn: #F59E0B;
  --warn-text: #FBBF24;
  --warn-bg: rgba(245, 158, 11, 0.14);
  --warn-border: rgba(245, 158, 11, 0.32);

  --bad: #EF4444;
  --bad-text: #F87171;
  --bad-bg: rgba(239, 68, 68, 0.14);
  --bad-border: rgba(239, 68, 68, 0.32);

  --info: #38BDF8;
  --info-text: #7DD3FC;
  --info-bg: rgba(56, 189, 248, 0.14);
  --info-border: rgba(56, 189, 248, 0.32);

  --input-bg: #0F172A;
  --input-editable: rgba(245, 158, 11, 0.08);
  --input-border: #374151;
  --input-focus: #60A5FA;
  --focus-ring: 0 0 0 3px rgba(96, 165, 250, 0.28);

  --sidebar-bg: #0E1422;
  --sidebar-border: #1F2937;
  --topbar-bg: rgba(11, 15, 25, 0.86);
  --backdrop: rgba(2, 6, 23, 0.72);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.28);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.24);
  --shadow-md: 0 6px 16px -2px rgba(0, 0, 0, 0.45), 0 2px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 16px 36px -6px rgba(0, 0, 0, 0.6), 0 6px 14px -2px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 24px 54px -12px rgba(0, 0, 0, 0.75);

  --chart-1: #60A5FA;
  --chart-2: #FBBF24;
  --chart-3: #34D399;
  --chart-4: #A78BFA;
  --chart-5: #22D3EE;
  --chart-6: #94A3B8;
  --chart-grid: #1F2937;
  --chart-axis: #94A3B8;
  --chart-tooltip-bg: #1E293B;
  --chart-tooltip-fg: #F8FAFC;
  --chart-keltner-fill: rgba(96, 165, 250, 0.11);
  --chart-keltner-line: rgba(96, 165, 250, 0.45);

  color-scheme: dark;
}

/* ==========================================================================
   Base Reset & Typography Primitives
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

[hidden] {
  display: none !important;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1, h2, h3, h4 {
  margin: 0;
  color: var(--text-primary);
  letter-spacing: -0.015em;
  line-height: 1.25;
}

p {
  margin: 0;
}

:focus-visible {
  outline: 2px solid var(--input-focus);
  outline-offset: 2px;
}

.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--text-muted);
}

.ok { color: var(--ok-text); }
.warn { color: var(--warn-text); }
.bad { color: var(--bad-text); }
.info { color: var(--info-text); }
.accent { color: var(--accent); }
.gold { color: var(--gold); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
