/* ==========================================================================
   Bodenanalyse – Web
   Aufbau und Formen angelehnt an PCBWay (weiße Kopfzeile, dunkle Menüleiste,
   flache Karten, kantige Felder), Farben aus dem Qt-Theme "Wurzelwerk"
   (Logo-Farben: Waldgrün, Sand, Weiß).
   ========================================================================== */

@import url("https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap");

:root {
  /* Palette aus style.qss der Qt-App */
  --forest-dark: #17351c;    /* Waldgrün dunkel */
  --forest: #244e2a;         /* Waldgrün – Hauptfarbe */
  --forest-mid: #2f6437;     /* Auswahl */
  --forest-light: #3d7a46;   /* Waldgrün hell – Hover, Fokus */
  --green-pale: #c9d9c6;     /* Hover-Fläche */
  --green-zebra: #dbe4d7;    /* Tabellenzeilen */
  --sand-logo: #d8cdbb;      /* Kreisfläche im Logo */
  --sand: #d9d1bf;           /* Dialoggrund */
  --sand-light: #e6dfcf;     /* helle Flächen */
  --cream: #f7f2e2;          /* Tooltip-Creme */
  --sand-border: #9c8f78;
  --sand-line: #b5a98f;
  --ink: #1f2a20;            /* Text */
  --ink-muted: #4d4739;      /* Nebentext */
  --radius: 2px;
  --page: #d3ccb9;           /* Seitenhintergrund */
  --surface: #e9e3d4;        /* Kopfzeile, Panels, Felder, Tabellen */
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Roboto, "Helvetica Neue", Helvetica, Tahoma, Arial, sans-serif;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--page);
  /* Footer immer ganz unten: Seite ist mindestens so hoch wie das Fenster,
     der Inhalt (.container) nimmt den übrigen Platz ein. */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--forest-light); }
a:hover { color: var(--forest); }

::selection { background: var(--forest-mid); color: #ffffff; }

/* ---------- Kopfbereich: weiße Zeile + dunkle Menüleiste ---------- */

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  padding: 0 max(24px, calc((100% - 1100px) / 2));
  background: var(--surface);
  border-top: 6px solid var(--forest-light);
  border-image: linear-gradient(90deg, var(--forest-light), var(--forest), var(--forest-dark)) 1;
}

.brand {
  order: 1;
  flex: 1;
  display: flex;
  align-items: center;
  height: 72px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--forest);
  text-decoration: none;
}
.brand:hover { color: var(--forest-light); }

.user {
  order: 2;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink-muted);
  font-size: 13px;
}

/* ---------- Benutzer-Menü: Dropdown beim Darüberfahren ---------- */

/* Knopf und aufgeklapptes Menü sind immer gleich breit. Ohne Angabe richtet
   sich die Breite nach dem Text im Knopf (mindestens 170px). Eine feste
   Breite gibt --menu-width vor, pro Menü im CSS oder direkt im HTML:
   <div class="user-menu" style="--menu-width: 300px"> */
.user-menu {
  position: relative;
  display: inline-block;
  width: var(--menu-width, auto);
  min-width: 170px;
}
.user-menu > .btn {
  width: 100%;
  justify-content: center;
  overflow: hidden;
  white-space: nowrap;
}

/* Das Menü ist selbst der Kasten. Der kleine Abstand zum Button wird durch
   ein unsichtbares Stück darüber überbrückt (::before), damit das Menü beim
   Hinüberfahren mit der Maus nicht wieder zugeht. */
.user-menu-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 100;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--sand-border);
  border-radius: var(--radius);
  box-shadow: 0 4px 10px rgba(31, 42, 32, 0.18);
}
.user-menu-dropdown::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -5px;
  height: 5px;
}
.user-menu:hover .user-menu-dropdown,
.user-menu:focus-within .user-menu-dropdown { display: block; }

.user-menu-dropdown form { margin: 0; }

