:root {
  color-scheme: light;
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #f0efec;
  --line: #e6e5e1;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #8a8984;
  --accent: #2a78d6;
  --focus: #2a78d633;
  --good: #008300;
  --bad: #d03b3b;
  --warn: #a35a00;
  --warn-bg: #fff4e0;
  --neutral: #b9b8b2;
  --band-op: .34; --band-rest: .2;
  --fix: #8c8b85;
  --c0: #85847e; --c1: #2a78d6; --c2: #eb6834; --c3: #1baf7a; --c4: #eda100;
  --c5: #e87ba4; --c6: #008300; --c7: #4a3aa7; --c8: #e34948;
  --c9: #0f8fa3; --c10: #8a5a2b; --c11: #7a8a00; --c12: #5c6bc0;
  --c13: #b5179e; --c14: #0095d0; --c15: #5b6b7c; --c16: #f0705e;
  --c17: #43a047; --c18: #8e44ad; --c19: #d4b000; --c20: #1f3a93;
  --c21: #a12828; --c22: #22a68f; --c23: #3e3e3c; --c24: #bcbbb4;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211; --surface: #1a1a19; --surface-2: #242422; --line: #2e2e2b;
    --text: #f4f4f2; --text-2: #c3c2b7; --muted: #8a8984; --accent: #3987e5; --focus: #3987e540;
    --good: #3fb950; --bad: #e66767; --neutral: #4b4b47; --fix: #a5a49d; --band-op: .5; --band-rest: .22; --warn: #e8a33d; --warn-bg: #2e2416;
    --c0: #9a9993; --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500;
    --c5: #d55181; --c6: #008300; --c7: #a08cf0; --c8: #e66767;
    --c9: #22a7bb; --c10: #b07a45; --c11: #a3b51a; --c12: #6c74e8;
    --c13: #d64ec0; --c14: #33b8ec; --c15: #8696a7; --c16: #ff8f80;
    --c17: #5fc463; --c18: #b072d0; --c19: #e6c419; --c20: #3a56b0;
    --c21: #c24a4a; --c22: #47d1b8; --c23: #5a5a56; --c24: #d6d5ce;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1a1a19; --surface-2: #242422; --line: #2e2e2b;
  --text: #f4f4f2; --text-2: #c3c2b7; --muted: #8a8984; --accent: #3987e5; --focus: #3987e540;
  --good: #3fb950; --bad: #e66767; --neutral: #4b4b47; --fix: #a5a49d; --band-op: .5; --band-rest: .22; --warn: #e8a33d; --warn-bg: #2e2416;
  --c0: #9a9993; --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500;
  --c5: #d55181; --c6: #008300; --c7: #a08cf0; --c8: #e66767;
  --c9: #22a7bb; --c10: #b07a45; --c11: #a3b51a; --c12: #6c74e8;
  --c13: #d64ec0; --c14: #33b8ec; --c15: #8696a7; --c16: #ff8f80;
  --c17: #5fc463; --c18: #b072d0; --c19: #e6c419; --c20: #3a56b0;
  --c21: #c24a4a; --c22: #47d1b8; --c23: #5a5a56; --c24: #d6d5ce;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
svg { fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

/* ── Header ── */
.top {
  position: sticky; top: 0; z-index: 10;
  display: grid; grid-template-columns: auto auto 1fr auto; grid-template-areas: "brand tabs profile tools";
  align-items: center; column-gap: 24px; row-gap: 12px;
  padding: 14px max(16px, calc((100vw - 1120px) / 2));
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.top .brand { grid-area: brand; }
.top .tabs { grid-area: tabs; }
.top .profile { grid-area: profile; justify-self: center; }
.top .tools { grid-area: tools; }
.brand { font-weight: 650; letter-spacing: -0.01em; }
.tabs { display: flex; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: 10px; overflow-x: auto; }
.tabs button { padding: 6px 12px; border-radius: 8px; color: var(--text-2); white-space: nowrap; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / 0.08); }
.tools { display: flex; align-items: center; gap: 4px; justify-content: flex-end; }
.status { font-size: 12px; color: var(--muted); margin-right: 8px; transition: opacity .3s; }
.icon { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; color: var(--text-2); }
.icon:hover { background: var(--surface-2); color: var(--text); }
.icon svg { width: 18px; height: 18px; }
.icon:disabled { opacity: .35; pointer-events: none; }
.menu { position: relative; }
.menu-pop {
  position: absolute; right: 0; top: 38px; min-width: 230px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 8px 30px rgb(0 0 0 / 0.12); display: flex; flex-direction: column;
}
.menu-pop button { text-align: left; padding: 8px 10px; border-radius: 8px; }
.menu-pop button:hover { background: var(--surface-2); }
.menu-pop .danger { color: var(--bad); }

/* ── Layout ── */
main { max-width: 1120px; margin: 0 auto; padding: 32px 16px 80px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); align-items: start; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); min-width: 0;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { font-size: 13px; font-weight: 600; margin: 0; color: var(--text-2); }
.card-head .sum { font-weight: 600; }
.label { font-size: 12px; color: var(--muted); }

/* ── Hero ── */
.hero { padding: 24px; }
.hero-top { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.hero-num { font-size: clamp(32px, 6vw, 44px); font-weight: 650; letter-spacing: -0.03em; line-height: 1.05; }
.hero-side { text-align: right; }
.hero-side .v { font-size: 18px; font-weight: 600; }

/* ── KPI tiles ── */
.kpis { display: grid; gap: 12px 20px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); }
.kpi { padding: 16px 18px; }
.kpi .v { font-size: 22px; font-weight: 620; letter-spacing: -0.02em; margin-top: 2px; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.pos { color: var(--good); }
.neg { color: var(--bad); }
.meter { height: 4px; border-radius: 4px; background: var(--surface-2); margin-top: 10px; overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 4px; background: var(--accent); transition: width .3s; }
.meter.over > i { background: var(--bad); }

/* ── Stacked bar ── */
.bar { display: flex; gap: 2px; height: 28px; border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.bar > div { min-width: 0; transition: flex-basis .3s; position: relative; }
.bar > div:hover { filter: brightness(1.08); }
.bar .hatch { background: repeating-linear-gradient(135deg, var(--neutral) 0 2px, transparent 2px 6px) !important; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 14px; font-size: 12px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend b { font-weight: 600; color: var(--text); }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ── Editable tables ── */
table { width: 100%; border-collapse: collapse; }
th { font-size: 12px; font-weight: 500; color: var(--muted); text-align: left; padding: 0 6px 6px; white-space: nowrap; }
th.r, td.r { text-align: right; }
td { padding: 1px 0; vertical-align: middle; }
.scroll { overflow-x: auto; margin: 0 -6px; }
.scroll table { min-width: 720px; }
.scroll td:first-child { min-width: 170px; }
.in {
  width: 100%; border: 1px solid transparent; background: transparent; border-radius: 7px;
  padding: 6px; outline: none; min-width: 0; text-overflow: ellipsis;
}
.in:hover { background: var(--surface-2); }
.in:focus { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.in.num { text-align: right; }
.in::placeholder { color: var(--muted); }
select.in { appearance: none; cursor: pointer; padding-right: 6px; min-width: 96px; }
.out { padding: 6px; text-align: right; font-weight: 600; white-space: nowrap; }
.muted { color: var(--muted); }

.rows { display: flex; flex-direction: column; }
.row { display: grid; grid-template-columns: 18px minmax(0, 1fr) 108px 28px; align-items: center; gap: 2px 4px; position: relative; padding-bottom: 3px; border-radius: 8px; }
.row.has-flag { grid-template-columns: 18px minmax(0, 1fr) 108px 28px 28px; }
.row .track { position: absolute; left: 28px; right: 58px; bottom: 1px; height: 2px; border-radius: 2px; pointer-events: none; }
.row.has-flag .track { right: 90px; }
.row .track i { display: block; height: 100%; background: var(--accent); opacity: .35; border-radius: 2px; transition: width .3s; }
.row:hover .track i, .row:focus-within .track i { opacity: .8; }
.del, .flag { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 7px; color: var(--muted); opacity: 0; }
.row:hover .del, .row:focus-within .del, tr:hover .del, tr:focus-within .del { opacity: 1; }

/* ── Drag & drop ── */
.grip {
  width: 18px; height: 28px; display: grid; place-items: center; border-radius: 6px; color: var(--muted);
  cursor: grab; touch-action: none; opacity: .35; transition: opacity .15s;
}
.grip svg { width: 16px; height: 16px; stroke-width: 2.6; }
.row:hover .grip, tr:hover .grip, .grip:focus-visible { opacity: 1; }
.grip:hover { color: var(--text); background: var(--surface-2); }
.grip:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.is-dragging, .is-dragging * { cursor: grabbing !important; user-select: none; }
.dragging { position: relative; z-index: 2; background: var(--surface) !important; box-shadow: 0 6px 24px rgb(0 0 0 / 0.14); border-radius: 8px; }
.dragging > td { background: var(--surface); }
.dragging .grip { opacity: 1; color: var(--accent); }
.empty-drop, .empty-row td {
  padding: 10px; font-size: 12px; color: var(--muted); text-align: center;
  border: 1px dashed var(--line); border-radius: 8px;
}
.del:hover { color: var(--bad); background: var(--surface-2); }
.del svg, .flag svg { width: 15px; height: 15px; }
.flag { opacity: .45; }
.flag:hover { opacity: 1; background: var(--surface-2); }
.flag[aria-pressed="true"] { opacity: 1; color: var(--c2); }
.add {
  margin-top: 8px; padding: 7px 6px; color: var(--muted); font-size: 13px; border-radius: 7px;
  display: inline-flex; align-items: center; gap: 6px;
}
.add:hover { color: var(--accent); background: var(--surface-2); }
.add svg { width: 14px; height: 14px; }
.note { font-size: 12px; color: var(--muted); margin: 12px 0 0; }

.inline { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.inline .in { width: 130px; font-size: 16px; font-weight: 600; border-color: var(--line); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 3px; margin-right: 8px; flex: none; }
.namecell { display: flex; align-items: center; padding-left: 6px; }


/* ── Tooltip ── */
.tip {
  position: fixed; z-index: 50; pointer-events: none; padding: 8px 10px; border-radius: 9px;
  background: var(--text); color: var(--bg); font-size: 12px; line-height: 1.45; width: max-content; max-width: min(320px, calc(100vw - 16px));
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.18);
}
.tip b { font-weight: 600; }

td.g { width: 22px; }
td.c, th.c { text-align: center; }
.small { font-size: 12px; }

/* ── Sparverteilung ── */
.card-head .inline { margin: 0; gap: 10px; }
.alloc { min-width: 880px; table-layout: fixed; }
.alloc col.c-g { width: 22px; }
.alloc col.c-num { width: 112px; }
.alloc col.c-val { width: 120px; }
.alloc col.c-del { width: 32px; }
.alloc .group-head td { padding: 18px 6px 4px; }
.alloc tbody.group:first-of-type .group-head td { padding-top: 4px; }
.alloc .group-head div { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.alloc .hint { font-size: 12px; color: var(--muted); flex: 1 1 260px; }
.alloc .group-sum { font-weight: 600; font-size: 13px; }
.pool-share { font-size: 12px; color: var(--muted); white-space: nowrap; }
.pool-share.full { color: var(--good); }
.pool-cap { margin: 6px 0 0; font-size: 12px; color: var(--warn); }
.alloc .colhead th { padding-top: 6px; border-bottom: 1px solid var(--line); }
.alloc .group-foot td { padding: 2px 0 6px; }
.alloc tbody.group { border-bottom: 1px solid var(--line); }
.alloc .totals td { padding-top: 6px; }
.alloc .totals .namecell { padding-left: 6px; gap: 0; }
.alloc .sum-row td { border-top: 1px solid var(--line); font-weight: 650; padding: 8px 6px 0; }
.alloc .sum-row .out { padding: 0 6px; font-size: 15px; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.p-clamp { --pc: var(--c1); } .p-pool { --pc: var(--c3); } .p-target { --pc: var(--c2); } .p-main { --pc: var(--text-2); } .p-fix { --pc: var(--fix); }
.namecell .pill { margin-left: 6px; font-size: 11px; font-weight: 600; }
.pill { color: var(--pc); background: color-mix(in srgb, var(--pc) 13%, transparent); }
select.cat.p-clamp, select.cat.p-pool, select.cat.p-target { color: var(--pc); font-weight: 600; }
.assign {
  appearance: none; border: 0; background: none; color: var(--muted); font-size: 13px; padding: 6px; border-radius: 7px; cursor: pointer;
}
.assign:hover, .assign:focus { color: var(--accent); background: var(--surface-2); outline: none; }
.namecell { gap: 4px; }
.namecell .in { font-weight: 500; }
.alloc-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px 16px; flex-wrap: wrap; margin-top: 12px; }
.alloc-foot select.in { width: auto; color: var(--text); font-weight: 500; }

/* ── Einnahmen & Ausgaben ── */
.io { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(0, 2fr); gap: 20px; align-items: start; }
.io-col { display: grid; gap: 12px; min-width: 0; }
.col-title { display: flex; justify-content: space-between; align-items: baseline; padding: 0 4px; }
.col-title h2 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -0.01em; }
.col-title .sum { font-weight: 650; font-size: 15px; }
.io-col > .add { justify-self: start; margin-top: 0; }
.io-col > .note { margin: 0 4px; }
.blocks { display: grid; gap: 14px; }
.block { padding: 16px 18px 12px; }
.block-head { display: flex; align-items: center; gap: 6px; }
.block-head .block-name { font-size: 15px; font-weight: 650; flex: 1; padding: 4px 6px; }
.block-head .del { opacity: .5; }
.block-acc { display: flex; align-items: center; gap: 2px; color: var(--muted); }
.block-acc svg { width: 14px; height: 14px; flex: none; }
.block-acc select.in { width: auto; max-width: 170px; font-size: 13px; color: var(--text-2); }
.toggle {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; font-size: 12px; font-weight: 600;
  color: var(--muted); border: 1px solid var(--line); white-space: nowrap;
}
.toggle svg { width: 14px; height: 14px; }
.toggle.icon-only { width: 30px; height: 28px; padding: 0; justify-content: center; border-radius: 8px; }
.toggle.icon-only svg { width: 16px; height: 16px; }
.toggle:hover { color: var(--text); border-color: var(--text-2); }
.toggle[aria-pressed="true"] { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 50%, transparent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.block-meta { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 10px 30px; }
.chip { font-size: 12px; padding: 2px 9px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.chip.rule { background: color-mix(in srgb, var(--c3) 13%, transparent); color: var(--text); font-weight: 600; }
.block-lists { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 4px 20px; }
.sub-head {
  display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-weight: 600;
  padding: 6px 6px 6px 24px; border-bottom: 1px solid var(--line); margin-bottom: 4px;
}
.sub-head span:last-child { color: var(--text-2); }
.block.dragging { box-shadow: 0 12px 36px rgb(0 0 0 / 0.18); }
@media (max-width: 860px) { .io { grid-template-columns: minmax(0, 1fr); } }

/* ── Konten ── */
.acc-table { min-width: 760px; table-layout: fixed; }
.acc-table th { padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.acc-table td { padding: 3px 8px; border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent); }
.acc-table tbody tr:last-child td { border-bottom: 0; }
.acc-table th:not(:first-child) { padding-left: 8px; padding-right: 8px; }
.acc-table td.g { padding: 0 0 0 4px; }
.acc-table .namecell { padding-left: 0; }
.acc-table .namecell .pill { margin-left: auto; flex: none; }
.acc-table td.r .out { padding-right: 0; }
.acc-table .rules-n, .acc-table th.rules-n { padding-left: 28px; color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.grid.wide { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.acc-table th:first-child, .rules-table th:first-child { width: 22px; }
.acc-table select.in { min-width: 160px; }
.acc-table input[type="radio"] { accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer; }
.note.lead { margin: -4px 0 14px; max-width: 70ch; }
.cats { margin: 0; display: grid; gap: 10px; }
.cats div { display: grid; grid-template-columns: 110px 1fr; gap: 12px; align-items: baseline; }
.cats dd { margin: 0; color: var(--text-2); font-size: 13px; }

@media (max-width: 860px) {
  .top { grid-template-columns: auto 1fr auto; grid-template-areas: "brand profile tools" "tabs tabs tabs"; column-gap: 12px; }
  .top .tabs { width: 100%; }
  .profile .menu-pop { left: auto; right: 0; transform: none; }
}
@media (max-width: 640px) {
  main { padding-top: 20px; }
  .hero-side { text-align: left; }
  .del { opacity: 1; }
}

/* ── Geldfluss ── */
.flow-wrap { overflow-x: auto; margin: 4px -4px 0; padding: 0 4px; }
.flow { display: block; fill: none; stroke: none; max-width: none; }
.flow .band { fill: var(--fc); opacity: var(--band-op); transition: opacity .15s; }
/* income → default account: always a neutral grey, whatever colour the account has */
.flow .band.rest { fill: var(--text-2); opacity: var(--band-rest); }
.flow .band:hover { opacity: .7; }
.flow .node { fill: var(--fc); }
.flow .node.var { fill: var(--surface); stroke: var(--fc); stroke-width: 1.5; stroke-dasharray: 3 2; }
/* surplus transfers: the amount varies, so no band – a soft ribbon with dots running towards the target */
.flow .over-bg { stroke: var(--fc); stroke-width: 8; stroke-linecap: round; stroke-linejoin: round; fill: none; opacity: .18; transition: opacity .15s; }
.flow .over { stroke: var(--fc); stroke-width: 2.5; stroke-dasharray: 0.1 7; stroke-linecap: round; fill: none; animation: surplus-flow 1.4s linear infinite; }
.flow .head { fill: var(--fc); stroke: var(--fc); stroke-width: 1; stroke-linejoin: round; }
@keyframes surplus-flow { to { stroke-dashoffset: -14.2; } }
@media (prefers-reduced-motion: reduce) { .flow .over { animation: none; } }
.flow .pill-bg { fill: color-mix(in srgb, var(--fc) 12%, var(--surface)); stroke: color-mix(in srgb, var(--fc) 45%, transparent); stroke-width: 1; }
.flow .arrow:hover .over-bg, .flow.hl .arrow.on .over-bg { opacity: .32; }
.flow .hit { stroke: transparent; stroke-width: 12; fill: none; }
.flow .arrowhead { stroke: var(--text-2); stroke-width: 1.5; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.flow text { fill: var(--text); font-size: 12.5px; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.flow .name { font-weight: 550; }
.flow .sub { fill: var(--text-2); font-size: 11.5px; }
.flow .sub.bad { fill: var(--bad); }
.flow .thr-label { fill: var(--text); font-size: 11px; font-weight: 500; stroke-width: 0; }
.flow .arrow.warn .thr-label { fill: var(--warn); }
.flow .colhead { fill: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; stroke-width: 0; }
.flow .band, .flow .arrow, .flow .node, .flow .label { transition: opacity .15s; }
.flow.hl .band:not(.on), .flow.hl .arrow:not(.on), .flow.hl .node:not(.on), .flow.hl .label:not(.on) { opacity: .12; }
.flow.hl .band.on { opacity: .7; }
.flow .label { cursor: default; }
.flow-key { margin-top: 8px; }
.flow-key .dash { width: 22px; height: 8px; border-radius: 4px; background:
  radial-gradient(circle, var(--c7) 1.3px, transparent 1.6px) 0 50% / 7px 8px repeat-x,
  color-mix(in srgb, var(--c7) 18%, transparent); }

.edit { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.edit summary { cursor: pointer; color: var(--text-2); font-size: 13px; width: fit-content; }
.edit summary:hover { color: var(--accent); }
.edit[open] summary { margin-bottom: 10px; }
.rules-table select.in { min-width: 120px; }
.rules-table .group-head td { padding: 18px 6px 6px; }
.rules-table tbody:first-of-type .group-head td { padding-top: 4px; }
.rules-table .group-head div { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.rules-table .group-head .pill { --pc: var(--kc); }
.rules-table .colhead th { font-size: 11.5px; font-weight: 600; color: var(--muted); text-align: left; padding: 4px 6px; }
.rules-table .colhead th.r { text-align: right; padding-right: 12px; }
.rules-table .group-foot td { padding: 4px 0 6px; }
.rules-table .empty-row td { color: var(--muted); font-size: 13px; padding: 8px 6px; }
.k-split { --kc: var(--accent); }
.k-overflow { --kc: var(--c7); }
.rules-table td.to { width: 20px; color: var(--muted); }
.rules-table td.to svg { width: 14px; height: 14px; display: block; }
.thr { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.thr .in { min-width: 0; font-size: 14px; color: var(--text); }
.rules-table .in.num { font-weight: 600; }
.rules-table td:nth-child(6) { width: 140px; }
.thr.day .in { width: 40px; text-align: center; }
.edit-foot { display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap; margin-top: 6px; }
.edit-foot .add { margin: 0; }
.edit-foot .main-acc { margin-left: auto; }
.main-acc select.in { width: auto; min-width: 140px; color: var(--text); }
.add svg { flex: none; }
.swatch { width: 12px; height: 12px; border-radius: 50%; flex: none; margin: 0 4px 0 6px; }
.swatch:hover { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--text-2); }

.picker {
  position: fixed; z-index: 40; padding: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 8px 30px rgb(0 0 0 / 0.14);
}
.picker-colors { display: grid; grid-template-columns: repeat(5, 22px); gap: 8px; }
.picker-colors button:hover { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--muted); }
.picker-colors button { width: 20px; height: 20px; border-radius: 50%; }
.picker-colors [aria-pressed="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text-2); }

.outdated {
  position: sticky; top: 0; z-index: 80; padding: 10px 16px; text-align: center; font-weight: 600; font-size: 13px;
  color: #fff; background: var(--bad);
}

/* ── Hauptkonto ── */

/* ── Abweichungen von der Budgetübersicht ── */
.devs { border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); background: var(--warn-bg); border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; font-size: 13px; }
.devs.ok { background: color-mix(in srgb, var(--good) 8%, var(--surface)); border-color: color-mix(in srgb, var(--good) 30%, transparent); }
.devs svg, .st svg { width: 14px; height: 14px; flex: none; }
.devs-head { display: flex; align-items: center; gap: 8px; color: var(--warn); }
.devs-head b { font-weight: 600; }
.devs-head .mini { margin-left: auto; }
.devs-head.ok { color: var(--good); }
.devs ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.devs li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--text); }
.devs li > svg { color: var(--warn); }
.devs li.miss > svg { color: var(--muted); }
.devs li > span { flex: 1 1 260px; }
.devs li b { font-weight: 600; }
.devs > .mini { margin-top: 8px; }
.mini { font-size: 12px; padding: 3px 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--text-2); white-space: nowrap; }
.mini:hover { color: var(--accent); border-color: var(--accent); }
.mini.ghost { border-color: transparent; background: none; color: var(--muted); }
.st { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; white-space: nowrap; }
.st.ok svg { width: 17px; height: 17px; stroke-width: 2.2; }
.st.ok { color: var(--good); }
.st.warn { color: var(--warn); }
.status { display: flex; align-items: center; gap: 6px; min-height: 34px; }
.rules-table select.link { min-width: 170px; max-width: 220px; color: var(--text-2); }
.rules-table { min-width: 980px; }
.flow .warn { fill: var(--warn); }

/* ── Anmeldung ── */
.locked .tabs, .locked .tools, .locked main { display: none; }
.auth { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: var(--bg); }
.auth-card {
  width: min(100%, 360px); display: grid; gap: 14px; padding: 28px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.auth-card .brand { color: var(--muted); font-size: 13px; }
.auth-card h1 { margin: -8px 0 4px; font-size: 22px; letter-spacing: -0.02em; }
.auth-card label { display: grid; gap: 6px; font-size: 12px; color: var(--text-2); }
.field {
  width: 100%; padding: 9px 10px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface); font-size: 14px; outline: none;
}
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.primary { padding: 10px; border-radius: 9px; background: var(--accent); color: #fff; font-weight: 600; }
.primary:hover { filter: brightness(1.08); }
.primary:disabled { opacity: .6; cursor: wait; }
.auth-err { margin: 0; font-size: 13px; color: var(--bad); }
.auth-switch { margin: 0; font-size: 13px; color: var(--muted); text-align: center; }
.auth-switch button { color: var(--accent); }
.menu-user { display: grid; padding: 6px 10px 8px; border-bottom: 1px solid var(--line); margin-bottom: 2px; }
.auth.modal { background: rgb(0 0 0 / 0.38); backdrop-filter: blur(2px); z-index: 70; }
.auth.modal .note { margin: -6px 0 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.dialog-actions .primary { padding: 9px 16px; }
.secondary { padding: 9px 14px; border-radius: 9px; border: 1px solid var(--line); color: var(--text-2); }
.secondary:hover { color: var(--text); background: var(--surface-2); }
.menu-pop hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; width: 100%; }

/* ── Privacy mode ── */
.private .in.num:not(:focus), .private [data-out], .private .out, .private .legend b,
.private [data-block-out], .private .group-sum, .private select.link, .private .max-btn b, .private .tip, .private .flow .amt, .private .devs li > span, .private .st.warn { filter: blur(5px); }
.private .thr.day .in { filter: none; }
#privacy[aria-pressed="true"] { color: var(--accent); }
.icon.lang { font-size: 11.5px; font-weight: 700; letter-spacing: .03em; width: 34px; }
.auth-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: -6px; }


/* account names in the overview are read-only (edited in the accounts tab) */
.acc-name { font-weight: 500; padding: 6px 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.namecell .dot { flex: none; margin: 0 4px 0 6px; }
.group-foot .add { margin-left: 4px; }

/* confirm dialog */
.confirm-card { max-width: 400px; }
.confirm-card h1 { font-size: 17px; }
.confirm-card p { margin: 0; color: var(--text-2); font-size: 14px; line-height: 1.45; }
.primary.danger { background: var(--bad); }

/* profile switcher + menus */
.profile-btn { display: flex; align-items: center; gap: 7px; max-width: 240px; padding: 5px 9px 5px 8px; border: 1px solid var(--line); border-radius: 9px; font-size: 13px; font-weight: 550; color: var(--text); }
.profile-btn:hover, .profile-btn[aria-expanded="true"] { background: var(--surface-2); }
.profile-btn svg { width: 16px; height: 16px; flex: none; color: var(--text-2); }
.profile-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile .menu-pop { left: 50%; right: auto; transform: translateX(-50%); min-width: 240px; z-index: 20; }
.menu-head { display: grid; gap: 2px; padding: 6px 10px 8px; }
.menu-head span { font-size: 12px; color: var(--muted); }
.menu-pop button { display: flex; align-items: center; gap: 10px; }
.menu-pop button svg { width: 16px; height: 16px; flex: none; color: var(--text-2); }
.menu-pop .danger svg { color: inherit; }
.menu-pop button:disabled { opacity: .4; cursor: default; background: none; }
.menu-pop .muted-item { color: var(--text-2); }
.menu-pop .menu-sec .pname { text-transform: none; letter-spacing: 0; font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-pop hr { margin: 6px 0 2px; }
.menu-sec { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding: 10px 10px 4px; display: flex; gap: 4px; min-width: 0; }
.menu-sec b { text-transform: none; letter-spacing: 0; color: var(--text-2); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-item .chk { display: flex; width: 16px; }
.profile-item .chk svg { color: var(--accent); visibility: hidden; }
.profile-item[aria-current="true"] { font-weight: 600; }
.profile-item[aria-current="true"] .chk svg { visibility: visible; }
.profile-item .pname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.confirm-card label { display: grid; gap: 6px; font-size: 13px; color: var(--text-2); }

/* Sparbetrag controls in the head of the Sparverteilung – quiet until used */
.spar-ctl { display: flex; align-items: center; gap: 6px 18px; flex-wrap: wrap; justify-content: flex-end; }
.spar { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.stepper { display: flex; align-items: center; border: 1px solid transparent; border-radius: 8px; transition: border-color .15s, background .15s; }
.stepper:hover, .stepper:focus-within { border-color: var(--line); background: var(--surface); }
.stepper button { width: 24px; height: 28px; font-size: 15px; color: var(--muted); border-radius: 6px; opacity: .55; transition: opacity .15s; }
.stepper:hover button, .stepper:focus-within button { opacity: 1; }
.stepper button:hover { color: var(--text); background: var(--surface-2); }
.stepper .in { width: 52px; border: 0; border-radius: 0; text-align: right; font-size: 14px; font-weight: 650; color: var(--text); padding: 4px 1px; background: none; -moz-appearance: textfield; appearance: textfield; }
.stepper .in::-webkit-inner-spin-button, .stepper .in::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.stepper .unit { padding: 0 2px; font-weight: 600; font-size: 14px; color: var(--text-2); }
.spar select.in { width: auto; padding: 4px 6px; font-size: 13px; font-weight: 600; color: var(--text-2); background: none; border: 1px solid transparent; }
.spar select.in:hover, .spar select.in:focus { border-color: var(--line); background: var(--surface); }
.max-btn { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 4px 9px; border-radius: 7px; border: 1px solid transparent; color: var(--muted); transition: background .15s, color .15s, border-color .15s; }
.max-btn svg { width: 14px; height: 14px; }
.max-btn b { font-weight: 650; }
.max-btn.up { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.max-btn.up:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.max-btn.down { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.max-btn.down:hover { background: color-mix(in srgb, var(--warn) 12%, transparent); }
.max-btn.done { color: var(--muted); cursor: default; }
.max-btn.done svg { color: var(--good); }
.private #sparInput { filter: blur(5px); }
.card-head:has(.spar-ctl) { align-items: center; flex-wrap: wrap; }

/* actions of the open profile: one quiet row of icons */
.profile-actions { display: flex; justify-content: space-between; padding: 2px 4px 0; }
.menu-pop .profile-actions button { width: 32px; height: 32px; padding: 0; justify-content: center; border-radius: 8px; }
.menu-pop .profile-actions button svg { width: 16px; height: 16px; color: var(--muted); }
.menu-pop .profile-actions button:hover svg { color: var(--text); }
.menu-pop .profile-actions .danger:hover { background: color-mix(in srgb, var(--bad) 12%, transparent); }
.menu-pop .profile-actions .danger:hover svg { color: var(--bad); }
.menu-pop .profile-actions button:disabled { opacity: .35; }
