:root {
    --bg-color: #07090e;
    --bg-card: #0f141f;
    --bg-hover: #172033;
    --text-primary: #f8fafc;
    --text-muted: #8493a8;
    --border-color: #1e293b;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #06b6d4;
    --card-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.6), 0 8px 10px -6px rgba(0, 0, 0, 0.6);
    --radius: 12px;
    --header-height: 72px;
}

[data-theme="light"] {
    --bg-color: #07090e;
    --bg-card: #0f141f;
    --bg-hover: #172033;
    --text-primary: #f8fafc;
    --text-muted: #8493a8;
    --border-color: #1e293b;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --card-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.6), 0 8px 10px -6px rgba(0, 0, 0, 0.6);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
    transition: background-color 0.2s ease, color 0.2s ease;
    min-height: 100vh;
}

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

.app-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 16px 28px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    white-space: nowrap;
}

.nav-links {
    display: flex;
    gap: 10px;
    align-items: center;
}

.nav-item {
    color: var(--text-muted);
    font-weight: 500;
    padding: 9px 16px;
    border-radius: 8px;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    background: transparent;
    border: none;
    font-size: 1.02rem;
    white-space: nowrap;
}
.nav-item:hover, .nav-item.active {
    color: var(--text-primary);
    background: var(--bg-hover);
    text-decoration: none;
}

/* Nav Dropdowns */
.nav-dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-toggle {
    user-select: none;
}

.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
    min-width: 240px;
    padding: 8px 0;
    z-index: 1000;
    animation: fadeIn 0.15s ease-out;
}

.dropdown-menu.dropdown-menu-left {
    right: auto;
    left: 0;
}

.nav-dropdown.active .dropdown-menu {
    display: block;
}

.dropdown-header {
    padding: 10px 18px 5px 18px;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    color: var(--text-muted);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    color: var(--text-primary);
    font-size: 0.96rem;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.12s ease;
}

.dropdown-item:hover {
    background: var(--bg-hover);
    text-decoration: none;
}

.dropdown-item.active {
    color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
    font-weight: 600;
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 8px 0;
}

/* ==========================================================================
   Layout Varianten (Boxed Fluid 45-80%, Boxed Classic 1350px, Boxed Compact 1100px, Full-Width)
   Das obere Menü (App-Header) bleibt dabei IMMER 100% Bildschirmbreite.
   ========================================================================== */

/* 1. Boxed Fluid (Standard): Dynamisch min. 45%, max. 80% der Fensterbreite */
[data-layout="boxed-fluid"] .container,
[data-layout="boxed-fluid"] .app-footer-inner,
[data-layout="boxed"] .container,
[data-layout="boxed"] .app-footer-inner {
    width: 80%;
    min-width: 45%;
    max-width: 80%;
    margin-left: auto;
    margin-right: auto;
}

/* 2. Boxed Classic (Ursprünglicher Default): Feste Maximalbreite 1350px, zentriert */
[data-layout="boxed-classic"] .container,
[data-layout="boxed-classic"] .app-footer-inner {
    width: 100%;
    max-width: 1350px;
    min-width: 0;
    margin-left: auto;
    margin-right: auto;
}

/* 3. Boxed Compact: Kompakte 1100px Maximalbreite, zentriert */
[data-layout="boxed-compact"] .container,
[data-layout="boxed-compact"] .app-footer-inner {
    width: 100%;
    max-width: 1100px;
    min-width: 0;
    margin-left: auto;
    margin-right: auto;
}

/* 4. Full-Width (Maximalbreite / 100%): Nutzt den vollen Bildschirm aus */
[data-layout="full"] .container,
[data-layout="full"] .app-footer-inner,
[data-layout="full-width"] .container,
[data-layout="full-width"] .app-footer-inner {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding-left: 28px;
    padding-right: 28px;
}

/* Fallback falls kein data-layout Attribut gesetzt ist (Standard ist Boxed Fluid) */
:root:not([data-layout]) .container,
:root:not([data-layout]) .app-footer-inner {
    width: 80%;
    min-width: 45%;
    max-width: 80%;
    margin-left: auto;
    margin-right: auto;
}

