/*
 * Bedienung mit Arbeitshandschuhen auf einem Handy im Technikraum:
 * große Flächen, hoher Kontrast, keine Hover-Abhängigkeiten.
 */
:root {
  --teal: #0f8a9c;
  --teal-d: #0b6d7c;
  --grau: #f2f5f6;
  --rand: #d4dcde;
  --text: #1c2429;
  --gedimmt: #5d6b70;
  --gut: #1a9c5b;
  --fehler: #d0342c;
  --warn: #b26a00;
}

* { box-sizing: border-box; }

/*
 * Muss vor allen Layoutregeln stehen und !important tragen: Klassen wie
 * .anmeldung setzen display:flex und schlagen sonst die Browserregel für
 * [hidden]. Die Anmeldemaske bliebe dann sichtbar, obwohl der Monteur längst
 * angemeldet ist.
 */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  color: var(--text);
  background: var(--grau);
  -webkit-text-size-adjust: 100%;
}

main {
  max-width: 820px;
  margin: 0 auto;
  padding: 12px 12px 90px;
}

h1 { font-size: 20px; margin: 14px 2px; }
h2 { font-size: 15px; margin: 0; text-transform: uppercase; letter-spacing: .4px; color: var(--teal-d); }
h3.gruppe {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--teal-d);
  background: #eef2f4;
  margin: 14px -14px 8px;
  padding: 8px 14px;
}

/* ---------------------------------------------------------------- Kopfleiste */

