:root {
  color-scheme: dark;
  --bg: #0b0d12;
  --panel: #141821;
  --panel-2: #1b202b;
  --line: #262c38;
  --text: #e9ecf2;
  --muted: #8a93a5;
  --accent: #4f8cff;
  --good: #2fbf71;
  --bad: #ff5d5d;
  --warn: #f2b63c;
  --radius: 16px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  font-size: 15px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100vh; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; border-radius: 10px; padding: 9px 14px; background: var(--panel-2); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); color: #fff; font-weight: 600; }
button.ghost { background: transparent; color: var(--muted); }
button.link { background: none; padding: 0; color: var(--accent); font-size: 13px; }
button.wide { width: 100%; padding: 14px; font-size: 16px; }
button.icon { background: transparent; color: var(--muted); font-size: 20px; padding: 6px 10px; }
input { font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pos { color: var(--good); }
.neg { color: var(--bad); }
.warn { color: var(--warn); }
.msg { min-height: 1.2em; color: var(--bad); font-size: 14px; margin: 10px 0 0; }
.msg.ok { color: var(--good); }
.field { display: grid; gap: 6px; margin: 14px 0; color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }

.mark { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 9px; background: var(--accent); color: #fff; font-weight: 800; }
.mark.big { width: 48px; height: 48px; border-radius: 14px; font-size: 22px; }
.boot { position: fixed; inset: 0; display: grid; place-items: center; }

/* ---------- Anmeldung ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--panel); border-radius: 22px; padding: 28px 22px; }
.auth-logo { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; font-size: 20px; }
.auth-logo small { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.login-only { display: grid; justify-items: center; gap: 6px; }
.passkey-btn { width: 96px; height: 96px; border-radius: 28px; background: var(--accent); color: #fff; display: grid; place-items: center; padding: 0; box-shadow: 0 10px 30px rgba(79,140,255,.35); }
.passkey-btn:disabled { opacity: .6; }
.login-only .msg { text-align: center; max-width: 280px; }
.steps { margin: 18px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.steps b { color: var(--text); font-weight: 600; }

/* ---------- Kopf ---------- */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top)); background: rgba(11,13,18,.9); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-size: 16px; white-space: nowrap; }
.tabs { display: flex; gap: 2px; margin-left: auto; }
.tabs a { padding: 8px 11px; border-radius: 10px; color: var(--muted); font-size: 14px; }
.tabs a.active { color: var(--text); background: var(--panel-2); }
main { max-width: 1180px; margin: 0 auto; padding: 14px 14px 56px; }

