:root {
  --tulip: #b0143c;
  --tulip-2: #e2365f;
  --leaf: #2f7d4a;
  --ink: #1d1b1f;
  --muted: #6c6670;
  --line: #e7e2e4;
  --bg: #fbf8f6;
  --card: #ffffff;
  --top-h: 60px;
  --panel-w: 360px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); background: var(--bg);
  overflow: hidden;
}

.top {
  position: fixed; inset: 0 0 auto 0; height: var(--top-h); z-index: 1000;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 16px; padding-top: env(safe-area-inset-top);
  background: var(--tulip); color: #fff;
  box-shadow: 0 2px 10px rgba(80, 0, 20, .25);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand h1 { font-size: 17px; margin: 0; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand p { margin: 0; font-size: 12.5px; opacity: .85; }
.tulip svg { width: 30px; height: 30px; fill: #ffd1dc; display: block; }
.live { display: flex; align-items: center; gap: 7px; font-size: 13px; white-space: nowrap;
  background: rgba(255,255,255,.14); padding: 5px 10px; border-radius: 999px; }
.live .dot { width: 9px; height: 9px; border-radius: 50%; background: #ccc; }
.live.ok .dot { background: #5eea8c; box-shadow: 0 0 0 0 rgba(94,234,140,.7); animation: pulse 2s infinite; }
.live.warn .dot { background: #ffc94d; }
.live.err .dot { background: #ff6b6b; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(94,234,140,0); } 100% { box-shadow: 0 0 0 0 rgba(94,234,140,0); } }

#map { position: fixed; top: var(--top-h); left: 0; right: var(--panel-w); bottom: 0; }

.panel {
  position: fixed; top: var(--top-h); right: 0; bottom: 0; width: var(--panel-w); z-index: 900;
  background: var(--card); border-left: 1px solid var(--line);
  overflow-y: auto; padding: 16px 16px 24px;
}
.panel section { margin-bottom: 18px; }
.panel h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; }
.grip { display: none; }

.head-line { font-weight: 600; font-size: 15.5px; margin-bottom: 10px; }
.head-line small { display: block; font-weight: 400; color: var(--muted); font-size: 13px; }
.progress { position: relative; height: 10px; background: #f0eaec; border-radius: 6px; overflow: hidden; }
.progress .covered { position: absolute; top: 0; bottom: 0; background: var(--tulip-2); border-radius: 6px; transition: all .6s; }
.progress .bar { position: absolute; top: 0; bottom: 0; left: 0; background: #e8c9d2; transition: width .6s; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.kpis div { background: var(--bg); border-radius: 10px; padding: 8px 10px; }
.kpis .k { display: block; font-size: 11.5px; color: var(--muted); }
.kpis .v { font-weight: 650; font-variant-numeric: tabular-nums; }

.info { background: #fff4f6; border: 1px solid #f5d3dc; border-radius: 10px; padding: 10px 12px; }
.info p { margin: 4px 0 0; }

.stations { list-style: none; margin: 0; padding: 0; }
.stations li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.stations li:last-child { border-bottom: 0; }
.stations .n { font-weight: 550; }
.stations .t { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stations .t small { display: block; color: var(--muted); font-size: 12px; }
.stations li.done { color: var(--muted); }
.stations li.now .t { color: var(--tulip); font-weight: 650; }
.muted { color: var(--muted); }

.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.legend li { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.legend .sw { width: 12px; height: 12px; border-radius: 50%; flex: none; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.2); }
.legend .age { margin-left: auto; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.legend .stale .age { color: #c2410c; }
.legend .meta { color: var(--muted); font-size: 12px; }

.tools { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; }
.tools button, .tools a {
  font: inherit; font-size: 14px; padding: 8px 12px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink); text-decoration: none;
}
.tools button.on { background: var(--tulip); border-color: var(--tulip); color: #fff; }
.hint { font-size: 12px; color: var(--muted); margin: 0; }

.closed { position: fixed; top: var(--top-h); inset-inline: 0; padding: 40px 20px; text-align: center; }

/* Marker */
.trk { position: relative; }
.trk .pin {
  width: 30px; height: 30px; border-radius: 50%; border: 3px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.35); display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 12px;
}
.trk.head .pin::after {
  content: ""; position: absolute; inset: -6px; border-radius: 50%;
  border: 3px solid currentColor; opacity: .5; animation: ring 1.8s infinite;
}
.trk.stale .pin { filter: grayscale(.8); opacity: .7; }
@keyframes ring { from { transform: scale(.8); opacity: .6; } to { transform: scale(1.5); opacity: 0; } }
.poi-icon { width: 14px; height: 14px; border-radius: 4px; background: #fff; border: 3px solid var(--leaf); box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.poi-icon.start { border-color: #2563eb; } .poi-icon.ziel { border-color: #111; } .poi-icon.tribuene { border-color: #d97706; }
.leaflet-tooltip.poi-label { font-weight: 600; }

/* Mobil: Panel als Bottom-Sheet */
@media (max-width: 800px) {
  :root { --top-h: 56px; }
  #map { right: 0; bottom: 34vh; }
  .panel {
    top: auto; left: 0; width: auto; height: 34vh; border-left: 0;
    border-top-left-radius: 16px; border-top-right-radius: 16px;
    box-shadow: 0 -4px 18px rgba(0,0,0,.15); padding-top: 22px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    transition: height .25s;
  }
  .panel.open { height: 78vh; }
  .grip { display: block; position: absolute; top: 0; left: 0; right: 0; height: 22px; border: 0; background: none; cursor: pointer; }
  .grip::before { content: ""; display: block; width: 44px; height: 5px; border-radius: 3px; background: #d7d0d3; margin: 8px auto 0; }
  .brand p { display: none; }
}
