/* ==========================================================================
   Budgetradar — Designsystem nach shadcn/ui (https://ui.shadcn.com)
   Tokens: shadcn "neutral" Basis in oklch, Primärfarbe auf Budgetradar-Blau.
   Die alten Variablennamen (--bg, --surface, --text, --green ...) bleiben als
   Aliase erhalten, weil die Templates sie in Inline-Styles verwenden.
   ========================================================================== */

/* --- Tokens: Dunkel ist Standard (Fallback, falls kein data-theme gesetzt) --- */
:root,
[data-theme="dark"] {
    --background:            oklch(0.145 0 0);
    --foreground:            oklch(0.985 0 0);
    --card:                  oklch(0.205 0 0);
    --card-foreground:       oklch(0.985 0 0);
    --popover:               oklch(0.205 0 0);
    --popover-foreground:    oklch(0.985 0 0);
    --primary:               oklch(0.623 0.214 259.815);
    --primary-hover:         oklch(0.678 0.198 259.815);
    --primary-foreground:    oklch(0.985 0 0);
    --secondary:             oklch(0.269 0 0);
    --secondary-foreground:  oklch(0.985 0 0);
    --muted:                 oklch(0.269 0 0);
    --muted-foreground:      oklch(0.708 0 0);
    --accent:                oklch(0.269 0 0);
    --accent-foreground:     oklch(0.985 0 0);
    --destructive:           oklch(0.704 0.191 22.216);
    --destructive-hover:     oklch(0.648 0.191 22.216);
    --destructive-foreground:oklch(0.985 0 0);
    --success:               oklch(0.723 0.179 148.5);
    --warning:               oklch(0.795 0.162 86.047);
    --border:                oklch(0.32 0 0);
    --input:                 oklch(0.35 0 0);
    --ring:                  oklch(0.623 0.214 259.815);

    /* Weiche Flächen für Badges, Alerts, Hervorhebungen */
    --primary-soft:          oklch(0.623 0.214 259.815 / 15%);
    --success-soft:          oklch(0.723 0.179 148.5 / 15%);
    --warning-soft:          oklch(0.795 0.162 86.047 / 15%);
    --destructive-soft:      oklch(0.704 0.191 22.216 / 15%);
    --overlay:               oklch(0 0 0 / 70%);
    --row-hover:             oklch(1 0 0 / 4%);

    /* Akzentfarben für Kennzahl-Kacheln (Vorbild: theme.css im Stillhalter Tracker) —
       bewusst gedämpft, damit sie neben der Grundpalette nicht herausstechen */
    --accent-green:  oklch(0.723 0.179 148.5);
    --accent-red:    oklch(0.637 0.208 25.331);
    --accent-blue:   oklch(0.623 0.214 259.815);
    --accent-orange: oklch(0.705 0.166 55.934);
    --accent-teal:   oklch(0.704 0.121 195.4);
    --accent-purple: oklch(0.627 0.233 303.9);

    /* Diagrammpalette: gleiche Sättigung/Helligkeit, damit kein Segment dominiert */
    --chart-1:  oklch(0.623 0.214 259.815);
    --chart-2:  oklch(0.723 0.179 148.5);
    --chart-3:  oklch(0.705 0.166 55.934);
    --chart-4:  oklch(0.627 0.233 303.9);
    --chart-5:  oklch(0.637 0.208 25.331);
    --chart-6:  oklch(0.704 0.121 195.4);
    --chart-7:  oklch(0.681 0.162 130.2);
    --chart-8:  oklch(0.769 0.155 85.9);
    --chart-9:  oklch(0.652 0.201 340.6);
    --chart-10: oklch(0.606 0.048 250.1);
    --chart-11: oklch(0.646 0.198 12.4);
    --chart-12: oklch(0.618 0.123 40.3);

    --radius:                0.625rem;
    --radius-sm:             calc(var(--radius) - 4px);
    --radius-md:             calc(var(--radius) - 2px);
    --radius-lg:             var(--radius);
    --radius-xl:             calc(var(--radius) + 4px);

    --shadow-xs:  0 1px 2px 0 oklch(0 0 0 / 25%);
    --shadow-sm:  0 1px 3px 0 oklch(0 0 0 / 30%), 0 1px 2px -1px oklch(0 0 0 / 30%);
    --shadow-md:  0 4px 6px -1px oklch(0 0 0 / 35%), 0 2px 4px -2px oklch(0 0 0 / 35%);
    --shadow-lg:  0 10px 15px -3px oklch(0 0 0 / 40%), 0 4px 6px -4px oklch(0 0 0 / 40%);

    /* --- Legacy-Aliase: von Inline-Styles in den Templates benutzt --- */
    --bg:         var(--background);
    --surface:    var(--card);
    --surface2:   var(--muted);
    --text:       var(--foreground);
    --text-muted: var(--muted-foreground);
    --green:      var(--success);
    --red:        var(--destructive);
    --yellow:     var(--warning);
}

/* --- Tokens: Hell --- */
[data-theme="light"] {
    --background:            oklch(1 0 0);
    --foreground:            oklch(0.145 0 0);
    --card:                  oklch(1 0 0);
    --card-foreground:       oklch(0.145 0 0);
    --popover:               oklch(1 0 0);
    --popover-foreground:    oklch(0.145 0 0);
    --primary:               oklch(0.546 0.245 262.881);
    --primary-hover:         oklch(0.488 0.243 264.376);
    --primary-foreground:    oklch(0.985 0 0);
    --secondary:             oklch(0.97 0 0);
    --secondary-foreground:  oklch(0.205 0 0);
    --muted:                 oklch(0.97 0 0);
    --muted-foreground:      oklch(0.556 0 0);
    --accent:                oklch(0.97 0 0);
    --accent-foreground:     oklch(0.205 0 0);
    --destructive:           oklch(0.577 0.245 27.325);
    --destructive-hover:     oklch(0.514 0.245 27.325);
    --destructive-foreground:oklch(0.985 0 0);
    --success:               oklch(0.627 0.194 149.214);
    --warning:               oklch(0.681 0.162 75.834);
    --border:                oklch(0.922 0 0);
    --input:                 oklch(0.922 0 0);
    --ring:                  oklch(0.546 0.245 262.881);

    --primary-soft:          oklch(0.546 0.245 262.881 / 10%);
    --success-soft:          oklch(0.627 0.194 149.214 / 12%);
    --warning-soft:          oklch(0.681 0.162 75.834 / 15%);
    --destructive-soft:      oklch(0.577 0.245 27.325 / 10%);
    --overlay:               oklch(0 0 0 / 55%);
    --row-hover:             oklch(0 0 0 / 3%);

    /* Im Hellmodus etwas dunkler, damit die Farben auf Weiß genug Kontrast haben */
    --accent-green:  oklch(0.567 0.168 148.5);
    --accent-red:    oklch(0.577 0.245 27.325);
    --accent-blue:   oklch(0.546 0.245 262.881);
    --accent-orange: oklch(0.622 0.171 51.2);
    --accent-teal:   oklch(0.588 0.114 195.4);
    --accent-purple: oklch(0.558 0.243 303.9);

    --chart-1:  oklch(0.546 0.245 262.881);
    --chart-2:  oklch(0.567 0.168 148.5);
    --chart-3:  oklch(0.622 0.171 51.2);
    --chart-4:  oklch(0.558 0.243 303.9);
    --chart-5:  oklch(0.577 0.245 27.325);
    --chart-6:  oklch(0.588 0.114 195.4);
    --chart-7:  oklch(0.575 0.148 130.2);
    --chart-8:  oklch(0.681 0.145 85.9);
    --chart-9:  oklch(0.579 0.201 340.6);
    --chart-10: oklch(0.529 0.045 250.1);
    --chart-11: oklch(0.573 0.203 12.4);
    --chart-12: oklch(0.541 0.113 40.3);

    --shadow-xs:  0 1px 2px 0 oklch(0 0 0 / 5%);
    --shadow-sm:  0 1px 3px 0 oklch(0 0 0 / 10%), 0 1px 2px -1px oklch(0 0 0 / 10%);
    --shadow-md:  0 4px 6px -1px oklch(0 0 0 / 10%), 0 2px 4px -2px oklch(0 0 0 / 10%);
    --shadow-lg:  0 10px 15px -3px oklch(0 0 0 / 10%), 0 4px 6px -4px oklch(0 0 0 / 10%);
}

