:root {
  color-scheme: light;
  --page: #f3f5fa;
  --surface: #ffffff;
  --surface-2: #eef1f7;
  --raised: #ffffff; /* aktiver Tab / Umschalter */
  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.16);
  --text: #0f172a;
  --text-2: #556179;
  --muted: #8a93a7;
  --grid: #e8ebf2;
  --axis: #c6ccd9;
  --accent: #2a78d6;
  --accent-text: #1c5cab;
  --btn: #256abf;
  --btn-hover: #1c5cab;
  --violet: #6b5cf0;
  --brand: linear-gradient(135deg, #2a78d6 0%, #5b5cf0 100%);
  --brand-text: linear-gradient(120deg, #1f6fd1 0%, #5a45e6 100%);
  --glow-1: rgba(42, 120, 214, 0.16);
  --glow-2: rgba(107, 92, 240, 0.13);
  --pos: #2a78d6;
  --neg: #e34948;
  --good-text: #006300;
  --neg-text: #c62828;
  --critical: #d03b3b;
  --warning: #fab219;
  --dim: 0.45;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 30px -14px rgba(15, 23, 42, 0.16);
  --shadow-lg: 0 30px 70px -24px rgba(15, 23, 42, 0.35);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #090d16;
    --surface: #111726;
    --surface-2: #1a2133;
    --raised: #273048;
    --border: rgba(255, 255, 255, 0.07);
    --border-strong: rgba(255, 255, 255, 0.14);
    --text: #f2f5fb;
    --text-2: #a3acc0;
    --muted: #6f7990;
    --grid: #1d2436;
    --axis: #384159;
    --accent: #3987e5;
    --accent-text: #86b6ef;
    --violet: #8577ff;
    --brand-text: linear-gradient(120deg, #6aa9ff 0%, #a497ff 100%);
    --glow-1: rgba(57, 135, 229, 0.22);
    --glow-2: rgba(133, 119, 255, 0.18);
    --pos: #3987e5;
    --neg: #e66767;
    --good-text: #0ca30c;
    --neg-text: #ff8b8b;
    --dim: 0.6;
    --shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 12px 32px -18px rgba(0, 0, 0, 0.7);
    --shadow-lg: 0 30px 80px -20px rgba(0, 0, 0, 0.7);
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  /* sanfter Farbschimmer oben auf der Seite */
  background:
    radial-gradient(900px 480px at 8% -160px, var(--glow-1), transparent 70%),
    radial-gradient(800px 460px at 92% -180px, var(--glow-2), transparent 70%),
    var(--page);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Kopfzeile ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--surface) 75%, transparent);
  -webkit-backdrop-filter: saturate(170%) blur(16px);
  backdrop-filter: saturate(170%) blur(16px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; letter-spacing: -0.02em; }
.logo {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--brand);
  box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--violet) 75%, transparent);
}
.logo rect { fill: none; }
.logo path { fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabs {
  display: flex;
  gap: 2px;
  padding: 4px;
  background: color-mix(in srgb, var(--surface-2) 85%, transparent);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.tabs button {
  border: 0;
  background: transparent;
  padding: 6px 14px;
  border-radius: 9px;
  cursor: pointer;
  color: var(--text-2);
  font-weight: 600;
  transition: color 0.2s, background-color 0.2s, box-shadow 0.2s;
}
.tabs button:hover { color: var(--text); }
.tabs button[aria-current="page"] {
  background: var(--raised);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08), 0 6px 14px -8px rgba(15, 23, 42, 0.35);
}
.top-actions { margin-left: auto; display: flex; gap: 4px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, filter 0.2s ease;
}
.btn svg { width: 16px; height: 16px; }
.btn.primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 8px 20px -10px color-mix(in srgb, var(--accent) 90%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.btn.primary:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: 0 12px 26px -10px color-mix(in srgb, var(--violet) 80%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.btn.primary:active { transform: none; filter: brightness(0.97); }
.btn.primary:disabled { opacity: 0.7; cursor: default; transform: none; filter: none; }
.btn.ghost { background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.outline { background: var(--surface); border-color: var(--border-strong); }
.btn.outline:hover { border-color: var(--accent); color: var(--accent-text); }
.btn.small { height: 30px; padding: 0 11px; font-size: 13px; border-radius: 9px; }
.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  cursor: pointer;
  padding: 0;
  transition: border-color 0.2s, background-color 0.2s, color 0.2s;
}
.icon-btn:not(:disabled):hover { border-color: var(--accent); color: var(--accent-text); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.icon-btn.plain { border: 0; background: transparent; width: 30px; height: 30px; color: var(--text-2); }
.icon-btn.plain:hover { background: color-mix(in srgb, var(--critical) 12%, transparent); color: var(--critical); }
.link { border: 0; background: none; padding: 0; cursor: pointer; font-weight: 600; text-align: left; }
.link:hover { color: var(--accent-text); text-decoration: underline; }

/* ---------- Layout & Karten ---------- */
main { max-width: 1240px; margin: 0 auto; padding: 28px 24px 40px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head h2 { font-size: 15px; font-weight: 680; letter-spacing: -0.01em; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.pill {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--text-2);
  white-space: nowrap;
}
.empty { color: var(--text-2); font-size: 13px; }
.caption { font-size: 13px; color: var(--text-2); margin-top: 14px; }
.caption strong { color: var(--text); font-weight: 650; }
.footnote { text-align: center; font-size: 12px; color: var(--muted); margin-top: 28px; }
.row { display: grid; gap: 18px; margin-bottom: 18px; align-items: start; }
.row-a { grid-template-columns: 2fr 1fr; }
.row-b { grid-template-columns: 1fr 1fr; }

/* ---------- Monatsauswahl & Kennzahlen ---------- */
.monthbar { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; flex-wrap: wrap; }
.monthbar h1 { font-size: 28px; font-weight: 760; letter-spacing: -0.035em; min-width: 200px; text-align: center; }
.monthbar .icon-btn { border-radius: 50%; box-shadow: var(--shadow); }
.monthbar .pill { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent-text); }
.kpis { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.hero-value { font-size: 54px; font-weight: 760; letter-spacing: -0.04em; line-height: 1.1; margin: 10px 0 8px; }
.hero-value.pos { color: var(--good-text); }
.hero-value.neg { color: var(--neg-text); }
.value { font-size: 28px; font-weight: 720; letter-spacing: -0.03em; margin: 6px 0 12px; }
.sub { font-size: 13px; color: var(--text-2); }

/* Die erste Kennzahl ("Übrig im …") ist der Blickfang: Verlauf in den Markenfarben, im Minus in Rot. */
.kpis > .card:first-child {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  border: 0;
  color: #fff;
  background: linear-gradient(135deg, #2566d8 0%, #4c55e6 55%, #6d45e3 100%);
  box-shadow: 0 22px 44px -22px rgba(76, 85, 230, 0.9);
}
.kpis > .card:first-child:has(.hero-value.neg) {
  background: linear-gradient(135deg, #d63a47 0%, #c22b5c 55%, #9b2a78 100%);
  box-shadow: 0 22px 44px -22px rgba(194, 43, 92, 0.9);
}
.kpis > .card:first-child::before,
.kpis > .card:first-child::after {
  content: "";
  position: absolute;
  z-index: -1;
  border-radius: 50%;
  pointer-events: none;
}
.kpis > .card:first-child::before {
  top: -150px;
  right: -110px;
  width: 340px;
  height: 340px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.28), transparent 65%);
}
.kpis > .card:first-child::after {
  right: -70px;
  bottom: -120px;
  width: 240px;
  height: 240px;
  border: 40px solid rgba(255, 255, 255, 0.07);
}
.kpis > .card:first-child .label,
.kpis > .card:first-child .sub { color: rgba(255, 255, 255, 0.86); }
.kpis > .card:first-child .hero-value { color: #fff; text-shadow: 0 2px 24px rgba(10, 20, 60, 0.25); }

/* Farbpunkt vor den übrigen Kennzahlen */
.kpis > .card:nth-child(2) { --dot: #16a34a; }
.kpis > .card:nth-child(3) { --dot: var(--neg); }
.kpis > .card:nth-child(4) { --dot: var(--violet); }
.kpis > .card:not(:first-child) .label { display: flex; align-items: center; gap: 8px; }
.kpis > .card:not(:first-child) .label::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dot);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--dot) 18%, transparent);
}
.mini { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 0; font-size: 13px; }
.mini dt { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 550; }
.balance-field { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.balance-field input {
  width: 116px;
  height: 34px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  text-align: right;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.balance-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent);
}

/* ---------- Hinweise ---------- */
.insights { display: grid; gap: 10px; margin-bottom: 18px; }
.callout {
  --tone: var(--accent);
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 16px 12px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: linear-gradient(90deg, color-mix(in srgb, var(--tone) 9%, var(--surface)), var(--surface) 65%);
  box-shadow: var(--shadow);
  color: var(--text-2);
}
.callout svg {
  flex: none;
  box-sizing: content-box;
  width: 18px;
  height: 18px;
  padding: 6px;
  margin: -3px 0;
  border-radius: 10px;
  color: var(--tone);
  background: color-mix(in srgb, var(--tone) 16%, transparent);
}
.callout strong { color: var(--text); font-weight: 650; }
.callout.critical { --tone: var(--critical); border-color: color-mix(in srgb, var(--critical) 32%, transparent); }
.callout.warning { --tone: var(--warning); border-color: color-mix(in srgb, var(--warning) 42%, transparent); }
.callout.info { --tone: var(--accent); }
.callout.safe { --tone: #16a34a; border-color: color-mix(in srgb, #16a34a 30%, transparent); }
.callout.tip { --tone: var(--violet); }
.callout { flex-wrap: wrap; }
.callout p { flex: 1 1 260px; }
.callout-actions { display: flex; flex-wrap: wrap; gap: 6px; align-self: center; margin-left: auto; }

/* Zugeklappte „Tipps & Hinweise“ – oben bleibt es ruhig */
.tips { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.tips summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px 11px 12px;
  cursor: pointer;
  list-style: none;
  font-weight: 650;
}
.tips summary::-webkit-details-marker { display: none; }
.tips summary::after {
  content: "";
  width: 7px;
  height: 7px;
  margin: 0 4px 0 2px;
  border-right: 2px solid var(--text-2);
  border-bottom: 2px solid var(--text-2);
  transform: rotate(45deg);
  transition: transform 0.15s;
}
.tips[open] summary::after { transform: rotate(-135deg); }
.tips-title { display: flex; align-items: center; gap: 12px; margin-right: auto; }
.tips-title svg {
  box-sizing: content-box;
  width: 18px;
  height: 18px;
  padding: 6px;
  margin: -3px 0;
  border-radius: 10px;
  color: var(--violet);
  background: color-mix(in srgb, var(--violet) 16%, transparent);
}
.tips-list { display: grid; gap: 8px; padding: 0 12px 12px; }
.tips-list .callout { box-shadow: none; }
.intro main .tips { animation: rise 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) 0.24s backwards; }

/* ---------- Was wäre wenn ---------- */
.monthbar .whatif-btn { margin-left: auto; }
.scenario-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-bottom: 18px;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px dashed color-mix(in srgb, var(--violet) 60%, transparent);
  background: color-mix(in srgb, var(--violet) 10%, var(--surface));
  color: var(--text-2);
}
.scenario-bar p { flex: 1 1 320px; }
.scenario-bar strong { color: var(--text); }
.scenario-actions { display: flex; gap: 6px; margin-left: auto; }
.whatif-items { margin-top: 2px; max-height: 220px; overflow-y: auto; padding: 2px; }
.chip.off { text-decoration: line-through; border-style: dashed; color: var(--text-2); background: var(--surface-2); }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 10px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; transition: background-color 0.15s; }
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.date { font-variant-numeric: tabular-nums; color: var(--text-2); width: 64px; }
td.bal { color: var(--text-2); }
.in { color: var(--good-text); font-weight: 600; }
.neg-text { color: var(--neg-text); }
.name { font-weight: 600; }
.cat { display: block; font-size: 12px; color: var(--text-2); }
tr.past td { opacity: 0.5; }
tr.group td {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding-top: 20px;
}
tfoot td { font-weight: 720; font-size: 15px; border-bottom: 0; padding-top: 14px; }
tfoot .reserve-row td { font-weight: 400; font-size: 14px; color: var(--text-2); padding-bottom: 0; }
.mini.reserve { margin-bottom: 12px; }
.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 550;
  padding: 2px 9px;
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--text-2);
  white-space: nowrap;
}
.badge.attn { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent-text); font-weight: 650; }
tr[data-act] { cursor: pointer; }
tr[data-act]:hover td { background: var(--surface-2); }
.outlook-table tr.selected td { font-weight: 680; background: color-mix(in srgb, var(--accent) 9%, transparent); }
/* Gleiche Spaltenbreiten in allen vier Posten-Tabellen */
.items-table { table-layout: fixed; }
.items-table th:nth-child(2), .items-table th:nth-child(3) { width: 150px; }
.items-table th:nth-child(4), .items-table th:nth-child(5) { width: 120px; }
.items-table th:nth-child(6) { width: 76px; }
tr.inactive td { opacity: 0.5; }
.row-actions { width: 76px; }
.row-buttons { display: flex; justify-content: flex-end; gap: 2px; }
/* Abhaken: grün statt rot */
.icon-btn.plain.pay:hover { background: color-mix(in srgb, #16a34a 14%, transparent); color: #16a34a; }
.icon-btn.plain.pay[aria-pressed="true"] { background: #16a34a; color: #fff; }
.paid-note { color: var(--good-text); font-weight: 600; }
.open-note { color: color-mix(in srgb, var(--warning) 55%, var(--text)); font-weight: 600; }

/* ---------- Kategorien ---------- */
.catbars { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.catbars li { display: grid; grid-template-columns: 1fr auto; gap: 5px 12px; font-size: 13px; }
.cat-val { font-variant-numeric: tabular-nums; font-weight: 550; }
.cat-share { color: var(--text-2); display: inline-block; min-width: 42px; text-align: right; font-weight: 400; }
.cat-track { grid-column: 1 / -1; height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.cat-bar {
  display: block;
  height: 100%;
  min-width: 3px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--pos), color-mix(in srgb, var(--pos) 50%, var(--violet)));
}

/* ---------- Diagramme ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; overflow: visible; }
.chart text { font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .zero-line { stroke: var(--axis); }
.chart .line { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.pos { stroke: var(--pos); filter: drop-shadow(0 4px 10px color-mix(in srgb, var(--pos) 55%, transparent)); }
.chart .line.neg { stroke: var(--neg); filter: drop-shadow(0 4px 10px color-mix(in srgb, var(--neg) 55%, transparent)); }
/* Verlaufsfläche unter der Linie (Farbverläufe stehen im SVG) */
.chart .stop.pos { stop-color: var(--pos); stop-opacity: 0.02; }
.chart .stop.neg { stop-color: var(--neg); stop-opacity: 0.03; }
.chart .stop.strong { stop-opacity: 0.34; }
.chart .dot { stroke: var(--surface); stroke-width: 2.5; }
.chart .dot.pos { fill: var(--pos); }
.chart .dot.neg { fill: var(--neg); }
.chart .crosshair { stroke: var(--text-2); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .label-strong {
  fill: var(--text);
  font-size: 12px;
  font-weight: 650;
  paint-order: stroke;
  stroke: var(--surface);
  stroke-width: 4px;
  stroke-linejoin: round;
}
.chart .bar { transition: opacity 0.2s; }
.chart .bar.pos { fill: var(--pos); }
.chart .bar.neg { fill: var(--neg); }
.chart .bar.dim { opacity: var(--dim); }
.chart .col { cursor: pointer; outline: none; }
.chart .col .hit { fill: transparent; transition: fill 0.15s; }
.chart .col:hover .bar, .chart .col:focus-visible .bar { opacity: 1; }
.chart .col:hover .hit, .chart .col:focus-visible .hit { fill: var(--surface-2); }
.chart .col:focus-visible .hit { stroke: var(--accent); stroke-width: 2; }
.chart .col.selected .month-label { fill: var(--text); font-weight: 680; }
.seg.small { margin: 0; }
.seg button {
  border: 0;
  background: transparent;
  padding: 4px 10px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  transition: color 0.2s, background-color 0.2s, box-shadow 0.2s;
}
.seg button[aria-pressed="true"] { background: var(--raised); color: var(--text); box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08), 0 4px 10px -6px rgba(15, 23, 42, 0.35); }

.tooltip {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  min-width: 170px;
  max-width: 280px;
  padding: 10px 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-strong);
  box-shadow: 0 16px 40px -12px rgba(2, 6, 23, 0.4);
  font-size: 12px;
}
.tip-title { color: var(--text-2); }
.tip-value { font-size: 16px; font-weight: 700; margin: 1px 0 4px; font-variant-numeric: tabular-nums; }
.tip-row { display: flex; justify-content: space-between; gap: 16px; color: var(--text-2); }
.tip-row span:last-child { color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Posten-Ansicht ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-head h1 { font-size: 28px; font-weight: 760; letter-spacing: -0.035em; }
.section { margin-bottom: 18px; }
.section-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 12px; }
.section-head h2 { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.section-head .total { margin-left: auto; font-size: 13px; color: var(--text-2); padding-top: 5px; white-space: nowrap; }
.section-head .total strong { color: var(--text); }
.section-head .btn { flex: none; }
.section-head .total + .btn { margin-left: 0; }
.section-head > div { flex: 1; }
.checklist { margin-bottom: 18px; }
.checklist summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; }
.checklist summary::-webkit-details-marker { display: none; }
/* Erledigt: aufklappbar wie die Checkliste */
.done-items summary { cursor: pointer; list-style: none; align-items: center; }
.done-items summary::-webkit-details-marker { display: none; }
.done-items:not([open]) summary { margin-bottom: 0; }
.checklist summary::after, .done-items summary::after {
  content: "";
  margin-left: auto;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--text-2);
  border-bottom: 2px solid var(--text-2);
  transform: rotate(45deg);
  transition: transform 0.15s;
}
.checklist[open] summary::after, .done-items[open] summary::after { transform: rotate(-135deg); }
.checklist > p { margin-top: 8px; font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: 99px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  transition: transform 0.15s, border-color 0.2s, box-shadow 0.2s;
}
.chip:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: 0 6px 14px -8px color-mix(in srgb, var(--accent) 70%, transparent); }
.chip svg { width: 14px; height: 14px; color: var(--accent); }
.chip .meta { color: var(--text-2); font-size: 12px; }
.chip.done { background: var(--surface-2); border-color: transparent; color: var(--text-2); }
.chip.done svg { color: var(--good-text); }

