:root {
  color-scheme: dark;
  --bg: #0c1217;
  --panel: rgba(17, 26, 33, 0.94);
  --line: rgba(157, 187, 206, 0.18);
  --text: #e7edf2;
  --muted: #9eb2c0;
  --blue: #75b7ff;
  --gold: #d6a95d;
  --red: #ff8f7a;
  --green: #8fd4b2;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: radial-gradient(circle at top, #13212b 0%, var(--bg) 52%);
  color: var(--text);
}

.shell {
  width: min(1280px, calc(100% - 32px));
  margin: 24px auto 48px;
  display: grid;
  gap: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.22);
}

.hero {
  display: grid;
  gap: 18px;
}

.hero h1, .panel h2 { margin: 0; }
.hero h1 { font-size: clamp(2rem, 4vw, 3.4rem); line-height: 0.98; max-width: 900px; }
.lede, .muted, .hero-stats span { color: var(--muted); }
.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: var(--blue);
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.hero-stats > div, .fact, .executive-point, .synthesis-card {
  padding: 16px;
  border-radius: 18px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.05);
  display: grid;
  gap: 4px;
}
.hero-stats strong, .fact strong { font-size: 1.05rem; }
.label, .fact span, .point-kicker { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; }

.grid.top-grid,
.executive-grid {
  display: grid;
  grid-template-columns: 1.3fr 0.7fr;
  gap: 18px;
}

