/* Fristsicher – Betongrau und Signalorange, große Tasten für Arbeitshandschuhe */
:root {
  --bg: #ecebe6;
  --surface: #ffffff;
  --surface-2: #f5f4f0;
  --ink: #1d2124;
  --muted: #5e646a;
  --line: #d6d3cc;
  --accent: #d9480f;
  --accent-ink: #b33c0b;
  --on-accent: #ffffff;
  --na: #d9480f;
  --bh: #2f6690;
  --bd: #9a6400;
  --ok: #2f7d4f; --ok-bg: #e3f1e8;
  --warn: #8a5a00; --warn-bg: #fbefd4;
  --danger: #b3261e; --danger-bg: #fbe3e1;
  --done: #4d5358; --done-bg: #e6e6e3;
  --paper: #ffffff;
  --shadow: 0 1px 2px rgba(29, 33, 36, .06), 0 6px 20px rgba(29, 33, 36, .06);
  --display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --body: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #141719; --surface: #1e2225; --surface-2: #262b2f; --ink: #eef0f1; --muted: #a3aab0; --line: #353b40;
    --accent: #ff7a33; --accent-ink: #ff9a5e; --on-accent: #1a0d05;
    --na: #ff8a4c; --bh: #6fb0e0; --bd: #e0a93a;
    --ok: #7fd3a0; --ok-bg: #1d3327; --warn: #f0c46a; --warn-bg: #3a2e14; --danger: #ff8f86; --danger-bg: #3d1f1d; --done: #b9bec2; --done-bg: #2b3034;
    --paper: #f7f6f2; --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141719; --surface: #1e2225; --surface-2: #262b2f; --ink: #eef0f1; --muted: #a3aab0; --line: #353b40;
  --accent: #ff7a33; --accent-ink: #ff9a5e; --on-accent: #1a0d05;
  --na: #ff8a4c; --bh: #6fb0e0; --bd: #e0a93a;
  --ok: #7fd3a0; --ok-bg: #1d3327; --warn: #f0c46a; --warn-bg: #3a2e14; --danger: #ff8f86; --danger-bg: #3d1f1d; --done: #b9bec2; --done-bg: #2b3034;
  --paper: #f7f6f2; --shadow: 0 1px 2px rgba(0, 0, 0, .3);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 17px/1.5 var(--body); padding-bottom: env(safe-area-inset-bottom, 0px); }
[hidden] { display: none !important; }
img { max-width: 100%; display: block; }
a { color: var(--accent-ink); }
h1, h2, h3 { text-wrap: balance; margin: 0; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }

/* Kopfzeile */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 10px; background: var(--bg); border-bottom: 1px solid var(--line); }
.topbar-title { flex: 1; min-width: 0; }
.topbar h1 { font: 700 24px/1.1 var(--display); letter-spacing: .01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar p { margin: 2px 0 0; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-mark { width: 12px; height: 34px; background: repeating-linear-gradient(-45deg, var(--accent) 0 6px, var(--ink) 6px 12px); border-radius: 3px; flex: none; }
.iconbtn { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; height: 44px; border-radius: 10px; color: var(--ink); text-decoration: none; }
.iconbtn:active { background: var(--surface-2); }
.iconbtn.text { font-weight: 600; font-size: 15px; padding: 0 8px; color: var(--accent-ink); }

.content { max-width: 680px; margin: 0 auto; padding: 18px 16px 120px; display: flex; flex-direction: column; gap: 26px; }
.section-title { font: 700 20px/1.2 var(--display); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 10px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.link { font-weight: 600; text-decoration: none; }
.link.small { display: block; text-align: center; font-size: 15px; padding: 10px; cursor: pointer; }

/* Kennzahlen */
.stats { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.stat { background: var(--surface); padding: 14px 12px; display: flex; flex-direction: column; gap: 2px; }
.stat-num { font: 700 26px/1.05 var(--display); font-variant-numeric: tabular-nums; }
.stat-label { font-size: 13px; color: var(--muted); line-height: 1.25; }
.stat.is-alert .stat-num { color: var(--danger); }
@media (max-width: 420px) { .stats { grid-template-columns: 1fr 1fr; } .stat:first-child { grid-column: 1 / -1; } }

/* Listen */
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.row { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: start; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); color: var(--ink); text-decoration: none; }
.row:not(:has(.typetag)) { grid-template-columns: 1fr auto; }
.row:active { background: var(--surface-2); }
.row.report { grid-template-columns: auto 1fr; }
.row.report .row-side { grid-column: 2; flex-direction: row; align-items: center; justify-content: space-between; text-align: left; }
.row-main { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.row-main strong { font-weight: 600; }
.row-main .muted { font-size: 14px; }
.row-desc { font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; text-align: right; }
.count { font-size: 14px; color: var(--muted); }
.amount { font-weight: 700; font-variant-numeric: tabular-nums; }

.typetag { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 8px; font: 700 17px/1 var(--display); letter-spacing: .04em; color: #fff; }
.t-nachtrag.typetag, .typetag.t-nachtrag { background: var(--na); }
.typetag.t-behinderung { background: var(--bh); }
.typetag.t-bedenken { background: var(--bd); }
:root[data-theme="dark"] .typetag { color: #121416; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .typetag { color: #121416; } }

.chip { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.tone-neutral { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.tone-warn { background: var(--warn-bg); color: var(--warn); }
.tone-ok { background: var(--ok-bg); color: var(--ok); }
.tone-danger { background: var(--danger-bg); color: var(--danger); }
.tone-done { background: var(--done-bg); color: var(--done); }

.empty { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--r); padding: 22px; display: flex; flex-direction: column; gap: 14px; align-items: flex-start; }
.empty p { margin: 0; color: var(--muted); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 48px; padding: 10px 18px; border-radius: 10px; border: 1px solid transparent; font: 600 17px/1.2 var(--body); text-decoration: none; cursor: pointer; color: var(--ink); background: transparent; }
.btn-lg { min-height: 58px; font-size: 19px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:active { filter: brightness(.92); }
.btn-secondary { background: var(--surface); border-color: var(--line); }
.btn-secondary:active { background: var(--surface-2); }
.btn-ghost { color: var(--accent-ink); }
.btn-ghost.danger, .danger { color: var(--danger); }
.btn-danger { background: var(--danger); color: #fff; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row-btns { display: flex; flex-wrap: wrap; gap: 10px; }

.bottombar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; padding: 12px 16px calc(env(safe-area-inset-bottom, 0px) + 12px); background: linear-gradient(to top, var(--bg) 70%, transparent); }
.bottombar > * { max-width: 648px; margin: 0 auto; display: flex; }

/* Willkommen */
.welcome { display: flex; flex-direction: column; gap: 18px; padding-top: 8px; }
.eyebrow { margin: 0; font-size: 14px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--accent-ink); }
.display { font: 700 clamp(38px, 10vw, 56px)/.98 var(--display); letter-spacing: -.005em; }
.lead { margin: 0; font-size: 18px; max-width: 60ch; }
.steps { list-style: none; counter-reset: s; margin: 0; padding: 0; display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.steps li { counter-increment: s; background: var(--surface); padding: 14px 14px 14px 58px; position: relative; display: flex; flex-direction: column; }
.steps li::before { content: counter(s); position: absolute; left: 14px; top: 13px; width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: var(--bg); font: 700 17px/30px var(--display); text-align: center; }
.steps span { color: var(--muted); font-size: 15px; }

/* Formulare */
.form { display: flex; flex-direction: column; gap: 22px; }
fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
legend { font: 700 20px/1.2 var(--display); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 12px; padding: 0; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field .label { font-weight: 600; font-size: 16px; }
.opt { font-weight: 400; color: var(--muted); font-size: 14px; }
input[type=text], input[type=email], input[type=tel], input[type=number], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; min-height: 52px; padding: 12px 14px; font: 400 17px/1.4 var(--body); color: var(--ink); background: var(--surface); border: 1.5px solid var(--line); border-radius: 10px; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.help { margin: 0; font-size: 14px; color: var(--muted); }
.error { margin: 0; padding: 12px 14px; border-radius: 10px; background: var(--danger-bg); color: var(--danger); font-weight: 600; }
.note { margin: 0; padding: 12px 14px; border-left: 4px solid var(--accent); background: var(--surface-2); border-radius: 0 10px 10px 0; font-size: 15px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 480px) { .grid2 { grid-template-columns: 1fr; } }
.check { display: flex; gap: 12px; align-items: center; font-weight: 500; min-height: 44px; }
.check input { width: 24px; height: 24px; accent-color: var(--accent); }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: flex; flex-direction: column; justify-content: center; min-height: 56px; padding: 8px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface); font-weight: 600; cursor: pointer; line-height: 1.2; }
.seg small { font-weight: 400; color: var(--muted); font-size: 13px; margin-top: 2px; }
.seg input:checked + span { border-color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.seg input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }

.block { display: flex; flex-direction: column; gap: 14px; }
.block-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.block-head h2 { font: 700 22px/1.15 var(--display); }
.block-head .muted { font-size: 14px; }

.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.thumb { position: relative; margin: 0; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--surface-2); max-width: 100%; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb figcaption { position: absolute; left: 6px; bottom: 6px; background: rgba(0,0,0,.6); color: #fff; font-size: 12px; font-weight: 700; padding: 1px 7px; border-radius: 99px; }
.thumb-del { position: absolute; top: 4px; right: 4px; width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.thumb-del svg { width: 18px; height: 18px; }

.dictate { position: relative; }
.dictate textarea { padding-bottom: 68px; min-height: 170px; }
.btn-mic { position: absolute; right: 10px; bottom: 10px; min-height: 48px; background: var(--ink); color: var(--bg); border-radius: 999px; padding: 8px 18px; }
.btn-mic.is-live { background: var(--danger); color: #fff; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--danger) 25%, transparent); } }
@media (prefers-reduced-motion: reduce) { .btn-mic.is-live { animation: none; } }

/* Projekt */
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.facts > div { background: var(--surface); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.facts .k { font-size: 13px; color: var(--muted); }
.facts .v { overflow-wrap: anywhere; }
.facts .v.strong { font: 700 24px/1.1 var(--display); font-variant-numeric: tabular-nums; }
.picker { display: flex; flex-direction: column; gap: 8px; scroll-margin-top: 80px; }
.pick { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; align-items: center; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); text-decoration: none; color: var(--ink); }
.pick > span:nth-child(2) { display: flex; flex-direction: column; }
.pick strong { font-size: 18px; }
.pick .muted { font-size: 15px; }
.pick .para { grid-column: 2; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pick:active { background: var(--surface-2); }

/* Schreiben */
.status-line { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; font-size: 15px; }
.paper { background: var(--paper); color: #1d2124; border-radius: 4px; padding: 26px 22px; box-shadow: var(--shadow); border-top: 6px solid #d9480f; font-size: 15px; line-height: 1.55; }
.paper p { margin: 0 0 12px; max-width: 65ch; }
.paper h3 { font: 700 22px/1.15 var(--display); margin: 18px 0 4px; }
.paper .bv { font-weight: 700; }
.paper .indent { display: inline-block; padding-left: 12px; border-left: 2px solid #e2ded6; }
.paper .muted { color: #5e646a; }
.paper-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 18px; }
.paper-head span { font-size: 13px; color: #5e646a; }
.paper-meta { display: flex; justify-content: space-between; gap: 16px; font-size: 14px; }
.paper-meta .right { text-align: right; font-variant-numeric: tabular-nums; }
.paper-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-top: 12px; border-top: 1px solid #e2ded6; padding-top: 14px; }
.paper-photos figure { margin: 0; }
.paper-photos figcaption { font-size: 12px; color: #5e646a; margin-top: 4px; }
.confirm { background: var(--surface); border: 1.5px solid var(--accent); border-radius: var(--r); padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.confirm p { margin: 0; }
.mailhelp { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 4px 14px; }
.mailhelp summary { font-weight: 600; padding: 12px 0; cursor: pointer; }
.mailhelp[open] { padding-bottom: 14px; display: flex; flex-direction: column; gap: 10px; }
.mailhelp[open] > * + * { margin-top: 10px; }
.sel { user-select: all; -webkit-user-select: all; font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.mailbody { white-space: pre-wrap; font: 400 14px/1.5 var(--body); background: var(--surface-2); padding: 12px; border-radius: 8px; margin: 0; user-select: text; -webkit-user-select: text; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 2px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.timeline li { position: relative; font-size: 15px; }
.timeline li::before { content: ""; position: absolute; left: -22px; top: 8px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.timeline .muted { font-variant-numeric: tabular-nums; margin-right: 6px; }
.hash { font-family: ui-monospace, Menlo, monospace; font-size: 11px; overflow-wrap: anywhere; }
.danger-zone { display: flex; flex-wrap: wrap; gap: 8px; border-top: 1px solid var(--line); padding-top: 14px; }
.danger-zone .confirm { width: 100%; border-color: var(--danger); }

#toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 96px); transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 10px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 20; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
