/* EB4SH — Oberfläche der energetischen Objektbetreuung (SourceQode)
   Design-Sprache: dezentes Admin-Panel — neutrale Flächen, eine Akzentfarbe,
   Ampel-Farben ausschließlich für Status (nie für Chrome). */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #1c2733;
  --muted: #64707d;
  --faint: #97a1ac;
  --line: #e5e8ec;
  --line-stark: #d5dae0;
  --accent: #0e7c86;
  --accent-dunkel: #0b5f67;
  --accent-hell: #e6f2f3;
  --gruen: #2f9e44;
  --gelb: #b97609;
  --rot: #d64550;
  --gruen-bg: #e5f4e8;
  --gelb-bg: #fcf0da;
  --rot-bg: #fbe7e9;
  --radius: 10px;
  --schatten: 0 1px 2px rgba(20, 30, 40, .04);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, "SF Pro Text", "Segoe UI", "Inter", system-ui, sans-serif;
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ---------- App-Rahmen: Seitenleiste + Hauptbereich (ADR-0001) ---------- */
.app { display: flex; min-height: 100vh; }

.seitenleiste {
  width: 232px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.seitenleiste .marke {
  padding: 20px 20px 14px;
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: .01em;
  border-bottom: 1px solid var(--line);
}
.seitenleiste .marke a { color: var(--ink); text-decoration: none; }
.seitenleiste .marke a::before {
  content: "";
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 3px;
  background: var(--accent);
  margin-right: 9px;
}
.seitenleiste .marke span {
  display: block; color: var(--faint); font-weight: 400;
  font-size: .7rem; margin: 3px 0 0 19px;
}
.seitenleiste nav { display: flex; flex-direction: column; padding: 8px 12px 24px; }
.seitenleiste .gruppe {
  font-size: .66rem; text-transform: uppercase; letter-spacing: .1em;
  color: var(--faint); font-weight: 600; margin: 18px 10px 5px;
}
.seitenleiste nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 7px 10px;
  border-radius: 8px;
  font-weight: 500;
  font-size: .9rem;
  display: flex;
  align-items: center;
  gap: 10px;
}
.seitenleiste nav a svg { flex-shrink: 0; opacity: .75; }
.seitenleiste nav a .zaehler { margin-left: auto; }
.seitenleiste nav a:hover { background: var(--bg); color: var(--ink); }
.seitenleiste nav a.aktiv {
  background: var(--accent-hell);
  color: var(--accent-dunkel);
  font-weight: 600;
}
.seitenleiste nav a.aktiv svg { opacity: 1; }
.seitenleiste .zaehler {
  background: var(--rot); color: #fff; border-radius: 999px;
  font-size: .7rem; font-weight: 700; padding: 1px 7px; line-height: 1.5;
}

.hauptbereich { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 28px;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.globale-suche { flex: 1; max-width: 440px; }
.globale-suche input {
  width: 100%; padding: 7px 14px; border: 1px solid var(--line-stark);
  border-radius: 8px; font-size: .88rem; background: var(--bg); color: var(--ink);
}
.globale-suche input::placeholder { color: var(--faint); }
.globale-suche input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 124, 134, .12); background: var(--surface);
}
.topbar .benutzer { color: var(--muted); font-size: .85rem; display: flex; gap: 14px; align-items: center; }
.topbar button.link {
  background: none; border: 1px solid var(--line-stark); color: var(--muted);
  border-radius: 7px; padding: 4px 12px; cursor: pointer; font-size: .82rem;
}
.topbar button.link:hover { background: var(--bg); color: var(--ink); }

.inhalt { max-width: 1160px; margin: 0 auto; padding: 30px 28px 90px; width: 100%; }

/* Schmale Viewports: Seitenleiste wird zur Kopfzeile */
@media (max-width: 880px) {
  .app { flex-direction: column; }
  .seitenleiste { width: 100%; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--line); }
  .seitenleiste nav { flex-direction: row; flex-wrap: wrap; gap: 2px; padding: 0 12px 12px; }
  .seitenleiste .gruppe { width: 100%; margin: 10px 10px 3px; }
  .topbar { position: static; }
}

/* ---------- Typografie ---------- */
h1 { font-size: 1.32rem; font-weight: 650; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: .95rem; font-weight: 650; margin: 0; }
.untertitel { color: var(--muted); margin: 0 0 22px; font-size: .9rem; }