.executive-points {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.next-steps {
  margin: 14px 0 0;
  padding-left: 18px;
  display: grid;
  gap: 12px;
  color: var(--muted);
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.filter-chip {
  appearance: none;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
  color: var(--muted);
  border-radius: 999px;
  padding: 9px 14px;
  cursor: pointer;
  font: inherit;
}

.filter-chip.active {
  background: rgba(117,183,255,0.16);
  border-color: rgba(117,183,255,0.42);
  color: var(--text);
}

#map {
  height: 520px;
  border-radius: 18px;
  overflow: hidden;
  margin-top: 14px;
}

.legend {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.legend-pill {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  color: var(--muted);
  font-size: 0.88rem;
}
.legend-swatch { width: 10px; height: 10px; border-radius: 999px; }
.legend-star {
  color: #ffd76a;
  font-size: 1rem;
  line-height: 1;
}

.subject-star-icon {
  background: transparent;
  border: 0;
}

.subject-star-pin {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: #0c1217;
  font-size: 1.15rem;
  font-weight: 800;
  background: radial-gradient(circle at 35% 35%, #fff3a6 0%, #ffd76a 48%, #f5b94a 100%);
  border: 2px solid rgba(12, 18, 23, 0.7);
  box-shadow: 0 0 0 3px rgba(117, 183, 255, 0.28), 0 8px 18px rgba(0, 0, 0, 0.35);
}

.takeaways {
  margin: 14px 0 0;
  padding-left: 18px;
  display: grid;
  gap: 12px;
  color: var(--muted);
}
.takeaways strong { color: var(--text); }

.subject-grid, .cards, .synthesis-grid {
  display: grid;
  gap: 14px;
}
.subject-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.cards { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.synthesis-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card {
  padding: 18px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.07);
  background: rgba(255,255,255,0.025);
  display: grid;
  gap: 10px;
}
.card h3, .synthesis-card h3 { margin: 0; font-size: 1.05rem; }
.card p, .synthesis-card p, .executive-point p { margin: 0; color: var(--muted); line-height: 1.65; }
.card .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.badge {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  color: var(--text);
  background: rgba(255,255,255,0.06);
}
.badge.subject { background: rgba(117,183,255,0.15); }
.badge.immediate { background: rgba(143,212,178,0.16); }
.badge.nearby { background: rgba(214,169,93,0.15); }
.badge.opposite { background: rgba(255,143,122,0.14); }
.badge.approx { background: rgba(255,255,255,0.08); }

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: #12202a;
  color: var(--text);
}
.leaflet-container a { color: var(--blue); }

@media (max-width: 980px) {
  .grid.top-grid,
  .executive-grid,
  .synthesis-grid { grid-template-columns: 1fr; }
  #map { height: 420px; }
}

.report-card { text-decoration: none; color: inherit; transition: transform 140ms ease, border-color 140ms ease, background 140ms ease; }
.report-card:hover { transform: translateY(-2px); border-color: rgba(117,183,255,0.28); background: rgba(255,255,255,0.045); }
.report-card .badge.nearby { background: rgba(255,255,255,0.08); }
.report-card p { line-height: 1.65; }
.source-note, .value-note { color: var(--muted); line-height: 1.6; font-size: 0.92rem; }
.report-card .source-note a, .panel a { color: var(--blue); }
.report-card .value-note { margin-top: -2px; }


.sparkline { width: 100%; height: 84px; display: block; margin: 0; }
.spark-grid line { stroke: rgba(255,255,255,0.08); stroke-dasharray: 3 5; }
.spark-line { fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.spark-area { opacity: 0.16; }
.spark-blue.spark-line, .spark-dot.spark-blue { stroke: var(--blue); fill: var(--blue); }
.spark-blue.spark-area { fill: var(--blue); }
.spark-green.spark-line, .spark-dot.spark-green { stroke: var(--green); fill: var(--green); }
.spark-green.spark-area { fill: var(--green); }
.spark-gold.spark-line, .spark-dot.spark-gold { stroke: var(--gold); fill: var(--gold); }
.spark-gold.spark-area { fill: var(--gold); }
.spark-red.spark-line, .spark-dot.spark-red { stroke: var(--red); fill: var(--red); }
.spark-red.spark-area { fill: var(--red); }
.spark-dot-start { fill: rgba(255,255,255,0.78); stroke: rgba(255,255,255,0.25); stroke-width: 1.2; }
.spark-label { fill: var(--muted); font-size: 10px; letter-spacing: 0.04em; }
.chart-shell { display: grid; gap: 12px; padding: 14px; border-radius: 18px; background: linear-gradient(180deg, rgba(255,255,255,0.045), rgba(255,255,255,0.02)); border: 1px solid rgba(255,255,255,0.07); }
.chart-shell.compact { padding: 12px; gap: 10px; }
.chart-header, .chart-topline { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.chart-header h3 { margin: 2px 0 0; font-size: 1rem; }
.chart-kicker { color: var(--muted); text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.68rem; margin: 0; }
.delta-pill { display: inline-flex; align-items: center; justify-content: center; min-width: 72px; padding: 8px 10px; border-radius: 999px; font-size: 0.84rem; font-weight: 600; border: 1px solid rgba(255,255,255,0.08); background: rgba(255,255,255,0.05); }
.delta-pill.up { color: #b9efd6; background: rgba(143,212,178,0.14); border-color: rgba(143,212,178,0.28); }
.delta-pill.down { color: #ffc0b4; background: rgba(255,143,122,0.14); border-color: rgba(255,143,122,0.28); }
.delta-pill.flat { color: var(--muted); }
.chart-scale, .trend-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.chart-scale > div, .trend-meta > div { padding: 12px; border-radius: 14px; background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.06); display: grid; gap: 4px; }
.mini-chart { display: grid; gap: 10px; }
.trend-inline { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; color: var(--muted); font-size: 0.84rem; }
.trend-inline span { display: grid; gap: 2px; }
.trend-inline strong { color: var(--text); font-size: 0.86rem; }
.trend-inline em { font-style: normal; color: var(--muted); }
.table-wrap { overflow-x: auto; margin-top: 14px; border-radius: 16px; border: 1px solid rgba(255,255,255,0.06); }
.history-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; background: rgba(255,255,255,0.02); }
.history-table th, .history-table td { text-align: left; padding: 11px 12px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.history-table th { color: var(--muted); font-weight: 600; background: rgba(255,255,255,0.03); }
.history-table td:nth-child(n+2), .history-table th:nth-child(n+2) { text-align: right; font-variant-numeric: tabular-nums; }
.history-table tbody tr:nth-child(even) { background: rgba(255,255,255,0.018); }
.history-table tbody tr:hover { background: rgba(117,183,255,0.05); }
.source-note, .value-note { color: var(--muted); line-height: 1.6; font-size: 0.92rem; }
.report-card .source-note a, .panel a { color: var(--blue); }
.report-card .value-note { margin-top: -2px; }
@media (max-width: 980px) { .trend-meta, .chart-scale, .trend-inline { grid-template-columns: 1fr; } }


.page-nav {
  display: grid;
  gap: 14px;
}

.page-nav-head {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.page-nav-head h2 {
  font-size: clamp(1.25rem, 2vw, 1.7rem);
}

.page-nav-section {
  display: grid;
  gap: 10px;
}

.page-nav-section h3 {
  margin: 0;
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.page-nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
  color: var(--muted);
  text-decoration: none;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease, color 140ms ease;
}

.nav-link:hover {
  transform: translateY(-1px);
  color: var(--text);
  border-color: rgba(117,183,255,0.28);
  background: rgba(117,183,255,0.08);
}

.nav-link.current {
  color: var(--text);
  border-color: rgba(117,183,255,0.36);
  background: rgba(117,183,255,0.14);
}