/* ==========================================================================
   Basis
   ========================================================================== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body { overflow-x: hidden; max-width: 100vw; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto,
                 'Helvetica Neue', Arial, sans-serif;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
    background: var(--background);
    color: var(--foreground);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img, svg { max-width: 100%; }
svg { flex-shrink: 0; }

::selection { background: var(--primary-soft); }

/* Einheitlicher Fokusring wie bei shadcn */
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

/* ==========================================================================
   Typografie
   ========================================================================== */
h1 { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; margin-bottom: 1rem; }
h2 { font-size: 1.125rem; font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; margin-bottom: .75rem; color: var(--foreground); }
h3 { font-size: .9375rem; font-weight: 600; line-height: 1.4; margin-bottom: .5rem; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ==========================================================================
   Layout
   ========================================================================== */
.container { max-width: 87.5rem; margin: 0 auto; padding: 1.5rem 2rem 4rem; }

/* --- Header (shadcn "site header": sticky, border-b, backdrop blur) --- */
nav {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .75rem 1rem;
    /* feste Höhe nur als Mindestmaß: bei hoher Zoomstufe darf die Leiste umbrechen,
       statt die hinteren Einträge abzuschneiden */
    min-height: 3.5rem;
    flex-wrap: wrap;
    padding: .5rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--background);
}

@supports (backdrop-filter: blur(8px)) {
    nav {
        background: color-mix(in oklab, var(--background) 80%, transparent);
        backdrop-filter: blur(12px) saturate(180%);
        -webkit-backdrop-filter: blur(12px) saturate(180%);
    }
}

nav .brand {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    font-size: .9375rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--foreground);
    text-decoration: none;
    white-space: nowrap;
}
nav .brand:hover { text-decoration: none; }
nav .brand .brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.625rem;
    height: 1.625rem;
    border-radius: var(--radius-md);
    background: var(--primary);
    color: var(--primary-foreground);
    flex-shrink: 0;
}
/* Die Bildmarke aus _logo.html bringt keine feste Größe mit — hier gesetzt */
.brand-mark svg { width: 1.0625rem; height: 1.0625rem; }
.auth-brand svg { width: 1.5rem; height: 1.5rem; }

nav .nav-links { display: flex; gap: .25rem; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

/* Navigationslinks als Ghost-Buttons */
nav .nav-links > a {
    display: inline-flex;
    align-items: center;
    gap: .375rem;
    height: 2rem;
    padding: 0 .625rem;
    border-radius: var(--radius-md);
    font-size: .875rem;
    font-weight: 500;
    color: var(--muted-foreground);
    text-decoration: none;
    white-space: nowrap;
    transition: background-color .15s, color .15s;
}
nav .nav-links > a:hover { background: var(--accent); color: var(--accent-foreground); text-decoration: none; }
nav .nav-links > a.active { background: var(--accent); color: var(--foreground); }

nav .nav-sep { width: 1px; height: 1.25rem; background: var(--border); margin: 0 .375rem; flex-shrink: 0; }

/* ==========================================================================
   Card
   ========================================================================== */
.card {
    background: var(--card);
    color: var(--card-foreground);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
}
.card > h2:first-child, .card > h1:first-child { margin-top: 0; }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(12.5rem, 1fr)); }

/* --- Kennzahlen-Karte mit farbigem Icon-Quadrat --- */
.stat-card {
    text-align: left;
    padding: 1.25rem 1.5rem;
    transition: border-color .15s, box-shadow .15s;
}
.stat-card:hover { border-color: color-mix(in oklab, var(--foreground) 18%, transparent); box-shadow: var(--shadow-sm); }
.stat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.125rem;
    height: 2.125rem;
    margin-bottom: .75rem;
    border-radius: var(--radius-md);
}
.stat-icon svg { width: 1.0625rem; height: 1.0625rem; }
.stat-icon.green  { background: color-mix(in oklab, var(--accent-green) 14%, transparent);  color: var(--accent-green); }
.stat-icon.red    { background: color-mix(in oklab, var(--accent-red) 14%, transparent);    color: var(--accent-red); }
.stat-icon.blue   { background: color-mix(in oklab, var(--accent-blue) 14%, transparent);   color: var(--accent-blue); }
.stat-icon.orange { background: color-mix(in oklab, var(--accent-orange) 14%, transparent); color: var(--accent-orange); }
.stat-icon.teal   { background: color-mix(in oklab, var(--accent-teal) 14%, transparent);   color: var(--accent-teal); }
.stat-icon.purple { background: color-mix(in oklab, var(--accent-purple) 14%, transparent); color: var(--accent-purple); }
.stat-card .value {
    font-size: 1.875rem;
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}
.stat-card .label { color: var(--muted-foreground); font-size: .8125rem; margin-top: .375rem; }
.stat-card.positive .value { color: var(--success); }
.stat-card.negative .value { color: var(--destructive); }

/* ==========================================================================
   Seitenkopf
   ========================================================================== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}
.page-header h1 { margin-bottom: .25rem; }
.page-sub { color: var(--muted-foreground); font-size: .875rem; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.card-sub { color: var(--muted-foreground); font-size: .875rem; margin-bottom: 1.25rem; margin-top: -.375rem; }

.text-success { color: var(--success); }
.text-destructive { color: var(--destructive); }

/* ==========================================================================
   Leerzustand
   ========================================================================== */
