:root {
  --bg: #E9ECEE; --surface: #FFFFFF; --ink: #1E2A33; --muted: #5E6B74; --line: #C9D0D5;
  --signal: #F5B700; --signal-ink: #1E2A33; --done: #2E6B4F; --danger: #A3322A; --track: #D5DADE;
  --font: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --cond: 'Barlow Condensed', 'Arial Narrow', var(--font);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #151C21; --surface: #1E272E; --ink: #E6EAED; --muted: #94A1AA; --line: #34414A;
          --track: #2C373F; --done: #5FB28A; --danger: #E07A70; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 1rem/1.5 var(--font);
       padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0); }
a { color: inherit; }
h1, h2, h3 { font-family: var(--cond); font-weight: 700; line-height: 1.1; margin: 0 0 .5rem; letter-spacing: .01em; }
h1 { font-size: 2.2rem; } h2 { font-size: 1.45rem; } h3 { font-size: 1.15rem; margin-top: 1.25rem; }
p { margin: 0 0 .5rem; }
small, .small { font-size: .85rem; }
.muted, small { color: var(--muted); }
:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; }

/* Kopfzeile */
.top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
       padding: .75rem 1.25rem; background: var(--ink); color: var(--bg); }
.brand { font: 700 1.35rem var(--cond); text-decoration: none; }
.top nav { display: flex; flex-wrap: wrap; gap: .35rem 1.1rem; align-items: center; }
.top nav a, .top nav button { white-space: nowrap; }
.top nav a { text-decoration: none; font-weight: 500; }
.top nav a:hover { text-decoration: underline; }
.top form { margin: 0; }
button.link { background: none; border: 0; color: inherit; font: inherit; font-weight: 500; padding: 0; cursor: pointer; }

main { max-width: 1100px; margin: 0 auto; padding: 1.25rem; }
.narrow { max-width: 30rem; margin: 1.5rem auto; }
.head-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }

/* Formulare */
input, textarea, select { font: inherit; color: var(--ink); background: var(--surface); width: 100%;
  border: 1px solid var(--line); border-radius: 4px; padding: .55rem .65rem; }
textarea { resize: vertical; }
label { display: block; font-weight: 500; }
label > input, label > textarea, label > select { margin-top: .25rem; font-weight: 400; }
.check-label { display: flex; gap: .5rem; align-items: center; font-weight: 400; }
.check-label input { width: auto; }
fieldset { border: 1px solid var(--line); border-radius: 4px; padding: .75rem 1rem; margin: 0; }
legend { font-weight: 600; padding: 0 .3rem; }
.stack { display: grid; gap: .6rem; margin: .5rem 0 1rem; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; }
.row > * { flex: 1 1 8rem; }
.row > button { flex: 0 0 auto; }
.num { max-width: 8rem; }
form.inline { display: inline; margin: 0; }
button, .btn { font: 600 1rem var(--font); background: var(--ink); color: var(--bg); border: 0; border-radius: 4px;
  padding: .6rem 1rem; cursor: pointer; text-decoration: none; display: inline-block; }
