:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-dim: #64748b;
  --accent: #4f46e5;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --blue: #2563eb;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding: 0;
}

/* Sticky nav */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 8px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.nav h1 {
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
}

.nav-links {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
}

.nav-links a {
  font-size: 11px;
  color: var(--text-dim);
  text-decoration: none;
  padding: 3px 8px;
  border-radius: 6px;
  transition: all 0.15s;
}

.nav-links a:hover {
  background: var(--bg);
  color: var(--text);
}

/* Mobile: collapse nav links behind toggle */
.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 16px;
  cursor: pointer;
  color: var(--text-dim);
}

@media (max-width: 768px) {
  .nav-toggle { display: block; }
  .nav-links {
    display: none !important;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 8px 16px;
    flex-direction: column;
    gap: 2px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  }
  .nav-links.open { display: flex !important; }
  .nav-links a { padding: 8px 12px; font-size: 13px; }
}

/* Global controls */
.controls {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.controls label {
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}

.controls select,
.controls input[type="range"] {
  font-size: 13px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
}

.controls .toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.controls .toggle button {
  font-size: 12px;
  padding: 4px 12px;
  border: none;
  background: var(--bg);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
}

.controls .toggle button.active {
  background: var(--accent);
  color: white;
}

/* Nav TLD styling */
.nav-tld {
  font-weight: 400;
  color: var(--text-dim);
  font-size: 14px;
}

/* Hero introduction — light background, high contrast */
.hero {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  padding: 32px 24px 24px;
}

.hero-inner {
  max-width: 1400px;
  margin: 0 auto;
}

.hero-headline {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 12px;
  color: var(--text);
}

@media (max-width: 600px) {
  .hero { padding: 20px 16px 16px; }
  .hero-headline { font-size: 22px; margin-bottom: 10px; }
}

.hero-highlight {
  color: var(--red);
  white-space: nowrap;
}

.hero-sub {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-dim);
  margin-bottom: 12px;
}

@media (max-width: 600px) {
  .hero-sub { font-size: 13px; margin-bottom: 8px; }
}

/* Inline stat strip in hero */
.hero-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 16px 0 12px;
}

.hero-stat {
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
}

.hero-stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.hero-stat-value.red { color: var(--red); }
.hero-stat-value.blue { color: var(--blue); }
.hero-stat-value.amber { color: var(--amber); }

.hero-stat-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-top: 2px;
}

@media (max-width: 600px) {
  .hero-stats { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .hero-stat { padding: 8px 10px; }
  .hero-stat-value { font-size: 18px; }
  .hero-stat-label { font-size: 10px; }
}

.hero-sources {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

/* Share buttons */
.share-bar {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 14px;
  flex-wrap: nowrap;
}

.share-bar-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-right: 2px;
  white-space: nowrap;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  text-decoration: none;
  transition: opacity 0.15s;
  flex-shrink: 0;
}

.share-btn svg { width: 16px; height: 16px; fill: currentColor; }
.share-btn:hover { opacity: 0.8; }
.share-btn-x { background: #000; color: #fff; }
.share-btn-fb { background: #1877f2; color: #fff; }
.share-btn-li { background: #0a66c2; color: #fff; }
.share-btn-wa { background: #25d366; color: #fff; }
.share-btn-rd { background: #ff4500; color: #fff; }
.share-btn-em { background: var(--text-dim); color: #fff; }
.share-btn-copy { background: #e2e8f0; color: var(--text-dim); cursor: pointer; border: none; }
.share-btn-copy svg { width: 14px; height: 14px; }

/* Main content */
.content {
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
}

/* Section headers */
.section {
  margin-bottom: 32px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 16px;
}

.section-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.section-header .subtitle {
  font-size: 12px;
  color: var(--text-dim);
}

/* KPI strip */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 32px;
}

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  text-align: center;
}

.kpi-card .kpi-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.kpi-card .kpi-value {
  font-size: 24px;
  font-weight: 700;
}

.kpi-card .kpi-value.green { color: var(--green); }
.kpi-card .kpi-value.red { color: var(--red); }
.kpi-card .kpi-value.amber { color: var(--amber); }
.kpi-card .kpi-value.blue { color: var(--blue); }

/* Info icons */
.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-dim);
  font-size: 9px;
  font-weight: 700;
  font-style: italic;
  cursor: help;
  margin-left: 4px;
  vertical-align: middle;
  position: relative;
}

.info-icon:hover {
  background: var(--accent);
  color: white;
}

.info-icon:hover::after {
  content: attr(title);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: white;
  font-size: 12px;
  font-weight: 400;
  font-style: normal;
  text-transform: none;
  letter-spacing: 0;
  line-height: 1.4;
  padding: 10px 14px;
  border-radius: 8px;
  width: 260px;
  z-index: 200;
  pointer-events: none;
  white-space: normal;
}

.info-icon:hover::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--text);
  z-index: 200;
}

/* Chart cards */
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 24px;
}

.chart-card h3 {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
}

.chart-card-featured {
  border: 2px solid var(--accent);
  box-shadow: 0 4px 24px rgba(79, 70, 229, 0.08);
}

.chart-card .chart-explainer {
  font-size: 13px;
  color: var(--text-dim);
  margin: -8px 0 16px;
  line-height: 1.5;
}

.chart-card canvas {
  width: 100% !important;
  max-height: 560px;
}

/* Two-column layout */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
}

/* Data table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 12px;
  border-bottom: 2px solid var(--border);
}

.data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.data-table tr:hover td {
  background: var(--bg);
}

.data-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.data-table .desc {
  font-size: 12px;
  color: var(--text-dim);
  max-width: 400px;
}

.data-freshness {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 12px;
  text-align: right;
}

/* Caveats panel */
.caveats {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 10px;
  padding: 20px;
  margin-top: 32px;
}

.caveats h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--amber);
  margin-bottom: 12px;
}

.caveats ul {
  font-size: 13px;
  color: #92400e;
  padding-left: 20px;
}

.caveats li {
  margin-bottom: 6px;
}

.caveats .sources {
  margin-top: 12px;
  font-size: 12px;
  color: #92400e;
}

/* Chart controls (toggle buttons) */
.chart-controls {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}

.chart-toggle {
  font-size: 12px;
  padding: 5px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
}

.chart-toggle:hover { color: var(--text); }
.chart-toggle.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* Country detail stats */
.country-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

@media (max-width: 600px) {
  .country-stats { grid-template-columns: repeat(2, 1fr); }
}

.country-stat {
  background: var(--bg);
  border-radius: 8px;
  padding: 12px;
}

.country-stat-value {
  font-size: 24px;
  font-weight: 700;
}

.country-stat-label {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* Reference data cards */
.ref-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 1100px) {
  .ref-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
  .ref-grid { grid-template-columns: 1fr; }
}

.ref-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}

.ref-stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.ref-stat-label {
  font-size: 13px;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 6px;
}

.ref-stat-context {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.4;
}

.ref-context-box {
  margin-top: 16px;
  padding: 14px 18px;
  background: #f1f5f9;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.6;
}

.ref-context-box p { margin: 0; }

/* Chart legend */
.chart-legend {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--text-dim);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

/* Loading state */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-dim);
  font-size: 14px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}

.empty-state h3 {
  font-size: 18px;
  margin-bottom: 8px;
  color: var(--text);
}

.empty-state p {
  font-size: 14px;
  max-width: 500px;
  margin: 0 auto;
}
