/* Exact visual language from Imagine assets (cleaned of mock bugs) */
:root {
  --bg: #f0f0ee;
  --bg-page: #f0f0ee;
  --surface: #ffffff;
  --surface-2: #fafaf9;
  --text: #1a1a1a;
  --text-2: #4a4a4a;
  --text-3: #8a8a8a;
  --line: #e8e8e6;
  --line-2: #dededc;
  --orange: #f0a010;
  --orange-2: #e8950a;
  --orange-soft: #fff4e0;
  --orange-bar: #f0a010;
  --orange-fill: rgba(240, 160, 16, 0.18);
  --shadow: 0 1px 3px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);
  --radius: 16px;
  --radius-sm: 12px;
  --nav-h: 68px;
  --font: "Inter", "Segoe UI", system-ui, sans-serif;
  --mono: "Inter", system-ui, sans-serif;
  --map-empty: #d8d8d6;
}

html[data-theme="light"] {
  color-scheme: light;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121212;
  --bg-page: #121212;
  --surface: #1c1c1c;
  --surface-2: #242424;
  --text: #f2f2f2;
  --text-2: #b0b0b0;
  --text-3: #777;
  --line: #2a2a2a;
  --line-2: #333;
  --orange: #f0a010;
  --orange-2: #ffb020;
  --orange-soft: rgba(240, 160, 16, 0.12);
  --orange-bar: #f0a010;
  --orange-fill: rgba(240, 160, 16, 0.2);
  --shadow: 0 2px 12px rgba(0,0,0,.35);
  --map-empty: #2a2a2a;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg-page);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--orange); text-decoration: none; }
a:hover { color: var(--orange-2); }

/* —— HEADER (mockup: white bar, logo left, nav center, toggle right) —— */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1180px;
  height: 100%;
  margin: 0 auto;
  padding: 0 28px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
}
.logo {
  font-weight: 700;
  font-size: 17px;
  color: var(--text) !important;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.logo b { color: var(--orange); font-weight: 700; }

.nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.nav a {
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 10px;
  position: relative;
  border-radius: 6px;
}
.nav a:hover { color: var(--text); }
.nav a.active {
  color: var(--orange);
}
.nav a.active::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 2px;
  height: 2px;
  background: var(--orange);
  border-radius: 2px;
}

.theme-pill {
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.theme-pill button {
  width: 32px;
  height: 28px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 14px;
}
.theme-pill button.on {
  background: var(--surface);
  color: var(--orange);
  box-shadow: var(--shadow);
}

.burger {
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
}
.burger span {
  display: block;
  width: 16px;
  height: 2px;
  background: var(--text);
  margin: 4px auto;
}

@media (max-width: 960px) {
  .topbar-inner { grid-template-columns: 1fr auto auto; }
  .burger { display: block; }
  .nav {
    display: none;
    position: absolute;
    top: var(--nav-h);
    left: 0; right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    flex-direction: column;
    padding: 12px 16px 16px;
    align-items: stretch;
    box-shadow: var(--shadow);
  }
  .nav.open { display: flex; }
  .nav a { padding: 12px 14px; }
  .nav a.active::after { display: none; }
  .nav a.active { background: var(--orange-soft); border-radius: 8px; }
}

/* —— PAGE —— */
.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 36px 28px 64px;
}

/* Hero */
.hero {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 40px;
  align-items: center;
  margin-bottom: 48px;
}
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 24px; }
}
.hero h1 {
  font-size: clamp(32px, 4.2vw, 44px);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.035em;
  margin: 0 0 16px;
  color: var(--text);
}
.hero p {
  margin: 0;
  font-size: 16px;
  color: var(--text-2);
  max-width: 460px;
  line-height: 1.55;
}
.hero-viz {
  height: 200px;
  border-radius: var(--radius);
  overflow: hidden;
}
.hero-viz svg { width: 100%; height: 100%; display: block; }

