/* Abfluss-Uebersicht — Stile fuer /abfluss
   Verwendet ausschliesslich Variablen aus app.css (--water, --ink, --card, --line usw.).
   Eigene Farbkonstanten nur wo unvermeidbar (Karten-Hintergrund ohne Tile-Layer). */

/* ============================================================
   SEITEN-LAYOUT: Karte als Hauptelement
   ============================================================ */

/* Hero-Container: Karte bekommt fast den gesamten Viewport */
.abfluss-hero {
  position: relative;
  /* Full-bleed: volle Viewport-Breite, unabhaengig vom zentrierten main-max-width */
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  background: var(--card);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--sh);
}

@media (max-width: 560px) {
  .abfluss-hero { margin-left: -.9rem; margin-right: -.9rem; }
}

/* Kopfzeile ueber der Karte (Titel + Gauge) */
.abfluss-header {
  display: flex;
  align-items: center;
  gap: .75rem 1.2rem;
  flex-wrap: wrap;
  padding: .85rem 1.4rem .75rem;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}

.abfluss-title {
  font-family: var(--font-display);
  font-weight: 750;
  font-size: clamp(1.05rem, 2.5vw, 1.3rem);
  letter-spacing: -.02em;
  color: var(--ink);
  margin: 0;
  line-height: 1.1;
  flex: none;
}

.abfluss-sub {
  font-size: .78rem;
  color: var(--muted);
  margin: 0;
  flex: 1;
  min-width: 12rem;
}

/* ---- Karte ---- */
#abfluss-map {
  height: clamp(440px, 74vh, 820px);
  border-radius: 0;
  overflow: hidden;
  border: none;
  display: block;
  width: 100%;
}

#abfluss-map.leaflet-container {
  background: #f0f4f8;   /* kein Tile-Layer: neutraler heller Hintergrund */
}

/* Dezente Strassen-/Gebaeude-Basiskarte (nur Raum Aarau, ab Zoom 14) */
.abfluss-basemap { filter: saturate(.85); }
html[data-theme="dark"] .abfluss-basemap {
  filter: invert(1) hue-rotate(180deg) brightness(.95) contrast(.92);
}

html[data-theme="dark"] #abfluss-map.leaflet-container {
  background: #0a1119;
}

/* Sichtbares Banner, wenn Live-Daten (Netz/Stationen) nicht geladen werden konnten
   (vorher nur console.error — Review Task 4a). Statische Ebenen bleiben trotzdem sichtbar. */
.abfluss-live-banner {
  padding: .55rem 1.4rem;
  font-size: .82rem;
  font-weight: 600;
  color: var(--fire2);
  background: var(--fire-soft);
  border-bottom: 1px solid var(--line);
}

/* Unterleiste: Quellenhinweis klein unter der Karte */
.abfluss-caption {
  padding: .35rem 1.4rem;
  font-size: .73rem;
  color: var(--muted);
  background: var(--card);
  border-top: 1px solid var(--line);
}

/* ============================================================
   LEGENDE (Leaflet-Control)
   ============================================================ */
.abfluss-legend {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: .55rem .8rem .65rem;
  font-size: .78rem;
  line-height: 1.55;
  min-width: 175px;
  box-shadow: var(--sh-lg);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--ink);
}

html[data-theme="dark"] .abfluss-legend {
  background: rgba(14, 22, 32, 0.96);
  border-color: var(--line);
  color: var(--ink);
}

.abfluss-legend .al-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}

/* Toggle-Button ist nur auf Mobile sichtbar (siehe MOBIL-LAYOUT unten) — auf Desktop bleibt
   die Legende wie bisher immer offen, ohne zusaetzliches Bedienelement. */
.abfluss-legend .al-toggle { display: none; }

.abfluss-legend b {
  display: block;
  margin-bottom: .32rem;
  font-size: .71rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  font-weight: 700;
  color: var(--muted);
  font-family: var(--font-display);
}

.abfluss-legend .row {
  display: flex;
  align-items: center;
  gap: .42rem;
  margin-bottom: .16rem;
}

