:root {
    /* Light Mode Default (FinTech Base) */
    --bg-main: #F4F7F6;
    --bg-card: #FFFFFF;
    --bg-card-hover: #F8FAFC;
    --text-main: #0F172A;
    --text-muted: #64748B;
    --primary: #10B981; /* Emerald */
    --primary-hover: #059669;
    --positive: #10B981;
    --negative: #EF4444;
    --border: #E2E8F0;
    --glass-blur: blur(20px);
    --radius-lg: 24px;
    --radius-md: 16px;
    --card-shadow: 0 8px 30px rgba(0,0,0,0.04);
    --select-arrow: url("data:image/svg+xml;utf8,<svg fill='%230F172A' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/><path d='M0 0h24v24H0z' fill='none'/></svg>");
}

[data-theme="dark"] {
    --bg-main: #0F172A;
    --bg-card: #1E293B;
    --bg-card-hover: #334155;
    --text-main: #F8FAFC;
    --text-muted: #94A3B8;
    --border: rgba(255, 255, 255, 0.1);
    --card-shadow: 0 8px 30px rgba(0,0,0,0.2);
    --select-arrow: url("data:image/svg+xml;utf8,<svg fill='white' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/><path d='M0 0h24v24H0z' fill='none'/></svg>");
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg-main: #0F172A;
        --bg-card: #1E293B;
        --bg-card-hover: #334155;
        --text-main: #F8FAFC;
        --text-muted: #94A3B8;
        --border: rgba(255, 255, 255, 0.1);
        --card-shadow: 0 8px 30px rgba(0,0,0,0.2);
        --select-arrow: url("data:image/svg+xml;utf8,<svg fill='white' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/><path d='M0 0h24v24H0z' fill='none'/></svg>");
    }
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    padding-bottom: 90px; /* Space for FAB */
    transition: background-color 0.3s ease, color 0.3s ease;
    -webkit-text-size-adjust: 100%; /* iOS skaliert Text nicht eigenmächtig */
}

/* --- Touch-Optimierung (Smartphone) --- */
button, .nav-item, .dashboard-group-item, .receipt-mini, .btn-member-avatar, .avatar, .split-type-btn {
    -webkit-tap-highlight-color: transparent; /* kein grauer Flash beim Tippen */
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation; /* kein 300ms-Verzögern, kein Doppeltipp-Zoom auf Buttons */
}

/* Spürbares Tipp-Feedback (Hover gibt's auf dem Handy nicht) */
.btn:active, .btn-action:active, .split-type-btn:active, .btn-settle:active,
.btn-small-action:active, .nav-item:active, .dashboard-group-item:active,
.modal-close:active, .avatar:active, .btn-member-avatar:active, .receipt-mini:active {
    transform: scale(0.95);
    opacity: 0.85;
}

.fab:active {
    transform: scale(0.92);
}

header {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    /* Safe-Area: nicht unter die Statusleiste/Notch im installierten PWA-Modus rutschen */
    padding: calc(1rem + env(safe-area-inset-top)) 1.5rem 1rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

h1 {
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(to right, #818CF8, #C084FC);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

main {
    padding: 1.5rem;
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-main);
}

h3 {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
    color: var(--text-muted);
}

.card {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: background 0.3s ease, box-shadow 0.3s ease;
    box-shadow: var(--card-shadow);
}

.card:hover {
    background: var(--bg-card-hover);
}

.form-group {
    margin-bottom: 1.25rem;
}

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

input, select {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.2s ease;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.btn {
    display: inline-block;
    width: 100%;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}

.btn-outline:hover {
    background: rgba(99, 102, 241, 0.1);
}

.btn-danger {
    background: var(--negative);
    color: white;
}

.btn-danger:hover {
    background: #DC2626;
    transform: translateY(-1px);
}

/* Live-Vorschau der Aufteilung */
.split-summary {
    margin-bottom: 1rem;
}

.split-summary:empty {
    display: none;
}

.split-summary-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.8125rem;
    color: var(--text-muted);
    padding: 0.2rem 0;
}

.split-summary-row span:last-child {
    font-weight: 600;
    color: var(--text-main);
}

.split-summary-status {
    margin-top: 0.4rem;
    padding-top: 0.4rem;
    border-top: 1px dashed var(--border);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--positive);
}

.split-summary.warn .split-summary-status {
    color: #FBBF24;
}

.expense-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 0.25rem;
    border-bottom: 1px solid var(--border);
    gap: 0.75rem;
}