.container {
    margin-top: calc(var(--header-height) + 25px);
    margin-bottom: 25px;
    padding: 0 15px;
    transition: width 0.2s ease, max-width 0.2s ease, min-width 0.2s ease;
}

/* Cards & Components */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--card-shadow);
    padding: 24px;
    margin-bottom: 24px;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
}

.kpi-title {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.kpi-value {
    font-size: 1.75rem;
    font-weight: 800;
}
.kpi-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-info { color: var(--info); }
.text-muted { color: var(--text-muted); }

/* Outline Buttons (Modern & Minimalist) */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: 0.92rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.18s ease;
    text-decoration: none;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}
.btn:hover {
    text-decoration: none;
    transform: translateY(-1px);
}
.btn-primary {
    background: rgba(59, 130, 246, 0.12);
    color: #93c5fd;
    border: 1px solid #3b82f6;
}
.btn-primary:hover {
    background: #2563eb;
    color: #ffffff;
    border-color: #3b82f6;
}
.btn-primary.active,
.btn-primary:active {
    background: rgba(59, 130, 246, 0.28);
    color: #ffffff;
    border-color: #60a5fa;
    box-shadow: 0 0 0 1px #60a5fa;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.04);
    color: #f1f5f9;
    border: 1px solid #334155;
}
.btn-secondary:hover {
    background: #1e293b;
    border-color: #64748b;
    color: #ffffff;
}
.btn-secondary.active,
.btn-secondary:active,
.btn-secondary.expense-interval-btn.active {
    background: rgba(59, 130, 246, 0.22);
    color: #ffffff !important;
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 1px #3b82f6;
}

.btn-success {
    background: rgba(16, 185, 129, 0.12);
    color: #6ee7b7;
    border: 1px solid #10b981;
}
.btn-success:hover {
    background: #059669;
    color: #ffffff;
    border-color: #10b981;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.12);
    color: #fca5a5;
    border: 1px solid #ef4444;
}
.btn-danger:hover {
    background: #dc2626;
    color: #ffffff;
    border-color: #ef4444;
}

.btn-warning {
    background: rgba(245, 158, 11, 0.12);
    color: #fde047;
    border: 1px solid #f59e0b;
}
.btn-warning:hover {
    background: #d97706;
    color: #ffffff;
    border-color: #f59e0b;
}

.btn-info {
    background: rgba(6, 182, 212, 0.12);
    color: #67e8f9;
    border: 1px solid #06b6d4;
}
.btn-info:hover {
    background: #0891b2;
    color: #ffffff;
    border-color: #06b6d4;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.82rem;
    border-radius: 6px;
}

/* Forms & Inputs */
.form-group {
    margin-bottom: 18px;
}
.form-group label {
    display: block;
    margin-bottom: 7px;
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--text-primary);
}
.form-control {
    width: 100%;
    padding: 12px 16px;
    background: #090d16;
    border: 2px solid #475569;
    border-radius: 8px;
    color: #ffffff;
    font-size: 1rem;
    font-weight: 500;
    outline: none;
    transition: all 0.2s ease;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4);
}
.form-control::placeholder {
    color: #64748b;
    opacity: 0.8;
}
.form-control:hover {
    border-color: #64748b;
    background: #0c121e;
}
.form-control:focus {
    border-color: #38bdf8;
    background: #0f172a;
    box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.25), inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

[data-theme="light"] .form-control {
    background: #ffffff;
    border: 2px solid #cbd5e1;
    color: #0f172a;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.06);
}
[data-theme="light"] .form-control:hover {
    border-color: #94a3b8;
}
[data-theme="light"] .form-control:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
}

/* Tables */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 6px;
}
th, td {
    padding: 10px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}
th {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    font-weight: 600;
    white-space: nowrap;
}
tbody tr:hover {
    background: var(--bg-hover);
}

/* 2x1 Button Grid für Tabellen-Aktionen: Oben Hinzufügen / Editieren, Unten Löschen */
.btn-grid-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    width: 140px;
    margin-left: auto;
}
.btn-grid-actions .btn {
    width: 100%;
    height: 27px;
    padding: 0 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
}
.btn-grid-actions .btn-delete-full {
    grid-column: span 2;
}

