:root {
  --bg: #0f1115;
  --tile: #181b22;
  --tile-2: #20242d;
  --line: #2a2f3a;
  --text: #eef0f4;
  --muted: #8b93a3;
  --accent: #4f8cff;
  --good: #34c77b;
  --warn: #ffb020;
  --bad: #ff5d5d;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f2f3f7; --tile: #ffffff; --tile-2: #f4f5f8; --line: #e3e6ec;
    --text: #12151b; --muted: #687083; color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding: calc(var(--safe-t) + 12px) 14px calc(var(--safe-b) + 84px);
}
main { max-width: 980px; margin: 0 auto; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

/* Kopf */
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 8px 2px 14px; }
.head h1 { font-size: 26px; margin: 0; letter-spacing: -.02em; }
.head .sub { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }

/* Raster */
.grid { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 760px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile { background: var(--tile); border-radius: var(--radius); padding: 14px; min-width: 0; }
.span-2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }
.tile h2 { font-size: 13px; margin: 0 0 10px; color: var(--muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em; display: flex; justify-content: space-between; align-items: center; }
.tile.muted { opacity: .55; }

/* KPI */
.kpi .val { font-size: 28px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.kpi .val small { font-size: 15px; color: var(--muted); font-weight: 500; }
.kpi .lbl { color: var(--muted); font-size: 12px; margin-top: 4px; }
.ring { --p: 0; width: 46px; height: 46px; border-radius: 50%; float: right;
  background: conic-gradient(var(--good) calc(var(--p) * 1%), var(--tile-2) 0);
  display: grid; place-items: center; }
.ring::after { content: ""; width: 34px; height: 34px; border-radius: 50%; background: var(--tile); }

/* Listen */
.list { display: flex; flex-direction: column; gap: 2px; }
.row { display: flex; align-items: center; gap: 12px; padding: 9px 4px; border-radius: 10px; }
.row + .row { border-top: 1px solid var(--line); }
.row .main { flex: 1; min-width: 0; }
.row .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .m { color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.row .ico { font-size: 22px; width: 28px; text-align: center; }
.row.done .t { color: var(--muted); text-decoration: line-through; }
.row.rest { opacity: .5; }
.empty { color: var(--muted); font-size: 14px; padding: 6px 4px; }

.check { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--line); background: transparent;
  cursor: pointer; flex: none; display: grid; place-items: center; font-size: 16px; transition: .15s; }
.check:hover { border-color: var(--accent); }
.check.on { background: var(--good); border-color: var(--good); color: #fff; }

.badge { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 99px; background: var(--tile-2); color: var(--muted); }
.badge.urgent { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.badge.behind { background: color-mix(in srgb, var(--bad) 20%, transparent); color: var(--bad); }
.badge.good { background: color-mix(in srgb, var(--good) 20%, transparent); color: var(--good); }
.badge.away { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); }

/* Wochenpunkte */
.week { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center; }
.dots { display: flex; gap: 5px; }
.dot { width: 22px; height: 22px; border-radius: 7px; background: var(--tile-2); font-size: 10px;
  display: grid; place-items: center; color: var(--muted); }
.dot.on { background: var(--good); color: #fff; }
.dot.off { opacity: .35; }
.dot.today { outline: 2px solid var(--accent); outline-offset: 1px; }
.wlabel { font-size: 14px; display: flex; justify-content: space-between; gap: 8px; }
.wlabel span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }

/* Heatmap */
.heat { display: grid; grid-template-rows: repeat(7, 11px); grid-auto-flow: column; grid-auto-columns: 11px; gap: 3px; margin-top: 10px; }
.heat i { border-radius: 3px; background: var(--tile-2); }
.heat i.on { background: var(--good); }
.heat i.off { opacity: .3; }
.heat i.fut { background: transparent; }

/* Eingabe */
.capture { display: flex; gap: 8px; }
.capture input { flex: 1; min-width: 0; background: var(--tile-2); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; }
.btn { background: var(--accent); color: #fff; border: 0; border-radius: 12px; padding: 10px 14px; font-weight: 600; cursor: pointer; }
.btn.ghost { background: var(--tile-2); color: var(--text); }
.btn.danger { background: transparent; color: var(--bad); }
.icon-btn { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 16px; padding: 6px; }
.icon-btn:hover { color: var(--text); }

/* Kalender */
.day h3 { font-size: 13px; margin: 0 0 4px; color: var(--muted); font-weight: 600; }
.day.today h3 { color: var(--accent); }
.day .row { cursor: pointer; }
.time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; width: 86px; flex: none; }
.toolbar { display: flex; gap: 8px; align-items: center; }

/* Formular-Sheet */
dialog { border: 0; border-radius: 20px; padding: 0; background: var(--tile); color: var(--text);
  width: min(520px, calc(100vw - 20px)); max-height: 90vh; }
dialog::backdrop { background: rgba(0,0,0,.5); }
dialog form { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
dialog h2 { margin: 0 0 4px; font-size: 18px; }
label.f { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
label.f input, label.f select, label.f textarea {
  background: var(--tile-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; color: var(--text); font-size: 15px; }
.frow { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chk { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips label { cursor: pointer; }
.chips input { display: none; }
.chips span { display: inline-block; padding: 6px 10px; border-radius: 99px; background: var(--tile-2); border: 1px solid var(--line); color: var(--text); }
.chips input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.actions .spacer { flex: 1; }

/* Tabbar */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around;
  background: color-mix(in srgb, var(--tile) 88%, transparent); backdrop-filter: blur(16px);
  border-top: 1px solid var(--line); padding: 8px 4px calc(var(--safe-b) + 8px); z-index: 5; }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); min-width: 70px; }
.tabbar .ti { font-size: 20px; line-height: 1; }
.tabbar a.active { color: var(--accent); }

/* Login */
body.locked .tabbar { display: none; }
.login { max-width: 420px; margin: 12vh auto 0; text-align: center; display: flex; flex-direction: column; gap: 14px; align-items: stretch; padding: 24px; }
.login img { align-self: center; }
.login h1 { margin: 0; font-size: 22px; }
.login summary { color: var(--muted); cursor: pointer; font-size: 14px; }

#toast { position: fixed; left: 50%; bottom: calc(var(--safe-b) + 84px); transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 10; }
#toast.show { opacity: 1; transform: translateX(-50%); }