/* Section heads */
.sec-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 0 0 16px;
  gap: 12px;
}
.sec-head h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.sec-head a {
  font-size: 14px;
  font-weight: 600;
  color: var(--orange);
  white-space: nowrap;
}

/* Country cards — EXACT mock layout */
.top-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 48px;
}
@media (max-width: 1100px) { .top-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) { .top-grid { grid-template-columns: 1fr 1fr; } }

.c-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px 16px 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
}
.c-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(0,0,0,.08);
}
.c-card .c-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}
.flag-img {
  display: inline-block;
  vertical-align: middle;
  border-radius: 3px;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgba(0,0,0,.08);
  flex-shrink: 0;
  background: var(--line);
}
.flag-img.flag-broken {
  width: 22px;
  height: 16px;
  font-size: 9px;
  line-height: 16px;
  text-align: center;
  color: var(--text-3);
  content: '';
}
.flag-fallback {
  display: inline-block;
  width: 20px;
  height: 15px;
  background: var(--line);
  border-radius: 2px;
  vertical-align: middle;
}
.country-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}
.c-card .c-score {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text);
  line-height: 1;
  margin-bottom: 12px;
}
.c-metric {
  display: grid;
  grid-template-columns: 1fr 28px;
  gap: 6px 8px;
  align-items: center;
  margin-bottom: 6px;
  font-size: 11px;
  color: var(--text-3);
}
.c-metric .bar-track {
  grid-column: 1 / -1;
  height: 4px;
  background: var(--line);
  border-radius: 99px;
  overflow: hidden;
  margin-top: -2px;
  margin-bottom: 4px;
}
.c-metric .bar-fill {
  height: 100%;
  background: var(--orange-bar);
  border-radius: 99px;
}
.c-metric .v {
  text-align: right;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

/* How it works */
.how-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
@media (max-width: 800px) { .how-grid { grid-template-columns: 1fr; } }
.how-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 20px;
  box-shadow: var(--shadow);
}
.how-ico {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--orange-soft);
  color: var(--orange);
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  font-size: 20px;
}
.how-card h3 {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 700;
}
.how-card p {
  margin: 0 0 14px;
  font-size: 13.5px;
  color: var(--text-2);
  line-height: 1.45;
}
.how-card a {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--orange);
}

/* Page titles */
.ptitle {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0 0 8px;
}
.plead {
  margin: 0 0 28px;
  color: var(--text-2);
  font-size: 15px;
  max-width: 560px;
}

/* Filters row */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin-bottom: 20px;
  align-items: flex-end;
}
.filters label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-3);
  font-weight: 500;
}
input, select {
  background: var(--surface);
  border: 1px solid var(--line-2);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  min-width: 160px;
  color-scheme: inherit;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px var(--orange-fill);
}
/* Native <option> list: force readable contrast in both themes (esp. Windows) */
select option {
  background-color: var(--surface);
  color: var(--text);
}
html[data-theme="dark"] select,
html[data-theme="dark"] input {
  background-color: var(--surface-2);
  color: #f2f2f2;
  border-color: var(--line-2);
}
html[data-theme="dark"] select option {
  background-color: #1c1c1c;
  color: #f2f2f2;
}
html[data-theme="dark"] select option:checked,
html[data-theme="dark"] select option:hover {
  background-color: #333;
  color: #fff;
}

