:root {
  --bg-base: #070b14;
  --bg-surface: #0f172a;
  --bg-elevated: #1e293b;
  --bg-glass: rgba(15, 23, 42, 0.85);
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border-subtle: #1e293b;
  --border-default: #334155;
  --accent-blue: #3b82f6;
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-purple: #8b5cf6;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --shadow-card: 0 10px 30px -5px rgba(0, 0, 0, 0.45);
}

[data-theme="light"] {
  --bg-base: #f8fafc;
  --bg-surface: #ffffff;
  --bg-elevated: #f1f5f9;
  --bg-glass: rgba(255, 255, 255, 0.9);
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --border-subtle: #e2e8f0;
  --border-default: #cbd5e1;
  --shadow-card: 0 8px 24px -4px rgba(15, 23, 42, 0.08);
}

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

html {
  scroll-behavior: smooth;
  font-family: var(--font-sans);
  background-color: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.65;
}

body {
  background-color: var(--bg-base);
  color: var(--text-primary);
  overflow-x: hidden;
}

a {
  color: var(--accent-cyan);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover {
  color: var(--accent-blue);
  text-decoration: underline;
}

/* Top Reading Progress Bar */
#progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan), var(--accent-emerald));
  width: 0%;
  z-index: 1000;
  transition: width 0.1s ease-out;
}

/* Top Sticky Header */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 900;
  background: var(--bg-glass);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-default);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-badge {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  color: #fff;
  font-weight: 700;
  font-size: 0.75rem;
  padding: 0.25rem 0.65rem;
  border-radius: 6px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.brand-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.nav-controls {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.btn-control {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  padding: 0.4rem 0.85rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-control:hover, .btn-control.active {
  background: var(--accent-blue);
  color: #fff;
  border-color: var(--accent-blue);
}

/* Layout Shell */
.layout-shell {
  max-width: 1480px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 2rem;
  padding: 2rem 1.5rem 5rem;
}

@media (max-width: 1120px) {
  .layout-shell {
    grid-template-columns: 1fr;
  }
  .sidebar-toc {
    position: static !important;
    max-height: none !important;
  }
}

/* Sidebar TOC */
.sidebar-toc {
  position: sticky;
  top: 4.5rem;
  align-self: start;
  max-height: calc(100vh - 5.5rem);
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 14px;
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
}

.toc-header {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 0.85rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.toc-link {
  display: block;
  font-size: 0.83rem;
  color: var(--text-secondary);
  padding: 0.42rem 0.65rem;
  border-radius: 7px;
  border-left: 2px solid transparent;
  transition: all 0.15s ease;
}

.toc-link:hover, .toc-link.active {
  background: var(--bg-elevated);
  color: var(--accent-cyan);
  border-left-color: var(--accent-cyan);
  text-decoration: none;
}

/* Hero Banner */
.hero-card {
  background: radial-gradient(circle at top right, rgba(59, 130, 246, 0.16), rgba(139, 92, 246, 0.08) 45%, var(--bg-surface) 80%);
  border: 1px solid var(--border-default);
  border-radius: 18px;
  padding: 2.25rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-card);
}

.hero-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border-default);
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

.pill.official { background: rgba(16, 185, 129, 0.14); color: #34d399; border-color: rgba(16, 185, 129, 0.35); }
.pill.estimate { background: rgba(59, 130, 246, 0.14); color: #60a5fa; border-color: rgba(59, 130, 246, 0.35); }
.pill.forecast { background: rgba(245, 158, 11, 0.14); color: #fbbf24; border-color: rgba(245, 158, 11, 0.35); }
.pill.na { background: rgba(148, 163, 184, 0.14); color: #94a3b8; border-color: rgba(148, 163, 184, 0.35); }
.pill.high { background: rgba(16, 185, 129, 0.18); color: #10b981; border-color: #10b981; }
.pill.med { background: rgba(245, 158, 11, 0.18); color: #f59e0b; border-color: #f59e0b; }
.pill.low { background: rgba(244, 63, 94, 0.18); color: #f43f5e; border-color: #f43f5e; }

.hero-title {
  font-size: 1.95rem;
  line-height: 1.3;
  font-weight: 800;
  margin-bottom: 0.9rem;
  letter-spacing: -0.01em;
}

.hero-subtitle {
  font-size: 1.02rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

/* Headline Metrics Strip */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
}

.metric-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: 12px;
  padding: 1.1rem 1.2rem;
}

.metric-val {
  font-family: var(--font-mono);
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--accent-cyan);
  line-height: 1.2;
}

.metric-label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 0.3rem;
}

.metric-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* Report Section Cards */
.report-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 16px;
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-card);
  scroll-margin-top: 4.5rem;
}

.section-header {
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

.section-tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent-cyan);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.section-title {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 0.2rem;
}

.sub-heading {
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 1.6rem 0 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sub-heading::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 1.1em;
  background: var(--accent-blue);
  border-radius: 2px;
}

p.prose {
  color: var(--text-secondary);
  font-size: 0.94rem;
  margin-bottom: 0.9rem;
}

/* Three Judgments A / B / C Grid */
.abc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: 1.25rem;
  margin: 1.5rem 0;
}

.abc-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-top: 4px solid var(--accent-blue);
  border-radius: 14px;
  padding: 1.35rem;
}

.abc-card.b-card { border-top-color: var(--accent-amber); }
.abc-card.c-card { border-top-color: var(--accent-emerald); }

.abc-title {
  font-size: 1.02rem;
  font-weight: 700;
  margin-bottom: 0.65rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

/* Data Tables */
.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  background: var(--bg-elevated);
  padding: 0.75rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
}

.filter-group {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.search-input {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  padding: 0.42rem 0.8rem;
  border-radius: 8px;
  font-size: 0.84rem;
  min-width: 220px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-default);
  border-radius: 12px;
  margin: 1rem 0;
}

table.inst-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  text-align: left;
}

table.inst-table th {
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-weight: 700;
  padding: 0.78rem 0.9rem;
  border-bottom: 1px solid var(--border-default);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

table.inst-table th:hover {
  color: var(--accent-cyan);
}

table.inst-table td {
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  vertical-align: top;
}

table.inst-table tr:hover td {
  background: rgba(59, 130, 246, 0.05);
}

.num-col {
  font-family: var(--font-mono);
  text-align: right;
  white-space: nowrap;
}

/* Chart Containers */
.chart-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: 14px;
  padding: 1.35rem;
  margin: 1.5rem 0;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.chart-title {
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--text-primary);
}

.chart-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.chart-img-wrap {
  text-align: center;
  margin-top: 0.75rem;
}

.chart-img-wrap img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--border-default);
}

