:root {
  --bg: #f4f6f8; --card: #ffffff; --text: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --accent: #0e7490; --accent-ink: #ffffff; --free: #b45309; --free-bg: #fef3c7;
  --pot: #0e7490; --pot-bg: #cffafe; --ok: #15803d; --ok-bg: #dcfce7; --warn: #b91c1c; --warn-bg: #fee2e2;
  --info-bg: #e0f2fe; --info: #0369a1; --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --card: #181b21; --text: #e5e7eb; --muted: #94a3b8; --line: #2a2f38;
    --accent: #22a3c0; --accent-ink: #04141a; --free: #fbbf24; --free-bg: #3a2a07;
    --pot: #67e8f9; --pot-bg: #083344; --ok: #4ade80; --ok-bg: #0d2a18; --warn: #f87171; --warn-bg: #3b1212;
    --info-bg: #0c2a3d; --info: #7dd3fc;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px; }
header.top {
  position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
header.top .wrap { display: flex; align-items: center; gap: 14px; min-height: 56px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); }
.brand img { width: 28px; height: 28px; border-radius: 7px; }
nav.main { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
nav.main a { padding: 6px 10px; border-radius: 9px; color: var(--muted); font-weight: 500; }
nav.main a.on { background: var(--card); color: var(--text); box-shadow: 0 0 0 1px var(--line); }
nav.main a:hover { text-decoration: none; color: var(--text); }
.who { font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
main { padding: 20px 0 48px; }
h1 { font-size: 26px; margin: 4px 0 16px; letter-spacing: -0.01em; }
h2 { font-size: 18px; margin: 28px 0 10px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.pot h3 { margin: 0 0 8px; font-size: 15px; color: var(--muted); font-weight: 600; display: flex; justify-content: space-between; }
.big { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin-top: 10px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; }
.kv .sep { grid-column: 1 / -1; border-top: 1px solid var(--line); margin: 4px 0; }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.st-eingereicht { background: var(--info-bg); color: var(--info); }
.st-in_auszahlung { background: var(--free-bg); color: var(--free); }
.st-ausgezahlt, .st-paid { background: var(--ok-bg); color: var(--ok); }
.st-open { background: var(--info-bg); color: var(--info); }
.st-overdue { background: var(--warn-bg); color: var(--warn); }
.free { color: var(--free); }
.potc { color: var(--pot); }
.warnbox { background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: 8px 12px; margin-top: 10px; font-size: 14px; }
.flash { background: var(--ok-bg); color: var(--ok); border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; }
.flash.err { background: var(--warn-bg); color: var(--warn); }
.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; }
.item .main { flex: 1; min-width: 0; }
.item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); display: block; }
.item .sub { font-size: 13px; color: var(--muted); }
.item .amt { text-align: right; }
svg.split { display: block; width: 100%; max-width: 360px; height: 6px; border-radius: 3px; margin-top: 6px; }
svg.split rect.a { fill: var(--free); } svg.split rect.b { fill: var(--pot); }
.legend { font-size: 12px; color: var(--muted); display: flex; gap: 12px; margin-top: 4px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.dot.a { background: var(--free); } .dot.b { background: var(--pot); }
button, .btn {
  appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--text);
  font: inherit; font-weight: 600; font-size: 14px; padding: 8px 14px; border-radius: 10px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none; min-height: 38px;
}
.btn:hover, button:hover { text-decoration: none; filter: brightness(0.97); }
.btn.primary, button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger, button.danger { color: var(--warn); }
.btn.sm, button.sm { padding: 4px 10px; min-height: 32px; font-size: 13px; }
form.inline { display: inline; margin: 0; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs a { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.tabs a.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.tabs a:hover { text-decoration: none; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px;
}
textarea { min-height: 80px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.fgrid { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
.fgrid .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .fgrid { grid-template-columns: 1fr; } .big { font-size: 26px; } h1 { font-size: 22px; } }
.check { display: flex; gap: 8px; align-items: center; font-size: 15px; color: var(--text); font-weight: 500; }
.check input { width: auto; }
.atts { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.att { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--bg); font-size: 12px; }
.att img { width: 100%; height: 120px; object-fit: cover; display: block; }
.att .ph { height: 120px; display: flex; align-items: center; justify-content: center; font-size: 28px; color: var(--muted); }
.att .meta { padding: 6px 8px; display: flex; gap: 6px; align-items: center; }
.att .meta span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code { font-size: 56px; font-weight: 800; letter-spacing: 0.12em; text-align: center; margin: 10px 0; font-variant-numeric: tabular-nums; }
.center { text-align: center; }
.narrow { max-width: 460px; margin: 6vh auto 0; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t td, table.t th { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t th { color: var(--muted); font-weight: 600; }
.empty { padding: 20px; text-align: center; color: var(--muted); background: var(--card); border: 1px dashed var(--line); border-radius: 12px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 4px; }
.calc { margin-top: 8px; font-size: 14px; }
.hidden { display: none !important; }
.mt { margin-top: 12px; }
.jc { justify-content: center; }
.rounded { border-radius: 14px; } code { font-size: 0.92em; background: var(--bg); padding: 1px 5px; border-radius: 5px; } ol { padding-left: 20px; } ol li { margin: 6px 0; }

@media (max-width: 640px) {
  header.top .wrap { gap: 6px 10px; padding-top: 8px; }
  .brand { order: 1; }
  .who { order: 2; margin-left: auto; }
  nav.main { order: 3; flex: 1 0 100%; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
  nav.main::-webkit-scrollbar { display: none; }
  nav.main a { white-space: nowrap; }
  .item { flex-wrap: wrap; }
  .item .amt { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
}
