:root {
  --navy: #1f2f58;
  --blue: #1f4ea3;
  --orange: #e8590c;
  --green: #2b8a3e;
  --red: #c92a2a;
  --bg: #f2f4f7;
  --card: #ffffff;
  --text: #1d2330;
  --muted: #6b7280;
  --line: #dde2e9;
  --radius: 12px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Arial, sans-serif; -webkit-text-size-adjust: 100%; }
a { color: var(--blue); }
h1 { font-size: 22px; margin: 8px 0 16px; }
h3 { font-size: 16px; margin: 0 0 12px; color: var(--navy); }
.muted { color: var(--muted); }
.pad { padding: 16px; }
.block { display: block; }
.hidden { display: none !important; }
.error { color: var(--red); min-height: 1em; }
.nowrap { white-space: nowrap; }
.r { text-align: right; }

/* Kopfzeile */
header.top { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--navy); color: #fff; padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 8px; }
.top-logo { display: block; height: 40px; padding: 4px 8px; border-radius: 8px; background: #fff; flex: none; }
.top-logo img { display: block; height: 32px; width: auto; }
.top-title { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { color: #fff; text-decoration: none; font-size: 32px; line-height: 1; padding: 0 8px; }
.top-nav { display: flex; gap: 4px; width: 100%; overflow-x: auto; }
.top-nav a { color: #cfd8ea; text-decoration: none; padding: 6px 10px; border-radius: 8px; font-size: 14px; white-space: nowrap; }
.top-nav a.on { background: rgba(255, 255, 255, 0.15); color: #fff; }
@media (min-width: 900px) { .top-nav { width: auto; } }
.savebadge { font-size: 12px; padding: 3px 8px; border-radius: 10px; background: rgba(255,255,255,0.15); }
.savebadge.ok { background: rgba(43, 138, 62, 0.8); }
.savebadge.err { background: rgba(201, 42, 42, 0.85); }

.main { max-width: 1100px; margin: 0 auto; padding: 12px 12px calc(110px + var(--safe-b)); }

/* Karten und Formulare */
.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin: 0 0 12px; box-shadow: 0 1px 3px rgba(16, 24, 40, 0.06); }
details.card > summary { cursor: pointer; padding: 2px 0 10px; }
.field { display: block; margin: 0 0 12px; min-width: 0; }
.lbl { display: block; font-size: 13px; color: var(--muted); margin: 0 0 4px; }
input, select, textarea { width: 100%; font: inherit; font-size: 16px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(31, 78, 163, 0.35); border-color: var(--blue); }
input:disabled, select:disabled, textarea:disabled { background: #f5f6f8; color: var(--muted); }
.with-unit { display: flex; align-items: center; }
.with-unit input { border-radius: 10px 0 0 10px; }
.unit { padding: 10px; background: #eef1f5; border: 1px solid var(--line); border-left: 0; border-radius: 0 10px 10px 0; font-size: 14px; color: var(--muted); white-space: nowrap; }
.hint { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; }
.check { display: flex; gap: 10px; align-items: center; margin: 0 0 12px; cursor: pointer; }
.check input { width: 22px; height: 22px; flex: none; }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (min-width: 640px) { .grid2 { grid-template-columns: 1fr 1fr; } .grid3 { grid-template-columns: 1fr 1fr 1fr; } }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0 0 10px; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.row > input[type=search] { flex: 1; min-width: 180px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 10px; padding: 11px 16px; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; background: #e9edf3; color: var(--text); }
.btn.primary { background: var(--orange); color: #fff; }
.btn.danger { background: #fff0f0; color: var(--red); }
.btn.ghost { background: #eef1f6; }
.btn.ghost.on { background: var(--navy); color: #fff; }
.btn.sm { padding: 7px 11px; font-size: 14px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: default; }

.seg { display: inline-flex; background: #e9edf3; border-radius: 10px; padding: 3px; gap: 2px; margin: 0 0 12px; flex-wrap: wrap; }
.seg.wide { display: flex; }
.seg.wide button { flex: 1; }
.seg button { border: 0; background: transparent; padding: 8px 12px; border-radius: 8px; font: inherit; font-size: 14px; cursor: pointer; color: var(--text); }
.seg button.on { background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.12); font-weight: 700; color: var(--navy); }

/* Login */
.login, .center-box { max-width: 380px; margin: 0 auto; padding: 40px 20px; text-align: center; }
.login-logo { width: 100%; max-width: 300px; margin: 0 auto 10px; display: block; }
.login-form { text-align: left; background: #fff; padding: 20px; border-radius: var(--radius); margin-bottom: 14px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }

/* Projektliste */
.plist { display: grid; gap: 10px; }
.prow { display: flex; gap: 8px; align-items: stretch; }
.prow .pcard { flex: 1; min-width: 0; }
.pdel { flex: none; width: 46px; border: 0; border-radius: var(--radius); background: #fff; font-size: 18px; cursor: pointer; box-shadow: 0 1px 3px rgba(16,24,40,0.06); filter: grayscale(1); opacity: 0.7; }
.pdel:hover, .pdel:focus-visible { filter: none; opacity: 1; background: #fff0f0; }
.pcard { display: flex; justify-content: space-between; gap: 10px; background: #fff; border-radius: var(--radius); padding: 14px; text-decoration: none; color: var(--text); box-shadow: 0 1px 3px rgba(16,24,40,0.06); }
.pc-main, .pc-side { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pc-main span { color: var(--muted); font-size: 14px; }
.pc-side { align-items: flex-end; text-align: right; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: #eef1f6; }
.st-angebot { background: #fff4e6; color: #a34400; }
.st-auftrag, .st-steht { background: #ebfbee; color: #237032; }
.st-abgelehnt { background: #fff0f0; color: var(--red); }
.empty { text-align: center; padding: 40px 10px; color: var(--muted); }

/* Tabs */
.tabs { display: flex; gap: 6px; margin: 0 0 12px; position: sticky; top: 88px; z-index: 20; background: var(--bg); padding: 6px 0; }
@media (min-width: 900px) { .tabs { top: 52px; } }
.tabs button { flex: 1; border: 0; background: #fff; border-radius: 10px; padding: 10px 4px; font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tabs button .num { font-size: 11px; width: 20px; height: 20px; border-radius: 50%; background: #e9edf3; display: inline-flex; align-items: center; justify-content: center; }
.tabs button.on { color: #fff; background: var(--navy); }
.tabs button.on .num { background: var(--orange); color: #fff; }

/* Preisleiste */
.pricebar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; display: flex; align-items: center; gap: 10px; padding: 10px 14px calc(10px + var(--safe-b)); background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -2px 10px rgba(0,0,0,0.06); }
.pb-l { flex: 1; display: flex; flex-direction: column; }
.pb-l b { font-size: 20px; color: var(--navy); }
.pb-l small { color: var(--muted); font-size: 12px; }
.ampel { border: 0; border-radius: 20px; padding: 8px 12px; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.ampel.ok { background: #ebfbee; color: var(--green); }
.ampel.warn { background: #fff4e6; color: #c44d00; }
ul.checks { padding-left: 0; list-style: none; margin: 0 0 12px; }
ul.checks li { padding: 8px 10px 8px 34px; border-radius: 8px; margin: 0 0 6px; position: relative; font-size: 14px; }
ul.checks li::before { position: absolute; left: 10px; top: 8px; font-weight: 700; }
ul.checks li.warn { background: #fff4e6; } ul.checks li.warn::before { content: "!"; color: #c44d00; }
ul.checks li.info { background: #eef4ff; } ul.checks li.info::before { content: "i"; color: var(--blue); }
ul.checks li.ok { background: #ebfbee; } ul.checks li.ok::before { content: "✓"; color: var(--green); }

/* Gerüstart / Vorlagen */
.typegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.typecard, .bigchoice { text-align: left; border: 2px solid var(--line); border-radius: 10px; background: #fff; padding: 10px; font: inherit; cursor: pointer; display: flex; flex-direction: column; gap: 3px; color: var(--text); }
.typecard small, .bigchoice small { color: var(--muted); font-size: 12px; }
.typecard.on, .bigchoice.on { border-color: var(--orange); background: #fff7f0; }
.bigchoice { padding: 16px; margin-bottom: 8px; }
.tplgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0 0 12px; }
.tplcard { border: 2px solid var(--line); background: #fff; border-radius: 10px; padding: 6px; font: inherit; font-size: 13px; cursor: pointer; display: flex; flex-direction: column; align-items: center; color: var(--text); }
.tplcard svg { width: 100%; max-width: 70px; height: 50px; }
.tplcard.on { border-color: var(--orange); background: #fff7f0; }
.wing { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin: 0 0 8px; }
.wing summary { cursor: pointer; font-weight: 600; font-size: 14px; margin-bottom: 8px; }

/* Karte */
.map { height: 55vh; min-height: 300px; border-radius: 10px; margin: 0 0 10px; background: #dfe6ee; }
.results { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.result { text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 8px; font: inherit; font-size: 14px; cursor: pointer; }
.vtx { background: #fff; border: 3px solid var(--orange); border-radius: 50%; }

/* Ansichten */
.stage { margin: 0 0 10px; }
.view3d { width: 100%; height: 52vh; min-height: 300px; border-radius: 12px; overflow: hidden; background: #dfe9f3; touch-action: none; }
.view3d.small { height: 300px; min-height: 0; }
svg.plan { width: 100%; height: 52vh; min-height: 300px; background: #fff; border-radius: 12px; display: block; touch-action: manipulation; }
svg.plan.small { height: 300px; }
.previewgrid { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 760px) { .previewgrid { grid-template-columns: 1fr 1fr; } }

.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; }
.chip { flex: none; border: 2px solid transparent; border-radius: 20px; padding: 7px 12px; font: inherit; font-size: 14px; cursor: pointer; background: #fff; white-space: nowrap; }
.chip.st-on { background: #ebfbee; color: #1d5e2b; }
.chip.st-off { background: #fff0f0; color: var(--red); }
.chip.st-neighbor { background: #eceff3; color: #555; }
.chip.sel { border-color: var(--orange); }

.sidepanel .sideinfo { background: #f6f8fb; border-radius: 10px; padding: 10px 12px; margin: 0 0 12px; }
.kv { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; padding: 3px 0; }
.kv span { color: var(--muted); }
.kv.strong { font-size: 16px; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 7px; }
.kv.strong span { color: var(--text); font-weight: 600; }
.stepper { margin: 0 0 12px; }
.stepper .row { margin: 0; flex-wrap: nowrap; }
.stepper b { min-width: 84px; text-align: center; }
.togs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.tog { border: 2px solid var(--line); background: #fff; border-radius: 20px; padding: 7px 12px; font: inherit; font-size: 14px; cursor: pointer; color: var(--text); }
.tog.on { border-color: var(--green); background: #ebfbee; color: #1d5e2b; font-weight: 600; }
.tog.on::before { content: "✓ "; }

/* Fotos */
.photolist { display: grid; gap: 8px; }
.photoitem { display: grid; grid-template-columns: 64px 1fr auto; gap: 10px; align-items: center; }
.photoitem img, .ph-empty { width: 64px; height: 48px; object-fit: cover; border-radius: 6px; background: #eef1f6; display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--muted); }
.photoitem small { display: block; color: var(--muted); }
.photoitem .row { margin: 0; }
.photo-stage { max-height: 65vh; overflow: auto; margin: 0 0 10px; }
.photo-stage canvas { width: 100%; height: auto; display: block; }

/* Angebot */
.tablewrap { overflow-x: auto; }
table.olines { width: 100%; border-collapse: collapse; font-size: 14px; }
table.olines th { text-align: left; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); padding: 6px; }
table.olines td { border-bottom: 1px solid #f0f2f5; padding: 7px 6px; vertical-align: top; }
.sums { max-width: 360px; margin: 12px 0 12px auto; }
.customrow { display: grid; grid-template-columns: 1fr 1fr; gap: 0 8px; align-items: end; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
@media (min-width: 700px) { .customrow { grid-template-columns: 3fr 1fr 1fr 1.4fr auto; } }
.customrow .btn { margin-bottom: 12px; }

/* Benutzer */
.ulist { display: grid; gap: 8px; }
.ucard { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; background: #fff; padding: 12px 14px; border-radius: var(--radius); }
.ucard.inactive { opacity: 0.6; }
.ucard .row { margin: 0; }
.logo-prev { max-height: 60px; max-width: 200px; border: 1px solid var(--line); border-radius: 8px; padding: 4px; background: #fff; }

/* Dialoge, Meldungen */
.modal { position: fixed; inset: 0; z-index: 200; background: rgba(15, 20, 30, 0.5); display: flex; align-items: flex-end; justify-content: center; padding: 0; }
@media (min-width: 640px) { .modal { align-items: center; padding: 20px; } }
.modal-box { background: #fff; width: 100%; max-width: 480px; border-radius: 16px 16px 0 0; padding: 18px 18px calc(18px + var(--safe-b)); max-height: 92vh; overflow-y: auto; }
.modal-box.wide { max-width: 900px; }
@media (min-width: 640px) { .modal-box { border-radius: 16px; } }
.modal-head { font-size: 17px; margin-bottom: 12px; }
.toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translate(-50%, 20px); opacity: 0; z-index: 300; background: #1d2330; color: #fff; padding: 10px 16px; border-radius: 10px; transition: 0.25s; max-width: 90vw; font-size: 14px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--red); }
.toast.ok { background: var(--green); }

/* Druckansicht Angebot */
.printview { position: fixed; inset: 0; z-index: 150; background: #e5e7eb; overflow-y: auto; }
.print-bar { position: sticky; top: 0; display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 10px; background: #fff; border-bottom: 1px solid var(--line); }
.print-bar .muted { font-size: 12px; flex: 1; }
.print-page { background: #fff; max-width: 210mm; margin: 16px auto; padding: 14mm 16mm; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
.quote { font-size: 10.5pt; color: #111; }
.q-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.q-logo { max-width: 60mm; max-height: 26mm; }
.q-company { text-align: right; font-size: 9pt; color: #333; }
.q-addr { margin: 10mm 0 6mm; min-height: 30mm; }
.q-sender { font-size: 7.5pt; color: #666; text-decoration: underline; margin-bottom: 2mm; }
.q-meta { display: flex; gap: 8mm; margin-bottom: 5mm; font-size: 9pt; }
.q-meta div { display: flex; flex-direction: column; }
.q-meta span { color: #666; }
.quote h1 { font-size: 15pt; margin: 2mm 0 3mm; color: #1f2f58; }
.quote h2 { font-size: 13pt; color: #1f2f58; }
.q-table { width: 100%; border-collapse: collapse; font-size: 9.5pt; margin: 3mm 0; }
.q-table th { text-align: left; border-bottom: 1.5px solid #1f2f58; padding: 4px; font-weight: 700; }
.q-table td { border-bottom: 1px solid #e3e6eb; padding: 4px; vertical-align: top; }
.q-table tr.grp td { font-weight: 700; color: #1f2f58; background: #f3f5f8; }
.q-table .note { font-size: 8pt; color: #666; }
.q-table.small { font-size: 9pt; }
.q-sum { margin-left: auto; width: 75mm; border-collapse: collapse; font-size: 10pt; }
.q-sum td { padding: 3px 4px; }
.q-sum tr.tot td { font-weight: 700; border-top: 1.5px solid #1f2f58; font-size: 11pt; }
.q-text { font-size: 9.5pt; color: #222; }
.q-pics { display: grid; grid-template-columns: 1fr 1fr; gap: 6mm; margin: 4mm 0; }
.q-plan svg { width: 100%; height: auto; max-height: 90mm; border: 1px solid #e3e6eb; }
.q-shot { width: 100%; border: 1px solid #e3e6eb; }
.q-foot { margin-top: 8mm; border-top: 1px solid #ccc; padding-top: 2mm; font-size: 7.5pt; color: #666; text-align: center; }
.q-break { break-after: page; }

@media print {
  @page { size: A4; margin: 0; }
  body.printing > *:not(.printview) { display: none !important; }
  body.printing .printview { position: static; background: #fff; overflow: visible; }
  .print-bar { display: none !important; }
  .print-page { box-shadow: none; margin: 0; max-width: none; padding: 14mm 16mm; }
}
@media screen and (max-width: 700px) {
  .print-page { margin: 8px; padding: 6mm 5mm; }
  .quote { font-size: 9pt; }
  .q-table { font-size: 8pt; }
  .q-pics { grid-template-columns: 1fr; }
  .q-logo { max-width: 45mm; }
}

.demo-hint { background: #fff4e6; color: #7a3500; border-radius: 10px; padding: 10px 12px; font-size: 14px; text-align: left; }

/* 1.1: Rollen, Protokolle, automatische Abmeldung, Face ID */
.chip.st-ortgang { border-color: #1c7ed6; color: #1c5fa8; background: #e7f1fc; }
.badge.role-master { background: #1f2f58; color: #fff; }
.badge.role-admin { background: #e7f1fc; color: #1c5fa8; }
.badge.role-user { background: #eef7ee; color: #2b6a33; }
.small { font-size: 13px; }
.grow { flex: 1; }
.idlebar { position: fixed; left: 12px; right: 12px; bottom: calc(84px + var(--safe-b)); z-index: 140; border: 0; border-radius: 12px; padding: 12px 14px;
  background: #fff4e6; color: #7a3500; font: inherit; font-weight: 600; box-shadow: 0 4px 16px rgba(0,0,0,0.18); cursor: pointer; }
.notice { background: #e7f1fc; color: #1c3d6e; border-radius: 10px; padding: 10px 12px; font-size: 14px; text-align: left; }
.facebox { margin: 0 0 6px; }
.facebox .error { margin: 6px 0 0; font-size: 14px; }
.btn.face { padding: 14px 16px; font-size: 17px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 12px 0 10px; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.loglist { background: #fff; border-radius: var(--radius); padding: 4px 12px; box-shadow: 0 1px 3px rgba(16,24,40,0.06); margin: 8px 0; }
.logday { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; padding: 12px 0 4px; }
.logrow { display: flex; gap: 12px; padding: 8px 0; border-top: 1px solid #f0f2f5; font-size: 14px; }
.logrow small { display: block; }
.logtime { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 42px; }
.logrow.ok .logtime { color: var(--green); }
.logrow.warn { color: var(--red); }
.errrow { white-space: pre-wrap; word-break: break-word; font-size: 12px; line-height: 1.35; margin: 0; padding: 8px 0; border-top: 1px solid #f0f2f5; }
.print-bar .grow { font-size: 13px; }
@media (max-width: 520px) { .print-bar .grow { display: none; } }
.expiry { color: var(--muted); font-size: 12px; }
.expiry.soon { color: var(--red); font-weight: 700; }
.standrow { border: 1px solid var(--line, #e3e6eb); border-radius: 10px; padding: 8px 10px 0; margin: 6px 0; background: #fafbfc; }
.standrow select { max-width: 70%; }
.standrow .grid3 { grid-template-columns: 1fr 1fr 1fr; gap: 0 8px; }
.standrow .field .lbl { font-size: 12px; }

.logintext { font-size: 14px; margin: 8px 0; }
.row.wrap { flex-wrap: wrap; }