.empty-state { text-align: center; padding: 3.5rem 2rem; }
.empty-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 3.5rem; height: 3.5rem; margin-bottom: 1.25rem;
    border-radius: var(--radius-xl);
    background: var(--muted); color: var(--muted-foreground);
}
.empty-icon svg { width: 1.75rem; height: 1.75rem; }
.empty-state h2 { margin-bottom: .5rem; }
.empty-state p { color: var(--muted-foreground); font-size: .875rem; max-width: 26rem; margin: 0 auto; line-height: 1.6; }
.empty-actions { display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; margin-top: 1.5rem; }

/* ==========================================================================
   Szenarienvergleich
   ========================================================================== */
.compare-card { margin-bottom: 1.5rem; }
.cmp-row {
    display: grid;
    grid-template-columns: minmax(6rem, 9.5rem) 1fr minmax(6rem, auto);
    align-items: center;
    gap: 1rem;
    padding: .5rem .5rem;
    margin: 0 -.5rem;
    border-radius: var(--radius-md);
    text-decoration: none;
    color: inherit;
    transition: background-color .15s;
    animation: rise-in .4s ease-out backwards;
    animation-delay: calc(var(--i, 0) * 70ms);
}
.cmp-row:hover { background: var(--row-hover); text-decoration: none; }
.cmp-name {
    font-size: .875rem; font-weight: 500;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cmp-track { height: .625rem; border-radius: 9999px; background: var(--muted); overflow: hidden; }
.cmp-fill {
    display: block; height: 100%; border-radius: 9999px;
    transform-origin: left center;
    animation: bar-grow .6s cubic-bezier(.22,.61,.36,1) backwards;
    animation-delay: calc(var(--i, 0) * 70ms + 80ms);
}
.cmp-fill.is-positive { background: var(--success); }
.cmp-fill.is-negative { background: var(--destructive); }
.cmp-value { font-size: .875rem; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }

/* ==========================================================================
   Szenario-Karte
   ========================================================================== */
.scenario-grid .card { margin-bottom: 0; }
.scenario-card {
    cursor: pointer;
    display: flex;
    flex-direction: column;
    padding: 1.25rem;
    transition: border-color .15s, box-shadow .15s, transform .15s;
    animation: rise-in .4s ease-out backwards;
    animation-delay: calc(var(--i, 0) * 70ms);
}
.scenario-card:hover {
    border-color: color-mix(in oklab, var(--primary) 50%, var(--border));
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.sc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; margin-bottom: .75rem; }
.sc-head h2 { margin: 0; font-size: 1rem; overflow: hidden; text-overflow: ellipsis; }

.sc-amount {
    font-size: 1.75rem; font-weight: 600; letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums; line-height: 1.1;
}
.sc-amount-unit { font-size: .8125rem; font-weight: 400; letter-spacing: normal; color: var(--muted-foreground); }

.sc-ratio { margin: 1rem 0 1.125rem; }
.sc-ratio-track { height: .5rem; border-radius: 9999px; background: var(--muted); overflow: hidden; }
.sc-ratio-fill {
    height: 100%; border-radius: 9999px;
    background: var(--primary);
    transform-origin: left center;
    animation: bar-grow .6s cubic-bezier(.22,.61,.36,1) backwards;
    animation-delay: calc(var(--i, 0) * 70ms + 120ms);
}
.sc-ratio-fill.is-over { background: var(--destructive); }
.sc-ratio-label { display: flex; justify-content: space-between; font-size: .75rem; color: var(--muted-foreground); margin-top: .4rem; }

/* Label links, Betrag rechts — stapelt sich statt zu kollidieren, egal wie stark gezoomt wird */
.sc-split { display: flex; flex-direction: column; gap: .375rem; }
.sc-row { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.sc-row-label { font-size: .8125rem; color: var(--muted-foreground); }
.sc-split .amount { font-size: .9375rem; white-space: nowrap; }

.sc-cats { display: flex; flex-wrap: wrap; gap: .375rem; margin-top: 1rem; }
.cat-chip {
    display: inline-flex; align-items: center; gap: .375rem;
    padding: .1875rem .5rem;
    border: 1px solid var(--border); border-radius: 9999px;
    background: var(--background);
    font-size: .75rem; color: var(--muted-foreground);
    max-width: 100%;
}
.cat-dot { width: .5rem; height: .5rem; border-radius: 9999px; flex-shrink: 0; }
.cat-share { color: var(--foreground); font-weight: 500; font-variant-numeric: tabular-nums; }

.sc-foot {
    display: flex; justify-content: space-between; align-items: center; gap: .5rem;
    margin-top: auto; padding-top: 1rem;
}
.sc-meta { font-size: .75rem; color: var(--muted-foreground); }
.sc-export { color: var(--muted-foreground); }

.badge-negative {
    background: var(--destructive-soft);
    border-color: color-mix(in oklab, var(--destructive) 25%, transparent);
    color: var(--destructive);
}

.modal-actions { display: flex; gap: .5rem; justify-content: flex-end; }

@keyframes rise-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
}
@keyframes bar-grow {
    from { transform: scaleX(0); }
    to   { transform: scaleX(1); }
}

/* ==========================================================================
   Button
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    height: 2.25rem;
    padding: 0 1rem;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: .875rem;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    text-decoration: none;
    transition: background-color .15s, border-color .15s, color .15s, opacity .15s;
}
.btn:hover { text-decoration: none; }
.btn:disabled, .btn[disabled] { pointer-events: none; opacity: .5; }
.btn svg { width: 1rem; height: 1rem; }

.btn-primary {
    background: var(--primary);
    color: var(--primary-foreground);
    box-shadow: var(--shadow-xs);
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-danger {
    background: var(--destructive);
    color: var(--destructive-foreground);
    box-shadow: var(--shadow-xs);
}
.btn-danger:hover { background: var(--destructive-hover); }

.btn-outline {
    background: var(--background);
    border-color: var(--border);
    color: var(--foreground);
    box-shadow: var(--shadow-xs);
}
.btn-outline:hover { background: var(--accent); color: var(--accent-foreground); }
.btn-outline.active {
    background: var(--primary-soft);
    border-color: color-mix(in oklab, var(--primary) 45%, transparent);
    color: var(--primary);
}

.btn-ghost { background: transparent; color: var(--foreground); }
.btn-ghost:hover { background: var(--accent); color: var(--accent-foreground); }

.btn-sm { height: 2rem; padding: 0 .75rem; font-size: .8125rem; border-radius: var(--radius-sm); }
.btn-sm svg { width: .875rem; height: .875rem; }

/* Quadratischer Icon-Button (Zoom, Theme-Umschalter) */
.zoom-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--muted-foreground);
    font-family: inherit;
    font-size: .875rem;
    cursor: pointer;
    transition: background-color .15s, color .15s;
}
.zoom-btn:hover { background: var(--accent); color: var(--accent-foreground); }
.zoom-btn svg { width: 1rem; height: 1rem; }

