:root {
  --bg: #f3f5f2; --surface: #ffffff; --surface-2: #eef1ec; --line: #dde3da;
  --text: #17211b; --muted: #5d6b62; --brand: #1f6b45; --brand-2: #2f8a5c; --brand-ink: #ffffff;
  --red: #c9372c; --red-bg: #fde8e6; --amber: #b86e00; --amber-bg: #fff1d6;
  --green: #1f7a4a; --green-bg: #e1f3e8; --grey: #6f7a73; --grey-bg: #eceeec;
  --blue: #2563a8; --blue-bg: #e3eefb;
  --radius: 14px; --shadow: 0 1px 2px rgba(20, 40, 30, .06), 0 4px 14px rgba(20, 40, 30, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1512; --surface: #18201b; --surface-2: #1f2923; --line: #2b3830;
    --text: #e6ece8; --muted: #95a39a; --brand: #3fa872; --brand-2: #57bd88; --brand-ink: #06140c;
    --red: #ff7468; --red-bg: #3a1916; --amber: #ffb347; --amber-bg: #3a2a10;
    --green: #5fd193; --green-bg: #15301f; --grey: #9aa59e; --grey-bg: #252e28;
    --blue: #7db3f0; --blue-bg: #172a40; --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
a { color: var(--brand); }
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.2; }
h1 { font-size: 1.35rem; } h2 { font-size: 1.1rem; } h3 { font-size: 1rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* Layout */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; background: var(--brand); color: var(--brand-ink);
}
.topbar .title { font-weight: 700; font-size: 1.05rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar button { background: transparent; border: 0; color: inherit; font-size: 1.3rem; padding: 4px 8px; cursor: pointer; }
main { max-width: 860px; margin: 0 auto; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: space-around;
  background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.bottomnav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; text-decoration: none;
  color: var(--muted); font-size: .72rem; padding: 4px 0; position: relative;
}
.bottomnav a .ic { font-size: 1.35rem; line-height: 1; }
.bottomnav a.active { color: var(--brand); font-weight: 600; }
.bottomnav a.plus .ic {
  background: var(--brand); color: var(--brand-ink); width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; margin-top: -18px; box-shadow: var(--shadow); font-size: 1.6rem;
}
.badge {
  position: absolute; top: 0; left: 55%; background: var(--red); color: #fff; border-radius: 10px;
  font-size: .68rem; padding: 0 6px; min-width: 18px; text-align: center; font-weight: 700;
}

/* Karten */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); margin-bottom: 12px; }
.card.link { display: block; color: inherit; text-decoration: none; cursor: pointer; }
.card.link:active { transform: scale(.995); }
.section-h { display: flex; align-items: baseline; justify-content: space-between; margin: 20px 2px 8px; }
.section-h h2 { margin: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); text-decoration: none; color: inherit; }
.kpi .v { font-size: 1.6rem; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi .l { color: var(--muted); font-size: .8rem; }
.kpi.red .v { color: var(--red); } .kpi.amber .v { color: var(--amber); } .kpi.green .v { color: var(--green); } .kpi.blue .v { color: var(--blue); }

/* Punkt-Karte */
.item { display: grid; grid-template-columns: 6px 1fr; gap: 0 12px; padding: 12px 14px 12px 0; overflow: hidden; }
.item .bar { border-radius: 0 4px 4px 0; }
.item .head { display: flex; gap: 8px; align-items: baseline; }
.item .nr { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .85rem; }
.item .t { font-weight: 650; flex: 1; }
.item .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.item .next { margin-top: 6px; font-size: .88rem; color: var(--muted); }
.item.closed { opacity: .6; }
.bar.red { background: var(--red); } .bar.amber { background: var(--amber); } .bar.green { background: var(--green); }
.bar.none, .bar.muted { background: var(--line); } .bar.done { background: var(--grey); }
.chip { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 2px 9px; font-size: .76rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.chip.red { background: var(--red-bg); color: var(--red); } .chip.amber { background: var(--amber-bg); color: var(--amber); }
.chip.green { background: var(--green-bg); color: var(--green); } .chip.blue { background: var(--blue-bg); color: var(--blue); }
.chip.done, .chip.muted, .chip.none { background: var(--grey-bg); color: var(--grey); }
.prog { height: 6px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin-top: 8px; }
.prog > i { display: block; height: 100%; background: var(--brand-2); border-radius: 4px; }

/* Filter */
.filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 10px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; flex-shrink: 0; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font: inherit; font-size: .85rem; color: var(--muted); cursor: pointer; white-space: nowrap; }
.seg button.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.filters select { flex-shrink: 0; width: auto; }

/* Formulare */
label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-2); outline-offset: 0; border-color: transparent; }
textarea { min-height: 84px; resize: vertical; }
input[type=range] { padding: 0; min-height: 32px; accent-color: var(--brand); border: 0; background: none; }
input[type=checkbox] { width: auto; min-height: 0; accent-color: var(--brand); transform: scale(1.25); margin-right: 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }
fieldset { border: 0; padding: 0; margin: 0 0 6px; }
legend { font-weight: 700; font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; color: var(--brand); margin-bottom: 8px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; padding: 10px 16px;
  border-radius: 10px; cursor: pointer; min-height: 44px; text-decoration: none;
}
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.danger { color: var(--red); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

/* Detail */
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
dl.kv dt { color: var(--muted); font-size: .85rem; }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { border-left: 2px solid var(--line); padding: 0 0 12px 12px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand-2); }
.photos { display: flex; gap: 8px; flex-wrap: wrap; }
.photos img { width: 96px; height: 96px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }

/* Sonstiges */
.toast {
  position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 50; font-weight: 600;
  max-width: calc(100% - 32px); box-shadow: var(--shadow);
}
.banner { background: var(--amber-bg); color: var(--amber); padding: 8px 12px; border-radius: 10px; margin-bottom: 12px; font-weight: 600; font-size: .9rem; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-plain li:last-child { border-bottom: 0; }
.bars .b { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; margin-bottom: 8px; font-size: .88rem; }
.bars .track { grid-column: 1 / -1; height: 8px; background: var(--surface-2); border-radius: 4px; display: flex; overflow: hidden; }
.bars .track i { display: block; height: 100%; }
.login { max-width: 380px; margin: 8vh auto; padding: 0 16px; }
.login .logo { width: 72px; height: 72px; border-radius: 18px; display: block; margin: 0 auto 14px; }
.center { text-align: center; }
.pinbox { font-size: 1.6rem; letter-spacing: .4em; text-align: center; }
.code { font-family: ui-monospace, Consolas, monospace; font-size: 1.3rem; font-weight: 700; letter-spacing: .08em; }
