/*
 * Design-System instakorr-control.
 * Bewusst schlank und ohne Framework: der gesamte Aufbau steht hier,
 * damit spätere Masken sich daran halten können statt eigene Wege zu gehen.
 */

:root {
  --grund: #ffffff;
  --flaeche: #f5f6f8;
  --flaeche-stark: #e9ebef;
  --linie: #dcdfe4;
  --schrift: #1f2933;
  --schrift-blass: #6b7684;

  /*
   * Farben aus der bestehenden Ninox-Oberfläche übernommen, damit der
   * Wechsel niemanden umgewöhnen lässt: dunkles Marineblau trägt Kopfzeilen,
   * Abschnittsbalken und Tabellenköpfe, Orange gehört den Aktionen.
   */
  --navy: #1f3864;
  --navy-hell: #2c4a7c;
  --orange: #e8a33d;
  --orange-dunkel: #d4913a;
  --akzent: #3b6fd4;
  --akzent-dunkel: #2f5cb3;
  --akzent-blass: #e8f1fb;
  --feld: #efefef;
  --gut: #4caf50;
  --schlecht: #e05252;

  --abstand: 1rem;
  --radius: 6px;
  --radius-gross: 10px;
  --schatten: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.1);
  --schriftfamilie: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --schriftfamilie-fest: ui-monospace, "Cascadia Mono", Consolas, monospace;

  /*
   * Immer helle Oberfläche – wie Ninox. Ohne diese Festlegung würde der
   * Browser bei einem auf "dunkel" gestellten Rechner die eingebauten
   * Bedienelemente (Eingabefelder, Auswahllisten, Kästchen) dunkel zeichnen,
   * während der Rest hell bleibt.
   */
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--schriftfamilie);
  font-size: 15px;
  line-height: 1.55;
  color: var(--schrift);
  background: var(--grund);
}

/* Sprungmarke für Tastaturbedienung */
.sprung {
  position: absolute;
  left: -9999px;
}
.sprung:focus {
  left: var(--abstand);
  top: var(--abstand);
  z-index: 10;
  padding: 0.5rem 0.75rem;
  background: var(--akzent);
  color: #fff;
  border-radius: var(--radius);
}

.kopf {
  display: flex;
  align-items: center;
  gap: var(--abstand);
  padding: 0.75rem var(--abstand);
  border-bottom: 1px solid var(--linie);
  background: var(--flaeche);
}

.marke {
  font-weight: 650;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--schrift);
  text-decoration: none;
}
.marke span { color: var(--akzent); }

.rahmen {
  display: grid;
  grid-template-columns: 17rem minmax(0, 1fr);
  min-height: calc(100vh - 7rem);
}

.navigation {
  padding: var(--abstand) 0.5rem;
  border-right: 1px solid var(--linie);
  background: var(--flaeche);
  overflow-y: auto;
  max-height: calc(100vh - 7rem);
  position: sticky;
  top: 0;
}

.navigation details { margin-bottom: 0.25rem; }

.navigation summary {
  cursor: pointer;
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius);
  font-weight: 600;
  text-transform: capitalize;
}
.navigation summary:hover { background: var(--flaeche-stark); }

.navigation ul {
  margin: 0.15rem 0 0.5rem;
  padding: 0 0 0 0.5rem;
  list-style: none;
  border-left: 2px solid var(--linie);
}

.navigation li a {
  display: block;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius);
  color: var(--schrift-blass);
  text-decoration: none;
  font-size: 0.9rem;
}
.navigation li a:hover {
  background: var(--akzent-blass);
  color: var(--akzent);
}

main {
  padding: calc(var(--abstand) * 1.5);
  min-width: 0;   /* damit breite Tabellen den Rahmen nicht sprengen */
}

h1 {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
}

h2 {
  margin: 2rem 0 0.75rem;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.lauftext {
  max-width: 62ch;
  color: var(--schrift-blass);
}

.anzahl {
  display: inline-block;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--flaeche-stark);
  color: var(--schrift-blass);
  font-size: 0.75rem;
  font-weight: 600;
}

.kennzahlen {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.75rem;
  margin: 1.5rem 0 0;
  padding: 0;
  list-style: none;
}

.kennzahlen li {
  padding: 0.85rem 1rem;
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  background: var(--flaeche);
  color: var(--schrift-blass);
  font-size: 0.85rem;
}

.kennzahlen strong {
  display: block;
  font-size: 1.6rem;
  font-weight: 650;
  color: var(--schrift);
  font-variant-numeric: tabular-nums;
}

/* Breite Tabellen scrollen in sich, nie die Seite */
.tabellenrahmen {
  overflow-x: auto;
  border: 1px solid var(--linie);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

thead th {
  position: sticky;
  top: 0;
  padding: 0.5rem 0.75rem;
  text-align: left;
  background: var(--flaeche-stark);
  border-bottom: 1px solid var(--linie);
  white-space: nowrap;
}

tbody td {
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid var(--linie);
  vertical-align: top;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--flaeche); }

.blass { color: var(--schrift-blass); }

code {
  font-family: var(--schriftfamilie-fest);
  font-size: 0.85em;
}

