/* -------------------------------------------------------------------------
 * AI Labor Displacement Dashboard — Stylesheet
 * Clean, minimal, responsive.  Dark text on light background.
 * ------------------------------------------------------------------------- */

:root {
  --bg: #f7f8fa;
  --card-bg: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --border: #e0e3e8;
  --accent: #4a6fa5;
  --accent-light: #e8f0fa;
  --accent-dark: #3a5a8a;
  --trend-up: #2e7d32;
  --trend-down: #c62828;
  --trend-flat: #757575;
  --conf-measured: #2e7d32;
  --conf-extracted: #f57f17;
  --conf-unknown: #999;
  --error-bg: #fef2f2;
  --error-border: #fecaca;
  --error-text: #c62828;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-hover: 0 2px 8px rgba(0,0,0,0.12);
  --radius: 8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ===========================  Navbar  =================================== */

.navbar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar-brand {
  font-weight: 700;
  font-size: 1rem;
  color: var(--accent);
  white-space: nowrap;
}
.navbar a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}
.navbar a:hover {
  background: var(--accent-light);
  color: var(--accent);
}
.navbar a.active {
  color: var(--accent);
  font-weight: 600;
}

/* ===========================  Layout  =================================== */

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}
.page-header {
  margin-bottom: 1.5rem;
}
.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
}
.page-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

/* ===========================  Freshness badge  ========================== */

.freshness-badge {
  display: inline-block;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 10px;
  margin-top: 0.5rem;
}
.freshness-badge.freshness-stale {
  border-color: #f0b400;
  color: #b8860b;
}
.section-header {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 2rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
}
.section-header:first-child {
  margin-top: 0;
}

/* ========================  Scenario hero  =============================== */

.scenario-hero {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 2rem;
}
.hero-title {
  font-size: 1.25rem;
  font-weight: 700;
}
.hero-subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

/* ========================  Scenario donut chart  ======================= */

.scenario-donut {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0 auto 1.5rem;
  max-width: 320px;
}
.scenario-donut.scenario-donut-empty {
  padding: 1.5rem 1rem;
  text-align: center;
}
.scenario-donut .no-data {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.85rem;
}
.scenario-donut-svg {
  width: 100%;
  max-width: 320px;
  height: auto;
  display: block;
}
.scenario-donut-group .scenario-arc {
  stroke: var(--card-bg);
  stroke-width: 1.5px;
  transition: opacity 0.18s ease;
}
.scenario-donut-center {
  pointer-events: none;
}
.scenario-donut-center-label {
  font-size: 13px;
  font-weight: 600;
  fill: var(--text);
}
.scenario-donut-center-pct {
  font-size: 22px;
  font-weight: 700;
  fill: var(--accent);
}

/* Legend */
.scenario-legend {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.5rem;
  width: 100%;
  max-width: 320px;
}
.scenario-legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.4rem;
  border-radius: 4px;
  font-size: 0.85rem;
  transition: background 0.15s ease;
}
.scenario-legend-item:hover,
.scenario-legend-item.active {
  background: var(--accent-light);
}
.scenario-legend-dot {
  flex: 0 0 12px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}
.scenario-legend-label {
  flex: 1 1 auto;
  font-weight: 500;
  color: var(--text);
}
.scenario-legend-pct {
  flex: 0 0 auto;
  font-weight: 700;
  color: var(--accent);
}

/* Hover tooltip */
.scenario-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(26, 26, 46, 0.92);
  color: #fff;
  border-radius: 6px;
  padding: 0.5rem 0.7rem;
  font-size: 0.78rem;
  line-height: 1.35;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
  max-width: 240px;
  z-index: 20;
}
.scenario-tooltip-name {
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 2px;
}
.scenario-tooltip-sub {
  color: #cbd5e1;
  font-size: 0.72rem;
  margin-bottom: 2px;
}
.scenario-tooltip-pct {
  font-weight: 700;
  color: #fbbf24;
  margin-bottom: 3px;
}
.scenario-tooltip-tagline {
  color: #e2e8f0;
  margin-bottom: 3px;
}
.scenario-tooltip-displacement {
  color: #94a3b8;
  font-size: 0.72rem;
}

