* { box-sizing: border-box; }

:root {
    --color-navy: #16305c;
    --color-navy-dark: #0f2140;
    --color-red: #9b1c2e;
    --color-red-dark: #7a1522;
    --color-gray: #8b8f94;
}

body {
    font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    background: #f2f4f7;
    color: #1a1a1a;
    margin: 0;
}
h1, h2, h3, .brand {
    font-family: Georgia, "Times New Roman", serif;
}
.topnav {
    background: var(--color-navy);
    padding: 10px 20px;
    display: flex;
    gap: 18px;
    align-items: center;
    flex-wrap: wrap;
}
.topnav a { color: white; text-decoration: none; font-size: 15px; }
.topnav .brand {
    font-weight: 700;
    font-size: 19px;
    margin-right: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: 0.3px;
}
.topnav .logo {
    height: 56px;
    width: 56px;
    border-radius: 50%;
    object-fit: cover;
}
main { max-width: 900px; margin: 0 auto; padding: 20px; }
h1 { margin-top: 0; color: var(--color-navy); }
h2, h3 { color: var(--color-navy); }
.card {
    background: white;
    border-radius: 10px;
    padding: 18px 20px;
    margin-bottom: 18px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border-top: 3px solid var(--color-red);
}
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 16px;
}
.form-grid .full { grid-column: 1 / -1; }
.form-grid label, .inline-form label {
    display: flex;
    flex-direction: column;
    font-size: 13px;
    color: #444;
    gap: 4px;
}
input, select {
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
}
input:focus, select:focus {
    outline: none;
    border-color: var(--color-navy);
}
button {
    background: var(--color-navy);
    color: white;
    border: none;
    padding: 9px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}
button:hover { background: var(--color-navy-dark); }
.btn { display: inline-block; text-decoration: none; }
.btn.danger, button.danger { background: var(--color-red); }
.btn.danger:hover, button.danger:hover { background: var(--color-red-dark); }
.btn.small, button.small { padding: 4px 10px; font-size: 12px; }
.checkbox { flex-direction: row !important; align-items: center; gap: 8px !important; }
table { width: 100%; border-collapse: collapse; }
table th, table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid #eee; }
table th { color: var(--color-navy); border-bottom: 2px solid var(--color-navy); }
table.mini td { padding: 4px 6px; }
.car-header { display: flex; justify-content: space-between; align-items: center; }
.games-list-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.games-list-header h2 { margin: 0; }
.add-game-card { padding: 12px 20px; }
.add-game-card summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--color-navy);
    font-size: 14px;
    list-style: none;
}
.add-game-card summary::-webkit-details-marker { display: none; }
.add-game-card[open] summary { margin-bottom: 12px; }
.form-grid.compact input { padding: 6px 8px; font-size: 13px; }
.form-grid.compact label { font-size: 12px; }
.seats { font-weight: 600; color: var(--color-navy); }
.seats.full { color: var(--color-red); }
.muted { color: #777; }
.muted.small, p.small { font-size: 12px; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; margin: 10px 0; }
.flash {
    background: #fdeaea;
    border: 1px solid var(--color-red);
    color: var(--color-red-dark);
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
}
.flash p { margin: 2px 0; }
.cars-table th, .cars-table td { vertical-align: top; }
.seats-cell { font-weight: 600; color: var(--color-navy); white-space: nowrap; }
.seats-cell.full { color: var(--color-red); }
.player-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #eef1f6;
    border: 1px solid #d7dee8;
    border-radius: 14px;
    padding: 3px 6px 3px 10px;
    margin: 2px 4px 2px 0;
    font-size: 13px;
}
.chip-remove {
    background: none;
    border: none;
    color: var(--color-red);
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    padding: 0 2px;
}
.small-form { margin: 4px 0 0 0; display: inline-flex; gap: 4px; }
.small-form select { font-size: 12px; padding: 4px 6px; }
.nav-spacer { flex: 1; }
.nav-user { color: #cfd8e8; font-size: 13px; }
.auth-card { max-width: 360px; margin: 40px auto; }
.auth-card h1 { text-align: center; }
.auth-card .form-grid { grid-template-columns: 1fr; }
.auth-card button { margin-top: 6px; }
.maps-link {
    color: var(--color-navy);
    font-size: 12px;
    text-decoration: none;
    white-space: nowrap;
}
.maps-link:hover { text-decoration: underline; }
.order-cell { white-space: nowrap; }
.order-cell button { padding: 2px 8px; font-size: 11px; }
.order-cell button:disabled { opacity: 0.3; cursor: default; }
.kader-select-all { margin-top: 4px; font-weight: 400; }
.kader-select-all label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: #777;
    cursor: pointer;
}
.kader-select-all input[type="checkbox"], table td input[type="checkbox"] { margin: 0; }