.expense-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.expense-icon {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    line-height: 1;
}

.expense-icon-settle {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.25);
}

.expense-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.expense-desc {
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.expense-meta {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
}

.expense-meta-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.expense-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.45rem;
    flex-shrink: 0;
}

.expense-amount {
    font-weight: 700;
    font-size: 1.0625rem;
    color: var(--text-main);
    text-align: right;
    white-space: nowrap;
}

.expense-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* Wisch-Gesten: links = löschen (rot), rechts = bearbeiten (blau) */
.swipe-row {
    position: relative;
    overflow: hidden;
}

.swipe-bg {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    padding: 0 1.4rem;
    background: transparent;
}

.swipe-bg-delete {
    background: var(--negative);
    justify-content: flex-end;
}

.swipe-bg-edit {
    background: #3B82F6;
    justify-content: flex-start;
}

.swipe-icon {
    font-size: 1.4rem;
    transition: transform 0.12s ease;
}

.swipe-bg.pass .swipe-icon {
    transform: scale(1.4);
}

.swipe-fg {
    position: relative;
    background: var(--bg-card);
    will-change: transform;
    touch-action: pan-y;
}

.btn-action {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 1rem;
    padding: 0.35rem;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.btn-action-edit {
    color: #818CF8;
}

.btn-action-edit:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.3);
    transform: translateY(-1px);
}

.btn-action-delete {
    color: var(--negative);
}

.btn-action-delete:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    transform: translateY(-1px);
}

.balance-item, .debt-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

/* Namensbereich darf schrumpfen, damit der Betrag nie überlappt. */
.balance-item .name-with-avatar {
    flex: 1;
    min-width: 0;
}

.balance-item:last-child, .debt-item:last-child {
    border-bottom: none;
}

/* „Wer zahlt an wen": Zahler oben, Pfeil, Empfänger unten (gestapelt) */
.debt-flow {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    flex: 1;
    min-width: 0;
}

.debt-flow .name-with-avatar {
    min-width: 0;
}

.debt-flow .name-with-avatar strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.debt-arrow {
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1;
    padding-left: 7px; /* unter den Avatar einrücken */
}

.debt-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
    flex-shrink: 0;
    white-space: nowrap;
}

.btn-settle {
    background: rgba(16, 185, 129, 0.12);
    color: var(--positive);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    font-weight: 600;
    padding: 0.55rem 0.8rem;
    min-height: 40px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    white-space: nowrap;
}

.btn-settle:hover {
    background: rgba(16, 185, 129, 0.22);
    transform: translateY(-1px);
}