/* Zoomstufe: Anzeige und Rücksetzknopf in einem */
.zoom-group {
    display: inline-flex;
    align-items: center;
    gap: .125rem;
    padding: .125rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}
.zoom-level {
    min-width: 3.25rem;
    height: 1.75rem;
    padding: 0 .25rem;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--muted-foreground);
    font-family: inherit;
    font-size: .75rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    transition: background-color .15s, color .15s;
}
.zoom-level:hover { background: var(--accent); color: var(--accent-foreground); }
.zoom-level.is-changed { color: var(--primary); font-weight: 600; }

/* ==========================================================================
   Formularelemente
   ========================================================================== */
input, select, textarea {
    display: block;
    width: 100%;
    height: 2.25rem;
    padding: 0 .75rem;
    border: 1px solid var(--input);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--foreground);
    font-family: inherit;
    font-size: .875rem;
    box-shadow: var(--shadow-xs);
    transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; min-height: 4.5rem; padding: .5rem .75rem; line-height: 1.5; resize: vertical; }

input::placeholder, textarea::placeholder { color: var(--muted-foreground); }

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--ring);
    box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 25%, transparent);
}
input:disabled, select:disabled, textarea:disabled { opacity: .5; cursor: not-allowed; }

input[type="checkbox"], input[type="radio"] {
    width: 1rem;
    height: 1rem;
    accent-color: var(--primary);
    box-shadow: none;
    vertical-align: middle;
}

input[type="file"] {
    height: auto;
    padding: .375rem .75rem;
    font-size: .8125rem;
    line-height: 1.6;
}
input[type="file"]::file-selector-button {
    margin-right: .75rem;
    padding: .25rem .625rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--background);
    color: var(--foreground);
    font-family: inherit;
    font-size: .8125rem;
    font-weight: 500;
    cursor: pointer;
}

/* Auswahlfeld mit Chevron wie bei shadcn */
select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 2rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .625rem center;
    cursor: pointer;
}
select option { background: var(--popover); color: var(--popover-foreground); }

label {
    display: block;
    font-size: .875rem;
    font-weight: 500;
    line-height: 1;
    color: var(--foreground);
    margin-bottom: .5rem;
    text-transform: none;
    letter-spacing: normal;
}

/* --- Einstellungszeile mit Schalter (shadcn "Switch") --- */
.setting-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 1.5rem; }
.setting-text { min-width: 0; }
.setting-title { font-size: .9375rem; font-weight: 500; margin-bottom: .25rem; }
.setting-desc { font-size: .8125rem; color: var(--muted-foreground); line-height: 1.55; max-width: 46rem; }

.switch { position: relative; flex-shrink: 0; display: inline-flex; cursor: pointer; margin-top: .125rem; }
.switch input {
    position: absolute; inset: 0; width: 100%; height: 100%;
    opacity: 0; margin: 0; cursor: pointer; z-index: 1;
}
.switch-track {
    display: inline-flex; align-items: center;
    width: 2.75rem; height: 1.5rem; padding: .125rem;
    border-radius: 9999px;
    background: var(--muted);
    border: 1px solid var(--border);
    transition: background-color .15s, border-color .15s;
}
.switch-thumb {
    width: 1.125rem; height: 1.125rem;
    border-radius: 9999px;
    background: var(--background);
    box-shadow: var(--shadow-xs);
    transition: transform .15s ease;
}
.switch input:checked + .switch-track { background: var(--primary); border-color: var(--primary); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(1.25rem); background: #fff; }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--ring); outline-offset: 2px; }

@media (max-width: 768px) {
    .setting-row { flex-direction: column; gap: .75rem; }
}

.form-row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end; }
.form-group { flex: 1; min-width: 7.5rem; }

/* ==========================================================================
   Tabelle
   ========================================================================== */
.card:has(table) { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 35rem; font-size: .875rem; }
th {
    height: 2.75rem;
    padding: 0 .75rem;
    text-align: left;
    vertical-align: middle;
    font-size: .8125rem;
    font-weight: 500;
    text-transform: none;
    letter-spacing: normal;
    color: var(--muted-foreground);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
td { padding: .75rem; vertical-align: middle; border-bottom: 1px solid var(--border); }
tbody tr { transition: background-color .15s; }
tbody tr:hover { background: var(--row-hover); }
tbody tr:last-child td { border-bottom: none; }

.amount { font-variant-numeric: tabular-nums; text-align: right; font-weight: 500; }
.amount.expense { color: var(--destructive); }
.amount.income { color: var(--success); }

/* ==========================================================================
   Badge
   ========================================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .125rem .5rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: .75rem;
    font-weight: 500;
    line-height: 1.35;
    white-space: nowrap;
}
.badge-cat {
    background: var(--primary-soft);
    border-color: color-mix(in oklab, var(--primary) 25%, transparent);
    color: var(--primary);
}
.badge-reserve {
    background: var(--warning-soft);
    border-color: color-mix(in oklab, var(--warning) 25%, transparent);
    color: var(--warning);
}
.badge-confirmed {
    background: var(--success-soft);
    border-color: color-mix(in oklab, var(--success) 25%, transparent);
    color: var(--success);
}

.confirm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.75rem;
    height: 1.75rem;
    padding: 0 .5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--muted-foreground);
    font-family: inherit;
    font-size: .75rem;
    cursor: pointer;
    transition: background-color .15s, border-color .15s, color .15s;
}
.confirm-btn:hover { background: var(--accent); color: var(--accent-foreground); }
.confirm-btn.confirmed {
    background: var(--success-soft);
    border-color: color-mix(in oklab, var(--success) 35%, transparent);
    color: var(--success);
}

/* ==========================================================================
   Alert (Flash-Meldungen)
   ========================================================================== */
.flash {
    position: relative;
    padding: .75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 1rem;
    font-size: .875rem;
    background: var(--card);
    color: var(--foreground);
}
.flash.error {
    background: var(--destructive-soft);
    border-color: color-mix(in oklab, var(--destructive) 30%, transparent);
    color: var(--destructive);
}
.flash.info {
    background: var(--primary-soft);
    border-color: color-mix(in oklab, var(--primary) 30%, transparent);
    color: var(--primary);
}
.flash.success {
    background: var(--success-soft);
    border-color: color-mix(in oklab, var(--success) 30%, transparent);
    color: var(--success);
}

/* ==========================================================================
   Dialog
   ========================================================================== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    background: var(--overlay);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    justify-content: center;
    align-items: center;
    padding: 1rem;
}
.modal-overlay.active { display: flex; animation: overlay-in .15s ease-out; }
.modal {
    background: var(--popover);
    color: var(--popover-foreground);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    width: 100%;
    max-width: 37.5rem;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modal-in .15s ease-out;
}
.modal h2 { margin-bottom: 1rem; }

@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in {
    from { opacity: 0; transform: scale(.97) translateY(4px); }
    to   { opacity: 1; transform: none; }
}

/* ==========================================================================
   Tabs (Wochen-/Monats-/Jahresumschalter)
   ========================================================================== */
.view-toggle {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .25rem;
    border-radius: var(--radius-lg);
    background: var(--muted);
    margin-bottom: 1rem;
}
.view-toggle .btn {
    height: 1.875rem;
    border: none;
    background: transparent;
    box-shadow: none;
    color: var(--muted-foreground);
}
.view-toggle .btn:hover { background: transparent; color: var(--foreground); }
.view-toggle .btn.active {
    background: var(--background);
    color: var(--foreground);
    box-shadow: var(--shadow-xs);
}

/* ==========================================================================
   Fortschritt & Diagrammbalken
   ========================================================================== */
.progress-bar {
    height: .5rem;
    background: var(--muted);
    border-radius: 9999px;
    overflow: hidden;
    margin-top: .5rem;
}
.progress-fill { height: 100%; border-radius: 9999px; transition: width .3s ease; }

/* ==========================================================================
   Ringdiagramm mit Legende
   ========================================================================== */
.donut-layout {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 2rem;
    align-items: center;
}
.donut-wrap { position: relative; width: 11rem; height: 11rem; flex-shrink: 0; }
.donut { width: 100%; height: 100%; transform: rotate(-90deg); }
.donut-track { fill: none; stroke: var(--muted); stroke-width: 3.2; }
.donut-seg {
    fill: none;
    stroke-width: 3.2;
    stroke-linecap: butt;
    transition: stroke-width .15s, opacity .15s;
}
.donut-seg:hover { stroke-width: 4.2; }
.donut-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    pointer-events: none;
}
.donut-center .donut-total {
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}
.donut-center .donut-caption { font-size: .6875rem; color: var(--muted-foreground); margin-top: .125rem; }

