/* ==========================================
   AUSGABEN-TRACKER — Apple Liquid Glass Design
   ========================================== */

/* ==========================================
   DESIGN TOKENS (CSS-Variablen)
   ========================================== */

:root {
    /* Apple System-Farben */
    --system-blue: #007aff;
    --system-green: #34c759;
    --system-red: #ff3b30;
    --system-orange: #ff9f0a;
    --system-yellow: #ffd60a;
    --system-purple: #af52de;
    --system-pink: #ff2d55;
    --system-gray: #8e8e93;

    /* Semantische Farben — Light Mode */
    --bg-primary: #f2f2f7;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f2f2f7;
    --bg-grouped: #f2f2f7;
    --text-primary: #1c1c1e;
    --text-secondary: #3a3a3c;
    --text-tertiary: #8e8e93;
    --separator: rgba(60, 60, 67, 0.12);
    --fill: rgba(120, 120, 128, 0.2);

    /* Glass-Effekte */
    --glass-bg: rgba(255, 255, 255, 0.72);
    --glass-bg-heavy: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.3);

    /* Schatten */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 2px 10px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.08);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.1);

    /* Spacing (4px Grid) */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;
    --space-16: 64px;

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 999px;

    /* Animationen */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-out: cubic-bezier(0, 0, 0.2, 1);
    --ease-bounce: cubic-bezier(0.175, 0.885, 0.32, 1.275);
    --duration-fast: 150ms;
    --duration: 300ms;
    --duration-slow: 400ms;

    /* Layout */
    --container-width: 960px;
    --nav-height: 56px;
}

/* ==========================================
   DARK MODE
   ========================================== */

@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #000000;
        --bg-secondary: #1c1c1e;
        --bg-tertiary: #2c2c2e;
        --bg-grouped: #000000;
        --text-primary: #ffffff;
        --text-secondary: #ebebf5;
        --text-tertiary: #8e8e93;
        --separator: rgba(84, 84, 88, 0.36);
        --fill: rgba(120, 120, 128, 0.36);

        --glass-bg: rgba(30, 30, 30, 0.72);
        --glass-bg-heavy: rgba(30, 30, 30, 0.88);
        --glass-border: rgba(255, 255, 255, 0.08);

        --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
        --shadow-md: 0 2px 10px rgba(0, 0, 0, 0.3);
        --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.4);
        --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.5);

        /* Leicht angepasste System-Farben fuer Dark Mode */
        --system-blue: #0a84ff;
        --system-green: #32d74b;
        --system-red: #ff453a;
        --system-orange: #ff9f0a;
    }
}

/* ==========================================
   DARK/LIGHT MODE TOGGLE (ueberschreibt Media Query)
   ========================================== */

/* Manuell: Light Mode erzwingen */
html.light-mode {
    --bg-primary: #f2f2f7;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f2f2f7;
    --bg-grouped: #f2f2f7;
    --text-primary: #1c1c1e;
    --text-secondary: #3a3a3c;
    --text-tertiary: #8e8e93;
    --separator: rgba(60, 60, 67, 0.12);
    --fill: rgba(120, 120, 128, 0.2);
    --glass-bg: rgba(255, 255, 255, 0.72);
    --glass-bg-heavy: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.3);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 2px 10px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.08);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.1);
    --system-blue: #007aff;
    --system-green: #34c759;
    --system-red: #ff3b30;
    --system-orange: #ff9f0a;
}

/* Manuell: Dark Mode erzwingen */
html.dark-mode {
    --bg-primary: #000000;
    --bg-secondary: #1c1c1e;
    --bg-tertiary: #2c2c2e;
    --bg-grouped: #000000;
    --text-primary: #ffffff;
    --text-secondary: #ebebf5;
    --text-tertiary: #8e8e93;
    --separator: rgba(84, 84, 88, 0.36);
    --fill: rgba(120, 120, 128, 0.36);
    --glass-bg: rgba(30, 30, 30, 0.72);
    --glass-bg-heavy: rgba(30, 30, 30, 0.88);
    --glass-border: rgba(255, 255, 255, 0.08);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 2px 10px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.5);
    --system-blue: #0a84ff;
    --system-green: #32d74b;
    --system-red: #ff453a;
    --system-orange: #ff9f0a;
}

/* ==========================================
   RESET & BASIS
   ========================================== */

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

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

body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 17px;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==========================================
   TYPOGRAFIE
   ========================================== */