/* Interactive Calculators & Cards */
.calc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.15rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: 12px;
  padding: 1.25rem;
  margin: 1.25rem 0;
}

.calc-control label {
  display: flex;
  justify-content: space-between;
  font-size: 0.83rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--text-secondary);
}

.calc-control input[type="range"] {
  width: 100%;
  accent-color: var(--accent-cyan);
}

/* Hypothesis & Red Team Cards */
.cards-2col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 1.15rem;
  margin: 1rem 0;
}

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

.hypo-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: 12px;
  padding: 1.25rem;
}

.hypo-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.hypo-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.evidence-list {
  list-style: none;
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

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

/* Callout Box */
.callout-box {
  background: rgba(59, 130, 246, 0.09);
  border-left: 4px solid var(--accent-blue);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin: 1.15rem 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.callout-box.warn {
  background: rgba(245, 158, 11, 0.09);
  border-left-color: var(--accent-amber);
}

.callout-box.emerald {
  background: rgba(16, 185, 129, 0.09);
  border-left-color: var(--accent-emerald);
}

/* Source Cards Grid */
.source-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 0.9rem;
  margin-top: 1rem;
}

.source-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: 10px;
  padding: 0.95rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  transition: border-color 0.15s ease;
}

.source-card:hover {
  border-color: var(--accent-cyan);
}

.source-title {
  font-size: 0.87rem;
  font-weight: 700;
  color: var(--text-primary);
}

.source-url {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--accent-cyan);
  word-break: break-all;
}

.footer-note {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.82rem;
  border-top: 1px solid var(--border-subtle);
  margin-top: 3rem;
}