.formel {
  display: block;
  max-width: 70ch;
  overflow-x: auto;
  white-space: pre;
  color: var(--schrift-blass);
}

.liste {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--schrift-blass);
}

a { color: var(--akzent); }

.fuss {
  display: flex;
  justify-content: space-between;
  gap: var(--abstand);
  padding: 0.75rem var(--abstand);
  border-top: 1px solid var(--linie);
  background: var(--flaeche);
  color: var(--schrift-blass);
  font-size: 0.8rem;
}

@media (max-width: 55rem) {
  .rahmen { grid-template-columns: 1fr; }
  .navigation {
    position: static;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--linie);
  }
  .fuss { flex-direction: column; gap: 0.25rem; }
  .stand { display: none; }
}

/* Mandantenumschaltung in der Kopfzeile */
.mandanten {
  display: flex;
  gap: 0.25rem;
  margin-left: auto;
  flex-wrap: wrap;
}
.mandanten a {
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--linie);
  border-radius: 999px;
  color: var(--schrift-blass);
  text-decoration: none;
  font-size: 0.82rem;
}
.mandanten a:hover { background: var(--flaeche-stark); }
.mandanten a.aktiv {
  background: var(--akzent-blass);
  border-color: var(--akzent);
  color: var(--akzent);
  font-weight: 600;
}

/* Suche über der Liste */
.suchleiste {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin: 1rem 0;
  flex-wrap: wrap;
}
.suchleiste input[type="search"] {
  flex: 1 1 18rem;
  min-width: 0;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  background: var(--grund);
  color: var(--schrift);
  font: inherit;
}
.suchleiste input[type="search"]:disabled { opacity: 0.5; }
.suchleiste button {
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--akzent);
  border-radius: var(--radius);
  background: var(--akzent);
  color: #fff;
  font: inherit;
  cursor: pointer;
}
.suchleiste button:hover { filter: brightness(1.1); }
.zuruecksetzen { font-size: 0.85rem; }

/* Seitenweises Blättern */
.blaettern {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin: 0.75rem 0;
  font-size: 0.9rem;
}
.blaettern a {
  padding: 0.3rem 0.8rem;
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  text-decoration: none;
}
.blaettern a:hover { background: var(--flaeche-stark); }
.blaettern a.aus {
  pointer-events: none;
  opacity: 0.4;
}
.blaettern span { color: var(--schrift-blass); }

/* Zahlen rechtsbündig und mit gleicher Ziffernbreite – so lassen sie sich vergleichen */
.rechts { text-align: right; }
.zahl { font-variant-numeric: tabular-nums; }
.leer { color: var(--schrift-blass); }

h3 { margin: 1.25rem 0 0.5rem; font-size: 0.98rem; }

details > summary { cursor: pointer; }

/* Anmeldung, Passwort vergessen/zuruecksetzen */
.anmeldeseite {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--flaeche);
}

.anmeldekarte {
  width: 100%;
  max-width: 22rem;
  padding: 2rem 1.75rem;
  background: var(--grund);
  border: 1px solid var(--linie);
  border-radius: 10px;
}

.anmelde-marke {
  display: block;
  margin-bottom: 1.5rem;
  font-weight: 650;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--schrift);
  text-decoration: none;
}
.anmelde-marke span { color: var(--akzent); }

.anmeldekarte h1 {
  margin: 0 0 1.25rem;
  font-size: 1.25rem;
}

.anmeldeformular {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.anmeldeformular label {
  margin-top: 0.6rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--schrift-blass);
}

.anmeldeformular input {
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  background: var(--grund);
  color: var(--schrift);
  font: inherit;
}
.anmeldeformular input:focus {
  outline: 2px solid var(--akzent);
  outline-offset: 1px;
}

