:root {
    --bg-color: #f8f9fa;
    --sidebar-bg: #ffffff;
    --primary-blue: #1e40af;
    --text-main: #111827;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    margin: 0;
    display: flex;
    height: 100vh;
    background-color: var(--bg-color);
    color: var(--text-main);
    overflow: hidden;
    /* Main-Content und Sidebar scrollen getrennt */
}

/* --- SIDEBAR --- */
.sidebar {
    width: 320px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 0;
    height: 100vh;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.sidebar h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.25rem;
    margin-bottom: 24px;
    margin-top: 0;
}

.sidebar-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 700;
    margin: 24px 0 12px;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* --- NAV CARDS --- */
.nav-card {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    transition: all 0.2s ease;
}

.nav-card:hover {
    border-color: var(--primary-blue);
    transform: translateY(-2px);
}

.nav-card.active {
    border: 2px solid var(--primary-blue);
    background-color: #f0f7ff;
}

.fzg-icon-circle {
    width: 40px;
    height: 40px;
    background: #f3f4f6;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #4b5563;
    flex-shrink: 0;
}

.nav-card.active .fzg-icon-circle {
    background: var(--primary-blue);
    color: white;
}

.nav-card h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.nav-card p {
    margin: 2px 0 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* --- SIDEBAR FOOTER (EXPORT) --- */
.sidebar-footer {
    padding: 20px 24px;
    background: #f9fafb;
    border-top: 1px solid var(--border-color);
    position: sticky;
    bottom: 0;
}

.sidebar-footer input[type="month"] {
    width: 100%;
    margin-bottom: 10px;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: white;
    font-family: inherit;
    font-size: 0.85rem;
    box-sizing: border-box;
}

.btn-export {
    background: white;
    border: 1px solid var(--border-color);
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--text-main);
    transition: all 0.2s;
    width: 100%;
    box-sizing: border-box;
}

.btn-export:hover {
    background: #f3f4f6;
    border-color: #cbd5e1;
}

/* --- MAIN CONTENT --- */
.main-content {
    flex: 1;
    padding: 40px 5%;
    overflow-y: auto;
    box-sizing: border-box;
}

.header-area {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.header-area h2 {
    margin: 0;
    font-size: 1.8rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-area p {
    margin: 5px 0 0;
    color: var(--text-muted);
}

.btn-add {
    background: #000;
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 8px;
    border: none;
    cursor: pointer;
    transition: transform 0.2s;
}

.btn-add:hover {
    transform: translateY(-2px);
}

/* --- STATS GRID --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.stat-card span {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 8px;
}

.stat-card strong {
    font-size: 1.4rem;
    color: var(--text-main);
}

#extendedStats {
    display: none;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px dashed var(--border-color);
    margin-bottom: 40px;
}

.btn-toggle-stats {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.75rem;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 32px;
}

.btn-toggle-stats:hover {
    background: #f3f4f6;
    color: var(--text-main);
}

/* --- BILL CARDS --- */
.bill-card {
    background: white;
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border-color);
    position: relative;
    /* Für Bearbeiten-Buttons wichtig */
}

.bill-header {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    font-size: 1.125rem;
    margin-bottom: 8px;
    padding-right: 60px;
    /* Platz für Buttons */
}

.bill-meta {
    display: flex;
    gap: 15px;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 20px;
    align-items: center;
}

.bill-details {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border-top: 1px solid #f3f4f6;
    margin-top: 20px;
    padding-top: 20px;
    gap: 20px;
}

.detail-item span {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 6px;
}

.detail-item strong {
    font-size: 1.1rem;
}

.reichweite-badge {
    margin-top: 15px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #f0f7ff;
    color: var(--primary-blue);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* --- BILL ACTIONS --- */
.bill-actions {
    position: absolute;
    top: 24px;
    right: 24px;
    display: flex;
    gap: 12px;
}

.bill-actions a {
    color: #cbd5e1;
    transition: 0.2s;
}

.bill-actions a:hover {
    color: var(--primary-blue);
}

.bill-actions a.delete:hover {
    color: #ef4444;
}

/* --- MODAL --- */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: white;
    padding: 32px;
    border-radius: 20px;
    width: 90%;
    max-width: 450px;
    position: relative;
    animation: slideUp 0.3s ease-out;
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden;
}

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

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close-modal {
    position: absolute;
    right: 20px;
    top: 20px;
    cursor: pointer;
    color: var(--text-muted);
    transition: 0.2s;
}

.close-modal:hover {
    color: var(--text-main);
}

.grid-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 20px;
}

.full-width {
    grid-column: span 2;
}

label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
    display: block;
    text-transform: uppercase;
}

input,
select {
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    width: 100%;
    box-sizing: border-box;
    background: #f9fafb;
    font-family: inherit;
}

.btn-submit {
    background: var(--primary-blue);
    color: white;
    border: none;
    padding: 14px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 10px;
    transition: 0.2s;
}

.btn-submit:hover {
    opacity: 0.9;
}

.form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 10px;
}

.btn-cancel {
    flex: 1;
    background-color: red;
    color: white;
    border: none;
    padding: 14px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
}

.btn-cancel:hover {
    opacity: 0.9;
}

.form-actions .btn-submit {
    flex: 1;
    margin-top: 0;
}

.form-actions .btn-cancel {
    margin-top: 0;
}

.logout-card {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    transition: all 0.2s ease;
}

.logout-card:hover {
    border-color: var(--primary-blue);
    transform: translateY(-2px);
}

.logout-card.active {
    border: 2px solid var(--primary-blue);
    background-color: #f0f7ff;
}

