/* =====================================================================
   Ansicht „Abnahmeprotokoll“ (js/views/abnahmeprotokoll.js): Druckvorlage, zwei Seiten DIN A4
   Entwurf vom 02.10.2026 zur Freigabe durch Lukas. Das Blatt ist immer hell (Papier), auch im dunklen Farbschema.
   Drucken bzw. „Als PDF speichern“ über den Browser; Knopfleiste und Hinweis nur am Bildschirm.
   ===================================================================== */

.ap-seite-bildschirm {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  padding: 16px 16px 40px;
}
.ap-leiste {
  width: 100%; max-width: 794px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
}
.ap-leiste__knoepfe { display: flex; flex-wrap: wrap; gap: 8px; }
.ap-hinweis { width: 100%; max-width: 794px; font-size: .9rem; color: var(--muted); }
.ap-hinweis p { margin: 0 0 4px; }

/* Bildschirm: Bogen auf die verfügbare Breite verkleinern (Maßstab setzt abnahmeprotokoll.js) */
.ap-rahmen { width: 100%; max-width: 794px; }
.ap-huelle {
  position: relative; margin: 0 auto;
  width: calc(210mm * var(--massstab, 1)); height: calc((var(--seiten, 2) * 297mm + (var(--seiten, 2) - 1) * 8mm) * var(--massstab, 1));
}
.ap-bogen {
  position: absolute; left: 0; top: 0; width: 210mm;
  display: flex; flex-direction: column; gap: 8mm;
  transform: scale(var(--massstab, 1)); transform-origin: 0 0;
}

