/* =====================================================================
   BudgetPlaner – Designsystem
   Tiefes Grün, warmes Papier, Source Sans 3. WCAG AA, 44px-Touch-Ziele,
   16px-Eingaben (kein Auto-Zoom), Hell/Dunkel, 320px–2560px.
   ===================================================================== */

@font-face { font-family: "Source Sans 3"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("../fonts/source-sans-3-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Source Sans 3"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("../fonts/source-sans-3-latin-ext-400-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Source Sans 3"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("../fonts/source-sans-3-latin-600-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Source Sans 3"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("../fonts/source-sans-3-latin-ext-600-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Source Sans 3"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("../fonts/source-sans-3-latin-700-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Source Sans 3"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("../fonts/source-sans-3-latin-ext-700-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --bg: #F7F3EA;
  --bg-elevated: #FBF8F2;
  --surface: #FFFFFF;
  --surface-2: #F3EEE3;
  --border: #E2DBCB;
  --border-strong: #CFC6B3;
  --text: #1E2522;
  --text-muted: #565E59;
  --text-faint: #5F6660;
  --on-bad: #FFFFFF;
  --primary: #1F5F4A;
  --primary-hover: #184C3B;
  --primary-soft: #E3EEE8;
  --primary-soft-2: #CDE1D6;
  --on-primary: #FFFFFF;
  --accent: #94500F;
  --accent-soft: #FBEBD9;
  --good: #1B6E47;
  --good-soft: #E1F2E8;
  --warn: #8A5300;
  --warn-soft: #FDF0D5;
  --bad: #B42318;
  --bad-soft: #FDE9E7;
  --neutral: #6E756F;
  --neutral-soft: #ECE9E2;
  --income: #1B6E47;
  /* Validierte Kategorialpalette (dataviz-Validator: CVD/Normalsicht bestanden; Reihenfolge = Sicherheitsmechanismus) */
  --chart-1: #2a78d6; --chart-2: #eb6834; --chart-3: #1baf7a; --chart-4: #eda100; --chart-5: #e87ba4;
  --chart-6: #008300; --chart-7: #4a3aa7; --chart-8: #e34948; --chart-other: #9a978f; --chart-grid: #ebe6da; --chart-axis: #cfc8b8;
  --focus: #1F5F4A;
  --shadow-sm: 0 1px 2px rgba(30, 37, 34, .06);
  --shadow: 0 1px 2px rgba(30, 37, 34, .06), 0 6px 18px rgba(30, 37, 34, .06);
  --shadow-lg: 0 10px 40px rgba(30, 37, 34, .18);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --header-h: 60px;
  --tabbar-h: 64px;
  --kpi-h: 0px;
  --sidebar-w: 248px;
  --font: "Source Sans 3", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Consolas, monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0F1513; --bg-elevated: #141C19; --surface: #18211E; --surface-2: #1F2A26; --border: #2C3833; --border-strong: #3B4943;
  --text: #E8EEEA; --text-muted: #A9B5AF; --text-faint: #8E9A94;
  --primary: #6CC4A1; --primary-hover: #8AD3B6; --primary-soft: #1C3229; --primary-soft-2: #24423A; --on-primary: #0D1A15;
  --accent: #F0A35E; --accent-soft: #3A2A1A;
  --good: #63C795; --good-soft: #17322A; --warn: #F2BE5C; --warn-soft: #3A2E15; --bad: #FF8A7D; --bad-soft: #3D1F1C; --on-bad: #2B0F0B;
  --neutral: #A9B5AF; --neutral-soft: #26302C; --income: #63C795;
  --chart-1: #3987e5; --chart-2: #d95926; --chart-3: #199e70; --chart-4: #c98500; --chart-5: #d55181; --chart-6: #008300; --chart-7: #9085e9; --chart-8: #e66767; --chart-other: #7c7a73; --chart-grid: #26302c; --chart-axis: #3b4943;
  --focus: #8AD3B6;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3); --shadow-lg: 0 12px 48px rgba(0, 0, 0, .55);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0F1513; --bg-elevated: #141C19; --surface: #18211E; --surface-2: #1F2A26; --border: #2C3833; --border-strong: #3B4943;
    --text: #E8EEEA; --text-muted: #A9B5AF; --text-faint: #8E9A94;
    --primary: #6CC4A1; --primary-hover: #8AD3B6; --primary-soft: #1C3229; --primary-soft-2: #24423A; --on-primary: #0D1A15;
    --accent: #F0A35E; --accent-soft: #3A2A1A;
    --good: #63C795; --good-soft: #17322A; --warn: #F2BE5C; --warn-soft: #3A2E15; --bad: #FF8A7D; --bad-soft: #3D1F1C; --on-bad: #2B0F0B;
    --neutral: #A9B5AF; --neutral-soft: #26302C; --income: #63C795;
    --chart-1: #3987e5; --chart-2: #d95926; --chart-3: #199e70; --chart-4: #c98500; --chart-5: #d55181; --chart-6: #008300; --chart-7: #9085e9; --chart-8: #e66767; --chart-other: #7c7a73; --chart-grid: #26302c; --chart-axis: #3b4943;
    --focus: #8AD3B6;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3); --shadow-lg: 0 12px 48px rgba(0, 0, 0, .55);
  }
}

/* ---------- Basis ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font); font-size: 1rem; line-height: 1.5; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; overflow-x: hidden; min-height: 100dvh;
}
body.scroll-locked { overflow: hidden; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5rem; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.075rem; }
h4 { font-size: 1rem; }
.h3 { font-size: 1.075rem; margin-top: .25rem; }
p { margin: 0 0 .75rem; }
a { color: var(--primary); text-underline-offset: 2px; }
a:hover { color: var(--primary-hover); }
small, .small { font-size: .875rem; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.num, .money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--income); }
.neg { color: var(--bad); }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
img, svg { max-width: 100%; }
/* Standardgröße der Inline-Icons; Kontexte (Buttons, Navigation …) überschreiben gezielt. */
.i { width: 1.25em; height: 1.25em; flex: none; vertical-align: -0.22em; }
/* Überschriften erhalten nach Navigation programmatisch den Fokus (Screenreader) – ohne sichtbaren Rahmen. */
h1[tabindex="-1"]:focus, h1:focus:not(:focus-visible) { outline: none; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--primary-soft-2); }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: .5rem; top: -100px; z-index: 1000; background: var(--primary); color: var(--on-primary); padding: .6rem 1rem; border-radius: var(--radius-sm); }
.skip-link:focus { top: .5rem; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; } }

/* ---------- App-Rahmen ---------- */
.app { min-height: 100dvh; display: flex; flex-direction: column; }
.app-header {
  position: sticky; top: 0; z-index: 40; height: var(--header-h); display: flex; align-items: center; gap: .5rem;
  padding: 0 1rem; padding-top: env(safe-area-inset-top); height: calc(var(--header-h) + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: .55rem; font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; min-height: 44px; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; flex: none; }
.brand-mark svg { width: 20px; height: 20px; }
.header-title { font-weight: 700; font-size: 1.05rem; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-spacer { flex: 1; }
.header-actions { display: flex; align-items: center; gap: .25rem; }
.app-body { flex: 1; display: flex; min-width: 0; }
.sidebar {
  display: none; width: var(--sidebar-w); flex: none; padding: 1rem .75rem 2rem; border-right: 1px solid var(--border);
  position: sticky; top: calc(var(--header-h) + env(safe-area-inset-top)); height: calc(100dvh - var(--header-h)); overflow-y: auto;
}
.nav-section { margin: 1rem .5rem .35rem; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); }
.nav-link {
  display: flex; align-items: center; gap: .7rem; min-height: 44px; padding: .5rem .75rem; border-radius: 10px;
  color: var(--text); text-decoration: none; font-weight: 600;
}
.nav-link svg { width: 20px; height: 20px; flex: none; color: var(--text-muted); }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--primary-soft); color: var(--primary); }
.nav-link.active svg { color: var(--primary); }
.nav-link .badge { margin-left: auto; }
.main { flex: 1; min-width: 0; padding: 1rem 1rem calc(var(--tabbar-h) + 1.5rem + env(safe-area-inset-bottom)); }
.page { max-width: 1180px; margin: 0 auto; }
.page-narrow { max-width: 760px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin: .25rem 0 1rem; }
.page-head h1 { margin: 0; }
.page-head .lead { margin: .25rem 0 0; color: var(--text-muted); }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

.tabbar {
  position: fixed; z-index: 45; left: 0; right: 0; bottom: 0; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--surface) 96%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--border);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 44px;
  color: var(--text-muted); text-decoration: none; font-size: .78rem; font-weight: 600; position: relative;
}
.tab svg { width: 24px; height: 24px; }
.tab.active { color: var(--primary); }
.tab.active::before { content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; border-radius: 0 0 3px 3px; background: var(--primary); }