.logout-card.active .fzg-icon-circle {
    background: var(--primary-blue);
    color: white;
}

.logout-card h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.logout-card p {
    margin: 2px 0 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.logout-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 700;
    margin: 24px 0 12px;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 6px;
}

#button-list {
    display: grid;
    grid-template-areas: "maintenanceBtn addBtn";
    gap: 0.5em;
}

#maintenanceBtn {
    grid-area: maintenanceBtn;
    margin-right: 0.5em;
}

#addBtn {
    grid-area: addBtn;
}

/* --- WARTUNGS-ITEMS --- */
.maintenance-heading {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
    margin: 0 0 12px 0;
    text-transform: none;
}

.maintenance-item {
    padding: 12px;
    background: #f9fafb;
    border-radius: 8px;
    margin-bottom: 10px;
    border: 1px solid var(--border-color);
    transition: all 0.2s;
}

.maintenance-item:hover {
    background: #f3f4f6;
}

.maintenance-item label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.95rem;
    font-weight: 500;
    text-transform: none;
    color: var(--text-main);
    cursor: pointer;
    margin: 0;
}

.maintenance-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    margin: 0;
    flex-shrink: 0;
    accent-color: var(--primary-blue);
}

.photo-upload {
    display: none;
    margin-top: 10px;
    margin-left: 28px;
    animation: slideDown 0.2s ease-out;
}

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

.photo-upload input[type="file"] {
    background: white;
    padding: 8px;
    font-size: 0.85rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.photo-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.photo-input-row:first-child {
    margin-top: 0;
}

.photo-input-row input[type="file"] {
    flex: 1;
    min-width: 0;
}

.btn-remove-photo-input {
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: #dc2626;
    border-radius: 4px;
    padding: 6px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}

.btn-remove-photo-input:hover {
    background: #fee2e2;
    color: #991b1b;
}

.existing-photo-list {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.btn-add-photo {
    margin-top: 8px;
    background: transparent;
    border: 1px dashed var(--border-color);
    color: var(--text-muted);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 0.8rem;
    cursor: pointer;
}

.btn-add-photo:hover {
    border-color: var(--primary-blue);
    color: var(--primary-blue);
}

/* --- WARTUNGS-BADGES --- */
.wartungs-items-list {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #f3f4f6;
}

.wartungs-item-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #f0f7ff;
    color: var(--primary-blue);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    margin-right: 8px;
    margin-bottom: 8px;
}

.wartungs-item-badge i {
    color: #10b981;
}

.wartungs-foto-actions {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 6px;
}

.wartungs-foto-actions a {
    display: inline-flex;
    align-items: center;
}

.wartungs-foto-actions .delete-photo {
    color: #ef4444;
}

.wartungs-foto-actions .delete-photo:hover {
    color: #b91c1c;
}

/* --- RESPONSIVE & DRUCK --- */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    body {
        flex-direction: column;
        overflow: auto;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        height: auto;
    }

    /* Verstecke alle Fahrzeuge und Labels standardmäßig auf Mobilgeräten */
    .sidebar-nav .sidebar-label,
    .sidebar-nav .nav-card:not(.active) {
        display: none;
    }

    /* Wenn die Sidebar die Klasse 'is-open' hat, zeige alles an */
    .sidebar.is-open .sidebar-nav .sidebar-label,
    .sidebar.is-open .sidebar-nav .nav-card {
        display: flex;
    }

    /* Optischer Hinweis für den User (optional) */
    .nav-card.active {
        cursor: pointer;
        position: relative;
    }

    /* Ein kleines Icon (Pfeil) anzeigen, dass es ausklappbar ist */
    .nav-card.active::after {
        content: '▼';
        position: absolute;
        right: 20px;
        font-size: 0.7rem;
        color: var(--primary-blue);
    }

    .sidebar.is-open .nav-card.active::after {
        content: '▲';
    }

    .main-content {
        padding: 20px;
    }

    /* Blende Export an Handy aus */
    #exportLabel,
    #export-form {
        display: none;
    }

    .header-area {
        flex-direction: column;
        /* Stapelt die Elemente untereinander */
        align-items: flex-start;
        /* Richtet Text und Button linksbündig aus */
        gap: 15px;
        /* Erzeugt einen sauberen Abstand zwischen Text und Button */
    }

    .btn-add {
        width: 100%;
        /* Optional: Der Button streckt sich über die volle Breite (bessere Klickfläche) */
        display: flex;
        justify-content: center;
        /* Zentriert Icon und Text im Button */
        padding: 12px;
        /* Etwas mehr "Touch-Fläche" für mobile User */
    }

    #logoutContainer {
        display: grid;
        grid-template-areas: "logoutLabel01 logoutBtn"
            "logoutLabel02 logoutBtn";
    }

    #logoutLabel01 {
        grid-area: logoutLabel01;
    }

    #logoutLabel02 {
        grid-area: logoutLabel02;
    }

    #logoutBtn {
        grid-area: logoutBtn;
    }
}

@media print {

    .sidebar,
    .btn-add,
    .btn-toggle-stats,
    .bill-actions {
        display: none !important;
    }

    .main-content {
        padding: 0 !important;
        overflow: visible !important;
        width: 100% !important;
        margin: 0 !important;
    }

    body {
        height: auto;
        overflow: visible !important;
        display: block;
    }

    .bill-card {
        break-inside: avoid;
        border: 1px solid #eee !important;
        box-shadow: none !important;
        margin-bottom: 10px !important;
    }

    #extendedStats {
        display: block !important;
    }
}