/* ---------- Karten & Tabellen ---------- */
.karte {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin: 0 0 18px;
  box-shadow: var(--schatten);
  overflow: hidden;
}
.karte .kopf {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
}
.karte .leer { padding: 16px 18px; color: var(--muted); font-size: .9rem; }
/* Gefahrenzone: destruktive Aktionen (Archivieren) klar abgesetzt */
.karte.gefahrenzone { border-color: var(--rot); }
.karte.gefahrenzone .kopf { border-bottom-color: var(--rot-bg); }
.karte.gefahrenzone .kopf h2 { color: var(--rot); }
/* Ausklappbares Archiv (z. B. archivierte Dokumente einer Liegenschaft) */
.archiv-block { border-top: 1px solid var(--line); }
.archiv-block summary {
  cursor: pointer; color: var(--accent-dunkel); font-size: .84rem;
  font-weight: 600; padding: 11px 18px; list-style-position: inside;
}
.archiv-block summary:hover { background: var(--bg); }
.archiv-block[open] summary { border-bottom: 1px solid var(--line); }

/* Dokument-Vorschau (Lightbox: PDF im iframe, Bild als img) */
.vorschau-knopf { background: none; border: none; cursor: pointer; font-size: 1rem; padding: 0 4px; }
.modal {
  position: fixed; inset: 0; background: rgba(15, 25, 35, .55);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 24px;
}
.modal[hidden] { display: none; }
.modal-inhalt {
  background: var(--surface); border-radius: var(--radius);
  width: min(920px, 100%); max-height: 90vh; display: flex; flex-direction: column;
  overflow: hidden; box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
.modal-kopf {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: .9rem;
}
#vorschau-body { flex: 1; overflow: auto; background: var(--bg); }
#vorschau-body iframe { width: 100%; height: 72vh; border: 0; display: block; }
#vorschau-body img { max-width: 100%; display: block; margin: 0 auto; }

/* Horizontale Tabs (Dashboard) */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tabs .tab {
  background: none; border: none; border-bottom: 2px solid transparent;
  padding: 9px 16px; font-family: inherit; font-size: .9rem; font-weight: 600;
  color: var(--muted); cursor: pointer;
}
.tabs .tab:hover { color: var(--ink); }
.tabs .tab.aktiv { color: var(--accent-dunkel); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.show { display: block; }

table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th {
  text-align: left; font-size: .7rem; text-transform: uppercase;
  letter-spacing: .07em; color: var(--faint); font-weight: 600;
  padding: 9px 18px; border-bottom: 1px solid var(--line);
}
td { padding: 10px 18px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tr.klickbar { cursor: pointer; }
tr.klickbar:hover td { background: #f8fafb; }
td.zahl, th.zahl { text-align: right; font-variant-numeric: tabular-nums; }

a { color: var(--accent-dunkel); }

/* ---------- Badges (Status: Ampel + Workflows) ---------- */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: .74rem; font-weight: 600; white-space: nowrap;
}
.badge.wartet { background: var(--gelb-bg); color: var(--gelb); }
.badge.freigegeben { background: var(--gruen-bg); color: var(--gruen); }
.badge.verworfen { background: #eceef1; color: var(--muted); }
.badge.fehler { background: var(--rot-bg); color: var(--rot); }
.badge.neutral { background: var(--accent-hell); color: var(--accent-dunkel); }
.badge.gruen { background: var(--gruen-bg); color: var(--gruen); }
.badge.gelb { background: var(--gelb-bg); color: var(--gelb); }
.badge.rot { background: var(--rot-bg); color: var(--rot); }
.badge.grau { background: #eceef1; color: var(--muted); }
.badge.gross { font-size: .92rem; padding: 5px 15px; }

.scoreliste { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 18px; }
.scoreliste .titelchen {
  width: 100%; font-size: .7rem; text-transform: uppercase;
  letter-spacing: .07em; color: var(--faint); font-weight: 600; margin-top: 6px;
}
.scoreliste .titelchen:first-child { margin-top: 0; }

/* ---------- Formulare & Buttons ---------- */
.knopf {
  display: inline-block; background: var(--accent); color: #fff;
  border: none; border-radius: 8px; padding: 8px 16px;
  font-size: .88rem; font-weight: 600; cursor: pointer; text-decoration: none;
}
.knopf:hover { background: var(--accent-dunkel); }
.knopf.sekundaer {
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-stark);
}
.knopf.sekundaer:hover { border-color: var(--accent); color: var(--accent-dunkel); background: var(--surface); }
.knopf.gefahr { background: var(--surface); color: var(--rot); border: 1px solid var(--rot); }
.knopf.gefahr:hover { background: var(--rot-bg); }
.knopf.klein { padding: 4px 11px; font-size: .78rem; }

form.gui p { margin: 0 0 16px; max-width: 560px; }
form.gui label { display: block; font-weight: 600; margin-bottom: 4px; font-size: .88rem; }
form.gui select, form.gui input[type="text"], form.gui input[type="password"],
form.gui input[type="file"] {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line-stark);
  border-radius: 8px; font-size: .92rem; background: var(--surface); color: var(--ink);
}
form.gui .helptext { color: var(--muted); font-size: .78rem; display: block; margin-top: 3px; }
.errorlist { color: var(--rot); margin: 0 0 12px; padding-left: 1.1em; }

input.wertfeld {
  width: 100%; min-width: 110px; padding: 5px 8px;
  border: 1px solid var(--line-stark); border-radius: 7px;
  font-size: .86rem; font-variant-numeric: tabular-nums;
}
input.wertfeld:disabled { background: var(--bg); color: var(--muted); }

/* ---------- Meldungen ---------- */
.meldungen { margin: 0 0 18px; }
.meldung { padding: 10px 16px; border-radius: 8px; margin-bottom: 8px; font-weight: 500; font-size: .9rem; }
.meldung.success { background: var(--gruen-bg); color: var(--gruen); }
.meldung.error { background: var(--rot-bg); color: var(--rot); }
.meldung.info { background: var(--accent-hell); color: var(--accent-dunkel); }

/* ---------- Login ---------- */
.login-rahmen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(165deg, #0b5f67, #123236 70%);
}
.login-karte {
  background: var(--surface); border-radius: 14px; padding: 36px;
  width: 360px; box-shadow: 0 16px 48px rgba(0, 0, 0, .3);
}
.login-karte h1 { margin-bottom: 2px; }
.login-karte .untertitel { margin-bottom: 20px; }

/* ---------- Detail-Raster ---------- */
.stammdaten-raster {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px 24px; padding: 16px 18px;
}
.stammdaten-raster .wert { font-weight: 600; }
.stammdaten-raster .bezeichner {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--faint);
}
.kopfzeile { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 12px; }
.suchfeld { display: flex; gap: 8px; flex-wrap: wrap; }
.suchfeld input {
  padding: 7px 12px; border: 1px solid var(--line-stark); border-radius: 8px;
  font-size: .88rem; width: 260px; background: var(--surface);
}
.suchfeld select {
  padding: 7px 10px; border: 1px solid var(--line-stark); border-radius: 8px;
  font-size: .88rem; background: var(--surface); color: var(--ink);
}
/* Filterleiste der Liegenschaftsliste (Suche + Ampel + Fristen + Heizungsalter) */
.filterleiste {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 18px;
  padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.filterleiste input[type="search"], .filterleiste select {
  padding: 7px 12px; border: 1px solid var(--line-stark); border-radius: 8px;
  font-size: .88rem; background: var(--surface); color: var(--ink); font-family: inherit;
}
.filterleiste input[type="search"] { width: 240px; }
.filter-check {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .86rem; color: var(--muted); cursor: pointer;
}
/* Ampel-Kacheln (Fristen-Zählung), klickbar als Filter */
.ampelkacheln { display: flex; gap: 10px; padding: 14px 18px; flex-wrap: wrap; }
.ampelkacheln a { text-decoration: none; }
.fussnote { color: var(--muted); font-size: .78rem; margin-top: 6px; }

/* ---------- Dashboard (Ebene 1, ADR-0001) ---------- */
.kpi-raster {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px; margin-bottom: 18px;
}
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px 18px 13px; text-decoration: none; color: var(--ink);
  box-shadow: var(--schatten);
}
.kpi .wert {
  display: block; font-size: 1.55rem; font-weight: 650;
  letter-spacing: -.01em; margin-bottom: 1px;
}
.kpi .bezeichner { font-size: .78rem; color: var(--muted); }
a.kpi:hover { border-color: var(--accent); }

.dashboard-spalten {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 18px; align-items: stretch;
}
.dashboard-spalten .karte { margin-bottom: 18px; }

.donut-bereich { display: flex; align-items: center; gap: 28px; padding: 20px 18px; flex-wrap: wrap; }
.donut { width: 148px; height: 148px; border-radius: 50%; position: relative; flex-shrink: 0; }
.donut::after {
  content: ""; position: absolute; inset: 19%;
  background: var(--surface); border-radius: 50%;
}
.donut .zentrum {
  position: absolute; inset: 0; z-index: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.donut .zentrum .wert { font-size: 1.5rem; font-weight: 650; line-height: 1.1; }
.donut .zentrum .bezeichner { font-size: .68rem; color: var(--muted); }
.donut-legende { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }

.risiko-liste { display: flex; flex-direction: column; }
.risiko-liste a {
  padding: 11px 18px; border-bottom: 1px solid var(--line);
  text-decoration: none; font-weight: 500; font-size: .9rem; color: var(--ink);
}
.risiko-liste a:last-child { border-bottom: none; }
.risiko-liste a:hover { background: #f8fafb; }
.risiko-liste .anzahl {
  display: inline-block; min-width: 26px; text-align: center;
  font-weight: 650; font-variant-numeric: tabular-nums;
  background: var(--bg); border-radius: 6px; padding: 0 6px; margin-right: 10px;
}
.risiko-liste .anzahl.warnung { background: var(--rot-bg); color: var(--rot); }

/* Gestapelte Statusbalken (2px Lücken zwischen Segmenten) */
.gewerke-balken { padding: 14px 18px 8px; }
.gewerke-balken .zeile { display: flex; align-items: center; gap: 12px; margin-bottom: 9px; }
.gewerke-balken .name { width: 190px; flex-shrink: 0; font-size: .84rem; color: var(--muted); }
.gewerke-balken .balken, .mini-balken {
  flex: 1; display: flex; gap: 2px; height: 14px; border-radius: 4px; overflow: hidden;
}
.gewerke-balken .balken span, .mini-balken span { display: block; height: 100%; }
.mini-balken { width: 120px; flex: none; height: 8px; margin-top: 6px; }

/* ---------- Ebene 3: Anker-Subnav + Scoreverlauf ---------- */
html { scroll-behavior: smooth; }
.subnav {
  display: flex; gap: 2px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 5px; margin-bottom: 18px;
  position: sticky; top: 64px; z-index: 5;
  box-shadow: var(--schatten);
}
.subnav a {
  padding: 5px 12px; border-radius: 7px; text-decoration: none;
  font-size: .84rem; font-weight: 500; color: var(--muted);
}
.subnav a:hover { background: var(--bg); color: var(--ink); }
.karte[id] { scroll-margin-top: 118px; }

.scoreverlauf { padding: 14px 18px 6px; border-bottom: 1px solid var(--line); }
.scoreverlauf svg { width: 100%; height: auto; display: block; border-radius: 6px; }
.scoreverlauf .achse {
  display: flex; justify-content: space-between;
  color: var(--faint); font-size: .74rem; padding: 5px 0 8px;
}

/* ---------- Sanierungs-Simulation (Was-wäre-wenn, instanzbasiert) ---------- */
.hinweis-zeile { padding: 12px 18px 16px; color: var(--muted); font-size: .88rem; margin: 0; }

/* Ergebnis-Panel */
.sim-ergebnis { padding: 18px; }
.sim-gesamt {
  display: flex; align-items: center; gap: 22px; flex-wrap: wrap;
  padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--line);
}
.sim-gesamt .titelchen {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--faint); font-weight: 600; margin-bottom: 6px;
}
.sim-gesamt .pfeil, .sim-positionen .zahl { color: var(--faint); }
.pfeil { font-size: 1.4rem; }
table.sim-positionen { width: 100%; font-size: .88rem; }
.sim-positionen th {
  text-align: left; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--faint); font-weight: 600; padding: 6px 10px; border-bottom: 1px solid var(--line);
}
.sim-positionen td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.sim-positionen tr:last-child td { border-bottom: none; }

/* Instanz-Blöcke im Formular */
.sim-instanz { padding: 14px 18px; border-bottom: 1px solid var(--line); }
.sim-instanz:last-child { border-bottom: none; }
.sim-instanz-kopf { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.sim-instanz-name { font-weight: 600; font-size: .92rem; }
.sim-instanz-score { font-size: .8rem; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.sim-felder { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px 18px; }
.sim-feld { display: flex; flex-direction: column; gap: 4px; }
.sim-feld label { font-size: .78rem; font-weight: 600; color: var(--muted); }
.sim-feld select, .sim-feld input {
  width: 100%; padding: 6px 9px; border: 1px solid var(--line-stark); border-radius: 8px;
  font-size: .86rem; background: var(--surface); color: var(--ink); font-family: inherit;
}
.feld-fehler { color: var(--rot); font-size: .76rem; }
.sim-aktion { margin: 4px 0 8px; }
