/* Testboard-Geräteverwaltung – helles, dichtes Design, ohne horizontales Scrollen */
:root {
  --hg: #f3f4f6;
  --flaeche: #ffffff;
  --flaeche2: #f8f9fb;
  --rand: #dfe2e7;
  --rand-stark: #c5cad3;
  --text: #1c2129;
  --leise: #646d7a;
  --akzent: #1f6feb;
  --akzent-hell: #e8f0fe;
  --gruen: #1a7f37;
  --gruen-hell: #dafbe1;
  --gelb: #9a6700;
  --gelb-hell: #fff4d4;
  --rot: #cf222e;
  --rot-hell: #ffebe9;
  --rinne: 16px;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--hg);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-wrap: break-word;
}
main { max-width: 1600px; margin: 0 auto; padding: 12px var(--rinne) 32px; }
h1 { font-size: 1.15rem; margin: 0; }
h2 { font-size: 1rem; margin: 0 0 8px; }
h3 { font-size: .75rem; margin: 0 0 6px; text-transform: uppercase; letter-spacing: .04em; color: var(--leise); }
p { margin: 4px 0; }
a { color: var(--akzent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: var(--flaeche2); border: 1px solid var(--rand); padding: 0 3px; border-radius: 3px; font-size: .9em; overflow-wrap: anywhere; }
.klein { font-size: .82rem; }
.leise-text { color: var(--leise); }
.rot-text { color: var(--rot); }
.gelb-text { color: var(--gelb); }
.gruen-text { color: var(--gruen); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; }
.nowrap { white-space: nowrap; }
.umbruch { overflow-wrap: anywhere; word-break: break-word; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.abstand { margin-top: 14px; }
.leer { color: var(--leise); text-align: center; padding: 14px; }

/* Formularelemente */
input, select, textarea, button { font: inherit; color: var(--text); }
input, select, textarea {
  background: var(--flaeche);
  border: 1px solid var(--rand-stark);
  border-radius: 5px;
  padding: 4px 8px;
  min-height: 30px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}
textarea { resize: vertical; }
input[type="file"] { padding: 3px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--akzent); outline-offset: -1px; border-color: var(--akzent); }
select.schmal { width: auto; max-width: 100%; }
button, .knopf {
  cursor: pointer;
  background: var(--akzent);
  color: #fff;
  border: 1px solid var(--akzent);
  border-radius: 5px;
  padding: 4px 10px;
  min-height: 30px;
  white-space: nowrap;
  flex: 0 0 auto;
}
button:hover { filter: brightness(1.08); }
button:focus-visible { outline: 2px solid var(--akzent); outline-offset: 2px; }
.knopf.leise { background: var(--flaeche); color: var(--text); border-color: var(--rand-stark); }
.knopf.leise:hover { background: var(--flaeche2); filter: none; }
.knopf.gefahr { background: var(--flaeche); color: var(--rot); border-color: #f0b4b4; }
.knopf.gefahr:hover { background: var(--rot-hell); filter: none; }
.knopf.bestaetigen, button.bestaetigen { background: var(--rot); color: #fff; border-color: var(--rot); font-weight: 600; }
.knopf.laeuft { background: var(--akzent-hell); color: var(--akzent); border-color: #b6cdf7; }
button:disabled { opacity: .55; cursor: default; filter: none; }
button.link { background: none; border: 0; padding: 0; min-height: 0; color: var(--akzent); text-decoration: underline; white-space: normal; }
label { color: var(--leise); font-size: .85rem; }

.karte { background: var(--flaeche); border: 1px solid var(--rand); border-radius: 8px; padding: 12px; min-width: 0; }
.karte.ohne-rand { padding: 0; overflow: hidden; }
.unterkarte { background: var(--flaeche2); border: 1px solid var(--rand); border-radius: 6px; padding: 10px; min-width: 0; }
.unterkarte-kopf { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; margin-bottom: 6px; }
.unterkarte-kopf h3 { margin: 0; }
.stapel { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.reihe { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; }
.reihe input { flex: 1 1 160px; width: auto; }
.knopfreihe { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-width: 0; }
.raster-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr)); gap: 12px; }

/* Anmeldung / Einrichtung */
.anmeldung { max-width: 340px; margin: 12vh auto; padding: 0 16px; }
.anmeldung h1 { margin-bottom: 12px; }
.anmeldung form { display: flex; flex-direction: column; gap: 8px; }

/* Meldungen */
.meldung { border-radius: 6px; padding: 7px 10px; margin: 0 0 10px; background: var(--gruen-hell); border: 1px solid #9fd8ac; }
.meldung.fehler { background: var(--rot-hell); border-color: #f0b4b4; }
.hinweisbox { background: var(--akzent-hell); border: 1px solid #b6cdf7; border-radius: 6px; padding: 8px 10px; margin-bottom: 10px; display: flex; flex-direction: column; gap: 6px; }

/* Obere Leiste */
.topbar {
  display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: space-between; align-items: center;
  background: var(--flaeche); border-bottom: 1px solid var(--rand); padding: 6px var(--rinne);
}
.topbar-links, .topbar-rechts { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; min-width: 0; }
.marke { font-size: 1rem; }
.seiten { display: flex; gap: 2px; }
.seite-link { padding: 5px 10px; border-radius: 5px; color: var(--leise); }
.seite-link:hover { background: var(--flaeche2); text-decoration: none; }
.seite-link.aktiv { background: var(--akzent-hell); color: var(--akzent); font-weight: 600; }
form.inline { margin: 0; }
.kopfzeile { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin-bottom: 10px; }
.inline-form { display: flex; gap: 6px; margin-left: auto; flex: 0 1 340px; min-width: 0; }
.inline-form input { flex: 1 1 auto; }

/* Kennzeichen */
.badges { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 2px; }
.badges:empty { display: none; }
.badge { display: inline-block; font-size: .72rem; line-height: 1.5; padding: 0 6px; border-radius: 999px; background: var(--flaeche2); border: 1px solid var(--rand); color: var(--leise); white-space: nowrap; }
.badge.gelb { background: var(--gelb-hell); border-color: #f0d58a; color: var(--gelb); }
.badge.blau { background: var(--akzent-hell); border-color: #b6cdf7; color: var(--akzent); }
.badge.rot { background: var(--rot-hell); border-color: #f0b4b4; color: var(--rot); font-weight: 600; }
.badge.typ-button { color: var(--akzent); border-color: #b6cdf7; }
.badge.typ-boot, .badge.typ-update_failed { background: var(--gelb-hell); color: var(--gelb); border-color: #f0d58a; }
.badge.typ-update_failed { background: var(--rot-hell); color: var(--rot); border-color: #f0b4b4; }
.badge.typ-crash { background: var(--rot); color: #fff; border-color: var(--rot); font-weight: 600; }
.badge.typ-nettool { color: var(--gruen); border-color: #9fd8ac; }
.punkt { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-left: 5px; vertical-align: middle; }
.punkt.rot { background: var(--rot); }
.punkt.blau { background: var(--akzent); }

/* Tabellen */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; color: var(--leise); font-weight: 600; }
table.geraete th, table.firmware th { background: var(--flaeche2); padding: 6px 10px; border-bottom: 1px solid var(--rand); }
table.geraete td, table.firmware td { padding: 6px 10px; border-bottom: 1px solid var(--rand); vertical-align: top; min-width: 0; overflow-wrap: anywhere; }
table.geraete tbody tr:last-child td, table.firmware tbody tr:last-child td { border-bottom: 0; }
tr.klickbar { cursor: pointer; }
tr.klickbar:hover { background: #f6f8fb; }
tr.gewaehlt, tr.gewaehlt:hover { background: var(--akzent-hell); }
.zelle-name { min-width: 160px; }
.name-knopf { background: none; border: 0; padding: 0; min-height: 0; color: var(--text); font-weight: 600; text-align: left; white-space: normal; }
.name-knopf:hover { color: var(--akzent); filter: none; }
table.mini { font-size: .88rem; }
table.mini th, table.mini td { padding: 3px 8px 3px 0; border-bottom: 1px solid var(--rand); vertical-align: top; overflow-wrap: anywhere; }
table.mini tr:last-child td { border-bottom: 0; }
table.ereignisse tr.ev-boot td, table.ereignisse tr.ev-update_failed td { background: var(--gelb-hell); }
table.ereignisse tr.ev-update_failed td { background: var(--rot-hell); }
table.ereignisse tr.ev-crash td { background: var(--rot-hell); color: var(--rot); }
table.ereignisse td:first-child, table.ereignisse td:nth-child(2) { width: 1%; white-space: nowrap; }
table.ereignisse td { padding-left: 4px; }

/* Detailbereich */
.detail { margin-top: 12px; padding: 0; }
.detail-kopf { display: flex; gap: 10px; justify-content: space-between; align-items: center; padding: 10px 12px 6px; }
.detail-kopf h2 { margin: 0; }
.tabs { display: flex; gap: 2px; padding: 0 8px; border-bottom: 1px solid var(--rand); overflow-x: auto; scrollbar-width: thin; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 0; color: var(--leise); padding: 6px 10px; min-height: 32px; }
.tab:hover { color: var(--text); filter: none; }
.tab.aktiv { color: var(--akzent); border-bottom-color: var(--akzent); font-weight: 600; }
.tab-inhalt { padding: 12px; min-width: 0; }
.raster-uebersicht { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 12px; }

/* Schlüssel/Wert-Raster */
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr) max-content minmax(0, 1fr); gap: 0 16px; margin: 0; }
.kv dt, .kv dd { margin: 0; }
.kv > dt { display: block; color: var(--leise); font-size: .82rem; padding: 3px 8px 3px 0; border-bottom: 1px solid var(--rand); }
.kv > dd { padding: 3px 0; border-bottom: 1px solid var(--rand); overflow-wrap: anywhere; min-width: 0; }

/* Formulare: Beschriftung links, Feld rechts */
.formular { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 10px; align-items: center; max-width: 720px; }
.formular-breit { max-width: none; grid-template-columns: max-content minmax(0, 1fr) max-content minmax(0, 1fr); }
.formular > label { white-space: nowrap; }
.feld { display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: center; min-width: 0; }
.feld input, .feld select { flex: 1 1 140px; width: auto; }
.feld textarea { flex: 1 1 100%; }
.feld > .klein { flex: 1 1 100%; }
.anzeige-text { font-size: .9rem; white-space: pre; overflow-x: auto; max-width: 42em; }

/* Drache */
.balken-zeile { display: flex; align-items: center; gap: 8px; min-width: 0; }
.balken-titel { flex: 0 0 5.5rem; color: var(--leise); }
.balken { flex: 1 1 auto; min-width: 50px; height: 8px; background: #e7e9ee; border-radius: 999px; overflow: hidden; }
.balken-fuellung { height: 100%; }
.balken-fuellung.gruen, .signal-balken.gruen { background: #2da44e; }
.balken-fuellung.gelb, .signal-balken.gelb { background: #d4a72c; }
.balken-fuellung.rot, .signal-balken.rot { background: var(--rot); }
.balken-wert { flex: 0 0 2rem; text-align: right; }
.mini-balken { display: flex; flex-direction: column; gap: 3px; margin: 4px 0; }

/* Net-Tools */
.nettool-leiste { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin-bottom: 6px; }
.nettool-leiste .reihe { flex: 1 1 360px; }
.nettool-raster { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); gap: 10px; margin-top: 8px; }
pre.json { background: #f6f8fa; border: 1px solid var(--rand); border-radius: 5px; padding: 8px; font-size: .78rem; max-height: 300px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; margin: 8px 0 0; }
.ping-zeiten { display: flex; gap: 2px; align-items: flex-end; height: 40px; flex-wrap: nowrap; overflow: hidden; }
.ping-balken { flex: 1 1 0; max-width: 18px; height: 100%; display: flex; align-items: flex-end; background: #eef1f5; border-radius: 2px; }
.ping-balken span { display: block; width: 100%; background: var(--akzent); border-radius: 2px; }
.ping-balken.timeout { background: var(--rot-hell); align-items: center; justify-content: center; color: var(--rot); font-size: .7rem; }
.kanaele { display: flex; gap: 2px; align-items: flex-end; height: 48px; }
.kanal { flex: 1 1 0; display: flex; flex-direction: column; align-items: stretch; justify-content: flex-end; height: 100%; min-width: 0; }
.kanal-saeule { display: block; background: var(--akzent); border-radius: 2px 2px 0 0; min-height: 1px; }
.kanal-nr { font-size: .65rem; color: var(--leise); text-align: center; }
.signal { display: inline-flex; align-items: center; gap: 6px; min-width: 120px; }
.signal-balken { display: inline-block; height: 6px; border-radius: 3px; flex: 0 0 auto; max-width: 50px; }

/* Verwaltung */
.verwaltung-zeile { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.verwaltung-zeile .knopf { min-width: 170px; }

/* Firmware */
.changelog { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--leise); }
#upload-token-reihe .knopf { flex: 0 0 auto; }

/* Mittlere Breite: Formular einspaltig, Übersicht untereinander */
@media (max-width: 1100px) {
  .formular-breit { grid-template-columns: max-content minmax(0, 1fr); }
  .raster-uebersicht { grid-template-columns: minmax(0, 1fr); }
}

/* Schmale Bildschirme: Tabellen werden zu Karten */
@media (max-width: 820px) {
  .kv { grid-template-columns: max-content minmax(0, 1fr); }
  table.geraete thead, table.firmware thead { display: none; }
  table.geraete, table.geraete tbody, table.firmware, table.firmware tbody { display: block; }
  table.geraete tr, table.firmware tr {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 12px;
    padding: 8px 10px; border-bottom: 1px solid var(--rand);
  }
  table.geraete td, table.firmware td { display: block; padding: 0; border: 0; }
  table.geraete td[data-label]::before, table.firmware td[data-label]::before {
    content: attr(data-label); display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: .03em; color: var(--leise);
  }
  table.geraete td.zelle-name, table.firmware td.umbruch { grid-column: 1 / -1; }
  table.geraete td.zelle-name::before { display: none; }
  table.geraete td.leer, table.firmware td.leer { grid-column: 1 / -1; }
  .inline-form { margin-left: 0; flex: 1 1 100%; }
}
@media (max-width: 520px) {
  .formular, .formular-breit { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .formular > span:empty { display: none; }
  .formular > label { margin-top: 6px; }
  .topbar-rechts { width: 100%; }
  .topbar-rechts select { flex: 1 1 auto; }
}
input.haken { width: auto; min-height: 0; flex: 0 0 auto; }