/* Links und Buttons im Menü sehen gleich aus: eine Zeile pro Eintrag */
.user-menu-dropdown a,
.user-menu-dropdown button {
  display: block;
  width: 100%;
  padding: 8px 14px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.user-menu-dropdown a:hover,
.user-menu-dropdown button:hover { background: var(--green-pale); color: var(--forest); }

/* ---------- Messgerät-Menü (eigene Klassen, unabhängig vom Benutzer-Menü) ---------- */

/* Aufbau im HTML:
   <div class="device-menu" id="device-menu" data-state="disconnected">
     <a class="device-button" id="btn-device-connect">Messgerät</a>
     <div class="device-dropdown"> ... </div>
   </div>
   serial-device.js setzt data-state: disconnected | connecting | connected.
   Knopf und Dropdown liegen in einem Raster mit einer Spalte. Die Spalte ist
   so breit wie das Breitere von beiden (ohne Zeilenumbruch), beide füllen sie.
   Das Dropdown steht in einer 0 hohen Zeile: es nimmt keine Höhe ein, ragt
   aber nach unten heraus und ist nur beim Darüberfahren sichtbar. */
.device-menu {
  position: relative;
  display: inline-grid;
  grid-template-rows: auto 0;
}

.device-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0;
  border: 1px solid var(--sand-border);
  border-radius: var(--radius);
  background: var(--sand-light);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  /* Immer quadratisch, Höhe wie .btn (eine Zeile + 2 x 6px Padding
     + 2 x 1px Rahmen). justify-self verhindert das Strecken auf die
     Breite des Dropdowns. */
  box-sizing: border-box;
  justify-self: end;
  width: calc(1lh + 14px);
  height: calc(1lh + 14px);
}
.device-button:hover { background: var(--green-pale); border-color: var(--forest-light); color: var(--ink); }

/* Statuspunkt vor dem Text, Standard: rot (getrennt) */
.device-button::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #8c2a1c;
}