h1 {
    font-size: 34px;
    font-weight: 700;
    letter-spacing: -0.4px;
    line-height: 1.2;
    color: var(--text-primary);
}

h2 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.2px;
    line-height: 1.3;
    color: var(--text-primary);
}

h3 {
    font-size: 20px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}

/* ==========================================
   NAVIGATION (Frosted Glass)
   ========================================== */

.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--nav-height);
    background: var(--glass-bg-heavy);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--separator);
}

.nav-container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 var(--space-6);
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-logo {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: -0.3px;
    transition: opacity var(--duration-fast) var(--ease);
}

.nav-logo:hover {
    opacity: 0.7;
    text-decoration: none;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: var(--space-2);
    align-items: center;
}

.nav-link {
    color: var(--system-blue);
    text-decoration: none;
    font-size: 17px;
    font-weight: 400;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    transition: background var(--duration-fast) var(--ease), opacity var(--duration-fast) var(--ease);
}

.nav-link:hover {
    background: var(--fill);
    text-decoration: none;
    opacity: 0.85;
}

.nav-user {
    color: var(--text-secondary);
    font-size: 15px;
    padding: 0 var(--space-2);
}

.nav-logout {
    color: var(--system-red);
    font-weight: 500;
}

.nav-logout:hover {
    background: rgba(255, 59, 48, 0.1);
}

.nav-register {
    background: var(--system-blue);
    color: #ffffff;
    font-weight: 600;
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-full);
}

.nav-register:hover {
    background: var(--system-blue);
    opacity: 0.85;
    color: #ffffff;
}

/* ==========================================
   HAUPTINHALTSBEREICH
   ========================================== */

.container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 var(--space-6);
    flex: 1;
}

main.container {
    padding-top: var(--space-8);
    padding-bottom: var(--space-16);
}

/* ==========================================
   FLASH-NACHRICHTEN (Toast-Style)
   ========================================== */

.flash-container {
    padding-top: var(--space-4);
}

.flash {
    padding: var(--space-3) var(--space-4);
    margin-bottom: var(--space-3);
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: opacity var(--duration) var(--ease), transform var(--duration) var(--ease);
}

.flash-success {
    background: rgba(52, 199, 89, 0.12);
    color: var(--system-green);
    border: 1px solid rgba(52, 199, 89, 0.2);
}

.flash-error {
    background: rgba(255, 59, 48, 0.12);
    color: var(--system-red);
    border: 1px solid rgba(255, 59, 48, 0.2);
}

.flash-info {
    background: rgba(0, 122, 255, 0.12);
    color: var(--system-blue);
    border: 1px solid rgba(0, 122, 255, 0.2);
}

/* Fade-Out-Klasse fuer auto-dismiss */
.flash.fade-out {
    opacity: 0;
    transform: translateY(-8px);
}

/* ==========================================
   KARTEN (Cards)
   ========================================== */

.card {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    box-shadow: var(--shadow-md);
    margin-bottom: var(--space-6);
    border: 1px solid var(--separator);
    transition: transform var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

/* Hover-Effekt nur auf Desktop (kein Touch) */
@media (hover: hover) {
    .card:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-lg);
    }
}

.card-header {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: var(--space-6);
    color: var(--text-primary);
    letter-spacing: -0.2px;
}

.card-compact {
    padding: var(--space-4);
    border-radius: var(--radius-lg);
}

/* ==========================================
   FORMULAR-ELEMENTE
   ========================================== */

form {
    display: flex;
    flex-direction: column;
}

.form-group {
    margin-bottom: var(--space-5);
    display: flex;
    flex-direction: column;
}

label {
    font-weight: 500;
    margin-bottom: var(--space-2);
    color: var(--text-secondary);
    font-size: 15px;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="search"],
input[type="color"],
input[type="file"],
textarea,
select {
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--separator);
    border-radius: var(--radius-md);
    font-size: 17px;
    font-family: inherit;
    background: var(--bg-secondary);
    color: var(--text-primary);
    min-height: 44px;
    transition: border-color var(--duration-fast) var(--ease), box-shadow var(--duration-fast) var(--ease);
    -webkit-appearance: none;
    appearance: none;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="search"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--system-blue);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.15);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-tertiary);
}

textarea {
    resize: vertical;
    min-height: 100px;
}

/* Select-Pfeil (eigener) */
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238e8e93' d='M1.41 0L6 4.58 10.59 0 12 1.41l-6 6-6-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--space-4) center;
    padding-right: var(--space-10);
}

/* ==========================================
   BUTTONS
   ========================================== */

