:root {
  --ink: #0f172a; --ink2: #334155; --muted: #64748b; --line: #e2e8f0; --soft: #f1f5f9; --bg: #fff;
  --accent: #2563eb; --accent-soft: #dbeafe; --good: #15803d; --good-soft: #dcfce7; --r: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); }
button { font: inherit; cursor: pointer; color: inherit; }
input { font: inherit; color: inherit; }
#map { position: fixed; inset: 0; }

/* ---------- Panel */
.panel {
  position: fixed; top: 12px; left: 12px; bottom: 12px; width: 380px; z-index: 2;
  display: flex; flex-direction: column; background: var(--bg); border-radius: 16px;
  box-shadow: 0 10px 40px rgba(15,23,42,.18); overflow: hidden;
}
.head { padding: 12px 14px 4px; }
.head h1 { margin: 0; font-size: 16px; letter-spacing: -.01em; }
.head h1 small { font-weight: 500; color: var(--muted); font-size: 12px; margin-left: 4px; }
.grip { display: none; }
.block { padding: 8px 14px 0; display: grid; gap: 6px; }
.row { display: flex; gap: 6px; align-items: center; }
.grow { flex: 1; min-width: 0; }
input[type=text], input[type=search], input[type=datetime-local] {
  width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px; background: #f8fafc; font-size: 13px;
}
input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); background: #fff; }
.icon { flex: none; height: 36px; min-width: 36px; border: 1px solid var(--line); background: #f8fafc; border-radius: 9px; font-size: 16px; }
.icon.wide { font-size: 12px; font-weight: 600; padding: 0 10px; }
.icon:hover { background: var(--accent-soft); }

/* Segment-Schalter */
.seg { display: inline-flex; background: var(--soft); padding: 3px; border-radius: 10px; gap: 2px; flex: none; }
.seg button { border: 0; background: transparent; height: 30px; min-width: 34px; padding: 0 8px; border-radius: 8px; color: var(--muted); font-size: 14px; }
.seg button.on { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(15,23,42,.14); }
.seg.sm button { height: 24px; min-width: 28px; font-size: 12px; padding: 0 7px; }

/* Dauer */
.dur { padding-top: 10px; gap: 0; }
.durhead { display: flex; align-items: center; gap: 10px; }
.big { font-size: 26px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; min-width: 74px; }
.big small { font-size: 13px; font-weight: 500; color: var(--muted); }
.arr { margin-left: auto; text-align: right; font-size: 11px; color: var(--muted); line-height: 1.25; }
.arr b { color: var(--ink2); font-size: 13px; }
input[type=range] { width: 100%; margin: 2px 0 0; accent-color: var(--accent); height: 24px; }

/* Reiter */
.tabs { display: flex; gap: 2px; margin: 6px 14px 0; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; border: 0; background: none; padding: 8px 4px 9px; font-size: 13px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button b { font-weight: 600; font-size: 11px; background: var(--soft); color: var(--ink2); border-radius: 999px; padding: 1px 6px; margin-left: 2px; font-variant-numeric: tabular-nums; }
.tabs button.on { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }
.tabs button.on b { background: var(--accent); color: #fff; }
.tabbody { flex: 1; overflow: auto; padding: 10px 14px 6px; }
.tab { display: none; }
.tab.on { display: grid; gap: 8px; align-content: start; }

/* Kennzahlen */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.kpis.two { grid-template-columns: 1fr 1fr; }
.kpis div { background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 6px 9px; }
.kpis b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.kpis span { font-size: 11px; color: var(--muted); }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chips button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 3px 10px; font-size: 12px; color: var(--muted); }
.chips button.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.find { height: 34px !important; }

/* Listen */
.list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.list li { display: flex; align-items: center; gap: 8px; padding: 6px 2px; border-bottom: 1px solid #f1f5f9; cursor: pointer; }
.list li:hover, .list li.sel { background: var(--accent-soft); }
.list .nm { flex: 1; min-width: 0; }
.list .nm b { display: block; font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .nm span { display: block; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .tm { text-align: right; font-size: 12px; color: var(--ink2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.list .tm small { display: block; color: var(--muted); font-size: 11px; }
.list li.out .nm b, .list li.out .tm { color: #b45309; }
.list li.info { cursor: default; color: var(--muted); font-size: 12px; justify-content: center; }
.note { margin: 0; font-size: 11px; color: var(--muted); }

/* Schalter */
.switch { display: flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }
.switch input { display: none; }
.switch span { width: 34px; height: 20px; border-radius: 999px; background: #cbd5e1; position: relative; transition: .15s; flex: none; }
.switch span::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { left: 16px; }

/* Vergleich */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .tip { position: absolute; pointer-events: none; background: #fff; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 6px 20px rgba(15,23,42,.14); padding: 6px 8px; font-size: 12px; white-space: nowrap; display: none; z-index: 3; }
.chart .tip b { display: block; margin-bottom: 2px; }
.chart .tip i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }
.chart .legend2 { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--ink2); margin-top: 4px; }
.chart .legend2 i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }
.cmp { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.cmp th { font-weight: 600; color: var(--muted); font-size: 11px; text-align: right; padding: 4px 4px; border-bottom: 1px solid var(--line); }
.cmp th:first-child { text-align: left; }
.cmp td { padding: 5px 4px; border-bottom: 1px solid #f1f5f9; text-align: right; }
.cmp td.loc { text-align: left; max-width: 130px; cursor: pointer; }
.cmp td.loc b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.cmp td.loc i { display: inline-block; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
.cmp td.best { background: var(--good-soft); color: var(--good); font-weight: 700; border-radius: 6px; }
.cmp td.x { width: 20px; padding: 0; }
.cmp td.x button { border: 0; background: none; color: var(--muted); font-size: 14px; padding: 2px 4px; }
.cmp td.x button:hover { color: #b91c1c; }

/* Suche */
.search { position: relative; }
.sugg { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(15,23,42,.14); list-style: none; margin: 0; padding: 4px; z-index: 5; display: none; max-height: 260px; overflow: auto; }
.sugg li { padding: 7px 9px; border-radius: 7px; cursor: pointer; font-size: 13px; }
.sugg li:hover, .sugg li.on { background: var(--accent-soft); }

/* Status */
.status { border-top: 1px solid var(--line); padding: 7px 14px; font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; min-height: 32px; }
.status.err { color: #b91c1c; }
.spin { width: 12px; height: 12px; border: 2px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; animation: s .8s linear infinite; display: none; flex: none; }
.loading .spin { display: inline-block; }
@keyframes s { to { transform: rotate(360deg); } }

/* Karte oben rechts */
.mapbar { position: fixed; top: 12px; right: 12px; z-index: 2; display: flex; gap: 8px; align-items: center; }
.mapbar .seg { box-shadow: 0 4px 14px rgba(15,23,42,.15); background: #fff; }
.legend { display: flex; align-items: center; gap: 6px; background: #fff; border-radius: 10px; padding: 6px 10px; font-size: 11px; color: var(--muted);
  box-shadow: 0 4px 14px rgba(15,23,42,.15); }
.legend i { width: 90px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, #10b981, #84cc16, #facc15, #f97316, #ef4444); }
.cmpmark { width: 22px; height: 22px; border-radius: 50%; color: #fff; font: 700 12px/22px system-ui, sans-serif; text-align: center;
  border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.3); cursor: pointer; }
.maplibregl-ctrl-attrib { font-size: 11px; }

/* ---------- Handy: Panel unten */
@media (max-width: 700px) {
  .panel { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: 58%; border-radius: 18px 18px 0 0; }
  .panel.min { height: auto; }
  .panel.min .block:not(.dur), .panel.min .tabbody, .panel.min .tabs { display: none; }
  .grip { display: block; width: 44px; height: 5px; border-radius: 3px; background: #cbd5e1; border: 0; margin: 0 auto 8px; padding: 0; }
  .head { padding-top: 8px; }
  .head h1 small { display: none; }
  .mapbar { top: 10px; right: 10px; left: 10px; justify-content: space-between; }
  .legend i { width: 60px; }
  .maplibregl-ctrl-bottom-right { bottom: 58%; }
  .panel.min ~ .maplibregl-ctrl-bottom-right { bottom: 140px; }
  .status { padding-bottom: calc(7px + env(safe-area-inset-bottom)); }
}

/* Icons */
.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; flex: none; }
.seg button .i { width: 18px; height: 18px; vertical-align: -4px; }
.seg.sm button .i { width: 14px; height: 14px; vertical-align: -2px; margin-right: 2px; }
.icon .i { width: 18px; height: 18px; vertical-align: middle; }
.icon.wide .i { width: 14px; height: 14px; vertical-align: -2px; }
.tabs button .i { width: 15px; height: 15px; vertical-align: -3px; margin-right: 1px; }
.chips button .i { width: 13px; height: 13px; vertical-align: -2px; }
.cmp td.x .i { width: 14px; height: 14px; }
.logo { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; background: var(--accent); color: #fff; margin-right: 7px; vertical-align: -6px; }
.logo .i { width: 15px; height: 15px; vertical-align: 0; }
.has-i { position: relative; }
.has-i > .i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.has-i > input { padding-left: 32px !important; }
.arrin { display: flex; align-items: center; gap: 6px; height: 36px; padding: 0 8px; border: 1px solid var(--line); border-radius: 9px; background: #f8fafc; color: var(--muted); font-size: 12px; }
.arrin input { border: 0 !important; background: transparent !important; height: 32px !important; padding: 0 !important; outline: none; min-width: 0; flex: 1; font-size: 13px; color: var(--ink); }
.arrin:focus-within { border-color: var(--accent); background: #fff; }
.cmp td.loc i { width: 16px; height: 16px; color: #fff; font: 700 10px/16px system-ui, sans-serif; text-align: center; font-style: normal; }
.cmp td.err { color: #b91c1c; text-align: left; }
.cmp .spin.on { display: inline-block; }

/* Layout-Fixes: Grid-/Flex-Kinder dürfen schrumpfen */
.block, .tab.on { grid-template-columns: minmax(0, 1fr); }
.row > * { min-width: 0; }
.arrin input { width: 100%; }
.tabs button { white-space: nowrap; display: flex; align-items: center; justify-content: center; gap: 4px; padding-left: 2px; padding-right: 2px; }
.tabs button b { margin-left: 0; }
.chart, .cmp { max-width: 100%; }
@media (max-width: 700px) { .panel { height: 62%; } }

/* Haupt-Tabs (Apps) */
.apps { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--soft); padding: 4px; border-radius: 12px; }
.apps button { border: 0; background: transparent; height: 34px; border-radius: 9px; font-weight: 600; font-size: 13px; color: var(--muted);
  display: flex; align-items: center; justify-content: center; gap: 6px; }
.apps button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(15,23,42,.14); }
.apps button[data-app="pv"].on .i { color: #d97706; }
.apps button[data-app="fitness"].on .i { color: #e11d48; }
.tabs button[hidden] { display: none; }
.list .tm a { color: var(--accent); font-size: 11px; text-decoration: none; }

/* Filter-Trichter */
.fhead { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.link { border: 0; background: none; color: var(--accent); font-size: 12px; font-weight: 600; padding: 2px 0; }
.funnel { display: grid; gap: 4px; }
.step { border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px 7px; cursor: pointer; background: #fff; }
.step:hover { border-color: #cbd5e1; }
.step.sel { border-color: #f59e0b; background: #fffbeb; }
.step.s0, .step.fin { cursor: default; background: #f8fafc; }
.step.fin { background: var(--accent-soft); border-color: #bfdbfe; }
.sh { display: flex; align-items: center; gap: 7px; font-size: 13px; }
.sh .no { width: 18px; height: 18px; border-radius: 50%; background: var(--soft); color: var(--ink2); font-size: 11px; font-weight: 700; display: grid; place-items: center; flex: none; }
.step.fin .no { background: var(--accent); color: #fff; }
.sh .sn { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--ink2); }
.sh .sn em { font-style: normal; color: #b45309; font-size: 12px; margin-left: 3px; }
.ctl { font-size: 12px; color: var(--muted); margin: 5px 0 0 25px; display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.ctl select { font: inherit; font-size: 12px; color: var(--ink); border: 1px solid var(--line); border-radius: 7px; padding: 2px 4px; background: #f8fafc; }
.ck { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.kinds { display: flex; flex-wrap: wrap; gap: 4px; }
.kinds button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 1px 8px; font-size: 11px; color: var(--muted); }
.kinds button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.sbar { position: relative; height: 5px; border-radius: 3px; background: var(--soft); margin: 6px 0 0 25px; overflow: hidden; display: flex; }
.sbar i { display: block; height: 100%; background: var(--accent); border-radius: 3px 0 0 3px; }
.sbar u { display: block; height: 100%; background: #fbbf24; }
.step.s0 .sbar i { background: #94a3b8; }
.list li.hd { cursor: default; font-size: 11px; font-weight: 700; color: var(--ink2); text-transform: uppercase; letter-spacing: .03em; background: #f8fafc; justify-content: flex-start; }

.step .sub { font-size: 11px; color: var(--muted); margin: 3px 0 0 25px; }
.step .sub em { font-style: normal; color: #b45309; }

/* Gym-Stufen */
.kpis.tiers button { text-align: left; border: 1px solid var(--line); background: #f8fafc; border-radius: 10px; padding: 6px 9px; opacity: .45; }
.kpis.tiers button.on { opacity: 1; }
.kpis.tiers button[data-tier="premium"].on { background: #fffbeb; border-color: #f59e0b; }
.kpis.tiers button[data-tier="komfort"].on { background: #eff6ff; border-color: #93c5fd; }
.kpis.tiers button[data-tier="standard"].on { background: #f8fafc; border-color: #cbd5e1; }
.kpis.tiers b { display: block; font-size: 17px; }
.kpis.tiers span { font-size: 11px; color: var(--muted); }
.tier { font-style: normal; font-size: 10px; font-weight: 700; border-radius: 5px; padding: 1px 5px; margin-right: 6px; vertical-align: 1px; }
.t-premium { background: #f59e0b; color: #fff; }
.t-komfort { background: #dbeafe; color: #1e40af; }
.t-standard { background: #e2e8f0; color: #475569; }

.legend.roads { gap: 5px; }
.legend.roads b { display: inline-block; width: 16px; height: 4px; border-radius: 2px; margin-left: 4px; }
.r-a { background: #2563eb; } .r-b { background: #eab308; } .r-l { background: #808080; } .r-o { background: #b0b5bd; }
.legend[hidden] { display: none; }
@media (max-width: 700px) { .legend.roads { display: none; } }

.tblhead { font-size: 11px; color: var(--muted); margin-bottom: -4px; }

.sugg li { display: flex; gap: 8px; align-items: flex-start; }
.sugg li .i { margin-top: 2px; color: var(--muted); }
.sugg .sg { min-width: 0; }
.sugg .sg b { display: block; font-weight: 500; }
.sugg .sg small { display: block; font-size: 11px; color: var(--muted); }
.sugg .sg small.warn { color: #b45309; }

.cmpmax { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink2); font-weight: 600; }
.verdict { margin: 0; font-size: 12px; background: var(--good-soft); color: #14532d; border-radius: 9px; padding: 7px 9px; line-height: 1.4; }
.cmp th.xcol, .cmp td.xcol { font-weight: 700; color: var(--ink); }
.cmp th.xcol { color: var(--ink); }
.cmp td.rk { width: 18px; color: var(--muted); font-weight: 700; text-align: left; padding-right: 0; }
.cmp tr.win td.rk { color: var(--good); }
.cmp th { white-space: nowrap; }
.cmp td.loc { max-width: 120px; }