/* Progress Bar */
.progress-container {
    background: var(--bg-hover);
    border-radius: 10px;
    overflow: hidden;
    height: 12px;
    width: 100%;
    margin: 8px 0;
}
.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--success));
    border-radius: 10px;
    transition: width 0.4s ease;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 8px;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 6px;
}
.badge-monthly { background: rgba(59, 130, 246, 0.2); color: #93c5fd; }
.badge-quarterly { background: rgba(139, 92, 246, 0.2); color: #c4b5fd; }
.badge-semi_annual { background: rgba(245, 158, 11, 0.2); color: #fde047; }
.badge-annual { background: rgba(236, 72, 153, 0.2); color: #f472b6; }

/* Badges inside buttons maintain crisp readability */
.btn .badge {
    vertical-align: middle;
}
.btn.active .badge-monthly,
.btn.active .badge-quarterly,
.btn.active .badge-semi_annual,
.btn.active .badge-annual,
.btn:hover .badge-monthly,
.btn:hover .badge-quarterly,
.btn:hover .badge-semi_annual,
.btn:hover .badge-annual {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

/* Alerts */
.alert {
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.95rem;
}
.alert-success { background: #10b98122; color: #34d399; border: 1px solid #10b98144; }
.alert-danger { background: #ef444422; color: #f87171; border: 1px solid #ef444444; }
.alert-info { background: #06b6d422; color: #38bdf8; border: 1px solid #06b6d444; }

/* Modal */
.modal-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-backdrop.active {
    display: flex;
}
.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
    width: 100%;
    max-width: 520px;
    box-shadow: var(--card-shadow);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}
.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
}

/* Utilities */
.d-flex { display: flex; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.text-right { text-align: right; }
.p-3 { padding: 16px; }
.p-4 { padding: 24px; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Mobile Hamburger Button */
.mobile-menu-toggle {
    display: none;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 10px;
    cursor: pointer;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    transition: all 0.2s ease;
}

.mobile-menu-toggle:hover {
    background: var(--bg-hover);
}

.hamburger-bar {
    display: block;
    width: 22px;
    height: 2px;
    background-color: var(--text-primary);
    border-radius: 2px;
    transition: all 0.2s ease;
}

.mobile-menu-toggle.active .hamburger-bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}
.mobile-menu-toggle.active .hamburger-bar:nth-child(2) {
    opacity: 0;
}
.mobile-menu-toggle.active .hamburger-bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* Mobile Header Action Group & Bottom Navigation (PWA) */
.header-actions-mobile {
    display: none;
    align-items: center;
    gap: 8px;
}

.mobile-icon-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 1.05rem;
    color: var(--text-primary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
    text-decoration: none;
}
.mobile-icon-btn:hover {
    background: var(--bg-hover);
    text-decoration: none;
}

.badge-unread-dot {
    position: absolute;
    top: -3px;
    right: -3px;
    width: 10px;
    height: 10px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid var(--bg-card);
}

.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 62px;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    z-index: 990;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.25);
    padding: 0 4px;
    justify-content: space-around;
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    height: 100%;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.72rem;
    font-weight: 500;
    gap: 3px;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}
.bottom-nav-item:hover, .bottom-nav-item.active {
    color: var(--primary);
    text-decoration: none;
}
.bottom-nav-item.active .bottom-nav-icon {
    transform: scale(1.15);
}
.bottom-nav-icon {
    font-size: 1.25rem;
    line-height: 1;
    transition: transform 0.15s ease;
}

/* ==========================================================================
   Responsive Breakpoints & Mobile Optimization
   ========================================================================== */

/* Global horizontal overflow prevention */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

/* 1. TABLET & INTERMEDIATE DESKTOP (<= 1024px) */
@media (max-width: 1024px) {
    .nav-item {
        padding: 8px 11px;
        font-size: 0.92rem;
    }
    .kpi-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 12px;
    }
    .dash-split-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

/* 2. MOBILE & SMALL TABLET (<= 860px) */
@media (max-width: 860px) {
    body {
        padding-bottom: 74px; /* Platz für PWA Bottom Navigation */
    }

    .mobile-bottom-nav {
        display: flex;
    }

    .header-actions-mobile {
        display: flex;
    }

    .mobile-menu-toggle {
        display: flex;
    }

    .app-header {
        padding: 10px 14px;
    }

    .brand-logo {
        font-size: 1.15rem;
    }

    .header-inner {
        position: relative;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .nav-links {
        display: none;
        position: absolute;
        top: calc(100% + 10px);
        left: -14px;
        right: -14px;
        background: var(--bg-card);
        border-bottom: 1px solid var(--border-color);
        box-shadow: 0 15px 30px rgba(0, 0, 0, 0.5);
        flex-direction: column;
        align-items: stretch;
        padding: 14px;
        gap: 6px;
        z-index: 999;
        max-height: calc(100vh - 80px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        animation: fadeIn 0.15s ease-out;
    }

    .nav-links.mobile-open {
        display: flex;
    }

    .nav-item {
        width: 100%;
        justify-content: flex-start;
        padding: 11px 14px;
        font-size: 0.98rem;
        border-radius: 8px;
    }

    .nav-dropdown {
        width: 100%;
    }

    .nav-dropdown .dropdown-toggle {
        width: 100%;
        justify-content: space-between;
    }

    .nav-dropdown .dropdown-menu {
        position: static;
        width: 100%;
        box-shadow: none;
        border: 1px solid var(--border-color);
        margin-top: 4px;
        margin-bottom: 6px;
        background: var(--bg-hover);
        border-radius: 8px;
    }

    /* Container Breiten auf Mobile erzwingen */
    [data-layout^="boxed"] .container,
    [data-layout^="boxed"] .app-footer-inner,
    [data-layout="boxed"] .container,
    [data-layout="boxed"] .app-footer-inner,
    .container {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        padding-left: 12px !important;
        padding-right: 12px !important;
        margin-top: calc(56px + 12px);
        margin-bottom: 18px;
    }

    .card {
        padding: 14px;
        margin-bottom: 14px;
        border-radius: 10px;
    }

    .kpi-grid {
        grid-template-columns: 1fr;
        gap: 10px;
        margin-bottom: 14px;
    }

    .kpi-card {
        padding: 12px 14px;
    }

    .kpi-value {
        font-size: 1.4rem;
    }

    /* Responsive Helper Grids */
    .grid-2-1,
    .grid-3-col,
    .dash-split-grid,
    .dash-preview-grid,
    #savingsGrid,
    #loansGrid,
    #installmentsGrid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    /* Tab Switcher & Filter Scrollbars dezent & touch-freundlich */
    .filter-tab-bar,
    div[style*="overflow-x: auto"] {
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        white-space: nowrap;
    }

    /* Modals auf Mobile */
    .modal-content {
        width: 96% !important;
        max-width: 96% !important;
        margin: 10px auto;
        padding: 16px 14px;
        max-height: 92vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 12px;
    }

    .modal-header {
        margin-bottom: 14px;
    }

    /* Formulare: 2-spaltige Grids in Modals brechen um */
    .form-grid-2,
    [style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    /* iOS Auto-Zoom auf Formulareingaben verhindern: min 16px font-size */
    .form-control, input, select, textarea {
        font-size: 16px !important;
    }

    /* Formularfelder in Filterleisten vollflächig */
    form.d-flex.align-center.gap-3.flex-wrap > div {
        width: 100% !important;
    }
    form.d-flex.align-center.gap-3.flex-wrap input,
    form.d-flex.align-center.gap-3.flex-wrap select {
        width: 100% !important;
        flex: 1;
    }

    /* Tabellen Scrollbar & Touch-Scroll */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
        overflow-x: auto;
        margin-left: -2px;
        margin-right: -2px;
        border-radius: 8px;
    }

    table th, table td {
        padding: 8px 8px;
        font-size: 0.84rem;
        white-space: normal;
    }

    /* Filterleisten umbrechen */
    .filter-tab-btn {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    /* Footer Margin für Bottom-Nav */
    footer {
        margin-bottom: 16px;
    }
}

/* 3. MOBIL-KACHELN STATT ÜBERBREITER TABELLEN (<= 640px, z.B. iPhone 16 Pro, Galaxy) */
@media (max-width: 640px) {
    /* Tabellencontainer komplett von starren Tabellen-Eigenschaften befreien */
    .table-responsive {
        overflow-x: visible !important;
        margin: 0 !important;
    }

    table.expense-table,
    table.daily-expense-table,
    table.incomes-table {
        display: block !important;
        width: 100% !important;
        border: none !important;
    }

    table.expense-table thead,
    table.daily-expense-table thead,
    table.incomes-table thead {
        display: none !important; /* Tabellenkopf auf Mobilgeräten ausblenden */
    }

    table.expense-table tbody,
    table.daily-expense-table tbody,
    table.incomes-table tbody {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
        width: 100% !important;
    }

    /* Jede Tabellenzeile wird zu einer schicken Kachel */
    table.expense-table tr,
    table.daily-expense-table tr,
    table.incomes-table tr {
        display: flex !important;
        flex-direction: column !important;
        background: var(--bg-hover) !important;
        border: 1px solid var(--border-color) !important;
        border-radius: 10px !important;
        padding: 12px 14px !important;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15) !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Spezielles Styling für Unter-Fixkosten Zeilen als Kachel */
    table.expense-table tr.child-expense-row {
        background: rgba(59, 130, 246, 0.05) !important;
        border-left: 3px solid var(--primary) !important;
        margin-top: -6px !important;
        padding-left: 14px !important;
    }

    /* Alle Tabellenzellen innerhalb der Kachel flüssig anordnen */
    table.expense-table td,
    table.daily-expense-table td,
    table.incomes-table td {
        display: block !important;
        width: 100% !important;
        padding: 4px 0 !important;
        border: none !important;
        box-sizing: border-box !important;
    }

    /* Status-Button oben in der Fixkosten-Kachel */
    table.expense-table tr td:first-child {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        border-bottom: 1px dashed var(--border-color) !important;
        padding-bottom: 8px !important;
        margin-bottom: 6px !important;
    }

    /* Aktionsbuttons am Kachel-Ende über die volle Breite */
    table.expense-table td.text-right,
    table.daily-expense-table td.text-right,
    table.incomes-table td.text-right {
        border-top: 1px solid var(--border-color) !important;
        padding-top: 10px !important;
        margin-top: 8px !important;
        display: flex !important;
        justify-content: flex-end !important;
    }

    table.expense-table .btn-grid-actions {
        width: 100% !important;
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 6px !important;
    }
    table.expense-table .btn-grid-actions .btn {
        height: 32px !important;
        font-size: 0.82rem !important;
    }

    table.daily-expense-table td.text-right > div,
    table.incomes-table td.text-right > div {
        width: 100% !important;
        display: flex !important;
        justify-content: flex-end !important;
        gap: 8px !important;
    }
    table.daily-expense-table td.text-right .btn,
    table.incomes-table td.text-right .btn {
        padding: 6px 12px !important;
        font-size: 0.85rem !important;
    }
}

/* 4. KLEINE SMARTPHONES (<= 480px) */
@media (max-width: 480px) {
    .app-header {
        padding: 8px 10px;
    }

    .brand-logo {
        font-size: 1.05rem;
        gap: 6px;
    }

    .card {
        padding: 12px;
        margin-bottom: 12px;
    }

    .kpi-value {
        font-size: 1.25rem;
    }

    .kpi-title {
        font-size: 0.76rem;
    }

    .kpi-sub {
        font-size: 0.74rem;
    }

    .btn {
        padding: 8px 11px;
        font-size: 0.86rem;
    }

    .btn-sm {
        padding: 5px 8px;
        font-size: 0.78rem;
    }

    /* Tab-Buttons im Dashboard */
    .dash-tab-btn {
        padding: 6px 9px !important;
        font-size: 0.78rem !important;
    }
}

