/* === Design Tokens === */
:root, [data-theme="light"] {
  --color-bg: #F5F4F0;
  --color-surface: #FFFFFF;
  --color-surface-2: #FAFAF8;
  --color-border: #D8D5CE;
  --color-divider: #E5E3DD;
  --color-text: #1A1A18;
  --color-text-muted: #6B6A65;
  --color-text-faint: #A3A29D;
  --color-primary: #1B7A82;
  --color-primary-hover: #14626A;
  --color-accent-warm: #C45A2D;
  --color-accent-warm-hover: #A34A24;
  --color-sp500: #1B7A82;
  --color-sp500-light: rgba(27, 122, 130, 0.08);
  --color-jolts: #C45A2D;
  --color-jolts-light: rgba(196, 90, 45, 0.08);
  --color-positive: #3A7A1E;
  --color-negative: #A13544;
  --color-gap-fill: rgba(27, 122, 130, 0.06);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.06);
  --radius-md: 8px;
  --radius-lg: 12px;
  --font-body: 'Inter', -apple-system, sans-serif;
  --font-mono: 'Geist Mono', 'JetBrains Mono', monospace;
  --transition: 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] {
  --color-bg: #0E0E0D;
  --color-surface: #161615;
  --color-surface-2: #1C1C1A;
  --color-border: #2A2A28;
  --color-divider: #222221;
  --color-text: #D4D3D0;
  --color-text-muted: #8A8985;
  --color-text-faint: #555553;
  --color-primary: #4AA8B2;
  --color-primary-hover: #3A949E;
  --color-accent-warm: #D97A4A;
  --color-accent-warm-hover: #C46A3A;
  --color-sp500: #4AA8B2;
  --color-sp500-light: rgba(74, 168, 178, 0.1);
  --color-jolts: #D97A4A;
  --color-jolts-light: rgba(217, 122, 74, 0.1);
  --color-positive: #5CA83A;
  --color-negative: #DD6974;
  --color-gap-fill: rgba(74, 168, 178, 0.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.3);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg: #0E0E0D;
    --color-surface: #161615;
    --color-surface-2: #1C1C1A;
    --color-border: #2A2A28;
    --color-divider: #222221;
    --color-text: #D4D3D0;
    --color-text-muted: #8A8985;
    --color-text-faint: #555553;
    --color-primary: #4AA8B2;
    --color-primary-hover: #3A949E;
    --color-accent-warm: #D97A4A;
    --color-accent-warm-hover: #C46A3A;
    --color-sp500: #4AA8B2;
    --color-sp500-light: rgba(74, 168, 178, 0.1);
    --color-jolts: #D97A4A;
    --color-jolts-light: rgba(217, 122, 74, 0.1);
    --color-positive: #5CA83A;
    --color-negative: #DD6974;
    --color-gap-fill: rgba(74, 168, 178, 0.05);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.3);
  }
}

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
}

::selection {
  background: rgba(74, 168, 178, 0.25);
  color: var(--color-text);
}

/* === Header === */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  border-bottom: 1px solid var(--color-divider);
  background: var(--color-surface);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left { display: flex; align-items: center; gap: 12px; }

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-text {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--color-text);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.data-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--color-positive);
  background: rgba(58, 122, 30, 0.1);
  padding: 3px 10px;
  border-radius: 100px;
  letter-spacing: 0.02em;
}

[data-theme="dark"] .data-badge {
  background: rgba(92, 168, 58, 0.12);
}

.theme-toggle {
  cursor: pointer;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 6px;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.theme-toggle:hover {
  color: var(--color-text);
  border-color: var(--color-text-muted);
}

/* === Dashboard Layout === */
.dashboard {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 32px;
}

/* === Hero Section === */
.hero-section {
  padding: 40px 0 24px;
}

.hero-content { margin-bottom: 28px; }

h1 {
  font-size: clamp(22px, 2.2vw, 30px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--color-text);
}

.subtitle {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-top: 6px;
  font-family: var(--font-mono);
}

/* === KPI Row === */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.kpi-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.kpi-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: var(--font-mono);
}

.kpi-value {
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums lining-nums;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.sp500-value { color: var(--color-sp500); }
.jolts-value { color: var(--color-jolts); }
.gap-value { color: var(--color-text); }

.kpi-delta {
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.kpi-delta.positive { color: var(--color-positive); }
.kpi-delta.negative { color: var(--color-negative); }

/* === Chart Section === */
.chart-section {
  padding: 8px 0 40px;
}

.chart-controls {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: var(--font-mono);
}

.button-group {
  display: flex;
  gap: 4px;
}

.btn-control {
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 14px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: transparent;
  color: var(--color-text-muted);
  transition: all var(--transition);
}

.btn-control:hover {
  color: var(--color-text);
  border-color: var(--color-text-muted);
}

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

.btn-control.active:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

.chart-container {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 28px 28px 28px 32px;
  position: relative;
  aspect-ratio: 2.2 / 1;
  min-height: 440px;
}

.chart-container canvas {
  width: 100% !important;
  height: 100% !important;
}

.chart-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  padding: 0 4px;
}

.source-text, .update-text {
  font-size: 11px;
  color: var(--color-text-faint);
  font-family: var(--font-mono);
}

/* === Thesis Section === */
.thesis-section {
  padding: 48px 0;
  border-top: 1px solid var(--color-divider);
}

.thesis-section h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 24px;
}

.thesis-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.thesis-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 24px;
}

.thesis-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-sp500-light);
  border-radius: 8px;
  margin-bottom: 16px;
  color: var(--color-primary);
}

.thesis-card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.thesis-card p {
  font-size: 13px;
  line-height: 1.65;
  color: var(--color-text-muted);
}

/* === Methodology === */
.methodology-section {
  padding: 40px 0;
  border-top: 1px solid var(--color-divider);
}

.methodology-section h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  letter-spacing: -0.01em;
}

.method-content p {
  font-size: 13px;
  line-height: 1.7;
  color: var(--color-text-muted);
  max-width: 80ch;
}

.method-content strong {
  color: var(--color-text);
  font-weight: 600;
}

/* === Footer === */
.site-footer {
  border-top: 1px solid var(--color-divider);
  padding: 20px 32px;
  background: var(--color-surface);
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--color-text-faint);
  font-family: var(--font-mono);
}

.footer-brand {
  font-weight: 600;
  color: var(--color-text-muted);
}

.footer-divider { opacity: 0.4; }

/* === Responsive === */
@media (max-width: 900px) {
  .dashboard { padding: 0 20px; }
  .site-header { padding: 14px 20px; }
  .site-footer { padding: 18px 20px; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .thesis-grid { grid-template-columns: 1fr; }
  .chart-container { aspect-ratio: 1.4 / 1; min-height: 320px; }
  .chart-controls { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 600px) {
  .kpi-row { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi-value { font-size: 22px; }
  .chart-container { aspect-ratio: 1.1 / 1; min-height: 280px; padding: 16px 12px 12px; }
  h1 { font-size: 20px; }
}

/* === Animations === */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.kpi-card { animation: fadeIn 0.5s ease-out both; }
.kpi-card:nth-child(2) { animation-delay: 0.06s; }
.kpi-card:nth-child(3) { animation-delay: 0.12s; }
.kpi-card:nth-child(4) { animation-delay: 0.18s; }
.chart-section { animation: fadeIn 0.6s ease-out 0.2s both; }

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