:root {
  --text: #262626;
  --grau: #7F7F7F;
  --hell: #F2F2F2;
  --linie: #BFBFBF;
  --akzent: #595959;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.4 Arial, Helvetica, sans-serif;
  color: var(--text);
  background: #E9E9E9;
}

/* ---- Kopfleiste ---- */
.leiste {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 20px;
  background: #fff;
  border-bottom: 1px solid var(--linie);
  box-shadow: 0 1px 6px rgba(0,0,0,.06);
}
.leiste img { height: 30px; }
.leiste .titel { font-weight: bold; letter-spacing: .1em; text-transform: uppercase; font-size: 12px; color: var(--grau); }
.leiste .status { font-size: 12px; color: var(--grau); }
.leiste .aktionen { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

button {
  font: inherit; font-size: 14px; font-weight: bold;
  padding: 8px 14px; border-radius: 4px; cursor: pointer;
  border: 1px solid var(--akzent); background: var(--akzent); color: #fff;
}
button:hover { background: var(--text); }
button.neben { background: #fff; color: var(--text); border-color: var(--linie); font-weight: normal; }
button.neben:hover { background: var(--hell); }
button.gefahr { background: #fff; color: #A33; border-color: #E0B4B4; font-weight: normal; }
button:disabled { opacity: .5; cursor: wait; }

/* ---- Ansichten: Startseite, Neuer Bericht, Einlesen ---- */
.ansicht[hidden] { display: none !important; }
body:not([data-ansicht="bericht"]) .leiste .aktionen { display: none; }
.leiste a.heim { display: flex; }

.seite { max-width: 920px; margin: 48px auto 80px; padding: 0 16px; }
.seite.breit { margin-top: 24px; }
.seite h1 { font-size: 28px; margin: 0 0 28px; letter-spacing: .01em; }
.kacheln { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.kacheln.zwei { grid-template-columns: repeat(2, 1fr); }
.kachel {
  position: relative; display: flex; flex-direction: column; gap: 8px; text-align: left;
  padding: 22px 22px 26px; min-height: 150px; border-radius: 8px;
  background: #fff; color: var(--text); border: 1px solid var(--linie); text-decoration: none;
  box-shadow: 0 1px 3px rgba(0,0,0,.08); font: inherit; cursor: pointer;
}
.kachel:hover { background: #fff; border-color: var(--akzent); box-shadow: 0 3px 12px rgba(0,0,0,.12); }
.kachel strong { font-size: 18px; }
.kachel span { font-size: 14px; color: #595959; line-height: 1.45; font-weight: normal; }
.kachel .bald {
  position: absolute; top: 12px; right: 12px; font-style: normal; font-size: 11px; color: var(--grau);
  border: 1px solid var(--linie); border-radius: 10px; padding: 2px 8px; text-transform: uppercase; letter-spacing: .05em;
}
.start-weiter { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 24px; }
a.knopf { display: inline-block; padding: 8px 14px; border-radius: 4px; border: 1px solid var(--linie); text-decoration: none; color: var(--text); font-size: 14px; background: #fff; }
a.knopf:hover { background: var(--hell); }
a.knopf[hidden] { display: none; }
.zurueck { display: inline-block; margin-top: 22px; color: var(--grau); text-decoration: none; font-size: 14px; }
.zurueck:hover { color: var(--text); }
.platzhalter { color: var(--grau); font-size: 15px; }
.knopfleiste { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.knopfleiste .zurueck { margin: 0 auto 0 0; }
.knopfleiste button:only-child { margin-left: auto; }
#btnScreenshot { margin-right: auto; }

#einlesenText { margin-top: 12px; }
.quellen { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.quellen li { border: 1px solid #DDD; border-radius: 4px; padding: 6px 10px; background: #FAFAFA; }
.quelle-kopf { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.quelle-kopf strong { overflow-wrap: anywhere; }
.quelle-kopf .info { color: var(--grau); font-size: 12px; }
.quelle-kopf .fehler { color: #A33; font-size: 12px; }
.quelle-kopf button { margin-left: auto; padding: 3px 9px; font-size: 12px; }
.quellen summary, .unterlagen summary { cursor: pointer; font-size: 12px; color: var(--grau); margin-top: 4px; }
.quellen pre, .unterlagen pre {
  white-space: pre-wrap; font: 12px/1.45 Menlo, Consolas, monospace; max-height: 260px; overflow: auto;
  background: #fff; border: 1px solid #E4E4E4; border-radius: 4px; padding: 8px; margin: 6px 0 4px;
}
.hinweis.klein { font-size: 13px; margin-bottom: 12px; }

label.erkannt-label { flex-direction: row; align-items: flex-start; gap: 8px; cursor: pointer; }
label.erkannt-label input { margin: 1px 0 0; accent-color: var(--text); }
.zeile.erkannt select { width: 100%; font: inherit; padding: 7px 9px; border: 1px solid #D5D5D5; border-radius: 4px; background: #fff; }
.zeile.erkannt:has(.erkannt-label input:not(:checked)) .wert { opacity: .45; }
.herkunft { font-size: 12px; color: var(--grau); margin-top: 5px; display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.herkunft .weitere-titel { margin-left: 0; font-weight: bold; }
button.vorschlag { padding: 2px 8px; font-size: 12px; font-weight: normal; background: #fff; color: var(--text); border-color: var(--linie); border-radius: 10px; }
button.vorschlag:hover { background: var(--hell); }

.unterlagen > summary { font-size: 14px; font-weight: bold; color: var(--text); margin: 0; }
.unterlagen-inhalt { margin-top: 8px; }

/* ---- Stammdaten ---- */
.benutzer-form { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 12px; align-items: end; }
.benutzer-knoepfe { display: flex; gap: 8px; }
.benutzer-tabelle { width: 100%; border-collapse: collapse; font-size: 14px; }
.benutzer-tabelle th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--grau);
  background: var(--hell); padding: 8px 10px; border-bottom: 1px solid var(--linie);
}
.benutzer-tabelle td { padding: 8px 10px; border-bottom: 1px solid var(--linie); }
.benutzer-tabelle td.knoepfe { text-align: right; white-space: nowrap; }
.benutzer-tabelle td.knoepfe button { padding: 3px 9px; font-size: 12px; margin-left: 6px; }
.benutzer-tabelle[hidden] { display: none; }
.speicherort-text { margin-top: 14px; }
#speicherortName { font-weight: bold; }
/* Techniker vor Ort: ein Feld zum Eintippen oder Auswählen */
.kombi { position: relative; }
.kombi input { padding-right: 38px; }
button.kombi-pfeil {
  position: absolute; top: 1px; right: 1px; bottom: 1px; width: 34px; padding: 0;
  border: 0; border-left: 1px solid #E4E4E4; border-radius: 0 4px 4px 0;
  background: #fff; color: var(--grau); font-size: 15px; font-weight: normal;
}
button.kombi-pfeil:hover { background: var(--hell); color: var(--text); }
.kombi-liste {
  position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 2px); max-height: 260px; overflow: auto;
  list-style: none; margin: 0; padding: 4px 0; background: #fff; border: 1px solid var(--linie); border-radius: 4px;
  box-shadow: 0 4px 14px rgba(0,0,0,.12);
}
.kombi-liste[hidden] { display: none; }
.kombi-liste li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 10px; font-size: 14px; cursor: pointer; }
.kombi-liste li:hover, .kombi-liste li.an { background: var(--hell); }
.kombi-liste li .tel { color: var(--grau); }
.kombi-liste li.leer { color: var(--grau); cursor: default; }

/* ---- Berichtsübersicht ---- */
.uebersicht-kopf { display: flex; gap: 10px; margin-bottom: 12px; }
.uebersicht-kopf input[type=search] {
  flex: 1; font: inherit; color: var(--text); padding: 7px 9px; border: 1px solid #D5D5D5; border-radius: 4px; background: #fff;
}
.tabelle-rahmen { overflow-x: auto; }
.uebersicht-tabelle { width: 100%; border-collapse: collapse; font-size: 14px; }
.uebersicht-tabelle[hidden] { display: none; }
.uebersicht-tabelle th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--grau); white-space: nowrap;
  background: var(--hell); padding: 8px 10px; border-bottom: 1px solid var(--linie); cursor: pointer; user-select: none;
}
.uebersicht-tabelle th:hover { color: var(--text); }
.uebersicht-tabelle th.sortiert { color: var(--text); }
.uebersicht-tabelle th.sortiert::after { content: ' ▲'; font-size: 9px; }
.uebersicht-tabelle th.sortiert.ab::after { content: ' ▼'; }
.uebersicht-tabelle td { padding: 9px 10px; border-bottom: 1px solid var(--linie); vertical-align: top; }
.uebersicht-tabelle td:first-child { font-weight: bold; white-space: nowrap; }
.uebersicht-tabelle td:nth-child(2) { white-space: nowrap; }
.uebersicht-tabelle tbody tr { cursor: pointer; }
.uebersicht-tabelle tbody tr:hover, .uebersicht-tabelle tbody tr:focus { background: var(--hell); outline: none; }
.knopfleiste:has(> [hidden]:only-child) { display: none; }

/* ---- Formular ---- */
main { max-width: 920px; margin: 24px auto 80px; padding: 0 16px; }

.karte {
  background: #fff; border-radius: 6px; padding: 18px 22px 22px; margin-bottom: 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.karte h2 {
  margin: 0 0 14px; padding-bottom: 6px; font-size: 19px;
  border-bottom: 2px solid var(--text);
}
.karte h2 .nr { color: var(--grau); font-size: 15px; margin-right: 12px; letter-spacing: .1em; }

.raster { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 18px; }

.zeile {
  display: grid; grid-template-columns: 220px 1fr; align-items: start;
  border-bottom: 1px solid var(--linie);
}
.zeile:first-of-type { border-top: 1px solid var(--linie); }
.zeile > .label, label {
  font-size: 11px; font-weight: bold; text-transform: uppercase; letter-spacing: .06em; color: var(--grau);
}
.zeile > .label { background: var(--hell); padding: 13px 12px; align-self: stretch; }
.zeile > .wert { padding: 7px 10px; }
.zeile > .wert.fest { padding: 12px; font-size: 14px; }

label { display: flex; flex-direction: column; gap: 5px; }

input[type=text], input[type=tel], input[type=email], input[type=date], input[type=time], textarea {
  width: 100%; font: inherit; color: var(--text);
  padding: 7px 9px; border: 1px solid #D5D5D5; border-radius: 4px; background: #fff;
}
input:focus, textarea:focus { outline: 2px solid #8C8C8C; outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; min-height: 60px; }
::placeholder { color: #A6A6A6; }

.optionen { display: flex; flex-wrap: wrap; gap: 6px 8px; padding: 2px 0; }
.optionen label {
  flex-direction: row; align-items: center; gap: 7px;
  font-size: 14px; font-weight: normal; text-transform: none; letter-spacing: 0; color: var(--text);
  padding: 6px 11px; border: 1px solid #D5D5D5; border-radius: 4px; cursor: pointer; user-select: none;
}
.optionen label:has(input:checked) { background: var(--akzent); border-color: var(--akzent); color: #fff; }
.optionen input { margin: 0; accent-color: var(--text); }

.hinweis { color: #404040; font-size: 14px; line-height: 1.6; margin: 0; }

/* Adresse: Straße, Land, PLZ, Ort */
.adresse { display: grid; grid-template-columns: 3fr 1.4fr 0.8fr 1.6fr; gap: 8px; }
.adresse label.klein { font-size: 10px; gap: 3px; min-width: 0; }
.adresse input { font-size: 15px; font-weight: normal; letter-spacing: 0; text-transform: none; }

/* ---- Fotos: je Zeile zwei Fotos, Text unter dem Foto ---- */
.fotobereich { padding: 4px 0; }
.fotobereich > .label { display: none; }
.fotos { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.foto {
  display: flex; flex-direction: column; gap: 8px; padding: 10px; min-width: 0;
  border: 1px solid #DDD; border-radius: 6px; background: #FAFAFA;
}
.foto-platz {
  aspect-ratio: 7.8 / 5.1; display: flex; align-items: center; justify-content: center;
  background: #F0F0F0; border: 1px dashed #D5D5D5; border-radius: 4px; overflow: hidden;
}
.foto-platz img { display: block; }
.foto-info { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.foto-einheit {
  width: 100%; font: inherit; font-size: 14px; font-weight: bold; color: var(--text);
  padding: 6px 8px; border: 1px solid #D5D5D5; border-radius: 4px; background: #fff;
}
.foto-nr { font-size: 12px; font-weight: bold; color: var(--grau); }
.foto-info textarea { flex: 1; min-height: 80px; }
label.foto-skala { gap: 2px; font-size: 10px; }
.foto-skala input { width: 100%; margin: 0; accent-color: var(--akzent); }
.foto-knoepfe { display: flex; gap: 6px; flex-wrap: wrap; }
.foto-knoepfe button { padding: 4px 9px; font-size: 12px; background: #fff; color: var(--text); border-color: var(--linie); font-weight: normal; }
.foto-knoepfe .gefahr { margin-left: auto; color: #A33; }
.foto-knoepfe [data-aktion="markieren"] { font-weight: bold; }

/* Hinweis neben den Optionen (z. B. Einheit mit lokalisierter Leckage) */
.optionen .zusatz { align-self: center; font-size: 13px; font-weight: bold; color: var(--text); margin-left: 6px; }
.optionen .zusatz:empty { display: none; }
.zeile[hidden] { display: none; }

button.ordner { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ablage {
  margin-top: 12px; padding: 18px; text-align: center; color: var(--grau); font-size: 14px;
  border: 2px dashed #CCC; border-radius: 6px; cursor: pointer;
}
.ablage.aktiv, .ablage:hover { border-color: var(--akzent); color: var(--text); background: var(--hell); }

/* ---- Überprüfungseinheiten ---- */
.einheit { border: 1px solid #D5D5D5; border-radius: 6px; padding: 0 0 4px; margin-bottom: 14px; overflow: hidden; }
.einheit .zeile:first-of-type { border-top: 0; }
.einheit .zeile:last-child { border-bottom: 0; }
.einheit-kopf {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; background: #E4E4E4; border-bottom: 1px solid var(--linie);
}
.einheit-kopf button { padding: 4px 10px; font-size: 12px; }
button.weitere { width: 100%; padding: 12px; border-style: dashed; border-width: 2px; color: var(--grau); }
button.weitere:hover { color: var(--text); border-color: var(--akzent); }

.schalterliste { display: grid; grid-template-columns: 1fr; gap: 6px; padding: 2px 0; align-items: start; }
.schalterliste.zwei { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.schalterliste.drei { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.schalter { border: 1px solid #D5D5D5; border-radius: 4px; }
.schalter:has(> .schalter-titel input:checked) { border-color: var(--akzent); }
label.schalter-titel {
  flex-direction: row; align-items: center; gap: 8px; padding: 7px 10px; cursor: pointer; user-select: none;
  font-size: 14px; font-weight: normal; text-transform: none; letter-spacing: 0; color: var(--text);
}
.schalter-titel input { margin: 0; width: 16px; height: 16px; accent-color: var(--text); }
.schalter:has(> .schalter-titel input:checked) > .schalter-titel { background: var(--akzent); color: #fff; font-weight: bold; }
.schalter .details { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 10px 10px; }
.schalter .details[hidden] { display: none; }
.schalter .details label.klein { flex: 1 1 80px; font-size: 10px; min-width: 0; }
.schalter .details label.klein.breit { flex: 1 1 100%; }
.schalter .details input { width: 100%; min-width: 0; font-size: 14px; font-weight: normal; letter-spacing: 0; text-transform: none; }
.schalter .details .trenner {
  flex: 1 1 100%; margin-top: 4px; padding-top: 8px; border-top: 1px solid #E0E0E0;
  font-size: 10px; font-weight: bold; text-transform: uppercase; letter-spacing: .05em; color: var(--grau);
}

/* ---- Foto markieren ---- */
body.dialog-offen { overflow: hidden; }
.markierer {
  position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column;
  background: rgba(20,20,20,.92);
}
.markierer[hidden] { display: none; }
.markierer-leiste {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px;
  padding: 10px 14px; background: #fff; border-bottom: 1px solid var(--linie);
}
.markierer-titel { font-size: 14px; }
.markierer .gruppe { display: flex; gap: 4px; flex-wrap: wrap; }
.markierer .gruppe.rechts { margin-left: auto; }
.markierer-leiste button { padding: 6px 10px; font-size: 13px; }
.markierer-leiste [data-werkzeug], .markierer-leiste [data-staerke], .markierer-leiste [data-m="zurueck"],
.markierer-leiste [data-m="links"], .markierer-leiste [data-m="rechts"] {
  background: #fff; color: var(--text); border-color: var(--linie); font-weight: normal;
}
.markierer-leiste [data-werkzeug].an, .markierer-leiste [data-staerke].an { background: var(--akzent); border-color: var(--akzent); color: #fff; }
.markierer .farben button { width: 30px; height: 30px; padding: 0; border: 2px solid #BBB; border-radius: 50%; }
.markierer .farben button.an { outline: 3px solid var(--text); outline-offset: 1px; }
.markierer-flaeche { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 12px; }
.markierer-flaeche canvas {
  max-width: 100%; max-height: 100%; touch-action: none; cursor: crosshair;
  box-shadow: 0 2px 16px rgba(0,0,0,.5); background: #fff;
}
.markierer-flaeche canvas.zuschneiden { cursor: cell; }

/* ---- PDF anzeigen ---- */
.pdf-ansicht iframe { flex: 1; width: 100%; border: 0; background: #525659; }
.pdf-ansicht a.knopf { padding: 6px 10px; font-size: 13px; }

/* ---- Einsatz: Status, zuweisen, abschließen (js/einsatz.js) ---- */
.einsatz { display: flex; align-items: center; gap: 10px 16px; flex-wrap: wrap; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--hell); }
.einsatz-status { font-size: 14px; }
.einsatz-status .klein { color: var(--grau); margin-left: 6px; }
.einsatz-knoepfe { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.einsatz-knoepfe select { font: inherit; font-size: 14px; padding: 7px 8px; border: 1px solid var(--linie); border-radius: 4px; background: #fff; }
.einsatz [hidden] { display: none !important; }
[data-status] { white-space: nowrap; }
[data-status="Zugewiesen"] { color: #8A5A00; }
[data-status="In Bearbeitung"] { color: #0B5CAD; }
[data-status="Fertig"] { color: #1E7B34; }

/* iPad: Bericht sichern über das Teilen-Fenster */
.teilen { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(0,0,0,.45); }
.teilen[hidden] { display: none; }
.teilen-box { width: min(520px, 100%); background: #fff; border-radius: 8px; padding: 20px 22px; box-shadow: 0 8px 30px rgba(0,0,0,.25); }
.teilen-box h2 { margin: 0 0 10px; font-size: 20px; }
.teilen-box ol { padding-left: 20px; margin: 0 0 10px; line-height: 1.6; }
.teilen-box .klein { color: var(--grau); font-size: 13px; word-break: break-all; }
.teilen-box .knopfleiste button:first-child { margin-right: auto; }

/* ---- iPad-App für Techniker (js/techniker.js) ---- */
body:not(.app) .nur-app, body.app .nicht-app { display: none !important; }
.einsaetze-kopf { display: flex; align-items: flex-end; gap: 10px; margin-bottom: 12px; }
.einsaetze-kopf label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--grau); }
.einsaetze-kopf select { font: inherit; font-size: 16px; padding: 8px; min-width: 240px; border: 1px solid var(--linie); border-radius: 4px; background: #fff; }
.einsaetze-kopf button { margin-left: auto; }
.einsaetze-liste { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.einsaetze-liste li {
  display: grid; grid-template-columns: 110px 1fr auto; gap: 4px 14px; align-items: center; cursor: pointer;
  padding: 12px 14px; border: 1px solid var(--linie); border-radius: 6px; background: #fff;
}
.einsaetze-liste li:active, .einsaetze-liste li:hover { background: var(--hell); }
.einsaetze-liste .datum { font-weight: bold; }
.einsaetze-liste .ort { font-size: 16px; }
.einsaetze-liste .klein { grid-column: 2; color: var(--grau); font-size: 13px; }
.einsaetze-liste [data-status] { grid-row: 1 / span 2; grid-column: 3; font-weight: bold; font-size: 14px; }
.einsaetze-liste li.fertig { opacity: .6; }
#einsaetzeOrdner { margin-right: auto; }

/* Dropbox: Code einfügen, Ordner wählen (js/dropbox.js) */
.dropbox-inhalt input[type=text] { width: 100%; font: inherit; padding: 8px; border: 1px solid var(--linie); border-radius: 4px; }
.dropbox-inhalt ol { padding-left: 20px; line-height: 1.6; }
.dropbox-ordner { list-style: none; margin: 8px 0 0; padding: 0; max-height: 50vh; overflow: auto; border: 1px solid var(--linie); border-radius: 4px; }
.dropbox-ordner li { padding: 9px 12px; border-bottom: 1px solid var(--hell); cursor: pointer; }
.dropbox-ordner li:hover { background: var(--hell); }
.dropbox-ordner li.leer { color: var(--grau); cursor: default; }
.dropbox-ordner li.hoch { color: var(--grau); }
.dropbox-knoepfe button:first-child { margin-right: auto; }

/* Bedienung mit dem Finger (iPad): größere Knöpfe */
@media (pointer: coarse) {
  button, a.knopf, .einsatz-knoepfe select { min-height: 44px; }
}

@media (max-width: 700px) {
  .zeile { grid-template-columns: 1fr; }
  .zeile > .label { padding: 8px 10px; }
  .fotos, .raster, .kacheln, .kacheln.zwei, .benutzer-form, .schalterliste.zwei, .schalterliste.drei { grid-template-columns: 1fr; }
  .adresse { grid-template-columns: 1fr 1fr; }
  .adresse label.strasse { grid-column: 1 / -1; }
  .seite { margin-top: 24px; }
}
