/* styles.css — Verwaltungsoberfläche des Fernwartungsportals.
 *
 * Eigens geschrieben statt aus bacnet-monitor übernommen: dort trägt das
 * Stylesheet Karten, Diagramme und eine Landkarte, die es hier nicht gibt.
 * Vierzig Kilobyte für acht Tabellenreiter wären totes Gewicht — und totes
 * CSS ist das, was beim nächsten Umbau niemand mehr anzufassen wagt.
 *
 * Hell und dunkel über prefers-color-scheme. Kein Umschalter: wer auf einem
 * Staging-Laptop im Serverraum sitzt, hat das im Betriebssystem schon
 * entschieden.
 */

:root {
  --bg:        #f4f5f7;
  --bg-karte:  #ffffff;
  --bg-leiste: #1f2430;
  --bg-ein:    #ffffff;
  --rand:      #d8dbe0;
  --rand-weich:#e8eaee;
  --text:      #1c1f26;
  --text-leise:#6b7280;
  --akzent:    #2563eb;
  --akzent-bg: #eff4ff;
  --gruen:     #15803d;
  --gruen-bg:  #e8f6ec;
  --rot:       #b91c1c;
  --rot-bg:    #fdeceb;
  --gelb:      #a16207;
  --gelb-bg:   #fdf6e3;
  --schatten:  0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.10);
  --radius:    8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #14171d;
    --bg-karte:  #1b1f27;
    --bg-leiste: #11141a;
    --bg-ein:    #232833;
    --rand:      #313846;
    --rand-weich:#262c37;
    --text:      #e6e8ec;
    --text-leise:#98a0ae;
    --akzent:    #5b8cff;
    --akzent-bg: #1c2537;
    --gruen:     #4ade80;
    --gruen-bg:  #14261b;
    --rot:       #f87171;
    --rot-bg:    #2a1719;
    --gelb:      #fbbf24;
    --gelb-bg:   #2a2416;
    --schatten:  0 1px 2px rgba(0,0,0,.4);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

[x-cloak] { display: none !important; }

h2 { font-size: 19px; margin: 0 0 4px; font-weight: 600; }
h3 { font-size: 15px; margin: 0 0 8px; font-weight: 600; }
a  { color: var(--akzent); }

.mono  { font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
         font-size: 12.5px; }
.muted { color: var(--text-leise); }
.klein { font-size: 12px; }
.rechts{ text-align: right; }
.nowrap{ white-space: nowrap; }

/* ── Anmeldung ─────────────────────────────────────────────────────────── */

.login-schirm {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); padding: 16px;
}
.login-box {
  width: 100%; max-width: 380px; background: var(--bg-karte);
  border: 1px solid var(--rand); border-radius: var(--radius);
  box-shadow: var(--schatten); padding: 28px;
}
.login-box h2 { margin-bottom: 2px; }
.login-sub { color: var(--text-leise); margin: 0 0 20px; font-size: 13px; }
.qr-box { display: flex; justify-content: center; padding: 12px 0; }
.qr-box svg { width: 190px; height: 190px; color: var(--text); }

/* ── Rahmen ────────────────────────────────────────────────────────────── */

