:root {
  color-scheme: dark;
  --bg: #0a0e15;
  --text: #f5f3f8;
  --muted: #c6c3ce;
  --coral: #ff7849;
  --amber: #ffb020;
  --gutter: clamp(20px, 4vw, 76px);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 400 14px/1.5 Inter, ui-sans-serif, system-ui, sans-serif;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 24px;
  padding: 12px var(--gutter);
}

.brand { flex: none; }
.brand-logo-link { display: block; }
.brand-logo-full { display: block; width: clamp(112px, 12vw, 166px); height: auto; }

.site-nav {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 4px clamp(12px, 2vw, 25px);
}

.nav-link, .map-language {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  color: var(--muted);
  font-size: .86rem;
  text-decoration: none;
}
.map-language { padding-inline: 5px; color: var(--text); font-weight: 700; }

a:hover, summary:hover { color: var(--coral); }
:where(a, button, summary):focus-visible { outline: 2px solid var(--coral); outline-offset: 3px; }

.map-layout {
  display: grid;
  grid-template-columns: minmax(150px, 22%) minmax(0, 1fr) minmax(190px, 23%);
  grid-template-rows: minmax(max(540px, calc(100svh - 94px)), auto);
}

.map-stage {
  position: relative;
  grid-row: 1;
  grid-column: 1 / -1;
  min-width: 0;
  overflow: hidden;
}

#globe { position: absolute; inset: 0; overflow: hidden; }
#globe.is-static::before {
  content: "";
  position: absolute;
  width: min(50%, calc(100svh - 240px), 650px);
  min-width: min(44vw, 320px);
  aspect-ratio: 1;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #343d4f, #1d2532 48%, #10151e 76%);
  box-shadow: 0 0 44px #8193bd20;
}

.load-status {
  position: absolute;
  inset: auto 23% 60px;
  margin: 0;
  color: var(--muted);
  text-align: center;
  font-size: .76rem;
  pointer-events: none;
}
.load-status.hidden, .empty-state:empty { display: none; }

.controls {
  position: absolute;
  bottom: 13px;
  left: var(--gutter);
  right: var(--gutter);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
}
.controls .button {
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: .8rem;
  min-height: 40px;
  padding: 4px 0;
  cursor: pointer;
}
.controls .button:hover:not(:disabled), .controls .button.active { color: var(--coral); }
.controls .button:disabled { cursor: default; opacity: .55; }

.left-panel, .right-panel {
  z-index: 1;
  grid-row: 1;
  align-self: start;
  min-width: 0;
}
.left-panel { grid-column: 1; margin: 24px 0 68px var(--gutter); }
.right-panel { grid-column: 3; margin: clamp(72px, 12vh, 116px) var(--gutter) 65px 0; }
.section-title h1, .section-title h2 { margin: 0; line-height: 1.25; }
.section-title h1 { font-size: clamp(1.12rem, 2vw, 1.56rem); }
.section-title h2 { font-size: .91rem; }
.source-state { margin: 5px 0 24px; color: var(--muted); font-size: .76rem; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px clamp(8px, 1.5vw, 24px);
}
.stat { display: flex; flex-direction: column-reverse; }
.stat:first-child { grid-column: 1 / -1; margin: 0 0 8px; }
.stat small { color: var(--muted); font-size: .76rem; }
.stat strong { font-size: clamp(1.12rem, 2vw, 1.7rem); line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat:first-child strong { font-size: clamp(2.5rem, 5.8vw, 5rem); line-height: 1; margin-bottom: 5px; }

.legend { margin-top: 22px; color: var(--muted); font-size: .74rem; }
.legend p { margin: 0 0 6px; }
#categoryLegend { display: flex; flex-wrap: wrap; gap: 3px 10px; list-style: none; padding: 0; margin: 0 0 8px; }
.category-item, .legend-row { display: flex; align-items: center; gap: 5px; }
.legend-row { flex-wrap: wrap; justify-content: space-between; }
.category-dot, .feed-icon { width: 7px; height: 7px; flex: none; border-radius: 50%; }

.source-timing { margin: 8px 0; color: var(--muted); font-size: .72rem; }
.source-timing div { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 8px; }
.source-timing dd { margin: 0; }
.empty-state { color: var(--muted); font-size: .76rem; margin: 6px 0; }

.table, .feed { display: grid; gap: 5px; }
.country-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 8px;
  align-items: start;
  font-size: .8rem;
}
.country-meta { display: contents; }
.country-meta b { font-weight: 500; }
.country-meta span { grid-column: 1 / -1; grid-row: 2; height: 2px; background: #40404a; }
.country-meta i { display: block; height: 100%; background: var(--amber); }
.country-value { grid-column: 2; grid-row: 1; font-weight: 700; font-variant-numeric: tabular-nums; }

.recent-title { margin: 16px 0 6px; }
.feed-item { display: flex; align-items: baseline; gap: 7px; font-size: .76rem; }
.feed-item b { font-weight: 500; }
.feed-item div span { display: block; color: var(--muted); }

.footer-note { margin-top: 14px; color: var(--muted); font-size: .74rem; }
.footer-note p { margin: 0 0 6px; }
.footer-note summary { color: var(--text); cursor: pointer; }
.footer-note details p { margin-top: 5px; }

.quito-marker { width: 1px; height: 1px; pointer-events: none; }
.quito-marker::before { content: ""; position: absolute; inset: -2px; border: 1px solid var(--text); border-radius: 50%; background: var(--amber); }
.quito-caption { position: absolute; top: 8px; left: 9px; white-space: nowrap; line-height: 1.3; text-shadow: 0 1px 4px #000, 0 1px 4px #000; }
.quito-caption strong, .quito-caption span { display: block; font-size: 10px; }

@media (max-width: 980px) {
  .topbar { gap: 4px 12px; }
  .map-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; }
  .left-panel, .map-stage, .right-panel { grid-column: 1; grid-row: auto; }
  .left-panel { margin: 20px var(--gutter) 0; }
  .source-state { margin-bottom: 12px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:first-child { grid-column: auto; margin: 0; }
  .stat:first-child strong { font-size: clamp(1.6rem, 7vw, 2.5rem); }
  .legend { margin-top: 14px; }
  .legend-row { justify-content: flex-start; }
  .map-stage { min-height: clamp(320px, 82vw, 500px); }
  #globe { inset: 0 0 42px; }
  #globe.is-static::before { width: min(65%, 390px); min-width: 0; max-height: 100%; }
  .load-status { inset: auto 12px 46px; }
  .controls { bottom: 0; }
  .right-panel { margin: 18px var(--gutter) 35px; }
}

@media (max-width: 600px) {
  .site-nav { flex-basis: 100%; order: 1; justify-content: flex-start; }
  .map-language { margin-left: auto; }
}
