:root {
    --plane: #f4f5f7; --surface: #ffffff; --surface-2: #fafbfc;
    --ink: #0c0e12; --ink2: #545a63; --muted: #8b909a;
    --grid: #e6e8ec; --border: rgba(12, 14, 18, 0.09);
    --accent: #2a78d6; --accent-soft: rgba(42, 120, 214, 0.12);
    --good: #12a150; --warning: #e0a010; --critical: #d8433b; --heat: #ec6a33;
    --r: 20px; --r-md: 14px; --r-sm: 10px;
    --shadow-sm: 0 1px 2px rgba(12, 14, 18, .04), 0 1px 3px rgba(12, 14, 18, .06);
    --shadow-md: 0 2px 6px rgba(12, 14, 18, .05), 0 12px 32px rgba(12, 14, 18, .07);
}
:root[data-theme="dark"], html:root:not([data-theme="light"]) {
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --plane: #0a0b0d; --surface: #16181c; --surface-2: #1b1e23;
        --ink: #f4f6f8; --ink2: #b2b8c2; --muted: #767c86;
        --grid: #24272d; --border: rgba(255, 255, 255, 0.09);
        --accent: #4a92ea; --accent-soft: rgba(74, 146, 234, 0.16);
        --good: #24b463; --warning: #f0b429; --critical: #ec6a62; --heat: #f0783c;
        --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
        --shadow-md: 0 2px 8px rgba(0,0,0,.35), 0 16px 40px rgba(0,0,0,.4);
    }
}
:root[data-theme="dark"] {
    --plane: #0a0b0d; --surface: #16181c; --surface-2: #1b1e23;
    --ink: #f4f6f8; --ink2: #b2b8c2; --muted: #767c86;
    --grid: #24272d; --border: rgba(255, 255, 255, 0.09);
    --accent: #4a92ea; --accent-soft: rgba(74, 146, 234, 0.16);
    --good: #24b463; --warning: #f0b429; --critical: #ec6a62; --heat: #f0783c;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
    --shadow-md: 0 2px 8px rgba(0,0,0,.35), 0 16px 40px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    background: var(--plane); color: var(--ink);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    line-height: 1.45; -webkit-font-smoothing: antialiased; letter-spacing: -0.006em;
}
a { color: var(--accent); text-decoration: none; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px 56px; }

/* Kopf – Grid mit gleich breiten Seitenspalten: das mittige Menü bleibt zentriert,
   egal wie breit der Status-Text rechts wird (keine Verschiebung). */
.site-head { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center;
    gap: 16px; padding: 22px 0 20px; margin-bottom: 22px; border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 12px; justify-self: start; }