.donut-legend { display: flex; flex-direction: column; gap: .125rem; min-width: 0; }
.legend-row {
    display: grid;
    grid-template-columns: .625rem minmax(0, 1fr) auto auto auto;
    align-items: center;
    gap: .625rem;
    padding: .375rem .5rem;
    margin: 0 -.5rem;
    border-radius: var(--radius-sm);
    font-size: .875rem;
    transition: background-color .15s;
}
.legend-row:hover { background: var(--row-hover); }
.legend-dot { width: .625rem; height: .625rem; border-radius: 9999px; }
.legend-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-count { font-size: .75rem; color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
.legend-value { font-variant-numeric: tabular-nums; font-weight: 500; min-width: 6rem; text-align: right; }
.legend-share { font-size: .75rem; color: var(--muted-foreground); font-variant-numeric: tabular-nums; min-width: 2.5rem; text-align: right; }

@media (max-width: 768px) {
    .donut-layout { grid-template-columns: 1fr; justify-items: center; gap: 1.25rem; }
    .donut-legend { width: 100%; }
}

.chart-bar { display: flex; align-items: center; gap: .75rem; margin-bottom: .5rem; }
.chart-bar .bar-label { width: 8.75rem; font-size: .8125rem; color: var(--muted-foreground); text-align: right; flex-shrink: 0; }
.chart-bar .bar-track { flex: 1; height: 1.5rem; background: var(--muted); border-radius: var(--radius-sm); overflow: hidden; }
.chart-bar .bar-fill {
    height: 100%;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    padding: 0 .5rem;
    font-size: .6875rem;
    font-weight: 600;
    min-width: fit-content;
}
.chart-bar .bar-value { width: 6.25rem; text-align: right; font-size: .8125rem; font-variant-numeric: tabular-nums; }

/* ==========================================================================
   Kategorieüberschrift
   ========================================================================== */
.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .5rem 0;
    margin-top: 1.5rem;
    border-bottom: 1px solid var(--border);
}
.category-total { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--destructive); }

/* --- Bankauswahl --- */
.bank-option { background: var(--card); }
.bank-option:hover { border-color: color-mix(in oklab, var(--primary) 40%, var(--border)) !important; }

/* ==========================================================================
   Anmeldeseiten
   ========================================================================== */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 2rem 1rem;
}
.auth-card { width: 100%; max-width: 25rem; margin-bottom: 0; padding: 2rem; box-shadow: var(--shadow-lg); }
.auth-card h1 { text-align: center; font-size: 1.375rem; margin-bottom: .375rem; }
.auth-card .auth-sub { text-align: center; color: var(--muted-foreground); font-size: .875rem; margin-bottom: 1.5rem; }
.auth-card .form-group { margin-bottom: 1rem; }
.auth-card .btn { width: 100%; margin-top: .5rem; }
.auth-card .link { text-align: center; margin-top: 1rem; font-size: .875rem; color: var(--muted-foreground); }
.auth-card .link a { color: var(--foreground); font-weight: 500; }

/* Markenzeichen über dem Anmeldeformular */
.auth-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    margin: 0 auto 1rem;
    border-radius: var(--radius-lg);
    background: var(--primary);
    color: var(--primary-foreground);
}

/* ==========================================================================
   Rechtstexte
   ========================================================================== */
.legal-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 3.5rem;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--background);
}
.legal-content { max-width: 48.75rem; margin: 0 auto; padding: 3.5rem 1.5rem 6rem; line-height: 1.7; }
.legal-content h1 { font-size: 1.875rem; font-weight: 600; letter-spacing: -0.025em; margin-bottom: .5rem; }
.legal-content .updated { color: var(--muted-foreground); font-size: .875rem; margin-bottom: 2.5rem; }
.legal-content h2 { font-size: 1.25rem; font-weight: 600; margin-top: 2.5rem; margin-bottom: .75rem; color: var(--foreground); }
.legal-content h3 { font-size: 1rem; font-weight: 600; margin-top: 1.5rem; margin-bottom: .5rem; }
.legal-content p, .legal-content li { color: var(--muted-foreground); font-size: .9375rem; }
.legal-content li { margin-left: 1.25rem; }
.legal-content a { color: var(--primary); }

/* ==========================================================================
   Mobil
   ========================================================================== */
/* ==========================================================================
   Tabellen als Karten auf schmalen Schirmen

   Breite Tabellen (die Ausgabenliste hat neun Spalten) sind auf dem Handy
   unbrauchbar: sie ragen aus dem Bild, und da `body` waagerechtes Scrollen
   unterbindet, sind die hinteren Spalten — Betrag, Status, Bearbeiten, Löschen —
   schlicht nicht erreichbar. Unterhalb von 768px wird deshalb jede Zeile zu einer
   eigenen Karte, in der jede Zelle ihre Spaltenüberschrift aus `data-label` als
   vorangestellte Beschriftung mitbringt.
   ========================================================================== */