.device-menu[data-state="connecting"] .device-button {
  background: #f3e2a0;
  border-color: #c9a227;
  color: #5c4408;
  pointer-events: none;
}
.device-menu[data-state="connecting"] .device-button::before { background: #c9a227; animation: device-pulse 1s infinite; }

.device-menu[data-state="connected"] .device-button { background: #2f9e44; border-color: #1f7a31; color: #ffffff; }
.device-menu[data-state="connected"] .device-button:hover { background: #38b04f; color: #ffffff; }
.device-menu[data-state="connected"] .device-button::before { background: #ffffff; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35); }

/* Dropdown mit unsichtbarer Hover-Brücke (::before), damit es beim
   Hinüberfahren mit der Maus nicht zugeht */
.device-dropdown {
  visibility: hidden;
  align-self: start;
  position: relative;
  z-index: 100;
  margin-top: 4px;
  background: var(--surface);
  border: 1px solid var(--sand-border);
  border-radius: var(--radius);
  box-shadow: 0 4px 10px rgba(31, 42, 32, 0.18);
}
.device-dropdown::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -5px;
  height: 5px;
}
.device-menu:hover .device-dropdown,
.device-menu:focus-within .device-dropdown { visibility: visible; }

/* Einträge im Dropdown (Buttons) */
.device-action {
  display: block;
  width: 100%;
  padding: 8px 14px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}
.device-action:hover { background: var(--green-pale); color: var(--forest); }
.device-action:disabled { opacity: .5; cursor: not-allowed; }

/* "Verbindung trennen" gibt es nur, solange verbunden ist */
.device-menu:not([data-state="connected"]) #btn-device-disconnect { display: none; }

/* Geräteinfos (Firmware, Hardware) als kleine Tabelle im Dropdown */
.device-dropdown table,
.device-dropdown table.table {
  margin: 0;
  border: 0;
  border-top: 1px solid var(--sand-line);
  border-radius: 0;
  font-size: 12px;
}
.device-dropdown caption { padding: 8px 14px 4px; font-size: 12px; white-space: nowrap; }
.device-dropdown td { padding: 4px 14px; white-space: nowrap; }

@keyframes device-pulse { 50% { opacity: .35; } }


/* Menü bricht in eine eigene Zeile um. Der dunkle Hintergrund wird per
   Schatten bis an den Fensterrand verlängert, die Links bleiben aber
   auf der Breite des Inhalts ausgerichtet. */
.topbar nav {
  order: 3;
  flex-basis: 100%;
  display: flex;
  gap: 28px;
  height: 40px;
  background: var(--forest);
  box-shadow: 0 0 0 100vmax var(--forest);
  clip-path: inset(0 -100vmax);
}

.topbar nav a,
.topbar nav .soon {
  display: flex;
  align-items: center;
  height: 40px;
  padding-top: 4px;
  border-bottom: 4px solid transparent;
  color: #ffffff;
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
}
.topbar nav a:hover { color: #ffffff; border-bottom-color: rgba(216, 205, 187, 0.45); }
.topbar nav a.active { border-bottom-color: var(--sand-logo); }
.topbar nav .soon { color: #93ad97; cursor: default; }

/* ---------- Inhalt ---------- */

.container {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px 40px;
}

h1, h2, h3 { color: var(--forest); line-height: 1.25; }
h1 { margin: 0 0 6px; font-size: 22px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 700; }

.lead { margin: 0 0 22px; color: var(--ink-muted); font-size: 13px; }

/* Kennzahl-Karten: Sandfläche, grüne Leiste links */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}
.card {
  padding: 14px 18px;
  background: var(--sand-light);
  border-left: 4px solid var(--forest-light);
  border-radius: var(--radius);
}
.card .label { color: var(--ink-muted); font-size: 13px; }
.card .value { color: var(--forest); font-size: 30px; font-weight: 700; line-height: 1.2; }

/* Panel: weiß mit Sandrahmen, Überschrift auf Sand mit grüner Unterlinie */
.panel {
  margin-top: 22px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--sand-line);
  border-radius: var(--radius);
}
.panel h2 {
  margin: -16px -20px 14px;
  padding: 10px 20px;
  background: var(--sand-light);
  border-bottom: 2px solid var(--forest);
  font-size: 15px;
}
.panel ul { margin: 0; padding-left: 18px; }
.panel li { margin: 4px 0; }

/* ---------- Bausteine für die nächsten Seiten ---------- */

/* Hauptaktion: volles Waldgrün (entspricht accent="true" in der Qt-App) */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 20px;
  border: 1px solid var(--forest);
  border-radius: var(--radius);
  background: var(--forest);
  color: #ffffff;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--forest-light); border-color: var(--forest-light); color: #ffffff; }
.btn:active { background: var(--forest-dark); border-color: var(--forest-dark); }

/* Zweitaktion: helles Grün mit grünem Rahmen */
.btn-green { background: var(--green-pale); border-color: var(--forest-light); color: var(--forest); }
.btn-green:hover { background: #b9cfb5; border-color: var(--forest); color: var(--forest); }

/* Neutral: Sand mit Sandrahmen */
.btn-plain { background: var(--sand-light); color: var(--ink); border-color: var(--sand-border); font-weight: 400; font-size: 13px; }
.btn-plain:hover { background: var(--green-pale); border-color: var(--forest-light); color: var(--ink); }

label { display: block; margin-bottom: 4px; font-weight: 500; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
select, textarea {
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--sand-border);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
textarea { height: auto; padding: 6px 8px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--forest-light); box-shadow: 0 0 0 2px rgba(61, 122, 70, 0.18); }

table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--sand-line); text-align: left; }
th { background: var(--sand); color: var(--ink); font-weight: 700; }
tbody tr:nth-child(even) td { background: var(--green-zebra); }
tr:hover td { background: var(--green-pale); }

.tag { display: inline-block; padding: 1px 8px; border-radius: var(--radius); background: var(--sand); font-size: 12px; }
.tag.ok   { background: var(--green-pale); color: var(--forest); }
.tag.warn { background: var(--cream); color: #7a5a12; border: 1px solid #e3d3a4; }
.tag.err  { background: #f6e3df; color: #8c2a1c; }

/* ---------- Tabellen (Erweiterung) ---------- */

/* Scrollbarer Rahmen für breite Tabellen: <div class="table-wrap"><table>… */
.table-wrap { overflow-x: auto; border: 1px solid var(--sand-line); border-radius: var(--radius); }
.table-wrap table { border: 0; }
.table-wrap tr:last-child td { border-bottom: 0; }

table.table { border: 1px solid var(--sand-line); border-radius: var(--radius); }
table caption { padding: 8px 10px; text-align: left; font-weight: 700; color: var(--forest); caption-side: top; }
thead th { border-bottom: 2px solid var(--forest); }
tfoot td, tfoot th { background: var(--sand-light); font-weight: 700; border-top: 2px solid var(--sand-line); }
td, th { vertical-align: middle; }
/* Tabellen ohne Kopfzeile (Kennzahl | Wert): linke Spalte als Beschriftung */
table.table tr > td:first-child:not(:last-child) { color: var(--ink-muted); width: 1%; white-space: nowrap; font-weight: 500; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.center, th.center { text-align: center; }
tr.clickable { cursor: pointer; }
tr.selected td { background: var(--forest-mid); color: #ffffff; }
tr.muted td { color: var(--ink-muted); }
table a { font-weight: 500; }

/* ---------- Text, Listen, Code ---------- */

p { margin: 0 0 12px; }
ul, ol { margin: 0 0 12px; padding-left: 22px; }
li { margin: 3px 0; }
dl { margin: 0 0 12px; }
dt { font-weight: 700; color: var(--forest); }
dd { margin: 0 0 8px; }
hr { margin: 22px 0; border: 0; border-top: 1px solid var(--sand-line); }
small, .small { font-size: 12px; }
.muted { color: var(--ink-muted); }
strong, b { font-weight: 700; }
blockquote {
  margin: 0 0 12px;
  padding: 8px 16px;
  background: var(--sand-light);
  border-left: 4px solid var(--forest-light);
  color: var(--ink-muted);
}
code, kbd, samp {
  padding: 1px 5px;
  background: var(--sand);
  border-radius: var(--radius);
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}
pre {
  margin: 0 0 12px;
  padding: 10px 14px;
  overflow-x: auto;
  background: var(--forest-dark);
  color: var(--sand-light);
  border-radius: var(--radius);
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.5;
}
pre code { padding: 0; background: none; color: inherit; }
img { max-width: 100%; height: auto; }
h4, h5, h6 { margin: 0 0 8px; color: var(--forest); font-size: 13px; font-weight: 700; }
h2, h3 { margin: 22px 0 10px; }

/* ---------- Formulare (Erweiterung) ---------- */

form p { margin: 0 0 12px; }
input[type="date"], input[type="time"], input[type="datetime-local"],
input[type="url"], input[type="search"], input[type="tel"], input[type="file"] {
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--sand-border);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
input[type="file"] { height: auto; padding: 4px 8px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--forest); width: 15px; height: 15px; vertical-align: middle; }
input:disabled, select:disabled, textarea:disabled { background: var(--sand); color: var(--ink-muted); cursor: not-allowed; }
input::placeholder, textarea::placeholder { color: #8a8470; }
select { padding-right: 4px; }
fieldset { margin: 0 0 16px; padding: 12px 16px; border: 1px solid var(--sand-line); border-radius: var(--radius); }
legend { padding: 0 6px; font-weight: 700; color: var(--forest); }
.helptext, .help { display: block; margin-top: 2px; font-size: 12px; color: var(--ink-muted); }
.errorlist { margin: 0 0 6px; padding: 0; list-style: none; color: #8c2a1c; font-size: 12px; }
.form-row { margin-bottom: 14px; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 16px; }

/* ---------- Formular-Karte (Login, Passwort ändern, Registrierung …) ---------- */

/* Schmale, zentrierte Karte. Ihre Überschrift sitzt wie beim .panel auf Sand
   mit grüner Unterlinie.
   <div class="form-card"><h1>Anmelden</h1><form>…</form></div> */
.form-card {
  max-width: 420px;
  margin: 24px auto 0;
  padding: 0 24px 24px;
  background: var(--surface);
  border: 1px solid var(--sand-line);
  border-radius: var(--radius);
}
.form-card h1 {
  margin: 0 -24px 20px;
  padding: 12px 24px;
  background: var(--sand-light);
  border-bottom: 2px solid var(--forest);
  font-size: 18px;
}

/* Django rendert {{ form }} als <div> je Feld (Label, Eingabe, Hilfetext,
   Fehler). Hier bekommt jedes Feld Abstand und volle Breite. */
.form-card form > div,
form.form-stack > div { margin-bottom: 14px; }
.form-card input[type="text"], .form-card input[type="email"],
.form-card input[type="password"], .form-card input[type="number"],
.form-card select, .form-card textarea,
form.form-stack input[type="text"], form.form-stack input[type="email"],
form.form-stack input[type="password"], form.form-stack input[type="number"],
form.form-stack select, form.form-stack textarea { width: 100%; }

/* Eingabefeld mit Fehler: roter Rahmen (Django setzt aria-invalid) */
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] {
  border-color: #8c2a1c;
}

/* Gesamtbreite für den Absende-Button und Zeile für Zusatzlinks darunter */
.form-card .form-actions { margin-top: 20px; }
.form-card .form-actions .btn { flex: 1; justify-content: center; }
.form-links { margin: 16px 0 0; font-size: 12px; text-align: center; color: var(--ink-muted); }
.form-links a { font-weight: 500; }

/* Weitere Buttons */
.btn-danger { background: #f6e3df; border-color: #8c2a1c; color: #8c2a1c; }
.btn-danger:hover { background: #8c2a1c; border-color: #8c2a1c; color: #ffffff; }
.btn-small { padding: 3px 10px; font-size: 12px; }
.btn:disabled, .btn.disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
button.btn { font-family: inherit; }

/* ---------- Meldungen (Django messages) ---------- */

.messages { margin: 0 0 16px; padding: 0; list-style: none; }
.messages li, .alert {
  margin: 0 0 8px;
  padding: 9px 14px;
  background: var(--sand-light);
  border: 1px solid var(--sand-line);
  border-left: 4px solid var(--forest-light);
  border-radius: var(--radius);
}
.messages li.success, .alert.ok { background: var(--green-pale); border-left-color: var(--forest); color: var(--forest); }
.messages li.warning, .alert.warn { background: var(--cream); border-color: #e3d3a4; border-left-color: #c9a227; color: #7a5a12; }
.messages li.error, .alert.err { background: #f6e3df; border-color: #e0b9b2; border-left-color: #8c2a1c; color: #8c2a1c; }

/* ---------- Sonstiges ---------- */

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 14px; }
.row { display: flex; flex-wrap: wrap; gap: 20px; }
.row > * { flex: 1; min-width: 240px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0 0 12px; }
.kv dt { color: var(--ink-muted); font-weight: 500; }
.kv dd { margin: 0; }
.empty { padding: 32px; text-align: center; color: var(--ink-muted); border: 1px dashed var(--sand-border); border-radius: var(--radius); }
.pagination { display: flex; gap: 6px; margin: 14px 0; }
.pagination a, .pagination span { padding: 3px 10px; border: 1px solid var(--sand-border); background: var(--sand-light); color: var(--ink); text-decoration: none; }
.pagination a:hover { background: var(--green-pale); border-color: var(--forest-light); }
.pagination .current { background: var(--forest); border-color: var(--forest); color: #ffffff; }
.visually-hidden, .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Fußzeile ---------- */

.footer {
  padding: 18px 24px;
  background: var(--forest-dark);
  color: var(--sand-logo);
  font-size: 12px;
  text-align: center;
}

/* ---------- Hilfsklassen (Text, Abstände, Anordnung) ---------- */

/* Textausrichtung: <h1 class="text-center">…</h1> */
.text-center { text-align: center; }
.text-left   { text-align: left; }
.text-right  { text-align: right; }

/* Textfarbe und -größe */
.text-muted  { color: var(--ink-muted); }
.text-green  { color: var(--forest); }
.text-error  { color: #8c2a1c; }
.text-small  { font-size: 12px; }
.text-large  { font-size: 16px; }
.text-bold   { font-weight: 700; }

/* Seitenkopf: große Überschrift mit kleinem Untertitel darunter.
   <div class="page-header"><h1>Surveys</h1><p>Alle deine Messungen</p></div> */
.page-header { margin-bottom: 20px; }
.page-header p { margin: 0; color: var(--ink-muted); }
.page-header.centered { text-align: center; }

/* Abschnittsüberschrift mit grüner Linie darunter */
.section-title {
  margin: 28px 0 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--forest);
}

/* Abstände: mt = oben, mb = unten (klein, mittel, groß) */
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 32px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 32px; }

/* Anordnung: Elemente in einer Zeile, optional rechtsbündig oder verteilt */
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.row.center { justify-content: center; }

/* Raster mit gleich breiten Spalten, bricht von selbst um */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }

/* Schmaler, zentrierter Inhaltsbereich (z. B. Textseiten wie die Startseite) */
.narrow { max-width: 720px; margin-left: auto; margin-right: auto; }

.hidden { display: none; }

/* ---------- Messeinstellungen (Messplatz) ---------- */

/* Felder untereinander: Beschriftung links, Feld rechts, alle Felder gleich breit */
:is(#device-settings-form, #electrode-settings-form) fieldset {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 48px;
  max-width: 1000px;
  padding: 6px 24px;
  background: var(--surface);
  min-width: 0;
}
:is(#device-settings-form, #electrode-settings-form) label {
  display: grid;
  grid-template-columns: 1fr 150px;
  align-items: center;
  gap: 16px;
  margin: 0;
  padding: 9px 0;
  border-bottom: 1px solid var(--sand-line);
  font-weight: 500;
  color: var(--ink);
}
:is(#device-settings-form, #electrode-settings-form) label:nth-last-child(-n+2) { border-bottom: 0; }
@media (max-width: 800px) {
  :is(#device-settings-form, #electrode-settings-form) fieldset { grid-template-columns: minmax(0, 1fr); }
  :is(#device-settings-form, #electrode-settings-form) label:nth-last-child(2) { border-bottom: 1px solid var(--sand-line); }
}
:is(#device-settings-form, #electrode-settings-form) input[type="number"],
:is(#device-settings-form, #electrode-settings-form) select {
  width: 100%;
  box-sizing: border-box;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
:is(#device-settings-form, #electrode-settings-form) select { text-align: left; }
:is(#device-settings-form, #electrode-settings-form) select { padding-right: 8px; }
:is(#device-settings-form, #electrode-settings-form) input:disabled,
:is(#device-settings-form, #electrode-settings-form) select:disabled {
  background: var(--sand-light);
  border-color: var(--sand-line);
}
/* berechnete Werte (nur lesbar) neben den Eingabefeldern, rechtsbündig wie diese */
#electrode-settings-form output {
  display: block;
  padding: 0 9px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--ink-muted);
}
#device-settings-status, #electrode-settings-status { margin: 10px 0 0; font-size: 13px; color: var(--ink-muted); }

/* ---------- schmale Bildschirme ---------- */

@media (max-width: 700px) {
  .brand { font-size: 20px; height: 56px; }
  .topbar nav { gap: 18px; overflow-x: auto; scrollbar-width: none; }
}