/* Global Health Report — mission-control dashboard */
:root {
  --bg0: #070b12;
  --bg1: #0d1522;
  --bg2: #121c2c;
  --line: rgba(160, 190, 220, 0.14);
  --text: #d7e2ef;
  --muted: #8fa3b8;
  --ink: #f3f7fb;
  --ok: #3dba8a;
  --warn: #d4a017;
  --bad: #e35d5d;
  --crit: #ff3b3b;
  --accent: #5ec8ff;
  --amber: #f0b429;
  --font: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --serif: "IBM Plex Serif", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(94, 200, 255, 0.08), transparent 55%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(227, 93, 93, 0.06), transparent 50%),
    linear-gradient(180deg, var(--bg0), var(--bg1) 40%, var(--bg0));
  min-height: 100vh;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 1.25rem 1.25rem 4rem; }

.topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  align-items: baseline;
  border-bottom: 1px solid var(--line);
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
}
.brand {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.35rem;
  color: var(--ink);
  letter-spacing: 0.02em;
}
.tagline { color: var(--muted); font-size: 0.92rem; max-width: 36rem; }
.nav a { margin-left: 1rem; font-size: 0.9rem; color: var(--muted); font-weight: 600; }
.nav a:hover { color: var(--ink); }

.hero {
  display: grid;
  grid-template-columns: 1.35fr 0.9fr;
  gap: 1.5rem;
  align-items: stretch;
  margin-bottom: 2rem;
}
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; }
}

.map-panel {
  background: linear-gradient(160deg, rgba(18, 28, 44, 0.95), rgba(7, 11, 18, 0.92));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.75rem 0.75rem 0.9rem;
  min-width: 0;
}
.map-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 950 / 620;
  border-radius: 10px;
  overflow: hidden;
  background: #070b12;
  border: 1px solid rgba(160, 190, 220, 0.1);
}
.world-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 1;
  filter: none;
  pointer-events: none;
  user-select: none;
}
.world-basemap-host {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: #0a1628;
}
.world-basemap-host svg {
  display: block;
  width: 100%;
  height: 100%;
}
.map-markers {
  position: absolute;
  inset: 0;
  z-index: 2;
}
.map-marker {
  position: absolute;
  width: 14px;
  height: 14px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  cursor: pointer;
  z-index: 3;
  box-shadow: 0 0 0 2px rgba(7, 11, 18, 0.65);
}
.map-marker::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1px solid currentColor;
  opacity: 0.35;
  pointer-events: none;
}
.map-marker.green { background: var(--ok); color: var(--ok); }
.map-marker.yellow { background: var(--warn); color: var(--warn); }
.map-marker.orange { background: #f08a4b; color: #f08a4b; }
.map-marker.red { background: var(--crit); color: var(--crit); }
.map-marker.blink {
  animation: hotspot-pulse 1.6s ease-in-out infinite;
}
@keyframes hotspot-pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  50% { transform: translate(-50%, -50%) scale(1.35); opacity: 0.72; }
}
.map-marker:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 1rem;
  margin-top: 0.65rem;
  font-size: 0.78rem;
  color: var(--muted);
  align-items: center;
}
.map-legend .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.35rem;
  vertical-align: middle;
}
.map-legend .dot.green { background: var(--ok); }
.map-legend .dot.yellow { background: var(--warn); }
.map-legend .dot.orange { background: #f08a4b; }
.map-legend .dot.red { background: var(--crit); }
.map-legend-hint { margin-left: auto; color: var(--accent); font-weight: 600; }

.map-popup {
  position: absolute;
  z-index: 8;
  width: min(320px, calc(100% - 1.5rem));
  max-height: min(70%, 360px);
  overflow: auto;
  background: rgba(10, 16, 26, 0.96);
  border: 1px solid rgba(160, 190, 220, 0.28);
  border-radius: 12px;
  padding: 0.85rem 1rem 1rem;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  color: var(--text);
}
.map-popup[hidden] { display: none !important; }
.map-popup h3 {
  margin: 0.2rem 0 0.15rem;
  font-family: var(--serif);
  font-size: 1.05rem;
  color: var(--ink);
  line-height: 1.25;
}
.map-popup-close {
  position: absolute;
  top: 0.35rem;
  right: 0.45rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}
.map-popup-close:hover { color: var(--ink); }
.map-popup-band {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  border: 1px solid currentColor;
}
.map-popup-band.green { color: var(--ok); }
.map-popup-band.yellow { color: var(--warn); }
.map-popup-band.orange { color: #f08a4b; }
.map-popup-band.red { color: var(--crit); }
.map-popup-region {
  margin: 0.15rem 0 0.55rem;
  color: var(--muted);
  font-size: 0.82rem;
}
.map-popup-why {
  margin: 0 0 0.75rem;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--text);
}
.map-popup-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 0.75rem;
  margin: 0;
  font-size: 0.78rem;
}
.map-popup-meta dt { color: var(--muted); }
.map-popup-meta dd { margin: 0; font-family: var(--mono); color: var(--ink); }