.abfluss-legend .row i {
  display: inline-block;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1.5px solid rgba(0, 0, 0, .14);
}

html[data-theme="dark"] .abfluss-legend .row i {
  border-color: rgba(255, 255, 255, .12);
}

.abfluss-legend .row .lbl {
  line-height: 1.3;
  color: var(--ink2);
}

/* Stale-Swatch: gepunkteter Ring statt Vollkreis */
.abfluss-legend .stale-swatch {
  background: var(--muted) !important;
  opacity: 0.45;
  border: 2px dashed var(--ink2) !important;
}

/* ============================================================
   KANTONSGRENZEN
   ============================================================ */
#abfluss-map path.canton-line { stroke: #c2ccd6; }
html[data-theme="dark"] #abfluss-map path.canton-line { stroke: #3a4756; }

/* ============================================================
   SEEN + LAUFKRAFTWERKE
   ============================================================ */
html[data-theme="dark"] #abfluss-map path.abfluss-lake,
html[data-theme="dark"] #abfluss-map path.abfluss-water {
  fill: #21465f;
  stroke: #21465f;
}
html[data-theme="dark"] #abfluss-map path.abfluss-kw {
  fill: #5a513f;
  stroke: #6e6450;
}

/* ============================================================
   STATIONS-LABEL (Wert + Tendenzpfeil, permanent auf der Karte)
   ============================================================ */
.station-label-tip {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
}
.station-label-tip::before { display: none !important; }   /* kein Tooltip-Zacken */

.station-label {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-variant-numeric: tabular-nums;
  font-size: .8rem;
  font-weight: 750;
  color: var(--ink);
  background: var(--card);
  padding: 1px 6px;
  border-radius: 7px;
  border: 1px solid var(--line);
  box-shadow: var(--sh-sm);
}
.station-label.stale { opacity: .55; }
.station-label .unit {
  font-size: .6rem;
  font-weight: 600;
  color: var(--muted);
  margin-left: 1px;
}

.trend-arrow {
  display: inline-block;
  align-self: center;
  font-size: 1.25rem;
  line-height: 1;
  font-weight: 900;
  color: var(--water);
  transition: transform .3s ease;
}

/* ============================================================
   SCHAETZ-KENNZAHLEN (unter der Karte)
   ============================================================ */
.abfluss-kennzahlen {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .8rem;
  padding: .9rem 1.4rem 1.1rem;
  background: var(--card);
  border-top: 1px solid var(--line);
}

.azk-card {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: .7rem .9rem;
  background: var(--water-soft);
}

.azk-label {
  font-size: .78rem;
  color: var(--water-ink);
  font-weight: 650;
  font-family: var(--font-display);
  line-height: 1.25;
}

.azk-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin: .3rem 0 .25rem;
}

