:root {
    --accent: #C8401A;
    --bg: #f5f4f0;
    --surface: #fff;
    --border: #e2e0d8;
    --ink1: #1a1916;
    --muted: #8a8880;
    --mono: 'DM Mono', monospace;
    --sans: 'DM Sans', system-ui, sans-serif;
    --radius: 4px;
    --shadow: 0 2px 12px rgba(0, 0, 0, .08)
}

body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--ink1);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden
}

.hdr {
    background: var(--ink1);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 52px;
    flex-shrink: 0
}

.hdr-title {
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: .08em;
    text-transform: uppercase;
    opacity: .85
}

.hdr-back {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #fff;
    text-decoration: none;
    background: rgba(255, 255, 255, .12);
    border: 1px solid rgba(255, 255, 255, .2);
    border-radius: var(--radius);
    padding: 6px 14px
}

.hdr-back:hover {
    background: var(--accent);
    border-color: var(--accent)
}

.toolbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 6px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    flex-shrink: 0
}

.stat-pill {
    font-family: var(--mono);
    font-size: 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 4px 10px;
    color: var(--muted);
    white-space: nowrap;
    flex-shrink: 0
}

.dom-btn {
    font-family: var(--sans);
    font-size: 11px;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--bg);
    color: var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap
}

.dom-btn:hover {
    background: var(--border);
    color: var(--ink1)
}

.dom-btn.active {
    background: var(--ink1);
    color: #fff;
    border-color: var(--ink1)
}

.dom-btn span {
    display: none
}

.legend {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
    flex-shrink: 0
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-family: var(--mono);
    font-size: 10px;
    color: var(--muted)
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, .1)
}

#map-wrap {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #b8cfe0
}

#map-svg {
    width: 100%;
    height: 100%;
    cursor: grab;
    user-select: none
}

#map-svg:active {
    cursor: grabbing
}

.country {
    fill: #e8e3d8;
    stroke: #8c8878;
    stroke-width: 1.0;
    transition: fill .15s
}

.country:hover {
    fill: #d4d0c4
}

.city-dot {
    cursor: pointer;
    transition: r .1s
}

.city-dot:hover {
    stroke-width: 2.5
}

.city-label {
    font-family: var(--mono);
    font-size: 9px;
    fill: var(--ink1);
    pointer-events: none;
    opacity: 0
}

#popup {
    display: none;
    position: absolute;
    z-index: 100;
    width: 260px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 0 4px 20px rgba(0, 0, 0, .15);
    border: 1px solid var(--border);
    overflow: hidden
}

.popup-hdr {
    background: var(--ink1);
    color: #fff;
    padding: 10px 14px
}

.popup-city {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px
}

.popup-meta {
    font-family: var(--mono);
    font-size: 9px;
    opacity: .55;
    text-transform: uppercase;
    letter-spacing: .05em
}

.popup-avg {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 14px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    font-size: 11px;
    font-family: var(--mono)
}

.popup-avg-val {
    font-size: 15px;
    font-weight: 600
}

.popup-body {
    padding: 4px 0;
    max-height: 260px;
    overflow-y: auto
}

.popup-close {
    position: absolute;
    top: 8px;
    right: 10px;
    background: none;
    border: none;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    opacity: .6;
    line-height: 1
}

.popup-close:hover {
    opacity: 1
}

.domain-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    text-decoration: none;
    color: var(--ink1);
    cursor: pointer;
    transition: background .1s;
    gap: 8px
}

.domain-row:last-child {
    border-bottom: none
}

.domain-row:hover {
    background: #f0ede6
}

.d-name {
    flex: 1;
    font-size: 12px
}

.d-score {
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap
}

.country-label {
    font-family: var(--mono);
    font-size: 8.5px;
    fill: #4a4840;
    pointer-events: none;
    text-anchor: middle;
    dominant-baseline: central;
    font-weight: 500;
    letter-spacing: .02em
}

#level-tooltip {
    display: none;
    position: fixed;
    z-index: 9999;
    background: var(--ink1);
    color: #fff;
    font-size: 11px;
    line-height: 1.6;
    padding: 10px 14px;
    border-radius: var(--radius);
    max-width: 300px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, .3);
    pointer-events: none
}

.tt-level {
    font-family: var(--mono);
    font-size: 9px;
    letter-spacing: .08em;
    text-transform: uppercase;
    opacity: .6;
    margin-bottom: 5px
}

.tt-bar {
    height: 3px;
    border-radius: 2px;
    margin-bottom: 8px
}