button:hover, .btn:hover { opacity: .9; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }
button.del { background: none; color: var(--muted); padding: 0 .35rem; font-size: .85rem; }
button.del:hover { color: var(--danger); }
button.danger { background: var(--danger); color: #fff; }
.danger-zone { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.code { font: 600 1.8rem var(--cond); letter-spacing: .3em; text-align: center; }
.qr { background: #fff; padding: 12px; width: max-content; margin: 1rem 0; }
.secret code { font-size: .95rem; word-break: break-all; }

.flash { padding: .7rem 1rem; border-radius: 4px; border-left: 5px solid var(--done); background: var(--surface); }
.flash.err { border-color: var(--danger); }
.empty { color: var(--muted); font-style: italic; }

/* Fortschritt: Absperrband als Füllung */
.progress { height: 10px; background: var(--track); border-radius: 2px; overflow: hidden; }
.progress .fill { height: 100%; background: var(--signal); }
.progress.big { height: 34px; border-radius: 3px; margin-top: 1rem; }
.progress.big .fill {
  background: repeating-linear-gradient(-45deg, var(--signal) 0 18px, var(--signal-ink) 18px 36px);
  box-shadow: inset 0 0 0 2px var(--signal-ink);
}
.progress.big .fill[style="width:100%"] { background: var(--done); box-shadow: none; }

/* Projektliste */
.plist, .ulist, .tasks, .files, .timeline { list-style: none; margin: 0; padding: 0; }
.plist { display: grid; gap: 2px; background: var(--line); border: 1px solid var(--line); }
.plist li { background: var(--surface); }
.plist a { display: grid; grid-template-columns: 1fr auto; gap: .2rem 1rem; padding: 1rem 1.1rem; text-decoration: none; }
.plist .ptitle { font: 700 1.3rem var(--cond); grid-column: 1; grid-row: 1; }
.plist .ppct { font: 700 1.3rem var(--cond); grid-column: 2; grid-row: 1 / 3; align-self: center; }
.plist .pmeta { color: var(--muted); font-size: .9rem; grid-column: 1; grid-row: 2; }
.plist .progress { grid-column: 1 / -1; grid-row: 3; margin-top: .4rem; }
.archived { opacity: .55; }
.ulist li { padding: .6rem 0; border-bottom: 1px solid var(--line); }
.ulist a { font-weight: 600; margin-right: .5rem; }

/* Projektkopf */
.hero { display: grid; grid-template-columns: 1fr auto; gap: 1rem; align-items: end;
        background: var(--surface); padding: 1.4rem; border-top: 6px solid var(--ink); margin-bottom: 1rem; }
.hero .progress, .hero .tools { grid-column: 1 / -1; }
.hero-text p { max-width: 65ch; }
.hero-status { text-align: right; }
.pct { display: block; font: 700 4.5rem/0.9 var(--cond); }
.pct small { font-size: 2rem; color: inherit; }
.state { font-weight: 600; }
.tools { margin: .5rem 0 0; font-size: .9rem; }

/* Einsatz: Adresse + Stempeluhr */
.field-bar { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between;
             background: var(--surface); padding: 1rem 1.4rem; margin-bottom: 1rem; }
.addr { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.stamp-form { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; flex: 1 1 18rem; justify-content: flex-end; margin: 0; }
.stamp-form input { flex: 1 1 12rem; }
.stamp { font-size: 1.1rem; padding: .8rem 1.4rem; }
.stamp.in { background: var(--done); color: #fff; }
.stamp.out { background: var(--signal); color: var(--signal-ink); }
.running { font-weight: 600; }
.clock-banner { background: var(--signal); color: var(--signal-ink); padding: .6rem 1rem; margin-bottom: 1rem; font-weight: 500; border-radius: 4px; }

/* Auftragsbestätigung */
.order { background: var(--surface); padding: 1.2rem 1.4rem; margin-bottom: 1rem; }
.order.pending { border: 3px solid var(--signal); }
.order.done summary { cursor: pointer; font-weight: 600; color: var(--done); }
.order details summary { cursor: pointer; font-weight: 600; }
.terms { display: grid; grid-template-columns: 9rem 1fr; gap: .5rem 1rem; margin: 1rem 0; }
.terms dt { font-weight: 600; color: var(--muted); }
.terms dd { margin: 0; max-width: 65ch; }
.legal { background: var(--bg); padding: .9rem 1.1rem; border-left: 4px solid var(--ink); max-width: 75ch; }
.legal h3 { margin-top: 0; }
.legal p { font-size: .95rem; }
button.confirm { background: var(--done); color: #fff; font-size: 1.05rem; padding: .8rem 1.3rem; justify-self: start; }
@media (max-width: 760px) { .terms { grid-template-columns: 1fr; gap: .1rem; } .terms dd { margin-bottom: .6rem; } }

/* Spalten & Blöcke */
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
.col { display: grid; gap: 1rem; }
.block { background: var(--surface); padding: 1.2rem 1.4rem; }
.block.internal { border-left: 5px solid var(--signal); }
.count { font: 600 1rem var(--font); color: var(--muted); margin-left: .3rem; }

.timeline { border-left: 2px solid var(--line); margin-left: .35rem; }
.timeline li { position: relative; padding: 0 0 1rem 1.2rem; }
.timeline li::before { content: ''; position: absolute; left: -7px; top: .35rem; width: 12px; height: 12px;
                       border-radius: 50%; background: var(--surface); border: 2px solid var(--ink); }
.timeline li:first-child::before { background: var(--signal); }
.timeline li form.inline { position: absolute; right: 0; top: 0; }
.timeline li p { padding-right: 1.5rem; }
.timeline time { font-size: .85rem; color: var(--muted); }

.tasks li { display: flex; align-items: center; gap: .6rem; padding: .35rem 0; border-bottom: 1px solid var(--line); }
.tasks .ttl { flex: 1; }
.tasks li.done .ttl { text-decoration: line-through; color: var(--muted); }
.check { width: 1.6rem; height: 1.6rem; padding: 0; display: inline-grid; place-items: center; border-radius: 3px;
         background: transparent; color: var(--done); border: 2px solid var(--line); font-weight: 700; }
.tasks li.done .check { border-color: var(--done); }

.note, .comment { padding: .7rem 0; border-bottom: 1px solid var(--line); }
.note footer, .comment footer { font-size: .85rem; color: var(--muted); }
.comment.from-customer { padding-left: .8rem; border-left: 3px solid var(--signal); }
.note a { word-break: break-all; }

.files li { padding: .45rem 0; border-bottom: 1px solid var(--line); }
.files small { display: block; }

.price .total { font: 700 3rem/1 var(--cond); margin: .3rem 0 .8rem; }
table { width: 100%; border-collapse: collapse; }
td { padding: .4rem 0; border-bottom: 1px solid var(--line); vertical-align: top; }
td:last-child { text-align: right; white-space: nowrap; }
.sum td:last-child { font-variant-numeric: tabular-nums; }
.manual { margin-top: 1rem; }
.manual summary { cursor: pointer; font-weight: 600; }

@media (max-width: 760px) {
  .cols { grid-template-columns: 1fr; }
  h1 { font-size: 1.8rem; }
  .pct { font-size: 3.4rem; display: inline; margin-right: .5rem; }
  .hero { grid-template-columns: 1fr; }
  .hero-status { text-align: left; }
  .stamp-form { justify-content: stretch; }
  .stamp { width: 100%; }
}
@media (prefers-reduced-motion: no-preference) {
  .progress.big .fill { transition: width .6s ease-out; }
}

/* System */
.narrow.wide { max-width: 42rem; }
.update-status { display: grid; gap: .2rem; padding: .9rem 1.1rem; margin: 1rem 0 1.5rem; background: var(--surface); border-left: 6px solid var(--line); }
.update-status.running, .update-status.queued { border-color: var(--signal); }
.update-status.ok { border-color: var(--done); }
.update-status.error { border-color: var(--danger); }
.log { background: var(--surface); padding: .8rem; font-size: .8rem; overflow-x: auto; white-space: pre-wrap; }
button:disabled { opacity: .45; cursor: not-allowed; }
.foot { max-width: 1100px; margin: 0 auto; padding: 0 1.25rem 1.5rem; color: var(--muted); font-size: .8rem; }

/* Überblick & Termine */
.overview { display: flex; flex-wrap: wrap; gap: 0 2.5rem; margin: 0 0 1.25rem; padding: .9rem 1.2rem; background: var(--surface); border-top: 4px solid var(--ink); }
.overview div { padding: .2rem 0; }
.overview dt { color: var(--muted); font-size: .9rem; }
.overview dd { margin: 0; font: 700 1.6rem var(--cond); }
.upcoming { margin-bottom: 1rem; }
.appts { list-style: none; margin: 0 0 .5rem; padding: 0; }
.appts li { display: grid; gap: .15rem; padding: .6rem 0 .6rem .8rem; border-left: 4px solid var(--signal); margin-bottom: .5rem; background: var(--bg); }
.appts .when { font-weight: 600; }
.appt-tools { font-size: .9rem; }
.month-nav { display: flex; gap: .4rem; }
.summary-line { font-size: 1.1rem; }
.scroll { overflow-x: auto; }

/* Zahlungen */
.sum.paid td { color: var(--muted); }
.sum .open-row td { color: var(--ink); font-weight: 700; font-size: 1.1rem; border-bottom: 0; }

/* Galerie */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr)); gap: .5rem; margin-bottom: 1rem; }
.gallery figure { margin: 0; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--track); }
.gallery figcaption { font-size: .8rem; color: var(--muted); }

/* Kostenaufstellung */
body.paper { background: var(--bg); }
.no-print { max-width: 48rem; margin: 1rem auto; padding: 0 1rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.sheet { max-width: 48rem; margin: 0 auto 2rem; background: #fff; color: #1E2A33; padding: 2.5rem 2.75rem; }
.sheet-head { display: flex; justify-content: space-between; border-bottom: 3px solid #1E2A33; padding-bottom: .6rem; margin-bottom: 2rem; }
.recipient { margin-bottom: 2rem; }
.sheet h1 { font-size: 2rem; }
.lines { margin: 1.25rem 0; }
.lines th { text-align: left; font-weight: 600; border-bottom: 2px solid #1E2A33; padding: .4rem 0; }
.lines th:not(:first-child), .lines td:not(:first-child) { text-align: right; padding-left: 1rem; white-space: nowrap; }
.lines td { border-color: #C9D0D5; }
.lines tr.strong td { font-weight: 700; border-top: 2px solid #1E2A33; }
.small-table td { font-size: .9rem; }
.small-table td:nth-child(2), .small-table td:nth-child(3) { text-align: left; white-space: normal; }
.fine { margin-top: 2rem; font-size: .85rem; color: #5E6B74; }
@media print {
  .no-print { display: none; }
  body.paper { background: #fff; }
  .sheet { margin: 0; padding: 0; max-width: none; }
}
@media (max-width: 600px) { .sheet { padding: 1.5rem 1.1rem; } }

.tag { display: inline-block; font-size: .75rem; font-weight: 600; padding: .05rem .4rem; border-radius: 3px; background: var(--signal); color: var(--signal-ink); vertical-align: middle; }
.publish { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin: 0; }
.settings fieldset { display: grid; gap: .8rem; }
.settings label small { display: block; font-weight: 400; margin-top: .2rem; }
.settings textarea { line-height: 1.45; }

/* Einladung */
.login-no { background: var(--surface); padding: .8rem 1rem; border-left: 4px solid var(--signal); }
.login-no strong { font: 700 1.5rem var(--cond); letter-spacing: .04em; }
.invite { background: var(--surface); padding: 1rem 1.1rem; margin: 1rem 0 1.5rem; border: 3px solid var(--signal); }
.invite input { font-size: .9rem; }
.invite-actions { margin-top: .6rem; }
.invite-actions > * { flex: 1 1 auto; text-align: center; }
.btn.wa { background: #1F7A4D; color: #fff; }

.paid-full { display: inline-block; margin: .6rem 0; padding: .35rem .7rem; background: var(--done); color: #fff; font-weight: 600; border-radius: 3px; }
