:root {
    --primary: #2c3e50;
    --accent: #3498db;
    --light: #ecf0f1;
    --white: #ffffff;
    --danger: #e74c3c;
    --shadow: 0 4px 6px rgba(0,0,0,0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0; padding: 0;
    background-color: #f0f2f5;
    color: #333;
    padding-top: 90px;
    touch-action: pan-x pan-y;
    -webkit-text-size-adjust: 100%;
}

/* --- HELFER KLASSEN (Müssen Vorrang haben!) --- */
.hidden { display: none !important; }
.step-hidden { display: none !important; } /* Das fixt Ihr Problem mit den Adressfeldern */

/* --- HEADER & NAVIGATION --- */
header {
    background-color: var(--white);
    position: fixed; top: 0; left: 0; width: 100%; height: 70px;
    z-index: 2000; box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    display: flex; align-items: center;
}
.header-content {
    width: 100%; max-width: 800px; margin: 0 auto; padding: 0 20px;
    display: flex; justify-content: space-between; align-items: center;
}
.app-logo { height: 50px; width: auto; object-fit: contain; display: block; }
.header-actions { display: flex; align-items: center; gap: 20px; }

/* Navigation Buttons */
#quick-add-btn {
    display: flex; align-items: center; justify-content: center;
    width: 45px; height: 45px;
    background: linear-gradient(135deg, var(--accent), #2980b9);
    color: white; border-radius: 50%; text-decoration: none; font-size: 1.2rem;
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
#quick-add-btn:hover { transform: translateY(-2px) scale(1.05); }
#quick-add-btn:active { transform: scale(0.95); }

#menu-toggle {
    background: none; border: none; cursor: pointer; padding: 0;
    width: 30px; height: 24px; display: flex; flex-direction: column; justify-content: space-between;
}
#menu-toggle span {
    display: block; width: 100%; height: 3px; background-color: var(--primary); border-radius: 4px;
}

/* Nav Dropdown */
nav {
    position: fixed; top: 70px; left: 0; width: 100%;
    background-color: #2c3e50; overflow: hidden; max-height: 0;
    transition: max-height 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 10px 30px rgba(0,0,0,0.2); z-index: 1900;
}
nav.open { max-height: 300px; }
nav a {
    display: flex; align-items: center; padding: 18px 30px;
    color: #ecf0f1; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,0.05);
}
nav a.active { background-color: rgba(52, 152, 219, 0.15); border-left: 4px solid var(--accent); }
nav a i { width: 30px; color: var(--accent); margin-right: 10px; }

/* --- GLOBAL LAYOUT --- */
main { padding: 15px; max-width: 600px; margin: 0 auto; }
.card {
    background: var(--white); padding: 20px; border-radius: 12px;
    box-shadow: var(--shadow); margin-bottom: 20px;
}
h2 { margin-top: 0; color: var(--primary); border-bottom: 2px solid var(--light); padding-bottom: 10px; }

