:root {
  --text: #1e293b;
  --text-secondary: #475569;
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --accent: #1e3a5f;
  --accent-light: #2563eb;
  --volcanic: #dc2626;
  --volcanic-light: #fef2f2;
  --urban: #2563eb;
  --urban-light: #eff6ff;
  --health: #059669;
  --health-light: #ecfdf5;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.1);
  --radius: 8px;
  --sidebar-width: 260px;
  --content-max: 100%;
  --font-sans: "Source Sans 3", "Source Sans Pro", system-ui, sans-serif;
  --font-serif: "Source Serif 4", "Source Serif Pro", Georgia, serif;
  --font-mono: "JetBrains Mono", "Fira Code", monospace;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 2rem;
}

body {
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  font-size: 16px;
}

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--accent);
  color: #fff;
  overflow-y: auto;
  z-index: 100;
  padding: 2rem 0;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  padding: 0 1.5rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  margin-bottom: 1rem;
}

.sidebar-brand h2 {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.3;
}

/* Issue #2: bump 0.75 → 0.8125 rem */
.sidebar-brand p {
  font-size: 0.8125rem;
  opacity: 0.75;
  margin-top: 0.25rem;
}

.sidebar nav {
  flex: 1;
}

/* Issue #8: bump opacity 0.75 → 0.85, size 0.85 → 0.9375 rem */
.sidebar nav a {
  display: block;
  padding: 0.55rem 1.5rem;
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  font-size: 0.9375rem;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.sidebar nav a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.sidebar nav a.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border-left-color: #60a5fa;
}

/* ── Main content ── */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

/* ── Hero ── */
.hero {
  background: linear-gradient(135deg, var(--accent), #0f172a);
  color: #fff;
  padding: 4rem 3rem 3rem;
}

/* Issue #1: constrain inner content width */
.hero-inner {
  max-width: var(--content-max);
}

.hero h1 {
  font-family: var(--font-serif);
  font-size: 2.2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.hero .subtitle {
  font-size: 1.1rem;
  opacity: 0.85;
  margin-bottom: 2rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

/* Issue #9: center stat cards, tabular-nums */
.stat-card {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  backdrop-filter: blur(8px);
  text-align: center;
}

.stat-card .stat-value {
  font-family: var(--font-mono);
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.stat-card .stat-label {
  font-size: 0.8125rem;
  opacity: 0.75;
  margin-top: 0.25rem;
}

/* ── Sections ── */
/* Issue #1: max-width container.  Issue #5: more vertical padding + thicker separator */
.section {
  padding: 3.5rem 3rem;
  border-bottom: none;
}

.section + .section {
  border-top: 2px solid var(--border);
}

.section-inner {
  max-width: var(--content-max);
}

.section h2 {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.section h3 {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
  margin: 2rem 0 0.75rem;
}

.section-intro {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
}

/* Issue #7: card header more prominent with bottom border */
.card-header {
  font-weight: 600;
  font-size: 1.05rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
  color: var(--accent);
}

/* ── Chart containers ── */
.chart-container {
  min-height: 400px;
  position: relative;
}

.chart-container.chart-short {
  min-height: 300px;
}

/* Issue #14: spinner loading state */
.chart-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--text-secondary);
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chart-loading::before {
  content: "";
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Metric cards within sections ── */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.metric-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
}

.metric-card .metric-value {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* Issue #2: bump 0.75 → 0.8125 rem */
.metric-card .metric-label {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

/* ── Caveat box ── */
/* Issue #11: more prominent caveats */
.caveat {
  border-left: 4px solid var(--health);
  background: var(--health-light);
  padding: 1.25rem 1.5rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 1.25rem 0;
  font-size: 0.95rem;
  color: #065f46;
}

.caveat-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
  display: block;
}

.caveat strong {
  color: #064e3b;
}

.caveat-warning {
  border-left-color: #f59e0b;
  background: #fffbeb;
  color: #92400e;
}

.caveat-warning strong {
  color: #78350f;
}
.caveat-warning .caveat-title {
  color: #78350f;
}

/* ── Pipeline diagram ── */
.pipeline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 1.5rem 0;
}

.pipeline-step {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  text-align: center;
  min-width: 120px;
}

.pipeline-step .step-label {
  font-weight: 600;
  color: var(--accent);
  display: block;
}

/* Issue #2: bump 0.75 → 0.8125 rem */
.pipeline-step .step-detail {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.pipeline-arrow {
  color: var(--text-secondary);
  font-size: 1.2rem;
}

/* ── Issue #6: Technical notes as definition list ── */
.tech-notes dt {
  font-weight: 600;
  color: var(--accent);
  font-size: 0.95rem;
  margin-top: 1rem;
}

.tech-notes dt:first-child {
  margin-top: 0;
}

.tech-notes dd {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  margin: 0.25rem 0 0 0;
  padding-left: 1rem;
  border-left: 2px solid var(--border);
}

/* ── Tables ── */
/* Issue #12: default sans-serif body, #16: zebra striping */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  margin: 1rem 0;
}

.data-table th,
.data-table td {
  padding: 0.65rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  font-weight: 600;
  color: var(--accent);
  background: var(--bg);
  position: sticky;
  top: 0;
}

/* Issue #12: sans-serif by default, #2: bump font size */
.data-table td {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
}

.data-table td.mono {
  font-family: var(--font-mono);
}

.data-table tbody tr:hover {
  background: #f1f5f9;
}

/* Issue #16: zebra-stripe */
.data-table tbody tr:nth-child(even) {
  background: var(--bg);
}
.data-table tbody tr:nth-child(even):hover {
  background: #f1f5f9;
}

.table-caption {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
  font-style: italic;
}

/* ── Two-column layout ── */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1.5rem;
}

/* ── Selector ── */
.chart-selector {
  margin-bottom: 1rem;
}

.chart-selector select {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  background: var(--bg-card);
  cursor: pointer;
}

/* ── Footer ── */
/* Issue #13: larger text, more opacity */
.footer {
  background: var(--accent);
  color: rgba(255, 255, 255, 0.9);
  padding: 2.5rem 3rem;
  font-size: 0.9rem;
}

.footer-inner {
  max-width: var(--content-max);
}

.footer a {
  color: #93c5fd;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.footer a:hover {
  color: #bfdbfe;
}

.footer h3 {
  color: #fff;
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 2rem;
}

/* ── Mobile hamburger ── */
.hamburger {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 200;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 1.3rem;
  cursor: pointer;
}

/* ── Responsive ── */
/* Issue #3: stack grid-2 at 1024 px */
@media (max-width: 1200px) {
  .grid-3 {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 1024px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

/* Issue #15: mobile scroll padding for hamburger */
@media (max-width: 768px) {
  html {
    scroll-padding-top: 4rem;
  }

  .hamburger {
    display: block;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .hero {
    padding: 4rem 1.5rem 2rem;
  }
  .hero h1 {
    font-size: 1.6rem;
  }

  .section {
    padding: 2.5rem 1.5rem;
  }

  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }

  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .chart-container {
    min-height: 300px;
  }

  .pipeline {
    flex-direction: column;
    align-items: stretch;
  }
  .pipeline-arrow {
    transform: rotate(90deg);
    text-align: center;
  }
}