.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: 220px;
  background: var(--bg-leiste); color: #cdd3de;
  display: flex; flex-direction: column; z-index: 100;
}
.sidebar .logo {
  padding: 18px 18px 14px; font-weight: 650; font-size: 15px; color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar .logo span { display: block; font-size: 11px; font-weight: 400;
                      color: #8b93a3; margin-top: 2px; }
.sidebar nav { flex: 1; overflow-y: auto; padding: 10px 0; }
.sidebar nav button {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 18px; background: none; border: 0; cursor: pointer;
  color: #b9c0cd; font-size: 13.5px; text-align: left; font-family: inherit;
}
.sidebar nav button:hover { background: rgba(255,255,255,.05); color: #fff; }
.sidebar nav button.aktiv {
  background: rgba(91,140,255,.16); color: #fff;
  box-shadow: inset 3px 0 0 var(--akzent);
}
.sidebar nav .zaehler {
  margin-left: auto; font-size: 11px; background: rgba(255,255,255,.10);
  border-radius: 10px; padding: 1px 7px;
}
.sidebar-fuss { padding: 12px 18px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-fuss .nutzer { font-size: 13px; color: #fff; }
.btn-abmelden {
  width: 100%; margin-top: 8px; padding: 6px; font-size: 12.5px;
  background: rgba(255,255,255,.07); color: #cdd3de; border: 0;
  border-radius: 6px; cursor: pointer; font-family: inherit;
}
.btn-abmelden:hover { background: rgba(255,255,255,.14); }

.inhalt { margin-left: 220px; min-height: 100vh; }
main { padding: 22px 26px 60px; max-width: 1500px; }

.kopfleiste { display: none; }

@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform .15s; }
  .sidebar.offen { transform: none; }
  .inhalt { margin-left: 0; }
  main { padding: 14px; }
  .kopfleiste {
    display: flex; align-items: center; gap: 10px; padding: 10px 14px;
    background: var(--bg-leiste); color: #fff;
  }
  .hamburger { background: none; border: 0; color: #fff; font-size: 20px;
               cursor: pointer; }
  .sidebar-schleier { position: fixed; inset: 0; background: rgba(0,0,0,.45);
                      z-index: 99; }
}

/* ── Karten und Werkzeugleisten ────────────────────────────────────────── */

.karte {
  background: var(--bg-karte); border: 1px solid var(--rand);
  border-radius: var(--radius); box-shadow: var(--schatten);
  margin-bottom: 18px;
}
.karte-kopf {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 13px 16px; border-bottom: 1px solid var(--rand-weich);
}
.karte-kopf h3 { margin: 0; }
.karte-kopf .rechtsbuendig { margin-left: auto; display: flex; gap: 8px; }
.karte-rumpf { padding: 16px; }
.karte-rumpf.eng { padding: 0; }

.werkzeuge { display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
             margin-bottom: 14px; }
.werkzeuge .wachsend { flex: 1; }

.seitenkopf { margin-bottom: 16px; }
.seitenkopf p { margin: 4px 0 0; color: var(--text-leise); max-width: 78ch; }

/* ── Kennzahlen ────────────────────────────────────────────────────────── */

.kpi-reihe { display: grid; gap: 12px; margin-bottom: 18px;
             grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.kpi {
  background: var(--bg-karte); border: 1px solid var(--rand);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--schatten);
}
.kpi-zahl { font-size: 26px; font-weight: 620; line-height: 1.1; }
.kpi-label { font-size: 12px; color: var(--text-leise); margin-top: 2px; }
.kpi.warnung .kpi-zahl { color: var(--gelb); }
.kpi.fehler  .kpi-zahl { color: var(--rot); }

/* ── Tabellen ──────────────────────────────────────────────────────────── */

.tabelle-rahmen { overflow-x: auto; }
table.tabelle { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tabelle th {
  text-align: left; font-weight: 600; font-size: 11.5px; letter-spacing: .03em;
  text-transform: uppercase; color: var(--text-leise);
  padding: 9px 12px; border-bottom: 1px solid var(--rand);
  background: var(--rand-weich); white-space: nowrap;
}
table.tabelle td {
  padding: 9px 12px; border-bottom: 1px solid var(--rand-weich);
  vertical-align: middle;
}
table.tabelle tbody tr:hover { background: var(--akzent-bg); }
table.tabelle td.aktionen { white-space: nowrap; text-align: right; }
table.tabelle td.aktionen .btn { margin-left: 4px; }

.leer { padding: 26px 16px; text-align: center; color: var(--text-leise); }
.leer strong { display: block; color: var(--text); margin-bottom: 4px; }

/* ── Formulare ─────────────────────────────────────────────────────────── */

.formular { display: grid; gap: 12px;
            grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.formular .breit { grid-column: 1 / -1; }
.feld { display: flex; flex-direction: column; gap: 4px; }
.feld > label { font-size: 12px; font-weight: 600; color: var(--text-leise); }
.feld .hinweis { font-size: 11.5px; color: var(--text-leise); }

.eingabe, select.eingabe, textarea.eingabe {
  width: 100%; padding: 7px 9px; font: inherit; font-size: 13px;
  color: var(--text); background: var(--bg-ein);
  border: 1px solid var(--rand); border-radius: 6px;
}
.eingabe:focus { outline: 2px solid var(--akzent); outline-offset: -1px;
                 border-color: var(--akzent); }
.eingabe[disabled] { opacity: .6; cursor: not-allowed; }
textarea.eingabe { min-height: 62px; resize: vertical; }

.schalter { display: flex; align-items: center; gap: 7px; font-size: 13px; }
.schalter input { width: 15px; height: 15px; }

/* ── Schaltflächen ─────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 7px 13px; font: inherit; font-size: 13px; font-weight: 500;
  border: 1px solid var(--rand); border-radius: 6px; cursor: pointer;
  background: var(--bg-ein); color: var(--text);
}
.btn:hover:not([disabled]) { border-color: var(--akzent); color: var(--akzent); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-haupt {
  background: var(--akzent); border-color: var(--akzent); color: #fff;
}
.btn-haupt:hover:not([disabled]) { filter: brightness(1.08); color: #fff; }
.btn-gefahr { color: var(--rot); border-color: var(--rand); }
.btn-gefahr:hover:not([disabled]) { border-color: var(--rot); background: var(--rot-bg); }
.btn-klein { padding: 4px 9px; font-size: 12px; }

/* ── Marken ────────────────────────────────────────────────────────────── */

.marke {
  display: inline-block; padding: 1px 8px; border-radius: 10px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: var(--rand-weich); color: var(--text-leise);
}
.marke-gruen { background: var(--gruen-bg); color: var(--gruen); }
.marke-rot   { background: var(--rot-bg);   color: var(--rot); }
.marke-gelb  { background: var(--gelb-bg);  color: var(--gelb); }
.marke-blau  { background: var(--akzent-bg);color: var(--akzent); }

.punkt { display: inline-block; width: 8px; height: 8px; border-radius: 50%;
         background: var(--text-leise); margin-right: 6px; }
.punkt.gruen { background: var(--gruen); }
.punkt.rot   { background: var(--rot); }
.punkt.gelb  { background: var(--gelb); }

/* ── Meldungen ─────────────────────────────────────────────────────────── */

.kasten { padding: 11px 14px; border-radius: 6px; font-size: 13px;
          margin-bottom: 14px; border: 1px solid transparent; }
.kasten p:first-child { margin-top: 0; }
.kasten p:last-child  { margin-bottom: 0; }
.kasten-warnung { background: var(--gelb-bg); border-color: var(--gelb);
                  color: var(--gelb); }
.kasten-fehler  { background: var(--rot-bg);  border-color: var(--rot);
                  color: var(--rot); }
.kasten-info    { background: var(--akzent-bg); border-color: var(--akzent);
                  color: var(--akzent); }
.kasten ul { margin: 6px 0 0; padding-left: 20px; }

.login-fehler { background: var(--rot-bg); color: var(--rot); padding: 8px 11px;
                border-radius: 6px; font-size: 12.5px; margin-top: 12px; }

/* ── Dialoge ───────────────────────────────────────────────────────────── */

.dialog-schleier {
  position: fixed; inset: 0; background: rgba(10,12,16,.55); z-index: 150;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto;
}
.dialog {
  width: 100%; max-width: 640px; background: var(--bg-karte);
  border: 1px solid var(--rand); border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0,0,0,.28);
}
.dialog.schmal { max-width: 420px; }
.dialog.weit   { max-width: 900px; }
.dialog-kopf { padding: 15px 18px; border-bottom: 1px solid var(--rand-weich); }
.dialog-kopf h3 { margin: 0; }
.dialog-kopf p  { margin: 4px 0 0; font-size: 12.5px; color: var(--text-leise); }
.dialog-rumpf { padding: 18px; }
.dialog-fuss {
  display: flex; gap: 8px; justify-content: flex-end; padding: 13px 18px;
  border-top: 1px solid var(--rand-weich); background: var(--rand-weich);
  border-radius: 0 0 var(--radius) var(--radius);
}
.dialog-zeile { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.dialog-zeile > label { font-size: 12px; font-weight: 600; color: var(--text-leise); }

/* ── Geheimnisse: einmalige Auslieferung ───────────────────────────────── */

.geheimnis {
  background: var(--gelb-bg); border: 1px solid var(--gelb);
  border-radius: 6px; padding: 12px 14px; margin-bottom: 14px;
}
.geheimnis-wert {
  display: flex; align-items: center; gap: 8px; margin-top: 8px;
  background: var(--bg-ein); border: 1px solid var(--rand);
  border-radius: 6px; padding: 7px 10px;
}
.geheimnis-wert code { flex: 1; overflow-x: auto; white-space: pre; }
pre.block {
  background: var(--bg-ein); border: 1px solid var(--rand); border-radius: 6px;
  padding: 12px; overflow-x: auto; font-size: 12.5px; margin: 0;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}
pre.block.diff .plus  { color: var(--gruen); }
pre.block.diff .minus { color: var(--rot); }

/* ── Zuordnungsmatrix ──────────────────────────────────────────────────── */

.matrix { display: grid; gap: 6px; }
.matrix-zeile {
  display: grid; grid-template-columns: 1fr auto auto auto; gap: 10px;
  align-items: center; padding: 7px 10px; border: 1px solid var(--rand-weich);
  border-radius: 6px;
}
.matrix-zeile:hover { background: var(--rand-weich); }
.matrix-zeile .name { font-size: 13px; }
.matrix-zeile .kunde { font-size: 11.5px; color: var(--text-leise); }

/* ── Hinweise (Toast) ──────────────────────────────────────────────────── */

#hinweise { position: fixed; right: 18px; bottom: 18px; z-index: 300;
            display: flex; flex-direction: column; gap: 8px; }
.hinweis-blase {
  display: flex; gap: 9px; align-items: flex-start; max-width: 380px;
  padding: 10px 14px; border-radius: 8px; font-size: 13px;
  background: var(--bg-karte); border: 1px solid var(--rand);
  box-shadow: 0 6px 20px rgba(0,0,0,.18);
}
.hinweis-blase.erfolg { border-left: 3px solid var(--gruen); }
.hinweis-blase.fehler { border-left: 3px solid var(--rot); }
.hinweis-blase.info   { border-left: 3px solid var(--akzent); }

/* ── Ladeanzeige ───────────────────────────────────────────────────────── */

.dreher {
  width: 13px; height: 13px; border: 2px solid currentColor;
  border-right-color: transparent; border-radius: 50%;
  display: inline-block; animation: dreh .7s linear infinite;
}
@keyframes dreh { to { transform: rotate(360deg); } }