/* ---------- das Blatt ---------- */
.ap-blatt {
  --ap-ink: #1D1816;
  --ap-orange: #F57F00;
  --ap-orange-dark: #C45F00;
  --ap-linie: #3A322E;
  --ap-fein: #B9AEA2;
  --ap-muted: #6B6158;
  position: relative; width: 210mm; height: 297mm; overflow: hidden; box-sizing: border-box;
  padding: 12mm 15mm 14mm;
  background: #fff; color: var(--ap-ink); color-scheme: light;
  font: 400 8.8pt/1.35 'Inter', 'Segoe UI', Arial, sans-serif; text-align: left;
  box-shadow: 0 6px 28px rgba(0, 0, 0, .18);
  page: protokoll;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.ap-blatt * { box-sizing: border-box; }
.ap-blatt h1, .ap-blatt h2, .ap-blatt p, .ap-blatt dl, .ap-blatt dd, .ap-blatt dt { margin: 0; padding: 0; }

.ap-kopf { display: flex; align-items: center; gap: 6mm; padding-bottom: 3.5mm; border-bottom: .5mm solid var(--ap-orange); }
.ap-logo { display: block; height: 15mm; width: auto; }
.ap-kopf--klein .ap-logo { height: 10mm; }
.ap-kopf__titel { flex: 1; }
.ap-titel { font: 700 16pt/1.15 'Inter', 'Segoe UI', Arial, sans-serif; letter-spacing: .01em; color: var(--ap-ink); }
.ap-kopf--klein .ap-titel { font-size: 12pt; }
.ap-nummer { margin-top: 1mm; font-size: 9pt; color: var(--ap-muted); }
.ap-nummer strong { color: var(--ap-ink); font-variant-numeric: tabular-nums; }

.ap-raster { display: grid; grid-template-columns: 1fr 1fr; gap: 3mm 8mm; margin-top: 4mm; }
.ap-abschnitt { margin-top: 4.5mm; }
.ap-raster .ap-abschnitt { margin-top: 0; }
.ap-abschnitt > h2 {
  font: 700 7.4pt/1 'Inter', 'Segoe UI', Arial, sans-serif; letter-spacing: .16em; text-transform: uppercase; color: var(--ap-orange-dark);
  padding-bottom: 1.2mm; margin-bottom: 1.8mm; border-bottom: .25mm solid var(--ap-fein);
}
.ap-erklaerung { margin-bottom: 1.6mm; font-size: 8pt; color: var(--ap-muted); }

.ap-angabe { display: grid; grid-template-columns: 26mm 1fr; gap: 2mm; align-items: baseline; padding: .7mm 0; }
.ap-angabe dt { font-size: 7.4pt; color: var(--ap-muted); }
.ap-angabe dd { min-height: 4.6mm; }
.ap-zeile { display: block; font-weight: 600; overflow-wrap: anywhere; }

/* Kästchen und Linien zum Ausfüllen von Hand */
.ap-box { display: inline-block; flex: none; width: 3.6mm; height: 3.6mm; border: .3mm solid var(--ap-linie); background: #fff; vertical-align: middle; }
.ap-auswahl { display: inline-flex; align-items: center; gap: 1.8mm; margin-right: 5mm; }
.ap-linie { display: inline-block; min-width: 14mm; height: 4.6mm; border-bottom: .3mm solid var(--ap-linie); vertical-align: bottom; }
.ap-angabe .ap-linie { display: block; width: 100%; }
.ap-linie--kurz { width: 22mm; margin: 0 1.6mm; }
.ap-linie--lang { flex: 1; }
.ap-linie--voll { display: block; width: 100%; height: 6mm; }

.ap-leistungen { display: grid; grid-template-columns: 1fr 1fr; gap: 1.6mm 6mm; }
.ap-leistungen .ap-auswahl { margin-right: 0; }
.ap-liste { display: flex; flex-direction: column; gap: 1.8mm; }
.ap-liste--reihe { flex-direction: row; flex-wrap: wrap; gap: 1.8mm 8mm; }

/* Heizkreise: der Kern der Vorlage */
.ap-verteiler { display: flex; align-items: flex-end; gap: 3mm; margin-bottom: 2mm; }
.ap-verteiler__label { font-weight: 600; white-space: nowrap; }
.ap-tabelle { width: 100%; border-collapse: collapse; table-layout: fixed; border: .3mm solid var(--ap-linie); }
.ap-tabelle th, .ap-tabelle td { border: .25mm solid var(--ap-linie); padding: 0 1.6mm; text-align: left; }
.ap-tabelle th { height: 8.4mm; background: #F3EEE7; font: 600 7.4pt/1.15 'Inter', 'Segoe UI', Arial, sans-serif; vertical-align: middle; }
.ap-tabelle td { height: 6.6mm; }
.ap-tabelle .ap-nr { width: 40mm; }
.ap-tabelle .ap-zahl { width: 24mm; }
.ap-tabelle .ap-haken { width: 22mm; text-align: center; }
.ap-tabelle .ap-klein { display: block; font-weight: 400; font-size: 6.2pt; color: var(--ap-muted); }
.ap-klein { font-size: 7.2pt; color: var(--ap-muted); }

.ap-pruefung { display: flex; flex-direction: column; gap: 2.4mm; }
.ap-pruefzeile { display: flex; align-items: flex-end; gap: 1mm; min-height: 5.4mm; }
.ap-pruefzeile__label { display: inline-block; width: 40mm; font-weight: 600; }
.ap-pruefzeile__label--zweit { width: auto; margin-left: 8mm; margin-right: 2mm; }
.ap-pruefzeile .ap-auswahl { align-self: center; }

.ap-zeilen { display: flex; flex-direction: column; gap: 0; }
.ap-bestaetigung { margin-top: 5mm; padding: 3mm 4mm; border: .3mm solid var(--ap-linie); display: flex; flex-direction: column; gap: 2mm; }
.ap-bestaetigung p { font-weight: 600; }

.ap-unterschriften { display: grid; grid-template-columns: 1fr 1fr; gap: 5mm 12mm; margin-top: 4mm; }
.ap-abnahmesatz { grid-column: 1 / -1; margin: 0; padding: 1.8mm 3.4mm; border: .3mm solid var(--ap-linie); font-weight: 600; font-size: 8.6pt; line-height: 1.35; }
.ap-kopiezeile { margin: 0; }
.apf-erklaerung { margin: 0; padding: 12px 14px; border: 2px solid var(--navy, #1D1816); border-radius: 10px; background: #fff; font-weight: 650; line-height: 1.45; }
.apf-maengelblock { padding: 14px; border: 1px solid var(--linie, #E6DFD4); border-radius: 10px; }
.ap-ortdatum { grid-column: 1 / -1; display: grid; grid-template-columns: 22mm 1fr; align-items: end; gap: 2mm; max-width: 100mm; }
.ap-unterschrift { display: flex; flex-direction: column; gap: 1mm; }
.ap-fuss { margin-top: 5mm; font-size: 8pt; color: var(--ap-muted); }
.ap-seitenzahl { position: absolute; left: 15mm; right: 15mm; bottom: 7mm; text-align: right; font-size: 6.8pt; color: var(--ap-muted); }

/* ---------- Druck ---------- */
@page protokoll { size: A4 portrait; margin: 0; }
@media print {
  body[data-layout="protokoll"] { background: #fff; }
  body[data-layout="protokoll"] .kopf,
  body[data-layout="protokoll"] .fuss,
  body[data-layout="protokoll"] .toasts,
  body[data-layout="protokoll"] .skip-link,
  body[data-layout="protokoll"] .ap-leiste,
  body[data-layout="protokoll"] .ap-hinweis { display: none !important; }
  body[data-layout="protokoll"] .haupt,
  body[data-layout="protokoll"] .ap-seite-bildschirm { padding: 0; margin: 0; display: block; }
  .ap-rahmen, .ap-huelle { width: 210mm; height: auto; max-width: none; margin: 0; }
  .ap-bogen { position: static; display: block; transform: none; width: 210mm; }
  .ap-blatt { height: 296.4mm; box-shadow: none; break-after: page; }
  .ap-blatt:last-child { break-after: auto; }
}

/* =====================================================================
   Digitales Abnahmeprotokoll (07.10.2026): Ausfüllen am Tablet, ausgefülltes Blatt, Knopf auf den Auftragsseiten
   ===================================================================== */

/* ---------- ausgefülltes Blatt ---------- */
.ap-box--an { align-items: center; justify-content: center; font: 700 8.5pt/1 'Inter', 'Segoe UI', Arial, sans-serif; color: var(--ap-ink); text-align: center; }
.ap-box { text-align: center; line-height: 3.2mm; }
.ap-wert { display: inline-block; min-width: 14mm; padding: 0 1.6mm; font-weight: 600; border-bottom: .3mm solid var(--ap-linie); }
.ap-wert--breit { display: block; min-width: 0; width: 100%; }
.ap-verteiler__wert { flex: 1; min-height: 4.6mm; font-weight: 600; border-bottom: .3mm solid var(--ap-linie); overflow-wrap: anywhere; }
.ap-maengel { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 8.6pt; line-height: 1.35; }     /* nie abschneiden: der Rest läuft auf Zusatzseiten */
.ap-unterschrift__feld { height: 16mm; border-bottom: .3mm solid var(--ap-linie); display: flex; align-items: flex-end; }
.ap-unterschrift__bild { display: block; max-height: 15mm; max-width: 100%; width: auto; height: auto; background: #fff; }

/* ---------- Ausfüllmodus ---------- */
.apf { width: 100%; max-width: 1100px; margin: 0 auto; padding: 14px 16px 64px; display: flex; flex-direction: column; gap: 14px; }
.apf-kopf { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.apf-kopf__titel { flex: 1 1 220px; min-width: 0; }
.apf-kopf__titel h1 { margin: 0; font-size: clamp(1.3rem, 4vw, 1.7rem); }
.apf-kopf__titel p { margin: 2px 0 0; overflow-wrap: anywhere; }
.apf-admin { margin: 0; }
.apf-leiste { display: flex; flex-direction: column; gap: 8px; position: sticky; top: 0; z-index: 5; padding: 8px 0 6px; background: var(--bg); }
.apf-schritte { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.apf-schritt {
  width: 100%; min-height: 48px; padding: 6px 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 1px solid var(--line-2); border-radius: 12px; background: var(--card); color: var(--text); font: inherit; font-size: 12.5px; font-weight: 650; cursor: pointer;
}
.apf-schritt[aria-current='step'] { background: var(--ink); color: var(--sand); border-color: var(--ink); }
:root[data-theme='dark'] .apf-schritt[aria-current='step'] { background: var(--orange); color: #1b1109; border-color: var(--orange); }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .apf-schritt[aria-current='step'] { background: var(--orange); color: #1b1109; border-color: var(--orange); } }
.apf-schritt__nr { font-size: 15px; font-weight: 800; }
.apf-schritt__text { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.apf-status { margin: 0; font-size: 13.5px; font-weight: 650; color: var(--muted); }
.apf-status[data-zustand='ok'] { color: var(--ok); }
.apf-status[data-zustand='arbeit'] { color: var(--warn); }
.apf-status[data-zustand='fehler'] { color: var(--err); }
.apf-karte h2 { margin: 0; }
.apf-karte h3 { margin: 16px 0 0; }
.apf-navi { display: flex; justify-content: space-between; gap: 12px; }
.apf-navi .btn { flex: 1 1 0; max-width: 260px; }
.apf-navi .btn:last-child:not(:first-child) { margin-left: auto; }

.apf-fakten { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px 18px; margin: 0; }
.apf-fakt { min-width: 0; }
.apf-fakt dt { font-size: 12.5px; color: var(--muted); font-weight: 650; }
.apf-fakt dd { margin: 0; font-weight: 650; overflow-wrap: anywhere; }
.apf-fakt--neu { background: #fff4d6; border-left: 4px solid #c47f00; padding: 4px 8px; border-radius: 6px; }
.apf-fakt--neu dt::after { content: ' (geändert)'; }

.apf-eingabe { min-height: 48px; font-size: 16px; }   /* 16 px: das iPad zoomt sonst beim Antippen */
.apf-hakenliste { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 10px; }
.apf-haken { display: flex; align-items: center; gap: 14px; min-height: 56px; padding: 10px 14px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--card); cursor: pointer; font-weight: 600; }
.apf-haken__box { width: 28px; height: 28px; flex: none; accent-color: var(--orange-dark); }
.apf-haken:has(input:checked) { border-color: var(--ok); background: var(--ok-bg); }
.apf-wahlreihe { display: flex; flex-wrap: wrap; gap: 10px; }
.apf-wahl { flex: 1 1 140px; min-height: 56px; padding: 10px 18px; border: 2px solid var(--line-2); border-radius: 12px; background: var(--card); color: var(--text); font: inherit; font-size: 17px; font-weight: 700; cursor: pointer; }
.apf-wahl[aria-checked='true'] { border-color: var(--navy); background: var(--navy); color: #fff; }

.apf-hk { display: grid; grid-template-columns: 90px minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1fr); gap: 8px; align-items: end; }
.apf-hk--kopf { font-size: 12.5px; font-weight: 700; color: var(--muted); padding-bottom: 0; }
.apf-hkliste { display: flex; flex-direction: column; gap: 8px; }
.apf-hk__zelle { display: block; min-width: 0; }
.apf-hk__beschr { display: none; font-size: 12px; font-weight: 650; color: var(--muted); }
.apf-summe { margin: 12px 0 0; font-weight: 700; font-variant-numeric: tabular-nums; }

.apf-pad { display: flex; flex-direction: column; gap: 8px; }
.apf-pad__kopf { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; }
.apf-pad__status { font-size: 13px; color: var(--muted); }
.apf-pad__rahmen { border: 2px dashed var(--line-2); border-radius: 14px; background: #fff; }
.apf-pad__flaeche { display: block; width: 100%; height: 200px; touch-action: none; cursor: crosshair; border-radius: 12px; background: #fff; }
.apf-pad__flaeche[data-zustand='ok'] { outline: 3px solid var(--ok); outline-offset: -3px; }
.apf-pad__fuss { display: flex; justify-content: flex-end; }
.apf-fotos h3 { margin: 0; }

/* Handy */
@media (max-width: 640px) {
  .apf { padding: 10px 12px 60px; }
  .apf-schritt__text { display: none; }
  .apf-schritt { min-height: 46px; }
  .apf-hakenliste { grid-template-columns: minmax(0, 1fr); }
  .apf-hk--kopf { display: none; }
  .apf-hk { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--card-2); }
  .apf-hk__beschr { display: block; margin-bottom: 2px; }
  .apf-pad__flaeche { height: 180px; }
  .apf-navi .btn { max-width: none; }
}

/* ---------- Knopf auf den Auftragsseiten (Partner und Admin) ---------- */
.ap-knopfkarte { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border: 2px solid var(--orange); border-radius: var(--radius); background: var(--orange-tint); }
.ap-knopfkarte[hidden] { display: none; }
.ap-knopfkarte--ruhig { border-color: var(--line-2); background: var(--card-2); }
.ap-knopfkarte__text { flex: 1 1 220px; min-width: 0; }
.ap-knopfkarte__text strong { display: block; }
.ap-knopfkarte__text span { color: var(--muted); font-size: 14px; }
.ap-knopfkarte .btn { flex: 0 0 auto; }

@media print {
  body[data-layout="protokoll"] .apf { display: none !important; }
}

/* Konflikt beim Speichern, Fotogalerie unter der unterschriebenen Ansicht */
.apf-konflikt[hidden] { display: none; }
.ap-galerie { width: 100%; max-width: 794px; }
.ap-galerie h2 { margin: 0; font-size: 1.1rem; }
@media print {
  body[data-layout="protokoll"] .ap-galerie { display: none !important; }
}
