:root {
  --bg: #f4f2ee;
  --panel: #ffffff;
  --ink: #1d1f24;
  --muted: #6b6f78;
  --line: #e4e1da;
  --accent: #2f4b7c;
  --accent-soft: #e6ecf6;
  --hoch: #b4322a;
  --hoch-soft: #fbe9e7;
  --mittel: #a8650a;
  --mittel-soft: #fdf1df;
  --niedrig: #4f6a5a;
  --niedrig-soft: #e7efe9;
  --ok: #2f7a4f;
  --err: #b4322a;
  --a-auftraege: #2f4b7c;
  --a-finanzen: #7a4b9c;
  --a-lager: #3d7f86;
  --a-bank: #2f7a4f;
  --a-mail: #8a6d1f;
  --a-steuer: #b4322a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 20, 30, .05), 0 2px 8px rgba(20, 20, 30, .04);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171b;
    --panel: #1e2126;
    --ink: #e9e7e2;
    --muted: #9aa0aa;
    --line: #2d3138;
    --accent: #8fb0e8;
    --accent-soft: #233046;
    --hoch: #f08c80;
    --hoch-soft: #3a2422;
    --mittel: #e8b45e;
    --mittel-soft: #37301f;
    --niedrig: #9cc3ab;
    --niedrig-soft: #213028;
    --ok: #7cc79b;
    --err: #f08c80;
    --a-auftraege: #8fb0e8;
    --a-finanzen: #c39be0;
    --a-lager: #7cc6cc;
    --a-bank: #7cc79b;
    --a-mail: #e0c36a;
    --a-steuer: #f08c80;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); line-height: 1.45; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Kopfzeile ---------- */
header.top {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 14px 28px; border-bottom: 1px solid var(--line); background: var(--panel);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; letter-spacing: -.01em; font-size: 17px; }
.brand span { color: var(--muted); font-weight: 500; }
.today { color: var(--muted); }
.spacer { flex: 1; }
.sources { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px;
  padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); background: var(--panel);
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.chip.err { color: var(--err); border-color: color-mix(in srgb, var(--err) 40%, var(--line)); cursor: help; }
.chip.err .dot { background: var(--err); }
.chip.off { cursor: help; }
.chip.off .dot { background: var(--line); border: 1px solid var(--muted); }
.btn {
  border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 6px 12px; font-size: 13.5px;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #10131a; } }
.btn:disabled { opacity: .6; cursor: default; }

.banner {
  margin: 0; padding: 8px 28px; font-size: 13.5px; background: var(--mittel-soft); color: var(--mittel);
  border-bottom: 1px solid var(--line);
}

/* ---------- Layout ---------- */
main { max-width: 1240px; margin: 0 auto; padding: 24px 28px 64px; }
.summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .label { font-size: 12.5px; color: var(--muted); }
.stat .value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; margin-top: 2px; }
.stat .sub { font-size: 12.5px; color: var(--muted); }
.stat.alert .value { color: var(--hoch); }

.grid { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 22px; align-items: start; }
aside { min-width: 0; position: sticky; top: 76px; display: flex; flex-direction: column; gap: 18px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.areas { padding: 6px; }
.area-btn {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; border: 0; background: none;
  padding: 7px 10px; border-radius: 7px; font-size: 14px;
}
.area-btn:hover { background: var(--bg); }
.area-btn.active { background: var(--accent-soft); font-weight: 600; }
.area-btn .sw { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.area-btn .count { margin-left: auto; color: var(--muted); font-size: 12.5px; }
.area-btn .count b { color: var(--hoch); font-weight: 650; margin-right: 4px; }

.side-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px 4px; font-weight: 600; }
.accounts { display: flex; flex-direction: column; gap: 8px; }
.acct { padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.acct .name { font-size: 13.5px; font-weight: 600; }
.acct .bal { font-size: 18px; font-weight: 650; letter-spacing: -.01em; margin-top: 2px; }
.acct .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.acct .meta.warn { color: var(--mittel); }
.acct.drop { outline: 2px dashed var(--accent); outline-offset: -4px; }
.acct .upload { margin-top: 8px; font-size: 12.5px; padding: 4px 9px; }

/* ---------- Liste ---------- */
.group { margin-bottom: 22px; }
.group h2 { display: flex; align-items: baseline; gap: 10px; font-size: 14px; margin: 0 0 8px 2px; }
.group h2 .n { color: var(--muted); font-weight: 500; }
.group h2 .bar { width: 4px; height: 14px; border-radius: 2px; align-self: center; }
.list { overflow: hidden; }
.item {
  display: grid; grid-template-columns: 1fr auto auto; gap: 16px; align-items: center;
  padding: 12px 16px; border-top: 1px solid var(--line);
}
.item:first-child { border-top: 0; }
.item.leaving { opacity: 0; transform: translateX(12px); transition: all .25s; }
.item > div { min-width: 0; }
.item .title { font-weight: 560; overflow-wrap: anywhere; }
.item .tags { flex-wrap: wrap; }
.item .detail { color: var(--muted); font-size: 13.5px; margin-top: 1px; }
.item .tags { display: flex; gap: 6px; align-items: center; margin-bottom: 3px; font-size: 12px; }
.tag { padding: 1px 7px; border-radius: 5px; font-weight: 600; font-size: 11.5px; }
.due { color: var(--muted); }
.due.late { color: var(--hoch); font-weight: 600; }
.amount { font-weight: 600; text-align: right; white-space: nowrap; }
.amount.neg { color: var(--muted); }
.actions { display: flex; gap: 6px; opacity: .55; transition: opacity .15s; }
.item:hover .actions, .item:focus-within .actions { opacity: 1; }
.icon-btn { border: 1px solid var(--line); background: var(--panel); border-radius: 7px; padding: 4px 9px; font-size: 12.5px; text-decoration: none; color: var(--ink); white-space: nowrap; }
.icon-btn:hover { border-color: var(--muted); }
.icon-btn.done:hover { border-color: var(--ok); color: var(--ok); }
.snooze { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 4px); background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.12); padding: 4px; z-index: 10; min-width: 140px;
}
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 6px 10px; border-radius: 5px; font-size: 13px; }
.menu button:hover { background: var(--bg); }

.empty { padding: 40px; text-align: center; color: var(--muted); }
details.hidden-list { margin-top: 10px; }
details.hidden-list summary { cursor: pointer; color: var(--muted); font-size: 13.5px; padding: 6px 2px; }
details.hidden-list .item .title { font-weight: 450; color: var(--muted); }
.footer-note { color: var(--muted); font-size: 12.5px; margin-top: 18px; }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg);
  padding: 9px 16px; border-radius: 8px; font-size: 13.5px; z-index: 20; display: flex; gap: 14px; align-items: center;
}
.toast button { background: none; border: 0; color: inherit; text-decoration: underline; padding: 0; }

@media (max-width: 900px) {
  header.top { padding: 12px 16px; }
  main { padding: 16px; }
  .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .accounts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
  aside { position: static; }
  .areas { display: flex; overflow-x: auto; }
  .area-btn { width: auto; white-space: nowrap; }
  .item { grid-template-columns: 1fr auto; }
  .item .actions { grid-column: 1 / -1; opacity: 1; }
}

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 360px; padding: 28px; }
.login h1 { font-size: 19px; margin: 0 0 4px; }
.login p { color: var(--muted); margin: 0 0 20px; font-size: 13.5px; }
.login label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
.login input { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: var(--bg); color: var(--ink); }
.login .btn { width: 100%; margin-top: 18px; padding: 9px; }
.login .error { color: var(--err); font-size: 13.5px; margin-top: 12px; min-height: 1em; }