.brand-mark { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
    background: linear-gradient(150deg, var(--accent), color-mix(in srgb, var(--accent) 60%, #000));
    color: #fff; box-shadow: var(--shadow-sm); }
.brand-mark svg { width: 22px; height: 22px; fill: #fff; }
.brand h1 { font-size: 1.35rem; margin: 0; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.brand .subtitle { display: block; color: var(--muted); font-weight: 500; font-size: .8rem; letter-spacing: 0; }
.topnav { display: flex; gap: 24px; font-size: .92rem; font-weight: 600; justify-self: center; }
.topnav a { color: var(--ink2); transition: color .15s; }
.topnav a:hover { color: var(--accent); }
.head-right { display: flex; align-items: center; gap: 10px; justify-self: end; }
.live-pill { justify-content: center; }
@media (max-width: 680px) {
    .site-head { grid-template-columns: 1fr auto; }
    .topnav { grid-column: 1 / -1; grid-row: 2; justify-self: start; gap: 18px; padding-top: 4px; }
}
.live-pill { display: inline-flex; align-items: center; gap: 8px; font-size: .82rem; font-weight: 600;
    color: var(--ink2); background: var(--surface); border: 1px solid var(--border); padding: 7px 13px;
    border-radius: 999px; box-shadow: var(--shadow-sm); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); animation: pulse 1.9s infinite; }
.dot.off { background: var(--muted); animation: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 55%, transparent); }
    70% { box-shadow: 0 0 0 6px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.icon-btn { background: var(--surface); border: 1px solid var(--border); color: var(--ink2); border-radius: 11px;
    width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
    box-shadow: var(--shadow-sm); transition: color .15s, transform .1s; }
.icon-btn:hover { color: var(--ink); } .icon-btn:active { transform: scale(.95); }
.icon-btn svg { width: 19px; height: 19px; fill: currentColor; }

/* Grid & Karten */
.cols { display: grid; grid-template-columns: 1.05fr 1fr; gap: 18px; align-items: stretch; }
@media (max-width: 860px) { .cols { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-sm); }
.card.pad { padding: 22px; }
.card-title { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .09em;
    color: var(--muted); margin: 0 0 16px; }

/* Tesla-artiges Kombiinstrument (immer dunkle Cockpit-Fläche) */
.cluster {
    --c-ink: #f3f7fd; --c-ink2: #9aa6b8; --c-dim: #5a6473; --c-line: rgba(255, 255, 255, .09);
    position: relative; overflow: hidden; color: var(--c-ink); border-radius: var(--r);
    border: 1px solid rgba(255, 255, 255, .08);
    background:
        radial-gradient(130% 120% at 50% -10%, #212a3a 0%, #10151e 55%, #080b11 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05), var(--shadow-md);
}
.cluster-top { display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 16px 24px; border-bottom: 1px solid var(--c-line); }
.gear { display: flex; gap: 12px; font-size: 1.05rem; font-weight: 700; letter-spacing: .1em;
    color: var(--c-dim); font-variant-numeric: tabular-nums; }
.gear b { transition: color .2s; }
.gear b.active { color: var(--c-ink); text-shadow: 0 0 14px rgba(120, 180, 255, .55); }

/* Kilometerstand prominent oben in der Mitte */
.odo { text-align: center; }
.odo-val { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums;
    line-height: 1; }
.odo-val small { font-size: .82rem; font-weight: 600; color: var(--c-ink2); margin-left: 4px; }
.odo-lbl { color: var(--c-dim); font-size: .62rem; font-weight: 700; letter-spacing: .16em;
    text-transform: uppercase; margin-top: 5px; }

@keyframes glow { from { filter: brightness(1); } to { filter: brightness(1.25); } }

.cluster-main { display: grid; grid-template-columns: 1fr 1.15fr 1fr; align-items: center; gap: 12px;
    padding: 14px 24px 20px; }

/* Runde Gauges (Tacho + Batterie) */
.speedo-wrap { display: flex; justify-content: center; }
/* Power-Gauge und Mini-Map: identische Rendergröße -> gleicher Außenradius. */
.gauge { width: 100%; max-width: 220px; height: auto; overflow: visible; }
.gauge.big { max-width: 288px; }   /* Tacho als primäres Element etwas größer */
.g-track { fill: none; stroke: rgba(255, 255, 255, .08); stroke-width: 12; stroke-linecap: round; }
.g-fill { fill: none; stroke-width: 12; stroke-linecap: round; transition: stroke .3s; }
.g-fill.speed { stroke: #cfe0f5; filter: drop-shadow(0 0 6px rgba(150, 190, 245, .5)); }
.g-fill.power { stroke: #5aa0f0; filter: drop-shadow(0 0 7px rgba(90, 160, 240, .55)); }
.g-fill.regen { stroke: #35c66d; filter: drop-shadow(0 0 7px rgba(52, 200, 110, .5)); }
.g-num { fill: var(--c-ink); font-size: 66px; font-weight: 800; text-anchor: middle;
    font-variant-numeric: tabular-nums; letter-spacing: -2px; }
.g-unit { fill: var(--c-ink2); font-size: 14px; font-weight: 700; text-anchor: middle;
    letter-spacing: 1.5px; text-transform: uppercase; }
/* Kilometerstand in der offenen Tacho-Lücke unten */
.g-odo { fill: var(--c-ink); font-size: 19px; font-weight: 800; text-anchor: middle;
    font-variant-numeric: tabular-nums; }
.g-odo-u { fill: var(--c-ink2); font-size: 12px; font-weight: 600; }
.g-odo-lbl { fill: var(--c-dim); font-size: 9px; font-weight: 700; text-anchor: middle; letter-spacing: 1.6px; }

/* Runde Mini-Karte im Cluster */
.minimap-wrap { display: flex; justify-content: center; }
.minimap { position: relative; width: 100%; max-width: 220px; aspect-ratio: 1; border-radius: 50%;
    overflow: hidden; border: 2px solid rgba(255, 255, 255, .12);
    box-shadow: 0 0 0 6px rgba(255, 255, 255, .03), inset 0 0 20px rgba(0, 0, 0, .5); }
.minimap .map-el { position: absolute; inset: 0; }
.minimap-fallback { position: absolute; inset: 0; display: grid; place-items: center;
    color: var(--c-ink2); font-size: .82rem; background: rgba(255, 255, 255, .04); }

.minimap .map-el { min-height: 0; }

/* Batterie-Symbol (Tesla-artig: Rahmen mit Terminal, grafischer Füllstand) */
.top-right { display: flex; align-items: center; gap: 9px; color: var(--c-ink2); font-size: .86rem;
    font-weight: 600; white-space: nowrap; }
.top-right .cbolt svg { width: 16px; height: 16px; fill: var(--good); }
.batbar { position: relative; width: 56px; height: 24px; border: 2px solid var(--c-ink2);
    border-radius: 5px; padding: 3px; }
.batbar::after { content: ''; position: absolute; right: -6px; top: 50%; transform: translateY(-50%);
    width: 3px; height: 9px; background: var(--c-ink2); border-radius: 0 2px 2px 0; }
.batbar-fill { display: block; height: 100%; border-radius: 2px; background: #35c66d;
    transition: width .7s cubic-bezier(.3,.7,.3,1); }
.batbar-fill.warn { background: var(--warning); }
.batbar-fill.crit { background: var(--critical); }
.batbar-fill.charging { animation: glow 1.7s ease-in-out infinite alternate; }
.bat-pct { font-weight: 750; color: var(--c-ink); font-variant-numeric: tabular-nums; }
.bat-pct small { font-size: .72rem; font-weight: 600; color: var(--c-ink2); margin-left: 1px; }
.bat-rng { color: var(--c-ink2); }

/* Vergrößern-Button auf der Mini-Karte */
.minimap-expand { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); z-index: 500;
    display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px;
    border-radius: 999px; cursor: pointer; color: #fff; font: inherit; font-size: .72rem; font-weight: 700;
    background: rgba(10, 14, 20, .72); border: 1px solid rgba(255, 255, 255, .2); backdrop-filter: blur(4px); }
.minimap-expand svg { width: 15px; height: 15px; fill: currentColor; }
.minimap-expand:hover { background: rgba(10, 14, 20, .9); }

/* Vollbild-Karte (Modal) */
.map-modal { position: fixed; inset: 0; z-index: 1000; background: rgba(0, 0, 0, .6);
    display: grid; place-items: center; padding: 20px; }
.map-modal-inner { position: relative; width: min(1000px, 96vw); height: min(80vh, 760px);
    background: var(--surface); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow-md); }
.map-modal-inner .map-el { position: absolute; inset: 0; height: 100%; min-height: 0; }
.map-modal-close { position: absolute; top: 12px; right: 12px; z-index: 600; width: 38px; height: 38px;
    border-radius: 10px; border: none; cursor: pointer; font-size: 17px; line-height: 1;
    background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* Telltale-Kontrollleuchten */
.cluster-foot { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px;
    padding: 18px 20px 20px; border-top: 1px solid var(--c-line); }
.lamp { display: inline-flex; width: 36px; height: 36px; align-items: center; justify-content: center;
    border-radius: 10px; color: var(--c-dim); background: rgba(255, 255, 255, .03);
    border: 1px solid var(--c-line); transition: color .25s, background .25s, box-shadow .25s, border-color .25s; }
.lamp svg { width: 21px; height: 21px; fill: currentColor; }
.lamp.on.grn { color: #3ad07a; background: rgba(52, 200, 110, .14); border-color: rgba(52, 200, 110, .4); box-shadow: 0 0 12px rgba(52, 200, 110, .35); }
.lamp.on.blu { color: #5aa0f0; background: rgba(90, 160, 240, .14); border-color: rgba(90, 160, 240, .4); box-shadow: 0 0 12px rgba(90, 160, 240, .35); }
.lamp.on.amb { color: #f0a83c; background: rgba(240, 150, 50, .15); border-color: rgba(240, 150, 50, .42); box-shadow: 0 0 12px rgba(240, 150, 50, .35); }
.lamp.on.red { color: #ff5a4e; background: rgba(255, 70, 60, .14); border-color: rgba(255, 70, 60, .4); box-shadow: 0 0 12px rgba(255, 70, 60, .32); }

/* Mobil: nicht umbrechen, Gauges nur kleiner */
@media (max-width: 760px) {
    .cluster-top { padding: 12px 14px; gap: 8px; }
    .bat-rng { display: none; }
    .cluster-main { grid-template-columns: 1fr 1.1fr 1fr; gap: 6px; padding: 10px 10px 14px; }
    .gauge, .minimap { max-width: 100%; }
    .odo-val { font-size: 1.25rem; }
    .cluster-foot { gap: 7px; padding: 14px 10px; }
    .lamp { width: 32px; height: 32px; }
    .lamp svg { width: 17px; height: 17px; }
    .map-modal { padding: 10px; }
    .map-modal-inner { height: 84vh; }
}
@media (max-width: 420px) {
    .lamp { width: 28px; height: 28px; border-radius: 8px; }
    .lamp svg { width: 15px; height: 15px; }
    .gear { gap: 8px; font-size: .95rem; }
}

/* Status-Chips (Cluster-Fuß) */
.chip { font-size: .8rem; font-weight: 600; padding: 6px 12px; border-radius: 999px; display: inline-flex;
    align-items: center; gap: 6px; border: 1px solid transparent; white-space: nowrap; }
.chip.good { color: #4bd688; background: rgba(52, 200, 110, .14); }
.chip.crit { color: var(--critical); background: color-mix(in srgb, var(--critical) 18%, transparent); }
.chip.neutral { color: var(--c-ink2); background: rgba(255, 255, 255, .06); }
.chip.heat { color: var(--heat); background: color-mix(in srgb, var(--heat) 18%, transparent); }
.chip svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; }

/* Karte */
.card.map { overflow: hidden; min-height: 460px; padding: 0; }
.map-el { height: 100%; min-height: 460px; background: var(--grid); }
.map-fallback { padding: 28px; color: var(--ink2); text-align: center; }
.leaflet-container { background: var(--grid); font-family: inherit; }
.leaflet-control-attribution { background: color-mix(in srgb, var(--surface) 85%, transparent) !important;
    color: var(--muted) !important; font-size: 10px; border-radius: 8px 0 0 0; }
.leaflet-control-attribution a { color: var(--ink2) !important; }
.leaflet-bar { border: none !important; box-shadow: var(--shadow-sm) !important; border-radius: 11px !important; overflow: hidden; }
.leaflet-bar a { background: var(--surface) !important; color: var(--ink) !important; border-color: var(--border) !important; }
.leaflet-bar a:hover { background: var(--grid) !important; }

.carmark { position: relative; }
.carmark-pulse { position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%;
    background: var(--accent); opacity: .35; animation: mpulse 1.9s infinite ease-out; }
@keyframes mpulse { 0% { transform: scale(.45); opacity: .5; } 100% { transform: scale(1.7); opacity: 0; } }
.carmark-dot { position: absolute; left: 8px; top: 8px; width: 10px; height: 10px; border-radius: 50%;
    background: var(--accent); border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.45); }
.carmark-arrow { position: absolute; left: 5px; top: 3px; width: 0; height: 0;
    border-left: 8px solid transparent; border-right: 8px solid transparent; border-bottom: 17px solid var(--accent);
    transform-origin: 50% 62%; filter: drop-shadow(0 1px 2px rgba(0,0,0,.4)); }

/* KPI-Tiles */
.tiles { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
@media (max-width: 860px) { .tiles { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 500px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
.tile { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 15px;
    transition: transform .12s, box-shadow .15s, border-color .15s; }
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); }
.tile .lbl { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: .68rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .06em; }
.tile .lbl svg { width: 15px; height: 15px; stroke: var(--accent); fill: none; stroke-width: 2; }
.tile .val { font-size: 1.45rem; font-weight: 700; margin-top: 9px; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.tile .val small { font-size: .82rem; font-weight: 600; color: var(--ink2); margin-left: 3px; }

.section-gap { margin-top: 18px; }

/* Footer */
.site-foot { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap;
    color: var(--muted); font-size: .82rem; margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--border); }
.site-foot a { color: var(--ink2); }
.foot-right { display: flex; gap: 16px; align-items: center; }
.toggle { background: var(--surface); border: 1px solid var(--border); color: var(--ink2); border-radius: 10px;
    padding: 7px 13px; font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer; box-shadow: var(--shadow-sm);
    transition: color .15s; }
.toggle:hover { color: var(--ink); }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
table caption { text-align: left; color: var(--muted); font-size: .72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .09em; padding: 4px 0 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--grid); }
th { color: var(--ink2); font-weight: 500; }
td:last-child { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
tr:last-child th, tr:last-child td { border-bottom: none; }
[hidden] { display: none !important; }