.triggered-section {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}
.triggered-section h3 {
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}
.triggered-list {
  list-style: none;
}
.triggered-item {
  padding: 0.75rem;
  background: #fafbfc;
  border-radius: 6px;
  margin-bottom: 0.5rem;
  border-left: 3px solid var(--accent);
}
.triggered-item-head {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  margin-bottom: 4px;
}
.triggered-indicator {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--accent);
}
.triggered-name {
  font-size: 0.85rem;
}
.triggered-item-body {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.triggered-explanation {
  font-size: 0.8rem;
  color: var(--text);
}
.no-triggered {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-style: italic;
}

/* ====================  Monitored indicators section  ==================== */

.monitored-section {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}
.monitored-section h3 {
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}
.monitored-caption {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0 0 0.75rem 0;
}

/* Constrained-width card grid for monitored indicators */
.monitored-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.75rem;
}
.monitored-card {
  padding: 0.75rem;
  background: #fafbfc;
  border-radius: 6px;
  border-left: 3px solid #10b981; /* monitoring green by default */
}
.monitored-card-triggered {
  border-left-color: #dc2626; /* triggered red */
  background: #fef2f2;
}
.monitored-card-head {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 4px;
}
.monitored-card-head .monitored-name {
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.3;
  flex: 1 1 auto;
}
.monitored-card-body {
  display: flex;
  gap: 0.75rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.monitored-explanation {
  font-size: 0.78rem;
  color: var(--text);
  margin: 0;
}
.monitored-note {
  font-size: 0.76rem;
  color: var(--text-muted);
  font-style: italic;
  margin: 0;
}

/* Tooltip wrapper around the Monitoring pill */
.status-badge-wrap {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
}
.monitored-tooltip {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  bottom: 100%;
  right: 0;
  z-index: 20;
  margin-bottom: 6px;
  padding: 0.4rem 0.65rem;
  background: #1a1a2e;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 400;
  white-space: nowrap;
  border-radius: 5px;
  box-shadow: var(--shadow-hover);
  transition: opacity 0.15s ease, visibility 0.15s ease;
  pointer-events: none;
}
.status-badge-wrap:hover .monitored-tooltip,
.status-badge-wrap:focus .monitored-tooltip {
  visibility: visible;
  opacity: 1;
}
.monitored-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  right: 8px;
  border: 5px solid transparent;
  border-top-color: #1a1a2e;
}

/* Status badges — green "Monitoring", red "Triggered" */
.status-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  padding: 2px 8px;
  border-radius: 9999px;
  white-space: nowrap;
}
.status-monitoring {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}
.status-triggered {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

/* ==========================  Card grid  ================================= */

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

/* ============================  Cards  =================================== */

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  transition: box-shadow 0.15s;
}
.card:hover {
  box-shadow: var(--shadow-hover);
}