@media (min-width: 768px) {
  .sidebar { display: block; }
  .tabbar { display: none; }
  .main { padding: 1.5rem 1.75rem 3rem; }
  .mobile-only { display: none !important; }
}
@media (max-width: 767.98px) {
  .desktop-only { display: none !important; }
  h1 { font-size: 1.4rem; }
}

/* ---------- Statusleiste / KPI (F-050) ---------- */
.kpi-bar {
  position: sticky; top: calc(var(--header-h) + env(safe-area-inset-top)); z-index: 30; margin: -1rem -1rem 1rem; padding: .6rem 1rem;
  background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
@media (min-width: 768px) { .kpi-bar { margin: -1.5rem -1.75rem 1.25rem; padding: .7rem 1.75rem; } }
.kpi-row { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; max-width: 1180px; margin: 0 auto; }
.kpis { display: flex; gap: .5rem 1.25rem; flex-wrap: wrap; flex: 1; justify-content: flex-end; }
.kpi { display: flex; flex-direction: column; min-width: 0; }
.kpi-label { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); }
.kpi-value { font-weight: 700; font-size: 1.05rem; white-space: nowrap; }
@media (max-width: 767.98px) {
  .kpi-row { gap: .5rem; }
  .kpi-row > .month-switch-wrap { flex: 1 1 100%; flex-wrap: nowrap; }
  .kpi-row .month-switch { flex: 1; justify-content: space-between; }
  .kpis { flex: 1 1 100%; justify-content: space-between; flex-wrap: nowrap; gap: .25rem .75rem; }
  .kpi-value { font-size: .98rem; }
  .kpi.optional { display: none; }
}

.month-switch { display: inline-flex; align-items: center; gap: .15rem; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 2px; }
.month-switch .label { min-width: 9.5rem; text-align: center; font-weight: 700; padding: 0 .25rem; white-space: nowrap; }
.month-switch .icon-btn { width: 40px; height: 40px; min-height: 40px; }
@media (max-width: 380px) { .month-switch .label { min-width: 7.5rem; font-size: .95rem; } }