/* Ampel rechts in der Zeile */
.azk-ampel { margin-left: auto; }
.azk-ampel-light {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  padding: 5px;
  border-radius: 7px;
  background: rgba(0, 0, 0, .06);
  border: 1px solid var(--line);
}
html[data-theme="dark"] .azk-ampel-light { background: rgba(255, 255, 255, .06); }
.azk-ampel-light i {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  opacity: .2;
  transition: opacity .3s, box-shadow .3s;
}
.azk-ampel-light i.rot { background: #e2453c; }
.azk-ampel-light i.orange { background: #f4a23c; }
.azk-ampel-light i.gruen { background: #2e9e5b; }
.azk-ampel-light i.on { opacity: 1; box-shadow: 0 0 6px currentColor; }
.azk-ampel-light i.rot.on { color: #e2453c; }
.azk-ampel-light i.orange.on { color: #f4a23c; }
.azk-ampel-light i.gruen.on { color: #2e9e5b; }

/* Handlungshinweis unter der Box */
.azk-action {
  font-size: .82rem;
  font-weight: 650;
  margin-top: .45rem;
  padding-top: .4rem;
  border-top: 1px dashed var(--line);
}
.azk-action:empty { display: none; }

/* Box-Faerbung nach Ampel (PoC-Tints, beide Themes) */
.azk-card.amp-gruen  { background: rgba(46, 158, 91, .12);  border-color: rgba(46, 158, 91, .55); }
.azk-card.amp-orange { background: rgba(244, 162, 60, .14); border-color: rgba(244, 162, 60, .6); }
.azk-card.amp-rot    { background: rgba(226, 69, 60, .14);  border-color: rgba(226, 69, 60, .6); }
.amp-gruen  .azk-action { color: #2e9e5b; }
.amp-orange .azk-action { color: #c97a1f; }
.amp-rot    .azk-action { color: #e2453c; }
html[data-theme="dark"] .amp-orange .azk-action { color: #f4a23c; }

.azk-val {
  font-size: 1.4rem;
  font-weight: 750;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}

.azk-arrow .trend-arrow { font-size: 1.5rem; }

.azk-note {
  font-size: .7rem;
  color: var(--muted);
  line-height: 1.35;
}

.azk-incomplete { border-color: var(--fire); }
.azk-incomplete .azk-note { color: var(--fire2); }

html[data-theme="dark"] .azk-incomplete .azk-note { color: var(--fire); }

/* Veraltete Schaetzwerte (d.stale aus dem Server-Kontrakt) grau daempfen */
.azk-card.azk-stale { opacity: .6; filter: grayscale(.3); }
.azk-card.azk-stale .azk-note { color: var(--fire2); opacity: 1; }

/* ============================================================
   MURGENTHAL-GAUGE
   Als kompaktes Status-Element in der Kopfzeile
   ============================================================ */
.murgenthal {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  flex: 0 1 auto;
  min-width: 230px;
  max-width: 340px;
  background: var(--water-soft);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: .55rem .8rem .65rem;
  font-size: .84rem;
}

html[data-theme="dark"] .murgenthal {
  background: var(--water-soft);
  border-color: var(--line);
  color: var(--ink);
}

/* Veralteter Murgenthal-Wert (d.stale aus dem Server-Kontrakt) */
.murgenthal.mg-stale { opacity: .65; filter: grayscale(.3); }
.murgenthal.mg-stale .mg-status { color: var(--fire2); opacity: 1; }

.mg-top {
  display: flex;
  align-items: center;
  gap: .4rem;
}

.mg-name {
  font-weight: 700;
  font-size: .76rem;
  color: var(--water-ink);
  font-family: var(--font-display);
  white-space: nowrap;
}

.mg-pct {
  margin-left: auto;
  font-weight: 750;
  font-size: .82rem;
  font-variant-numeric: tabular-nums;
  border: 1.5px solid currentColor;
  border-radius: 999px;
  padding: .04rem .5rem;
  line-height: 1.3;
}

.mg-status {
  font-size: .72rem;
  color: var(--muted);
  line-height: 1.3;
}

.mg-info {
  background: none;
  border: 1px solid currentColor;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  font-size: .68rem;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  color: var(--water);
  flex-shrink: 0;
}

.mg-info:hover {
  background: rgba(0, 0, 0, .07);
}

html[data-theme="dark"] .mg-info {
  color: var(--water);
}

/* Info-Popover (Klick/Tap statt nur title="…") */
.mg-info-wrap {
  position: relative;
  display: inline-flex;
}

.mg-info-pop {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 20;
  width: max(220px, 60vw);
  max-width: 280px;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  box-shadow: var(--sh-lg);
  padding: .55rem .7rem;
  font-size: .76rem;
  line-height: 1.4;
  font-weight: 400;
}

.mg-info-pop[hidden] {
  display: none;
}

/* Balken */
.mg-bar {
  position: relative;
  height: 9px;
  background: var(--line);
  border-radius: 5px;
  overflow: hidden;
  width: 100%;
}

html[data-theme="dark"] .mg-bar {
  background: var(--line);
}

.mg-fill {
  height: 100%;
  border-radius: 5px;
  transition: width .4s ease, background .3s;
  min-width: 2px;
}

/* Schwellen-Markierung bei 100 % */
.mg-threshold {
  position: absolute;
  top: 0; right: 0;
  width: 2px;
  height: 100%;
  background: rgba(0, 0, 0, .28);
}

html[data-theme="dark"] .mg-threshold {
  background: rgba(255, 255, 255, .28);
}

.mg-val {
  font-size: 1.35rem;
  font-weight: 750;
  color: var(--ink);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
  line-height: 1.1;
}

html[data-theme="dark"] .mg-val {
  color: var(--ink);
}

/* ============================================================
   ANSICHT-UMSCHALTER (Leaflet-Control)
   ============================================================ */
.view-toggle-btn,
.leaflet-view-toggle {
  min-height: 40px;           /* Touch-Target >= 40px */
  padding: .5rem 1rem;
  border-radius: var(--r-sm);
  border: 1.5px solid var(--water);
  background: var(--card);
  color: var(--water);
  font-size: .85rem;
  font-weight: 650;
  font-family: var(--font-display);
  cursor: pointer;
  transition: var(--ease);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow: var(--sh-sm);
  white-space: nowrap;
}

.view-toggle-btn:hover,
.view-toggle-btn.active,
.leaflet-view-toggle:hover,
.leaflet-view-toggle.active {
  background: var(--water);
  color: #fff;
  box-shadow: var(--sh);
}

html[data-theme="dark"] .view-toggle-btn,
html[data-theme="dark"] .leaflet-view-toggle {
  border-color: var(--water);
  background: var(--card);
  color: var(--water);
}

html[data-theme="dark"] .view-toggle-btn:hover,
html[data-theme="dark"] .view-toggle-btn.active,
html[data-theme="dark"] .leaflet-view-toggle:hover,
html[data-theme="dark"] .leaflet-view-toggle.active {
  background: var(--water2);
  color: var(--card);
}

/* ============================================================
   POI-MARKER
   ============================================================ */
.poi-kraftwerk {
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .4));
}

.poi-referenz {
  color: var(--fire);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .35));
}

.poi-popup-title {
  margin: 0 0 .35rem;
  font-size: .95rem;
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--ink);
}

.poi-popup-info {
  margin: 0 0 .3rem;
  font-size: .82rem;
  color: var(--ink2);
  line-height: 1.45;
}

.poi-popup-derived {
  background: var(--fire-soft);
  border-left: 3px solid var(--fire);
  padding: .25rem .5rem;
  margin-top: .4rem;
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  font-size: .82rem;
  font-weight: 650;
  color: var(--fire2);
}

html[data-theme="dark"] .poi-popup-derived {
  background: var(--fire-soft);
  color: var(--fire);
}

/* Leaflet-Popups ans Farbschema anpassen */
.leaflet-popup-content-wrapper {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  box-shadow: var(--sh-lg);
}
.leaflet-popup-tip {
  background: var(--card);
}

/* ============================================================
   STATIONS-PANEL
   ============================================================ */
.station-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(380px, 100vw);
  height: 100vh;
  background: var(--card);
  border-left: 1px solid var(--line);
  box-shadow: var(--sh-lg);
  z-index: 1100;
  overflow-y: auto;
  padding: 1.1rem 1.2rem 2rem;
  display: flex;
  flex-direction: column;
  gap: .7rem;
  transition: transform var(--ease);
}

html[data-theme="dark"] .station-panel {
  background: var(--card);
  border-color: var(--line);
  color: var(--ink);
}

.station-panel[hidden] {
  display: none;
}

.sp-close {
  align-self: flex-end;
  background: none;
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  min-width: 40px;
  font-size: 1.05rem;
  cursor: pointer;
  line-height: 1;
  color: var(--muted);
  flex-shrink: 0;
  transition: var(--ease);
  display: grid;
  place-items: center;
}

.sp-close:hover {
  background: var(--fire-soft);
  color: var(--fire2);
  border-color: var(--fire2);
}

.sp-name {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 750;
  letter-spacing: -.02em;
  margin: 0;
  color: var(--ink);
}

.sp-now {
  font-size: .86rem;
  color: var(--ink2);
  border-bottom: 1px solid var(--line);
  padding-bottom: .6rem;
  font-variant-numeric: tabular-nums;
}

/* Panel-Diagramm als klickbarer Vergroessern-Button */
.sp-chart-btn {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--card);
  cursor: zoom-in;
  overflow: hidden;
  transition: var(--ease);
}
.sp-chart-btn:hover { border-color: var(--water); box-shadow: var(--sh-sm); }
.sp-chart { width: 100%; }
.sp-enlarge-hint {
  position: absolute;
  right: .4rem;
  bottom: .4rem;
  font-size: .68rem;
  font-weight: 650;
  color: var(--water);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .12rem .5rem;
  pointer-events: none;
}

.sp-note {
  font-size: .76rem;
  color: var(--muted);
  margin: 0;
}

/* ============================================================
   DIAGRAMM-LIGHTBOX (vergroessern + Export)
   ============================================================ */
.chart-modal { position: fixed; inset: 0; z-index: 1300; }
.chart-modal[hidden] { display: none; }
.cm-backdrop {
  position: absolute; inset: 0;
  background: rgba(8, 14, 22, .62);
  backdrop-filter: blur(2px);
}
.cm-dialog {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(960px, 94vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--sh-lg);
  overflow: hidden;
}
.cm-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  padding: .7rem 1rem;
  border-bottom: 1px solid var(--line);
}
.cm-title {
  font-family: var(--font-display);
  font-weight: 750;
  font-size: 1rem;
  color: var(--ink);
}
.cm-actions { display: flex; align-items: center; gap: .5rem; }
.cm-png, .cm-svg {
  min-height: 36px;
  padding: .35rem .8rem;
  border-radius: var(--r-sm);
  border: 1.5px solid var(--water);
  background: var(--card);
  color: var(--water);
  font-size: .82rem;
  font-weight: 650;
  font-family: var(--font-display);
  cursor: pointer;
  transition: var(--ease);
}
.cm-png:hover, .cm-svg:hover { background: var(--water); color: #fff; }
.cm-close {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: none;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}
.cm-close:hover { background: var(--fire-soft); color: var(--fire2); border-color: var(--fire2); }
.cm-chart { padding: 1rem 1.1rem 1.2rem; overflow: auto; }
.cm-chart svg { width: 100%; height: auto; }

@media (max-width: 600px) {
  .cm-actions { gap: .35rem; }
  .cm-png, .cm-svg { padding: .3rem .55rem; font-size: .76rem; }
}

.sp-src {
  font-size: .82rem;
  color: var(--water);
  font-weight: 600;
}

.sp-src:hover {
  text-decoration: underline;
}

/* ============================================================
   MOBIL-LAYOUT (<=600px)
   ============================================================ */
@media (max-width: 600px) {
  /* Karte voll breit, etwas weniger Hoehe */
  #abfluss-map {
    height: clamp(340px, 60vh, 480px);
  }

  /* Kopfzeile stapeln */
  .abfluss-header {
    flex-direction: column;
    align-items: flex-start;
    padding: .7rem .9rem .65rem;
    gap: .5rem;
  }

  .murgenthal {
    width: 100%;
    max-width: none;
    min-width: 0;
  }

  /* Panel als Bottom-Sheet */
  .station-panel {
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100vw;
    height: 62vh;
    border-left: none;
    border-top: 2px solid var(--water);
    box-shadow: 0 -4px 24px rgba(0, 0, 0, .22);
    border-radius: var(--r) var(--r) 0 0;
    padding-top: .9rem;
  }

  /* Zieh-Griff oben am Bottom-Sheet */
  .station-panel::before {
    content: "";
    display: block;
    width: 2.5rem;
    height: 4px;
    background: var(--line);
    border-radius: 2px;
    margin: 0 auto .6rem;
    flex-shrink: 0;
    order: -1;
  }

  /* Touch-Targets: Close-Button groesser */
  .sp-close {
    width: 40px;
    height: 40px;
    min-width: 40px;
  }

  /* View-Toggle: breiteres Tap-Target */
  .view-toggle-btn,
  .leaflet-view-toggle {
    min-height: 44px;
    padding: .6rem 1.1rem;
  }

  /* Legende etwas kompakter */
  .abfluss-legend {
    font-size: .74rem;
    padding: .45rem .65rem .55rem;
    min-width: 155px;
  }

  /* Legende auf Mobile einklappbar (Standard: zu) — sonst verdeckt sie zusammen mit den
     Overlay-Controls einen Grossteil der kleinen Karte (Review Task 5). */
  .abfluss-legend .al-toggle {
    display: inline-flex;
    align-items: center;
    gap: .2rem;
    background: none;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--ink2);
    font-size: .66rem;
    font-weight: 700;
    padding: .1rem .5rem;
    cursor: pointer;
    min-height: 22px;
  }
  .abfluss-legend.is-collapsed .al-body { display: none; }

  /* Overlay-Controls (Nowcast/Gefahrenkarte/Oberflaechenabfluss) kompakter: Deckkraft-Slider
     erst zeigen, wenn die Checkbox aktiviert ist (statt immer sichtbar, nur deaktiviert). */
  .nowcast-control .nowcast-opacity { display: none; }
  .nowcast-control.ctl-on .nowcast-opacity { display: block; }

  /* Kennzahlen einspaltig */
  .abfluss-kennzahlen {
    grid-template-columns: 1fr;
    padding: .8rem .9rem 1rem;
  }
}

/* ============================================================
   LEAFLET-KONTROLLEN IM DUNKELMODUS
   ============================================================ */
html[data-theme="dark"] .leaflet-bar a,
html[data-theme="dark"] .leaflet-control-zoom a {
  background: var(--card) !important;
  color: var(--ink) !important;
  border-bottom-color: var(--line) !important;
}

html[data-theme="dark"] .leaflet-control-attribution {
  background: rgba(14, 22, 32, .88) !important;
  color: var(--muted) !important;
}

html[data-theme="dark"] .leaflet-control-attribution a {
  color: var(--water) !important;
}

html[data-theme="dark"] .leaflet-popup-content-wrapper,
html[data-theme="dark"] .leaflet-popup-tip {
  background: var(--card) !important;
  color: var(--ink) !important;
  border-color: var(--line) !important;
}

/* ============================================================
   NOWCAST-CONTROL (ICON-CH1, 6-h-Niederschlagssumme)
   ============================================================ */
.nowcast-control {
  background: rgba(255,255,255,.95);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: .5rem .65rem;
  font-size: .78rem;
  color: var(--ink);
  box-shadow: var(--sh-lg);
  min-width: 180px;
}
html[data-theme="dark"] .nowcast-control { background: rgba(14,22,32,.96); }
.nowcast-control label { display: flex; align-items: center; gap: .35rem; font-weight: 650; cursor: pointer; }
.nowcast-control .nowcast-opacity { width: 100%; margin: .4rem 0 .2rem; }
.nowcast-control .nowcast-info { font-size: .68rem; color: var(--muted); line-height: 1.3; }
/* Veraltetes Nowcast-Manifest (mf.stale aus dem Server-Kontrakt) */
.nowcast-control.nowcast-stale .nowcast-info { color: var(--fire2); }
/* zwei Topright-Controls (Nowcast + Gefahrenkarte) etwas Abstand */
.gk-control { margin-top: .4rem; max-width: 230px; }
.oa-control { margin-top: .4rem; max-width: 230px; }
.oa-control.oa-relevant { box-shadow: 0 0 0 2px var(--fire2, #CE2B38); }
.gk-row { display: flex; align-items: center; gap: .35rem; }
.gk-cb { display: flex; align-items: center; margin: 0; cursor: pointer; }
.gk-name { font-weight: 650; cursor: pointer; }
.gk-name:hover { color: var(--fire2, #CE2B38); }
.gk-info { opacity: .55; font-size: .9em; }

/* ============================================================
   GEFAHRENKARTE-PANEL (rechts) — Legende + ausgedeutschte Stufen
   ============================================================ */
.gk-panel {
  position: fixed;
  top: .8rem; right: .8rem;
  width: min(330px, calc(100vw - 1.6rem));
  height: auto;
  max-height: calc(100vh - 1.6rem);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--sh-lg);
  z-index: 1090;            /* unter dem Stations-Panel (1100) */
  overflow-y: auto;
  padding: 1.1rem 1.2rem 1.3rem;
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.gk-panel[hidden] { display: none; }
.gk-panel-close {
  align-self: flex-end;
  background: none; border: 1px solid var(--line); border-radius: 50%;
  width: 36px; height: 36px; font-size: 1.05rem; line-height: 1; cursor: pointer;
  color: var(--muted); display: grid; place-items: center;
}
.gk-panel-close:hover { background: var(--fire-soft); color: var(--fire2); border-color: var(--fire2); }
.gk-panel-title {
  font-family: var(--font-display); font-size: 1.1rem; font-weight: 750;
  letter-spacing: -.02em; margin: 0; color: var(--ink);
}
.gk-panel-lead { font-size: .82rem; color: var(--ink2); line-height: 1.45; margin: 0; }
.gk-levels { list-style: none; margin: .3rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .7rem; }
.gk-levels li { display: flex; gap: .55rem; align-items: flex-start; }
.gk-levels b { display: block; font-size: .86rem; color: var(--ink); }
.gk-levels span { font-size: .78rem; color: var(--ink2); line-height: 1.4; }
.gk-sw {
  flex: none; width: 18px; height: 18px; border-radius: 4px; margin-top: 2px;
  border: 1px solid rgba(0,0,0,.18);
}
html[data-theme="dark"] .gk-sw { border-color: rgba(255,255,255,.18); }
.gk-sw.rot  { background: #e2453c; }
.gk-sw.blau { background: #4a78c8; }
.gk-sw.gelb { background: #f2d83b; }
.gk-sw.rest { background: repeating-linear-gradient(45deg, #f2d83b 0 4px, #fff 4px 8px); }
.oa-legend-head { font-size: .78rem; font-weight: 650; color: var(--ink); margin: .2rem 0 -.1rem; }
.oa-levels li span { line-height: 1.35; }
.gk-sw.oa-h1   { background: #ffbdff; }
.gk-sw.oa-h2   { background: #df73ff; }
.gk-sw.oa-h3   { background: #8400a8; }
.gk-sw.oa-glet { background: #def5ff; }
.gk-sw.oa-gew  { background: #00a6ff; }
.gk-panel-src {
  margin-top: .4rem; padding-top: .6rem; border-top: 1px solid var(--line);
  font-size: .72rem; color: var(--muted); line-height: 1.35;
}

@media (max-width: 600px) {
  .gk-panel { left: 0; right: 0; bottom: 0; top: auto;
    width: 100vw; height: auto; max-height: 52vh;
    border: none; border-top: 2px solid var(--water);
    border-radius: var(--r) var(--r) 0 0; }
}

/* ============================================================
   HQ/MQ-GLOSSAR (Legende + Stations-Panel)
   ============================================================ */
.abfluss-legend .legend-gloss {
  display: block;
  margin-top: .45rem;
  padding-top: .4rem;
  border-top: 1px solid var(--line);
  font-size: .66rem;
  line-height: 1.35;
  color: var(--muted);
}
.sp-gloss { font-size: .72rem; color: var(--muted); line-height: 1.4; margin: 0; }

/* ============================================================
   POI-/KRAFTWERK-MARKER (sauberer Chip statt rohes Glyph)
   ============================================================ */
.kw-marker {
  display: grid;
  place-items: center;
  font-size: 13px;
  line-height: 1;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .35));
}
.poi-kraftwerk span, .poi-referenz span {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--sh-sm);
  font-size: 13px;
  line-height: 1;
}
.poi-referenz span { color: var(--fire); }
.poi-kraftwerk span { color: #b58a2e; }