.filters { display: grid; gap: 8px; margin-bottom: 14px; }
.custom-range { display: flex; align-items: center; gap: 8px; }
.custom-range input { max-width: 180px; }
.selects { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
select { font: inherit; color: var(--text); background: var(--panel); border: 0; border-radius: 10px; padding: 8px 10px; }
.selects #updated { margin-left: auto; }
.seg { display: flex; gap: 4px; overflow-x: auto; background: var(--panel); padding: 4px; border-radius: 12px; max-width: 100%; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { background: transparent; white-space: nowrap; padding: 7px 11px; font-size: 14px; color: var(--muted); }
.seg button.active { background: var(--accent); color: #fff; }

/* ---------- Bausteine ---------- */
.panel { background: var(--panel); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 16px; margin: 0 0 12px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 22px 2px 10px; }
.section-title h2 { margin: 0; font-size: 15px; color: var(--muted); font-weight: 600; letter-spacing: .02em; }

.status-strip { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 4px; scrollbar-width: none; }
.status-strip::-webkit-scrollbar { display: none; }
.status-chip { display: flex; align-items: center; gap: 8px; background: var(--panel); border-radius: 12px; padding: 9px 12px; white-space: nowrap; font-size: 13px; }
.status-chip b { font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; flex: none; }
.dot.ok { background: var(--good); box-shadow: 0 0 0 3px rgba(47,191,113,.15); }
.dot.bad { background: var(--bad); box-shadow: 0 0 0 3px rgba(255,93,93,.15); }

.hero { background: linear-gradient(160deg, #1a2234, var(--panel)); border-radius: 20px; padding: 18px; margin-bottom: 10px; }
.hero .label { color: var(--muted); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; display: flex; justify-content: space-between; }
.hero .value { font-size: 30px; font-weight: 750; margin: 6px 0 14px; letter-spacing: -.01em; }
.kpis { display: grid; gap: 0; }
.kpi { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 8px 0; border-top: 1px solid rgba(255,255,255,.06); }
.kpi span { color: var(--muted); font-size: 13px; }
.kpi b { font-size: 15px; font-weight: 600; }
.kpi.info span, .kpi.info b { color: var(--muted); font-weight: 500; }

.site-rows { background: var(--panel); border-radius: var(--radius); overflow: hidden; margin-bottom: 18px; }
.site-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 12px 14px; border-top: 1px solid var(--line); }
.site-row:first-child { border-top: 0; }
.site-row:active { background: var(--panel-2); }
.site-row .name { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.site-row .ours { text-align: right; font-weight: 700; }
.site-row .sub { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: 12px; }
.site-row .sub b { color: var(--text); font-weight: 500; }

.grid2 { display: grid; gap: 14px; }

.breakdown { width: 100%; border-collapse: collapse; font-size: 14px; }
.breakdown th { text-align: right; font-weight: 500; color: var(--muted); font-size: 12px; padding: 6px 4px; }
.breakdown th:first-child, .breakdown td:first-child { text-align: left; }
.breakdown td { text-align: right; padding: 10px 4px; border-top: 1px solid var(--line); white-space: nowrap; }
.breakdown tr.total td { font-weight: 700; }
.breakdown .hide-sm { display: none; }

.chart { display: flex; align-items: stretch; gap: 2px; height: 70px; margin: 4px 0 12px; position: relative; }
.chart::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px dashed var(--line); pointer-events: none; }
.bar { flex: 1; min-width: 2px; display: flex; flex-direction: column; }
.bar .up { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; }
.bar .down { flex: 1; display: flex; flex-direction: column; justify-content: flex-start; }
.bar i { display: block; border-radius: 2px; }
.bar .up i { background: var(--good); }
.bar .down i { background: var(--bad); }
.chart-legend { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-top: -6px; margin-bottom: 8px; }

.alert { padding: 12px 14px; border-radius: 12px; background: rgba(255,93,93,.12); color: #ffbcbc; font-size: 13px; margin-bottom: 14px; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; margin: 2px 0 12px; }
.site-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.site-head h1 { font-size: 22px; margin: 0; display: flex; align-items: center; gap: 10px; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.fact { background: var(--panel); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.fact span { display: block; color: var(--muted); font-size: 11px; }
.fact b { font-size: 14px; }

.share-table { width: 100%; border-collapse: collapse; }
.share-table td { padding: 11px 4px; border-top: 1px solid var(--line); vertical-align: top; }
.share-table tr:first-child td { border-top: 0; }
.share-table .pct { font-size: 18px; font-weight: 700; text-align: right; }
.history { color: var(--muted); font-size: 12px; margin-top: 4px; }
.toggle { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.toggle input { width: auto; margin-top: 3px; }

.list { list-style: none; padding: 0; margin: 0 0 12px; }
.list li { display: flex; justify-content: space-between; gap: 10px; padding: 11px 0; border-top: 1px solid var(--line); align-items: center; }
.list li:first-child { border-top: 0; }
.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 1; }
.empty { color: var(--muted); padding: 28px 0; text-align: center; }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); width: min(420px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.6); }

@media (max-width: 520px) {
  .brand .word { display: none; }
  .tabs a { padding: 8px 9px; }
}
@media (min-width: 760px) {
  main { padding: 22px 22px 64px; }
  .hero-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; }
  .hero { margin-bottom: 0; }
  .grid2 { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
  .facts { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .breakdown .hide-sm { display: table-cell; }
}

/* ---------- Seite im Detail ---------- */
.status-line { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: 13px; margin: -2px 0 14px; }
.status-line b { color: var(--text); font-weight: 500; }
.mini-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.mini-table th { text-align: right; color: var(--muted); font-weight: 500; font-size: 12px; padding: 4px; }
.mini-table th:first-child, .mini-table td:first-child { text-align: left; }
.mini-table td { text-align: right; padding: 8px 4px; border-top: 1px solid var(--line); }
.wallet-view { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); }
.wallet-view .head { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.wallet-view .line { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); padding: 3px 0; }
.wallet-view .line b { color: var(--text); font-weight: 500; }
.settle-panel .open-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.settle-panel .open-head h2 { margin: 0; }
.settle-list { list-style: none; margin: 0; padding: 0; }
.settle-list li { border-top: 1px solid var(--line); padding: 10px 0; }
.settle-list li.voided { opacity: .55; }
.settle-list .line1 { display: flex; justify-content: space-between; gap: 10px; }
.settle-list .line2 { color: var(--muted); font-size: 12px; margin-top: 3px; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.badge { display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 6px; background: var(--panel-2); color: var(--muted); }
.badge.bad { background: rgba(255,93,93,.15); color: #ffb3b3; }
#settle-preview .kpi { padding: 6px 0; }

.breakdown tr.locked td { text-align: left; white-space: normal; color: var(--muted); font-size: 12px; padding: 8px 4px; }
