@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;600;700;900&family=Rajdhani:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ═══════════════════════════════════════════════════════════════
   FinancialAIguru LLC — Unified Design System (Midnight Apex)
   Single source of truth for all 130+ apps.
   ═══════════════════════════════════════════════════════════════ */

/* ── Root Variables (Dark Mode Default) ── */

:root {
  /* ── Backgrounds ── */
  --bg-primary: #0B1120;
  --bg-surface: #131D2E;
  --bg-elevated: #1A2744;
  --bg-hover: #1F3050;
  --bg-active: #253D5E;

  /* ── Borders ── */
  --border-subtle: rgba(255,255,255,0.06);
  --border-medium: rgba(255,255,255,0.10);
  --border-bright: rgba(255,255,255,0.16);

  /* ── Text ── */
  --text-primary: #E2E8F0;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --text-disabled: #475569;

  /* ── Accent ── */
  --accent: #38BDF8;
  --accent-hover: #7DD3FC;
  --accent-subtle: rgba(56,189,248,0.12);
  --accent-muted: rgba(56,189,248,0.06);
  --accent-secondary: #818CF8;

  /* ── Semantic ── */
  --positive: #34D399;
  --positive-subtle: rgba(52,211,153,0.10);
  --negative: #F87171;
  --negative-subtle: rgba(248,113,113,0.10);
  --warning: #FBBF24;
  --warning-subtle: rgba(251,191,36,0.10);
  --gold: #FBBF24;
  --gold-subtle: rgba(251,191,36,0.10);

  /* ── Chart palette ── */
  --chart-1: #38BDF8;
  --chart-2: #818CF8;
  --chart-3: #34D399;
  --chart-4: #FBBF24;
  --chart-5: #F472B6;
  --chart-6: #2DD4BF;

  /* ── Alpha Variants ── */
  --accent-dim: rgba(56,189,248,0.25);
  --accent-glow: rgba(56,189,248,0.35);
  --positive-dim: rgba(52,211,153,0.25);
  --negative-dim: rgba(248,113,113,0.25);
  --gold-dim: rgba(251,191,36,0.25);
  --warning-dim: rgba(251,191,36,0.25);

  /* ── Extended palette (migration targets) ── */
  --text-white: #ffffff;
  --text-white-30: rgba(255,255,255,0.3);
  --text-white-50: rgba(255,255,255,0.5);
  --text-white-70: rgba(255,255,255,0.7);
  --text-white-80: rgba(255,255,255,0.8);
  --text-white-90: rgba(255,255,255,0.9);
  --positive-bright: #3FB950;
  --accent-cyan: #00c8ff;
  --accent-cyan-dim: rgba(0,200,255,0.15);
  --accent-cyan-subtle: rgba(0,200,255,0.12);
  --accent-neon: #00ff9d;
  --accent-neon-subtle: rgba(0,255,157,0.12);

  /* ── Financial Signal Colors ── */
  --signal-red: #F85149;
  --signal-red-subtle: rgba(248,81,73,0.10);
  --signal-green: #3FB950;
  --signal-green-subtle: rgba(63,185,80,0.10);

  /* ── Extended Gold/Amber Palette ── */
  --gold-muted: #D4A843;
  --gold-warm: #f0b429;
  --gold-deep: #D29922;
  --gold-light: #ffd166;

  /* ── Extended Accent Colors ── */
  --accent-cyan-bright: #00D4FF;
  --accent-violet: #a78bfa;
  --accent-purple: #8B5CF6;
  --accent-orange: #fb923c;
  --accent-orange-subtle: rgba(251,147,60,0.10);
  --accent-pink: #ec4899;
  --accent-pink-subtle: rgba(236,72,153,0.10);
  --accent-blue: #3b82f6;
  --accent-teal: #2dd4bf;

  /* ── Structural Slate Tones ── */
  --text-slate: #4A6580;
  --text-slate-light: #5A7A99;
  --text-slate-muted: #5a6a80;
  --text-gray: #A0AAB8;
  --text-gray-dim: #6b7a8d;

  /* ── Deep Backgrounds ── */
  --bg-deep: #080E17;
  --bg-elevated-dark: #1E3045;
  --bg-base: var(--bg-deep);

  /* ── Overlays ── */
  --overlay-light: rgba(0,0,0,0.3);
  --overlay-medium: rgba(0,0,0,0.5);
  --overlay-heavy: rgba(0,0,0,0.7);
  --overlay-backdrop: rgba(11,17,32,0.85);

  /* ── Glass ── */
  --glass-bg: rgba(19,29,46,0.8);
  --glass-blur: blur(12px);

  /* ── Shadows ── */
  --shadow-card: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-card-hover: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-glow: 0 2px 8px rgba(56,189,248,0.25);

  /* ── Typography ── */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --font-body: 'Rajdhani', var(--font-sans);
  --font-display: 'Orbitron', var(--font-sans);

  /* ── Marketing doc aliases ── */
  --accent-gold: var(--gold-muted);

  /* ── Spacing (4px base) ── */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  /* ── Radius ── */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 16px;
  --radius-pill: 999px;

  /* ── Transitions ── */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.2s ease;
}

