/* Aufmaß vor Ort (aufmass.js) – Reiter „📏 Aufmaß“ in der Vorgangsmappe, nur im neuen Gerüst.
   Farben und Schrift aus den Variablen der Seite (--ink, --line, --red …). Handy zuerst: große Felder, Schrift ≥ 16 px (kein Zoom auf dem iPhone). */
.am-tab .zahl { background: var(--ink); color: #fff; border-radius: 9px; padding: 0 7px; font-size: 12px; margin-left: 2px; }
.vg-tabs .am-tab.an .zahl { background: var(--red); }
.am-punkt { color: var(--orange); font-size: 11px; vertical-align: 2px; }

.am-karte { padding: 16px; }
.am-kopf { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 12px; }
.am-kopf h3 { margin: 0; font-size: 19px; }
.am-status { font-size: 13px; font-weight: 700; border-radius: 20px; padding: 4px 11px; background: #e3f3e7; color: var(--good); }
.am-status.laeuft { background: #eef2f7; color: #38506b; }
.am-status.warte { background: #fff3d6; color: #7a5600; }
.am-status.fehler { background: #fde5e5; color: var(--bad); }

/* Liste der Aufmaße */
.am-liste { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; scrollbar-width: thin; }
.am-m { flex: none; border: 1.5px solid var(--line); background: #fff; border-radius: 12px; padding: 8px 14px; text-align: left; font: inherit; color: var(--ink); cursor: pointer; display: grid; gap: 1px; min-height: 52px; max-width: 260px; }
.am-m b { font-size: 15px; white-space: nowrap; }
.am-m small { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.am-m.an { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.am-m.neuester:not(.am-m-neu) { background: #fffaf0; }
.am-m-neu { border-style: dashed; color: var(--red); }
.am-m-neu b { color: var(--red); }
.am-badge { display: inline-block; background: var(--good); color: #fff; border-radius: 9px; padding: 0 7px; font-size: 11px; font-weight: 700; vertical-align: 1px; margin-left: 4px; }
.am-lokal { color: #7a5600; font-weight: 700; }

/* Hinweise */
.am-hinweisbox { background: #faf7f4; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 0 0 12px; font-size: 14px; }
.am-hinweisbox.warn { background: #fff6e6; border-color: #f2d7a6; }
.am-kundeninfo { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; background: #fbf6ec; border-color: #ead9b6; }
.am-kundeninfo > span { flex: 1 1 260px; }
.am-leer { padding: 6px 0 4px; }
.am-leer p { margin: 0 0 12px; }
.am-gross { font-size: 17px; padding: 14px 22px; min-height: 52px; }

/* Kopfdaten */
.am-meta { display: grid; grid-template-columns: 170px minmax(0, 1fr) minmax(0, 1fr); gap: 10px; margin-bottom: 12px; }

/* Sprungleiste (bleibt beim Scrollen oben) */
.am-sprung { position: sticky; top: 0; z-index: 6; display: flex; gap: 6px; overflow-x: auto; padding: 8px 0; margin: 0 -2px; background: var(--card, #fff); scrollbar-width: none; }
.am-sprung::-webkit-scrollbar { display: none; }
.am-sprung button { flex: none; border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 7px 12px; font: inherit; font-size: 13.5px; font-weight: 600; color: var(--ink); cursor: pointer; white-space: nowrap; min-height: 38px; }
.am-sprung button:hover { border-color: var(--ink); }
.am-sz { color: var(--good); font-weight: 800; }

/* Bereiche – auf breiten Bildschirmen (Gerüst mit voller Fensterbreite) nebeneinander, auf dem Handy untereinander */
.am-bereiche { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr)); gap: 0 14px; align-items: start; }
details.am-bereich { border: 1px solid var(--line); border-radius: 12px; margin: 10px 0; background: #fff; min-width: 0; }
details.am-bereich { scroll-margin-top: 64px; }   /* beim Springen nicht unter der Sprungleiste verschwinden */
details.am-bereich > summary { list-style: none; cursor: pointer; padding: 12px 14px; display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 16.5px; min-height: 54px; user-select: none; }
details.am-bereich > summary::-webkit-details-marker { display: none; }
details.am-bereich > summary::after { content: '▾'; color: var(--muted); font-size: 14px; transition: transform .15s; }
details.am-bereich[open] > summary::after { transform: rotate(180deg); }
details.am-bereich[open] > summary { border-bottom: 1px solid var(--line); }
.am-zaehler { margin-left: auto; font-size: 12.5px; font-weight: 700; color: var(--muted); background: #f3efeb; border-radius: 12px; padding: 2px 9px; white-space: nowrap; }
.am-zaehler:empty { display: none; }
.am-zaehler.teil { background: #fff3d6; color: #7a5600; }
.am-zaehler.voll { background: #e3f3e7; color: var(--good); }
.am-bereich-inhalt { padding: 14px; }
.am-weiter { display: flex; justify-content: flex-end; margin-top: 14px; }
.am-weiter .btn { min-height: 46px; font-size: 15px; }

/* Felder */
.am-felder { display: grid; gap: 16px; }
.am-reihe { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.am-feld { display: flex; flex-direction: column; gap: 5px; min-width: 0; margin: 0; }
.am-feld[hidden] { display: none !important; }
.am-l { font-size: 14px; font-weight: 700; color: var(--ink); }
.am-l-e { font-weight: 500; color: var(--muted); }
.am-in { font: inherit; font-size: 17px; line-height: 1.3; padding: 11px 12px; min-height: 48px; border: 1.5px solid #d9d2c8; border-radius: 10px; background: #fff; color: var(--ink); width: 100%; min-width: 0; -webkit-appearance: none; appearance: none; }
select.am-in { -webkit-appearance: auto; appearance: auto; }
textarea.am-in { min-height: 84px; resize: vertical; }
.am-in:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(59,59,59,.15); }
.am-in::placeholder { color: #a39b91; }
.am-zahl-wrap { display: flex; align-items: stretch; min-width: 0; }
.am-zahl-wrap .am-in { border-radius: 10px 0 0 10px; text-align: right; font-variant-numeric: tabular-nums; }
.am-einheit { display: grid; place-items: center; padding: 0 10px; min-width: 48px; background: #f3efeb; border: 1.5px solid #d9d2c8; border-left: 0; border-radius: 0 10px 10px 0; font-weight: 800; color: var(--brown); font-size: 15px; }
.am-feld.ungueltig .am-in, .am-in.ungueltig { border-color: var(--bad); background: #fff7f7; }
.am-feld.pruefen .am-in { border-color: var(--orange); }
.am-meldung { font-size: 13.5px; line-height: 1.35; }
.am-meldung.fehler { color: var(--bad); }
.am-meldung.pruefen { color: #8a5300; }
.am-hilfe { font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.am-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.am-wahl { border: 1.5px solid #d9d2c8; background: #fff; border-radius: 22px; padding: 9px 15px; min-height: 44px; font: inherit; font-size: 15px; cursor: pointer; color: var(--ink); text-align: left; }
.am-wahl:hover { border-color: var(--ink); }
.am-wahl[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 700; }
.am-wahl.klein { padding: 6px 11px; min-height: 36px; font-size: 13.5px; }
.am-kunde-zeile:empty { display: none; }
.am-kunde { display: inline-block; border: 1.5px dashed #d2b77f; background: #fbf6ec; color: #5e4b28; border-radius: 9px; padding: 6px 10px; font: inherit; font-size: 13.5px; line-height: 1.35; text-align: left; cursor: pointer; max-width: 100%; }
button.am-kunde:hover { border-style: solid; }
.am-kunde b { color: var(--red); white-space: nowrap; }
.am-kunde small { color: var(--muted); }
.am-kunde.info { cursor: default; }
.am-kunde.gleich { border-style: solid; border-color: #bfe0c8; background: #eef8f1; color: var(--good); cursor: default; font-weight: 600; }
.am-info:empty { display: none; }
.am-info { margin-top: 14px; display: grid; gap: 6px; }
.am-info p { margin: 0; padding: 8px 11px; border-radius: 9px; background: #f6f3ee; font-size: 14px; }

/* Fotos */
.am-fotos { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; align-items: stretch; }
.am-foto, .am-foto-neu { position: relative; width: 92px; height: 92px; padding: 0; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; background: #f3efeb; cursor: pointer; flex: none; }
.am-foto img { width: 100%; height: 100%; object-fit: cover; display: block; }
.am-foto.warte img { opacity: .75; }
.am-f-badge, .am-f-warte { position: absolute; top: 4px; font-style: normal; background: rgba(255,255,255,.92); border-radius: 8px; padding: 0 5px; font-size: 13px; }
.am-f-badge { left: 4px; } .am-f-warte { right: 4px; }
.am-f-text { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.55); color: #fff; font-size: 11px; line-height: 1.25; padding: 2px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.am-foto-neu { display: grid; place-content: center; justify-items: center; gap: 2px; border: 1.5px dashed #cbbfae; background: #fff; color: var(--ink); font: inherit; }
.am-foto-neu span { font-size: 28px; line-height: 1; }
.am-foto-neu small { font-size: 12.5px; font-weight: 700; }
.am-foto-neu:hover { border-color: var(--ink); }
.am-skizzen .am-foto, .am-skizzen .am-foto-neu { width: 140px; height: 105px; }
.am-skizzen .am-foto img { object-fit: contain; background: #fff; }

/* Positionen */
.am-pos-liste { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); align-items: start; gap: 12px; margin: 10px 0; }
.am-pos-liste > .am-pos-leer { grid-column: 1 / -1; }
.am-pos { border: 1px solid var(--line); border-left: 4px solid var(--wood-dark, #b89668); border-radius: 10px; padding: 10px 12px; background: #fff; display: grid; gap: 10px; }
.am-pos-kopf { display: flex; gap: 8px; align-items: center; }
.am-pos-nr { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 13px; }
.am-pos-kopf .am-in { font-weight: 700; }
.am-x { flex: none; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--muted); font-size: 16px; cursor: pointer; }
.am-x:hover { color: var(--bad); border-color: var(--bad); }
.am-link { border: 0; background: none; padding: 2px 0; font: inherit; font-weight: 700; color: var(--red); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; min-height: 32px; }
.am-pos-werte, .am-abzug { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px; }
.am-pos-w { display: grid; gap: 3px; flex: 1 1 110px; min-width: 96px; position: relative; }
.am-pos-w > span:first-child { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.am-pos-w.am-formel { flex: 3 1 220px; }
.am-pos-w.pruefen .am-in { border-color: var(--orange); }
.am-pos-hinweis { font-size: 12px; color: #8a5300; }
.am-zahl-wrap.klein .am-einheit { min-width: 40px; font-size: 13.5px; padding: 0 6px; }
.am-mal { color: var(--muted); padding-top: 33px; font-size: 16px; }
.am-abzuege { display: grid; gap: 8px; padding: 8px 10px; background: #f8f6f3; border-radius: 9px; }
.am-abzug { border-bottom: 1px dashed var(--line); padding-bottom: 8px; }
.am-abzug-t { flex-basis: 100%; font-size: 12.5px; font-weight: 800; color: var(--brown); }
.am-pos-erg { font-size: 15px; background: #f6f3ee; border-radius: 8px; padding: 8px 10px; }
.am-pos-erg b { font-size: 17px; }
.am-pos-notiz { font-size: 15px; min-height: 42px; padding: 8px 10px; }
.am-pos-leer { margin: 4px 0; }
.am-pos-neu { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 6px; }
.am-pos-neu-k { display: grid; gap: 1px; text-align: left; border: 1.5px dashed #cbbfae; background: #fff; border-radius: 11px; padding: 10px 12px; font: inherit; color: var(--ink); cursor: pointer; min-height: 64px; }
.am-pos-neu-k:hover { border-color: var(--ink); border-style: solid; }
.am-pos-neu-k .am-sym { font-size: 20px; line-height: 1; color: var(--red); font-weight: 800; }
.am-pos-neu-k small { color: var(--muted); font-size: 12px; }
.am-summen:empty { display: none; }
.am-summen { margin-top: 14px; padding: 10px 12px; border-radius: 10px; background: #fbf6ec; border: 1px solid #ead9b6; }
.am-summen table { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 15px; }
.am-summen td { padding: 5px 4px; border-top: 1px solid #ead9b6; }
.am-summen .r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Aktionen, Papierkorb */
.am-aktionen { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.am-aktionen .btn { min-height: 46px; font-size: 15px; }
.am-stand { margin: 8px 0 0; }
.am-korb { margin-top: 12px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; }
.am-korb > summary { cursor: pointer; padding: 10px 0; font-weight: 700; color: var(--muted); }
.am-korb-z { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.am-korb-z span { flex: 1; min-width: 0; } .am-korb-z small { display: block; }
.am-korb-z img { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; flex: none; }

/* Überschneidung (Konflikt) */
.am-konflikt { border: 2px solid var(--orange); background: #fff8ef; border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; }
.am-konflikt p { margin: 6px 0 10px; }
.am-k-liste { display: grid; gap: 12px; margin-bottom: 12px; }
.am-k-z { display: grid; gap: 5px; }
.am-knoepfe { display: flex; flex-wrap: wrap; gap: 8px; }
.am-knoepfe .btn { min-height: 46px; }

/* Vollbild: Foto ansehen, Zeichnen */
html.am-gesperrt, html.am-gesperrt body { overflow: hidden; }
.am-overlay { position: fixed; inset: 0; z-index: 10050; background: #1f1d1b; color: #fff; display: flex; flex-direction: column; }
.am-o-kopf { display: flex; align-items: center; gap: 10px; padding: calc(env(safe-area-inset-top) + 10px) 14px 10px; background: #fff; color: var(--ink); }
.am-o-kopf b { flex: 1; min-width: 0; }
.am-o-zu { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-size: 18px; cursor: pointer; }
.am-o-bild { flex: 1; min-height: 0; display: grid; place-items: center; padding: 10px; }
.am-o-bild img { max-width: 100%; max-height: 100%; object-fit: contain; background: #fff; border-radius: 4px; }
.am-o-fuss { background: #fff; color: var(--ink); padding: 12px 14px calc(env(safe-area-inset-bottom) + 12px); display: grid; gap: 10px; max-height: 50vh; overflow: auto; }
.am-z-leiste { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: calc(env(safe-area-inset-top) + 8px) 10px 8px; background: #fff; color: var(--ink); }
.am-z-gruppe { display: flex; gap: 4px; align-items: center; }
.am-z-rechts { margin-left: auto; gap: 8px; }
.am-z-rechts .btn { min-height: 44px; }
.am-z-w { display: grid; justify-items: center; gap: 0; min-width: 56px; min-height: 48px; padding: 4px 8px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; font: inherit; font-size: 20px; line-height: 1.1; cursor: pointer; color: var(--ink); }
.am-z-w span { font-size: 11px; font-weight: 700; }
.am-z-w[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.am-z-farben button { width: 36px; height: 36px; border-radius: 50%; border: 2px solid #cfc7bc; background: var(--f); cursor: pointer; }
.am-z-farben button[aria-pressed="true"] { box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--ink); border-color: #fff; }
.am-z-flaeche { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 8px; overflow: hidden; }
.am-z-flaeche canvas { display: block; touch-action: none; background: #fff; box-shadow: 0 4px 20px rgba(0,0,0,.4); border-radius: 3px; cursor: crosshair; }
.am-z-tipp { text-align: center; font-size: 13px; color: #d8d2ca; padding: 0 12px calc(env(safe-area-inset-bottom) + 8px); }
.am-z-eingabe { position: absolute; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 16px); transform: translateX(-50%); width: min(460px, calc(100% - 24px)); background: #fff; color: var(--ink); border-radius: 14px; padding: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.45); display: grid; gap: 10px; }
.am-z-eingabe[hidden] { display: none; }
.am-z-reihe { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.am-z-reihe .am-in { flex: 1 1 140px; }

/* Meldung unten */
#amToast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 140%); z-index: 10060; background: var(--ink); color: #fff; border-radius: 12px; padding: 11px 14px; display: flex; gap: 12px; align-items: center; box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: calc(100% - 24px); font-size: 14.5px; transition: transform .2s; pointer-events: none; }
#amToast.an { transform: translate(-50%, 0); pointer-events: auto; }
#amToast button { border: 0; background: #fff; color: var(--ink); border-radius: 8px; padding: 7px 12px; font: inherit; font-weight: 800; cursor: pointer; white-space: nowrap; }

/* Ablauf: Sprung zum Aufmaß beim Schritt „Besichtigung / Aufmaß vor Ort“ */
.am-zum { white-space: nowrap; }

/* Handy */
@media (max-width: 860px) {
  .am-sprung { top: 57px; }   /* unter dem Kopf des Gerüsts */
  details.am-bereich, #amKarte { scroll-margin-top: 122px; }
  #amToast { bottom: calc(80px + env(safe-area-inset-bottom)); }
}
@media (max-width: 640px) {
  .am-karte { padding: 12px; margin-left: -4px; margin-right: -4px; }
  .am-meta { grid-template-columns: 1fr 1fr; }
  .am-meta .am-feld:last-child { grid-column: 1 / -1; }
  .am-bereich-inhalt { padding: 12px 10px; }
  .am-reihe { grid-template-columns: 1fr 1fr; }
  .am-reihe > .am-feld:only-child { grid-column: 1 / -1; }
  .am-foto, .am-foto-neu { width: calc((100% - 16px) / 3); height: auto; aspect-ratio: 1; }
  .am-skizzen .am-foto, .am-skizzen .am-foto-neu { width: calc((100% - 8px) / 2); height: auto; aspect-ratio: 4 / 3; }
  .am-pos-w { flex: 1 1 calc(50% - 20px); }
  .am-mal { display: none; }
  .am-pos-typen { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
  .am-pos-typen .am-wahl { flex: none; white-space: nowrap; }
  .am-z-w span { display: none; }
  .am-z-w { min-width: 46px; }
  .am-z-rechts { width: 100%; justify-content: flex-end; }
  .am-z-rechts [data-za="zurueck"] { margin-right: auto; }
  .am-z-farben button { width: 32px; height: 32px; }
  .am-z-leiste { gap: 6px; }
}
@media print { .am-tab, .am-karte { display: none !important; } }