/* Forms */
.form-group { margin-bottom: 15px; }
label { display: block; margin-bottom: 5px; font-weight: 600; color: #555; }
input, select, textarea {
    width: 100%;
    max-width: 100%; /* SICHERHEITSNETZ: Darf niemals breiter als der Eltern-Container sein */
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 16px !important;
    background-color: #fff;
    appearance: none;
    box-sizing: border-box; /* Zur Sicherheit auch hier nochmal explizit */
}
input:focus, select:focus { border-color: var(--accent); outline: none; }
input[readonly] { background-color: #e9ecef; color: #6c757d; }

/* --- MODALS (Global) --- */
.fb-modal {
    position: fixed; inset: 0; z-index: 9999;
    display: grid; place-items: start center; align-content: start;
    padding: calc(max(0.75rem, env(safe-area-inset-top)) + 70px) 1rem 1rem 1rem;
}
.fb-modal__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.fb-modal__panel {
    position: relative; width: min(520px, 100%); background: #fff;
    border-radius: 12px; padding: 1.5rem; box-shadow: 0 10px 30px rgba(0,0,0,.25);
    max-height: calc(100dvh - 2rem); overflow: auto;
}
.fb-modal__title { margin: 0 0 1rem 0; text-align: center; border-bottom: 1px solid #f0f0f0; padding-bottom: 10px; }
.fb-modal__msg { text-align: center; padding: 1rem 0; }

.fb-modal__actions {
    display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; flex-wrap: wrap;
}
/* Wichtig: Dieser Selector muss stark sein */
.fb-modal__actions .fb-modal__btn {
    height: 44px; padding: 0 20px; border-radius: 8px; border: none; font-weight: 500; cursor: pointer;
    min-width: 100px; display: inline-flex; align-items: center; justify-content: center;
}
.fb-modal__btn.primary { background-color: var(--accent); color: white; }
.fb-modal__btn.secondary { background-color: #f0f2f5; color: #333; }
.fb-modal__btn.danger { background-color: var(--danger); color: white; }

/* FIX für Resend Button - Damit er wirklich weg ist */
#btn-resend-cancel.hidden { display: none !important; }

/* --- WICHTIG: Verhindert, dass Padding die Breite sprengt --- */
*, *::before, *::after {
    box-sizing: border-box;
}

/* --- AUTOCOMPLETE (Global für alle Seiten) --- */
.autocomplete-wrapper {
    position: relative;
}

.suggestions-list {
    list-style: none !important; /* WICHTIG: Entfernt die Punkte */
    padding: 0;
    margin: 0;
    border: 1px solid #ddd;
    border-radius: 0 0 8px 8px;
    max-height: 200px;
    overflow-y: auto;
    background: white;
    position: absolute;
    width: 100%;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    box-sizing: border-box;
}

.suggestions-list li {
    padding: 12px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    font-size: 0.95rem;
    color: #333;
    display: block;
}

.suggestions-list li:hover {
    background-color: #f0f2f5;
    color: var(--accent); /* Ihr Blau (#3498db) */
}

/* Header-Elemente */
#menu-toggle { display: none !important; }

header .header-content .header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Spezifisch für den Home-Button im Header */
header .header-content .header-actions a.btn-home-large {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 45px !important;
    height: 45px !important;
    text-decoration: none !important;
    color: #000000 !important;
}

header .header-content .header-actions a.btn-home-large i::before {
    font-size: 35px !important;
    display: inline-block !important;
}

/* --- BASIS & HEADER --- */
* { box-sizing: border-box; }
body { background-color: #f0f2f5; font-family: sans-serif; margin: 0; padding-top: 70px; }
.home-wrapper { max-width: 500px; margin: 0 auto; padding: 15px; }

/* Home Button Größe erzwingen */
header .header-content .btn-home-large i::before {
    font-size: 35px !important;
    color: #2c3e50 !important;
}

/* --- CARDS --- */
.home-card {
    background: white; border-radius: 12px; padding: 15px;
    margin-bottom: 12px; box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}
.booking-border { border-left: 5px solid #27ae60; }
.trip-border { border-left: 5px solid #3498db; }

.card-label { font-size: 0.7rem; text-transform: uppercase; color: #888; font-weight: 700; margin-bottom: 8px; }
.card-main { display: flex; justify-content: space-between; align-items: center; }
.card-title { font-size: 1rem; font-weight: 700; color: #333; }
.income-text { color: #27ae60; font-weight: 800; font-size: 1.1rem; }
.card-sub { font-size: 0.8rem; color: #aaa; margin-top: 5px; }

.route-box { display: flex; flex-direction: column; gap: 4px; }
.route-item { font-size: 0.85rem; color: #444; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* --- 3-SPALTEN GRID --- */
.home-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 20px;
}

.home-btn {
    display: flex; flex-direction: column; align-items: center;
    padding: 12px 5px; border-radius: 12px; text-decoration: none;
    transition: transform 0.1s;
}
.home-btn:active { transform: scale(0.95); }
.home-btn span { color: white; font-size: 0.75rem; font-weight: 700; margin-top: 8px; text-align: center; }

.btn-icon {
    width: 36px; height: 36px; background: rgba(255,255,255,0.25);
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    color: white; font-size: 1rem;
}

/* Farbgruppen */
.btn-green { background-color: #27ae60; }
.btn-blue { background-color: #3498db; }
.btn-orange { background-color: #e67e22; }
.btn-gray { background-color: #7f8c8d; }

.grid-placeholder { visibility: hidden; }

/* --- GRID LAYOUT --- */
.home-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* 3 Spalten nebeneinander */
    gap: 8px;
    margin-top: 20px;
}

/* Spezialklasse für die letzte Reihe (Kunden) */
.grid-full-width {
    grid-column: span 3; /* Nimmt alle 3 Spalten ein */
    display: flex;
    justify-content: center;
}

.grid-full-width .home-btn {
    width: calc(33.33% - 6px); /* Gleiche Breite wie die oberen Buttons */
}

/* --- BUTTON STYLES --- */
.home-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px 4px;
    border-radius: 12px;
    text-decoration: none;
    transition: transform 0.1s;
}

.home-btn:active { transform: scale(0.95); }

.home-btn span {
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    margin-top: 8px;
    text-align: center;
    line-height: 1.1;
}

.btn-icon {
    width: 34px;
    height: 34px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1rem;
}

/* --- FARBGRUPPEN --- */
/* Einnahmen/Umsätze: Grün */
.group-income { background-color: #27ae60; }

/* Fahrten: Blau */
.group-trip { background-color: #3498db; }

/* Ausgaben: Orange */
.group-expense { background-color: #e67e22; }

/* Kunden/Verwaltung: Grau */
.group-meta { background-color: #7f8c8d; }

/* --- CARDS (HOMESCREEN) --- */
.home-card {
    background: white; border-radius: 14px; padding: 15px;
    margin-bottom: 10px; box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.booking-border { border-left: 5px solid #27ae60; }
.trip-border { border-left: 5px solid #3498db; }

/* --- GRID BASICS --- */
.home-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 10px;
}

/* --- GRUPPEN ÜBERSCHRIFTEN --- */
.grid-section-title {
    grid-column: span 3; /* Erstreckt sich über alle 3 Spalten */
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    color: #95a5a6;
    letter-spacing: 0.5px;
    margin-top: 15px;
    margin-bottom: 5px;
    padding-left: 5px;
    border-bottom: 1px solid #ecf0f1;
    padding-bottom: 3px;
}

/* Kunden-Zentrierung */
.grid-full-width {
    grid-column: span 3;
    display: flex;
    justify-content: center;
    margin-top: 5px;
}

.grid-full-width .home-btn {
    width: calc(33.33% - 7px);
}

/* --- BUTTONS --- */
.home-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px 4px;
    border-radius: 12px;
    text-decoration: none;
    transition: transform 0.1s;
}

.home-btn span {
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    margin-top: 8px;
    text-align: center;
}

.btn-icon {
    width: 34px;
    height: 34px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1rem;
}

/* --- FARBEN --- */
.group-income { background-color: #27ae60; }
.group-trip { background-color: #3498db; }
.group-expense { background-color: #e67e22; }
.group-meta { background-color: #7f8c8d; }

/* --- CARDS --- */
.home-card {
    background: white; border-radius: 14px; padding: 15px;
    margin-bottom: 10px; box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.booking-border { border-left: 5px solid #27ae60; }
.trip-border { border-left: 5px solid #3498db; }

/* --- FARB-GRUPPIERUNG --- */

/* 1. EINNAHMEN (Grün-Töne) */
.group-income-dark  { background-color: #219150; } /* Kräftiges Waldgrün */
.group-income-light { background-color: #2ecc71; } /* Helles Smaragdgrün */

/* 2. FAHRTEN (Blau-Töne) */
.group-trip-dark    { background-color: #2980b9; } /* Sattes Marineblau */
.group-trip-light   { background-color: #5dade2; } /* Helles Himmelblau */

/* 3. AUSGABEN (Orange/Braun-Töne) */
.group-expense-dark  { background-color: #d35400; } /* Dunkles Kürbisorange */
.group-expense-light { background-color: #f39c12; } /* Helles Goldorange */

/* 4. VERWALTUNG (Grau) */
.group-meta { background-color: #7f8c8d; }

/* --- GRID & TYPO OPTIMIERUNGEN --- */
.grid-section-title {
    grid-column: span 3;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    color: #0080ff;
    margin-top: 25px;
    margin-bottom: 2px;
    padding-bottom: 3px;
    border-bottom: 1px solid #ecf0f1;
}

.home-btn span {
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    margin-top: 8px;
    text-align: center;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1); /* Bessere Lesbarkeit auf hellen Tönen */
}

/* --- STORNO STYLES --- */

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

.badge-storno {
    background-color: #fee2e2;
    color: #c0392b;
    font-size: 0.7rem;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid #fadbd8;
    text-transform: uppercase;
}

/* Wenn storniert: Rote Border und Betrag durchstreichen */
.home-card.booking-border.is-cancelled {
    border-left-color: #e74c3c;
    background-color: #fffbfb;
}

.is-cancelled .income-text {
    text-decoration: line-through;
    color: #95a5a6 !important;
    opacity: 0.7;
}

.is-cancelled .card-title {
    color: #7f8c8d;
}

/* --- FARB-ABSTUFUNGEN GRID --- */

/* Einnahmen (Grün) */
.group-income-dark  { background-color: #219150; }
.group-income-light { background-color: #2ecc71; }

/* Fahrten (Blau) */
.group-trip-dark    { background-color: #2980b9; }
.group-trip-light   { background-color: #5dade2; }

/* Ausgaben (Orange) */
.group-expense-dark  { background-color: #d35400; }
.group-expense-light { background-color: #f39c12; }

.group-meta { background-color: #7f8c8d; }


.login-body {
    /* Nutzt die dynamische Viewport-Höhe (beachtet Browser-Leisten auf dem Handy) */
    height: 100dvh; 
    width: 100vw;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #f4f7f9;
    position: fixed; /* Fixiert den Hintergrund */
    top: 0;
    left: 0;
}

.login-card {
    background: #ffffff;
    padding: 2.5rem;
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    width: 90%;
    max-width: 380px;
    /* Verhindert, dass die Karte bei kleinen Screens zu groß wird */
    max-height: 90dvh; 
    text-align: center;
    z-index: 10;
}

.login-card h2 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    color: #333;
    font-size: 1.5rem;
}

.login-card form {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.login-card input {
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 12px;
    font-size: 1rem;
    background: #fafafa;
    -webkit-appearance: none; /* iOS Fix */
}

.login-card input:focus {
    border-color: #007bff;
    background: #fff;
    outline: none;
    box-shadow: 0 0 0 4px rgba(0, 123, 255, 0.1);
}

.primary-btn {
    background-color: #007bff;
    color: white;
    padding: 16px;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 0.5rem;
}

.login-error {
    background-color: #fff0f0;
    color: #e74c3c;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    border: 1px solid #ffdada;
}

.pwa-enforce-body {
    height: 100dvh; width: 100vw; margin: 0; overflow: hidden;
    display: flex; justify-content: center; align-items: center;
    background-color: #f4f7f9; font-family: sans-serif;
}
.pwa-card {
    background: #fff; padding: 2.5rem; border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.1); width: 90%; max-width: 380px; text-align: center;
}
.pwa-form { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; }
.pwa-form input { padding: 14px; border: 1px solid #ddd; border-radius: 10px; font-size: 1rem; }
.btn-pwa {
    width: 100%; padding: 16px; border: none; border-radius: 12px;
    font-size: 1.1rem; font-weight: 600; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 10px;
}
.btn-pwa-install { background: #28a745; color: #fff; margin-bottom: 10px; }
.btn-pwa-check { background: #007bff; color: #fff; }
.pwa-help-box { margin: 20px 0; padding: 12px; background: #e9ecef; border-radius: 10px; font-size: 0.85rem; color: #495057; }
.ios-hint { margin-top: 20px; font-size: 0.8rem; color: #888; text-align: left; background: #f8f9fa; padding: 10px; border-radius: 10px; }
.pwa-hide { display: none !important; }
.login-error { color: #d63031; background: #ffe5e5; padding: 10px; border-radius: 8px; margin-bottom: 15px; font-size: 0.85rem; }
.login-logo { max-width: 180px; margin-bottom: 10px; }