/* ---------- Willkommen ---------- */
.welcome { position: relative; overflow: hidden; isolation: isolate; max-width: 680px; margin: 32px auto; padding: 44px; }
.welcome::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: -200px;
  right: -180px;
  width: 460px;
  height: 460px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--glow-2), transparent 65%);
}
.welcome h1 {
  font-size: 32px;
  font-weight: 780;
  letter-spacing: -0.035em;
  line-height: 1.15;
  margin-bottom: 14px;
  background: var(--brand-text);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.welcome > p { color: var(--text-2); font-size: 15px; }
.steps { margin: 26px 0 30px; padding: 0; list-style: none; counter-reset: step; display: grid; gap: 14px; }
.steps li { counter-increment: step; display: flex; gap: 12px; align-items: flex-start; }
.steps li::before {
  content: counter(step);
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  box-shadow: 0 6px 14px -6px color-mix(in srgb, var(--violet) 75%, transparent);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
}
.steps li span { padding-top: 2px; }
.welcome-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Dialog ---------- */
dialog {
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 0;
  width: min(520px, calc(100vw - 32px));
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
dialog[open] { animation: pop 0.22s cubic-bezier(0.2, 0.8, 0.2, 1); }
dialog::backdrop {
  background: rgba(6, 10, 22, 0.5);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
dialog form { padding: 26px; }
dialog h2 { font-size: 19px; font-weight: 720; letter-spacing: -0.02em; margin-bottom: 16px; }
.seg { display: inline-flex; padding: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; margin-bottom: 16px; }
.seg label { position: relative; padding: 6px 16px; border-radius: 8px; cursor: pointer; color: var(--text-2); font-weight: 600; transition: color 0.2s, background-color 0.2s; }
.seg label input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--raised); color: var(--text); box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08), 0 4px 10px -6px rgba(15, 23, 42, 0.35); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--accent); }
.field { display: grid; align-content: start; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 14px; }
.field input, .field select {
  height: 40px;
  padding: 0 12px;
  border-radius: 11px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-weight: 400;
  font-size: 14px;
  min-width: 0;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.opt { font-weight: 400; }
.field-note { font-weight: 400; font-size: 12px; line-height: 1.4; }
.field-note:empty { display: none; }
.label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.link.small { font-size: 12px; font-weight: 650; color: var(--accent-text); justify-self: start; }
.change-row { display: flex; align-items: center; gap: 8px; }
.change-row + .change-row { margin-top: 8px; }
.change-row input[type="month"], .change-row input[type="date"] { width: 170px; }
.change-row .c-amount, .change-row .x-amount { width: 120px; text-align: right; }
.change-row .link { margin-left: 4px; }
.change-row .icon-btn.plain { margin-left: auto; }
.change-row .row-buttons { display: flex; gap: 2px; margin-left: auto; }
.change-row .row-buttons .icon-btn.plain { margin-left: 0; }
.icon-btn.plain.pay:disabled[aria-pressed="true"] { opacity: 0.6; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-bottom: 8px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--btn); }
.check.small-check { margin: 2px 0 0; font-size: 13px; font-weight: 500; color: var(--text-2); }
.net-table { margin: 14px 0 12px; font-size: 13px; }
.net-table td { padding: 5px 0; }
.net-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.net-table tr.total td { font-weight: 720; font-size: 15px; border-bottom: 0; padding-top: 10px; }
.net-table tr.sum td { font-weight: 650; }
.net-table tr.msg td { text-align: left; color: var(--neg-text); font-weight: 650; border-bottom: 0; }
.hint { font-size: 13px; color: var(--text-2); background: var(--surface-2); padding: 10px 12px; border-radius: 11px; margin-bottom: 18px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.dialog-lead { color: var(--text-2); margin: -6px 0 18px; }
.dialog-actions .push-left { margin-right: auto; }
#checkinDialog { width: min(440px, calc(100vw - 32px)); }
#payDialog { width: min(560px, calc(100vw - 32px)); }
#payDialog .dialog-actions { flex-wrap: wrap; }

/* ---------- Sparkonto ---------- */
.savings { --save: #16a34a; margin-bottom: 18px; }
.savings h2 { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 680; }
.savings h2::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--save);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--save) 18%, transparent);
}
.savings-empty { display: flex; align-items: center; gap: 12px 20px; flex-wrap: wrap; }
.savings-empty > div { flex: 1; min-width: 220px; }
.savings-empty h2 { margin-bottom: 4px; }
.savings-body { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 32px; flex-wrap: wrap; }
.savings-body .value { margin-bottom: 4px; }
.savings-future { min-width: 200px; }
.savings-more { margin-top: 14px; }
.savings-more summary { cursor: pointer; font-size: 13px; font-weight: 650; color: var(--accent-text); width: fit-content; }
.savings-more summary:hover { text-decoration: underline; }
.savings-tip {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--save) 9%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--save) 22%, transparent);
  color: var(--text-2);
  font-size: 13px;
}
.savings-tip svg { flex: none; width: 18px; height: 18px; margin-top: 1px; color: var(--save); }
.savings-tip strong { color: var(--text); }
.intro main .card.savings { animation-delay: 0.25s; }