.kopf {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #fff;
  border-bottom: 1px solid var(--rand);
  padding: env(safe-area-inset-top) 10px 8px;
}
.kopfzeile { display: flex; align-items: center; gap: 8px; padding-top: 8px; }
.kopfzeile strong { font-size: 15px; }
.wachsen { flex: 1; }
.benutzer { font-size: 13px; color: var(--gedimmt); }
.kopfnav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.verbindung { font-size: 11px; padding: 2px 7px; border-radius: 9px; background: #e8eced; color: var(--gedimmt); }
.verbindung.gut { background: #e3f5ea; color: var(--gut); }
.verbindung.schlecht { background: #fdeceb; color: var(--fehler); }

.auswahl {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  padding: 10px;
  border: 1px solid var(--rand);
  border-radius: 8px;
  background: #fff;
}
.auswahl.schmal { flex: 0 0 auto; max-width: 42%; }

/* ---------------------------------------------------------------- Abschnitte */

.abschnitt {
  background: #fff;
  border: 1px solid var(--rand);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
}
.abschnittkopf { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.abschnitt > h2 { margin-bottom: 10px; }
.werkzeuge { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.zaehler { font-size: 13px; color: var(--gedimmt); margin-left: auto; }

.felder { display: flex; flex-wrap: wrap; gap: 10px; }
.feld { flex: 1 1 100%; display: flex; flex-direction: column; gap: 4px; }
.feld.halb { flex: 1 1 calc(50% - 5px); min-width: 150px; }
.feld label { font-size: 12px; color: var(--gedimmt); }
.stern { color: var(--fehler); }

input, textarea, select {
  font: inherit;
  font-size: 16px; /* verhindert das Zoomen auf iOS */
  padding: 10px;
  border: 1px solid var(--rand);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  width: 100%;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--teal); outline-offset: -1px; }
textarea { resize: vertical; }

.blockzeile { display: flex; gap: 8px; margin-bottom: 8px; }
.blockzeile .feld { flex: 1; }

/* --------------------------------------------------------------- Positionen */

.position { border-top: 1px solid var(--rand); padding: 10px 0; }
.position:first-child { border-top: 0; }
.position.gesetzt { background: #fafcfc; }
.pkopf { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.pnr {
  flex: 0 0 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--grau);
  color: var(--gedimmt);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pname { flex: 1; font-size: 15px; }
.freitext { font-size: 15px; padding: 7px 9px; }

.bewertungen { display: flex; gap: 6px; flex-wrap: wrap; }
.bewertung {
  flex: 1 1 auto;
  min-height: 44px;
  min-width: 74px;
  padding: 8px 10px;
  font: inherit;
  font-size: 14px;
  border: 1.5px solid var(--rand);
  border-radius: 8px;
  background: #fff;
  color: var(--gedimmt);
  cursor: pointer;
}
.bewertung.aktiv {
  background: var(--farbe);
  border-color: var(--farbe);
  color: #fff;
  font-weight: 600;
}

.zusatz { display: none; gap: 6px; margin-top: 8px; }
.zusatz.sichtbar { display: flex; }
.zusatz input { font-size: 15px; padding: 8px 9px; }

.weg {
  flex: 0 0 32px;
  height: 32px;
  border: 0;
  border-radius: 6px;
  background: #fdeceb;
  color: var(--fehler);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

/* -------------------------------------------------------------------- Fotos */

.fotoliste { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-bottom: 10px; }
.foto { position: relative; border: 1px solid var(--rand); border-radius: 8px; overflow: hidden; background: #fff; }
.foto img { width: 100%; height: 110px; object-fit: cover; display: block; }
.foto input { border: 0; border-top: 1px solid var(--rand); border-radius: 0; font-size: 13px; padding: 7px 8px; }
.foto .weg { position: absolute; top: 6px; right: 6px; background: rgba(255,255,255,.92); }

canvas#unterschrift {
  width: 100%;
  border: 1px dashed var(--rand);
  border-radius: 8px;
  background: #fff;
  touch-action: none;
}

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

.knopf {
  font: inherit;
  font-size: 15px;
  padding: 11px 16px;
  min-height: 44px;
  border: 1px solid var(--rand);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}
.knopf.klein { font-size: 13px; padding: 7px 11px; min-height: 36px; }
.knopf.winzig { font-size: 12px; padding: 5px 9px; min-height: 30px; }
.knopf.gross { background: var(--teal); border-color: var(--teal); color: #fff; font-weight: 600; flex: 1; }
.knopf.gefahr { color: var(--fehler); border-color: #f0c4c1; }

.aktionen {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,.96);
  border-top: 1px solid var(--rand);
  backdrop-filter: blur(6px);
}

.gesperrt { opacity: .62; pointer-events: none; }

/* ---------------------------------------------------------------- Meldungen */

.hinweis {
  background: #fff;
  border: 1px solid var(--rand);
  border-radius: 10px;
  padding: 14px;
  color: var(--gedimmt);
  font-size: 14px;
  line-height: 1.5;
}
.hinweis.warnung { border-color: #f0d9b0; background: #fdf6e9; color: var(--warn); }
.fehlertext { color: var(--fehler); font-size: 13px; min-height: 18px; margin: 4px 0 0; }

.meldung {
  position: fixed;
  left: 50%;
  top: 14px;
  transform: translate(-50%, -140%);
  z-index: 60;
  max-width: 90vw;
  padding: 11px 16px;
  border-radius: 9px;
  background: #1c2429;
  color: #fff;
  font-size: 14px;
  transition: transform .2s ease;
}
.meldung.sichtbar { transform: translate(-50%, 0); }
.meldung.gut { background: var(--gut); }
.meldung.fehler { background: var(--fehler); }
.meldung.warnung { background: var(--warn); }

/* --------------------------------------------------------------- Anmeldung */

.anmeldung { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.anmeldekarte {
  width: 100%;
  max-width: 340px;
  background: #fff;
  border: 1px solid var(--rand);
  border-radius: 12px;
  padding: 24px;
  text-align: center;
}
.anmeldekarte h1 { font-size: 19px; margin: 10px 0 2px; }
.anmeldekarte .firma { color: var(--teal); font-size: 13px; margin: 0 0 18px; }
.anmeldekarte label { display: block; text-align: left; font-size: 12px; color: var(--gedimmt); margin: 10px 0 4px; }
.anmeldekarte .knopf { width: 100%; margin-top: 14px; }

.fuss { text-align: center; font-size: 12px; color: var(--gedimmt); padding: 0 12px 100px; }
.fuss a { color: var(--teal); }

/* ------------------------------------------------------------ Büro-Ansicht */

.buero { max-width: 1100px; margin: 0 auto; padding: 16px 14px 60px; }
.suchleiste { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.suchleiste input, .suchleiste select { width: auto; flex: 1 1 150px; }
.suchleiste input[type="search"] { flex: 2 1 240px; }

table.treffer { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--rand); border-radius: 10px; overflow: hidden; }
table.treffer th, table.treffer td { text-align: left; padding: 9px 11px; border-bottom: 1px solid var(--rand); font-size: 14px; }
table.treffer th { background: #eef2f4; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--teal-d); }
table.treffer tr:last-child td { border-bottom: 0; }
.marke { display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 9px; background: #e8eced; color: var(--gedimmt); }
.marke.mangel { background: #fdeceb; color: var(--fehler); }
.marke.entwurf { background: #fdf6e9; color: var(--warn); }
.marke.fertig { background: #e3f5ea; color: var(--gut); }

/* ------------------------------------------------------------- Verwaltung */

.reiter { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--rand); margin-bottom: 16px; }
.reiterknopf {
  font: inherit;
  font-size: 14px;
  padding: 10px 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--gedimmt);
  cursor: pointer;
}
.reiterknopf.aktiv { color: var(--teal-d); border-bottom-color: var(--teal); font-weight: 600; }

.benutzerkarte.stillgelegt { opacity: .62; }

.archivgruppe { margin-top: 18px; border-top: 1px solid var(--rand); padding-top: 12px; }
.archivgruppe > summary {
  cursor: pointer;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--gedimmt);
  padding: 8px 4px;
  list-style: none;
}
.archivgruppe > summary::-webkit-details-marker { display: none; }
.archivgruppe > summary::before { content: '▸ '; display: inline-block; width: 14px; }
.archivgruppe[open] > summary::before { content: '▾ '; }
.archivgruppe > summary:hover { color: var(--teal-d); }
.benutzerkarte h2 { text-transform: none; letter-spacing: 0; font-size: 16px; color: var(--text); }

.rechteliste {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 4px 14px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--rand);
}
.rechtzeile { display: flex; align-items: center; gap: 8px; font-size: 14px; padding: 4px 0; cursor: pointer; }
.rechtzeile input { width: auto; flex: 0 0 auto; }

code { background: var(--grau); padding: 1px 5px; border-radius: 4px; font-size: 13px; }

@media (max-width: 640px) {
  table.treffer thead { display: none; }
  table.treffer tr { display: block; border-bottom: 1px solid var(--rand); padding: 4px 0; }
  table.treffer td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 5px 11px; }
  table.treffer td::before { content: attr(data-spalte); color: var(--gedimmt); font-size: 12px; }
}

/* ------------------------------------------------------- Dialogfenster */
/* Eigener Overlay statt <dialog>: der iPad-Safari im Einsatz ist alt genug,
   dass showModal() dort fehlt. */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}
.dialog {
  background: #fff;
  border-radius: 12px;
  padding: 18px 18px 14px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .3);
}
.dialog h2 { margin: 0 0 6px; font-size: 18px; }
.dialog label { display: block; margin-top: 10px; font-size: 13px; color: var(--gedimmt); }
.dialogtext { margin: 0; font-size: 14px; color: var(--gedimmt); }
.dialogaktionen { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.auswahl.breit { width: 100%; max-width: none; }

/* ------------------------------------------------- Stunden und Zuschläge */
/* Steht direkt unter dem Stundenblock. Der Monteur soll die Aufschläge sehen,
   bevor der Kunde unterschreibt – nicht erst im fertigen PDF. */
.stundenvorschau { margin: 4px 0 14px; }
.stundenvorschau:empty { display: none; }
.stundenvorschau .tagesart {
  font-size: 13px;
  color: var(--gedimmt);
  margin-bottom: 4px;
}
table.stundentabelle {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  background: var(--grau);
  border-radius: 8px;
  overflow: hidden;
}
table.stundentabelle th,
table.stundentabelle td { padding: 5px 9px; text-align: left; }
table.stundentabelle thead th {
  font-size: 12px;
  font-weight: 600;
  color: var(--gedimmt);
  border-bottom: 1px solid var(--rand);
}
table.stundentabelle .rechts { text-align: right; white-space: nowrap; }
table.stundentabelle .klein { font-size: 12px; color: var(--gedimmt); }
table.stundentabelle .stark { font-weight: 600; }
table.stundentabelle tfoot td {
  border-top: 1px solid var(--rand);
  font-weight: 600;
}

/* --------------------------------------------------- Zuschlagseinstellungen */
#zuschlagTabellen {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 8px;
}
.zuschlagblock h3 { margin: 0 0 6px; font-size: 14px; }
table.zuschlagtabelle { border-collapse: collapse; font-size: 14px; }
table.zuschlagtabelle td { padding: 2px 4px 2px 0; white-space: nowrap; }
table.zuschlagtabelle input { width: 62px; }
tr.gedimmt { opacity: .5; text-decoration: line-through; }
tr.gedimmt em { text-decoration: none; }
td.rechts { text-align: right; }

/* Zahlenfeld mit Einheit daneben, z. B. Füllgewicht 3,5 [kg] */
.mitEinheit { display: flex; gap: 6px; }
.mitEinheit input { flex: 1 1 auto; min-width: 0; }
.mitEinheit select.einheit { flex: 0 0 auto; width: auto; min-width: 62px; }