.score-panel h1 {
  font-family: var(--serif);
  font-size: clamp(1.6rem, 3.5vw, 2.1rem);
  margin: 0 0 0.5rem;
  color: var(--ink);
}
.big-score {
  font-family: var(--mono);
  font-size: clamp(2.4rem, 6vw, 3.4rem);
  color: var(--ink);
  line-height: 1.1;
}
.big-score span { color: var(--muted); font-size: 0.45em; }
.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-top: 0.65rem;
  font-size: 0.88rem;
  color: var(--muted);
}
.meta-row strong { color: var(--ink); font-weight: 600; }

.status-STABLE { color: var(--ok); }
.status-ELEVATED { color: #8fd17a; }
.status-STRESSED { color: var(--warn); }
.status-SEVERE { color: #f08a4b; }
.status-CRITICAL, .status-CASCADING_FAILURE { color: var(--crit); }
.delta-up { color: var(--bad); }
.delta-down { color: var(--ok); }

.section { margin: 2rem 0; }
.section h2 {
  font-family: var(--serif);
  font-size: 1.25rem;
  margin: 0 0 0.35rem;
  color: var(--ink);
}
.section .hint { color: var(--muted); font-size: 0.9rem; margin: 0 0 1rem; }

.domain-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
}
.domain-card {
  position: relative;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.85rem 0.9rem;
  cursor: help;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.domain-card:hover,
.domain-card:focus-within,
.domain-card.tip-open {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 25%, transparent);
  z-index: 40;
}
.domain-card .name {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
}
.domain-card .val {
  font-family: var(--mono);
  font-size: 1.35rem;
  color: var(--ink);
  margin-top: 0.2rem;
}
.domain-card .sub { font-size: 0.8rem; color: var(--muted); margin-top: 0.15rem; }

.domain-tip {
  display: none;
  position: absolute;
  left: 0;
  right: auto;
  bottom: calc(100% + 8px);
  min-width: 240px;
  max-width: min(340px, 85vw);
  width: max-content;
  padding: 0.75rem 0.85rem;
  /* Solid panel — never inherit a missing --bg (that made tips see-through). */
  background: #0a101a;
  background: rgba(10, 16, 26, 0.98);
  border: 1px solid rgba(160, 190, 220, 0.35);
  border-radius: 12px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
  z-index: 50;
  pointer-events: auto;
  color: var(--ink);
}
.domain-card:hover .domain-tip,
.domain-card:focus-within .domain-tip,
.domain-card.tip-open .domain-tip {
  display: block;
}
/* Flip tip downward when card is near the top of the grid */
.domain-card:nth-child(-n+4) .domain-tip {
  bottom: auto;
  top: calc(100% + 8px);
}
.domain-tip-hd {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 0.45rem;
}
.domain-tip-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.domain-tip-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: baseline;
  font-size: 0.78rem;
  line-height: 1.3;
  padding: 0.2rem 0;
  border-bottom: 1px solid rgba(160, 190, 220, 0.1);
}
.domain-tip-list li:last-child { border-bottom: 0; }
.domain-tip-list .tip-name {
  color: var(--ink);
  flex: 1;
  min-width: 0;
}
.domain-tip-list .tip-risk {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  font-family: var(--mono);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  flex-shrink: 0;
}
.domain-tip-list .tip-risk:hover,
.domain-tip-list .tip-risk:focus-visible {
  color: var(--ink);
}
.domain-tip-list .tip-risk:disabled {
  color: var(--muted);
  text-decoration: none;
  cursor: default;
}
.domain-tip-ft {
  margin-top: 0.5rem;
  font-size: 0.65rem;
  color: var(--muted);
}