.btn,
button[type="submit"],
input[type="submit"] {
    font-family: inherit;
    font-size: 17px;
    font-weight: 600;
    padding: var(--space-3) var(--space-6);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    text-decoration: none;
    text-align: center;
    transition: all var(--duration-fast) var(--ease);
    -webkit-user-select: none;
    user-select: none;
}

/* Primary Button (Blau) */
.btn,
button[type="submit"],
input[type="submit"] {
    background: var(--system-blue);
    color: #ffffff;
}

.btn:hover,
button[type="submit"]:hover,
input[type="submit"]:hover {
    opacity: 0.85;
    text-decoration: none;
}

.btn:active,
button[type="submit"]:active,
input[type="submit"]:active {
    transform: scale(0.98);
    opacity: 0.75;
}

/* Danger Button (Rot) */
.btn-danger {
    background: var(--system-red);
    color: #ffffff;
}

.btn-danger:hover {
    opacity: 0.85;
}

/* Success Button (Gruen) */
.btn-success {
    background: var(--system-green);
    color: #ffffff;
}

.btn-success:hover {
    opacity: 0.85;
}

/* Secondary Button (Grau / Transparent) */
.btn-secondary {
    background: var(--fill);
    color: var(--system-blue);
}

.btn-secondary:hover {
    background: var(--separator);
}

/* Ghost Button (nur Text) */
.btn-ghost {
    background: transparent;
    color: var(--system-blue);
    padding: var(--space-2) var(--space-3);
}

.btn-ghost:hover {
    background: var(--fill);
}

/* Kleine Buttons */
.btn-small {
    font-size: 15px;
    padding: var(--space-1) var(--space-3);
    min-height: 32px;
    border-radius: var(--radius-sm);
}

/* Button-Gruppen */
.btn-group {
    display: flex;
    gap: var(--space-3);
    margin-top: var(--space-4);
}

.btn-group a,
.btn-group button {
    flex: 1;
    text-align: center;
}

/* Form-Actions (Speichern + Abbrechen) */
.form-actions {
    display: flex;
    gap: var(--space-3);
    margin-top: var(--space-4);
}

.form-actions .btn {
    flex: 1;
}

/* ==========================================
   DASHBOARD
   ========================================== */

/* Kopfbereich mit Titel und Betrag */
.dashboard-header {
    margin-bottom: var(--space-8);
}

.dashboard-header h1 {
    margin-bottom: var(--space-2);
}

.total-amount {
    font-size: 44px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -1px;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

/* Filter-Bereich */
.filter-card {
    margin-bottom: var(--space-6);
}

.filter-controls {
    display: flex;
    gap: var(--space-4);
    align-items: flex-end;
    flex-wrap: wrap;
}

.filter-group {
    flex: 1;
    min-width: 150px;
    display: flex;
    flex-direction: column;
}

.filter-group label {
    margin-bottom: var(--space-2);
}

.filter-btn {
    min-width: 140px;
    white-space: nowrap;
}

/* Chart-Container */
#chart-container {
    padding: var(--space-4) 0;
    max-height: 350px;
}

/* ==========================================
   TRANSAKTIONSLISTE (Card-basiert)
   ========================================== */

.transaction-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: var(--separator);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.transaction-item {
    display: flex;
    align-items: center;
    padding: var(--space-4) var(--space-5);
    background: var(--bg-secondary);
    gap: var(--space-4);
    transition: background var(--duration-fast) var(--ease);
}

.transaction-item:hover {
    background: var(--bg-tertiary);
}

/* Kategorie-Icon (Emoji) */
.transaction-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--fill);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

/* Beschreibung & Meta */
.transaction-details {
    flex: 1;
    min-width: 0;
}

.transaction-category {
    font-size: 17px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.transaction-meta {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Betrag */
.transaction-amount {
    font-size: 17px;
    font-weight: 600;
    text-align: right;
    white-space: nowrap;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.amount-expense {
    color: var(--text-primary);
}

.amount-income {
    color: var(--system-green);
}

/* Aktionen (Edit/Delete) */
.transaction-actions {
    display: flex;
    gap: var(--space-1);
    flex-shrink: 0;
}

.action-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all var(--duration-fast) var(--ease);
    min-height: auto;
    padding: 0;
}

.action-btn:hover {
    background: var(--fill);
    color: var(--text-primary);
}

.action-btn.action-delete:hover {
    background: rgba(255, 59, 48, 0.1);
    color: var(--system-red);
}

/* Fallback: Tabellen-Styles (fuer Abwaertskompatibilitaet) */
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

thead {
    background: var(--bg-tertiary);
}

th {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-tertiary);
    border-bottom: 1px solid var(--separator);
}

td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--separator);
    font-size: 15px;
}

