:root {
  --bg: #0d1b26;
  --panel: rgba(10, 22, 32, 0.86);
  --line: rgba(255, 255, 255, 0.16);
  --text: #f4f8fb;
  --text-2: #dbe7ef;      /* Sekundärtext bleibt hell – keine blassen Grautöne */
  --accent: #6fd3ff;
  --green: #3ecf6e;
  --yellow: #ffd23f;
  --red: #ff5a4f;
  --calm: #8fb8ff;
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); }
button, select, input { font: inherit; color: inherit; }
#view { position: fixed; inset: 0; }
#view canvas { display: block; touch-action: none; }

/* Beschriftungen im 3D-Bild */
#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.lbl { position: absolute; transform: translate(-50%, -100%); white-space: nowrap; font-size: 12px; font-weight: 600;
  padding: 2px 7px; border-radius: 8px; background: rgba(8, 18, 26, 0.82); border: 1px solid var(--line); color: #fff;
  text-shadow: 0 1px 2px #000; }
.lbl.poi { font-size: 13px; border-color: var(--accent); pointer-events: auto; cursor: pointer; }
.lbl.station { font-size: 11px; font-weight: 500; }
.lbl.station b { color: var(--accent); }
.lbl.storm { border-color: var(--red); background: rgba(60, 8, 8, 0.85); }
.lbl.place { background: none; border: none; font-weight: 500; font-size: 11px; opacity: 0.95; }

/* Kopfzeile */
#top { position: fixed; top: 0; left: 0; right: 0; height: 52px; display: flex; align-items: center; gap: 14px;
  padding: 0 12px; background: linear-gradient(#0a1620ee, #0a162000); z-index: 5; pointer-events: none; }
#top > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 8px; }
.brand svg { width: 32px; height: 32px; }
.brand b { display: block; font-size: 17px; letter-spacing: .3px; }
.brand span { display: block; font-size: 11px; color: var(--text-2); margin-top: -2px; }
#clock { font-variant-numeric: tabular-nums; font-weight: 600; padding: 5px 12px; border-radius: 20px; background: var(--panel);
  border: 1px solid var(--line); }
#clock .tag { font-size: 11px; margin-left: 6px; padding: 1px 6px; border-radius: 6px; background: #24465c; }
#clock .tag.fc { background: #5b4a14; }
#banner { flex: 1; min-width: 0; padding: 6px 12px; border-radius: 10px; background: rgba(120, 20, 16, 0.9); border: 1px solid #ff7a70;
  font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
#btn-stats { margin-left: auto; }
.icon-btn { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); cursor: pointer;
  font-weight: 700; flex: none; }
.icon-btn:hover, .pill:hover, .cams button:hover { border-color: var(--accent); }

/* Panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px); }
#left, #right { position: fixed; top: 60px; bottom: 92px; width: 300px; overflow-y: auto; z-index: 4; padding: 0 12px 12px; }
#left { left: 10px; }
#right { right: 10px; width: 270px; }
#left.collapsed, #right.collapsed { width: 44px; overflow: hidden; }
#left.collapsed > :not(.panel-head), #right.collapsed > :not(.panel-head) { display: none; }
.collapsed .panel-head h2 { display: none; }
.panel-head { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; padding: 10px 0 6px;
  background: linear-gradient(var(--panel) 70%, transparent); z-index: 1; }
.panel-head h2 { margin: 0; font-size: 15px; }
.collapse { border: 1px solid var(--line); background: none; border-radius: 8px; width: 26px; height: 26px; cursor: pointer; }
.group { border-top: 1px solid var(--line); padding: 8px 0; }
.group h3 { margin: 2px 0 6px; font-size: 13px; color: var(--accent); display: flex; align-items: center; gap: 6px; }
.group label { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 3px 0; cursor: pointer; }
.group label.sel { flex-direction: column; align-items: stretch; gap: 3px; }
.group select { background: #10283a; border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; }
.group input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }
.mini { font-size: 11px; padding: 1px 7px; border-radius: 6px; border: 1px solid var(--line); background: #10283a; cursor: pointer; }
.fx-row { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 2px 0; }
.fx-row small { margin-left: auto; font-size: 11px; color: var(--text-2); }
.cams { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.cams button, .pill { border: 1px solid var(--line); background: #10283a; border-radius: 8px; padding: 6px 8px; cursor: pointer; font-size: 13px; }

/* POI-Karten */
.card { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin: 8px 0; background: rgba(16, 36, 50, 0.7); cursor: pointer; }
.card:hover { border-color: var(--accent); }
.card-head { display: flex; align-items: center; gap: 8px; }
.card-head h4 { margin: 0; font-size: 14px; flex: 1; }
.lamp { width: 13px; height: 13px; border-radius: 50%; box-shadow: 0 0 8px currentColor; background: currentColor; flex: none; }
.lamp.gruen { color: var(--green); } .lamp.gelb { color: var(--yellow); } .lamp.rot { color: var(--red); } .lamp.flaute { color: var(--calm); }
.big { display: flex; align-items: baseline; gap: 10px; margin: 6px 0 2px; }
.big .val { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.big .unit { font-size: 13px; color: var(--text-2); }
.big .arrow { width: 26px; height: 26px; margin-left: auto; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 1px 10px; font-size: 12.5px; }
.facts dt { color: var(--text-2); }
.facts dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.hint { font-size: 12px; margin-top: 6px; padding: 5px 7px; border-radius: 7px; background: rgba(111, 211, 255, 0.12); line-height: 1.35; }
.hint.warn { background: rgba(255, 90, 79, 0.2); }
.spark { width: 100%; height: 46px; display: block; margin-top: 6px; }
.jumpgauge { width: 100%; height: 64px; display: block; margin-top: 4px; }

/* Zeitleiste */
#timeline { position: fixed; left: 10px; right: 10px; bottom: 10px; height: 72px; display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; z-index: 5; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.t-track { position: relative; flex: 1; height: 44px; }
#t-slider { position: absolute; left: 0; right: 0; top: 4px; width: 100%; accent-color: var(--accent); margin: 0; }
#t-radar { position: absolute; top: 0; height: 4px; background: #3ecf6e; border-radius: 2px; }
#t-ticks { position: absolute; left: 0; right: 0; top: 24px; height: 18px; font-size: 11px; }
#t-ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
#t-ticks span.day { font-weight: 700; color: var(--accent); }
#t-ticks i { position: absolute; top: -6px; width: 1px; height: 5px; background: #fff8; }
#legend { width: 230px; font-size: 11px; }
#legend .bar { height: 10px; border-radius: 3px; margin: 2px 0; }
#legend .ticks { display: flex; justify-content: space-between; }

/* Popup (Klick ins Gelände) */
#popup { position: fixed; z-index: 6; width: 290px; padding: 10px 12px; font-size: 13px; }
#popup h4 { margin: 0 0 4px; font-size: 14px; display: flex; justify-content: space-between; }
#popup h4 button { background: none; border: none; cursor: pointer; font-size: 16px; }
#popup .fx { display: grid; grid-template-columns: 1fr 90px 44px; gap: 2px 6px; align-items: center; margin-top: 6px; }
#popup .fx .b { height: 8px; border-radius: 4px; background: #ffffff22; position: relative; }
#popup .fx .b i { position: absolute; top: 0; bottom: 0; border-radius: 4px; }
#popup .fx span:last-child { text-align: right; font-variant-numeric: tabular-nums; }

/* Info-Dialog */
dialog#info, dialog#stats, dialog#alarm { max-width: 820px; width: calc(100% - 24px); max-height: calc(100% - 40px); background: #0e2130; color: var(--text);
  border: 1px solid var(--line); border-radius: 14px; padding: 18px 22px; }
dialog::backdrop { background: #000a; }
dialog#info h2 { margin-top: 0; }
dialog#info h3 { color: var(--accent); margin-bottom: 6px; }
dialog#info table { border-collapse: collapse; width: 100%; font-size: 13px; }
dialog#info td, dialog#info th { border-bottom: 1px solid var(--line); padding: 4px 6px; text-align: left; }
dialog#info .ok { color: var(--green); } dialog#info .err { color: var(--red); }
dialog#info a { color: var(--accent); }
.close-x { float: right; }

#loading { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: var(--bg); z-index: 20; font-size: 15px; }
#loading.hidden { display: none; }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid #ffffff22; border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 820px) {
  #left, #right { top: auto; bottom: 90px; max-height: 46vh; width: calc(100% - 20px); left: 10px; right: 10px; }
  #left.collapsed, #right.collapsed { width: 44px; height: 44px; }
  #right.collapsed { left: auto; }
  #left:not(.collapsed) ~ #right:not(.collapsed) { display: none; }
  #legend { display: none; }
  #t-ticks span:not(.day) { display: none; }
  #banner { position: fixed; top: 54px; left: 10px; right: 10px; }
  .brand span { display: none; }
  #popup { left: 10px !important; right: 10px; width: auto; top: 60px !important; }
}