@media (max-width: 768px) {
    table.table-cards { display: block; min-width: 0; }
    /* `display:block` auf tr würde sonst das hidden-Attribut aushebeln — dann bleiben
       aufklappbare Detailzeilen dauerhaft sichtbar und der Klick wirkt funktionslos. */
    .table-cards tr[hidden] { display: none; }
    .table-cards thead { display: none; }
    .table-cards tbody { display: block; }

    .table-cards tr {
        display: block;
        padding: .75rem .875rem;
        margin-bottom: .5rem;
        border: 1px solid var(--border);
        border-radius: var(--radius-lg);
        background: var(--card);
    }
    .table-cards tr:hover { background: var(--card); }
    .table-cards tr:last-child td { border-bottom: none; }

    .table-cards td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        padding: .1875rem 0;
        border: none;
        text-align: left;
    }
    .table-cards td[data-label]::before {
        content: attr(data-label);
        flex-shrink: 0;
        font-size: .75rem;
        color: var(--muted-foreground);
    }
    /* Zellen, die nur bei Bedarf gefüllt werden (z.B. Rücklage), sonst ausblenden */
    .table-cards td.cell-optional:not(:has(*)) { display: none; }

    /* Knopfzeile am Kartenfuß */
    .table-cards td.cell-actions {
        justify-content: flex-start;
        gap: .5rem;
        margin-top: .5rem;
        padding-top: .625rem;
        border-top: 1px solid var(--border);
    }
    .table-cards td.cell-actions::before { display: none; }
    .table-cards td.cell-actions .btn,
    .table-cards td.cell-actions .confirm-btn { min-height: 2.25rem; }

    /* Symbolknöpfe beschriften — auf dem Touchscreen ist "✎" allein zu wenig */
    .table-cards .cell-actions .edit-item-btn::after { content: "Bearbeiten"; margin-left: .375rem; }
    .table-cards .cell-actions .btn-danger::after { content: "Löschen"; margin-left: .375rem; }

    /* Buchungstext ist mobil die wichtigste Spalte — ausschreiben statt abschneiden.
       Die Kürzung steht als Inline-Style im Template, daher !important. */
    .table-cards .txn-description {
        display: block;
        max-width: none !important;
        white-space: normal !important;
        overflow: visible !important;
        font-weight: 500;
        padding-bottom: .25rem;
    }
    /* Zuordnungs-Auswahl über die volle Kartenbreite bedienbar machen */
    .table-cards .cell-actions form { width: 100%; flex-wrap: wrap; }
    .table-cards .cell-actions select {
        max-width: none !important;
        font-size: .875rem !important;
        flex: 1 1 100%;
    }
}

@media (max-width: 768px) {
    .container { padding: 1rem 1rem 3rem; }

    nav { padding: .625rem 1rem; row-gap: .5rem; }
    /* auf schmalen Schirmen eine einzige, seitlich scrollbare Zeile statt Mehrfachumbruch */
    nav .nav-links {
        width: 100%;
        gap: .125rem;
        flex-wrap: nowrap;
        justify-content: flex-start;
        overflow-x: auto;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    nav .nav-links > a, nav .zoom-group { flex-shrink: 0; }

    /* Vergleichsbalken: Name und Wert oben, Balken darunter über die volle Breite */
    .cmp-row {
        grid-template-columns: 1fr auto;
        grid-template-areas: "name value" "track track";
        gap: .375rem .75rem;
    }
    .cmp-name { grid-area: name; }
    .cmp-value { grid-area: value; }
    .cmp-track { grid-area: track; }
    nav .nav-links::-webkit-scrollbar { display: none; }
    nav .nav-links > a { font-size: .8125rem; padding: 0 .5rem; }

    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .stat-card .value { font-size: 1.5rem; }
    .form-row { flex-direction: column; align-items: stretch; }
    .form-group { min-width: 0; }
    .modal { padding: 1.25rem; }
    .chart-bar { flex-wrap: wrap; }
    .chart-bar .bar-label { width: 100%; text-align: left; }
    .chart-bar .bar-value { width: auto; margin-left: auto; }
    h1 { font-size: 1.25rem; }
    .card { padding: 1.25rem; }
    .legal-content { padding: 2rem 1.25rem 4rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
    }
}

/* ==========================================================================
   Rücklagenbedarf
   ========================================================================== */
.reserve-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1.5rem;
    padding-bottom: 1.25rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
}
.reserve-big {
    font-size: 2.25rem;
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.05;
    color: var(--warning);
    font-variant-numeric: tabular-nums;
}
.reserve-big-label { font-size: .8125rem; color: var(--muted-foreground); margin-top: .25rem; }

