:root {
  --bg: #f4f2ee;
  --panel: #ffffff;
  --ink: #1d2327;
  --muted: #68717a;
  --line: #e2ded6;
  --accent: #0e6e6a;
  --accent-ink: #ffffff;
  --accent-soft: #e2f1ef;
  --warn: #b5541c;
  --warn-soft: #fbeadf;
  --bad: #b3261e;
  --bad-soft: #fbe3e1;
  --ok: #2f7d32;
  --ok-soft: #e4f2e4;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(30, 30, 20, .06), 0 2px 8px rgba(30, 30, 20, .04);
  font-size: 15px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font-family: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.45;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 .2rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .8rem; }
h3 { font-size: .95rem; margin: 1rem 0 .5rem; }
small, .muted { color: var(--muted); }
code, .mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .92em; }

/* ---------- Layout ---------- */
.top {
  background: #1f2a2e; color: #fff; position: sticky; top: 0; z-index: 10;
}
.top .inner {
  max-width: 1280px; margin: 0 auto; padding: .55rem 1rem;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.brand { font-weight: 700; color: #fff; display: flex; align-items: center; gap: .5rem; letter-spacing: .01em; }
.brand:hover { text-decoration: none; }
.brand .logo { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); display: grid; place-items: center; font-size: 15px; }
.nav { display: flex; gap: .15rem; flex-wrap: wrap; flex: 1; }
.nav a { color: #c9d3d6; padding: .35rem .6rem; border-radius: 7px; font-size: .93rem; }
.nav a:hover, .nav a.active { background: rgba(255, 255, 255, .1); color: #fff; text-decoration: none; }
.top form.search { display: flex; }
.top form.search input { background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .15); color: #fff; width: 210px; }
.top form.search input::placeholder { color: #9fb0b5; }
main { max-width: 1280px; margin: 0 auto; padding: 1.2rem 1rem 3rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head .actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.grid { display: grid; gap: 1rem; }
.grid > * { min-width: 0; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.main-side { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); }
@media (max-width: 900px) { .grid.main-side { grid-template-columns: 1fr; } }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > h2 { padding: 1rem 1.1rem 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .6rem; }
.card-head h2 { margin: 0; }

/* ---------- Kennzahlen ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; box-shadow: var(--shadow); color: inherit; }
.stat:hover { text-decoration: none; border-color: var(--accent); }
.stat .v { font-size: 1.6rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: .85rem; }
.stat.warn .v { color: var(--warn); }
.stat.bad .v { color: var(--bad); }

/* ---------- Tabellen ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #faf9f6; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fbfaf7; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.clickable { cursor: pointer; }
.table-wrap { overflow-x: auto; }
tfoot td { font-weight: 600; background: #faf9f6; }

/* ---------- Formulare ---------- */
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .2rem; font-weight: 500; }
input, select, textarea {
  width: 100%; font: inherit; color: inherit; background: #fff;
  border: 1px solid #d3cec4; border-radius: 8px; padding: .5rem .6rem;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { min-height: 70px; resize: vertical; }
input[type=checkbox], input[type=radio] { width: auto; }
.field { margin-bottom: .75rem; }
.row { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.check { display: flex; gap: .45rem; align-items: center; color: var(--ink); font-size: .93rem; }
.inline { display: flex; gap: .5rem; align-items: flex-end; flex-wrap: wrap; }
.inline > * { flex: 1 1 120px; }
.inline > .shrink { flex: 0 0 auto; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; margin: 0 0 1rem; background: var(--panel); box-shadow: var(--shadow); }
legend { font-weight: 600; padding: 0 .3rem; }

.btn {
  display: inline-flex; align-items: center; gap: .35rem; justify-content: center;
  font: inherit; font-weight: 550; font-size: .92rem; cursor: pointer;
  border: 1px solid #cfc9be; background: #fff; color: var(--ink);
  padding: .48rem .85rem; border-radius: 8px; white-space: nowrap;
}
.btn:hover { text-decoration: none; border-color: #a9a297; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); border-color: #e7b9b5; }
.btn.small { padding: .25rem .55rem; font-size: .82rem; }
.btn.link { border: 0; background: none; padding: 0; color: var(--accent); }
.nav .btn.primary { color: #fff; }
form.inline-form { display: inline; }

/* ---------- Status ---------- */
.chip { display: inline-block; font-size: .78rem; font-weight: 600; padding: .12rem .55rem; border-radius: 99px; background: #ece9e3; color: #4a4f54; white-space: nowrap; }
.chip.s-angenommen { background: #e8eef7; color: #2b4f86; }
.chip.s-diagnose { background: #efe8f7; color: #5b3a8a; }
.chip.s-kva { background: var(--warn-soft); color: var(--warn); }
.chip.s-wartet_teile { background: #fff3cd; color: #8a6100; }
.chip.s-in_reparatur { background: var(--accent-soft); color: var(--accent); }
.chip.s-fertig { background: var(--ok-soft); color: var(--ok); }
.chip.s-abgeholt { background: #ecebe8; color: #6b6b6b; }
.chip.s-storniert { background: var(--bad-soft); color: var(--bad); }
.chip.p-entwurf { background: #ecebe8; }
.chip.p-bestellt { background: #e8eef7; color: #2b4f86; }
.chip.p-teilweise { background: #fff3cd; color: #8a6100; }
.chip.p-geliefert { background: var(--ok-soft); color: var(--ok); }
.chip.p-storniert { background: var(--bad-soft); color: var(--bad); }
.chip.prio { background: var(--bad); color: #fff; }
.chip.low { background: var(--bad-soft); color: var(--bad); }
.chip.lex { background: #e6f0fb; color: #1d5fa8; }

.tabs { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: .8rem; }
.tabs a { padding: .32rem .7rem; border-radius: 99px; background: #fff; border: 1px solid var(--line); color: var(--ink); font-size: .87rem; }
.tabs a.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.tabs a:hover { text-decoration: none; }
.tabs .count { color: var(--muted); margin-left: .25rem; font-variant-numeric: tabular-nums; }
.tabs a.active .count { color: #c8cdd0; }

/* Status-Leiste im Auftrag */
.progress { display: flex; gap: 0; margin: .6rem 0 0; flex-wrap: wrap; }
.progress button {
  flex: 1 1 auto; font: inherit; font-size: .8rem; border: 1px solid var(--line); background: #fff; color: var(--muted);
  padding: .4rem .5rem; cursor: pointer; margin-left: -1px;
}
.progress button:first-child { border-radius: 8px 0 0 8px; margin-left: 0; }
.progress button:last-child { border-radius: 0 8px 8px 0; }
.progress button.done { background: var(--accent-soft); color: var(--accent); }
.progress button.current { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.progress button.cancel { color: var(--bad); }

/* ---------- Meldungen ---------- */
.flash { padding: .65rem .9rem; border-radius: 8px; margin-bottom: .6rem; border: 1px solid; }
.flash.ok { background: var(--ok-soft); border-color: #c4e0c4; color: #1f5a22; }
.flash.error { background: var(--bad-soft); border-color: #f0c2bd; color: #8b1d16; }
.banner { background: var(--warn-soft); color: var(--warn); padding: .5rem 1rem; text-align: center; font-size: .9rem; }

dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0; }
dl.kv dt { color: var(--muted); font-size: .88rem; }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
.pre { white-space: pre-wrap; }
.empty { color: var(--muted); padding: 1.2rem; text-align: center; }
.sum-line { display: flex; justify-content: space-between; padding: .25rem 0; font-variant-numeric: tabular-nums; }
.sum-line.big { font-size: 1.15rem; font-weight: 650; border-top: 1px solid var(--line); margin-top: .3rem; padding-top: .5rem; }
.sum-line.open { color: var(--bad); font-weight: 600; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: .4rem 0; border-bottom: 1px dashed var(--line); font-size: .9rem; }
.timeline li:last-child { border: 0; }
.timeline time { color: var(--muted); font-size: .8rem; display: block; }

.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .5rem; }
.photos figure { margin: 0; position: relative; }
.photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }
.photos figcaption { font-size: .75rem; color: var(--muted); }
.photos form { position: absolute; top: 4px; right: 4px; }

/* Autocomplete */
.ac { position: relative; }
.ac-list { position: absolute; left: 0; right: 0; top: 100%; z-index: 20; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.1); max-height: 280px; overflow: auto; display: none; }
.ac-list div { padding: .5rem .65rem; cursor: pointer; border-bottom: 1px solid #f1eee8; }
.ac-list div:hover, .ac-list div.sel { background: var(--accent-soft); }
.ac-list small { display: block; }
.picked { display: flex; align-items: center; gap: .6rem; padding: .55rem .7rem; border: 1px solid var(--accent); background: var(--accent-soft); border-radius: 8px; }

.login { max-width: 360px; margin: 12vh auto; }
details summary { cursor: pointer; color: var(--accent); font-weight: 550; margin: .3rem 0; }
.hide-mobile { }
@media (max-width: 700px) {
  .hide-mobile { display: none; }
  .top form.search input { width: 100%; }
  .top form.search { flex: 1 1 100%; }
  main { padding: .8rem .6rem 3rem; }
  th, td { padding: .5rem .45rem; }
}

/* ---------- Board ---------- */
main.wide { max-width: none; }
.board { display: flex; gap: .75rem; overflow-x: auto; padding-bottom: 1rem; align-items: flex-start; min-height: 60vh; }
.column { flex: 0 0 268px; background: #ebe8e1; border-radius: 12px; display: flex; flex-direction: column; max-height: calc(100vh - 190px); }
.column.drop-target { outline: 2px dashed var(--accent); background: var(--accent-soft); }
.col-head { display: flex; justify-content: space-between; align-items: center; padding: .6rem .75rem; font-weight: 650; font-size: .9rem; border-radius: 12px 12px 0 0; border-top: 4px solid #b9b3a8; }
.col-head .count { background: rgba(0,0,0,.08); border-radius: 99px; padding: 0 .5rem; font-size: .8rem; }
.col-head.s-anfrage { border-color: #8a8f96; } .col-head.s-angenommen { border-color: #2b4f86; }
.col-head.s-diagnose { border-color: #5b3a8a; } .col-head.s-kva { border-color: var(--warn); }
.col-head.s-wartet_teile { border-color: #c99a00; } .col-head.s-teile_da { border-color: #d9480f; }
.col-head.s-in_reparatur { border-color: var(--accent); } .col-head.s-fertig { border-color: var(--ok); }
.col-head.s-abgeholt { border-color: #9a9a9a; }
.cards { padding: 0 .5rem .5rem; overflow-y: auto; display: flex; flex-direction: column; gap: .5rem; min-height: 60px; }
.col-foot { padding: .4rem .75rem .6rem; font-size: .8rem; color: var(--muted); }
.kcard { background: #fff; border-radius: 9px; padding: .55rem .65rem; box-shadow: 0 1px 2px rgba(0,0,0,.08); border: 1px solid #e3dfd7; cursor: grab; font-size: .88rem; }
.kcard:hover { border-color: #c8c1b4; }
.kcard.prio { border-left: 4px solid var(--bad); }
.kcard.dragging { opacity: .45; }
.kcard.saving { opacity: .6; }
.kc-top { display: flex; justify-content: space-between; align-items: center; }
.kc-top a { font-weight: 650; font-size: .82rem; }
.kc-age { font-size: .75rem; color: var(--muted); }
.kc-age.late { color: var(--bad); font-weight: 650; }
.kc-name { font-weight: 600; margin-top: .15rem; }
.kc-dev { color: var(--ink); }
.kc-prob { color: var(--muted); font-size: .8rem; margin-top: .15rem; }
.kc-chips { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .35rem; }
.kc-chips .chip { font-size: .7rem; padding: .05rem .4rem; }
.kc-move { margin-top: .4rem; font-size: .8rem; padding: .25rem .35rem; display: none; }
@media (hover: none), (max-width: 700px) { .kc-move { display: block; } .kcard { cursor: default; } }
@media (max-width: 700px) { .column { flex-basis: 82vw; max-height: none; } }
.toast { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); background: #1f2a2e; color: #fff; padding: .65rem 1rem; border-radius: 9px; z-index: 50; box-shadow: 0 6px 24px rgba(0,0,0,.25); max-width: 90vw; }
.toast.bad { background: var(--bad); }
.chip.s-teile_da { background: #ffe8d9; color: #b03d00; }
.chip.s-anfrage { background: #ecebe8; color: #555; }
.col-head .count + .count { display: none; }
.badge { background: var(--bad); color: #fff; border-radius: 99px; padding: 0 .4rem; font-size: .72rem; font-weight: 700; }
details.more { position: relative; }
details.more summary { list-style: none; color: #c9d3d6; padding: .35rem .6rem; border-radius: 7px; font-size: .93rem; cursor: pointer; margin: 0; font-weight: 400; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary:hover, details.more summary.active, details.more[open] summary { background: rgba(255,255,255,.1); color: #fff; }
details.more .menu { position: absolute; top: 110%; left: 0; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.18); padding: .35rem; min-width: 210px; z-index: 30; display: flex; flex-direction: column; }
details.more .menu a { color: var(--ink); padding: .45rem .6rem; border-radius: 7px; }
details.more .menu a:hover { background: var(--accent-soft); text-decoration: none; }

/* ---------- Termine (Woche) ---------- */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .5rem; }
.day { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem; min-height: 140px; }
.day.today { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.day.closed { background: #f0eee9; }
.day-head { font-weight: 650; font-size: .85rem; margin-bottom: .4rem; }
.appt { display: block; background: var(--accent-soft); border-left: 3px solid var(--accent); border-radius: 6px; padding: .3rem .45rem; margin-bottom: .35rem; color: var(--ink); font-size: .82rem; line-height: 1.3; }
.appt:hover { text-decoration: none; filter: brightness(.97); }
.appt small { display: block; color: var(--muted); }
.appt.k-abholung { background: var(--ok-soft); border-color: var(--ok); }
.appt.k-reparatur { background: #ffe8d9; border-color: #d9480f; }
.appt.k-beratung { background: #efe8f7; border-color: #5b3a8a; }
.appt.cancelled { opacity: .45; text-decoration: line-through; }
@media (max-width: 900px) { .week { grid-template-columns: 1fr; } .day { min-height: 0; } }

/* ---------- Checkliste ---------- */
.checklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: .3rem 1rem; }
.check-row { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .25rem 0; border-bottom: 1px dashed var(--line); font-size: .9rem; }
.seg { display: inline-flex; border: 1px solid #d3cec4; border-radius: 7px; overflow: hidden; flex: none; }
.seg label { margin: 0; color: var(--ink); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: .18rem .5rem; font-size: .76rem; cursor: pointer; background: #fff; border-left: 1px solid #e6e1d8; }
.seg label:first-child span { border-left: 0; }
.seg .seg-ok input:checked + span { background: var(--ok); color: #fff; }
.seg .seg-defekt input:checked + span { background: var(--bad); color: #fff; }
.seg .seg-na input:checked + span { background: #8a8f96; color: #fff; }

/* ---------- Unterschrift ---------- */
.sigpad canvas { width: 100%; height: auto; aspect-ratio: 3 / 1; border: 1px dashed #b9b3a8; border-radius: 8px; background: #fff; touch-action: none; display: block; }
.sig-actions { display: flex; justify-content: space-between; align-items: center; margin: .3rem 0 .5rem; }
.sig-img { max-width: 100%; max-height: 110px; border-bottom: 1px solid var(--ink); }

.add-item { padding: 1rem 1.1rem; border-top: 1px solid var(--line); background: #fcfbf9; }
details.inline-edit summary { list-style: none; color: inherit; font-weight: 400; margin: 0; cursor: pointer; }
details.inline-edit summary::-webkit-details-marker { display: none; }
details.inline-edit[open] summary { display: none; }
.notify-toggle { margin-left: .8rem; font-size: .82rem; color: var(--muted); }
.notify-toggle input { display: none; }
.notify-toggle span { cursor: pointer; text-decoration: underline dotted; }
.bar { background: #efece6; border-radius: 4px; height: 12px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); }
.sum-line { gap: .6rem; } .sum-line > :last-child { flex: none; }
.banner.bad { background: var(--bad); color: #fff; } .banner.bad a { color: #fff; text-decoration: underline; }
.chat { display: flex; flex-direction: column; gap: .45rem; max-height: 420px; overflow-y: auto; padding: .2rem; }
.bubble { max-width: 88%; padding: .45rem .65rem; border-radius: 12px; font-size: .88rem; line-height: 1.35; }
.bubble.in { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble.in.unread { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.bubble.out { align-self: flex-end; background: #dcf3e6; border-bottom-right-radius: 4px; }
.bubble .meta { font-size: .72rem; color: var(--muted); margin-top: .2rem; }

/* Auswahl-Listen & Schritt-Anleitungen */
.choice-list { display: grid; gap: .55rem; }
.choice-list label.check { align-items: flex-start; gap: .55rem; }
.choice-list label.check input { margin-top: .25rem; }
ol.steps { padding-left: 1.3rem; margin: .6rem 0 0; }
ol.steps li { margin: .5rem 0; line-height: 1.45; }

/* ---------- Handy / installierte App ---------- */
.tabbar { display: none; }
.menu-list a { display: flex; align-items: center; gap: .75rem; padding: .85rem 1rem; color: var(--ink); border-bottom: 1px solid var(--line); font-size: 1rem; }
.menu-list a:last-child { border-bottom: 0; }
.menu-list a:hover { background: var(--accent-soft); text-decoration: none; }
.menu-list a > span:first-child { width: 1.6rem; text-align: center; }
.menu-list .chev { margin-left: auto; color: var(--muted); font-size: 1.2rem; }
.top { padding-top: env(safe-area-inset-top); }
@media (max-width: 700px) {
  .top .inner { flex-wrap: nowrap; gap: .5rem; padding: .5rem .6rem; }
  .top .nav { display: none; }
  .brand { font-size: 0; gap: 0; }
  .brand .logo { width: 32px; height: 32px; font-size: 17px; }
  .top form.search { flex: 1 1 auto; min-width: 0; }
  .top form.search input { width: 100%; padding: .45rem .6rem; }
  .new-btn { padding: .45rem .8rem; font-size: 1.1rem; line-height: 1; }
  .new-btn .lbl { display: none; }
  main { padding-bottom: calc(5.5rem + env(safe-area-inset-bottom)); }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -2px 10px rgba(0, 0, 0, .05);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: .1rem; padding: .45rem 0 .5rem; color: var(--muted); font-size: .7rem; }
  .tabbar a:hover { text-decoration: none; }
  .tabbar a.active { color: var(--accent); font-weight: 600; }
  .tabbar .ti { font-size: 1.3rem; line-height: 1.2; position: relative; }
  .tabbar .badge { position: absolute; top: -4px; right: -12px; font-size: .62rem; }
  .banner { font-size: .85rem; padding: .45rem .7rem; }
}

details.sub { border: 1px dashed var(--line); border-radius: 8px; padding: .4rem .6rem; margin: .4rem 0 .6rem; }
details.sub > summary { cursor: pointer; font-size: .9rem; color: var(--accent); }
.num-pos { color: var(--bad); } .num-neg { color: #1b7a3a; }
.model-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .3rem .8rem; }