tbody tr:hover {
    background: var(--bg-tertiary);
}

td .amount {
    font-weight: 600;
    text-align: right;
}

/* ==========================================
   LEERE ZUSTAENDE
   ========================================== */

.empty-state {
    text-align: center;
    padding: var(--space-16) var(--space-6);
    color: var(--text-tertiary);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: var(--space-4);
    display: block;
}

.empty-state-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.empty-state-text {
    font-size: 15px;
    margin-bottom: var(--space-6);
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
}

/* ==========================================
   LINKS
   ========================================== */

a {
    color: var(--system-blue);
    text-decoration: none;
    transition: opacity var(--duration-fast) var(--ease);
}

a:hover {
    opacity: 0.7;
    text-decoration: none;
}

.text-link {
    margin-top: var(--space-5);
    font-size: 15px;
    color: var(--text-tertiary);
}

.text-link a {
    color: var(--system-blue);
    font-weight: 500;
}

/* ==========================================
   AUTH-SEITEN (Login/Register)
   ========================================== */

.auth-wrapper {
    max-width: 420px;
    margin: var(--space-12) auto 0;
}

.auth-title {
    font-size: 34px;
    font-weight: 700;
    text-align: center;
    margin-bottom: var(--space-8);
    letter-spacing: -0.4px;
}

/* ==========================================
   FOOTER
   ========================================== */

.footer {
    text-align: center;
    padding: var(--space-8) var(--space-6);
    margin-top: auto;
    font-size: 13px;
    color: var(--text-tertiary);
}

.footer p {
    margin: 0;
}

/* ==========================================
   ANIMATIONEN
   ========================================== */

@media (prefers-reduced-motion: no-preference) {
    @keyframes fadeIn {
        from {
            opacity: 0;
            transform: translateY(8px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

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

    main.container {
        animation: fadeIn var(--duration) var(--ease-out);
    }

    .card {
        animation: fadeIn var(--duration) var(--ease-out);
        animation-fill-mode: both;
    }

    .card:nth-child(1) { animation-delay: 0ms; }
    .card:nth-child(2) { animation-delay: 60ms; }
    .card:nth-child(3) { animation-delay: 120ms; }
    .card:nth-child(4) { animation-delay: 180ms; }
}

/* ==========================================
   RESPONSIVE DESIGN
   ========================================== */

@media (max-width: 768px) {
    :root {
        --nav-height: 48px;
    }

    body {
        font-size: 16px;
        /* Platz fuer Bottom-Nav */
        padding-bottom: 80px;
    }

    h1 {
        font-size: 28px;
    }

    .total-amount {
        font-size: 36px;
    }

    /* Desktop-Navbar auf Mobile verstecken */
    .navbar {
        display: none;
    }

    /* Bottom-Nav auf Mobile zeigen */
    .bottom-nav {
        display: flex;
    }

    /* FAB auf Mobile zeigen */
    .fab {
        display: flex;
    }

    /* Bento-Grid auf Mobile: eine Spalte */
    .bento-grid {
        grid-template-columns: 1fr;
        gap: var(--space-4);
    }

    .container {
        padding: 0 var(--space-4);
    }

    main.container {
        padding-top: var(--space-6);
    }

    .card {
        padding: var(--space-5);
        border-radius: var(--radius-lg);
    }

    .filter-controls {
        flex-direction: column;
        gap: var(--space-3);
    }

    .filter-group {
        min-width: 100%;
    }

    .filter-btn {
        width: 100%;
    }

    .btn-group,
    .form-actions {
        flex-direction: column;
    }

    /* Transaktionsliste kompakter auf Mobil */
    .transaction-item {
        padding: var(--space-3) var(--space-4);
    }

    .transaction-actions {
        flex-direction: column;
        gap: 0;
    }

    .auth-wrapper {
        margin-top: var(--space-8);
    }

    /* Footer ueber Bottom-Nav schieben */
    .footer {
        padding-bottom: var(--space-4);
    }
}

@media (max-width: 480px) {
    .nav-logo {
        font-size: 17px;
    }

    .nav-register {
        padding: var(--space-1) var(--space-3);
        font-size: 15px;
    }

    /* Verhindert Auto-Zoom auf iOS bei Fokus */
    input[type="text"],
    input[type="password"],
    input[type="email"],
    input[type="number"],
    input[type="date"],
    textarea,
    select {
        font-size: 16px;
    }
}

/* ==========================================
   THEME-TOGGLE BUTTON
   ========================================== */

.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 17px;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--duration-fast) var(--ease);
    min-height: 36px;
}

.theme-toggle:hover {
    background: var(--fill);
}

.theme-icon {
    font-size: 18px;
    line-height: 1;
}

/* ==========================================
   BOTTOM-NAVIGATION (Mobile)
   ========================================== */

.bottom-nav {
    display: none; /* Standardmaessig versteckt, nur auf Mobile sichtbar */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--glass-bg-heavy);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid var(--separator);
    padding: var(--space-2) 0;
    padding-bottom: max(var(--space-2), env(safe-area-inset-bottom));
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: var(--space-1) 0;
    color: var(--text-tertiary);
    text-decoration: none;
    font-size: 10px;
    font-weight: 500;
    border: none;
    background: none;
    cursor: pointer;
    transition: color var(--duration-fast) var(--ease);
    -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item.active {
    color: var(--system-blue);
}

.bottom-nav-item:hover {
    color: var(--system-blue);
    text-decoration: none;
    opacity: 1;
}

.bottom-nav-icon {
    font-size: 22px;
    line-height: 1;
}

.bottom-nav-label {
    font-size: 10px;
    line-height: 1.2;
}

/* ==========================================
   FAB (Floating Action Button)
   ========================================== */

.fab {
    display: none; /* Standardmaessig versteckt, nur auf Mobile sichtbar */
    position: fixed;
    bottom: 90px;
    right: 20px;
    z-index: 99;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--system-blue);
    color: #ffffff;
    font-size: 28px;
    font-weight: 300;
    line-height: 1;
    text-decoration: none;
    box-shadow: 0 4px 16px rgba(0, 122, 255, 0.35);
    align-items: center;
    justify-content: center;
    transition: transform var(--duration-fast) var(--ease), box-shadow var(--duration-fast) var(--ease);
    -webkit-tap-highlight-color: transparent;
}

.fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(0, 122, 255, 0.45);
    opacity: 1;
    text-decoration: none;
    color: #ffffff;
}

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

/* ==========================================
   BENTO-GRID LAYOUT
   ========================================== */

.bento-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-6);
}

/* Karten die volle Breite einnehmen */
.bento-full {
    grid-column: 1 / -1;
}

/* Chart und Transaktionen nebeneinander auf Desktop */
.bento-chart {
    grid-column: 1 / -1;
}

.bento-transactions {
    grid-column: 1 / -1;
}

/* ==========================================
   SKELETON LOADING
   ========================================== */

.skeleton-chart {
    display: flex;
    align-items: flex-end;
    gap: var(--space-4);
    height: 200px;
    padding: var(--space-4);
}

.skeleton-bar {
    flex: 1;
    background: linear-gradient(90deg, var(--fill) 25%, var(--separator) 50%, var(--fill) 75%);
    background-size: 200% 100%;
    border-radius: var(--radius-sm);
    animation: skeleton-shimmer 1.5s ease infinite;
}

@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ==========================================
   NAV-ACTIVE (aktiver Link hervorheben)
   ========================================== */

.nav-active {
    color: var(--text-primary);
    font-weight: 600;
}

/* ==========================================
   BOTTOM-NAV FAB (grosser + Button in Mitte)
   ========================================== */

.bottom-nav-fab {
    width: 40px;
    height: 40px;
    background: var(--system-blue);
    color: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 300;
    margin-top: -8px;
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.3);
}

/* ==========================================
   STAT-CARDS (Dashboard Statistik-Karten)
   ========================================== */

.stat-card {
    padding: var(--space-5);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-6);
    flex-wrap: wrap;
}

.stat-main {
    flex: 1;
}

.stat-side {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.stat-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-1);
}