/* ---------- Bewegung: Karten gleiten beim Öffnen einer Ansicht kurz herein ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
.intro main .card, .intro main .callout { animation: rise 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) backwards; }
.intro .kpis > :nth-child(2) { animation-delay: 0.06s; }
.intro .kpis > :nth-child(3) { animation-delay: 0.12s; }
.intro .kpis > :nth-child(4) { animation-delay: 0.18s; }
.intro .insights > * { animation-delay: 0.22s; }
.intro .row-b > * { animation-delay: 0.28s; }
.intro .row-a > * { animation-delay: 0.34s; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Schmale Fenster ---------- */
@media (max-width: 1040px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .row-a, .row-b { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  /* Kopfzeile: Logo und Symbol-Buttons oben, Tabs darunter über die volle Breite */
  .topbar-inner { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .top-actions { margin-left: auto; gap: 0; }
  .top-actions .label { display: none; }
  .top-actions .btn { padding: 0 10px; }
  .top-actions .btn svg { width: 20px; height: 20px; }
  .tabs { order: 3; width: 100%; }
  .tabs button { flex: 1; padding: 8px 6px; font-size: 13px; }
  main { padding: 16px 12px 24px; }
  .card { padding: 18px 16px; }
  /* Handy: Übrig und Kontostand über die volle Breite, Einnahmen und Ausgaben kompakt nebeneinander */
  .kpis { grid-template-columns: 1fr 1fr; gap: 12px; }
  .kpis > .card:first-child, .kpis > .card:nth-child(4) { grid-column: 1 / -1; }
  .kpis > .card:nth-child(2) .mini, .kpis > .card:nth-child(3) .mini { display: none; }
  .kpis > .card:nth-child(2) .value, .kpis > .card:nth-child(3) .value { font-size: 22px; margin-bottom: 0; }
  .hero-value { font-size: 44px; }
  .monthbar { gap: 8px; }
  .monthbar h1 { min-width: 0; font-size: 21px; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .savings-future { width: 100%; }
  .section-head { flex-wrap: wrap; }
  .welcome { padding: 26px 22px; margin: 16px auto; }
  .welcome h1 { font-size: 27px; }
  .page-head h1 { font-size: 23px; }
  dialog form { padding: 20px 16px; }
  .change-row { flex-wrap: wrap; }
  .icon-btn.plain { width: 36px; height: 36px; }
  .chip { height: 36px; }
  /* iOS zoomt in Eingabefelder unter 16 px hinein */
  input, select { font-size: 16px !important; }

  /* Tabellen werden zu kompakten Listen statt quer zu scrollen */
  .bookings, .bookings tbody, .bookings tfoot, .items-table, .items-table tbody { display: block; }
  .bookings thead, .items-table thead { display: none; }
  .bookings td, .items-table td { border: 0; padding: 0; }
  .bookings tbody tr:not(.group) {
    display: grid;
    grid-template-columns: 44px 1fr auto;
    column-gap: 8px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
  }
  .bookings td:nth-child(1) { grid-row: 1 / span 2; }
  .bookings td:nth-child(2) { grid-column: 2; grid-row: 1 / span 2; min-width: 0; }
  .bookings td:nth-child(3) { display: none; }
  .bookings td:nth-child(4) { grid-column: 3; grid-row: 1; }
  .bookings td:nth-child(5) { grid-column: 3; grid-row: 2; font-size: 12px; }
  .bookings tr.group, .bookings tr.group td { display: block; padding: 16px 0 4px; }
  .bookings tfoot tr { display: flex; justify-content: space-between; padding-top: 12px; }
  .bookings tfoot td { padding: 0; }
  .items-table tbody tr {
    display: grid;
    grid-template-columns: 1fr auto auto;
    column-gap: 10px;
    row-gap: 4px;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
  }
  .items-table td:nth-child(1) { grid-column: 1; grid-row: 1; min-width: 0; }
  .items-table td:nth-child(2) { grid-column: 1; grid-row: 2; }
  .items-table td:nth-child(3) { grid-column: 2; grid-row: 2; text-align: right; font-size: 12px; color: var(--text-2); }
  .items-table td:nth-child(4) { grid-column: 2; grid-row: 1; }
  .items-table td:nth-child(5) { display: none; }
  .items-table td:nth-child(6) { grid-column: 3; grid-row: 1 / span 2; }
  .row-buttons { flex-direction: column; }
}
