:root {
  --page-bg: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f2f1ec;
  --border: rgba(11, 11, 11, 0.10);
  --border-strong: rgba(11, 11, 11, 0.18);
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --axis: #c3c2b7;
  --accent: #2a78d6;
  --accent-soft: #cde2fb;
  --good: #0ca30c;
  --warning: #fab219;
  --critical: #d03b3b;
  --radius-lg: 18px;
  --radius-md: 12px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { color-scheme: light; }

body {
  margin: 0;
  background: var(--page-bg);
  color: var(--text-primary);
  min-height: 100vh;
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 420px;
  background: radial-gradient(ellipse 900px 420px at 50% -10%, rgba(42, 120, 214, 0.08), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

header.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(249, 249, 247, 0.82);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px 0 24px;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  max-width: 1280px;
  margin: 0 auto;
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, #2a78d6, #1baf7a);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  box-shadow: 0 2px 8px rgba(42, 120, 214, 0.25);
}

.brand-text h1 {
  font-size: 1.02rem;
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: var(--text-primary);
}

.brand-text .brand-sub {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.topbar-actions { display: flex; align-items: center; gap: 14px; }

.live-status {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.76rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--good);
  animation: pulse 2s infinite;
  flex-shrink: 0;
}
.live-dot.refreshing { background: var(--warning); animation: pulse-fast 0.7s infinite; }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(12, 163, 12, 0.4); }
  70% { box-shadow: 0 0 0 6px rgba(12, 163, 12, 0); }
  100% { box-shadow: 0 0 0 0 rgba(12, 163, 12, 0); }
}
@keyframes pulse-fast {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.btn-refresh {
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-family: var(--font);
}
.btn-refresh:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn-refresh:active { transform: scale(0.97); }

nav.tabs {
  max-width: 1280px;
  margin: 16px auto 0 auto;
  display: inline-flex;
  gap: 2px;
  background: var(--surface-2);
  padding: 4px;
  border-radius: 11px;
  border: 1px solid var(--border);
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 8px 18px;
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
  font-family: var(--font);
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { background: var(--surface); color: var(--text-primary); box-shadow: 0 1px 2px rgba(11, 11, 11, 0.06); }

main {
  position: relative;
  z-index: 1;
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 24px 40px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.tab-intro {
  color: var(--text-muted);
  margin: 0 0 16px 0;
  font-size: 0.85rem;
}

/* KPI / stat strip -- the headline numbers a desk actually watches */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.stat-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1.15;
}

.stat-sub {
  font-size: 0.72rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meter {
  height: 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  overflow: hidden;
  margin-top: 4px;
}
.meter-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.4s ease;
  width: 0%;
}

.grid { display: grid; gap: 16px; }
.grid.two-col { grid-template-columns: repeat(2, 1fr); }
.grid.multi-col { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

@media (max-width: 800px) {
  .grid.two-col { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: 1fr; }
  .topbar-inner h1 { font-size: 0.95rem; }
}

.card {
  background: linear-gradient(180deg, var(--surface), var(--surface) 60%, #f5f4f0);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color 0.15s;
}
.card:hover { border-color: var(--border-strong); }

.card.full-width { width: 100%; }

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 10px;
}

.card-title h2 {
  font-size: 0.92rem;
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

.card-kicker {
  display: block;
  font-size: 0.66rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-top: 3px;
  font-weight: 600;
}

.ticker {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--text-secondary);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  letter-spacing: 0.03em;
  margin-left: 8px;
  font-variant-numeric: tabular-nums;
}

.badge {
  font-size: 0.68rem;
  background: var(--surface-2);
  color: var(--text-secondary);
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--border);
}

.country-select {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 0.78rem;
  font-family: var(--font);
}

.chart-wrap { position: relative; height: 230px; }
.chart-wrap.tall { height: 320px; }
.grid.multi-col .chart-wrap { height: 130px; }

.status-line {
  margin-top: 10px;
  font-size: 0.74rem;
  color: var(--text-muted);
  min-height: 1em;
}
.status-line.error { color: var(--critical); }

.legend-note {
  margin: 8px 0 0 0;
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.source-note {
  margin: 12px 0 0 0;
  font-size: 0.66rem;
  color: var(--text-muted);
  opacity: 0.8;
}

footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.72rem;
  padding: 24px;
  position: relative;
  z-index: 1;
}