/* ===== Mobile-Optimierung ===== */

/* Kein Auto-Zoom bei Formularfeldern auf iOS */
input, select, textarea { font-size: 16px; }

/* Größere Tap-Ziele */
button, .btn, a.btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
.btn.small, button.small { min-height: 36px; }

/* Tabellen: Karte scrollt seitlich statt zu quetschen */
.card { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Bottom-Tab-Bar: auf Desktop unsichtbar */
.bottomnav { display: none; }

@media (max-width: 700px) {
    /* Topnav auf Handy schlank halten: nur Logo + Nutzer + Abmelden sichtbar */
    .topnav-link { display: none; }
    .topnav { padding: 10px 14px; }
    .topnav .logo { height: 40px; width: 40px; }
    .topnav .brand { font-size: 16px; }

    main { padding: 14px; padding-bottom: 90px; }

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

    /* Bottom-Tab-Bar aktivieren */
    .bottomnav {
        display: flex;
        position: fixed;
        left: 0; right: 0; bottom: 0;
        background: var(--color-navy);
        padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
        justify-content: space-around;
        align-items: center;
        box-shadow: 0 -2px 8px rgba(0,0,0,0.15);
        z-index: 100;
    }
    .bottomnav a {
        color: #cfd8e8;
        text-decoration: none;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        font-size: 10px;
        padding: 4px 6px;
        border-radius: 8px;
        min-width: 44px;
        min-height: 44px;
        justify-content: center;
    }
    .bottomnav a.active { color: white; background: rgba(255,255,255,0.12); }
    .bn-icon { font-size: 20px; line-height: 1; }
}

/* Tabelle auf Handy als Karten-Layout statt schmaler Tabelle */
@media (max-width: 700px) {
    .cars-table, .cars-table thead, .cars-table tbody, .cars-table th, .cars-table td, .cars-table tr {
        display: block;
        width: 100%;
    }
    .cars-table thead { display: none; }
    .cars-table tr {
        margin-bottom: 16px;
        border: 1px solid #e0e4ea;
        border-radius: 10px;
        padding: 10px 12px;
        background: white;
    }
    .cars-table td {
        border-bottom: none;
        padding: 8px 0;
        white-space: normal;
    }
    .cars-table td[data-label]::before {
        content: attr(data-label);
        display: block;
        font-size: 11px;
        font-weight: 700;
        color: var(--color-navy);
        text-transform: uppercase;
        letter-spacing: 0.4px;
        margin-bottom: 4px;
    }
    .checkbox-list { width: 100%; }
    .checkbox-list-item { width: 100%; }
}

/* Checkbox-Liste: jeder Name klar auf eigener Zeile */
.checkbox-list-item {
    flex-wrap: nowrap;
    white-space: normal;
    width: 100%;
}
.checkbox-list-item input[type="checkbox"] {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}
.checkbox-list-item {
    border-bottom: 1px solid #e8eaed;
    padding-bottom: 6px;
}
.checkbox-list-item:last-of-type {
    border-bottom: none;
}

/* Mehrfachauswahl von Spielern - Grundlayout */
.add-players { margin-top: 8px; }
.small-form-toggle {
    cursor: pointer;
    color: var(--color-navy);
    font-size: 13px;
    font-weight: 600;
    list-style: none;
}
.small-form-toggle::-webkit-details-marker { display: none; }
.checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
    padding: 10px;
    background: #f7f8fa;
    border-radius: 8px;
}

/* Links mit .btn-Klasse wie echte Buttons gestalten */
.btn {
    background: var(--color-navy);
    color: white !important;
    padding: 9px 16px;
    border-radius: 6px;
    font-size: 14px;
}
.btn:hover { background: var(--color-navy-dark); }