.metric-table tr.metric-flash {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  background: rgba(94, 200, 255, 0.1);
}
.metric-table tr.metric-flash td {
  background: rgba(94, 200, 255, 0.08);
}

.panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 800px) { .panels { grid-template-columns: 1fr; } }

.panel {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem 1.1rem;
}
.panel h3 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  color: var(--ink);
}
.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}
.list li:last-child { border-bottom: 0; }
.mono { font-family: var(--mono); }

.cascade {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  margin-bottom: 0.75rem;
  font-size: 0.88rem;
}
.cascade .node {
  background: rgba(94, 200, 255, 0.1);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
}
.cascade .arrow { color: var(--muted); }

.outlook-section { margin-top: 0.5rem; }
.outlook-headline {
  color: var(--ink);
  font-size: 1.05rem;
  line-height: 1.55;
  margin: 0 0 1.25rem;
  max-width: 52rem;
}
.outlook-panels { margin-bottom: 1rem; }
.outlook-domain, .outlook-channel {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
}
.outlook-domain:last-child, .outlook-channel:last-child { border-bottom: 0; }
.od-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: baseline;
  margin-bottom: 0.35rem;
}
.od-top strong { color: var(--ink); }
.od-delta { color: var(--muted); }
.od-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.85rem;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
}
.od-pressure {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.72rem;
  font-weight: 600;
}
.pressure-rising .od-pressure { color: var(--bad); }
.pressure-easing .od-pressure { color: var(--ok); }
.pressure-stable .od-pressure { color: var(--warn); }
.od-out { color: var(--accent); }
.od-copy {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.45;
}
.outlook-list li span:first-child {
  flex: 1;
  line-height: 1.4;
}

.chart-box {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
  min-height: 260px;
}
.chart-box canvas { width: 100% !important; height: 240px !important; }

.range-btns { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.75rem; }
.range-btns button {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}
.range-btns button.active, .range-btns button:hover {
  color: var(--ink);
  border-color: var(--accent);
}

.analysis .block { margin-bottom: 1rem; }
.analysis .block h4 { margin: 0 0 0.35rem; color: var(--amber); font-size: 0.85rem; letter-spacing: 0.06em; text-transform: uppercase; }
.analysis p { margin: 0; color: var(--text); font-size: 0.92rem; }

.metric-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.metric-table th, .metric-table td {
  text-align: left;
  padding: 0.5rem 0.4rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.metric-table th { color: var(--muted); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }
.metric-table details summary { cursor: pointer; color: var(--accent); }
.metric-detail {
  margin-top: 0.4rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.metric-domains {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.metric-domain {
  background: linear-gradient(160deg, rgba(18, 28, 44, 0.95), rgba(7, 11, 18, 0.92));
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.metric-domain > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1rem;
  color: var(--ink);
  font-weight: 600;
  user-select: none;
}
.metric-domain > summary::-webkit-details-marker { display: none; }
.metric-domain > summary::after {
  content: "+";
  color: var(--muted);
  font-family: var(--mono);
  font-weight: 500;
  font-size: 1.1rem;
  line-height: 1;
}
.metric-domain[open] > summary::after { content: "−"; }
.metric-domain .md-name {
  text-transform: capitalize;
  letter-spacing: 0.02em;
}
.metric-domain .md-meta {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.82rem;
  white-space: nowrap;
}
.metric-domain-body {
  padding: 0 0.65rem 0.65rem;
  overflow-x: auto;
  border-top: 1px solid var(--line);
}

.footer {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
}
.disclaimer {
  margin-top: 0.75rem;
  max-width: 48rem;
  color: var(--muted);
}

.banner-error {
  background: rgba(227, 93, 93, 0.12);
  border: 1px solid rgba(227, 93, 93, 0.35);
  color: #ffb4b4;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}
