/* BauPilot – gemeinsame Grundlagen. P8: Funktion vor Optik, P7: gut lesbar bei Sonne. */
:root {
  --bg: #f5f4f0; --surface: #ffffff; --surface-2: #efede7; --text: #141414; --muted: #5c5a55; --line: #d6d2c8;
  --primary: #236b87; --primary-ink: #ffffff; --primary-soft: #dcebf2;
  --brand-magenta: #c4007f; --brand-orange: #eb912e; --brand-green: #a0b718; --brand-petrol: #236b87;
  --ok: #15803d; --ok-soft: #dcf5e3; --warn: #a15c07; --warn-soft: #fdf0c8; --bad: #b91c1c; --bad-soft: #fde2e2;
  --info: #1d4ed8; --info-soft: #e0e9fd; --focus: #1d4ed8;
  --radius: 12px; --radius-lg: 18px;
  --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 8px 24px rgb(0 0 0 / .08);
  /* Hausschrift der Website (Greycliff CF) ist lizenzpflichtig – deshalb eine ruhige Systemschrift */
  --font: "Avenir Next", Avenir, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121211; --surface: #1c1c1b; --surface-2: #272725; --text: #f3f2ee; --muted: #aaa79f; --line: #3b3a37;
    --primary: #63b3d1; --primary-ink: #06222d; --primary-soft: #12303c;
    --ok: #4ade80; --ok-soft: #12301d; --warn: #facc15; --warn-soft: #352a08; --bad: #f87171; --bad-soft: #3a1515;
    --info: #93b4fd; --info-soft: #17254a; --focus: #93b4fd;
    color-scheme: dark;
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.45; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .75em; }
a { color: var(--info); }
img { max-width: 100%; }
.muted { color: var(--muted); } .small { font-size: .875rem; } .strong { font-weight: 700; }
.ic { width: 1.25em; height: 1.25em; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.25em; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.hidden { display: none !important; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5em; min-height: 44px; padding: .5em 1em; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; font-weight: 600; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--bad); border-color: currentColor; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { min-height: 34px; padding: .25em .7em; font-size: .875rem; }
.btn.block { width: 100%; }
.btn.icon { padding: .4em; min-width: 44px; }

.chip { display: inline-flex; align-items: center; gap: .35em; padding: .15em .6em; border-radius: 999px; font-size: .8125rem; font-weight: 600; background: var(--surface-2); color: var(--text); white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); } .chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); } .chip.info { background: var(--info-soft); color: var(--info); }
.chip.primary { background: var(--primary-soft); color: var(--text); } .chip.dashed { background: transparent; border: 1px dashed var(--muted); color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1rem; }
.stack > * + * { margin-top: .75rem; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem; }

label.field, .field { display: block; }
.field > span { display: block; font-size: .875rem; font-weight: 600; margin-bottom: .3rem; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time], input[type=search], input[type=month], input:not([type]), select, textarea {
  width: 100%; min-height: 44px; padding: .5em .7em; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
textarea { min-height: 5em; resize: vertical; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--primary); }

.progress { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--ok); border-radius: 999px; }

table.tbl { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.tbl th, .tbl td { padding: .5em .6em; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th { font-size: .8125rem; color: var(--muted); font-weight: 600; background: var(--surface); position: sticky; top: 0; z-index: 1; }
.tbl tr.click { cursor: pointer; } .tbl tr.click:hover td { background: var(--surface-2); }
.tbl td.num, .tbl th.num, .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl input, .tbl select { min-height: 34px; padding: .25em .4em; }

.toast-wrap { position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; flex-direction: column; gap: .5rem; z-index: 1000; width: min(92vw, 480px); pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: .8em 1em; border-radius: 12px; box-shadow: var(--shadow); font-weight: 600; display: flex; gap: .6em; align-items: center; animation: tin .18s ease-out; }
.toast.bad { background: var(--bad); color: #fff; }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }

dialog { border: none; border-radius: var(--radius-lg); padding: 0; background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgb(0 0 0 / .3); width: min(680px, 94vw); max-width: 94vw; }
dialog.wide { width: min(1040px, 96vw); }
dialog::backdrop { background: rgb(0 0 0 / .45); }
.dlg-head { display: flex; align-items: center; gap: .5rem; padding: .9rem 1rem .4rem; }
.dlg-head h2 { margin: 0; flex: 1; }
.dlg-body { padding: .5rem 1rem 1rem; max-height: 72vh; overflow: auto; }
.dlg-foot { display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; padding: .75rem 1rem; border-top: 1px solid var(--line); }

.empty { padding: 2rem 1rem; text-align: center; color: var(--muted); }
.notice { border-left: 4px solid var(--info); background: var(--info-soft); padding: .6em .8em; border-radius: 8px; }
.notice.warn { border-color: var(--warn); background: var(--warn-soft); }
.notice.bad { border-color: var(--bad); background: var(--bad-soft); }
.notice.ok { border-color: var(--ok); background: var(--ok-soft); }
.proto { display: inline-block; font-size: .75rem; padding: .05em .5em; border: 1px dashed var(--muted); border-radius: 6px; color: var(--muted); font-weight: 600; }
.thumbs { display: flex; gap: .5rem; flex-wrap: wrap; }
.thumbs img { width: 84px; height: 84px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
audio { max-width: 100%; height: 40px; }
.update-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 2000; display: flex; gap: 1rem; align-items: center; justify-content: center; flex-wrap: wrap; padding: .6rem 1rem; background: var(--info); color: #fff; font-weight: 600; }
.center-card { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.center-card > .card { width: min(440px, 100%); }
.kbd { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; letter-spacing: .08em; }
.orig { text-decoration: line-through; color: var(--muted); }

/* Unterschriftsfeld */
.sigpad { position: relative; border: 1.5px dashed var(--line, #bbb); border-radius: 12px; background: #fff; overflow: hidden; touch-action: none; }
.sigpad canvas { display: block; touch-action: none; cursor: crosshair; }
.sigpad .sigline { position: absolute; left: 16px; right: 16px; bottom: 34px; border-top: 1px solid #ccc; color: #999; font-size: .75rem; padding-top: 2px; pointer-events: none; }

/* Meldungen innerhalb eines Dialogs (R-33) */
dialog .toast-wrap { position: fixed; }
.dlg-error { margin: 0 0 .75rem; font-weight: 600; }
.field.invalid select, .field.invalid input, select.invalid, input.invalid { outline: 2px solid var(--bad); outline-offset: 1px; }

/* farbenfroh – Logo hell/dunkel und Farbband aus den drei Ringen */
.brand-logo { display: block; height: 34px; width: auto; }
.brand-logo.light-only { display: block; } .brand-logo.dark-only { display: none; }
.brand-dark { display: none; align-items: center; gap: .4rem; font-weight: 700; letter-spacing: .01em; }
@media (prefers-color-scheme: dark) { .brand-logo.light-only { display: none; } .brand-logo.dark-only { display: block; } .brand-dark { display: inline-flex; } }
.brand-band { height: 4px; border-radius: 2px; background: linear-gradient(90deg, var(--brand-magenta) 0 33%, var(--brand-orange) 33% 66%, var(--brand-green) 66%); }
