:root {
    color-scheme: light;
    --ink: #18212b;
    --muted: #5d6876;
    --line: #d8dee6;
    --panel: rgba(255, 255, 255, 0.94);
    --panel-solid: #ffffff;
    --blue: #1d4ed8;
    --teal: #00897b;
    --rose: #d63b55;
    --amber: #d88918;
    --shadow: 0 18px 45px rgba(18, 28, 45, 0.18);
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
}

body {
    min-width: 320px;
    overflow: hidden;
    color: var(--ink);
    font-family: Arial, "Microsoft YaHei", "PingFang SC", sans-serif;
    background: #eef2f5;
}

button,
input {
    font: inherit;
}

.app-shell {
    position: relative;
    width: 100vw;
    height: 100vh;
}

.map-stage,
.map {
    width: 100%;
    height: 100%;
}

.map {
    background: #dfe7ed;
}

/* Leaflet layout fallback. This keeps tiles correctly stacked even if CDN CSS is blocked. */
.leaflet-container {
    position: relative;
    overflow: hidden;
    outline: 0;
    background: #dfe7ed;
    font-family: inherit;
}

.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
    position: absolute;
    left: 0;
    top: 0;
}

.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow {
    user-select: none;
    -webkit-user-drag: none;
}

.leaflet-tile {
    width: 256px;
    height: 256px;
    border: 0;
    filter: saturate(0.92);
}

.leaflet-tile-pane {
    z-index: 200;
}

.leaflet-overlay-pane {
    z-index: 400;
}

.leaflet-shadow-pane {
    z-index: 500;
}

.leaflet-marker-pane {
    z-index: 600;
}

.leaflet-tooltip-pane {
    z-index: 650;
}

.leaflet-popup-pane {
    z-index: 700;
}

.leaflet-container img {
    max-width: none;
    max-height: none;
}

.leaflet-control-container .leaflet-top,
.leaflet-control-container .leaflet-bottom {
    position: absolute;
    z-index: 1000;
    pointer-events: none;
}

.leaflet-control-container .leaflet-top {
    top: 0;
}

.leaflet-control-container .leaflet-bottom {
    bottom: 0;
}

.leaflet-control-container .leaflet-left {
    left: 0;
}

.leaflet-control-container .leaflet-right {
    right: 0;
}

.leaflet-control {
    position: relative;
    z-index: 1000;
    margin: 10px;
    pointer-events: auto;
}

.leaflet-right .leaflet-control {
    float: right;
}

.leaflet-bottom .leaflet-control {
    margin-bottom: 14px;
}

.leaflet-control-zoom {
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(18, 28, 45, 0.18);
}

.leaflet-control-zoom a {
    display: block;
    width: 34px;
    height: 34px;
    color: var(--ink);
    background: #fff;
    text-align: center;
    text-decoration: none;
    font-size: 20px;
    font-weight: 700;
    line-height: 34px;
}

.leaflet-control-zoom a + a {
    border-top: 1px solid var(--line);
}

.leaflet-popup {
    position: absolute;
    text-align: center;
}

.leaflet-popup-content-wrapper {
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 12px 28px rgba(18, 28, 45, 0.22);
}

.leaflet-popup-tip-container,
.leaflet-tooltip {
    position: absolute;
}

.control-panel {
    position: absolute;
    top: 18px;
    left: 18px;
    z-index: 800;
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: min(390px, calc(100vw - 36px));
    max-height: calc(100vh - 36px);
    padding: 18px;
    overflow: auto;
    border: 1px solid rgba(216, 222, 230, 0.9);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
}

.panel-head {
    display: grid;
    gap: 7px;
}

.eyebrow {
    margin: 0;
    color: var(--blue);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin: 0;
}

h1 {
    font-size: 28px;
    line-height: 1.16;
}

h2 {
    font-size: 15px;
}

.panel-head p:not(.eyebrow),
.source-note {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.55;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    background: var(--panel-solid);
}

.stats-grid div {
    min-width: 0;
    padding: 12px 10px;
    border-right: 1px solid var(--line);
}

.stats-grid div:last-child {
    border-right: 0;
}

.stats-grid strong {
    display: block;
    font-size: 22px;
    line-height: 1.05;
}

.stats-grid span {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

.field {
    display: grid;
    gap: 8px;
}

.field label,
.label {
    color: #2a3542;
    font-size: 13px;
    font-weight: 700;
}

.search-row {
    display: grid;
    grid-template-columns: 1fr 38px;
    gap: 8px;
}

input[type="search"] {
    width: 100%;
    min-width: 0;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    outline: 0;
    background: #fff;
}

input[type="search"]:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.14);
}

.icon-button,
.segment,
.list-head button {
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--ink);
    background: #fff;
    cursor: pointer;
}

.icon-button {
    width: 38px;
    height: 40px;
    font-size: 22px;
    line-height: 1;
}

.segmented {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.segment {
    min-width: 0;
    height: 38px;
    padding: 0 6px;
    white-space: nowrap;
}

.segment.active {
    border-color: var(--blue);
    color: #fff;
    background: var(--blue);
}

.checks {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.checks label {
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--ink);
    font-weight: 500;
}

.checks input {
    width: 16px;
    height: 16px;
    accent-color: var(--blue);
}

.legend {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
}

.legend div {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.08);
}

.dot.mega {
    background: var(--rose);
}

.dot.large {
    background: var(--amber);
}

.dot.regional {
    background: var(--teal);
}

.city-list {
    display: grid;
    gap: 10px;
    min-height: 0;
}

.list-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.list-head button {
    height: 32px;
    padding: 0 10px;
    color: var(--blue);
    font-size: 13px;
    font-weight: 700;
}

#cityList {
    display: grid;
    gap: 7px;
    max-height: 230px;
    margin: 0;
    padding: 0;
    overflow: auto;
    list-style: none;
}

#cityList li {
    display: grid;
    grid-template-columns: 24px 1fr auto;
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
}

#cityList li:hover {
    border-color: rgba(29, 78, 216, 0.45);
}

.rank {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.city-name {
    min-width: 0;
}

.city-name strong,
.city-name span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.city-name strong {
    font-size: 14px;
}

.city-name span {
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
}

.pop {
    color: var(--ink);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.city-marker {
    border: 2px solid rgba(255, 255, 255, 0.92);
    border-radius: 50%;
    box-shadow: 0 4px 13px rgba(16, 24, 40, 0.28);
}

.city-label {
    border: 0;
    border-radius: 4px;
    padding: 3px 6px;
    color: #17202a;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 8px rgba(16, 24, 40, 0.13);
    font-size: 12px;
    font-weight: 700;
}

.leaflet-popup-content {
    min-width: 190px;
    margin: 12px 14px;
}

.popup-title {
    margin-bottom: 6px;
    font-size: 16px;
    font-weight: 800;
}

.popup-meta {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.55;
}

.source-note {
    padding-top: 2px;
}

@media (max-width: 720px) {
    body {
        overflow: hidden;
    }

    .control-panel {
        top: auto;
        right: 10px;
        bottom: 10px;
        left: 10px;
        width: auto;
        max-height: 48vh;
        padding: 14px;
    }

    h1 {
        font-size: 22px;
    }

    .panel-head p:not(.eyebrow),
    .source-note,
    .legend {
        font-size: 12px;
    }

    #cityList {
        max-height: 150px;
    }
}
