/* Atlas — dunkles Skeleton-Theme.
   Struktur und Wording folgen dem Mockup v1.6 (Sidebar / Karte / KPI-Panel),
   die Farbgebung ist auf dunkel umgestellt. */

:root {
  --bg: #0e1116;
  --panel: #151a22;
  --panel-2: #1c2230;
  --border: #262d3a;
  --text: #e6eaf2;
  --muted: #8b95a7;
  --accent: #4c8dff;
  --accent-soft: #1a2740;
  --amber: #f0b429;
  --green: #3fb950;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

/* ---------- Header ---------- */
header {
  height: 52px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
header h1 { font-size: 16px; font-weight: 700; letter-spacing: .04em; }
header .sub { font-size: 13px; color: var(--muted); }

.tag {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 99px;
  font-weight: 600;
  letter-spacing: .03em;
}
/* Header-Tag spiegelt den Zustand des letzten Modelllaufs. */
.tag[data-state="unknown"] { background: var(--panel-2); color: var(--muted); }
.tag[data-state="ok"]      { background: #12301a; color: var(--green); }
.tag[data-state="warn"]    { background: #3a2f10; color: var(--amber); }
.tag[data-state="none"]    { background: var(--panel-2); color: var(--muted); }
.tag[data-state="offline"] { background: #3a2f10; color: var(--amber); }

.api-state {
  margin-left: auto;
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 99px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.api-state[data-state="ok"]      { color: var(--green); border-color: #1e3a24; }
.api-state[data-state="offline"] { color: var(--amber); border-color: #3a2f10; }

/* ---------- Layout ---------- */
#app { display: flex; height: calc(100% - 52px); }

/* ---------- Sidebar ---------- */
#sidebar {
  width: 320px;
  min-width: 320px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px 16px 40px;
}
.sec { margin-bottom: 22px; }
.sec h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  margin-bottom: 9px;
}

.layerrow {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 13px;
  color: var(--muted);
}
.layerrow input { accent-color: var(--accent); }

/* Studio-Auswahl für die Fahrzeit-Zonen: gehört sichtbar zur Layerzeile
 * darüber, deshalb leicht eingerückt. */
.selectrow {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 2px 0 6px 24px;
  font-size: 12px;
  color: var(--muted);
}
.selectrow select {
  width: 100%;
  padding: 5px 6px;
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.selectrow select:disabled { opacity: 0.55; }

.radio-group { display: flex; gap: 6px; }
.radio-group label {
  flex: 1;
  text-align: center;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 2px;
  color: var(--muted);
  background: var(--panel-2);
}
.radio-group input { display: none; }
.radio-group label:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 99px;
  background: var(--panel-2);
  color: var(--muted);
}
.chip input { accent-color: var(--accent); }

.modules { list-style: none; display: flex; flex-direction: column; gap: 7px; }
.modules li {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 8px 10px;
}
.modules .mod-title { font-size: 12.5px; font-weight: 600; }
.modules .mod-summary { font-size: 11.5px; color: var(--muted); line-height: 1.45; margin-top: 3px; }
.modules .mod-state {
  display: inline-block;
  margin-top: 6px;
  font-size: 10px;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 1px 7px;
  border-radius: 99px;
  background: #3a2f10;
  color: var(--amber);
}
.modules .module-skeleton { color: var(--muted); font-size: 12.5px; border-left-color: var(--border); }

.hint { font-size: 11px; color: var(--muted); margin-top: 8px; line-height: 1.5; }

/* ---------- Karte ---------- */
#mapwrap { flex: 1; position: relative; background: #0b0e13; }
#map { position: absolute; inset: 0; }

#mapFallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  background: linear-gradient(160deg, #10151d, #0b0e13);
}
#mapFallback[hidden] { display: none; }
#mapFallback strong { display: block; color: var(--text); margin-bottom: 8px; font-size: 15px; }

#clickHint {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  background: rgba(21, 26, 34, .92);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12.5px;
  padding: 7px 14px;
  border-radius: 99px;
}

#legend {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 5;
  min-width: 190px;
  background: rgba(21, 26, 34, .94);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 11.5px;
}
#legend .title { font-weight: 650; }
#legend .bar {
  height: 10px;
  border-radius: 5px;
  margin: 7px 0 4px;
  background: linear-gradient(90deg, #1d2733, #2f4a6d, #4c8dff);
  opacity: .55;
}
#legend .lbls { display: flex; justify-content: space-between; color: var(--muted); }
#legend[hidden] { display: none; }

/* Legende der Fahrzeit-Zonen: diskrete Klassen, gleiche Position wie die
   Zell-Legende — sichtbar ist immer nur eine von beiden. */
#legendTravelTime {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 5;
  min-width: 190px;
  background: rgba(21, 26, 34, .94);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 11.5px;
}
#legendTravelTime[hidden] { display: none; }
#legendTravelTime .title { font-weight: 650; }
#legendTravelTime .classes { list-style: none; margin: 7px 0 0; }
#legendTravelTime .classes li {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 2px 0;
  color: var(--muted);
}
#legendTravelTime .sw { width: 14px; height: 10px; border-radius: 3px; flex: none; opacity: .85; }
#legendTravelTime .note { margin-top: 6px; font-size: 10.5px; color: var(--muted); line-height: 1.4; }

/* Studio-Popup: gleiche Panel-Optik wie die übrigen Karten-Overlays. */
.maplibregl-popup-content {
  background: rgba(21, 26, 34, .96);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 12px;
}
.maplibregl-popup-close-button { color: var(--muted); font-size: 15px; }
.maplibregl-popup-tip { display: none; }
.studio-popup .sp-name { font-weight: 650; font-size: 12.5px; }
.studio-popup .sp-row { color: var(--muted); margin-top: 3px; }
/* Herkunft von M_j sichtbar unterscheiden: abgeleitet/geschätzt darf nicht wie
   ein gemeldeter Wert aussehen. */
.studio-popup .sp-source {
  margin-top: 6px;
  display: inline-block;
  font-size: 10.5px;
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--border);
  color: var(--muted);
}
.studio-popup .sp-source[data-kind="heuristik"]  { background: #3a2f10; color: var(--amber); }
.studio-popup .sp-source[data-kind="schaetzung"] { background: #3a2f10; color: var(--amber); }
.studio-popup .sp-source[data-kind="erhoben"]    { background: #12301a; color: var(--green); }

/* ---------- KPI-Panel ---------- */
#kpi {
  width: 360px;
  min-width: 360px;
  background: var(--panel);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px;
}
#kpi h2 { font-size: 15px; }
#kpi h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  margin: 20px 0 9px;
}
#kpi .coords { font-size: 11.5px; color: var(--muted); margin: 4px 0 14px; }

.kpigrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.kpibox { background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.kpibox.wide { margin-bottom: 4px; }
.kpibox .k { font-size: 11px; color: var(--muted); line-height: 1.35; }
.kpibox .v { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 3px; }
.kpibox .u { font-size: 11px; color: var(--muted); font-weight: 400; }

/* Findings des Modelllaufs: sichtbar, aber kompakt. */
.findings { list-style: none; display: flex; flex-direction: column; gap: 6px; margin-top: 9px; }
.findings[hidden] { display: none; }
.findings li {
  display: flex;
  gap: 7px;
  align-items: flex-start;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 7px 9px;
}
.findings .sev {
  flex: none;
  font-size: 9.5px;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 99px;
  background: var(--border);
  color: var(--muted);
}
.findings .sev[data-severity="warn"]  { background: #3a2f10; color: var(--amber); }
.findings .sev[data-severity="error"] { background: #3d1b1b; color: #f2777a; }
.findings .fmsg { font-size: 11px; color: var(--muted); line-height: 1.45; }

.meta { display: flex; flex-direction: column; gap: 7px; }
.meta > div { display: flex; justify-content: space-between; gap: 12px; font-size: 12.5px; }
.meta dt { color: var(--muted); }
.meta dd { text-align: right; }

/* MapLibre-Kontrollen an das dunkle Theme angleichen */
.maplibregl-ctrl-group { background: var(--panel-2); }
.maplibregl-ctrl-attrib { background: rgba(21, 26, 34, .85) !important; }
.maplibregl-ctrl-attrib a { color: var(--muted) !important; }