.reserve-facts { display: flex; flex-wrap: wrap; gap: 1.75rem; }
.reserve-facts > div { display: flex; flex-direction: column; }
.reserve-fact-value { font-size: 1.0625rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.reserve-fact-label { font-size: .75rem; color: var(--muted-foreground); margin-top: .125rem; }

/* Jahresverlauf: wann das Geld wirklich abfließt */
.reserve-year {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: .375rem;
    align-items: end;
    height: 6rem;
}
.reserve-month { display: flex; flex-direction: column; height: 100%; gap: .375rem; }
.reserve-bar-slot {
    flex: 1;
    display: flex;
    align-items: flex-end;
    background: var(--muted);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.reserve-bar {
    width: 100%;
    min-height: 2px;
    background: var(--warning);
    border-radius: var(--radius-sm);
    transform-origin: bottom center;
    animation: bar-rise .5s cubic-bezier(.22,.61,.36,1) backwards;
}
.reserve-month-name { text-align: center; font-size: .6875rem; color: var(--muted-foreground); }
.reserve-month.is-current .reserve-bar-slot { outline: 2px solid var(--ring); outline-offset: 1px; }
.reserve-month.is-current .reserve-month-name { color: var(--foreground); font-weight: 600; }

.reserve-hint { font-size: .75rem; color: var(--muted-foreground); margin-top: .625rem; }
.reserve-table { margin-top: 1.25rem; }

.cat-reserve {
    font-size: .75rem;
    color: var(--warning);
    margin-left: .5rem;
    white-space: nowrap;
}

@keyframes bar-rise { from { transform: scaleY(0); } to { transform: scaleY(1); } }

@media (max-width: 768px) {
    .reserve-head { flex-direction: column; align-items: flex-start; gap: 1rem; }
    .reserve-facts { gap: 1.25rem; }
    .reserve-year { gap: .1875rem; height: 5rem; }
    .cat-reserve { display: block; margin-left: 0; margin-top: .25rem; white-space: normal; }
}

/* --- Aufklappbare Kategoriezeilen in der Rücklagen-Tabelle --- */
.reserve-row { cursor: pointer; }
.reserve-row:hover { background: var(--row-hover); }
.reserve-caret {
    display: inline-flex;
    width: .875rem;
    height: .875rem;
    margin-right: .375rem;
    color: var(--muted-foreground);
    vertical-align: -1px;
    transition: transform .15s;
}
.reserve-caret svg { width: 100%; height: 100%; }
.reserve-row.is-open .reserve-caret { transform: rotate(90deg); }

.reserve-detail > td { padding: 0 0 .75rem; background: transparent; }
.reserve-items {
    width: 100%;
    min-width: 0;
    margin: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: color-mix(in oklab, var(--muted) 55%, transparent);
    overflow: hidden;
}
.reserve-items th { height: 2.25rem; font-size: .75rem; }
.reserve-items td { padding: .5rem .75rem; font-size: .8125rem; }
.reserve-items tbody tr:last-child td { border-bottom: none; }

/* --- Rücklagenkonto im Forecast --- */
.reserve-konto {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.rk-block {
    padding: 1rem 1.125rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--background);
}
.rk-label { font-size: .75rem; color: var(--muted-foreground); margin-bottom: .375rem; }
.rk-value {
    font-size: 1.5rem; font-weight: 600; letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}
.rk-note { font-size: .75rem; color: var(--muted-foreground); margin-top: .375rem; line-height: 1.45; }
.rk-gap.is-ok { border-color: color-mix(in oklab, var(--success) 40%, transparent); background: var(--success-soft); }
.rk-gap.is-ok .rk-value { color: var(--success); }
.rk-gap.is-short { border-color: color-mix(in oklab, var(--destructive) 40%, transparent); background: var(--destructive-soft); }
.rk-gap.is-short .rk-value { color: var(--destructive); }

.rk-bar-wrap { margin-bottom: 1.25rem; }
.rk-bar-track { height: .625rem; border-radius: 9999px; background: var(--muted); overflow: hidden; }
.rk-bar {
    height: 100%; border-radius: 9999px;
    transform-origin: left center;
    animation: bar-grow .6s cubic-bezier(.22,.61,.36,1) backwards;
}
.rk-bar.is-ok { background: var(--success); }
.rk-bar.is-warn { background: var(--warning); }
.rk-bar.is-short { background: var(--destructive); }
.rk-bar-label { font-size: .75rem; color: var(--muted-foreground); margin-top: .4rem; }

.rk-frei {
    display: flex; flex-wrap: wrap; align-items: baseline;
    justify-content: space-between; gap: .5rem 1rem;
    padding: .875rem 1rem;
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg);
    font-size: .8125rem; color: var(--muted-foreground);
}
.rk-frei strong { font-size: 1rem; font-variant-numeric: tabular-nums; }

.rk-form { display: flex; align-items: flex-end; gap: .75rem; flex-wrap: wrap; margin-top: 1.25rem; }
.rk-form .form-group { max-width: 16rem; }

.reserve-warn {
    display: flex; gap: .625rem; align-items: flex-start;
    margin-top: 1rem; padding: .75rem 1rem;
    border: 1px solid color-mix(in oklab, var(--warning) 30%, transparent);
    border-radius: var(--radius-lg);
    background: var(--warning-soft);
    font-size: .8125rem; line-height: 1.55;
}
.reserve-warn svg { width: 1rem; height: 1rem; margin-top: .125rem; color: var(--warning); }

@media (max-width: 768px) {
    .reserve-detail > td { padding: 0 0 .5rem; }
    .reserve-items { border: none; background: transparent; }
    .rk-form { flex-direction: column; align-items: stretch; }
    .rk-form .form-group { max-width: none; }
}

/* --- Anklickbare Kennzahl-Kacheln und Hinweise --- */
.is-clickable { cursor: pointer; }
.stat-card.is-clickable:hover {
    border-color: color-mix(in oklab, var(--primary) 45%, var(--border));
    box-shadow: var(--shadow-md);
}
.stat-card.is-clickable:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.stat-card.is-clickable::after {
    content: "";
    position: absolute; top: .75rem; right: .875rem;
    width: .5rem; height: .5rem;
    border-right: 1.5px solid var(--muted-foreground);
    border-top: 1.5px solid var(--muted-foreground);
    transform: rotate(45deg);
    opacity: 0; transition: opacity .15s;
}
.stat-card.is-clickable { position: relative; }
.stat-card.is-clickable:hover::after { opacity: 1; }

/* Monatsbalken sind Knöpfe */
button.reserve-month {
    border: none; background: transparent; padding: 0;
    font-family: inherit; cursor: pointer;
    border-radius: var(--radius-sm);
}
button.reserve-month:hover .reserve-bar-slot { outline: 1px solid var(--border); }
button.reserve-month:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

button.reserve-warn {
    width: 100%; text-align: left; font-family: inherit; cursor: pointer;
    color: inherit;
}
button.reserve-warn:hover { background: color-mix(in oklab, var(--warning) 22%, transparent); }

/* Kopfzeile im Detailfenster */
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.detail-head h2 { margin-bottom: .25rem; }
#detailInhalt table { margin-top: .5rem; }

.diff-gegen {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
    gap: 1rem; margin-bottom: 1.25rem;
}
.diff-gegen > div {
    display: flex; flex-direction: column; gap: .25rem;
    padding: .875rem 1rem; border: 1px solid var(--border); border-radius: var(--radius-lg);
}

/* ==========================================================================
   Sparpotenzial-Seite
   ========================================================================== */
.datengrundlage { margin-bottom: 1.5rem; }
.dg-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
    gap: 1rem;
}
.dg-item {
    padding: 1rem 1.125rem;
    border: 1px solid var(--border);
    border-left-width: 3px;
    border-radius: var(--radius-lg);
    background: var(--background);
}
.dg-item.is-ok { border-left-color: var(--success); }
.dg-item.is-warn { border-left-color: var(--warning); }
.dg-item.is-bad { border-left-color: var(--destructive); }
.dg-value {
    font-size: 1.5rem; font-weight: 600; letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}
.dg-label { font-size: .8125rem; color: var(--muted-foreground); margin-top: .25rem; line-height: 1.45; }
.dg-hint { font-size: .75rem; color: var(--warning); margin-top: .5rem; }
.dg-item .btn { margin-top: .75rem; }

