/* Farb- und Formensprache bewusst identisch zum Signalflow-Konfigurator,
   damit die eigenen Tools als eine Familie erkennbar bleiben. */
:root {
  --bg: #f4f5f7;
  --flaeche: #ffffff;
  --flaeche-2: #f8f9fb;
  --rand: #d6d9de;
  --rand-stark: #b3b8c0;
  --text: #1f2328;
  --leise: #6b727c;
  --primaer: #2f6fb5;
  --primaer-text: #ffffff;
  --gefahr: #c0392b;
  --ok-bg: #eef6ee;
  --ok-rand: #7fae7f;
  --warn-bg: #fdf3e3;
  --warn-rand: #e0b054;
  --fehler-bg: #fdecea;
  --fehler-rand: #d9534f;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1d21;
    --flaeche: #24272c;
    --flaeche-2: #1f2226;
    --rand: #3a3f46;
    --rand-stark: #50565e;
    --text: #e6e8ea;
    --leise: #9aa1aa;
    --primaer: #4b8fd6;
    --ok-bg: #21301f;
    --ok-rand: #4d7a4d;
    --warn-bg: #3a2f1c;
    --warn-rand: #8a6b2a;
    --fehler-bg: #3a2320;
    --fehler-rand: #a4453f;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif;
}

.versteckt { display: none !important; }
.luecke { flex: 1; }

/* ---------- Kopf ---------- */
.kopf {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--flaeche);
  border-bottom: 1px solid var(--rand);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}
.kopf h1 { font-size: 17px; margin: 0; font-weight: 600; white-space: nowrap; }
.suche { flex: 0 1 320px; }

input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--flaeche);
  border: 1px solid var(--rand-stark);
  border-radius: 6px;
  padding: 6px 8px;
  min-width: 0;
}
input:focus, select:focus { outline: 2px solid var(--primaer); outline-offset: -1px; }

button, .knopf-link {
  font: inherit;
  background: var(--flaeche);
  color: var(--text);
  border: 1px solid var(--rand-stark);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
button:hover, .knopf-link:hover { border-color: var(--primaer); }
button.klein { padding: 4px 9px; font-size: 13px; }
button.primaer { background: var(--primaer); color: var(--primaer-text); border-color: var(--primaer); }

/* ---------- Globale Bedingungen ---------- */
.bedingungen {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--flaeche-2);
  border-bottom: 1px solid var(--rand);
}
.bedingungen label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--leise);
}
.bedingungen input { width: 78px; }
.bedingungen .abgeleitet { font-size: 13px; color: var(--leise); }
.bedingungen .abgeleitet strong { color: var(--text); }

/* ---------- Arbeitsfläche: Liste links, offener Rechner rechts ---------- */
.arbeitsflaeche {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 18px;
  padding: 16px;
  align-items: start;
}

.liste {
  display: flex;
  flex-direction: column;
  gap: 1px;
  position: sticky;
  top: 62px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  padding-right: 4px;
}

.listen-gruppe {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--leise);
  margin: 14px 0 4px;
}
.listen-gruppe:first-child { margin-top: 0; }

.listen-knopf {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 6px 10px;
  border-color: transparent;
  background: transparent;
  color: var(--text);
  border-radius: 6px;
  font-size: 13px;
}
.listen-knopf:hover { background: var(--flaeche); border-color: var(--rand); }
.listen-knopf .listen-titel { flex: 1; }
.listen-knopf.aktiv {
  background: var(--primaer);
  border-color: var(--primaer);
  color: var(--primaer-text);
  font-weight: 600;
}
.listen-knopf.aktiv .nummer { color: var(--primaer-text); border-color: var(--primaer-text); }

.anzeige { min-width: 0; }
.anzeige .karte { max-width: 720px; }

/* ---------- Felder ---------- */
.felder { display: flex; flex-direction: column; gap: 7px; }