/* ── Light Mode ── */

[data-theme="light"] {
  --bg-primary: #F1F5F9;
  --bg-surface: #FFFFFF;
  --bg-elevated: #FFFFFF;
  --bg-hover: #E2E8F0;
  --bg-active: #CBD5E1;

  --border-subtle: rgba(0,0,0,0.06);
  --border-medium: rgba(0,0,0,0.10);
  --border-bright: rgba(0,0,0,0.16);

  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-muted: #94A3B8;
  --text-disabled: #CBD5E1;

  --accent: #0284C7;
  --accent-hover: #0369A1;
  --accent-subtle: rgba(2,132,199,0.08);
  --accent-muted: rgba(2,132,199,0.04);
  --accent-secondary: #6366F1;

  --positive: #059669;
  --positive-subtle: rgba(5,150,105,0.08);
  --negative: #DC2626;
  --negative-subtle: rgba(220,38,38,0.08);
  --warning: #D97706;
  --warning-subtle: rgba(217,119,6,0.08);

  --chart-1: #0284C7;
  --chart-2: #7C3AED;
  --chart-3: #059669;
  --chart-4: #D97706;
  --chart-5: #DB2777;
  --chart-6: #0891B2;

  --glass-bg: rgba(255,255,255,0.8);
  --glass-blur: blur(12px);

  --shadow-card: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-card-hover: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-glow: 0 2px 8px rgba(2,132,199,0.15);
}

/* ── Base Reset ── */

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

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

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-variant-numeric: tabular-nums;
}

::selection { background: var(--accent-subtle); color: var(--accent); }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-medium); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-bright); }

/* ── Typography ── */

.text-xs { font-size: 11px; line-height: 1.4; }
.text-sm { font-size: 13px; line-height: 1.5; }
.text-base { font-size: 14px; line-height: 1.5; }
.text-lg { font-size: 16px; line-height: 1.4; font-weight: 600; }
.text-xl { font-size: 20px; line-height: 1.3; font-weight: 700; }
.text-2xl { font-size: 28px; line-height: 1.2; font-weight: 700; }
.text-3xl { font-size: 36px; line-height: 1.1; font-weight: 700; }
.text-metric { font-family: var(--font-mono); font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }

.label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.font-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.font-sans { font-family: var(--font-sans); }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* ── Semantic Text Colors ── */

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-positive { color: var(--positive); }
.text-negative { color: var(--negative); }
.text-warning { color: var(--warning); }

/* ── Cards ── */

.card {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--transition-normal), border-color var(--transition-normal);
}
.card:hover {
  box-shadow: var(--shadow-card-hover);
  border-color: var(--border-medium);
}
.card-compact { padding: var(--space-3); }
.card-elevated { background: var(--bg-elevated); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
}

/* ── KPI Card ── */

.kpi {
  text-align: center;
  padding: var(--space-4);
}
.kpi-value {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}
.kpi-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: var(--space-1);
}
.kpi-delta {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  margin-top: var(--space-1);
}
.kpi-delta.up { color: var(--positive); }
.kpi-delta.down { color: var(--negative); }