/* Statistik */
dialog#stats { max-width: 980px; }
dialog h2 small { font-weight: 500; font-size: 13px; }
.stats-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 6px 0 12px; }
.stats-bar select, .stats-bar button { background: #10283a; border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; }
.stats-bar button.on { border-color: var(--accent); background: #17405a; }
.stats-grid { display: grid; grid-template-columns: minmax(260px, 360px) 1fr; gap: 18px; align-items: start; }
.stats-grid svg { width: 100%; height: auto; display: block; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin: 10px 0; }
.kpi { background: #10283a; border: 1px solid var(--line); border-radius: 10px; padding: 6px 9px; }
.kpi b { display: block; font-size: 18px; }
.kpi span { font-size: 12px; }
.rose-legend { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; margin-top: 4px; }
.rose-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 4px; vertical-align: -2px; }
.chart-title { font-weight: 700; margin: 12px 0 2px; color: var(--accent); font-size: 13px; }
.empty { padding: 18px; border: 1px dashed var(--line); border-radius: 10px; }
/* Alarme */
dialog#alarm { max-width: 520px; }
.alarm-row { border-top: 1px solid var(--line); padding: 9px 0; }
.alarm-row > label { display: flex; gap: 8px; align-items: center; font-weight: 600; cursor: pointer; }
.alarm-row .sub { margin: 6px 0 0 26px; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; align-items: center; }
.alarm-row .sub label { display: flex; gap: 5px; align-items: center; }
.alarm-row input[type=number] { width: 64px; background: #10283a; border: 1px solid var(--line); border-radius: 6px; padding: 3px 5px; }
.alarm-row select { background: #10283a; border: 1px solid var(--line); border-radius: 6px; padding: 3px 5px; }
.btn { border: 1px solid var(--accent); background: #17405a; border-radius: 9px; padding: 7px 14px; cursor: pointer; font-weight: 600; }
.btn.secondary { border-color: var(--line); background: #10283a; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.note { font-size: 13px; padding: 8px 10px; border-radius: 8px; background: rgba(111, 211, 255, 0.12); margin: 8px 0; line-height: 1.4; }
.note.warn { background: rgba(255, 90, 79, 0.2); }
.prob { font-size: 12px; margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.prob b { color: var(--accent); }
.lbl.station { pointer-events: auto; cursor: pointer; }
@media (max-width: 820px) { .stats-grid { grid-template-columns: 1fr; } }
@media (max-width: 820px) {
  #top { gap: 8px; padding: 0 8px; }
  .brand > div { display: none; }
  #clock { font-size: 13px; padding: 4px 8px; }
  #clock .tag { display: none; }
}

/* ===== Hochfirst ===== */
.model-pick { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 3px 4px 3px 12px; }
.model-pick select { background: #10283a; border: 1px solid var(--line); border-radius: 14px; padding: 4px 8px; max-width: 230px; }
#btn-net { margin-left: auto; }
#hud { position: fixed; top: 58px; left: 50%; transform: translateX(-50%); z-index: 4; display: flex; gap: 10px; align-items: stretch; pointer-events: none; }
#hud .tile { background: rgba(8, 20, 30, 0.86); border: 1px solid var(--line); border-radius: 12px; padding: 5px 12px; text-align: center; min-width: 92px; }
#hud .tile b { display: block; font-size: 24px; font-variant-numeric: tabular-nums; line-height: 1.1; }
#hud .tile span { font-size: 11px; }
#hud .tile.src { min-width: 0; display: flex; flex-direction: column; justify-content: center; font-size: 12px; }
#hud .lampbig { width: 22px; height: 22px; border-radius: 50%; margin: 3px auto 2px; box-shadow: 0 0 12px currentColor; background: currentColor; }
#left section { border-top: 1px solid var(--line); padding: 8px 0; }
#left section h3 { margin: 2px 0 6px; font-size: 13px; color: var(--accent); display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
#left { width: 380px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-left: auto; }
.seg + .seg { margin-left: 0; }
.seg button { background: #10283a; border: none; padding: 2px 7px; font-size: 11px; cursor: pointer; color: #fff; }
.seg button.on { background: #1f5677; }
.gauge { width: 100%; display: block; }
.mchart { width: 100%; display: block; cursor: crosshair; }
.legend-row { display: flex; flex-wrap: wrap; gap: 3px 10px; font-size: 11.5px; }
.legend-row label { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.legend-row i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; }
.sbars { display: grid; gap: 3px; }
.sbar { display: grid; grid-template-columns: 30px 1fr 110px 74px; align-items: center; gap: 6px; font-size: 12.5px; }
.sbar .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sbar .track { position: relative; height: 10px; background: #ffffff1a; border-radius: 5px; }
.sbar .track::after { content: ''; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: #fff; }
.sbar .track i { position: absolute; top: 0; bottom: 0; border-radius: 5px; }
.sbar .nv { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.sbar .nv small { font-weight: 500; }
.lbl.sensor { font-size: 11.5px; border-color: #ffffff55; }
.lbl.sensor.live { border-color: #3ecf6e; }
.lbl.sensor .v { font-weight: 800; }
.lbl.mark { background: rgba(255, 255, 255, 0.9); color: #111; text-shadow: none; font-size: 11px; }
.ai-head { display: flex; align-items: center; gap: 8px; }
.ai-head h3 { margin: 0 !important; }
.ai-head .btn { margin-left: auto; padding: 3px 9px; font-size: 12px; }
.ai-text { font-size: 13px; line-height: 1.42; margin: 6px 0; }
.ai-fenster { display: grid; gap: 3px; margin: 6px 0; }
.ai-fenster div { display: grid; grid-template-columns: 112px 1fr; gap: 6px; font-size: 12.5px; padding: 3px 6px; border-radius: 6px; }
.ai-fenster .gut { background: rgba(62, 207, 110, 0.18); }
.ai-fenster .eingeschraenkt { background: rgba(255, 210, 63, 0.18); }
.ai-fenster .ungeeignet { background: rgba(255, 90, 79, 0.2); }
.ai-sub { font-size: 12.5px; margin: 4px 0; }
.ai-sub b { color: var(--accent); }
.ai-meta { font-size: 11.5px; margin-top: 6px; }
.chat { margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 6px; }
.chat .log { max-height: 220px; overflow-y: auto; display: grid; gap: 5px; font-size: 12.5px; margin-bottom: 6px; }
.chat .q { background: #17405a; padding: 4px 8px; border-radius: 8px; justify-self: end; max-width: 90%; }
.chat .a { background: #10283a; padding: 4px 8px; border-radius: 8px; max-width: 95%; white-space: pre-wrap; }
.chat form { display: flex; gap: 6px; }
.chat input { flex: 1; background: #10283a; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
dialog#net { max-width: 900px; width: calc(100% - 24px); max-height: calc(100% - 40px); background: #0e2130; color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 18px 22px; }
dialog#net table { border-collapse: collapse; width: 100%; font-size: 13px; }
dialog#net td, dialog#net th { border-bottom: 1px solid var(--line); padding: 3px 5px; text-align: left; }
dialog#net input[type=text], dialog#net input[type=number], dialog#net input[type=password] { background: #10283a; border: 1px solid var(--line); border-radius: 6px; padding: 3px 5px; width: 100%; }
dialog#net pre { background: #091722; padding: 8px 10px; border-radius: 8px; overflow-x: auto; font-size: 12px; }
@media (max-width: 820px) {
  #hud { top: auto; bottom: 142px; transform: none; left: 10px; right: 10px; justify-content: center; gap: 6px; }
  #hud .tile.src { display: none; }
  #hud .tile { min-width: 70px; padding: 4px 6px; }
  #hud .tile b { font-size: 18px; }
  #left { width: calc(100% - 20px); }
  .model-pick { font-size: 0; padding: 2px; }
  .model-pick select { max-width: 140px; font-size: 12px; }
}

.speed select { background: #10283a; border: 1px solid var(--line); border-radius: 8px; padding: 5px 6px; font-size: 12.5px; }
@media (max-width: 820px) { .speed select { max-width: 74px; } }
