:root {
  --bg: #0a0e17;
  --bg-card: rgba(18, 26, 42, 0.75);
  --bg-card-hover: rgba(24, 34, 54, 0.85);
  --bg-sidebar: rgba(10, 14, 23, 0.95);
  --text-primary: #e8edf5;
  --text-secondary: #8a95ad;
  --text-muted: #5a6577;
  --accent-warm: #f59e0b;
  --accent-hot: #ef4444;
  --accent-cool: #06b6d4;
  --accent-danger: #dc2626;
  --accent-green: #22c55e;
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(245, 158, 11, 0.3);
  --glass-bg: rgba(18, 26, 42, 0.6);
  --glass-border: rgba(255, 255, 255, 0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace;
}

[data-theme="light"] {
  --bg: #f0f2f5;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: rgba(255, 255, 255, 0.95);
  --bg-sidebar: rgba(255, 255, 255, 0.95);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: rgba(0, 0, 0, 0.08);
  --border-hover: rgba(245, 158, 11, 0.5);
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(0, 0, 0, 0.06);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
}

a { color: var(--accent-warm); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hot); }

::selection { background: rgba(245, 158, 11, 0.3); color: #fff; }

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 260px;
  height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(20px);
  z-index: 100;
  display: flex;
  flex-direction: column;
  padding: 0;
  transition: transform var(--transition);
}

.sidebar-brand {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-brand .logo {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent-warm), var(--accent-hot));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-brand .brand-text {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.3px;
}

.sidebar-brand .brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
  display: block;
}

.sidebar-nav {
  padding: 16px 12px;
  flex: 1;
  overflow-y: auto;
}

.nav-section {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  padding: 16px 12px 8px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover { background: rgba(255, 255, 255, 0.04); color: var(--text-primary); }
.nav-item.active { background: rgba(245, 158, 11, 0.1); color: var(--accent-warm); }

.nav-item .nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--border);
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  background: none;
  width: 100%;
}

.theme-toggle:hover { background: rgba(255, 255, 255, 0.04); color: var(--text-primary); }

/* Main content */
.main-content {
  margin-left: 260px;
  flex: 1;
  min-height: 100vh;
  padding: 0;
}

.page-header {
  padding: 32px 40px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-header h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.page-header p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 4px;
}

.page-body {
  padding: 32px 40px 64px;
}

/* Bento grid */
.bento-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 20px;
}

.bento-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: all var(--transition);
  backdrop-filter: blur(12px);
}

.bento-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  box-shadow: var(--shadow);
}

.bento-card.span-3 { grid-column: span 3; }
.bento-card.span-4 { grid-column: span 4; }
.bento-card.span-5 { grid-column: span 5; }
.bento-card.span-6 { grid-column: span 6; }
.bento-card.span-7 { grid-column: span 7; }
.bento-card.span-8 { grid-column: span 8; }
.bento-card.span-9 { grid-column: span 9; }
.bento-card.span-12 { grid-column: 1 / -1; }

.bento-card.featured {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(239, 68, 68, 0.06));
  border-color: rgba(245, 158, 11, 0.2);
}

/* Metric cards */
.metric-card .metric-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
  margin-bottom: 6px;
}

.metric-card .metric-value {
  font-family: var(--font-mono);
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -1px;
  line-height: 1;
}

.metric-card .metric-value .metric-unit {
  font-size: 16px;
  color: var(--text-secondary);
  font-weight: 500;
}

.metric-card .metric-change {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  margin-top: 6px;
  padding: 2px 8px;
  border-radius: 4px;
}

.metric-change.up { color: var(--accent-hot); background: rgba(239, 68, 68, 0.1); }
.metric-change.down { color: var(--accent-green); background: rgba(34, 197, 94, 0.1); }
.metric-change.warn { color: var(--accent-warm); background: rgba(245, 158, 11, 0.1); }

.metric-card .metric-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* Charts */
.chart-container {
  width: 100%;
  position: relative;
}

.chart-container canvas {
  width: 100% !important;
  height: auto !important;
  max-height: 280px;
}

.chart-container.tall canvas {
  max-height: 380px;
}

.chart-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-primary);
}

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-card);
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.data-table .num {
  font-family: var(--font-mono);
  text-align: right;
  color: var(--text-primary);
}

/* Stat blocks */
.stat-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.stat-block {
  flex: 1;
  min-width: 140px;
}

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

.stat-block .stat-value {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
  margin-top: 2px;
}

/* Tags */
.tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.tag-red { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.tag-amber { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.tag-green { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
.tag-blue { background: rgba(6, 182, 212, 0.15); color: #22d3ee; }

/* Glossary / key insights */
.insight-list {
  list-style: none;
}

.insight-list li {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.insight-list li:last-child { border-bottom: none; }

.insight-list .insight-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 2px;
}

.insight-list .insight-text {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.insight-list .insight-text strong {
  color: var(--text-primary);
}

/* Section */
.section-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title .title-rule {
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Navigation between pages */
.page-nav {
  display: flex;
  gap: 12px;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
}

.btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-warm), #d97706);
  border-color: transparent;
  color: #fff;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #f59e0b, #b45309);
  border-color: transparent;
}

/* Sparkline inline */
.sparkline {
  display: inline-block;
  width: 60px;
  height: 20px;
  vertical-align: middle;
  margin-left: 8px;
}

/* Footer */
.page-footer {
  text-align: center;
  padding: 24px 40px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

/* Hamburger */
.mobile-toggle {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 200;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 18px;
  align-items: center;
  justify-content: center;
}

/* Responsive */
@media (max-width: 1024px) {
  .bento-card.span-3, .bento-card.span-4, .bento-card.span-5,
  .bento-card.span-6, .bento-card.span-7, .bento-card.span-8, .bento-card.span-9 {
    grid-column: span 6;
  }
}

@media (max-width: 768px) {
  body { flex-direction: column; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .mobile-toggle { display: flex; }
  .page-header { padding: 24px 20px 16px; padding-top: 64px; }
  .page-body { padding: 20px; }
  .page-footer { padding: 20px; }
  .bento-grid { gap: 12px; }
  .bento-card.span-3, .bento-card.span-4, .bento-card.span-5,
  .bento-card.span-6, .bento-card.span-7, .bento-card.span-8, .bento-card.span-9 {
    grid-column: 1 / -1;
  }
  .metric-card .metric-value { font-size: 26px; }
  .stat-row { flex-direction: column; }
}

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

.bento-card {
  animation: fadeIn 0.5s ease forwards;
}

.bento-card:nth-child(1) { animation-delay: 0.05s; }
.bento-card:nth-child(2) { animation-delay: 0.1s; }
.bento-card:nth-child(3) { animation-delay: 0.15s; }
.bento-card:nth-child(4) { animation-delay: 0.2s; }
.bento-card:nth-child(5) { animation-delay: 0.25s; }
.bento-card:nth-child(6) { animation-delay: 0.3s; }
.bento-card:nth-child(7) { animation-delay: 0.35s; }
