/* ═══════════════════════════════════════════════════════════════
   FinancialAIguru LLC — Professional Design System
   Professional-grade visual language. Zero decoration. Pure data.
   ═══════════════════════════════════════════════════════════════ */

/* ── Color Tokens ── */
:root {
  /* Backgrounds — professional dark slate/navy */
  --bg-primary: #141D2B;
  --bg-surface: #1B2638;
  --bg-elevated: #223044;
  --bg-hover: #2A3A50;
  --bg-active: #33445C;

  /* Borders — cool slate */
  --border-subtle: #2E3E54;
  --border-medium: #3D506A;
  --border-bright: #4E6380;

  /* Text — clean whites and grays */
  --text-primary: #E6EDF3;
  --text-secondary: #8B949E;
  --text-muted: #6E7681;
  --text-disabled: #484F58;

  /* Accent — cyan/teal from logo */
  --accent: #00C8FF;
  --accent-hover: #00A8D6;
  --accent-subtle: rgba(0, 200, 255, 0.12);
  --accent-muted: rgba(0, 200, 255, 0.06);

  /* Semantic (ONLY for data meaning) */
  --positive: #3FB950;
  --positive-subtle: rgba(63, 185, 80, 0.10);
  --negative: #F85149;
  --negative-subtle: rgba(248, 81, 73, 0.10);
  --warning: #D29922;
  --warning-subtle: rgba(210, 153, 34, 0.10);

  /* Chart palette */
  --chart-1: #00C8FF;
  --chart-2: #8B5CF6;
  --chart-3: #00FF9D;
  --chart-4: #D29922;
  --chart-5: #F778BA;
  --chart-6: #3FB950;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;

  /* 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: 12px;

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

/* ── Light Theme ── */
[data-theme="light"] {
  --bg-primary: #F8F9FB;
  --bg-surface: #FFFFFF;
  --bg-elevated: #F0F1F4;
  --bg-hover: #E8E9ED;
  --bg-active: #DDDEE3;

  --border-subtle: #E0E1E6;
  --border-medium: #C8C9D0;
  --border-bright: #B0B1BA;

  --text-primary: #1A1A2E;
  --text-secondary: #5A5A72;
  --text-muted: #8A8A9E;
  --text-disabled: #B0B0C0;

  --accent: #2563EB;
  --accent-hover: #1D4ED8;
  --accent-subtle: rgba(37, 99, 235, 0.10);
  --accent-muted: rgba(37, 99, 235, 0.05);

  --positive: #16A34A;
  --positive-subtle: rgba(22, 163, 74, 0.10);
  --negative: #DC2626;
  --negative-subtle: rgba(220, 38, 38, 0.10);
  --warning: #D97706;
  --warning-subtle: rgba(217, 119, 6, 0.10);

  --chart-1: #0091D5;
  --chart-2: #7C3AED;
  --chart-3: #059669;
  --chart-4: #D97706;
  --chart-5: #DB2777;
  --chart-6: #059669;
}

/* ── Theme Toggle ── */
.theme-toggle {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 9999;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all var(--transition-fast);
  line-height: 1;
}
.theme-toggle:hover {
  color: var(--text-primary);
  border-color: var(--border-medium);
  background: var(--bg-elevated);
}

/* ── Base Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

/* ── Scrollbar ── */
::-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: 15px; line-height: 1.5; }
.text-lg { font-size: 18px; line-height: 1.4; font-weight: 600; }
.text-xl { font-size: 24px; line-height: 1.3; font-weight: 700; }
.text-2xl { font-size: 32px; line-height: 1.2; font-weight: 700; }
.text-metric { font-size: 40px; line-height: 1.1; font-weight: 700; font-family: var(--font-mono); }

.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); }

.font-mono { font-family: var(--font-mono); }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

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

/* ── Layout ── */
.container { max-width: 1400px; margin: 0 auto; padding: 0 var(--space-4); }
.container-narrow { max-width: 960px; margin: 0 auto; padding: 0 var(--space-4); }

.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(240px, 1fr)); gap: var(--space-4); }

/* ── Card ── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  transition: border-color var(--transition-fast);
}
.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); }

/* ── Table ── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: left;
  padding: var(--space-2) var(--space-3);
  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;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid rgba(42, 42, 58, 0.5);
  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); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-elevated); border-color: var(--border-medium); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-sm { padding: var(--space-1) var(--space-3); font-size: 12px; }
.btn-lg { padding: var(--space-3) var(--space-6); font-size: 15px; }

/* ── Pill / Badge ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
}
.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-accent { background: var(--accent-subtle); color: var(--accent); }
.badge-neutral { background: rgba(144, 144, 168, 0.12); color: var(--text-secondary); }

/* ── Input ── */
.input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition-fast);
}
.input:focus { border-color: var(--accent); }
.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); }

/* ── 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-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 9999;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  transition: all var(--transition-fast);
}
.back-link:hover { color: var(--text-primary); border-color: var(--border-medium); background: var(--bg-elevated); }

/* ── 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);
}

/* ── Loading ── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-surface) 25%, var(--bg-elevated) 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); } }

/* ── Utility ── */
.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); }
.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; }

/* ── Responsive ── */
@media (max-width: 1024px) {
  .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: 14px; }
  .container { padding: 0 var(--space-3); }
  .card { padding: var(--space-3); }
  .text-metric { font-size: 28px; }
  .kpi-value { font-size: 22px; }
}

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