:root {
  --bg: #f4f6f8; --flaeche: #ffffff; --flaeche2: #eef2f5; --linie: #d9e0e6; --text: #17242d; --text2: #5a6b78;
  --akzent: #0b7a99; --akzent2: #e0f3f8; --gut: #1f9d55; --warn: #d99a00; --schlecht: #d64545; --grau: #8a99a6;
  --seite: #0f2632; --seite-text: #d7e6ee; --seite-text2: #8fb0c1; --seite-hover: #173847; --seite-aktiv: #1e4a5c;
  --schatten: 0 6px 24px rgba(10, 30, 40, .18);
  font-family: "Open Sans", "Segoe UI", system-ui, -apple-system, sans-serif; font-size: 14px; color: var(--text);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e171d; --flaeche: #15222a; --flaeche2: #1b2b35; --linie: #2a3c47; --text: #e3edf2; --text2: #93a8b5;
    --akzent: #4cc3df; --akzent2: #173a46; --schatten: 0 6px 24px rgba(0, 0, 0, .5);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
[hidden] { display: none !important; }
a { color: var(--akzent); }
button { font: inherit; }
input, select, textarea { font: inherit; color: var(--text); background: var(--flaeche); border: 1px solid var(--linie); border-radius: 6px; padding: 6px 8px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--akzent); outline-offset: -1px; }
label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--text2); }
label.inline { flex-direction: row; align-items: center; gap: 6px; font-size: 13px; color: var(--text); }
.btn { border: 1px solid var(--linie); background: var(--flaeche); color: var(--text); padding: 7px 12px; border-radius: 7px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--akzent); }
.btn.primaer { background: var(--akzent); border-color: var(--akzent); color: #fff; }
.btn.klein { padding: 3px 8px; font-size: 12px; }
.btn.gefahr { color: var(--schlecht); }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { border: 0; background: transparent; color: inherit; font-size: 18px; width: 34px; height: 34px; border-radius: 8px; cursor: pointer; }
.icon-btn:hover { background: var(--flaeche2); }
.fehler { color: var(--schlecht); min-height: 1em; }
.leise { color: var(--text2); font-size: 12px; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; word-break: break-all; }

/* Anmeldung */
.anmeldung { position: fixed; inset: 0; display: grid; place-items: center; background: linear-gradient(160deg, #0f2632, #0b4a5e); padding: 16px; }
.karte-box { background: var(--flaeche); padding: 28px; border-radius: 14px; width: min(360px, 100%); display: flex; flex-direction: column; gap: 14px; box-shadow: var(--schatten); }
.marke { display: flex; gap: 12px; align-items: center; }
.marke img { width: 44px; height: 44px; }
.marke small { display: block; color: var(--text2); }

/* Grundgerüst */
.app { display: flex; height: 100vh; height: 100dvh; }
.seite { width: 290px; flex: none; background: var(--seite); color: var(--seite-text); display: flex; flex-direction: column; z-index: 1001; }
.kopf { display: flex; align-items: center; gap: 10px; padding: 14px 14px 10px; }
.kopf img { width: 34px; height: 34px; }
.kopf .titel { flex: 1; min-width: 0; }
.kopf .titel b { display: block; font-size: 16px; }
.kopf small { color: var(--seite-text2); font-size: 11px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suche { padding: 0 12px 8px; }
.suche input { width: 100%; background: var(--seite-hover); border-color: transparent; color: var(--seite-text); }
.menu { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
.menu h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--seite-text2); margin: 14px 8px 4px; font-weight: 600; }
.menu .eintrag { display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: 7px; cursor: pointer; color: var(--seite-text); text-decoration: none; }
.menu .eintrag:hover { background: var(--seite-hover); }
.menu .eintrag.aktiv { background: var(--seite-aktiv); }
.menu .eintrag .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu .eintrag .wert { font-size: 12px; color: var(--seite-text2); white-space: nowrap; }
.menu .sym { width: 18px; text-align: center; opacity: .85; }
.menu .unter { margin-left: 26px; border-left: 1px solid #2b4d5d; padding-left: 4px; }
.menu .unter .eintrag { padding: 5px 8px; font-size: 13px; }
.punkt { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--grau); box-shadow: 0 0 0 2px rgba(255,255,255,.15); }
.punkt.gut { background: var(--gut); } .punkt.warn { background: var(--warn); } .punkt.schlecht { background: var(--schlecht); }
.fuss { padding: 10px 16px; font-size: 12px; color: var(--seite-text2); border-top: 1px solid #1f3c4a; }
.fuss a { color: var(--seite-text2); }
.haupt { flex: 1; position: relative; min-width: 0; }
.karte { position: absolute; inset: 0; background: #1b2b35; }
.nur-mobil { display: none; }

/* Panel */
.panel { position: absolute; top: 12px; right: 12px; bottom: 12px; width: 480px; max-width: calc(100% - 24px); background: var(--flaeche); border-radius: 12px; box-shadow: var(--schatten); display: flex; flex-direction: column; z-index: 1000; }
.panel.breit { width: min(1100px, calc(100% - 24px)); }
.panel-kopf { display: flex; align-items: center; gap: 4px; padding: 8px 8px 8px 14px; border-bottom: 1px solid var(--linie); }
.panel-kopf h2 { flex: 1; font-size: 16px; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-inhalt { flex: 1; overflow-y: auto; padding: 14px; }
.reiter { display: flex; gap: 2px; border-bottom: 1px solid var(--linie); margin: -4px -14px 14px; padding: 0 10px; overflow-x: auto; }
.reiter button { border: 0; background: none; padding: 8px 10px; color: var(--text2); border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.reiter button.aktiv { color: var(--akzent); border-bottom-color: var(--akzent); font-weight: 600; }
.kacheln { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; margin-bottom: 14px; }
.kachel { background: var(--flaeche2); border-radius: 8px; padding: 8px 10px; }
.kachel small { display: block; color: var(--text2); font-size: 11px; }
.kachel b { font-size: 17px; font-variant-numeric: tabular-nums; }
.raster { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.raster .ganz { grid-column: 1 / -1; }
.zeile { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.liste { border: 1px solid var(--linie); border-radius: 8px; max-height: 260px; overflow-y: auto; }
.liste .li { display: flex; gap: 8px; align-items: center; padding: 6px 10px; border-bottom: 1px solid var(--linie); }
.liste .li:last-child { border-bottom: 0; }
table.tab { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tab th, table.tab td { text-align: left; padding: 5px 6px; border-bottom: 1px solid var(--linie); vertical-align: top; }
table.tab th { color: var(--text2); font-weight: 600; font-size: 12px; }
table.tab td.z { text-align: right; font-variant-numeric: tabular-nums; }
.chip { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; background: var(--flaeche2); color: var(--text2); }
.chip.gut { background: #dff3e7; color: #146c3a; } .chip.warn { background: #fbefd0; color: #8a6200; } .chip.schlecht { background: #fbe0e0; color: #9d2a2a; } .chip.info { background: var(--akzent2); color: var(--akzent); }
.diagramm { position: relative; height: 320px; }
.panel.breit .diagramm { height: 460px; }
.hinweis { background: var(--akzent2); border-radius: 8px; padding: 10px 12px; font-size: 13px; margin: 10px 0; }
.kette { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 12px; }
.kette span { background: var(--flaeche2); padding: 2px 7px; border-radius: 10px; }
.kette i { color: var(--text2); font-style: normal; }
h4 { margin: 18px 0 8px; font-size: 13px; }

/* Karte */
.legende { position: absolute; left: 12px; bottom: 24px; z-index: 900; background: rgba(15,38,50,.86); color: #e6f1f6; border-radius: 10px; padding: 8px 10px; font-size: 12px; line-height: 1.6; pointer-events: none; }
.legende i { display: inline-block; width: 18px; margin-right: 6px; vertical-align: middle; }
.ms-marker { width: 18px; height: 18px; border-radius: 50%; border: 3px solid #fff; background: var(--grau); box-shadow: 0 1px 6px rgba(0,0,0,.5); }
.ms-marker.gut { background: var(--gut); } .ms-marker.warn { background: var(--warn); } .ms-marker.schlecht { background: var(--schlecht); }
.ms-marker.gewaehlt { outline: 3px solid #5fd3e8; outline-offset: 2px; }
.ms-marker.aus { opacity: .45; }
.rep-marker { width: 12px; height: 12px; background: #f4c542; transform: rotate(45deg); border: 2px solid #3a2f00; }
.gw-marker { width: 16px; height: 16px; background: #5fd3e8; border: 3px solid #0b3b4f; border-radius: 3px; }
.leaflet-tooltip.ms-label { background: rgba(15,38,50,.85); color: #fff; border: 0; box-shadow: none; font-size: 11px; padding: 2px 6px; }
.leaflet-tooltip.ms-label::before { display: none; }
.leaflet-tooltip.iso-label { background: transparent; border: 0; box-shadow: none; color: #fff; font-weight: 700; font-size: 11px; text-shadow: 0 0 3px #000, 0 0 2px #000; padding: 0; }
.leaflet-tooltip.iso-label::before { display: none; }
.leaflet-popup-content { font-size: 13px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #0f2632; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 3000; box-shadow: var(--schatten); }
.druckkopf { display: none; }

@media (max-width: 760px) {
  .nur-mobil { display: inline-block; }
  .seite { position: fixed; inset: 0 auto 0 0; width: 86vw; max-width: 320px; transform: translateX(-100%); transition: transform .2s; }
  .seite.offen { transform: none; }
  .menu-auf { position: absolute; top: 10px; left: 10px; z-index: 950; background: var(--flaeche); box-shadow: var(--schatten); }
  .panel, .panel.breit { left: 0; right: 0; bottom: 0; top: auto; width: 100%; max-width: 100%; height: 62%; border-radius: 14px 14px 0 0; }
  .raster { grid-template-columns: 1fr; }
  .legende { display: none; }
  .leaflet-top.leaflet-left { top: 50px; }
}

@media print {
  @page { size: A4 landscape; margin: 10mm; }
  .seite, .panel, .menu-auf, .leaflet-control-zoom, .leaflet-control-layers, .toast { display: none !important; }
  .app, .haupt { height: 185mm; }
  .druckkopf { display: block; position: absolute; top: 8px; left: 8px; z-index: 1000; background: #fff; color: #000; padding: 8px 12px; border: 1px solid #000; font-size: 11pt; }
  .legende { background: #fff; color: #000; border: 1px solid #000; }
}
