:root {
    --bg: #0f1b1e;
    --panel: #15282d;
    --panel-2: #1d343a;
    --ink: #e8f1f2;
    --muted: #8fa9ad;
    --border: #26424a;
    --accent: #2dd4bf;
    --accent-ink: #06312c;
    --good: #2dd4bf;
    --bad: #e8746a;
}
* { box-sizing: border-box; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
body {
    margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg); color: var(--ink); height: 100vh; display: flex; flex-direction: column;
}

.topbar {
    display: flex; align-items: center; gap: 12px; padding: 8px 16px; min-height: 56px;
    background: linear-gradient(90deg, #0c1719, #15282d); border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.brand { font-size: 1.05rem; white-space: nowrap; }
.brand-mark { color: var(--accent); margin-right: 5px; }
.brand strong { color: var(--accent); }

select#indicator, .search-wrap input, .tbtn, .seg-btn {
    background: var(--panel); color: var(--ink); border: 1px solid var(--border);
    border-radius: 8px; padding: 8px 11px; font-size: .88rem; font-family: inherit;
}
select#indicator { min-width: 230px; font-weight: 600; cursor: pointer; }
.ind-pick { display: flex; }

.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.seg-btn { border: 0; background: transparent; color: var(--muted); border-radius: 999px; padding: 6px 13px; cursor: pointer; font-weight: 600; }
.seg-btn.active { background: var(--accent); color: var(--accent-ink); }

.search-wrap { position: relative; }
.search-wrap input { min-width: 170px; }
.ac {
    position: absolute; z-index: 1200; top: 110%; left: 0; right: 0; margin: 0; padding: 4px; list-style: none;
    background: var(--panel); border: 1px solid var(--border); border-radius: 8px; max-height: 280px; overflow-y: auto;
    box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.ac li { padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: .87rem; }
.ac li:hover, .ac li.sel { background: var(--panel-2); }
.ac li small { color: var(--muted); }

.tbtn { cursor: pointer; white-space: nowrap; font-weight: 600; }
.tbtn:hover { background: var(--panel-2); }
.tbtn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.layout { flex: 1; display: grid; grid-template-columns: 1fr 360px; min-height: 0; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } .sidebar { display: none; } }

.map-wrap { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; background: #0c1719; }

.legend, .readout {
    position: absolute; z-index: 500; background: rgba(21,40,45,.95); border: 1px solid var(--border);
    border-radius: 10px; padding: 11px 13px; box-shadow: 0 6px 20px rgba(0,0,0,.45);
}
.legend { left: 12px; bottom: 12px; font-size: .78rem; max-width: 240px; }
.legend h3 { margin: 0 0 7px; font-size: .8rem; color: var(--muted); }
.legend .row { display: flex; align-items: center; gap: 8px; margin: 2px 0; }
.legend .sw { width: 16px; height: 12px; border-radius: 3px; }

.readout { right: 12px; top: 12px; min-width: 230px; max-width: 270px; }
.readout-hint { color: var(--muted); font-size: .85rem; }
.readout .r-name { font-size: 1.05rem; font-weight: 700; }
.readout .r-bl { color: var(--muted); font-size: .8rem; margin-bottom: 8px; }
.readout .r-rank { display: inline-block; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: .76rem; padding: 2px 9px; border-radius: 999px; margin-bottom: 8px; }
.readout table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.readout td { padding: 2px 0; }
.readout td.v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.readout tr.hl td { color: var(--accent); }
.readout .cmp-add { margin-top: 9px; width: 100%; background: var(--panel-2); color: var(--ink); border: 1px solid var(--border); border-radius: 7px; padding: 7px; cursor: pointer; font-weight: 600; }

.sidebar { background: var(--panel); border-left: 1px solid var(--border); padding: 14px 14px 0; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.sidebar .panel { background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.sidebar h2 { margin: 0 0 2px; font-size: 1rem; }
.sidebar-sub { margin: 0 0 8px; color: var(--muted); font-size: .8rem; }
.rank-toggle, .rk-btn { font-size: .78rem; }
.rank-toggle { display: inline-flex; gap: 4px; margin-bottom: 8px; }
.rk-btn { background: var(--panel); color: var(--muted); border: 1px solid var(--border); border-radius: 6px; padding: 4px 9px; cursor: pointer; }
.rk-btn.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.ranking { list-style: none; margin: 0; padding: 0; counter-reset: r; }
.ranking li { counter-increment: r; display: grid; grid-template-columns: 24px 1fr auto; gap: 9px; align-items: center; padding: 5px 6px; border-radius: 6px; font-size: .85rem; cursor: pointer; }
.ranking li:hover { background: var(--panel); }
.ranking li::before { content: counter(r); color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.ranking .rk-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ranking .rk-val { font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 600; }

.histogram { display: flex; align-items: flex-end; gap: 2px; height: 90px; }
.histogram .hbar { flex: 1; background: var(--accent); border-radius: 2px 2px 0 0; min-height: 2px; opacity: .85; }
.histogram .hbar.active { background: #fff; }
.hist-meta { color: var(--muted); font-size: .76rem; margin: 6px 0 0; }
.source { color: var(--muted); font-size: .72rem; line-height: 1.5; padding: 4px 0 14px; }

/* Vergleichs-Leiste */
.compare-bar { display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: #0c1719; border-top: 1px solid var(--border); }
.cmp-title { font-weight: 700; color: var(--accent); }
.cmp-slot { flex: 1; max-width: 260px; background: var(--panel); border: 1px dashed var(--border); border-radius: 8px; padding: 7px 11px; font-size: .85rem; min-height: 36px; display: flex; align-items: center; justify-content: space-between; }
.cmp-slot.filled { border-style: solid; }
.cmp-empty { color: var(--muted); }
.cmp-slot .x { cursor: pointer; color: var(--muted); padding-left: 8px; }
.cmp-open { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 8px; padding: 8px 14px; font-weight: 700; cursor: pointer; }
.cmp-open:disabled { opacity: .4; cursor: default; }
.cmp-close { margin-left: auto; background: transparent; border: 0; color: var(--muted); font-size: 1.3rem; cursor: pointer; }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 3000; background: rgba(4,10,11,.72); display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; max-width: 760px; width: 100%; max-height: 86vh; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 1.15rem; }
.modal-x { background: transparent; border: 0; color: var(--muted); font-size: 1.5rem; cursor: pointer; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-body table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.modal-body th, .modal-body td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--border); }
.modal-body td.num { text-align: right; font-variant-numeric: tabular-nums; }
.modal-body td.win { color: var(--accent); font-weight: 700; }
.modal-body .meth-ind { font-weight: 600; }
.modal-body small { color: var(--muted); }

.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--panel); color: var(--ink); }
.leaflet-container { font: inherit; background: #0c1719; }
