:root {
  --sidebar-width: 350px;
  --ink: #151817;
  --muted: #626864;
  --paper: #deddd5;
  --panel: #f3f1e8;
  --line: #b9bcb5;
  --accent: #f2c94c;
  --accent-dark: #896500;
  --chrome: #111315;
  --map: #000;
  --map-line: #fff;
  --selected: #fff;
  --country-fill: #747474;
  --country-hover: #b8b8b8;
  --danger: #ff755e;
  --continuous-gradient: linear-gradient(90deg, #440154, #3b528b, #21918c, #5ec962, #fde725);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--paper); color: var(--ink); font-family: "Arial Narrow", "Roboto Condensed", Arial, sans-serif; overflow-x: hidden; }
button, input { font: inherit; }
button { color: inherit; }

.topbar { position: absolute; z-index: 50; top: 0; right: 0; left: 0; height: 58px; padding: 0; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: stretch; background: transparent; color: #f8f6ef; pointer-events: none; }
.brand { display: inline-flex; align-items: center; gap: 10px; width: max-content; padding: 0 18px 0 14px; border-right: 1px solid #343836; background: var(--chrome); color: inherit; text-decoration: none; font-weight: 900; letter-spacing: .08em; font-size: 12px; white-space: nowrap; pointer-events: auto; }
.brand-mark { display: grid; place-items: center; height: 32px; width: 40px; background: var(--accent); color: var(--ink); font-size: 11px; }
.status { font-family: Consolas, monospace; letter-spacing: .08em; font-size: 8px; color: #a9b0ab; white-space: nowrap; }
.status-dot { display: inline-block; width: 6px; height: 6px; margin-right: 7px; border-radius: 50%; background: #66a630; box-shadow: 0 0 0 3px #66a63022; }
.topbar-actions { display: flex; align-items: stretch; background: var(--chrome); pointer-events: auto; }
.topbar-actions .status { display: flex; align-items: center; padding: 0 12px; border-left: 1px solid #343836; background: var(--chrome); }
.mobile-search-toggle { display: none; }
.mobile-search-actions { display: none; }
.desktop-search-actions { display: flex; justify-content: flex-end; margin: -2px 0 8px; }
.desktop-clear-all { min-height: 24px; padding: 0 9px; border: 1px solid var(--ink); background: var(--ink); color: #fff; cursor: pointer; font-family: Consolas, monospace; font-size: 8px; font-weight: 900; letter-spacing: .08em; }
.desktop-clear-all:hover, .desktop-clear-all:focus-visible { border-color: var(--accent-dark); background: var(--accent); color: var(--ink); outline: none; }
.mobile-map-history-controls { display: none; }
.mobile-ad-section { display: none; }
.mobile-scroll-indicator { display: none; }

.metric-navigation, .desktop-metric-navigation { display: flex; min-width: 0; align-items: stretch; pointer-events: none; }
.metric-navigation { position: relative; overflow: visible; }
.desktop-metric-navigation { width: auto; flex: 0 0 auto; }
.top-menu { position: relative; display: flex; align-items: stretch; pointer-events: auto; }
.metric-navigation .mobile-metric-navigation { display: none; }
.desktop-metric-navigation > .top-menu { flex: 0 0 auto; }
.top-menu-trigger { min-height: 100%; padding: 0 16px; border: 0; border-left: 1px solid #343836; background: var(--chrome); color: #f8f6ef; cursor: pointer; font-family: Consolas, monospace; font-size: 11px; font-weight: 700; letter-spacing: .055em; text-transform: uppercase; white-space: nowrap; pointer-events: auto; }
.data-health-link { display:flex; align-items:center; text-decoration:none; }
.top-menu-trigger:hover, .top-menu-trigger:focus-visible, .top-menu.open > .top-menu-trigger, .top-menu.contains-active > .top-menu-trigger { background: #242826; color: var(--accent); outline: none; }
.utility-trigger { border-right: 1px solid #343836; }
.current-metric-status { position: fixed; z-index: 45; top: 64px; left: var(--sidebar-width); display: inline-block; width: max-content; min-width: 0; max-width: min(760px, calc(100vw - var(--sidebar-width) - 520px)); min-height: 58px; padding: 5px 12px; overflow: hidden; border: 1px solid #343836; background: #090b0ae8; color: #f4f2ea; pointer-events: auto; }
.current-metric-status .active-metric-name { margin: 0 0 4px; overflow: hidden; color: var(--accent); font-family: "Arial Narrow", "Roboto Condensed", Arial, sans-serif; font-size: 22px; font-weight: 900; letter-spacing: .035em; line-height: 1; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }
.current-metric-status .map-instruction { display: none; }
.current-metric-status .metric-data-note { margin-top: 2px; font-size: 8px; font-weight: 700; white-space: nowrap; }
.top-menu-panel { position: absolute; z-index: 60; top: 100%; left: 0; border: 1px solid #343836; border-top: 3px solid var(--accent); background: var(--chrome); color: #f8f6ef; }
.top-menu-panel[hidden] { display: none; }
.settings-menu .top-menu-panel { right: 0; left: auto; }
.metric-menu-panel { width: 210px; }
.metric-menu-panel.submenu-open { width: 760px; }
.metric-menu-columns { display: grid; grid-template-columns: 210px; min-height: 0; align-items: start; }
.metric-menu-panel.submenu-open .metric-menu-columns { grid-template-columns: 210px 270px minmax(0, 1fr); }
.metric-subcategory-list, .metric-menu-list { display: grid; min-height: 0; max-height: calc(100vh - 72px); align-self: start; align-content: start; overflow-y: auto; }
.metric-subcategory-list { grid-auto-rows: minmax(58px, auto); border-right: 1px solid #3d413f; }
.metric-menu-list { grid-auto-rows: minmax(58px, auto); border-right: 1px solid #3d413f; }
.metric-menu-panel:not(.submenu-open) .metric-menu-list, .metric-menu-panel:not(.submenu-open) .metric-menu-description { display: none; }
.metric-subcategory-option { display: flex; justify-content: space-between; align-items: center; min-height: 58px; padding: 13px 14px; border: 0; border-bottom: 1px solid #3d413f; background: #171a18; color: #f3f1e8; cursor: pointer; font-family: Consolas, monospace; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-align: left; text-transform: uppercase; }
.metric-subcategory-option:last-child { border-bottom: 0; }
.metric-subcategory-option:hover, .metric-subcategory-option:focus-visible, .metric-subcategory-option.active { background: #2a2e2b; color: var(--accent); outline: none; }
.metric-subcategory-option span:last-child { font-size: 17px; }
.metric-option { display: grid; grid-template-columns: minmax(0, 1fr) auto; width: 100%; min-height: 58px; align-items: center; gap: 12px; padding: 13px 14px; border: 0; border-bottom: 1px solid #3d413f; background: #202421; color: #f3f1e8; text-align: left; cursor: pointer; }
.metric-option:last-child { border-bottom: 0; }
.metric-option span { overflow: hidden; font-size: 12px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.metric-option small { color: #929994; font-family: Consolas, monospace; font-size: 8px; text-align: right; }
.metric-option:hover, .metric-option:focus-visible, .metric-option.active { background: var(--accent); color: var(--ink); outline: none; }
.metric-option:hover small, .metric-option:focus-visible small, .metric-option.active small { color: #594900; }
.metric-menu-description { padding: 18px; background: #1b1e1c; }
.metric-menu-description .eyebrow { color: var(--accent); }
.metric-menu-description h2 { margin: 0 0 9px; font-size: 18px; line-height: 1.05; text-transform: uppercase; }
.metric-menu-description p { margin: 0 0 14px; color: #c9ceca; font-size: 10px; line-height: 1.5; }
.metric-detail-meta { display: grid; gap: 5px; padding-top: 11px; border-top: 1px solid #3d413f; color: #aeb5b0; font-family: Consolas, monospace; font-size: 7px; text-transform: uppercase; }
.metric-detail-meta a { color: var(--accent); }
.settings-panel { width: 340px; padding: 14px; }
.menu-panel-heading { margin: 0 0 8px; color: var(--accent); font-family: Consolas, monospace; font-size: 8px; font-weight: 700; letter-spacing: .12em; }
.settings-future-note { margin: 9px 1px 1px; color: #929994; font-size: 8px; line-height: 1.4; }

.button { min-height: 38px; padding: 0 15px; border: 1px solid var(--ink); background: transparent; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; font-size: 10px; cursor: pointer; }
.button:hover { background: var(--ink); color: var(--panel); }
.button-primary { width: 100%; display: flex; align-items: center; justify-content: space-between; min-height: 48px; background: var(--ink); color: white; }
.button-primary:hover { background: var(--accent); color: var(--ink); }

.app-shell { height: 100vh; min-height: 620px; display: grid; grid-template-columns: var(--sidebar-width) minmax(520px, 1fr) 190px; }
.control-panel { display: flex; min-height: 0; padding: 76px 12px 18px; flex-direction: column; background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; }
.control-panel[hidden] { display: none; }
.control-panel section { margin-bottom: 26px; }
.eyebrow { margin: 0 0 10px; font-family: Consolas, monospace; color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .13em; }
.metric-data-note { display: flex; gap: 10px; margin-top: 5px; color: #9ca39e; font-family: Consolas, monospace; font-size: 7px; line-height: 1.25; }
.metric-data-note a { overflow: hidden; color: var(--accent); text-overflow: ellipsis; white-space: nowrap; }
.landmass-filter { padding: 11px; border: 1px solid #424744; background: #202321; color: #f3f1e8; }
.landmass-filter-heading { display: flex; gap: 8px; justify-content: space-between; align-items: baseline; font-family: Consolas, monospace; font-size: 8px; font-weight: 700; letter-spacing: .08em; }
.landmass-filter output { color: var(--accent); white-space: nowrap; }
.landmass-filter input[type="range"] { width: 100%; height: 18px; margin: 6px 0 3px; accent-color: var(--accent); cursor: pointer; }
.landmass-filter small { display: block; color: #aeb5b0; font-size: 8px; line-height: 1.35; }
.reference-opacity-control, .settings-control { margin-top: 10px; padding-top: 10px; border-top: 1px solid #424744; }
.settings-toggle-control label { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-family: Consolas, monospace; font-size: 8px; font-weight: 700; letter-spacing: .08em; }
.settings-toggle-control input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.settings-select-control label { display: block; margin-bottom: 6px; font-family: Consolas, monospace; font-size: 8px; font-weight: 700; letter-spacing: .08em; }
.settings-select-control select { width: 100%; height: 32px; margin-bottom: 4px; padding: 0 8px; border: 1px solid #565c58; border-radius: 0; background: #111412; color: #f3f1e8; font-size: 10px; cursor: pointer; }
.settings-select-control select:focus { border-color: var(--accent); outline: none; }

.search-wrap { position: relative; }
.search-wrap svg { position: absolute; top: 11px; left: 11px; width: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.search-wrap input { width: 100%; height: 41px; padding: 0 12px 0 36px; border: 1px solid var(--ink); border-radius: 0; outline: none; background: white; font-size: 12px; }
.search-wrap input:focus { box-shadow: inset 3px 0 var(--accent-dark); }
.search-results { position: absolute; z-index: 20; width: 243px; max-height: 190px; overflow-y: auto; background: white; border: 1px solid var(--ink); border-top: 0; box-shadow: 5px 5px 0 #17201b22; }
.search-results:empty { display: none; }
.search-result { display: flex; justify-content: space-between; width: 100%; padding: 10px; border: 0; border-bottom: 1px solid #ddd; background: white; text-align: left; cursor: pointer; font-size: 11px; }
.search-result:hover { background: var(--accent); }
.search-result code { color: var(--muted); font-size: 9px; }

.section-heading, .tray-header { display: flex; justify-content: space-between; align-items: start; }
.text-button { padding: 0; border: 0; background: none; font-family: Consolas, monospace; font-size: 9px; font-weight: 700; cursor: pointer; text-decoration: underline; }
.comparison-heading { align-items: baseline; }
.comparison-mode { padding: 3px 5px; background: var(--ink); color: #fff; font-family: Consolas, monospace; font-size: 7px; font-weight: 700; letter-spacing: .08em; }
.comparison-mode.many-to-many { background: #244f75; }
.comparison-groups-grid { display: grid; grid-template-columns: minmax(0, 1fr) 15px minmax(0, 1fr); align-items: stretch; }
.mobile-group-tabs { display: none; }
.comparison-group { position: relative; min-width: 0; padding: 6px; border: 1px solid var(--line); background: #eeede6; transition: border-color .08s, box-shadow .08s, background .08s; }
.comparison-group.group-a { border-top: 3px solid #a5001c; }
.comparison-group.group-b { border-top: 3px solid #1769a7; }
.comparison-group.group-a { background: #f7eeee; }
.comparison-group.group-b { background: #edf3f7; }
.comparison-group.drop-active { border-color: var(--accent-dark); background: #f7f8df; box-shadow: inset 0 0 0 2px var(--accent); }
.comparison-group.drop-active::after { content: attr(data-drop-hint); position: absolute; z-index: 5; right: 7px; bottom: 7px; left: 7px; padding: 7px 8px; background: #111412; color: var(--accent); font-family: Consolas, monospace; font-size: 8px; font-weight: 700; letter-spacing: .03em; line-height: 1.25; pointer-events: none; text-transform: uppercase; }
.group-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 7px; }
.group-heading strong { font-family: Consolas, monospace; font-size: 9px; letter-spacing: .1em; }
.group-heading .text-button { font-size: 7px; }
.group-search-wrap input { height: 35px; padding-left: 31px; padding-right: 6px; font-size: 9px; }
.group-search-wrap svg { top: 9px; }
.group-search-results { left: 6px; right: 6px; width: auto; }
.group-divider { display: grid; place-items: center; margin: 0; color: var(--muted); font-family: Consolas, monospace; font-size: 7px; font-weight: 700; }
.group-divider::before, .group-divider::after { display: none; }
.selection-list { min-height: 108px; border: 1px dashed var(--line); }
.group-selection-list { min-height: 75px; max-height: 275px; margin-top: 8px; overflow-y: auto; background: #fff; }
.empty-selection { display: flex; gap: 10px; align-items: center; padding: 18px 14px; color: var(--muted); }
.group-selection-list .empty-selection { min-height: 65px; padding: 10px; }
.empty-selection p { margin: 0; font-size: 11px; line-height: 1.45; }
.crosshair { display: grid; place-items: center; min-width: 29px; height: 29px; border: 1px solid var(--line); border-radius: 50%; font-family: Consolas, monospace; }
.selection-item { position: relative; display: grid; grid-template-columns: 5px minmax(0, 1fr); gap: 5px; align-items: center; min-height: 45px; padding: 7px 21px 7px 12px; border-bottom: 1px solid var(--line); background: #fff; cursor: grab; }
.selection-item:last-child { border-bottom: 0; }
.selection-item.reordering { opacity: .42; cursor: grabbing; }
.selection-item.drop-before::before, .selection-item.drop-after::after { content: ""; position: absolute; z-index: 2; left: 3px; right: 3px; height: 3px; background: var(--accent-dark); pointer-events: none; }
.selection-item.drop-before::before { top: -2px; }
.selection-item.drop-after::after { bottom: -2px; }
.selection-grip { position: absolute; left: 2px; overflow: hidden; color: var(--muted); font-family: Consolas, monospace; font-size: 9px; letter-spacing: -5px; }
.selection-swatch { width: 5px; height: 30px; background: var(--accent); }
.selection-item > span:nth-of-type(3) { min-width: 0; }
.selection-item b, .selection-item small { display: block; }
.selection-item b { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 9px; }
.selection-item small { margin-top: 2px; color: var(--muted); font-family: Consolas, monospace; font-size: 8px; }
.map-drag-tile-preview { position: fixed; z-index: 1000; display: grid; grid-template-columns: 5px minmax(0, 1fr); gap: 7px; align-items: center; width: 210px; min-height: 45px; padding: 7px 12px; border: 1px solid #101713; background: #fff; color: var(--ink); box-shadow: 5px 5px 0 #0006; pointer-events: none; }
.map-drag-tile-preview b, .map-drag-tile-preview small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-drag-tile-preview b { font-size: 9px; }
.map-drag-tile-preview small { margin-top: 2px; color: var(--muted); font-family: Consolas, monospace; font-size: 8px; }
.remove-country { position: absolute; top: 50%; right: 2px; width: 19px; height: 28px; padding: 0; border: 0; background: none; cursor: pointer; font-size: 15px; line-height: 1; transform: translateY(-50%); }
.export-note { margin: 7px 0 0; text-align: center; color: var(--muted); font-size: 9px; }
.sidebar-bottom-stack { margin-top: auto; flex: 0 0 auto; }
.sidebar-ad-section { margin: 14px 0 0 !important; padding-top: 14px; border-top: 1px solid var(--line); }

.map-workspace { position: relative; display: flex; min-width: 0; flex-direction: column; background: var(--map); color: white; }
.map-instruction { margin: 0; color: #e2e6e3; font-size: 11px; }
.zoom-controls { display: flex; }
.topbar-actions > .zoom-controls { align-self: center; margin: 0 8px; }
.zoom-controls button { width: 33px; height: 33px; border: 1px solid #ffffff55; border-right: 0; background: transparent; color: white; cursor: pointer; font-size: 16px; }
.zoom-controls button:last-child { border-right: 1px solid #ffffff55; }
.zoom-controls button:hover { background: var(--accent); color: var(--ink); }
.zoom-controls button:disabled { color: #ffffff38; cursor: default; background: transparent; }
.map-stage { position: relative; flex: 1; min-height: 390px; overflow: hidden; cursor: grab; }
.map-stage.map-panning { cursor: grabbing; }
.map-stage::after { content: "EDGE PAN"; display: none; position: absolute; z-index: 3; top: 50%; right: 8px; padding: 5px 3px; border: 1px solid #ffffff55; color: #fff; font-family: Consolas, monospace; font-size: 7px; letter-spacing: .1em; line-height: 1.05; writing-mode: vertical-rl; transform: translateY(-50%); pointer-events: none; }
.map-stage.edge-pan-active::after { display: block; }
.map-stage.layout-changing { cursor: wait; }
#worldMap { display: block; width: 100%; height: 100%; color: #ffffff12; touch-action: none; user-select: none; }
.grid-fill { pointer-events: none; }
.country-fill { fill: var(--country-fill); stroke: none; pointer-events: none; transition: opacity .12s; }
.country-fill-group.missing-data .country-fill { fill: url(#noDataPattern) !important; opacity: .72; }
.country-fill-group.hovered .country-fill { fill: var(--country-hover) !important; }
.country-fill-group.missing-data.hovered:not(.selected) .country-fill { fill: url(#noDataPattern) !important; opacity: .72; }
.country-fill-group.selected .country-fill { fill: var(--selection-color) !important; }
.country-fill-group.selected.missing-data .country-fill { fill: url(#noDataPattern) !important; opacity: .72; }
.gradient-metric .country-fill-group.selected .country-fill { fill: var(--metric-fill) !important; }
.gradient-metric .country-fill-group.selected.missing-data .country-fill { fill: url(#noDataPattern) !important; opacity: .72; }
.gradient-metric.gradient-selection-active .country-fill-group:not(.selected):not(.missing-data) .country-fill { fill: #747474 !important; }
.gradient-metric.gradient-selection-active .country-fill-group.hovered:not(.selected):not(.missing-data) .country-fill { fill: var(--country-hover) !important; }
.landmass-below-threshold { display: none; }
.reference-boundaries { opacity: 0; pointer-events: none; transition: opacity .18s; }
.reference-boundaries.active { opacity: var(--reference-boundary-opacity, .45); }
.metric-transitioning-non-area .reference-boundaries,
.metric-transitioning-non-area .country-shape { opacity: 0 !important; transition: none; }
.reference-boundary { fill: none; stroke: #fff; stroke-width: .8; vector-effect: non-scaling-stroke; }
.country { cursor: grab; transition: opacity .12s; pointer-events: all; }
.country-shape { fill: transparent; stroke: #fff; stroke-width: .9; vector-effect: non-scaling-stroke; transition: opacity .12s; }
.cartogram-active .country.missing-data:not(.selected):not(.target):not(.dragging) .country-shape { opacity: 0; }
.country:hover .country-shape { stroke: #fff; stroke-width: 1.5; }
.country.selected .country-shape { stroke: var(--selected) !important; stroke-width: 1.8; }
.gradient-metric .country.selected:not(.target):not(.dragging) .country-shape { stroke: #fff !important; stroke-width: 1.8; }
.gradient-metric.many-to-many-comparison .country.selected:not(.target):not(.dragging) .country-shape { stroke: #fff !important; stroke-width: 1.4; }
.country.target .country-shape { stroke: #d8ff36 !important; stroke-width: 3.4; stroke-dasharray: none; transition: none; }
.country.dragging { opacity: 1; }
.country.dragging .country-shape { stroke: #27d9ff !important; stroke-width: 3.1; stroke-dasharray: none; }
.drag-ghost { fill: #aaa; stroke: #27d9ff; stroke-width: 2.2; opacity: .84; pointer-events: none; }
.area-comparison-overlays { pointer-events: none; }
.area-comparison-outline { pointer-events: all; cursor: move; }
.area-comparison-hatch { pointer-events: none; }
.area-comparison-outline-hit { fill: transparent; stroke: transparent; stroke-width: 16; vector-effect: non-scaling-stroke; pointer-events: visibleStroke; }
.area-comparison-outline-path { fill: transparent; stroke: var(--area-outline-color); stroke-width: 2.4; vector-effect: non-scaling-stroke; paint-order: stroke; pointer-events: visibleStroke; filter: drop-shadow(0 0 2px #000); }
.area-comparison-outline-path:hover { stroke-width: 3.2; }
.area-outline-rotate-handle { fill: var(--area-outline-color); stroke: #000; stroke-width: .65; paint-order: stroke; text-anchor: middle; dominant-baseline: central; font-family: Arial, sans-serif; font-size: 10px; font-weight: 900; cursor: alias; pointer-events: all; user-select: none; }
.map-stage.area-outline-moving, .map-stage.area-outline-rotating { cursor: grabbing; }
.comparison-connections { pointer-events: none; }
.comparison-connection { fill: none; stroke: #d7d7d7; stroke-width: var(--comparison-line-width, 2); vector-effect: non-scaling-stroke; opacity: .6; }
.comparison-connection[data-group="A"] { stroke: #ff5b70; }
.comparison-connection[data-group="B"] { stroke: #52a7ff; }
.group-boundary-overlays { pointer-events: none; }
.group-boundary-overlay { fill: none; stroke-width: 5.4; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; opacity: .98; }
.group-boundary-overlay[data-group="A"] { stroke: #ff1f2d; }
.group-boundary-overlay[data-group="B"] { stroke: #08a7df; }
.country-labels { pointer-events: none; }
.country-label { fill: #fff; stroke: none; text-anchor: middle; dominant-baseline: central; font-family: "Arial Narrow", "Roboto Condensed", Arial, sans-serif; font-weight: 800; letter-spacing: .01em; pointer-events: none; }
.country-label.label-hidden { display: none; }
.map-loading { position: absolute; z-index: 4; inset: 0; display: grid; place-content: center; gap: 12px; background: var(--map); color: #d4d9d5; font-family: Consolas, monospace; text-align: center; font-size: 10px; letter-spacing: .12em; }
.map-loading span { justify-self: center; width: 28px; height: 28px; border: 2px solid #ffffff22; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.map-tooltip { position: absolute; z-index: 10; top: 0; left: 0; width: 220px; padding: 9px 10px; pointer-events: none; background: #f4f3ec; color: var(--ink); border: 1px solid #fff; border-left: 4px solid var(--accent); border-radius: 0; box-shadow: 5px 5px 0 #0008; font-size: 10px; }
.tooltip-card { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 9px; align-items: center; }
.tooltip-flag { position: relative; display: grid; place-items: center; width: 36px; height: 27px; overflow: hidden; border: 1px solid #c8c8c1; background: #fff; }
.tooltip-flag img { position: absolute; z-index: 1; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; }
.tooltip-flag-fallback { color: var(--muted); font-family: Consolas, monospace; font-size: 10px; }
.tooltip-copy { min-width: 0; }
.tooltip-copy b { display: block; font-size: 11px; line-height: 1.15; }
.tooltip-metric { display: block; margin-top: 2px; overflow: hidden; color: var(--muted); font-family: Consolas, monospace; font-size: 7px; letter-spacing: .08em; text-overflow: ellipsis; white-space: nowrap; }
.tooltip-stats { display: flex; gap: 8px; align-items: baseline; justify-content: space-between; margin-top: 5px; }
.tooltip-stats strong { font-family: Consolas, monospace; font-size: 11px; }
.tooltip-rank { color: var(--muted); font-family: Consolas, monospace; font-size: 8px; white-space: nowrap; }
.tooltip-meta { display: flex; justify-content: space-between; gap: 8px; margin-top: 5px; padding-top: 5px; border-top: 1px solid #d1d2ca; color: var(--muted); font-family: Consolas, monospace; font-size: 7px; }
.tooltip-meta span:last-child { max-width: 62%; overflow: hidden; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.tooltip-warning { display: block; margin-top: 4px; color: #8b4d19; font-family: Consolas, monospace; font-size: 7px; }
.rate-legend { position: absolute; z-index: 4; left: 18px; bottom: 15px; display: flex; align-items: center; gap: 6px; color: #c9cfca; font-family: Consolas, monospace; font-size: 7px; }
.rate-legend[hidden] { display: none; }
.rate-legend i { width: 112px; height: 7px; border: 1px solid #ffffff44; background: var(--continuous-gradient); }
.rate-legend small { margin-left: 7px; padding-left: 13px; background: repeating-linear-gradient(45deg, #252525 0 3px, #595959 3px 5px); color: #c9cfca; font-size: 7px; }
.coordinate-readout { position: absolute; right: 18px; bottom: 15px; color: #9ca79f; font-family: Consolas, monospace; font-size: 8px; }

.comparison-tray { position: absolute; z-index: 15; left: 18px; right: 18px; bottom: 18px; padding: 14px; background: var(--chrome); color: #f4f2ea; box-shadow: 7px 7px 0 #0008; border: 1px solid #454a47; border-top: 4px solid var(--accent); }
.comparison-content { display: grid; grid-template-columns: minmax(190px, .75fr) 2fr; gap: 18px; align-items: center; }
.comparison-summary h3 { margin: 0 0 4px; text-transform: uppercase; font-size: 17px; }
.comparison-summary p { margin: 0; color: #b5bcb7; font-size: 10px; }
.gradient-summary b { color: #f4f2ea; text-transform: uppercase; }
.gradient-comparison { display: grid; gap: 7px; min-width: 0; }
.gradient-scale-track { height: 44px; border: 1px solid #aeb4b0; background: var(--continuous-gradient); }
.gradient-scale-values { display: grid; grid-template-columns: repeat(var(--gradient-label-count, 3), 1fr); color: #d8ddd9; font-family: Consolas, monospace; font-size: 9px; }
.gradient-scale-values span:not(:first-child):not(:last-child) { text-align: center; }
.gradient-scale-values span:last-child { text-align: right; }
.gradient-group-key { display: flex; gap: 16px; margin-top: 3px; font-family: Consolas, monospace; font-size: 8px; font-weight: 700; }
.gradient-group-key span { padding-left: 10px; border-left: 4px solid; }
.gradient-group-key .group-a-key { border-color: #ff5b70; }
.gradient-group-key .group-b-key { border-color: #52a7ff; }
.comparison-bars { display: grid; gap: 7px; min-width: 0; }
.comparison-bar-row { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 7px; align-items: center; min-width: 0; }
.comparison-bar-row::before { content: attr(data-group-label); color: #d8ddd9; font-family: Consolas, monospace; font-size: 8px; font-weight: 700; }
.comparison-bar-track { display: flex; min-width: 0; height: 44px; border: 1px solid #777d79; background: #2d302f; overflow: hidden; }
.comparison-bar-track:not(.rate-values) { position: relative; display: block; }
.comparison-bar-track.rate-values .comparison-bar-segment { flex: 1 1 0 !important; width: auto !important; }
.comparison-bar-track:not(.rate-values) .comparison-bar-segment.no-data { position: absolute; flex: 0 0 0 !important; width: 0 !important; min-width: 0; padding: 0; border: 0; background: transparent !important; color: transparent !important; overflow: visible; }
.comparison-bar-track:not(.rate-values) .comparison-bar-segment.no-data::after { content: ""; position: absolute; z-index: 1; top: 0; bottom: 0; left: 0; width: 1px; background: #b6b6b0; }
.comparison-bar-track:not(.rate-values) .comparison-bar-segment.no-data .comparison-bar-copy { display: none; }
.comparison-bar-segment { box-sizing: border-box; display: flex; min-width: 0; flex: 0 0 auto; align-items: center; padding: 5px 7px; border-right: 1px solid #101713; overflow: hidden; color: #101713; font-family: Consolas, monospace; white-space: nowrap; }
.comparison-bar-track:not(.rate-values) .comparison-bar-segment { position: absolute; top: 0; bottom: 0; height: 100%; }
.comparison-bar-segment:last-child { border-right: 0; }
.comparison-bar-copy { display: grid; min-width: 0; gap: 1px; }
.comparison-bar-copy b, .comparison-bar-copy span { overflow: hidden; text-overflow: ellipsis; }
.comparison-bar-copy b { font-size: 9px; }
.comparison-bar-copy span { font-size: 7px; }
.bar-tooltip { position: absolute; z-index: 2; top: 0; left: 0; display: grid; gap: 2px; min-width: 158px; max-width: 240px; padding: 8px 10px; pointer-events: none; background: #f4f3ec; color: var(--ink); border: 1px solid var(--ink); border-left: 4px solid var(--tooltip-accent, var(--accent)); box-shadow: 4px 4px 0 #0005; font-family: Consolas, monospace; line-height: 1.2; }
.bar-tooltip[hidden] { display: none; }
.bar-tooltip b { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.bar-tooltip span { font-size: 9px; }
.bar-tooltip small { color: var(--muted); font-size: 8px; text-transform: uppercase; }

.ad-rail { display: grid; place-items: center; padding: 15px; background: var(--panel); border-left: 1px solid var(--line); }
.ad-label { margin-bottom: 6px; color: #7c827e; font-family: Consolas, monospace; font-size: 7px; letter-spacing: .13em; text-align: center; }
.ad-slot { position: relative; display: grid; place-content: center; border: 1px dashed #9fa49d; color: #7f857f; text-align: center; background: #ebeae2; overflow: hidden; }
.ad-slot-rail { width: 160px; height: min(600px, calc(100vh - 112px)); }
.ad-slot-square { width: min(300px, 100%); height: 250px; margin: 0 auto; }
.ad-slot .adsbygoogle { position: relative; z-index: 2; display: block !important; width: 100%; min-width: 1px; height: 100%; min-height: 1px; }
.ad-slot span { font-family: Consolas, monospace; font-size: 8px; letter-spacing: .18em; }
.ad-slot small { margin-top: 5px; font-size: 7px; }
.ad-slot span, .ad-slot small, .ad-slot i { grid-area: 1 / 1; }
.ad-slot .adsbygoogle + span, .ad-slot .adsbygoogle + span + small, .ad-slot .adsbygoogle + span + small + i { position: relative; z-index: 1; }
.ad-slot i::before, .ad-slot i::after { content: ""; position: absolute; left: 50%; top: 50%; width: 35px; height: 1px; background: #c4c6c0; }
.ad-slot i::before { transform: translate(-50%, -50%) rotate(45deg); }
.ad-slot i::after { transform: translate(-50%, -50%) rotate(-45deg); }

dialog { width: min(470px, calc(100vw - 32px)); padding: 28px; border: 1px solid var(--ink); border-top: 6px solid var(--accent); background: var(--panel); box-shadow: 12px 12px 0 #0005; }
dialog::backdrop { background: #17201bc9; }
dialog h2 { margin: 0 0 18px; text-transform: uppercase; font-size: 25px; }
dialog ol { padding-left: 19px; }
dialog li { margin-bottom: 11px; padding-left: 5px; font-size: 12px; line-height: 1.5; }
.dialog-close { position: absolute; top: 10px; right: 12px; border: 0; background: transparent; font-size: 22px; cursor: pointer; }
.dialog-note { padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; line-height: 1.5; }
.dialog-links { display: flex; flex-wrap: wrap; gap: 8px 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.dialog-links a { color: var(--ink); font-family: Consolas, monospace; font-size: 9px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.dialog-links a:hover, .dialog-links a:focus-visible { color: var(--accent-dark); outline: none; }

@media (max-width: 1250px) {
  :root { --sidebar-width: 340px; }
  .app-shell { grid-template-columns: var(--sidebar-width) minmax(480px, 1fr); }
  .ad-rail { display: none; }
  .desktop-metric-navigation > .top-menu { flex: 0 0 auto; }
  .top-menu-trigger { padding-right: 11px; padding-left: 11px; font-size: 8px; }
  .current-metric-status { max-width: min(520px, calc(100vw - var(--sidebar-width) - 260px)); }
  .current-metric-status .map-instruction, .current-metric-status .metric-data-note { display: none; }
}

@media (max-width: 900px) and (min-width: 721px) {
  :root { --sidebar-width: 320px; }
  .app-shell { grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
  .topbar-actions .status { display: none; }
  .brand { padding-right: 10px; font-size: 10px; }
  .desktop-metric-navigation > .top-menu { flex: 0 0 auto; }
  .top-menu-trigger { padding-right: 8px; padding-left: 8px; font-size: 7px; }
  .current-metric-status { display: none; }
  .control-panel { padding-right: 12px; padding-left: 12px; }
}

@media (max-width: 720px) {
  html, body { height: 100%; overflow: hidden; }
  .topbar { height: 58px; padding: 0; display: block; background: transparent; pointer-events: none; }
  .brand { height: 58px; max-width: calc(100vw - 122px); min-width: 0; padding-right: 10px; overflow: hidden; background: #f4f3ecee; color: var(--ink); font-size: 10px; }
  .brand span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .brand-mark { width: 34px; height: 28px; }
  .mobile-search-toggle {
    display: flex;
    position: fixed;
    z-index: 56;
    top: 0;
    right: 0;
    width: 122px;
    max-width: 34vw;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-width: 0;
    width: 100%;
    height: 58px;
    padding: 0 10px;
    border: 0;
    border-left: 1px solid #343836;
    background: #f4f3ecee;
    color: var(--ink);
    cursor: pointer;
    font-weight: 900;
    letter-spacing: .04em;
    text-transform: uppercase;
    pointer-events: auto;
  }
  .mobile-search-toggle[aria-expanded="true"] { background: var(--accent); }
  .mobile-search-toggle span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-search-toggle span:last-child { font-size: 19px; line-height: 1; }
  .mobile-map-history-controls {
    position: fixed;
    z-index: 55;
    top: 58px;
    right: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 122px;
    max-width: 34vw;
    height: 34px;
    pointer-events: auto;
  }
  .mobile-map-history-controls button {
    border: 0;
    border-top: 1px solid #343836;
    border-left: 1px solid #343836;
    background: #111412ee;
    color: #fff;
    font-family: Consolas, monospace;
    font-size: 15px;
    font-weight: 900;
    cursor: pointer;
  }
  .mobile-map-history-controls button:last-child { border-right: 1px solid #343836; }
  .mobile-map-history-controls button:disabled { color: #ffffff38; }
  .topbar-actions { display: none !important; }
  .metric-navigation {
    position: fixed;
    z-index: 54;
    top: 62px;
    left: 8px;
    display: block;
    width: min(220px, calc(100vw - 16px));
    border: 0;
    pointer-events: none;
  }
  .desktop-metric-navigation { display: none; }
  .current-metric-status { display: none; }
  .metric-navigation .mobile-metric-navigation { display: flex; width: 100%; pointer-events: auto; }
  .mobile-metric-navigation > .top-menu-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    min-height: 40px;
    padding: 0 11px;
    overflow: hidden;
    border: 1px solid #343836;
    background: #111412ee;
    color: var(--accent);
    position: relative;
    text-align: left;
    text-overflow: ellipsis;
  }
  .mobile-metric-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .mobile-metric-caret {
    flex: 0 0 auto;
    color: #f4f2ea;
    font-size: 12px;
  }
  .mobile-metric-navigation.open .mobile-metric-caret { transform: rotate(180deg); }
  .top-menu-panel {
    position: fixed;
    top: 106px;
    bottom: 46px;
    left: 8px !important;
    right: auto;
    width: min(360px, calc(100vw - 16px));
    height: calc(100dvh - 152px);
    max-height: none;
    overflow: hidden;
    overscroll-behavior: contain;
    touch-action: pan-y;
  }
  .mobile-menu-panel.metric-menu-panel,
  .mobile-menu-panel.metric-menu-panel.submenu-open {
    width: min(360px, calc(100vw - 16px));
  }
  .mobile-menu-columns {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr);
    height: 100%;
    min-height: 0;
    max-height: none;
    align-items: stretch;
    align-content: stretch;
  }
  .metric-menu-panel.submenu-open .mobile-menu-columns { grid-template-columns: minmax(118px, 40%) minmax(0, 1fr); }
  .mobile-menu-panel .metric-subcategory-list, .mobile-menu-panel .metric-menu-list {
    height: 100%;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
  }
  .mobile-scroll-indicator {
    position: fixed;
    z-index: 90;
    display: block;
    width: 0;
    height: 0;
    pointer-events: none;
    filter: drop-shadow(0 1px 2px #000);
  }
  .mobile-scroll-indicator[hidden] { display: none; }
  .mobile-scroll-indicator.up {
    border-right: 8px solid transparent;
    border-bottom: 11px solid var(--accent);
    border-left: 8px solid transparent;
  }
  .mobile-scroll-indicator.down {
    border-top: 11px solid var(--accent);
    border-right: 8px solid transparent;
    border-left: 8px solid transparent;
  }
  .mobile-menu-panel .metric-subcategory-list { grid-auto-rows: minmax(50px, auto); }
  .mobile-menu-panel .metric-menu-list { grid-auto-rows: minmax(50px, auto); }
  .mobile-menu-panel .metric-subcategory-option { min-height: 50px; padding: 10px; font-size: 9px; line-height: 1.25; overflow-wrap: anywhere; }
  .mobile-menu-panel .metric-option { min-height: 50px; grid-template-columns: minmax(0, 1fr); gap: 4px; padding: 10px; }
  .mobile-menu-panel .metric-option span { font-size: 10px; line-height: 1.2; white-space: normal; overflow-wrap: anywhere; }
  .mobile-menu-panel .metric-option small { text-align: left; }
  .mobile-menu-panel .metric-menu-description { display: none !important; }
  .settings-panel { width: auto; }
  .app-shell { position: fixed; inset: 0; height: 100dvh; min-height: 0; display: block; overflow: hidden; }
  .control-panel {
    position: fixed;
    z-index: 35;
    top: 106px;
    left: 8px;
    right: auto;
    width: min(360px, calc(100vw - 16px));
    min-width: 0;
    max-height: min(58dvh, 480px);
    padding: 8px;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    border: 1px solid var(--line);
    background: #f4f3ecef;
    box-shadow: 0 8px 24px #0008;
  }
  body:not(.mobile-search-open) .control-panel {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0;
    max-height: none;
    padding: 0;
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
    pointer-events: none;
  }
  body:not(.mobile-search-open) .control-panel .selection-section,
  body:not(.mobile-search-open) .control-panel .button-primary,
  body:not(.mobile-search-open) .control-panel .mobile-search-actions {
    display: none;
  }
  .desktop-search-actions { display: none; }
  .selection-section {
    display: flex;
    flex-direction: column;
  }
  .comparison-heading { order: 0; }
  .mobile-search-actions { order: 1; }
  .mobile-group-tabs { order: 2; }
  .comparison-groups-grid { order: 3; }
  .selection-section, .comparison-groups-grid, .comparison-group, .group-search-wrap, .group-selection-list, .button-primary {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
  .control-panel section { margin-bottom: 10px; }
  .mobile-group-tabs { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); width: 100%; min-width: 0; max-width: 100%; margin-bottom: 8px; overflow: hidden; }
  .mobile-group-tabs button { min-width: 0; min-height: 34px; padding: 0 6px; overflow: hidden; border: 1px solid var(--line); background: #e8e7df; font-family: Consolas, monospace; font-size: 9px; font-weight: 700; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }
  .mobile-group-tabs button + button { border-left: 0; }
  .mobile-group-tabs button.active { background: var(--ink); color: #fff; }
  .comparison-groups-grid { display: block; }
  .comparison-groups-grid .comparison-group:not(.mobile-group-active) { display: none; }
  .comparison-groups-grid .group-divider { display: none; }
  .group-heading { margin-bottom: 5px; }
  .group-search-wrap input { height: 32px; }
  .group-selection-list { min-height: 64px; max-height: min(24dvh, 190px); }
  .group-selection-list .empty-selection { min-height: 58px; padding: 8px; }
  .empty-selection p { font-size: 10px; }
  .search-results { width: calc(100% - 36px); }
  .map-workspace { position: fixed; inset: 0; min-height: 100dvh; padding-bottom: 58px; }
  .map-stage { height: 100dvh; min-height: 100dvh; touch-action: none; }
  .metric-data-note { flex-wrap: wrap; }
  .comparison-tray { right: 8px; bottom: 58px; left: 8px; max-height: 18dvh; overflow-y: auto; padding: 8px; border-top-width: 2px; box-shadow: 0 0 0 1px #0008; }
  .comparison-tray,
  .comparison-tray * {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }
  .comparison-content { grid-template-columns: 1fr; gap: 8px; }
  .comparison-tray .tray-header,
  .comparison-tray .comparison-summary { display: none !important; }
  .comparison-bars { gap: 5px; }
  .comparison-summary h3 { font-size: 14px; }
  .comparison-bar-row { grid-template-columns: 38px minmax(0, 1fr); }
  .comparison-bar-track { height: 28px; }
  .comparison-bar-copy b { font-size: 8px; }
  .comparison-bar-copy span { display: block; font-size: 6px; line-height: 1.05; }
  .country-label { font-size: inherit; font-weight: 900; }
  .country-label[data-label-mode="name"] { letter-spacing: 0; }
  .map-instruction { max-width: 290px; }
  .sidebar-bottom-stack { display: grid; gap: 6px; margin-top: 8px; }
  .mobile-search-actions {
    display: grid;
    grid-template-columns: 40px 40px minmax(0, 1fr);
    gap: 6px;
    width: 100%;
    margin-bottom: 8px;
  }
  .mobile-search-actions button {
    min-height: 34px;
    border: 1px solid var(--ink);
    background: #111412;
    color: #fff;
    font-family: Consolas, monospace;
    font-size: 13px;
    font-weight: 900;
    cursor: pointer;
  }
  .mobile-search-actions button:disabled {
    color: #ffffff44;
    border-color: #11141266;
  }
  .mobile-clear-all {
    letter-spacing: .08em;
    font-size: 10px !important;
  }
  .button-primary { min-height: 34px; padding: 0 12px; }
  #exportButton { display: none; }
  .export-note { display: none; }
  .sidebar-ad-section {
    display: none;
  }
  .mobile-ad-section {
    position: fixed;
    z-index: 55;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    height: 54px;
    place-items: center;
    border-top: 1px solid var(--line);
    background: #f4f3ecf2;
    pointer-events: auto;
  }
  .ad-slot-mobile { width: min(320px, calc(100vw - 16px)); height: 50px; margin: 0 auto; }
  .ad-slot-mobile small { display: none; }
  .ad-slot-mobile span { font-size: 9px; }
  .sidebar-ad-section .ad-label { display: none; }
  .ad-slot-square { width: min(300px, calc(100vw - 16px)); height: 34px; margin: 0 auto; }
  .ad-slot-square small { display: none; }
  .map-drag-tile-preview {
    width: min(240px, calc(100vw - 24px));
    transform: translate3d(12px, 12px, 0);
  }
}

@media print {
  .topbar-actions, .metric-navigation, .control-panel, .ad-rail, .zoom-controls, .export-note { display: none !important; }
  .topbar { grid-template-columns: 1fr auto; }
  .app-shell { display: block; height: calc(100vh - 58px); }
  .map-workspace { height: 100%; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