/* Table mockup style */
.tbl-wrap {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  overflow: hidden;
  box-shadow: var(--shadow);
}
table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.tbl th {
  text-align: left;
  padding: 12px 14px;
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.tbl th.orange { color: var(--orange); }
table.tbl td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
}
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tbody tr { cursor: pointer; }
table.tbl tbody tr:hover td { background: var(--orange-soft); }
table.tbl .score {
  font-weight: 700;
  color: var(--orange);
  background: var(--orange-soft) !important;
  font-variant-numeric: tabular-nums;
}
table.tbl .num { color: var(--text-3); font-variant-numeric: tabular-nums; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--orange);
  color: #1a1a1a !important;
  border: none;
  border-radius: 999px;
  padding: 11px 20px;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.05); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-outline {
  background: transparent;
  color: var(--orange) !important;
  border: 1.5px solid var(--orange);
  border-radius: 999px;
  padding: 10px 18px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-outline:hover { background: var(--orange-soft); }

/* Cards generic */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

/* Compare */
.cmp-builder {
  margin-bottom: 22px;
}
.cmp-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}
.cmp-pick {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px 6px 6px 10px;
}
.cmp-pick select.cmp-iso {
  min-width: 180px;
  max-width: 260px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  padding: 6px 8px;
  color-scheme: inherit;
}
html[data-theme="dark"] .cmp-pick {
  background: #1c1c1c;
  border-color: #3a3a3a;
}
html[data-theme="dark"] .cmp-pick select.cmp-iso {
  background: #242424;
  color: #f2f2f2;
  border-color: #333;
}
html[data-theme="dark"] .cmp-pick select.cmp-iso option {
  background: #1c1c1c;
  color: #f2f2f2;
}
.cmp-pick .cmp-rm {
  padding: 4px 10px;
  min-width: 36px;
  font-size: 14px;
  line-height: 1;
}
.cmp-pick .cmp-rm:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.cmp-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.cmp-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
}
.cmp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.cmp-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.cmp-radar-wrap {
  position: relative;
  max-width: 720px;
  margin: 0 auto;
}
.cmp-card .big {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -0.04em;
  margin: 6px 0 14px;
}
.row-m {
  display: grid;
  grid-template-columns: 110px 1fr 36px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--text-3);
}
.row-m .track {
  height: 6px;
  background: var(--line);
  border-radius: 99px;
  overflow: hidden;
}
.row-m .fill {
  height: 100%;
  background: var(--orange);
  border-radius: 99px;
}
.row-m .v { text-align: right; color: var(--text-2); font-variant-numeric: tabular-nums; }

/* Weights */
.w-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 16px;
}
@media (max-width: 900px) { .w-grid { grid-template-columns: 1fr; } }
.w-row { margin-bottom: 18px; }
.w-row .lab {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 500;
}
.w-row .lab span { color: var(--orange); font-weight: 700; }
input[type=range] {
  width: 100%;
  accent-color: var(--orange);
  min-width: 0;
  padding: 0;
  border: none;
  background: transparent;
}
.rank-badge {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--orange);
  color: #1a1a1a;
  font-size: 12px;
  font-weight: 800;
  display: inline-grid;
  place-items: center;
}

