/* Grundbauteile für alle Entwürfe. Farben, Schriften und Aufbau legt jeder Entwurf über Variablen fest:
   --bg --card --panel --text --muted --line --accent --on-accent --accent-bg --good --bad --r --r-s --font --head --num --shadow */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; line-height: 1.55; font-variant-numeric: tabular-nums; }
h1, h2, h3, h4 { font-family: var(--head); line-height: 1.2; margin: 0; text-wrap: balance; }
p { margin: 0; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.klein { font-size: 13.5px; color: var(--muted); margin-top: 8px; }
.intro { color: var(--muted); margin-bottom: 14px; max-width: 70ch; }
.neg { color: var(--bad) !important; }

/* Knöpfe */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px; border-radius: var(--r-s); border: 1px solid var(--line); background: var(--card); color: var(--text); font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--accent); }
.btn.prim { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.prim:hover { filter: brightness(1.08); }
.btn.link { min-height: 0; padding: 0; border: 0; background: none; color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.btn:disabled { opacity: .55; cursor: wait; }

/* Felder */
.fld { margin-bottom: 16px; }
.fld-l { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; margin-bottom: 6px; }
.fld-in { position: relative; display: flex; align-items: stretch; }
.fld-in input, .fld select, .fld textarea, .fld-in select { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--card); font-size: 16px; }
.fld textarea { min-height: 0; resize: vertical; }
.fld-in input { padding-right: 46px; }
.fld-in .fld-u { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; font-size: 15px; }
.fld-in.monat { gap: 8px; }
.fld-in.monat select { flex: 1.6; }
.fld-in.monat input { flex: 1; padding-right: 12px; }
.fld input:focus, .fld select:focus, .fld textarea:focus { border-color: var(--accent); outline: 2px solid color-mix(in srgb, var(--accent) 30%, transparent); outline-offset: 0; }
.fld.bad input { border-color: var(--bad); }
.fld-err { color: var(--bad); font-size: 13.5px; margin-top: 4px; }
.fld-h { font-size: 14px; color: var(--muted); margin-top: 6px; padding: 8px 10px; background: var(--panel); border-radius: var(--r-s); }
.ibtn { flex: none; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--muted); background: none; color: var(--muted); font-size: 12px; font-weight: 700; font-style: italic; font-family: Georgia, serif; line-height: 1; cursor: pointer; padding: 0; }
.ibtn[aria-expanded="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.fld-chk { margin-bottom: 14px; display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
.fld-chk label { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; flex: 1; }
.fld-chk input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.fld-chk .fld-h { flex-basis: 100%; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { flex: 1 1 auto; min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--card); cursor: pointer; font-size: 15px; hyphens: manual; }
.seg button[aria-checked="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.kurz-note { font-size: 14px; color: var(--muted); padding-top: 4px; }

/* Wert-Schätzung */
.ws-zahl { display: flex; flex-direction: column; gap: 2px; }
.ws-l { font-size: 14px; color: var(--muted); font-weight: 600; }
.ws-mitte { font-family: var(--num); font-size: clamp(30px, 5vw, 42px); line-height: 1.1; letter-spacing: -.01em; }
.ws-sp { color: var(--muted); font-size: 15px; }
.ws-bar { position: relative; height: 10px; border-radius: 99px; background: var(--panel); margin: 14px 0 6px; }
.ws-fill { position: absolute; inset: 0; border-radius: 99px; background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 25%, transparent), var(--accent), color-mix(in srgb, var(--accent) 25%, transparent)); }
.ws-pin { position: absolute; top: -5px; width: 4px; height: 20px; margin-left: -2px; border-radius: 2px; background: var(--text); }
.ws-eigen { font-size: 15px; }
.ws-wie { margin-top: 12px; }
.ws-wie summary, details > summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.ws-wie .tbl { margin-top: 10px; }