/* ── Buttons ── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-medium);
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary {
  background: var(--accent);
  color: #FFFFFF;
  border-color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: var(--shadow-glow);
}
.btn-sm { padding: var(--space-1) var(--space-3); font-size: 11px; }
.btn-lg { padding: var(--space-3) var(--space-6); font-size: 15px; }
.btn-pill { border-radius: var(--radius-pill); }

/* ── Badges ── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  letter-spacing: 0.03em;
  line-height: 1.4;
}
.badge-accent { background: var(--accent-subtle); color: var(--accent); }
.badge-positive { background: var(--positive-subtle); color: var(--positive); }
.badge-negative { background: var(--negative-subtle); color: var(--negative); }
.badge-warning { background: var(--warning-subtle); color: var(--warning); }
.badge-neutral { background: var(--border-subtle); color: var(--text-secondary); }
.badge-pill { border-radius: var(--radius-pill); }

/* ── Tables ── */

.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: var(--space-2) var(--space-3);
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}
.data-table th.right, .data-table td.right { text-align: right; }
.data-table td {
  font-family: var(--font-mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  white-space: nowrap;
}
.data-table tbody tr { transition: background var(--transition-fast); }
.data-table tbody tr:hover { background: var(--bg-hover); }

/* ── Inputs ── */

.input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-sans);
  font-size: 14px;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color var(--transition-fast);
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-subtle); }
.input::placeholder { color: var(--text-muted); }

/* ── Tabs ── */

.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
}
.tab {
  padding: var(--space-3) var(--space-4);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
}
.tab:hover { color: var(--text-secondary); }
.tab.active { color: var(--text-primary); border-bottom-color: var(--accent); }

/* ── Nav Bar / Toolbar ── */

.nav-bar {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-2) var(--space-4);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border-subtle);
}
.nav-tab {
  padding: var(--space-1) var(--space-3);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.nav-tab:hover { color: var(--text-primary); background: var(--bg-hover); }
.nav-tab.active { color: var(--accent); background: var(--accent-subtle); font-weight: 600; }

/* ── Bottom Navigation ── */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  z-index: 100;
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: color var(--transition-fast);
  border-top: 2px solid transparent;
}
.nav-item:hover { color: var(--text-secondary); }
.nav-item.active { color: var(--accent); border-top-color: var(--accent); }
.nav-icon { font-size: 18px; }

/* ── Back Link / Back Button ── */

.back-link,
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  text-decoration: none;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  transition: color 0.2s;
  white-space: nowrap;
}
.back-link:hover,
.back-btn:hover { color: var(--accent); }

/* ── Ticker Tape Container ── */
#tickerTape { position: relative; z-index: 10; flex-shrink: 0; }

/* ── Section Header ── */

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: var(--space-6) 0 var(--space-4);
}
.section-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

/* ── Status Dots ── */

.status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
}
.status-dot.live { background: var(--positive); }
.status-dot.warning { background: var(--warning); }
.status-dot.error { background: var(--negative); }
.status-dot.accent { background: var(--accent); }

/* ── Icon Styles ── */

.icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: middle;
}
.icon-sm { width: 14px; height: 14px; }
.icon-md { width: 18px; height: 18px; }
.icon-lg { width: 24px; height: 24px; }

/* ── Theme Toggle ── */

.theme-toggle {
  position: fixed;
  bottom: 72px;
  left: var(--space-3);
  z-index: 1000;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  line-height: 1;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }

/* ── Layout Utilities ── */

.container { max-width: 1400px; margin: 0 auto; padding: 0 var(--space-6); }
.container-narrow { max-width: 960px; margin: 0 auto; padding: 0 var(--space-6); }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); }
.grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--space-4); }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--space-4); }

/* ── Spacing Utilities ── */

.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.p-4 { padding: var(--space-4); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* ── Loading States ── */

.skeleton {
  background: linear-gradient(90deg, var(--bg-surface) 25%, var(--bg-hover) 50%, var(--bg-surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.spinner {
  width: 24px; height: 24px;
  border: 2px solid var(--border-subtle);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Disclaimer ── */

.disclaimer {
  margin: var(--space-6) var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--warning-subtle);
  border: 1px solid rgba(251, 191, 36, 0.2);
  border-left: 3px solid var(--warning);
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.6;
  border-radius: var(--radius-sm);
}

/* ── Accessibility ── */

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

/* ── Responsive ── */

@media (max-width: 1024px) {
  .grid-3, .grid-4, .grid-5 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: 1fr; }
  body { padding-bottom: 64px; font-size: 13px; }
  .container { padding: 0 var(--space-3); }
  .card { padding: var(--space-3); }
  .text-metric { font-size: 22px; }
  .kpi-value { font-size: 18px; }
}