/* ---------- Karten & Raster ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1rem; box-shadow: var(--shadow-sm); min-width: 0; }
.card + .card { margin-top: 1rem; }
.grid > .card + .card, .row > .card + .card { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .75rem; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; display: flex; align-items: center; gap: .4rem; }
.card-sub { color: var(--text-muted); font-size: .9rem; margin-top: -.4rem; margin-bottom: .75rem; }
.card.flat { box-shadow: none; }
.card.soft { background: var(--surface-2); }
.card.link { text-decoration: none; color: inherit; display: block; transition: border-color .15s, transform .15s; }
.card.link:hover { border-color: var(--border-strong); }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.grid.start { align-items: start; }
.stack { display: flex; flex-direction: column; gap: .75rem; }
.stack-sm { display: flex; flex-direction: column; gap: .4rem; }
.row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.spacer { flex: 1; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

.stat { display: flex; flex-direction: column; gap: .15rem; }
.stat-label { font-size: .85rem; color: var(--text-muted); font-weight: 600; display: flex; align-items: center; gap: .3rem; }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.15; }
.stat-value.sm { font-size: 1.25rem; }
.stat-hint { font-size: .85rem; color: var(--text-muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 44px; padding: .55rem 1rem;
  border-radius: 10px; border: 1px solid transparent; font-weight: 600; font-size: 1rem; cursor: pointer; text-decoration: none;
  background: var(--surface); color: var(--text); border-color: var(--border-strong); transition: background .15s, border-color .15s, color .15s;
  line-height: 1.2; white-space: nowrap;
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--on-primary); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: var(--on-bad); }
.btn-danger:hover { filter: brightness(.92); background: var(--bad); color: var(--on-bad); }
.btn-soft { background: var(--primary-soft); border-color: transparent; color: var(--primary); }
.btn-soft:hover { background: var(--primary-soft-2); color: var(--primary); }
.btn-sm { min-height: 36px; padding: .35rem .75rem; font-size: .92rem; }
.btn-block { width: 100%; }
.btn[disabled], .btn.disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; min-height: 44px; border-radius: 999px; border: 0; background: transparent;
  color: var(--text-muted); cursor: pointer; position: relative; flex: none; text-decoration: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.sm { width: 36px; height: 36px; min-height: 36px; }
.icon-btn.sm svg { width: 18px; height: 18px; }
.dot-badge { position: absolute; top: 6px; right: 6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font-size: .72rem; font-weight: 700; display: grid; place-items: center; line-height: 1; }
.fab {
  position: fixed; right: 1rem; bottom: calc(var(--tabbar-h) + 1rem + env(safe-area-inset-bottom)); z-index: 35; width: 56px; height: 56px; border-radius: 18px;
  border: 0; background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-lg); display: grid; place-items: center; cursor: pointer;
}
.fab svg { width: 26px; height: 26px; }
@media (min-width: 768px) { .fab { display: none; } }

/* ---------- Formulare ---------- */
.field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.field > label, .label { font-weight: 600; font-size: .92rem; display: flex; align-items: center; gap: .3rem; }
.field .hint { font-size: .85rem; color: var(--text-muted); }
.field .error, .form-error { font-size: .88rem; color: var(--bad); font-weight: 600; }
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: .55rem .75rem; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-size: 16px; line-height: 1.3;
}
.input:focus, .select:focus, .textarea:focus { outline: 3px solid color-mix(in srgb, var(--focus) 35%, transparent); border-color: var(--primary); }
.input[aria-invalid="true"] { border-color: var(--bad); }
.input.amount { text-align: right; font-variant-numeric: tabular-nums; }
.textarea { min-height: 88px; resize: vertical; }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-addon { display: inline-flex; align-items: center; padding: 0 .75rem; border: 1px solid var(--border-strong); border-left: 0; border-radius: 0 10px 10px 0; background: var(--surface-2); color: var(--text-muted); font-weight: 600; }
.form-grid { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.check { display: inline-flex; align-items: center; gap: .55rem; min-height: 44px; cursor: pointer; font-weight: 500; }
.check input { width: 22px; height: 22px; accent-color: var(--primary); flex: none; margin: 0; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { font-weight: 600; font-size: .92rem; margin-bottom: .3rem; padding: 0; }
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.segmented button, .segmented label {
  min-height: 38px; padding: .35rem .85rem; border: 0; background: transparent; border-radius: 9px; font-weight: 600; color: var(--text-muted); cursor: pointer;
  display: inline-flex; align-items: center; gap: .35rem;
}
.segmented button[aria-pressed="true"], .segmented button.active, .segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented label { padding: 0; }
.segmented label span { padding: .35rem .85rem; border-radius: 9px; min-height: 38px; display: inline-flex; align-items: center; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented input:focus-visible + span { outline: 3px solid var(--focus); }
.switch { position: relative; display: inline-flex; align-items: center; gap: .6rem; min-height: 44px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 46px; height: 28px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .15s; }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- Badges, Chips, Ampel (F-051, F-121: Farbe + Symbol + Text) ---------- */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 700; background: var(--neutral-soft); color: var(--text-muted); white-space: nowrap; }
.badge.primary { background: var(--primary-soft); color: var(--primary); }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.chip { display: inline-flex; align-items: center; gap: .35rem; padding: .25rem .65rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-size: .85rem; font-weight: 600; color: var(--text-muted); }
.chip .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.ampel { display: inline-flex; align-items: center; gap: .35rem; padding: .18rem .6rem .18rem .35rem; border-radius: 999px; font-size: .82rem; font-weight: 700; white-space: nowrap; }
.ampel .ampel-icon { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; color: #fff; flex: none; }
.ampel .ampel-icon svg { width: 13px; height: 13px; }
.ampel.green { background: var(--good-soft); color: var(--good); }
.ampel.green .ampel-icon { background: var(--good); }
.ampel.yellow { background: var(--warn-soft); color: var(--warn); }
.ampel.yellow .ampel-icon { background: #C78100; }
.ampel.red { background: var(--bad-soft); color: var(--bad); }
.ampel.red .ampel-icon { background: var(--bad); }
.ampel.neutral { background: var(--neutral-soft); color: var(--text-muted); }
.ampel.neutral .ampel-icon { background: var(--neutral); }
.ampel.compact { padding: .15rem; }
.ampel-btn { border: 0; background: none; padding: 0; cursor: help; border-radius: 999px; }

/* ---------- Info-Tooltips (F-141) ---------- */
.info { position: relative; display: inline-flex; vertical-align: middle; }
.info-btn { width: 28px; height: 28px; min-height: 28px; border: 0; background: transparent; color: var(--text-faint); border-radius: 50%; display: inline-grid; place-items: center; cursor: pointer; padding: 0; }
.info-btn:hover { color: var(--primary); background: var(--primary-soft); }
.info-btn svg { width: 17px; height: 17px; }
.popover {
  position: absolute; z-index: 60; top: calc(100% + 6px); left: 50%; transform: translateX(-50%); width: min(320px, 86vw);
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: .75rem .9rem; font-size: .92rem; font-weight: 400; line-height: 1.45; text-align: left; text-transform: none; letter-spacing: 0; white-space: normal;
}
.popover.align-left { left: 0; transform: none; }
.popover.align-right { left: auto; right: 0; transform: none; }
.popover strong { display: block; margin-bottom: .25rem; }
.popover .formula { display: block; margin-top: .4rem; padding: .4rem .5rem; border-radius: 8px; background: var(--surface-2); font-size: .85rem; }

/* ---------- Fortschritt ---------- */
.progress { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--border); }
.progress > span { display: block; height: 100%; border-radius: 999px; background: var(--primary); transition: width .4s ease; }
.progress.lg { height: 14px; }
.progress.good > span { background: var(--good); }
.progress.warn > span { background: #C78100; }
.progress.bad > span { background: var(--bad); }
.progress.done > span { background: linear-gradient(90deg, var(--good), var(--primary)); }

/* ---------- Listen & Positionen (F-013: eine Zeile je Position) ---------- */
.group { margin-bottom: 1.25rem; }
.group-head { display: flex; align-items: center; gap: .6rem; padding: .25rem .25rem .5rem; flex-wrap: wrap; }
.group-head h2 { margin: 0; font-size: 1.1rem; display: flex; align-items: center; gap: .5rem; }
.group-head .sum { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.group-target { font-size: .82rem; color: var(--text-muted); font-weight: 600; }
.cat-block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.cat-block + .cat-block { margin-top: .6rem; }
.cat-head { display: flex; align-items: center; gap: .55rem; padding: .55rem .75rem; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.cat-head h3 { margin: 0; font-size: .98rem; display: flex; align-items: center; gap: .45rem; min-width: 0; }
.cat-head .sum { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cat-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: #fff; flex: none; }
.cat-icon svg { width: 17px; height: 17px; }
.entry { border-top: 1px solid var(--border); }
.entry:first-child { border-top: 0; }
.entry-row { display: flex; align-items: center; gap: .55rem; padding: .35rem .5rem .35rem .65rem; min-height: 52px; }
.entry-main { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; text-align: left; background: none; border: 0; padding: .3rem .1rem; cursor: pointer; border-radius: 8px; color: inherit; }
.entry-main:hover .entry-name { text-decoration: underline; text-decoration-color: var(--border-strong); }
.entry-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-meta { font-size: .82rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; gap: .4rem; align-items: center; }
.entry-amount { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.entry-amount small { display: block; font-weight: 500; color: var(--text-muted); font-size: .78rem; }
.entry.paused .entry-name, .entry.paused .entry-amount { color: var(--text-faint); }
.entry.paused .entry-amount .nominal { text-decoration: line-through; }
.entry.done .entry-name { color: var(--text-muted); }
.done-check { width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: none; cursor: pointer; border-radius: 50%; flex: none; color: var(--text-faint); }
.done-check .box { width: 24px; height: 24px; border-radius: 8px; border: 2px solid var(--border-strong); display: grid; place-items: center; transition: background .15s, border-color .15s; }
.done-check.checked .box { background: var(--good); border-color: var(--good); color: #fff; }
.done-check .box svg { width: 15px; height: 15px; }
.fix-tag { font-size: .72rem; font-weight: 700; padding: .05rem .4rem; border-radius: 5px; background: var(--primary-soft); color: var(--primary); text-transform: uppercase; letter-spacing: .04em; }
.var-tag { font-size: .72rem; font-weight: 700; padding: .05rem .4rem; border-radius: 5px; background: var(--accent-soft); color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
.entry-details { padding: .25rem .75rem .9rem 3.4rem; display: grid; gap: .6rem; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: .5rem .9rem; font-size: .9rem; }
.detail-grid dt { color: var(--text-muted); font-size: .8rem; font-weight: 600; }
.detail-grid dd { margin: 0; font-weight: 600; }
.drag-handle { width: 40px; height: 44px; display: grid; place-items: center; color: var(--text-faint); cursor: grab; touch-action: none; border: 0; background: none; border-radius: 8px; flex: none; }
.drag-handle:active { cursor: grabbing; }
.sort-dragging { position: fixed; z-index: 100; pointer-events: none; box-shadow: var(--shadow-lg); background: var(--surface); border-radius: var(--radius); opacity: .95; }
.sort-placeholder { border: 2px dashed var(--primary); border-radius: var(--radius); background: var(--primary-soft); margin: 2px 0; }
.list { list-style: none; margin: 0; padding: 0; }
.list-row { display: flex; align-items: center; gap: .65rem; padding: .65rem .25rem; border-top: 1px solid var(--border); min-height: 52px; }
.list-row:first-child { border-top: 0; }
.list-row .grow { flex: 1; min-width: 0; }
/* Verwaltung: Aktionen rutschen auf schmalen Bildschirmen unter die Kontodaten. */
.list-row.admin-user { flex-wrap: wrap; align-items: flex-start; }
.list-row.admin-user .grow { flex: 1 1 15rem; }
.add-row { display: flex; align-items: center; gap: .5rem; width: 100%; padding: .55rem .9rem; min-height: 46px; border: 0; border-top: 1px dashed var(--border); background: transparent; color: var(--primary); font-weight: 600; cursor: pointer; text-align: left; }
.add-row:hover { background: var(--primary-soft); }
.add-row svg { width: 18px; height: 18px; }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: .55rem .7rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); background: var(--surface-2); position: sticky; top: 0; z-index: 1; white-space: nowrap; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table tbody th { text-transform: none; letter-spacing: 0; font-size: inherit; color: var(--text); background: transparent; position: static; font-weight: 600; white-space: nowrap; }
.table tr:last-child th { border-bottom: 0; }
.table tr.total td { font-weight: 700; background: var(--surface-2); }
.table tr.sub td:first-child { padding-left: 1.6rem; }
.table td.hl { background: var(--warn-soft); color: var(--warn); font-weight: 700; }
.table .sticky-col { position: sticky; left: 0; background: inherit; z-index: 1; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }

/* ---------- Dialoge ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 80; background: rgba(15, 21, 19, .5); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease; }
.modal {
  width: 100%; max-height: 92dvh; overflow: auto; background: var(--surface); border-radius: 20px 20px 0 0; box-shadow: var(--shadow-lg);
  padding: 1.1rem 1.1rem calc(1.1rem + env(safe-area-inset-bottom)); animation: slide-up .2s ease;
}
.modal-head { display: flex; align-items: flex-start; gap: .5rem; margin-bottom: .75rem; }
.modal-head h2 { margin: 0; flex: 1; font-size: 1.2rem; }
.modal-foot { display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; margin-top: 1.25rem; }
.modal-foot .left { margin-right: auto; }
@media (min-width: 768px) {
  .modal-backdrop { align-items: center; padding: 1.5rem; }
  .modal { max-width: 560px; border-radius: 20px; padding: 1.4rem; }
  .modal.wide { max-width: 820px; }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }

/* ---------- Toasts & Banner ---------- */
.toasts { position: fixed; z-index: 90; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + 1rem + env(safe-area-inset-bottom)); width: min(560px, calc(100vw - 1.5rem)); display: flex; flex-direction: column; gap: .5rem; pointer-events: none; }
@media (min-width: 768px) { .toasts { bottom: 1.5rem; } }
.toast { pointer-events: auto; display: flex; align-items: center; gap: .6rem; padding: .7rem .8rem .7rem 1rem; border-radius: 14px; background: #1E2522; color: #F3F6F4; box-shadow: var(--shadow-lg); animation: slide-up .2s ease; }
:root[data-theme="dark"] .toast { background: #2A3631; }
.toast .msg { flex: 1; min-width: 0; }
.toast.error { background: #8E1B12; }
.toast.success { background: #155C3B; }
.toast button { background: none; border: 0; color: inherit; font-weight: 700; cursor: pointer; min-height: 36px; padding: .25rem .6rem; border-radius: 8px; }
.toast button:hover { background: rgba(255, 255, 255, .12); }
.toast a { color: #B9F0D6; font-weight: 700; }
.banner { display: flex; align-items: center; gap: .6rem; padding: .65rem 1rem; font-weight: 600; font-size: .92rem; flex-wrap: wrap; }
.banner svg { width: 18px; height: 18px; flex: none; }
.banner.offline { background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); }
.banner.info { background: var(--primary-soft); color: var(--primary); }
.notice { display: flex; gap: .65rem; align-items: flex-start; padding: .8rem 1rem; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2); }
.notice svg { width: 20px; height: 20px; flex: none; margin-top: 2px; }
.notice.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 25%, transparent); color: var(--text); }
.notice.warn svg { color: var(--warn); }
.notice.bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.notice.bad svg { color: var(--bad); }
.notice.good { background: var(--good-soft); border-color: color-mix(in srgb, var(--good) 25%, transparent); }
.notice.good svg { color: var(--good); }
.notice.info svg { color: var(--primary); }
.notice p:last-child { margin-bottom: 0; }

/* ---------- Leerzustände, Laden ---------- */
.empty { text-align: center; padding: 2rem 1rem; color: var(--text-muted); }
.empty .empty-icon { width: 56px; height: 56px; margin: 0 auto .75rem; border-radius: 16px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; }
.empty .empty-icon svg { width: 28px; height: 28px; }
.empty h3 { color: var(--text); }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 8px; min-height: 1rem; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--primary-soft-2); border-top-color: var(--primary); animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Zielzone (B-02) ---------- */
.zone { position: relative; height: 16px; border-radius: 999px; background: linear-gradient(90deg, var(--bad-soft) 0%, var(--warn-soft) 35%, var(--good-soft) 45%, var(--good-soft) 55%, var(--primary-soft) 65%, var(--primary-soft) 100%); border: 1px solid var(--border); }
.zone-target { position: absolute; top: -4px; bottom: -4px; left: 50%; width: 2px; background: var(--good); }
.zone-marker { position: absolute; top: 50%; width: 22px; height: 22px; border-radius: 50%; transform: translate(-50%, -50%); background: var(--surface); border: 4px solid var(--primary); box-shadow: var(--shadow); transition: left .4s ease; }
.zone-labels { display: flex; justify-content: space-between; font-size: .78rem; color: var(--text-faint); margin-top: .35rem; }

/* ---------- Diagramme ---------- */
.chart { width: 100%; display: block; overflow: visible; }
.chart text { fill: var(--text-muted); font-size: 12px; font-family: var(--font); }
.chart .grid-line { stroke: var(--chart-grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .axis { stroke: var(--chart-axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .hit:focus { outline: none; }
.chart .crosshair { stroke: var(--text-faint); stroke-width: 1; }
.chart .marker { stroke: var(--surface); stroke-width: 2; }
.chart .tick-label { font-variant-numeric: tabular-nums; }
.chart-table-toggle { margin-top: .4rem; }
.chart-legend { display: flex; flex-wrap: wrap; gap: .4rem .9rem; font-size: .88rem; margin-top: .5rem; }
.chart-legend .item { display: inline-flex; align-items: center; gap: .4rem; }
.chart-legend .swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.chart-legend .swatch.line { height: 3px; border-radius: 2px; }
.chart-legend .swatch.dashed { background: repeating-linear-gradient(90deg, currentColor 0 4px, transparent 4px 7px) !important; }
.chart-tooltip { position: absolute; pointer-events: none; z-index: 20; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow); padding: .45rem .6rem; font-size: .85rem; white-space: nowrap; }
.chart-wrap { position: relative; }
.donut-center { font-weight: 700; }
.legend-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.legend-table td { padding: .35rem .25rem; border-bottom: 1px solid var(--border); }
.legend-table tr:last-child td { border-bottom: 0; }
.legend-table button { background: none; border: 0; padding: 0; color: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: .45rem; font-weight: 600; text-align: left; min-height: 32px; }
.legend-table button:hover { text-decoration: underline; }

/* ---------- Kalender (F-030) ---------- */
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-head { font-size: .78rem; font-weight: 700; color: var(--text-faint); text-align: center; padding: .25rem 0; text-transform: uppercase; }
.cal-day {
  position: relative; min-height: 92px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); padding: .3rem .35rem;
  display: flex; flex-direction: column; gap: 2px; text-align: left; cursor: pointer; font: inherit; color: inherit; min-width: 0;
}
.cal-day:hover { border-color: var(--border-strong); }
.cal-day.outside { background: transparent; border-style: dashed; opacity: .55; }
.cal-day.today { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.cal-day.critical { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.cal-day.selected { outline: 3px solid var(--focus); outline-offset: 1px; }
.cal-day .d { font-weight: 700; font-size: .85rem; display: flex; align-items: center; justify-content: space-between; gap: 2px; }
.cal-day .flow { font-size: .74rem; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-day .bal { margin-top: auto; font-size: .74rem; color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-day.critical .bal { color: var(--bad); font-weight: 700; }
.cal-day .dots { display: flex; gap: 3px; flex-wrap: wrap; }
.cal-day .dots i { width: 7px; height: 7px; border-radius: 50%; display: block; }
.crit-icon { color: var(--bad); width: 15px; height: 15px; }
.cp-icon { color: var(--primary); width: 15px; height: 15px; }
@media (max-width: 767.98px) {
  .calendar { gap: 3px; }
  .cal-day { min-height: 58px; padding: .2rem .25rem; }
  .cal-day .flow { display: none; }
  .cal-day .bal { font-size: .66rem; }
}

/* ---------- Onboarding & Landing ---------- */
.steps { display: flex; gap: .35rem; margin: .5rem 0 1.25rem; }
.steps span { flex: 1; height: 6px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.steps span.done { background: var(--primary); border-color: var(--primary); }
.steps span.current { background: var(--primary-soft-2); border-color: var(--primary); }
.hero { padding: 2.5rem 0 1.5rem; display: grid; gap: 2rem; align-items: center; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.2rem); line-height: 1.08; letter-spacing: -.02em; margin-bottom: 1rem; }
.hero .lead { font-size: 1.2rem; color: var(--text-muted); max-width: 38rem; }
@media (min-width: 960px) { .hero { grid-template-columns: 1.1fr .9fr; padding: 4rem 0 2.5rem; } }
.feature { display: flex; gap: .85rem; align-items: flex-start; }
.feature .f-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; flex: none; }
.feature .f-icon svg { width: 22px; height: 22px; }
.public-header { position: sticky; top: 0; z-index: 40; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.public-header .inner { max-width: 1180px; margin: 0 auto; padding: .5rem 1rem; display: flex; align-items: center; gap: .5rem; min-height: 60px; }
.public-main { max-width: 1180px; margin: 0 auto; padding: 1rem 1rem 3rem; width: 100%; flex: 1; }
.footer { border-top: 1px solid var(--border); padding: 1.5rem 1rem calc(1.5rem + var(--tabbar-h)); color: var(--text-muted); font-size: .9rem; }
.footer .inner { max-width: 1180px; margin: 0 auto; display: flex; gap: .5rem 1.25rem; flex-wrap: wrap; align-items: center; }
.footer a { color: var(--text-muted); }
@media (min-width: 768px) { .footer { padding-bottom: 1.5rem; } }
.auth-card { max-width: 440px; margin: 2rem auto; }
.code-input { font-size: 1.8rem !important; letter-spacing: .5rem; text-align: center; font-variant-numeric: tabular-nums; font-weight: 700; }
.divider-text { display: flex; align-items: center; gap: .75rem; color: var(--text-faint); font-size: .85rem; margin: 1rem 0; }
.divider-text::before, .divider-text::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---------- Menüs ---------- */
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 70; min-width: 230px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: .35rem; }
.menu a, .menu button { display: flex; align-items: center; gap: .6rem; width: 100%; min-height: 44px; padding: .5rem .7rem; border: 0; background: none; border-radius: 9px; color: var(--text); text-decoration: none; font-weight: 600; cursor: pointer; text-align: left; font-size: .95rem; }
.menu a:hover, .menu button:hover { background: var(--surface-2); }
.menu svg { width: 18px; height: 18px; color: var(--text-muted); }
.menu .sep { height: 1px; background: var(--border); margin: .3rem 0; }
.menu .danger, .menu .danger svg { color: var(--bad); }
.menu .menu-head { padding: .5rem .7rem; font-size: .85rem; color: var(--text-muted); }
.panel { position: absolute; right: 0; top: calc(100% + 6px); z-index: 70; width: min(400px, 94vw); max-height: 70vh; overflow: auto; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.notif { display: flex; gap: .65rem; padding: .75rem .9rem; border-top: 1px solid var(--border); }
.notif.unread { background: var(--primary-soft); }
.notif .n-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--primary); margin-top: .45rem; flex: none; }
.notif .n-body { flex: 1; min-width: 0; }
.notif .n-title { font-weight: 700; }
.notif .n-time { font-size: .8rem; color: var(--text-faint); }

/* ---------- Diverses ---------- */
.kbd { font-family: var(--mono); font-size: .85em; padding: .1rem .35rem; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; background: var(--surface-2); }
.code-block { font-family: var(--mono); font-size: .85rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: .6rem .75rem; overflow-x: auto; word-break: break-all; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; font-weight: 700; font-size: .9rem; flex: none; }
.avatar.lg { width: 44px; height: 44px; font-size: 1.05rem; }
.pill-nav { display: flex; gap: .35rem; overflow-x: auto; padding-bottom: .25rem; margin-bottom: 1rem; scrollbar-width: thin; }
.pill-nav button, .pill-nav a { flex: none; min-height: 40px; padding: .4rem .9rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-weight: 600; color: var(--text-muted); cursor: pointer; text-decoration: none; }
.pill-nav .active, .pill-nav [aria-selected="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
details.faq { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 0 1rem; }
details.faq + details.faq { margin-top: .5rem; }
details.faq summary { cursor: pointer; font-weight: 700; min-height: 48px; display: flex; align-items: center; list-style: none; gap: .5rem; }
details.faq summary::after { content: "+"; margin-left: auto; font-size: 1.3rem; color: var(--text-faint); }
details.faq[open] summary::after { content: "–"; }
details.faq > div { padding-bottom: 1rem; color: var(--text-muted); }
.update-bar { position: fixed; z-index: 95; top: calc(var(--header-h) + .5rem); left: 50%; transform: translateX(-50%); }
.version { font-size: .8rem; color: var(--text-faint); }

/* ---------- Ladebildschirm / Fehler ---------- */
.boot { min-height: 100dvh; display: grid; place-items: center; text-align: center; color: var(--text-muted); }
.boot .brand-mark { width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 1rem; }
.boot .brand-mark svg { width: 38px; height: 38px; }
#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000; background: var(--bad-soft); color: var(--text); padding: .8rem 1rem; border-top: 2px solid var(--bad); box-shadow: var(--shadow-lg); }
#blazor-error-ui .reload { font-weight: 700; margin-left: .5rem; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 1rem; top: .6rem; }
.blazor-error-boundary { background: var(--bad-soft); color: var(--bad); padding: 1rem; border-radius: var(--radius); }
.blazor-error-boundary::after { content: "Es ist ein Fehler aufgetreten / An error occurred."; }

@media print {
  .app-header, .sidebar, .tabbar, .fab, .toasts, .kpi-bar, .page-actions, .no-print { display: none !important; }
  body { background: #fff; }
  .main { padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
}

/* ---------- Farb- und Symbolauswahl ---------- */
.picker { border: 0; padding: 0; margin: 0; min-width: 0; }
.picker legend { margin-bottom: .35rem; }
.swatches, .icon-opts { display: flex; flex-wrap: wrap; gap: .4rem; }
.swatch-opt, .icon-opt { position: relative; cursor: pointer; }
.swatch-opt input, .icon-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.swatch-opt > span:first-of-type { display: block; width: 40px; height: 40px; border-radius: 50%; background: var(--c); border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--border-strong); }
.swatch-opt input:checked + span { box-shadow: 0 0 0 3px var(--text); }
.swatch-opt input:focus-visible + span, .icon-opt input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.icon-opt > span:first-of-type { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); }
.icon-opt input:checked + span { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.icon-opt svg { width: 22px; height: 22px; }

/* ---------- Cashflow-Liste ---------- */
.cf-day-group { padding: .5rem 0; border-top: 1px solid var(--border); }
.cf-day-group:first-child { border-top: 0; padding-top: 0; }
.cf-day-group.critical .cf-day-head { color: var(--bad); }
.cf-day-head { padding: .25rem 0; }
.cf-day-group .list-row { min-height: 48px; padding: .35rem .25rem; }

/* ---------- Statistik ---------- */
.top-list .list-row { padding: .5rem .1rem; }
.top-bar { height: 6px; border-radius: 999px; background: var(--surface-2); margin: .3rem 0 .15rem; overflow: hidden; }
.top-bar span { display: block; height: 100%; border-radius: 999px; background: var(--chart-1); }
.year-table { max-height: 70vh; }
.year-table .table th, .year-table .table td { padding: .45rem .55rem; font-size: .85rem; }
.year-table .sticky-col { position: sticky; left: 0; z-index: 2; background: var(--surface); min-width: 10rem; }
.year-table thead .sticky-col { background: var(--surface-2); z-index: 3; }
.year-table tr.total .sticky-col { background: var(--surface-2); }

/* ---------- Prognosen & Szenario ---------- */
.link-btn { background: none; border: 0; padding: 0; font: inherit; font-weight: 600; color: var(--primary); text-decoration: underline; cursor: pointer; text-align: left; min-height: 32px; }
.scenario.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow-sm); }

/* ---------- Profil & Haushalt ---------- */
.table-check { width: 22px; height: 22px; accent-color: var(--primary); cursor: pointer; }
.token-value { display: block; word-break: break-all; white-space: pre-wrap; font-size: .8rem; }
.danger-zone { border-color: color-mix(in srgb, var(--bad) 35%, var(--border)); }
.danger-zone h2 { color: var(--bad); }
.member-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 700; flex: none; }
.rules-grid { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }

/* ---------- Benachrichtigungen & Verlauf ---------- */
.notif-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-muted); flex: none; }
.notif-icon.warn { background: var(--warn-soft); color: var(--warn); }
.notif-icon svg { width: 18px; height: 18px; }
.history-row { padding: .75rem .25rem; border-top: 1px solid var(--border); list-style: none; }
.history-row:first-child { border-top: 0; }
.invalid-row td, .invalid-row th { background: var(--bad-soft); }

/* ---------- Hilfe & Glossar ---------- */
.glossary-index { display: flex; flex-wrap: wrap; gap: .25rem; }
.glossary-index a { min-width: 36px; min-height: 36px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); font-weight: 700; text-decoration: none; color: var(--primary); }
.glossary-index a:hover { background: var(--primary-soft); }
.glossary { margin: 0; }
.glossary-letter { font-size: 1.4rem; font-weight: 800; color: var(--primary); margin: 1.25rem 0 .25rem; scroll-margin-top: calc(var(--header-h) + 12px); }
.glossary-item { padding: .75rem 0; border-top: 1px solid var(--border); scroll-margin-top: calc(var(--header-h) + 12px); }
.glossary-item dt { font-weight: 700; font-size: 1.05rem; margin-bottom: .25rem; }
.glossary-item dd { margin: 0; color: var(--text); }
.glossary-item:target { background: var(--primary-soft); border-radius: 10px; padding-left: .6rem; padding-right: .6rem; }
.faq { border-top: 1px solid var(--border); padding: .35rem 0; }
.faq:first-of-type { border-top: 0; }
.faq summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.faq p { margin: .25rem 0 .75rem; color: var(--text-muted); }
.howto { margin: 0; padding-left: 1.25rem; display: grid; gap: .6rem; }
.howto li span { display: block; color: var(--text-muted); }
.stars { display: inline-flex; gap: .15rem; }
.star { position: relative; cursor: pointer; }
.star input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.star span[aria-hidden] { font-size: 1.8rem; line-height: 1; color: var(--border-strong); display: inline-grid; place-items: center; width: 44px; height: 44px; }
.star span.on { color: var(--accent); }
.star input:focus-visible + span { outline: 3px solid var(--focus); border-radius: 8px; }

/* ---------- Finanzrechner ---------- */
.calc-card { display: flex; flex-direction: column; gap: .35rem; }
.calc-card .f-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; }
.calc-card .f-icon svg { width: 22px; height: 22px; }
.calc-result .stat-value { font-size: 1.9rem; }
.result-grid { display: grid; gap: .9rem 1.25rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); }

/* ---------- Rechtliches & Neuigkeiten ---------- */
.legal h2 { font-size: 1.1rem; margin-top: 1.5rem; }
.pre-line { white-space: pre-line; }
.release-list { margin: 0; padding-left: 1.2rem; display: grid; gap: .4rem; }
.payoff-debt { padding: .75rem; }
.line-editor-row { display: grid; grid-template-columns: 1fr minmax(9rem, 12rem) auto; gap: .5rem; align-items: end; }
@media (max-width: 479.98px) { .line-editor-row { grid-template-columns: 1fr auto; } .line-editor-row .field:nth-child(2) { grid-column: 1; } }
.glossary-more summary { cursor: pointer; color: var(--primary); font-weight: 600; font-size: .9rem; min-height: 36px; display: flex; align-items: center; }

/* Sehr schmale Bildschirme (320 px): lange Button-Texte umbrechen statt überlaufen. */
@media (max-width: 479.98px) {
  .btn { white-space: normal; max-width: 100%; text-align: center; height: auto; }
}