.anmeldeformular button {
  margin-top: 1.1rem;
  padding: 0.6rem 1rem;
  border: 1px solid var(--akzent);
  border-radius: var(--radius);
  background: var(--akzent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.anmeldeformular button:hover { filter: brightness(1.08); }

.anmelde-nebenlink {
  margin-top: 1.1rem;
  font-size: 0.88rem;
}

.anmelde-hinweis {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  color: var(--schrift-blass);
}

.anmelde-fehler {
  margin: 0 0 1rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius);
  background: color-mix(in srgb, #e04f5f 12%, var(--grund));
  border: 1px solid color-mix(in srgb, #e04f5f 40%, var(--linie));
  color: #e04f5f;
  font-size: 0.88rem;
}

/* Angemeldeter Benutzer in der Kopfzeile */
.kontomenue {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--schrift-blass);
  margin-left: 0.75rem;
}
.kontomenue a { color: var(--akzent); text-decoration: none; }
.kontomenue a:hover { text-decoration: underline; }

/* Eingabe-Engine: generisches Formular, Aktionen in Listen */

.knopf-neu {
  margin-left: 0.75rem;
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius);
  background: var(--akzent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  vertical-align: middle;
}
.knopf-neu:hover { filter: brightness(1.08); }

td.aktionen, th.aktionen { white-space: nowrap; }
td.aktionen { display: flex; gap: 0.6rem; align-items: center; justify-content: flex-end; }
td.aktionen a { color: var(--akzent); text-decoration: none; font-size: 0.85rem; }
td.aktionen a:hover { text-decoration: underline; }
td.aktionen form { display: inline; margin: 0; }
td.aktionen button {
  padding: 0;
  border: 0;
  background: none;
  color: #b3435a;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
td.aktionen button:hover { text-decoration: underline; }

.formular-fehler {
  margin: 0 0 1.25rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  background: color-mix(in srgb, #e04f5f 12%, var(--grund));
  border: 1px solid color-mix(in srgb, #e04f5f 40%, var(--linie));
  color: #e04f5f;
}
.formular-fehler p { margin: 0 0 0.35rem; font-weight: 600; }
.formular-fehler ul { margin: 0; padding-left: 1.2rem; }

/*
 * Eingabemaske: Reiter als Unterseiten, darin Abschnitte mit Balken.
 *
 * Das <form>-Element selbst ist nur noch eine Hülle für die verborgenen
 * Felder; die sichtbaren Eingaben stehen über das form-Attribut darin,
 * damit sie sich auf die Reiter verteilen können.
 */
.formularschale { display: contents; }

.reiterleiste {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem;
  margin: 0 0 1rem;
  border-bottom: 2px solid var(--linie);
}
.reiterleiste .reiter {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.8rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--schrift-blass);
  text-decoration: none;
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}
.reiterleiste .reiter:hover { background: var(--flaeche); color: var(--schrift); }
.reiterleiste .reiter.gewaehlt {
  color: var(--navy);
  background: var(--flaeche);
  border-bottom-color: var(--orange);
}
.reitersymbol { font-size: 0.95rem; line-height: 1; }

/* Nur eine Hülle, die im Lesemodus alles darin abschaltet. */
.maskenbereich { border: 0; padding: 0; margin: 0; min-width: 0; }

.abschnittsraster {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  align-items: start;
}

/* Lesemodus: sichtbar, aber erkennbar nicht zum Anfassen. */
.maskenbereich:disabled .formularfeld input,
.maskenbereich:disabled .formularfeld select,
.maskenbereich:disabled .formularfeld textarea {
  color: var(--schrift);
  opacity: 1;
  cursor: default;
}
.maskenbereich:disabled .chip-entfernen,
.maskenbereich:disabled .mehrfachverweis-suche,
.maskenbereich:disabled .dateiloeschen { display: none; }

.hinweis-lesen {
  margin: 0 0 1rem;
  padding: 0.5rem 0.8rem;
  font-size: 0.85rem;
  color: var(--schrift-blass);
  background: var(--flaeche);
  border-left: 3px solid var(--orange);
  border-radius: 0 var(--radius) var(--radius) 0;
  max-width: 76rem;
}
.abschnitt--voll { grid-column: 1 / -1; }

.abschnittsbalken {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: -0.9rem -1rem 0.9rem;
  padding: 0.4rem 0.6rem 0.4rem 1rem;
  font-size: 0.92rem;
  font-weight: 650;
  color: #fff;
  background: var(--navy);
  border-radius: var(--radius-gross) var(--radius-gross) 0 0;
}

.abschnittsinhalt {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: 0.9rem 1.1rem;
  align-items: start;
}
.formularfeld--richtext,
.formularfeld--mehrfachauswahl,
.formularfeld--block,
.formularfeld--breit,
.unterlistenblock { grid-column: 1 / -1; }

.unterlistenblock h3 { margin: 0 0 0.5rem; }
.formularfeld--block textarea { width: 100%; resize: vertical; }

/* Zeilenumbruch aus der Ninox-Maske: nimmt die Restzeile weg, ohne Platz
   zu brauchen – das nächste Feld beginnt links in einer neuen Reihe. */
.zeilenumbruch { grid-column: 1 / -1; height: 0; }

/* Mehrfachauswahl: gleich breite Kästchen über die ganze Feldbreite. */
.checkboxgruppe {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
  gap: 0.2rem 0.5rem;
}
.checkboxoption {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}
.checkboxoption input { flex: none; }

/*
 * Nein/Ja-Umschalter wie in Ninox: zwei Felder nebeneinander, das gewählte
 * hervorgehoben. Die Auswahlknöpfe selbst sind unsichtbar, aber vorhanden –
 * Tastatur und Vorlesen bedienen sie weiterhin.
 */
.schalter {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--grund);
  min-width: 9rem;
}
.schalter input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.schalter label {
  padding: 0.4rem 0.7rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--schrift-blass);
  text-align: center;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.12s ease, color 0.12s ease;
}
.schalter label:hover { background: var(--flaeche); }
.schalter input:checked + label {
  background: var(--akzent);
  color: #fff;
}
.schalter input:focus-visible + label { outline: 2px solid var(--orange); outline-offset: -2px; }

/* Beim Lesen bleibt die Aussage sichtbar, nur nicht mehr anfassbar. Die
   Regel für abgeschaltete Felder hebt sonst das Verstecken der Auswahl-
   knöpfe wieder auf – deshalb hier ausdrücklich. */
.maskenbereich:disabled .formularfeld .schalter input { opacity: 0; }
.maskenbereich:disabled .schalter label { cursor: default; }
.maskenbereich:disabled .schalter label:hover { background: none; }
.maskenbereich:disabled .schalter input:checked + label { background: var(--akzent); }

/* Ein Schalter braucht keine eigene Zeile für seine Beschriftung. */
.formularfeld--schalter { flex-direction: column; align-items: stretch; gap: 0.3rem; }

/* PLZ, die gerade nachgeschlagen oder gerade ergänzt wurde. */
.formularfeld input.sucht { opacity: 0.6; }
.formularfeld input.ergaenzt {
  border-color: var(--gut);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--gut) 25%, transparent);
}