.potenzial-box {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
    gap: 1rem; margin-bottom: 1.25rem;
    padding: 1rem 1.25rem;
    border: 1px solid color-mix(in oklab, var(--warning) 35%, transparent);
    border-radius: var(--radius-lg);
    background: var(--warning-soft);
}
.potenzial-value {
    font-size: 2rem; font-weight: 600; letter-spacing: -0.03em;
    color: var(--warning); font-variant-numeric: tabular-nums; line-height: 1.1;
}
.potenzial-label { font-size: .8125rem; color: var(--muted-foreground); margin-top: .25rem; }
.potenzial-jahr { font-size: .9375rem; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Balken mit Marke bei 100 % des Durchschnitts */
.ratio-bar {
    position: relative;
    height: .5rem;
    border-radius: 9999px;
    background: var(--muted);
    overflow: hidden;
    min-width: 6rem;
    margin-bottom: .25rem;
}
.ratio-fill { height: 100%; border-radius: 9999px; }
.ratio-fill.is-ok { background: var(--success); }
.ratio-fill.is-under { background: var(--primary); }
.ratio-fill.is-over { background: var(--destructive); }
.ratio-mark {
    position: absolute; top: 0; bottom: 0; left: 50%;
    width: 2px; background: var(--foreground); opacity: .35;
}

.quellen ul { list-style: none; margin: 0 0 .75rem; }
.quellen li { padding: .25rem 0; font-size: .875rem; }
.quellen li::before { content: "→"; color: var(--muted-foreground); margin-right: .5rem; }

/* Buchungstext vollständig anzeigen. Bankverwendungszwecke enthalten lange Ketten
   ohne Leerzeichen ("Saldo.221.573,49-Zinssatz"), deshalb muss auch innerhalb eines
   Worts umgebrochen werden — sonst ragt die Zelle aus der Tabelle. */
.txn-description {
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    max-width: 38rem;
    line-height: 1.45;
}

/* Filterleiste über der Buchungsliste */
.txn-filter {
    display: flex; flex-wrap: wrap; gap: 1.25rem;
    margin: .75rem 0 1rem;
}
.txn-filter-gruppe { display: inline-flex; align-items: center; gap: .375rem; flex-wrap: wrap; }
.txn-filter-label { font-size: .75rem; color: var(--muted-foreground); margin-right: .25rem; }

/* Rückfrage, wenn der gebuchte Betrag vom geplanten abweicht */
.betrag-frage {
    margin-top: .5rem;
    padding: .625rem .75rem;
    border: 1px solid color-mix(in oklab, var(--warning) 35%, transparent);
    border-radius: var(--radius-md);
    background: var(--warning-soft);
    font-size: .8125rem;
    line-height: 1.5;
}
.betrag-frage-knoepfe { display: flex; gap: .375rem; margin-top: .5rem; }
.betrag-frage.is-fertig { background: var(--success-soft); border-color: color-mix(in oklab, var(--success) 35%, transparent); }

/* Beschriftung einer erfolgten Zuordnung — gleiche Form wie in der Auswahlliste */
.zuordnung-text {
    display: inline-block;
    font-size: .75rem;
    color: var(--muted-foreground);
    line-height: 1.4;
}

/* Durchlaufende Zuordnung deutlich von echten Buchungen abheben */
.topf-zuordnung { color: var(--accent-teal); font-style: italic; }

/* Auswahl Ausgabe/Einnahme im Dialog "Neuer Budgetposten" */
.art-wahl { display: flex; gap: .5rem; }
.art-option {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .45rem .8rem; margin: 0;
    border: 1px solid var(--border); border-radius: var(--radius-md);
    cursor: pointer; font-size: .875rem; font-weight: 500;
    transition: border-color .15s, background-color .15s;
}
.art-option:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary);
}
.art-option input { width: auto; box-shadow: none; }

/* Buchungen, die soeben automatisch zugeordnet wurden */
.is-neu-zugeordnet { background: var(--success-soft) !important; }
.is-neu-zugeordnet td { border-bottom-color: color-mix(in oklab, var(--success) 30%, transparent); }
.neu-zugeordnet-hinweis {
    display: flex; gap: .625rem; align-items: flex-start;
    margin: .75rem 0 0; padding: .75rem 1rem;
    border: 1px solid color-mix(in oklab, var(--success) 30%, transparent);
    border-radius: var(--radius-lg);
    background: var(--success-soft);
    font-size: .8125rem; line-height: 1.5;
}
.neu-zugeordnet-hinweis svg { width: 1rem; height: 1rem; margin-top: .125rem; color: var(--success); }

/* Anklickbare Ringsegmente und Legendenzeilen */
.donut-seg.is-clickable { cursor: pointer; }
.legend-row.is-clickable { cursor: pointer; }
.legend-row.is-clickable:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

/* Auffällig hohe Einzelbuchung in der Buchungsliste eines Postens */
.ist-ausreisser { background: var(--warning-soft); }

/* Ziel-Auswahl in der Buchungsliste eines Postens */
.ziel-wahl {
    width: auto; min-width: 9rem; height: 2rem;
    font-size: .8125rem; padding: 0 1.75rem 0 .5rem;
    display: inline-block; margin-left: .375rem;
}

/* ==========================================================================
   Buchungsliste im Dialog — Blöcke statt Tabelle
   In einem schmalen Dialog quetscht eine Tabelle mit Aktionsspalte den langen
   Buchungstext auf wenige Zeichen Breite. Jede Buchung bekommt deshalb einen
   eigenen Block: Kopfzeile mit Datum und Betrag, darunter der Text, darunter
   die Bedienelemente.
   ========================================================================== */
.bu-liste { list-style: none; margin: 0; display: flex; flex-direction: column; gap: .5rem; }
.bu-eintrag {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: .75rem .875rem;
    background: var(--background);
}
.bu-eintrag.ist-ausreisser {
    background: var(--warning-soft);
    border-color: color-mix(in oklab, var(--warning) 35%, transparent);
}
.bu-eintrag.ist-erledigt { opacity: .5; }
.bu-kopf { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.bu-datum { font-size: .8125rem; color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
.bu-betrag { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.bu-text {
    font-size: .8125rem; line-height: 1.45;
    margin: .5rem 0 .75rem;
    color: var(--muted-foreground);
    overflow-wrap: anywhere;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.bu-aktionen { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.bu-aktionen .ziel-wahl { flex: 1 1 12rem; min-width: 12rem; max-width: 26rem; margin-left: 0; }

/* ==========================================================================
   Monatsstand — "wo stehe ich?"
   ========================================================================== */
.stand-kopf { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.stand-zahl { flex-shrink: 0; }
.stand-wert {
    font-size: 1.875rem; font-weight: 600; letter-spacing: -0.03em;
    color: var(--success); font-variant-numeric: tabular-nums; line-height: 1.1;
}
.stand-label { font-size: .8125rem; color: var(--muted-foreground); margin-top: .25rem; }
.stand-balken-bereich { flex: 1 1 18rem; min-width: 0; }
.stand-balken {
    height: .75rem; border-radius: 9999px;
    background: var(--muted); overflow: hidden;
}
.stand-balken-klein { height: .5rem; min-width: 5rem; margin-bottom: .25rem; }
.stand-fuellung {
    height: 100%; border-radius: 9999px; background: var(--success);
    transform-origin: left center;
    animation: bar-grow .6s cubic-bezier(.22,.61,.36,1) backwards;
}
.stand-fuellung.is-fertig { background: var(--primary); }
.stand-legende {
    display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
    font-size: .8125rem; color: var(--muted-foreground); margin-top: .5rem;
}