.stat-mini {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-mini-label {
    font-size: 12px;
    color: var(--text-tertiary);
}

.stat-mini-value {
    font-size: 17px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.stat-trend {
    margin-top: var(--space-2);
    font-size: 13px;
}

.trend-up { color: var(--system-green); }
.trend-down { color: var(--system-red); }
.trend-equal { color: var(--text-tertiary); }

/* ==========================================
   TYPE-TABS (Ausgabe/Einnahme Umschalter)
   ========================================== */

.type-tabs {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
}

.type-tab {
    flex: 1;
    padding: var(--space-2) var(--space-4);
    border: 1px solid var(--separator);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease);
    font-family: inherit;
    text-align: center;
    min-height: 40px;
}

.type-tab.active {
    background: var(--system-blue);
    color: #ffffff;
    border-color: var(--system-blue);
}

.type-tab:hover:not(.active) {
    background: var(--fill);
}

.modal-type-tabs {
    margin-bottom: var(--space-4);
}

/* ==========================================
   MODAL (Schnelleingabe, Export)
   ========================================== */

.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

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

.modal {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    max-width: 480px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: modalSlideUp var(--duration) var(--ease-out);
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-5);
}

.modal-header h2 {
    margin: 0;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--fill);
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--duration-fast) var(--ease);
    min-height: auto;
    padding: 0;
}

.modal-close:hover {
    background: var(--separator);
}

.input-large {
    font-size: 28px !important;
    font-weight: 600;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* ==========================================
   FORM-ROW (nebeneinander auf Desktop)
   ========================================== */

.form-row {
    display: flex;
    gap: var(--space-4);
}

.form-row .form-group {
    flex: 1;
}

/* ==========================================
   PROGRESS-BAR (Budget-Fortschritt)
   ========================================== */

.progress-bar-bg {
    width: 100%;
    height: 8px;
    background: var(--fill);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin: var(--space-2) 0;
}

.progress-bar-fill {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width 0.6s var(--ease);
}

.progress-green { background: var(--system-green); }
.progress-yellow { background: var(--system-orange); }
.progress-red { background: var(--system-red); }

.progress-over {
    background: var(--system-red);
    animation: pulse-red 1.5s ease infinite;
}

@keyframes pulse-red {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ==========================================
   BUDGET (Budget-Karten und Mini-Bars)
   ========================================== */

.budget-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-4);
}

.budget-card {
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
}

.budget-header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
}

.budget-icon {
    font-size: 20px;
}

.budget-name {
    flex: 1;
    font-weight: 600;
    font-size: 15px;
}

.budget-amounts {
    font-size: 15px;
    font-variant-numeric: tabular-nums;
}

.budget-spent {
    font-weight: 600;
}

.budget-percent {
    font-size: 12px;
    margin-top: var(--space-1);
}

.budget-mini {
    margin-bottom: var(--space-3);
}

.budget-mini:last-child {
    margin-bottom: 0;
}

.budget-mini-header {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: var(--space-1);
}

/* ==========================================
   UPCOMING / SUBSCRIPTIONS
   ========================================== */

.upcoming-list {
    margin-top: var(--space-3);
}

.upcoming-item {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    padding: var(--space-1) 0;
    border-bottom: 1px solid var(--separator);
}

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

.sub-paused {
    opacity: 0.5;
}

.badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-weight: 500;
    margin-left: var(--space-2);
}

.badge-gray {
    background: var(--fill);
    color: var(--text-tertiary);
}

/* ==========================================
   ANALYTICS
   ========================================== */

.analytics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-4);
}

.chart-wrapper {
    position: relative;
    max-height: 300px;
    padding: var(--space-2) 0;
}

.comparison-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.comparison-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: 14px;
}

.comparison-category {
    flex: 1;
    font-weight: 500;
}

.comparison-diff {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    min-width: 60px;
    text-align: right;
}

/* ==========================================
   FIELD-ERROR (Client-side Validierung)
   ========================================== */

.field-error {
    color: var(--system-red);
    font-size: 13px;
    margin-top: var(--space-1);
}

/* ==========================================
   UTILITIES
   ========================================== */

.text-center { text-align: center; }
.text-green { color: var(--system-green); }
.text-red { color: var(--system-red); }
.text-gray { color: var(--text-tertiary); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.gap-3 { gap: var(--space-3); }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.no-data {
    text-align: center;
    padding: var(--space-10) var(--space-4);
    color: var(--text-tertiary);
    font-size: 15px;
}

/* ==========================================
   RESPONSIVE: Form-Rows + Modal
   ========================================== */

@media (max-width: 768px) {
    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .stat-row {
        flex-direction: column;
        gap: var(--space-4);
    }

    .stat-side {
        flex-direction: row;
        gap: var(--space-6);
    }

    .analytics-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-3);
    }

    .budget-grid {
        grid-template-columns: 1fr;
    }

    .modal {
        max-height: 85vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        max-width: 100%;
        animation: modalSlideUpMobile var(--duration) var(--ease-out);
    }

    @keyframes modalSlideUpMobile {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }
}