.settlement-item {
    background: rgba(16, 185, 129, 0.04);
    border-radius: var(--radius-md);
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.split-member-toggle {
    padding: 0.35rem 0;
}

.balance-positive {
    color: var(--positive);
    font-weight: 600;
}

.balance-negative {
    color: var(--negative);
    font-weight: 600;
}

.balance-neutral {
    color: var(--text-muted);
}

/* Modal styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    /* Falls der Dialog doch höher als der Bildschirm ist, kann das Overlay scrollen. */
    overflow-y: auto;
    padding: 1rem;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Hintergrund (Haupt-App) sperren, solange ein Modal offen ist. */
body:has(.modal-overlay.active) {
    overflow: hidden;
}

.modal-content {
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    width: 100%;
    max-width: 400px;
    /* Höhe auf den sichtbaren Bereich begrenzen und INNEN scrollen lassen. */
    max-height: calc(100vh - 2rem);
    max-height: calc(100dvh - 2rem);
    overflow-y: auto;
    overscroll-behavior: contain; /* Touch-Scroll bleibt im Dialog (kein Durchrutschen) */
    -webkit-overflow-scrolling: touch; /* sanftes Momentum-Scrollen auf iOS */
    transform: translateY(20px);
    transition: transform 0.3s ease;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    margin: auto;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

/* Primär-Aktion im (scrollbaren) Ausgaben-Dialog immer sichtbar am unteren Rand anheften. */
#btn-submit-expense {
    position: sticky;
    bottom: 0;
    margin-top: 0.75rem;
    box-shadow: 0 -8px 14px 6px var(--bg-main);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    /* Komfortable Tipp-Fläche */
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: -0.5rem -0.5rem -0.5rem 0; /* optischer Ausgleich, ohne Layout zu sprengen */
    flex-shrink: 0;
}

.split-type-selector {
    display: flex;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.25rem;
    margin-bottom: 1rem;
}

.split-type-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.7rem 0.5rem;
    min-height: 44px;
    border-radius: calc(var(--radius-md) - 2px);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.split-type-btn.active {
    background: var(--bg-card);
    color: var(--text-main);
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.split-members-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.split-member-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.split-member-name {
    flex: 1;
    font-size: 0.875rem;
}

.split-member-input {
    width: 100px;
    padding: 0.5rem;
    text-align: right;
}

.fab {
    position: fixed;
    bottom: calc(32px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    width: 64px;
    height: 64px;
    border-radius: 32px;
    background: var(--primary);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.4);
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 1000;
    border: 4px solid var(--bg-main);
}

.fab:hover {
    transform: translateX(-50%) scale(1.08);
}

#group-selector-select {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-main);
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    width: auto;
    appearance: none;
    -webkit-appearance: none;
    background-image: var(--select-arrow);
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 1.25rem;
    outline: none;
    transition: all 0.2s ease;
}

#group-selector-select:hover {
    background: var(--bg-card-hover);
    border-color: var(--primary);
}

#group-selector-select option {
    background: var(--bg-main);
    color: var(--text-main);
    padding: 0.5rem;
}

/* --- Tab Views & Bottom Navigation --- */
.view-content {
    display: none;
}

.view-content.active {
    display: block;
}



.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 999;
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
    background: transparent;
    border: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    height: 100%;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    gap: 0.2rem;
    outline: none;
}

.nav-item.active {
    color: var(--primary);
}

.nav-item.active .nav-icon {
    transform: translateY(-2px);
    filter: drop-shadow(0 2px 8px rgba(99, 102, 241, 0.4));
}

.nav-icon {
    transition: transform 0.2s ease;
}

/* --- Kleine Nutzer-Avatare (überall in Listen) --- */
.user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #fff;
    font-weight: 700;
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
    line-height: 1;
    vertical-align: middle;
}

.name-with-avatar {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.btn-member-avatar {
    background: none;
    border: none;
    padding: 0;
    width: auto;
    cursor: pointer;
    display: inline-flex;
    border-radius: 50%;
    transition: transform 0.15s ease;
}

.btn-member-avatar:hover {
    transform: scale(1.08);
}

/* --- Profilbild / Avatar (Hauptnutzer, Dashboard) --- */
.avatar {
    position: relative;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.1);
    background-size: cover;
    background-position: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.avatar:hover {
    transform: scale(1.05);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.3);
}

.avatar.has-image .avatar-placeholder {
    display: none;
}

.avatar-badge {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid var(--bg-main);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    pointer-events: none;
}

.avatar-remove {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--negative);
    color: white;
    border: 2px solid var(--bg-main);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0;
}

/* Unsichtbare, größere Tipp-Fläche fürs kleine ×-Symbol */
.avatar-remove::after {
    content: '';
    position: absolute;
    inset: -10px;
}

/* Bei gesetztem Bild: Entfernen-Knopf statt Kamera-Badge zeigen */
.avatar.has-image .avatar-badge {
    display: none;
}