.feld {
  display: grid;
  /* Beschriftungsspalte gedeckelt: auf einer breiten Karte soll das Formular
     kompakt bleiben, die volle Breite gehört den Tabellen. */
  grid-template-columns: minmax(0, 300px) 150px;
  align-items: center;
  gap: 8px;
}
.feld-label { font-size: 13px; color: var(--text); }
.feld-fest .feld-label { color: var(--leise); }
.feld-eingabe { display: flex; align-items: center; gap: 5px; }
.feld-eingabe input, .feld-eingabe select { width: 100%; text-align: right; }
.feld-eingabe select { text-align: left; }
.feld-eingabe .einheit { font-size: 12px; color: var(--leise); min-width: 34px; }
.schloss { font-size: 11px; color: var(--primaer); width: 10px; }

/* Berechnete Felder heben sich ab, ohne gesperrt zu wirken: sie bleiben
   anklickbar, ein Klick macht sie zur Eingabe. */
.feld.berechnet input {
  background: var(--flaeche-2);
  color: var(--primaer);
  font-weight: 600;
  border-style: dashed;
}

/* Eigene Zeile für Felder mit langen Inhalten. */
.feld.feld-breit { grid-template-columns: 1fr; gap: 3px; }
.feld.feld-breit .feld-eingabe input,
.feld.feld-breit .feld-eingabe select { text-align: left; }

button.aktion { margin-top: 10px; }

/* ---------- Ausgaben ---------- */
.ausgaben { margin: 12px 0 0; display: flex; flex-direction: column; gap: 0; }
.ausgabe {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 5px 0;
  border-top: 1px solid var(--rand);
}
.ausgabe dt { font-size: 12.5px; color: var(--leise); margin: 0; }
.ausgabe dd { margin: 0; text-align: right; font-size: 13px; }
.ausgabe dd strong { font-variant-numeric: tabular-nums; }
.ausgabe dd .einheit { color: var(--leise); font-size: 12px; margin-left: 4px; }
.fussnote-klein { display: block; font-size: 11px; color: var(--leise); font-weight: 400; }

/* ---------- Hinweise ---------- */
.hinweis {
  margin: 12px 0 0;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12.5px;
  border: 1px solid var(--rand);
  background: var(--flaeche-2);
}
.hinweis-ok { background: var(--ok-bg); border-color: var(--ok-rand); }
.hinweis-warn { background: var(--warn-bg); border-color: var(--warn-rand); }
.hinweis-gefahr { background: var(--fehler-bg); border-color: var(--fehler-rand); }

.fussnote { margin: 10px 0 0; font-size: 11.5px; color: var(--leise); line-height: 1.5; }

/* ---------- Tabellen ---------- */
.tabelle-huelle { margin-top: 12px; max-height: 260px; overflow: auto; border: 1px solid var(--rand); border-radius: 6px; }
.tabelle-huelle table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tabelle-huelle th, .tabelle-huelle td { padding: 4px 8px; text-align: right; border-bottom: 1px solid var(--rand); }
.tabelle-huelle th:nth-child(2), .tabelle-huelle td:nth-child(2),
.tabelle-huelle th:nth-child(3), .tabelle-huelle td:nth-child(3) { text-align: right; }
.tabelle-huelle thead th { position: sticky; top: 0; background: var(--flaeche-2); }
.tabelle-huelle td { font-variant-numeric: tabular-nums; }
.tabelle-huelle .fussnote { padding: 6px 8px; margin: 0; }

.leer { text-align: center; color: var(--leise); padding: 40px 16px; }

.fuss {
  padding: 14px 16px 24px;
  color: var(--leise);
  font-size: 12px;
  text-align: center;
  border-top: 1px solid var(--rand);
}
.fuss a { color: var(--leise); }

@media (max-width: 760px) {
  .arbeitsflaeche { grid-template-columns: 1fr; gap: 12px; padding: 12px 10px 50px; }
  .liste {
    position: static;
    max-height: 42vh;
    border: 1px solid var(--rand);
    border-radius: 10px;
    background: var(--flaeche);
    padding: 10px;
  }
  .anzeige .karte { max-width: none; }
  .suche { flex: 1 1 100%; order: 5; }
}

@media (max-width: 560px) {
  .feld { grid-template-columns: 1fr 130px; }
}