.metric-card {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.metric-id {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.card-title {
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
}
.card-value-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}
.card-value {
  font-size: 1.5rem;
  font-weight: 700;
}
.trend {
  font-size: 1rem;
}
.trend-up   { color: var(--trend-up); }
.trend-down { color: var(--trend-down); }
.trend-flat { color: var(--trend-flat); }

.card-sparkline {
  width: 100%;
  height: 32px;
  margin: 0.5rem 0;
}

.card-timeseries {
  width: 100%;
  height: 80px;
  margin: 0.5rem 0;
}
.card-read {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.card-as-of {
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 4px;
  margin-top: auto;
}

/* =======================  Confidence icons  ============================= */

.conf {
  font-size: 0.85rem;
  font-weight: 700;
  cursor: help;
}
.conf-measured  { color: var(--conf-measured); }
.conf-extracted { color: var(--conf-extracted); }
.conf-unknown   { color: var(--conf-unknown); }
.conf-estimated { color: #7c4fd6; }

/* =======================  Estimated-confidence cards (R15)  =========== */

/* Cards with estimated data get a dashed left border and lighter opacity */
.metric-card.confidence-estimated {
  border-left: 4px dashed #b89df5;
  opacity: 0.85;
}
.metric-card.confidence-estimated .card-value {
  color: #7c4fd6;
}

/* Inline badge shown next to the value on estimated cards */
.estimated-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #7c4fd6;
  background: #f0eaff;
  border: 1px solid #d4c8f5;
  border-radius: 3px;
  padding: 1px 5px;
  cursor: help;
}

/* =========================  Error banner  =============================== */

.error-banner {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error-text);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

/* =======================  Metro explorer  =============================== */

.metro-controls {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.metro-controls label {
  font-size: 0.85rem;
  font-weight: 600;
}
.metro-controls select {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.85rem;
  background: var(--card-bg);
  color: var(--text);
  cursor: pointer;
}

table.metro-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
table.metro-table th {
  background: #f0f2f5;
  text-align: left;
  padding: 0.6rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
table.metro-table th:hover {
  background: #e8ebef;
}
table.metro-table th.sorted-asc::after  { content: ' \25B2'; }
table.metro-table th.sorted-desc::after { content: ' \25BC'; }
table.metro-table td {
  padding: 0.55rem 0.8rem;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}
table.metro-table tr {
  cursor: pointer;
  transition: background 0.1s;
}
table.metro-table tr:hover {
  background: #f7f8fa;
}
table.metro-table .metro-name-cell {
  font-weight: 600;
}

/* Shading classes for choropleth-like background tinting */
.shade-0 { background: #ffffff; }
.shade-1 { background: #eef4fb; }
.shade-2 { background: #d4e4f4; }
.shade-3 { background: #a8c8e6; }
.shade-4 { background: #6a98cf; }
.shade-5 { background: #4a6fa5; color: #fff; }

/* ===========================  Modal  ==================================== */

.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}
.modal {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  max-width: 700px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 1.5rem;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.modal-header h2 {
  font-size: 1.2rem;
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0;
  line-height: 1;
}
.modal-close:hover {
  color: var(--text);
}
.modal-body {}
.modal-metric-row {
  display: flex;
  justify-content: space-between;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.modal-metric-row:last-child {
  border-bottom: none;
}
.modal-metric-name {
  color: var(--text-muted);
}
.modal-metric-value {
  font-weight: 600;
}
.modal-loading, .modal-no-data {
  color: var(--text-muted);
  font-style: italic;
  padding: 1rem 0;
}

/* ========================  Community page  ============================== */

.community-input {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  align-items: center;
}
.community-input label {
  font-size: 0.9rem;
  font-weight: 600;
}
.community-input input {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 1rem;
  width: 140px;
}
.community-input input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
}
.community-input button {
  padding: 0.5rem 1.25rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.community-input button:hover {
  background: var(--accent-dark);
}
.community-input button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.community-header {
  margin-bottom: 1.5rem;
}
.community-copy {
  font-size: 1rem;
}
.community-split {
  font-size: 0.85rem;
  color: var(--conf-extracted);
  font-style: italic;
  margin-top: 0.25rem;
}

.community-grid {
  grid-template-columns: repeat(3, 1fr);
}
.community-card h3 {
  font-size: 1rem;
  margin-bottom: 0.25rem;
}
.geo-label {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--accent);
}
.geo-code {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: monospace;
  margin-top: -0.25rem;
}
.cadence-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  font-style: italic;
}
.community-metrics {}
.community-metric-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  gap: 0.5rem;
}
.community-metric-row:last-child {
  border-bottom: none;
}
.cm-name {
  color: var(--text-muted);
  flex: 1;
}
.cm-value {
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}
.loading, .no-data {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-style: italic;
}
.no-data-inline {
  color: var(--text-muted);
}

/* =======================  Responsive  =================================== */

@media (max-width: 1024px) and (min-width: 769px) {
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .card-grid,
  .community-grid {
    grid-template-columns: 1fr;
  }
  .container {
    padding: 1rem;
  }
  .navbar {
    padding: 0 1rem;
    gap: 0.75rem;
    overflow-x: auto;
  }
  .navbar a {
    font-size: 0.8rem;
    padding: 0.4rem 0.5rem;
    white-space: nowrap;
  }
  .scenario-hero {
    padding: 1rem;
  }
  table.metro-table {
    font-size: 0.75rem;
  }
  table.metro-table th,
  table.metro-table td {
    padding: 0.4rem 0.5rem;
  }
  .card-value {
    font-size: 1.25rem;
  }
  .community-input input {
    width: 120px;
  }
}

/* ========================  Learn More page  ============================== */

/* Scenario definitions */
.scenario-definitions-section {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.scenario-toggles-row {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.scenario-definitions-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
  color: var(--accent);
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s;
}

.scenario-definitions-toggle:hover {
  background: var(--accent-light);
  border-color: var(--accent);
}

.scenario-definitions-content {
  margin-top: 1rem;
}

.methodology-note {
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text-muted);
  padding: 0.75rem 1rem;
  background: #f7f8fa;
  border-radius: 4px;
  border-left: 3px solid var(--accent);
}

.scenario-focus {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 1rem;
  padding: 0.5rem 0.75rem;
  background: #f7f8fa;
  border-radius: 4px;
}

.scenario-definition-card {
  padding: 0.75rem;
  background: #fafbfc;
  border-radius: 6px;
  margin-bottom: 0.75rem;
  border-left: 3px solid var(--accent);
}

.scenario-definition-card h4 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.scenario-tagline {
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.scenario-definition-card p {
  font-size: 0.85rem;
  line-height: 1.4;
  margin-bottom: 0.5rem;
}

.scenario-timeline,
.scenario-impact {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.scenario-signals ul {
  list-style: disc;
  padding-left: 1.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.scenario-methodology-plain {
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.45;
  margin-top: 1rem;
  padding: 0.6rem 0.75rem;
  background: #f0f4fa;
  border-left: 3px solid var(--accent);
  border-radius: 4px;
}

.scenario-methodology {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: #f7f8fa;
  border-radius: 4px;
}

.outlook-gauge-container {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.outlook-gauge {
  width: 100%;
}

.gauge-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 1rem;
}
.gauge-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
}
.gauge-assessed {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.gauge-bar-container {
  padding: 0 0.5rem;
}

.gauge-labels {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.gauge-label-left,
.gauge-label-right {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}
.gauge-label-left {
  color: #c62828;
}
.gauge-label-right {
  color: #2e7d32;
}

.gauge-track {
  position: relative;
  width: 100%;
  height: 28px;
  background: #eef0f4;
  border-radius: 14px;
  overflow: visible;
}

.gauge-gradient {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(90deg, #c62828 0%, #f57f17 50%, #2e7d32 100%);
  border-radius: 14px;
  opacity: 0.15;
}

.gauge-marker {
  position: absolute;
  top: -4px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 2;
}

.gauge-marker-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}

.gauge-marker-label {
  position: absolute;
  top: 28px;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}

.gauge-score {
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  margin-top: 1.75rem;
  color: var(--text);
}

.gauge-meta {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.gauge-breakdown {
  font-style: italic;
}

/* ---- Filters ---- */

.learn-filters {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.filter-btn {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.filter-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.filter-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ---- Resource cards ---- */

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

.learn-resource-card {
  display: flex;
  flex-direction: column;
  border-left: 4px solid var(--border);
}
.learn-resource-card.perspective-optimistic,
.learn-resource-card.perspective-boomer {
  border-left-color: #2e7d32;
}
.learn-resource-card.perspective-pessimistic,
.learn-resource-card.perspective-doomer {
  border-left-color: #c62828;
}
.learn-resource-card.perspective-neutral {
  border-left-color: #f57f17;
}

.resource-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.resource-perspective {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
}
.perspective-tag-optimistic,
.perspective-tag-boomer {
  background: #e8f5e9;
  color: #2e7d32;
}
.perspective-tag-pessimistic,
.perspective-tag-doomer {
  background: #ffebee;
  color: #c62828;
}
.perspective-tag-neutral {
  background: #fff8e1;
  color: #f57f17;
}

.resource-category {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.resource-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  line-height: 1.3;
}
.resource-title a {
  color: var(--text);
  text-decoration: none;
}
.resource-title a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.resource-authors {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.resource-meta {
  display: flex;
  gap: 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.resource-org {
  font-weight: 500;
}
.resource-year {
  font-weight: 500;
}

.resource-summary {
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.45;
  margin-top: 0.25rem;
}

@media (max-width: 600px) {
  .learn-resource-grid {
    grid-template-columns: 1fr;
  }
  .gauge-marker-label {
    font-size: 0.7rem;
  }
}

/* ========================  Metro Impact Heatmap  ========================= */

.heatmap-section {
  margin-bottom: 2rem;
}

.heatmap-controls {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.heatmap-legend .legend-label {
  font-weight: 600;
  font-size: 0.75rem;
  white-space: nowrap;
}

.heatmap-legend .legend-gradient {
  width: 240px;
  height: 16px;
  border-radius: 8px;
  background: linear-gradient(90deg,
    #ffc878 0%,
    #e8782c 50%,
    #b42020 100%);
}

.heatmap-summary {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  font-style: italic;
}

/* ========================  Learn More search  ============================= */

.learn-search-section {
  margin-bottom: 2rem;
}

.search-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.search-bar input {
  flex: 1;
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s;
}

.search-bar input:focus {
  border-color: var(--accent);
}

.search-bar button {
  padding: 0.6rem 1.5rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.search-bar button:hover {
  background: var(--accent-dark);
}

.search-clear-btn {
  background: var(--border) !important;
  color: var(--text) !important;
}
.search-clear-btn:hover {
  background: #ccc !important;
}

.search-result-count {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.search-result-item {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.search-result-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

.search-result-title {
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
}

.search-result-title:hover {
  color: var(--accent);
  text-decoration: underline;
}

.search-result-snippet {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  line-height: 1.4;
}

.search-result-snippet mark {
  background: #fff3cd;
  color: var(--text);
  padding: 1px 2px;
  border-radius: 2px;
}

/* ========================  Column info icons  =========================== */

.col-info-icon {
  display: inline-block;
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: help;
  vertical-align: super;
  margin-left: 2px;
  opacity: 0.6;
  transition: opacity 0.15s, color 0.15s;
}
.col-info-icon:hover {
  opacity: 1;
  color: var(--accent);
}

/* ========================  Metro Impact Heatmap (US Map)  =============== */

.heatmap-section {
  margin-bottom: 2rem;
}

.heatmap-controls {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.heatmap-legend .legend-label {
  font-weight: 600;
  font-size: 0.75rem;
  white-space: nowrap;
}

.heatmap-legend .legend-gradient {
  width: 240px;
  height: 16px;
  border-radius: 8px;
  background: linear-gradient(90deg,
    #ffc878 0%,
    #e8782c 50%,
    #b42020 100%);
}

.heatmap-summary {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  font-style: italic;
}

.heatmap-map {
  position: relative;
  background: #1a1a2e;
  border: 1px solid #2a2a4e;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.5rem;
  margin-bottom: 1rem;
  transition: opacity 0.2s ease;
}

/* Loading skeleton for first load */
.heatmap-loading-skeleton {
  text-align: center;
  padding: 1rem;
}

.heatmap-skeleton-map {
  width: 100%;
  max-width: 960px;
  aspect-ratio: 16 / 10;
  margin: 0 auto 0.75rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
}

.heatmap-skeleton-map::before {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 100%; height: 100%;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(74, 111, 165, 0.08) 50%,
    transparent 100%);
  animation: heatmap-shimmer 1.5s infinite;
}

@keyframes heatmap-shimmer {
  0%   { left: -100%; }
  100% { left: 200%; }
}

.heatmap-svg {
  width: 100%;
  height: auto;
  display: block;
}

.heatmap-state {
  fill: #2a2a3e;
  stroke: #3a3a5e;
  stroke-width: 0.5;
}

.heatmap-state-border {
  fill: none;
  stroke: #3a3a5e;
  stroke-width: 0.5;
  stroke-linejoin: round;
}

.heatmap-marker {
  transition: r 0.15s, fill-opacity 0.15s, stroke 0.15s;
}

/* Tooltip for map markers */
.heatmap-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(26, 26, 46, 0.92);
  color: #fff;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.8rem;
  z-index: 10;
  white-space: nowrap;
  transition: opacity 0.15s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.heatmap-tooltip .tooltip-name {
  font-weight: 700;
  margin-bottom: 2px;
}

.heatmap-tooltip .tooltip-score {
  font-size: 0.85rem;
}

.heatmap-tooltip .tooltip-rank {
  font-size: 0.7rem;
  color: #aaa;
  margin-top: 2px;
}

/* ========================  Chart tooltips  ============================== */

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(26, 26, 46, 0.92);
  color: #fff;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  font-size: 0.75rem;
  z-index: 10;
  white-space: nowrap;
  transition: opacity 0.1s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  line-height: 1.3;
}

.chart-tooltip-period {
  font-weight: 700;
  font-size: 0.7rem;
  color: #aab;
}

.chart-tooltip-value {
  font-weight: 600;
}

/* ========================  Scenario subtitles  ========================== */

.scenario-subtitle {
  font-size: 0.78rem !important;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: 0.3rem;
  margin-bottom: 0.25rem;
  padding: 0;
}

/* ========================  Responsive heatmap  ========================= */

@media (max-width: 768px) {
  .heatmap-legend .legend-gradient {
    width: 120px;
  }
  .heatmap-map {
    padding: 0.25rem;
  }
  .heatmap-controls .filter-btn {
    font-size: 0.78rem;
    padding: 0.35rem 0.75rem;
  }
}

/* ========================  Dark Heatmap Stage  =========================== */

.heatmap-stage {
  background: #0e0e1a;
  border-radius: 12px;
  padding: 2rem 1.5rem;
  margin: 0 -0.5rem 2rem;
}

.heatmap-stage .section-header {
  color: #f0f0f5;
  border-bottom-color: #2a2a4e;
}

.heatmap-stage .heatmap-controls .filter-btn {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.15);
  color: #c0c0d0;
}

.heatmap-stage .heatmap-controls .filter-btn:hover {
  border-color: rgba(255,255,255,0.3);
  color: #fff;
}

.heatmap-stage .heatmap-controls .filter-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.heatmap-stage .heatmap-legend {
  color: #a0a0b0;
}

.heatmap-stage .heatmap-legend .legend-label {
  color: #c0c0d0;
}

.heatmap-stage .heatmap-legend .legend-gradient {
  border: 1px solid rgba(255,255,255,0.1);
}

.heatmap-stage .heatmap-summary {
  color: #808090;
}

/* ========================  Hero Banner  ================================= */

.hero-banner {
  margin-bottom: 2rem;
  padding: 2rem 0 1.5rem;
  border-bottom: 1px solid var(--border);
}

.hero-banner h1 {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.hero-subtitle {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.hero-stats {
  display: flex;
  gap: 2.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.hero-stat {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.hero-stat-value {
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
}

.hero-stat-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

@media (max-width: 768px) {
  .hero-banner h1 { font-size: 1.5rem; }
  .hero-stat-value { font-size: 1.75rem; }
  .hero-stats { gap: 1.5rem; }
}

/* ========================  Marker Pulse Animation  ====================== */

@keyframes marker-pulse {
  0%, 100% { fill-opacity: 0.85; }
  50% { fill-opacity: 1; }
}

.heatmap-marker.high-impact {
  animation: marker-pulse 2.5s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .heatmap-marker.high-impact { animation: none; }
}

/* ========================  Scenario Button Severity Dots  ================ */

.heatmap-mode-btn[data-mode="A"]::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #dc2626;
  margin-right: 6px;
  vertical-align: middle;
}

.heatmap-mode-btn[data-mode="B"]::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d97706;
  margin-right: 6px;
  vertical-align: middle;
}

.heatmap-mode-btn[data-mode="C"]::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #0891b2;
  margin-right: 6px;
  vertical-align: middle;
}

/* Tint active button with severity color */
.heatmap-mode-btn[data-mode="A"].active {
  background: #991b1b;
  border-color: #991b1b;
}
.heatmap-mode-btn[data-mode="B"].active {
  background: #b45309;
  border-color: #b45309;
}
.heatmap-mode-btn[data-mode="C"].active {
  background: #0e7490;
  border-color: #0e7490;
}

/* ========================  Card Severity Borders  ======================= */

.metric-card.severity-stable {
  border-left: 4px solid #4a6fa5;
}
.metric-card.severity-warming {
  border-left: 4px solid #d97706;
}
.metric-card.severity-hot {
  border-left: 4px solid #dc2626;
}
.metric-card.severity-crisis {
  border-left: 4px solid #991b1b;
}

.card-why {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: 0.25rem;
  padding-top: 0.25rem;
  border-top: 1px solid var(--border);
  font-style: italic;
}

/* ========================  Metro Detail Sidebar  ========================= */

.metro-sidebar {
  position: fixed;
  top: 0;
  right: -480px;
  width: 460px;
  max-width: 90vw;
  height: 100vh;
  background: var(--card-bg);
  box-shadow: -4px 0 24px rgba(0,0,0,0.15);
  z-index: 300;
  transition: right 0.3s ease;
  overflow-y: auto;
  visibility: hidden;
}

.metro-sidebar.open {
  right: 0;
  visibility: visible;
}

.metro-sidebar-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.25);
  z-index: 299;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.metro-sidebar-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.metro-sidebar-content {
  padding: 1.5rem;
}

.metro-sidebar-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0.25rem 0.5rem;
  line-height: 1;
  z-index: 10;
}

.metro-sidebar-close:hover {
  color: var(--text);
}

.metro-sidebar h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  padding-right: 2rem;
}

.metro-sidebar-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.metro-sidebar-section {
  margin-bottom: 1.5rem;
}

.metro-sidebar-section h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--border);
}

.metro-sidebar-metric-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  gap: 1rem;
}

.metro-sidebar-metric-row:last-child {
  border-bottom: none;
}

.metro-sidebar-metric-name {
  color: var(--text);
  font-weight: 500;
  flex: 1;
}

.metro-sidebar-metric-why {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
  line-height: 1.35;
}

.metro-sidebar-metric-value {
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
  flex-shrink: 0;
}

.metro-sidebar-metric-row.null-data .metro-sidebar-metric-value {
  color: var(--text-muted);
}

@media (max-width: 768px) {
  .metro-sidebar {
    width: 100vw;
    right: -100vw;
  }
}