/* Sources — each card independent height (no row stretch when one opens) */
.src-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  align-items: start;
}
@media (max-width: 800px) { .src-grid { grid-template-columns: 1fr; } }
.src-card {
  align-self: start;
  height: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.src-card h3 { margin: 0 0 4px; font-size: 16px; }
.src-card .org { color: var(--text-3); font-size: 13px; margin-bottom: 8px; }
.src-card .src-chips { margin-bottom: 4px; }
.src-card .src-links {
  margin: 12px 0 0;
  font-size: 13px;
}
.src-card details.src-metrics {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.src-card details.src-metrics summary {
  cursor: pointer;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  list-style: none;
  user-select: none;
}
.src-card details.src-metrics summary::-webkit-details-marker { display: none; }
.src-card details.src-metrics summary::before {
  content: '▸ ';
  color: var(--orange);
}
.src-card details.src-metrics[open] summary::before { content: '▾ '; }
.src-card details.src-metrics ul {
  margin: 10px 0 0;
  padding: 0 0 0 16px;
  max-height: 240px;
  overflow-y: auto;
  font-size: 12px;
  color: var(--text-3);
  overscroll-behavior: contain;
}
.src-card details.src-metrics li {
  margin: 3px 0;
  line-height: 1.35;
}
.chip {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--line);
  font-size: 11px;
  color: var(--text-2);
  margin-right: 4px;
}
.chip.ok { background: #e8f8ee; color: #168a3c; border-color: transparent; }
html[data-theme="dark"] .chip.ok { background: rgba(22,138,60,.2); color: #4ade80; }

/* Method */
.meth-grid {
  display: grid;
  grid-template-columns: 1.3fr 0.7fr;
  gap: 20px;
}
@media (max-width: 900px) { .meth-grid { grid-template-columns: 1fr; } }
.meth-block { margin-bottom: 22px; }
.meth-block h3 {
  margin: 0 0 8px;
  font-size: 17px;
  color: var(--orange);
  font-weight: 700;
}
.meth-block p { margin: 0 0 10px; color: var(--text-2); font-size: 14px; }
.code {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  font-family: ui-monospace, monospace;
  font-size: 12.5px;
  color: var(--text);
  overflow-x: auto;
}
.side {
  border: 1px solid var(--orange);
  border-radius: var(--radius);
  padding: 18px;
  background: var(--surface);
  margin-bottom: 14px;
}
.side h3 {
  margin: 0 0 10px;
  color: var(--orange);
  font-size: 15px;
}
.side ul { margin: 0; padding-left: 18px; color: var(--text-2); font-size: 13.5px; }
.side li { margin-bottom: 6px; }

/* ETL */
.pipe {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 20px 0 28px;
}
@media (max-width: 800px) { .pipe { grid-template-columns: 1fr; } }
.pipe .card h3 { color: var(--orange); margin: 0 0 6px; }
.pipe .card p, .pipe .card li { color: var(--text-2); font-size: 13.5px; }
.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.pill.ok { background: #e8f8ee; color: #168a3c; }
.pill.run { background: var(--orange-soft); color: var(--orange-2); }
.pill.fail { background: #fde8e8; color: #c0392b; }
html[data-theme="dark"] .pill.ok { background: rgba(22,138,60,.2); color: #4ade80; }
html[data-theme="dark"] .pill.fail { background: rgba(192,57,43,.2); color: #f87171; }

/* Map */
#world-map {
  width: 100%;
  height: min(62vh, 500px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.tooltip-map {
  position: fixed;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  box-shadow: var(--shadow);
  z-index: 50;
  display: none;
  min-width: 140px;
}
.tooltip-map strong { display: block; margin-bottom: 4px; }
.tooltip-map .line {
  height: 3px;
  background: var(--orange);
  border-radius: 2px;
  margin: 6px 0;
}
.legend {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  font-size: 12px;
  color: var(--text-3);
}
.legend .grad {
  flex: 1;
  max-width: 320px;
  height: 12px;
  border-radius: 99px;
  /* high-contrast choropleth: red → amber → green */
  background: linear-gradient(90deg, #b91c1c 0%, #ea580c 25%, #eab308 50%, #65a30d 75%, #15803d 100%);
  border: 1px solid var(--line);
}
.legend b {
  font-weight: 700;
  color: var(--text-2);
  min-width: 2.2em;
}

/* Footer */
.foot {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 22px 28px;
  font-size: 13px;
  color: var(--text-3);
}
.foot-inner {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.foot a { color: var(--text-2); margin-left: 14px; }
.foot a:hover { color: var(--orange); }
#footer-etl { font-size: 11px; color: var(--text-3); }

.loading { padding: 48px 0; color: var(--text-3); }
.err {
  background: #fde8e8;
  border: 1px solid #f5c2c2;
  border-radius: var(--radius);
  padding: 20px;
  color: #8b1e1e;
}
html[data-theme="dark"] .err {
  background: rgba(192,57,43,.15);
  border-color: rgba(192,57,43,.35);
  color: #fca5a5;
}

.muted { color: var(--text-3); }
.flex { display: flex; }
.gap { gap: 10px; }
.items-center { align-items: center; }
.mb-0 { margin-bottom: 0 !important; }
.mt { margin-top: 16px; }
.two {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 16px;
}
@media (max-width: 900px) { .two { grid-template-columns: 1fr; } }
.score-xl {
  font-size: 48px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
}
details summary { cursor: pointer; color: var(--text-3); font-size: 12px; }
details ul { font-size: 11px; color: var(--text-3); padding-left: 16px; }
