:root {
  --bg: #0b0e12;
  --panel: #12161c;
  --panel2: #171c24;
  --border: #232a33;
  --text: #e5e9ee;
  --muted: #8b96a5;
  --accent: #4cc9f0;
  --amber: #f0a832;
  --red: #ef4444;
  --green: #34d399;
  --blue: #60a5fa;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  overflow: hidden;
}

body { display: flex; }

/* ---------- Sidebar ---------- */
#sidebar {
  width: 390px;
  min-width: 390px;
  height: 100%;
  overflow-y: auto;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

#sidebar header { padding: 18px 18px 8px; }
#sidebar h1 { margin: 0; font-size: 19px; letter-spacing: 0.3px; }
#sidebar h1 span { color: var(--accent); margin: 0 4px; }
#sidebar .sub { margin: 4px 0 0; color: var(--muted); font-size: 12px; }

.panel {
  margin: 10px 14px 0;
  padding: 14px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.panel h2 {
  margin: 0 0 10px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.step-no {
  display: inline-flex;
  width: 20px; height: 20px;
  align-items: center; justify-content: center;
  background: var(--accent);
  color: #06222e;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
}

.count { color: var(--accent); }

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: #1c232d;
  color: var(--text);
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: #242d39; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }
.mode-btn.active {
  border-color: var(--accent);
  background: #123240;
  color: var(--accent);
}
.btn-primary {
  width: 100%;
  background: var(--accent);
  border-color: var(--accent);
  color: #06222e;
  font-weight: 700;
}
.btn-primary:hover:not(:disabled) { background: #6fd6f5; }

.pick-info { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.pick-line { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.pick-line .txt { flex: 1; }
.pick-line.set { color: var(--text); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #2c3540; flex-shrink: 0; }
.pick-line.set .dot-start { background: var(--green); }
.pick-line.set .dot-dest { background: var(--accent); }

.hint { color: var(--muted); font-size: 12px; line-height: 1.5; margin: 10px 0 0; }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.field span { font-size: 11.5px; color: var(--muted); }
.field input, .field select {
  background: #0e1319;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 7px 9px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.field input:focus, .field select:focus { outline: 1px solid var(--accent); border-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }

.chk-row { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; padding: 4px 0; cursor: pointer; }
.chk-row input { accent-color: var(--accent); margin-top: 2px; }
.chk-row small { color: var(--muted); }

.status-log { margin-top: 12px; font-size: 12.5px; display: flex; flex-direction: column; gap: 5px; }
.status-log .st { display: flex; gap: 8px; align-items: baseline; color: var(--muted); }
.status-log .st.run::before { content: "⏳"; }
.status-log .st.ok { color: var(--text); }
.status-log .st.ok::before { content: "✓"; color: var(--green); }
.status-log .st.err { color: var(--red); }
.status-log .st.err::before { content: "✗"; }
.status-log .st.warn { color: var(--amber); }
.status-log .st.warn::before { content: "△"; }

.route-summary {
  margin-top: 12px;
  padding: 10px 12px;
  background: #0e1319;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.6;
}
.route-summary b { color: var(--accent); font-variant-numeric: tabular-nums; }

.issue-list { display: flex; flex-direction: column; gap: 6px; max-height: 340px; overflow-y: auto; }
.issue {
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--muted);
  border-radius: 7px;
  background: #0e1319;
  cursor: pointer;
  transition: background 0.15s;
}
.issue:hover { background: #16202b; }
.issue.high { border-left-color: var(--red); }
.issue.warn { border-left-color: var(--amber); }
.issue.info { border-left-color: var(--blue); }
.issue.active { background: #1d2733; outline: 1px solid var(--accent); }
.issue.passed { opacity: 0.55; }
.issue .t { font-weight: 600; font-size: 13px; display: flex; justify-content: space-between; gap: 8px; }
.issue .t .km { color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; white-space: nowrap; }
.issue .d { color: var(--muted); font-size: 12px; margin-top: 3px; line-height: 1.45; }
/* Klärungsbedarf: fehlende Datengrundlage + zuständige Stelle */
.issue .badge {
  display: inline-block; margin-top: 6px; padding: 2px 7px;
  border: 1px solid var(--amber); border-radius: 10px;
  color: var(--amber); font-size: 11px; font-weight: 600;
}

#sidebar footer { margin-top: auto; padding: 14px 18px; }
#sidebar footer p { color: #5b6672; font-size: 11px; line-height: 1.5; margin: 0; }

/* ---------- Main / 3D ---------- */
#main { position: relative; flex: 1; height: 100%; }
#cesiumContainer { position: absolute; inset: 0; }
#cesiumContainer .cesium-viewer-bottom { opacity: 0.5; }
#cesiumContainer .cesium-widget-credits { font-size: 10px; }

.loading3d {
  position: absolute;
  top: 14px; left: 50%;
  transform: translateX(-50%);
  background: rgba(18, 22, 28, 0.94);
  border: 1px solid var(--border);
  padding: 10px 16px 12px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 20;
  min-width: 320px;
  transition: opacity 0.5s;
}
.loading3d.fading { opacity: 0; pointer-events: none; }
.loading3d .load-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  margin-bottom: 7px;
}
.loading3d .st.run::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 2px; border: 2px solid var(--accent); border-top-color: transparent; border-radius: 50%; animation: spin 0.9s linear infinite; vertical-align: -1px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 2D map card */
.map2d-card {
  position: absolute;
  left: 14px;
  bottom: 14px;
  width: 430px;
  height: 330px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  z-index: 30;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 28px rgba(0,0,0,0.5);
  transition: width 0.2s, height 0.2s;
}
.map2d-card.expanded { width: min(72%, 900px); height: 72%; }
.map2d-card.picking { outline: 2px solid var(--accent); }
.map2d-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: var(--panel2);
}
.map2d-head span:first-child { flex: 1; }
.mode-badge {
  background: #123240;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
}
#map2d { flex: 1; background: #0b0e12; cursor: crosshair; }
#map2d .ol-attribution { background: rgba(11,14,18,0.7); color: var(--muted); font-size: 9px; }
#map2d .ol-attribution a { color: var(--muted); }
#map2d .ol-zoom .ol-zoom-in, #map2d .ol-zoom .ol-zoom-out {
  background: #1c232d; color: var(--text); border-radius: 4px;
}

.icon-btn {
  appearance: none;
  background: #1c232d;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  width: 28px; height: 28px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
}
.icon-btn:hover { background: #242d39; }
.icon-btn.big { width: 40px; height: 40px; font-size: 16px; border-radius: 8px; }
.icon-btn.active { background: #123240; border-color: var(--accent); }
#btnSync2d { filter: grayscale(1) opacity(0.55); }
#btnSync2d.active { filter: none; }
#btnLoop { filter: grayscale(1) opacity(0.55); }
#btnLoop.active { filter: none; }

/* Legend */
.legend {
  position: absolute;
  top: 14px; right: 14px;
  background: rgba(18, 22, 28, 0.92);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 12px;
  z-index: 25;
  min-width: 190px;
}
.legend-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted); margin-bottom: 7px; }
.legend-row { display: flex; align-items: center; gap: 8px; margin: 4px 0; color: var(--text); }
.sw { width: 16px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.sw-route { background: #38bdf8; height: 4px; }
.sw-profil { background: rgba(76, 201, 240, 0.35); border: 1px solid var(--accent); }
.sw-sweep { background: rgba(240, 168, 50, 0.45); }
.sw-sign { background: #9aa4b2; width: 4px; height: 12px; border-radius: 1px; }
.layer-hint { margin: -2px 0 6px 26px; }
.sw-high { background: var(--red); width: 10px; height: 10px; border-radius: 50%; }
.sw-warn { background: var(--amber); width: 10px; height: 10px; border-radius: 50%; }
.sw-info { background: var(--blue); width: 10px; height: 10px; border-radius: 50%; }

/* Playbar */
.playbar {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(18, 22, 28, 0.94);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 16px;
  z-index: 30;
  width: min(620px, 60%);
  box-shadow: 0 8px 28px rgba(0,0,0,0.5);
}
.playbar input[type="range"] { flex: 1; accent-color: var(--accent); }
.play-info { font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--muted); white-space: nowrap; min-width: 90px; text-align: right; }
.speed-sel {
  background: #1c232d; color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 5px 6px; font-size: 12px;
}
.follow { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.follow input { accent-color: var(--accent); }

/* Live event toast */
.live-event {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30, 16, 16, 0.95);
  border: 1px solid var(--red);
  color: #fecaca;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 14px;
  z-index: 40;
  max-width: 60%;
  text-align: center;
}
.live-event.warn { border-color: var(--amber); background: rgba(32, 25, 10, 0.95); color: #fde68a; }
.live-event.info { border-color: var(--blue); background: rgba(12, 22, 36, 0.95); color: #bfdbfe; }

.hidden { display: none !important; }

/* Scrollbars */
::-webkit-scrollbar { width: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2c3540; border-radius: 5px; }