/*
 * Kartenausschnitt der Baustellenanschrift – über die volle Abschnittsbreite.
 *
 * `isolation` ist wichtig: Leaflet stapelt seine Ebenen intern mit hohen
 * Werten (400 bis 700). Ohne einen eigenen Stapelzusammenhang lägen die
 * aufgeklappten Auswahllisten der Zuständigkeiten darunter – man sah sie,
 * konnte sie aber nicht anklicken.
 */
.kartenausschnitt {
  margin-top: 0.9rem;
  position: relative;
  z-index: 0;
  isolation: isolate;
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--flaeche);
}
.kartenausschnitt .karte {
  width: 100%;
  height: 17rem;
  background: var(--flaeche-stark);
}
.kartenausschnitt.gross .karte { height: 34rem; }

/* Legende der Kartenfarben. */
.kartenlegende {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 1rem;
  margin: 0;
  padding: 0.4rem 0.6rem;
  list-style: none;
  font-size: 0.75rem;
  color: var(--schrift-blass);
  background: var(--flaeche);
  border-top: 1px solid var(--linie);
}
.kartenlegende li { display: flex; align-items: center; gap: 0.35rem; }
.punkt {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--linie);
}
.punkt--eigen { background: var(--orange); }
.punkt--ausfuehrung { background: #2f6fd0; }
.punkt--offen { background: #5c6b7f; }
.punkt--fertig { background: #b9bfc8; }

.kartenknoepfe {
  position: absolute;
  right: 0.5rem;
  bottom: 0.5rem;
  display: flex;
  gap: 0.3rem;
}
.kartenknopf {
  padding: 0.22rem 0.6rem;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--navy);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  cursor: pointer;
}
.kartenknopf:hover { background: #fff; }
.karte-fehlt { margin: 0; padding: 1.5rem 1rem; text-align: center; }

/* Helfer im Abschnittsbalken: Adresse in Karte öffnen, Text kopieren. */
.abschnittsaktionen { display: flex; gap: 0.3rem; flex: none; }
.abschnittsknopf {
  padding: 0.15rem 0.55rem;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
}
.abschnittsknopf:hover { background: rgba(255, 255, 255, 0.26); }
.abschnittsknopf.geschafft {
  background: var(--gut);
  border-color: var(--gut);
}

/* Anhak-Liste für Mehrfachverweise – Beobachter, Polier. */
.mehrfachwahl { position: relative; }
.mehrfachwahl > summary {
  display: block;
  cursor: pointer;
  list-style: none;
  padding: 0.45rem 0.6rem;
  font-size: 0.9rem;
  background: var(--feld);
  border: 1px solid transparent;
  border-radius: var(--radius);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mehrfachwahl > summary::-webkit-details-marker { display: none; }
.mehrfachwahl > summary::after { content: "▾"; float: right; color: var(--schrift-blass); }
.mehrfachwahl > summary:hover { border-color: var(--linie); }
.mehrfachwahl.gesetzt > summary { color: var(--schrift); font-weight: 600; }

.mehrfachwahl-liste {
  margin-top: 0.25rem;
  padding: 0.35rem;
  max-height: 16rem;
  overflow-y: auto;
  background: var(--grund);
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  box-shadow: var(--schatten);
  min-width: 12rem;
}
.mehrfachwahl-liste.schwebend { position: fixed; z-index: 1000; margin-top: 0; }
.mehrfachwahl-liste label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.2rem 0.25rem;
  font-size: 0.85rem;
  white-space: nowrap;
  cursor: pointer;
  border-radius: 4px;
}
.mehrfachwahl-liste label:hover { background: var(--flaeche); }
.mehrfachwahl-liste input[type="checkbox"] { width: auto; margin: 0; }

.formularfeld { display: flex; flex-direction: column; gap: 0.3rem; }
/*
 * Muss sein: das hidden-Attribut setzt display:none nur in der
 * Browser-Vorgabe, und jede eigene display-Angabe hebt das wieder auf. Ohne
 * diese Zeile blieben die Felder, die erst bei "Ja" erscheinen sollen,
 * immer sichtbar.
 */
.formularfeld[hidden] { display: none; }

/* Abgeleiteter Wert: sieht aus wie ein Feld, ist aber keins. */
.rechenwert {
  padding: 0.45rem 0.6rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  background: var(--flaeche);
  border: 1px dashed var(--linie);
  border-radius: var(--radius);
}
.rechenweg { font-size: 0.72rem; color: var(--schrift-blass); }

/* Bilder unter einem Dateifeld: Vorschau statt nur Dateiname. */
.dateiliste { display: flex; flex-wrap: wrap; gap: 0.6rem 1rem; }
.dateiliste li.mit-bild { display: flex; flex-direction: column; gap: 0.25rem; max-width: 14rem; }
.bildvorschau img {
  display: block;
  max-width: 14rem;
  max-height: 10rem;
  object-fit: contain;
  background: var(--flaeche);
  border: 1px solid var(--linie);
  border-radius: var(--radius);
}
.bildvorschau:hover img { border-color: var(--akzent); }

/* Löschen steht abgesetzt am rechten Rand – nicht neben Speichern. */
.formularaktionen .loeschform { margin-left: auto; }
.formularaktionen button.loeschen {
  background: none;
  color: var(--schlecht);
  border: 1px solid var(--schlecht);
  font-weight: 600;
}
.formularaktionen button.loeschen:hover {
  background: color-mix(in srgb, var(--schlecht) 12%, var(--grund));
  filter: none;
}
.formularfeld--richtext, .formularfeld--mehrfachauswahl { grid-column: 1 / -1; }

.formularfeld label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--schrift-blass);
}

.formularfeld input[type="text"],
.formularfeld input[type="email"],
.formularfeld input[type="tel"],
.formularfeld input[type="url"],
.formularfeld input[type="number"],
.formularfeld input[type="date"],
.formularfeld input[type="datetime-local"],
.formularfeld input[type="time"],
.formularfeld select,
.formularfeld textarea {
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  background: var(--grund);
  color: var(--schrift);
  font: inherit;
}
.formularfeld input:focus,
.formularfeld select:focus,
.formularfeld textarea:focus {
  outline: 2px solid var(--akzent);
  outline-offset: 1px;
}

.formularfeld input[type="checkbox"] { width: 1.1rem; height: 1.1rem; }
.formularfeld input[type="color"] { padding: 0.2rem; height: 2.3rem; }
.formularfeld textarea { resize: vertical; }

/* Gleich breite Kästchen über die ganze Feldbreite – siehe oben. */
.checkboxgruppe {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
  gap: 0.35rem 0.6rem;
}
.checkboxoption {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
  font-weight: 400;
  font-size: 0.88rem;
  color: var(--schrift);
}

.verweisfeld { position: relative; }
.verweisfeld .verweis-anzeige {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  background: var(--grund);
  color: var(--schrift);
  font: inherit;
}
.verweis-treffer {
  position: absolute;
  z-index: 5;
  top: 100%;
  left: 0;
  right: 0;
  margin: 0.2rem 0 0;
  padding: 0.25rem 0;
  max-height: 14rem;
  overflow-y: auto;
  list-style: none;
  background: var(--grund);
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}
.verweis-treffer li {
  padding: 0.4rem 0.65rem;
  font-size: 0.88rem;
  cursor: pointer;
}
.verweis-treffer li:hover { background: var(--flaeche); }

.dateiliste { margin: 0.4rem 0 0; padding: 0; list-style: none; font-size: 0.85rem; }
.dateiliste li { display: flex; align-items: center; gap: 0.6rem; padding: 0.2rem 0; }
.dateiliste a { color: var(--akzent); }
.dateiloeschen { margin: 0; }
.dateiloeschen button {
  padding: 0;
  border: 0;
  background: none;
  color: #b3435a;
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}
.dateiloeschen button:hover { text-decoration: underline; }

.formularaktionen {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.5rem;
}
.formularaktionen button {
  padding: 0.6rem 1.2rem;
  border: 1px solid var(--akzent);
  border-radius: var(--radius);
  background: var(--akzent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.formularaktionen button:hover { filter: brightness(1.08); }
.formularaktionen .abbrechen { color: var(--schrift-blass); font-size: 0.9rem; }

/* Eingebettete Unterlisten im Formular */
.unterliste { margin: 0.5rem 0 1rem; }
.unterliste table { font-size: 0.85rem; }
.verweisfeld .verweis-anzeige[readonly] {
  background: var(--flaeche);
  color: var(--schrift-blass);
  cursor: not-allowed;
}

/* Mehrfachverweis (Verknüpfungstabelle) */
.mehrfachverweis { position: relative; }
.mehrfachverweis .chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 0.4rem;
  padding: 0;
  list-style: none;
}
.mehrfachverweis .chips li {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.3rem 0.25rem 0.6rem;
  border-radius: 999px;
  background: var(--akzent-blass);
  color: var(--akzent);
  font-size: 0.82rem;
}
.chip-entfernen {
  padding: 0;
  width: 1.1rem;
  height: 1.1rem;
  border: 0;
  border-radius: 999px;
  background: none;
  color: inherit;
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
}
.chip-entfernen:hover { background: rgba(0, 0, 0, 0.08); }
.mehrfachverweis-suche {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  background: var(--grund);
  color: var(--schrift);
  font: inherit;
}

/* Eingaberaster für Messwerte */
.raster { margin: 0.5rem 0 1.25rem; }

.rastertabelle { font-size: 0.85rem; }
.rastertabelle thead th {
  padding: 0.4rem 0.5rem;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}
.rastertabelle tbody td {
  padding: 0.15rem 0.3rem;
  vertical-align: middle;
}
.rastertabelle tbody tr:hover { background: transparent; }

.raster-nr {
  width: 2.2rem;
  text-align: right;
  color: var(--schrift-blass);
  font-variant-numeric: tabular-nums;
  font-size: 0.8rem;
}
.raster-aktion { width: 2rem; text-align: center; }

/* Abgeleitete Spalten: sichtbar, aber erkennbar nicht bearbeitbar */
th.raster-abgeleitet { color: var(--schrift-blass); font-style: italic; }
td.raster-abgeleitet {
  background: var(--flaeche);
  color: var(--schrift-blass);
  text-align: center;
  white-space: nowrap;
}
.raster-haken { font-weight: 700; }

.rastertabelle input[type="text"],
.rastertabelle input[type="number"],
.rastertabelle input[type="date"],
.rastertabelle select {
  width: 100%;
  min-width: 6rem;
  padding: 0.3rem 0.4rem;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--schrift);
  font: inherit;
  font-size: 0.85rem;
}
.rastertabelle input:hover,
.rastertabelle select:hover { border-color: var(--linie); }
.rastertabelle input:focus,
.rastertabelle select:focus {
  outline: none;
  border-color: var(--akzent);
  background: var(--grund);
  box-shadow: 0 0 0 2px var(--akzent-blass);
}
.rastertabelle input[type="checkbox"] { width: 1.05rem; height: 1.05rem; }
.rastertabelle input[type="number"] { text-align: right; font-variant-numeric: tabular-nums; }

.raster-suche { position: relative; min-width: 9rem; }

.raster-loeschen {
  padding: 0 0.3rem;
  border: 0;
  background: none;
  color: var(--schrift-blass);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
}
.raster-loeschen:hover { color: #b3435a; background: var(--flaeche-stark); }

.raster-fuss {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.5rem;
}
.raster-neu {
  padding: 0.35rem 0.8rem;
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  background: var(--flaeche);
  color: var(--schrift);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.raster-neu:hover { background: var(--flaeche-stark); }

.raster-stand { font-size: 0.8rem; color: var(--schrift-blass); }
.raster-stand--ok { color: #2e7d4f; }
.raster-stand--fehler { color: #b3435a; font-weight: 600; }
.raster-hinweis {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
  color: var(--schrift-blass);
}

/* ==========================================================================
   Ninox-Optik: farbige Plaketten für Auswahlwerte
   Farben und Symbole stammen aus Ninox und kamen bei der Migration mit.
   ========================================================================== */

.plakette {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  margin: 0.1rem 0.15rem 0.1rem 0;
  border-radius: 999px;
  background: var(--flaeche-stark);
  color: var(--schrift);
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.45;
  white-space: nowrap;
}

/* Ja/Nein wie in Ninox: grüner Haken, blasses Kreuz */
.ja-nein { font-weight: 600; font-size: 0.82rem; }
.ja-nein.ja { color: #2e7d4f; }
.ja-nein.nein { color: var(--schrift-blass); font-weight: 400; }

/* --- Knöpfe -------------------------------------------------------------- */

.formularaktionen button,
.knopf-neu {
  border-radius: var(--radius);
  box-shadow: var(--schatten);
  transition: background-color 0.12s ease, box-shadow 0.12s ease;
}
.formularaktionen button:hover,
.knopf-neu:hover {
  background: var(--akzent-dunkel);
  border-color: var(--akzent-dunkel);
  filter: none;
}
.formularaktionen button:active,
.knopf-neu:active { box-shadow: none; }

.raster-neu { box-shadow: var(--schatten); transition: background-color 0.12s ease; }

/* --- Tabellen: ruhiger, mit klarer Kopfzeile ----------------------------- */

.tabellenrahmen {
  border-radius: var(--radius-gross);
  box-shadow: var(--schatten);
  background: var(--grund);
}
thead th {
  font-size: 0.78rem;
  letter-spacing: 0.01em;
  color: var(--schrift-blass);
  text-transform: none;
}
tbody tr:hover { background: var(--akzent-blass); }

/* --- Formular: jeder Abschnitt eine Karte -------------------------------- */

.abschnitt {
  padding: 0.9rem 1rem 1rem;
  border: 1px solid var(--linie);
  border-radius: var(--radius-gross);
  background: var(--grund);
  box-shadow: var(--schatten);
}

.formularfeld label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--schrift-blass);
}

.formularfeld input[type="text"],
.formularfeld input[type="email"],
.formularfeld input[type="tel"],
.formularfeld input[type="url"],
.formularfeld input[type="number"],
.formularfeld input[type="date"],
.formularfeld input[type="datetime-local"],
.formularfeld input[type="time"],
.formularfeld select,
.formularfeld textarea,
.verweisfeld .verweis-anzeige,
.mehrfachverweis-suche {
  border-radius: var(--radius);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.formularfeld input:focus,
.formularfeld select:focus,
.formularfeld textarea:focus,
.verweisfeld .verweis-anzeige:focus,
.mehrfachverweis-suche:focus {
  outline: none;
  border-color: var(--akzent);
  box-shadow: 0 0 0 3px var(--akzent-blass);
}

/* --- Kopfzeile ----------------------------------------------------------- */

.kopf {
  background: var(--grund);
  box-shadow: var(--schatten);
  border-bottom: 1px solid var(--linie);
}
.mandanten a {
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-size: 0.85rem;
}
.mandanten a.aktiv {
  background: var(--akzent);
  color: #fff;
}

/* ==========================================================================
   Ninox-Optik, zweiter Schritt: nach dem Vorbild der bestehenden Oberfläche
   ========================================================================== */

/* --- Kopfzeile und Titel ------------------------------------------------- */

.kopf {
  background: var(--navy);
  border-bottom: 0;
}
.marke { color: #fff; }
.marke span { color: var(--orange); }
.kontomenue { color: rgba(255, 255, 255, 0.75); }
.kontomenue a { color: #fff; }

.mandanten a {
  border-color: rgba(255, 255, 255, 0.25);
  color: rgba(255, 255, 255, 0.8);
}
.mandanten a:hover { background: rgba(255, 255, 255, 0.12); }
.mandanten a.aktiv {
  background: #fff;
  border-color: #fff;
  color: var(--navy);
  font-weight: 600;
}

/*
 * Seitentitel als durchgehender Balken – in Ninox trägt jede Maske so eine
 * Zeile, und daran erkennt man auf einen Blick, wo man ist.
 */
h1 {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 1rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius);
  background: var(--navy);
  color: #fff;
  font-size: 1.15rem;
  font-weight: 650;
}

h2 {
  margin: 1.75rem 0 0.6rem;
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius);
  background: var(--navy);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 650;
}
h2 .anzahl { background: rgba(255, 255, 255, 0.2); color: #fff; }

h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 1.25rem 0 0.5rem;
  font-size: 0.95rem;
  color: var(--navy);
}

/* --- Aktionen: orange wie gewohnt ---------------------------------------- */

.knopf-neu,
.formularaktionen button,
.suchleiste button {
  background: var(--orange);
  border-color: var(--orange);
  color: #3a2a08;
  font-weight: 650;
}
.knopf-neu:hover,
.formularaktionen button:hover,
.suchleiste button:hover {
  background: var(--orange-dunkel);
  border-color: var(--orange-dunkel);
}

/* --- Tabellen: dunkler Kopf, kompakte Zeilen ----------------------------- */

thead th {
  background: var(--navy);
  color: #fff;
  border-bottom: 0;
  font-weight: 650;
  font-size: 0.8rem;
  white-space: normal;         /* lange Messgrössen dürfen umbrechen */
  vertical-align: bottom;
}
tbody td { vertical-align: middle; }
tbody tr:hover { background: var(--akzent-blass); }

/*
 * Sortierpfeile im Tabellenkopf.
 *
 * Zwei Dreiecke am rechten Rand der Überschrift, nebeneinander und über die
 * ganze Höhe der Kopfzeile – so ist die Schaltfläche gross genug für einen
 * Finger. Links sortiert aufsteigend, rechts absteigend. Es sind gewöhnliche
 * Verweise: die Liste kommt sortiert vom Server, das arbeitet also auch ohne
 * JavaScript und lässt sich als Adresse weitergeben.
 */
th.sortierbar {
  position: relative;
  padding-right: 2.8rem;
}

.sortierpfeile {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: stretch;
  font-size: 0.66rem;
}
.sortierpfeile .pfeil {
  display: flex;
  align-items: center;
  padding: 0 0.32rem;
  color: rgba(255, 255, 255, 0.42);
  text-decoration: none;
  transition: color 0.12s ease, background-color 0.12s ease;
}
.sortierpfeile .pfeil:last-child { padding-right: 0.55rem; }
.sortierpfeile .pfeil:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}
.sortierpfeile .pfeil.gewaehlt { color: var(--orange); }

/* Umschalter Arbeits-/Admin-Ansicht im Kopf. */
.ansichtsknopf {
  padding: 0.2rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  white-space: nowrap;
}
.ansichtsknopf:hover { background: rgba(255, 255, 255, 0.28); }
.ansichtsknopf.aktiv {
  background: var(--orange);
  border-color: var(--orange);
  color: #3a2a08;
}

/* --- Dashboard ----------------------------------------------------------- */

.dashboard-block { margin-bottom: 2rem; }

.kacheln {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0.9rem;
  max-width: 42rem;
  margin-bottom: 1.1rem;
}
.kachel {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.9rem 1rem;
  text-decoration: none;
  color: var(--schrift);
  background: var(--grund);
  border: 1px solid var(--linie);
  border-left: 4px solid var(--navy);
  border-radius: var(--radius-gross);
  box-shadow: var(--schatten);
}
.kachel:hover { background: var(--flaeche); }
.kachel--gut { border-left-color: var(--gut); }
.kachel--schlecht { border-left-color: var(--schlecht); }
.kachel-zahl { font-size: 1.9rem; font-weight: 700; line-height: 1.1; }
.kachel-text { font-size: 0.82rem; color: var(--schrift-blass); }

.rollen { white-space: nowrap; }
tr.ueberfaellig .faellig { color: var(--schlecht); font-weight: 600; }

/* Ein Klick irgendwo in die Zeile öffnet den Datensatz. */
tr.anklickbar { cursor: pointer; }
tr.anklickbar:focus-visible { outline: 2px solid var(--orange); outline-offset: -2px; }

/*
 * Filterzeile unter den Spaltenüberschriften.
 *
 * Die Bedienelemente gehören zum Suchformular über der Tabelle (form-Attribut)
 * – ein <form> innerhalb einer Tabelle wäre kein gültiges HTML und würde vom
 * Browser aus der Zeile herausgeschoben.
 */
.filterzeile th {
  position: static;
  background: var(--navy-hell);
  padding: 0.3rem 0.5rem 0.45rem;
  font-weight: 400;
}

.filterzeile input,
.filterzeile summary {
  width: 100%;
  min-width: 5.5rem;
  font: inherit;
  font-size: 0.78rem;
  padding: 0.22rem 0.4rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  color: var(--schrift);
}
.filterzeile input:focus,
.filterzeile summary:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 1px;
}

.filter-bereich {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.filter-bereich .bis { color: rgba(255, 255, 255, 0.6); }

/* Datumsfilter: ein Feld, davor ob "ab" oder "bis" gemeint ist. */
.filter-datum { display: flex; align-items: center; gap: 0.3rem; }
.filter-datum .wort {
  flex: none;
  font-size: 0.7rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
}

/* Anhak-Liste: eingeklappt ein Feld, aufgeklappt die Werte darunter. */
.filterfeld { position: relative; }
.filterfeld > summary {
  display: block;
  cursor: pointer;
  list-style: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.filterfeld > summary::-webkit-details-marker { display: none; }
.filterfeld > summary::after {
  content: "▾";
  float: right;
  margin-left: 0.3rem;
  color: var(--schrift-blass);
}
.filterfeld.gesetzt > summary {
  background: var(--orange);
  color: #3a2a08;
  font-weight: 600;
}

.filter-liste {
  margin-top: 0.25rem;
  padding: 0.35rem;
  max-height: 15rem;
  overflow-y: auto;
  background: var(--grund);
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  box-shadow: var(--schatten);
  min-width: 11rem;
}
/* Mit JavaScript schwebt die Liste über der Tabelle statt die Zeile zu dehnen. */
.filter-liste.schwebend { position: fixed; z-index: 1000; margin-top: 0; }

.filter-liste label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.16rem 0.2rem;
  font-size: 0.8rem;
  color: var(--schrift);
  white-space: nowrap;
  cursor: pointer;
  border-radius: 4px;
}
.filter-liste label:hover { background: var(--flaeche); }
.filter-liste input[type="checkbox"] { width: auto; min-width: 0; margin: 0; }

.filter-schnellwahl {
  display: flex;
  gap: 0.3rem;
  padding-bottom: 0.35rem;
  margin-bottom: 0.3rem;
  border-bottom: 1px solid var(--linie);
}
.filter-schnellwahl button {
  flex: 1;
  padding: 0.18rem 0.3rem;
  font: inherit;
  font-size: 0.72rem;
  white-space: nowrap;
  color: var(--akzent);
  background: none;
  border: 1px solid var(--linie);
  border-radius: 4px;
  cursor: pointer;
}
.filter-schnellwahl button:hover { background: var(--akzent-blass); }

.ohne-treffer td {
  padding: 1.25rem 0.75rem;
  color: var(--schrift-blass);
  text-align: center;
}

/* --- Formularfelder: gefüllt statt umrandet ------------------------------ */

.formularfeld input[type="text"],
.formularfeld input[type="email"],
.formularfeld input[type="tel"],
.formularfeld input[type="url"],
.formularfeld input[type="number"],
.formularfeld input[type="date"],
.formularfeld input[type="datetime-local"],
.formularfeld input[type="time"],
.formularfeld select,
.formularfeld textarea,
.verweisfeld .verweis-anzeige,
.mehrfachverweis-suche,
.suchleiste input[type="search"] {
  border-color: transparent;
  background: var(--feld);
}
.formularfeld input:hover,
.formularfeld select:hover,
.formularfeld textarea:hover { border-color: var(--linie); }

/* --- Raster: Prüfergebnis als Zeichen, Zahlen mit Komma ------------------ */

.raster-haken { font-size: 1rem; font-weight: 700; }
.raster-haken[data-wert="ja"] { color: var(--gut); }
.raster-haken[data-wert="nein"] { color: var(--schlecht); }

.rastertabelle thead th {
  background: var(--navy);
  color: #fff;
  font-size: 0.75rem;
}
td.raster-abgeleitet { background: transparent; }
.rastertabelle tbody td { border-bottom: 1px solid var(--linie); }

/* Auswahllisten im Raster: gefüllt, Platzhalter blass – wie in Ninox */
.rastertabelle select { background: var(--grund); }
.rastertabelle select:has(option[value=""]:checked) { color: var(--schrift-blass); }