/* Tabellen */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -2px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl th, .tbl td { padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th { font-size: 13px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.tbl td:last-child, .tbl th:last-child { text-align: right; }
.tbl.zahlen td:not(:first-child), .tbl.zahlen th:not(:first-child) { text-align: right; white-space: nowrap; }
.tbl tr.sum td { font-weight: 700; border-bottom: 0; }
.tbl tr.jetzt td { background: var(--accent-bg); font-weight: 600; }
.tbl .plus { color: var(--good); } .tbl .minus { color: var(--bad); }
.z-note { display: block; font-size: 12.5px; color: var(--muted); font-weight: 400; }

/* Abrechnung */
.zettel { width: 100%; border-collapse: collapse; }
.zettel td { padding: 10px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.zettel .z-b { text-align: right; white-space: nowrap; padding-left: 12px; font-family: var(--num); }
.zettel .z-minus .z-b { color: var(--muted); }
.zettel .z-zw td { font-weight: 600; border-top: 1px solid var(--text); }
.zettel .z-sum td { font-weight: 800; font-size: 1.2em; border-top: 2px solid var(--text); border-bottom: 0; padding-top: 12px; }
.zettel .z-sum .z-b { color: var(--accent); }
.zettel .z-sum.neg .z-b { color: var(--bad); }

/* Wasserfall (vom Preis zum Rest) */
.wf { display: grid; gap: 8px; }
.wf-r { display: grid; grid-template-columns: minmax(92px, 9.5em) 1fr auto; align-items: center; gap: 10px; font-size: 14.5px; }
.wf-l { color: var(--muted); }
.wf-t { position: relative; height: 22px; background: var(--panel); border-radius: 4px; }
.wf-b { position: absolute; top: 0; bottom: 0; border-radius: 4px; background: var(--accent); }
.wf-r.minus .wf-b { background: color-mix(in srgb, var(--bad) 70%, var(--card)); }
.wf-r.sum .wf-b { background: var(--good); }
.wf-r.sum.neg .wf-b { background: var(--bad); }
.wf-r.sum .wf-l, .wf-r.sum .wf-v { font-weight: 700; color: var(--text); }
.wf-v { text-align: right; white-space: nowrap; font-family: var(--num); min-width: 7.5em; }
@media (max-width: 520px) { .wf-r { grid-template-columns: 1fr auto; } .wf-t { grid-column: 1 / -1; grid-row: 2; height: 14px; } }

/* Kacheln */
.kacheln { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.kachel { padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r); background: var(--card); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.k-l { font-size: 13.5px; color: var(--muted); font-weight: 600; }
.k-w { font-family: var(--num); font-size: 22px; line-height: 1.2; overflow-wrap: anywhere; }
.k-s { font-size: 13px; color: var(--muted); }
.kachel.haupt { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.kachel.haupt .k-l, .kachel.haupt .k-s { color: inherit; opacity: .85; }
.kachel.haupt.neg { background: var(--bad); border-color: var(--bad); color: #fff; }
.kacheln.klein { margin-top: 14px; }

.hinweise { margin: 0; padding-left: 20px; display: grid; gap: 8px; }

/* Reiter */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; margin-bottom: 18px; scrollbar-width: none; }
.tabs [role=tab] { flex: none; min-height: 42px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 99px; background: var(--card); cursor: pointer; font-weight: 600; font-size: 15px; }
.tabs [role=tab][aria-selected="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.tabp .fld { max-width: 360px; }

/* Checkliste */
.check { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 18px; }
.check label { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.check input:checked + span { color: var(--muted); text-decoration: line-through; }

/* Begriffe */
.begriff { border-bottom: 1px solid var(--line); padding: 10px 0; }
.begriff summary { color: var(--text); }
.begriff p { margin-top: 6px; color: var(--muted); }

/* KI */
.drop { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 22px 16px; border: 2px dashed var(--line); border-radius: var(--r); background: var(--panel); cursor: pointer; text-align: center; }
.drop:hover, .drop.ueber { border-color: var(--accent); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop-t b { color: var(--accent); }
.drop-s { font-size: 13.5px; color: var(--muted); }
.ki-dateien { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 4px; font-size: 14.5px; }
.ki-dateien li { display: flex; justify-content: space-between; gap: 10px; }
.ki-dateien li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ki-text { margin: 12px 0; }
.ki-text textarea { width: 100%; margin-top: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--card); resize: vertical; }
.ki-schutz { margin: 10px 0 14px; }
.ki-status { font-size: 14.5px; color: var(--muted); margin-left: 6px; }
.ki-res { margin-top: 16px; padding: 14px 16px; border-left: 3px solid var(--accent); background: var(--accent-bg); border-radius: 0 var(--r-s) var(--r-s) 0; }
.ki-res h4 { font-size: 15px; margin: 10px 0 6px; } .ki-res h4:first-child { margin-top: 0; }
.ki-res ul { margin: 0 0 10px; padding-left: 20px; }
.ki-res p + p { margin-top: 8px; }
.ki-neu { list-style: none; padding: 0 !important; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 4px 16px; }
.ki-neu li { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px dashed var(--line); padding: 3px 0; }
.ki-neu li span { color: var(--muted); }
.ins-ausgabe { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-s); padding: 14px; margin-bottom: 10px; white-space: normal; }
.ins-ausgabe p:first-child { font-weight: 700; }

/* Anfrage */
.anf-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0 16px; }
.fld input[type=file] { min-height: 0; padding: 8px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.ok-box { padding: 16px; border-radius: var(--r); background: var(--accent-bg); }

/* Einstellungen */
.einst { position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; width: 270px; padding: 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--card); box-shadow: var(--shadow); }
.einst fieldset { border: 0; padding: 0; margin: 0 0 12px; }
.einst legend { font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.einst .seg button { min-height: 36px; font-size: 14px; padding: 6px 8px; }
.farben { display: flex; gap: 8px; flex-wrap: wrap; }
.farbe { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--line); padding: 3px; background: none; cursor: pointer; }
.farbe span { display: block; width: 100%; height: 100%; border-radius: 50%; }
.farbe[aria-pressed="true"] { border-color: var(--text); }
.zahnrad { width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: 50%; border: 1px solid var(--line); background: var(--card); cursor: pointer; color: var(--text); }
.zahnrad svg { width: 20px; height: 20px; }

/* Meldung */
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 100; display: flex; gap: 14px; align-items: center; max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: var(--r); background: var(--text); color: var(--bg); box-shadow: var(--shadow); font-size: 15px; transition: opacity .3s; }
.toast .btn.link { color: var(--bg); }
.toast.weg { opacity: 0; }

/* Leiste am Handy */
.mbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px max(16px, env(safe-area-inset-left, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)); background: var(--card); border-top: 1px solid var(--line); box-shadow: 0 -6px 20px -12px rgba(0,0,0,.3); transform: translateY(110%); transition: transform .25s; }
.mbar.an { transform: none; }
.mbar b { font-family: var(--num); font-size: 20px; }
.mbar span { font-size: 13px; color: var(--muted); display: block; }
@media (min-width: 981px) { .mbar { display: none; } }
@media print { .mbar, .toast, .zahnrad, .einst { display: none !important; } }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; } }