.avatar.has-image .avatar-remove {
    display: flex;
}

/* --- Premium Dashboard Styles --- */
.dashboard-card {
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--border) 200%);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.dashboard-card.glow-green {
    box-shadow: 0 8px 32px rgba(16, 185, 129, 0.15), inset 0 0 0 1px rgba(16, 185, 129, 0.2);
    border-color: rgba(16, 185, 129, 0.25);
}

.dashboard-card.glow-red {
    box-shadow: 0 8px 32px rgba(239, 68, 68, 0.15), inset 0 0 0 1px rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.25);
}

.dashboard-card.glow-neutral {
    box-shadow: 0 8px 32px rgba(255, 255, 255, 0.05);
}

/* --- Member Badges --- */
.member-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    padding: 0.25rem 0.6rem 0.25rem 0.3rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-main);
    transition: all 0.2s ease;
}

.member-badge:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

/* --- Dashboard Elements --- */
.dashboard-group-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.875rem 1rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.dashboard-group-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--primary);
    transform: translateX(3px);
}

.dashboard-detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 0.5rem;
    border-bottom: 1px solid var(--border);
}

.dashboard-detail-item:last-child {
    border-bottom: none;
}

.dashboard-detail-left {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.dashboard-detail-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Action Buttons inside lists */
.btn-share-actions {
    display: flex;
    gap: 0.35rem;
}

.btn-small-action {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 0.8125rem;
    padding: 0.5rem 0.7rem;
    min-height: 38px;
    border-radius: 8px;
    transition: all 0.2s ease;
    color: var(--text-main);
}

.btn-small-action:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--primary);
}

/* Modal Member Row */
.manage-member-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: 8px;
}

/* --- Beleg / Quittung --- */
#receipt-preview {
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.receipt-thumb {
    width: 90px;
    height: 90px;
    object-fit: cover;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    cursor: pointer;
}

.receipt-mini {
    width: 34px;
    height: 34px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border);
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.15s ease;
}

.receipt-mini:hover {
    transform: scale(1.08);
    border-color: var(--primary);
}

/* Lightbox (Beleg vergrößern) */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    overflow: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.lightbox-overlay.active {
    display: flex;
}

.lightbox-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--radius-md);
    cursor: zoom-in;
}

.lightbox-img.zoomed {
    max-width: none;
    max-height: none;
    width: auto;
    cursor: zoom-out;
}

.lightbox-close {
    position: fixed;
    top: 1rem;
    right: 1rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border: none;
    font-size: 1.75rem;
    line-height: 1;
    cursor: pointer;
    z-index: 2010;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- Statistik --- */
.stat-row {
    margin-bottom: 0.9rem;
}

.stat-row-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    margin-bottom: 0.4rem;
    gap: 0.5rem;
}

.stat-row-head span:last-child {
    color: var(--text-muted);
    white-space: nowrap;
}

.stat-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin-right: 0.4rem;
    vertical-align: middle;
}

.stat-row-head strong {
    color: var(--text-main);
}

.stat-bar {
    height: 9px;
    border-radius: 5px;
    background: rgba(148, 163, 184, 0.18);
    overflow: hidden;
}

.stat-bar-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 0.4s ease;
    min-width: 4px;
}

/* Monatstrend (Säulen) */
.trend-bars {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 0.5rem;
    height: 110px;
}

.trend-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
}

.trend-bar-track {
    width: 70%;
    max-width: 34px;
    flex: 1;
    display: flex;
    align-items: flex-end;
    background: rgba(148, 163, 184, 0.12);
    border-radius: 6px;
    overflow: hidden;
}

.trend-bar-fill {
    width: 100%;
    background: rgba(148, 163, 184, 0.5);
    border-radius: 6px;
    transition: height 0.4s ease;
}

.trend-bar-fill.current {
    background: var(--primary);
}

.trend-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
}

.trend-label.current {
    color: var(--text-main);
    font-weight: 700;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}


.btn-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}
.btn-close:hover {
    color: var(--text);
}
