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

body {
    font-family: sans-serif;
    margin: 2rem;
    color: #222;
    background: #f7f7f5;
}

.form-row select,
.form-row input:not([type="checkbox"]),
.form-row textarea {
    width: 100%;
}

.flashes {
    list-style: none;
    padding: 0;
}

.flash-error {
    color: #b00020;
}

.flash-success {
    color: #2e7d32;
}

.flash-info {
    color: #1565c0;
}

.app-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.app-nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
}

.nav-btn {
    display: inline-block;
    padding: 0.4rem 0.9rem;
    border-radius: 6px;
    background: #fff;
    border: 1px solid #ccc;
    color: #222;
    text-decoration: none;
    font-weight: bold;
    font-size: 0.85rem;
}

.nav-btn:hover {
    background: #f0f0f0;
}

.app-user {
    color: #555;
}

/* KPI-Karten */
.kpi-cards {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin: 1.5rem 0;
}

.kpi-card {
    flex: 1 1 200px;
    background: #fff;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.kpi-label {
    font-size: 0.85rem;
    color: #666;
}

.kpi-value {
    font-size: 1.8rem;
    font-weight: bold;
}

.kpi-sub {
    font-size: 0.8rem;
    color: #888;
}

.kpi-positive .kpi-value {
    color: #2e7d32;
}

.kpi-open .kpi-value {
    color: #ef6c00;
}

/* Buttons */
.action-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin: 1.5rem 0;
}

.btn {
    display: inline-block;
    background: #2e7d32;
    color: #fff;
    text-decoration: none;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-weight: bold;
}

.btn:hover {
    background: #256428;
}

.btn-warn {
    background: #ef6c00;
}

.btn-warn:hover {
    background: #c85a00;
}

.btn-danger {
    background: #b00020;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0.4rem 0.8rem;
}

.btn-danger:hover {
    background: #8e001a;
}

/* Offene-Posten-Liste */
.guest-list {
    list-style: none;
    padding: 0;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.guest-list-item {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #eee;
}

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

.guest-list-name {
    font-weight: bold;
    color: #222;
    text-decoration: none;
}

.guest-list-name:hover {
    text-decoration: underline;
}

.guest-list-notes {
    color: #888;
    font-size: 0.85rem;
    flex: 1;
}

.guest-list-amount {
    color: #ef6c00;
    font-weight: bold;
    /* nicht auf .guest-list-notes (flex:1) verlassen, um den Betrag nach
       rechts zu schieben - fehlt die Notiz (kein notes-Feld gesetzt),
       raeumt sonst nichts den Platz und der Betrag rutscht neben den Namen */
    margin-left: auto;
}

/* Login */
.login-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 320px;
    background: #fff;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-top: 1.5rem;
}

.login-form input {
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1rem;
}

.login-form button {
    margin-top: 0.5rem;
    border: none;
    cursor: pointer;
}

/* Gast-Autocomplete */
.guest-autocomplete {
    position: relative;
}

.guest-autocomplete-input {
    width: 100%;
    box-sizing: border-box;
}

.guest-autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 20;
    margin: 2px 0 0;
    padding: 0;
    list-style: none;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    max-height: 220px;
    overflow-y: auto;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.guest-autocomplete-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
}

.guest-autocomplete-item:hover,
.guest-autocomplete-item.is-active {
    background: #f0f0f0;
}

/* Konsumation erfassen */
.order-form {
    max-width: 480px;
}

/* Zahlung erfassen */
.payment-form {
    max-width: 400px;
}

.open-amount-display {
    margin: 0.4rem 0 0;
    padding: 0.5rem 0.75rem;
    background: #fff3e0;
    color: #ef6c00;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.9rem;
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 1rem;
}

.form-row select,
.form-row input:not([type="checkbox"]),
.form-row textarea {
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1rem;
    font-family: inherit;
}

.product-group {
    background: #fff;
    border: none;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 1rem;
    margin-bottom: 1rem;
}

.product-group legend {
    font-weight: bold;
    padding: 0 0.25rem;
    margin-bottom: 0.5rem;
}

.product-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid #eee;
}

.product-row:last-child {
    border-bottom: none;
}

.product-name {
    flex: 1;
}

.product-price {
    color: #888;
    font-size: 0.9rem;
    width: 3.5rem;
    text-align: right;
}

.qty-control {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.qty-control input {
    width: 3rem;
    text-align: center;
    padding: 0.3rem;
    border: 1px solid #ccc;
    border-radius: 4px;
}

/* Native Spinner-Pfeile ausblenden - die eigenen +/- Buttons (.qty-btn)
   decken das schon ab, zwei Steuerelemente uebereinander waeren doppelt.
   Beide Regeln noetig: WebKit/Blink (Safari/Chrome) nutzen die Pseudo-
   Elemente, Firefox/Gecko das -moz-appearance-Property. */
.qty-control input[type="number"]::-webkit-inner-spin-button,
.qty-control input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.qty-control input[type="number"] {
    -moz-appearance: textfield;
}

.qty-btn {
    width: 1.8rem;
    height: 1.8rem;
    border: 1px solid #ccc;
    background: #f0f0f0;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
}

.qty-btn:hover {
    background: #e0e0e0;
}

/* Gaeste-Verwaltung */
.page-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.page-header-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.guest-form {
    max-width: 400px;
}

.filter-form {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.filter-form input[type="text"] {
    flex: 1;
    min-width: 200px;
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1rem;
}

.filter-form select {
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1rem;
}

.badge {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: bold;
}

.badge-inactive {
    background: #eee;
    color: #666;
}

.guests-list {
    list-style: none;
    padding: 0;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.guests-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #eee;
    flex-wrap: wrap;
}

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

.guests-list-item[hidden] {
    display: none;
}

.guests-list-main {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.guests-list-name-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.guests-list-name {
    font-weight: bold;
    color: #222;
    text-decoration: none;
}

.guests-list-name:hover {
    text-decoration: underline;
}

.guests-list-notes,
.guests-list-contact {
    color: #888;
    font-size: 0.85rem;
}

.guests-list-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.guests-amount {
    font-weight: bold;
}

.guests-amount.is-open {
    color: #ef6c00;
}

.guests-amount.is-clear {
    color: #2e7d32;
}

/* Gast-Detail */
.guest-detail-notes,
.guest-detail-contact {
    color: #888;
    font-size: 0.9rem;
    margin: 0.15rem 0;
}

.badge-open {
    background: #fff3e0;
    color: #ef6c00;
}

.badge-paid {
    background: #e8f5e9;
    color: #2e7d32;
}

.month-block {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 1rem;
    margin-bottom: 1rem;
}

.month-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.month-label {
    font-weight: bold;
}

.month-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid #eee;
}

.month-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 0.4rem 0.2rem;
    cursor: pointer;
    color: #666;
    font-size: 0.9rem;
}

.month-tab.is-active {
    color: #222;
    border-bottom-color: #2e7d32;
    font-weight: bold;
}

.detail-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.detail-list li {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid #f2f2f2;
}

.detail-list li:last-child {
    border-bottom: none;
}

.detail-amount {
    font-weight: bold;
    margin-left: auto;
}

.detail-note {
    color: #888;
    font-size: 0.85rem;
}

.detail-empty {
    color: #888;
    font-size: 0.9rem;
}

/* Produkte-Verwaltung */
.product-form {
    max-width: 400px;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.btn-link {
    color: #2e7d32;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: bold;
    /* Reset fuer den Fall, dass .btn-link auf einem <button> statt einer
       <a> sitzt (z.B. .unreachable-hint-close) - fuer <a> ohnehin No-Ops */
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
    cursor: pointer;
}

.btn-link:hover {
    text-decoration: underline;
}

.product-category-block {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 0.75rem 1rem 0.25rem;
    margin-bottom: 1rem;
    overflow: hidden;
}

.product-category-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.5rem;
    cursor: pointer;
    list-style: none; /* Firefox-Aufklapp-Dreieck entfernen, eigenes Chevron statt dessen */
}

.product-category-header::-webkit-details-marker {
    display: none; /* Chrome/Safari-Aufklapp-Dreieck entfernen */
}

.product-category-title {
    font-weight: bold;
}

.details-chevron {
    display: inline-block;
    transition: transform 0.15s ease;
}

/* generisch statt an .product-category-header gebunden, damit jede
   <details><summary>-Kombination mit .details-chevron denselben Dreh-
   Effekt bekommt (z.B. auch .unreachable-hint-summary unten) */
details[open] > summary .details-chevron {
    transform: rotate(90deg);
}

.product-category-summary {
    color: #888;
    font-size: 0.85rem;
}

.products-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.products-list-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid #eee;
}

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

.products-list-name {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.products-list-price {
    color: #666;
    width: 4rem;
    text-align: right;
}

.products-list-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Zustellungs-Ueberwachung (Bounce-Hinweis) */
.bounce-hint {
    background: #fff3e0;
    color: #ef6c00;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin: 1rem 0;
    font-size: 0.9rem;
}

/* Erreichbarkeits-Uebersicht: eingeklappte <details>-Variante des
   Bounce-Hinweises, damit die ausgeschriebene Namensliste auf dem Handy
   nicht standardmaessig Platz wegnimmt (Punkt 6) */
.unreachable-hint-summary {
    cursor: pointer;
    list-style: none;
}

.unreachable-hint-summary::-webkit-details-marker {
    display: none;
}

.unreachable-hint-body {
    margin-top: 0.5rem;
}

.unreachable-hint-body p {
    margin: 0 0 0.5rem;
}

/* Mobile-first Anpassungen (Auftrag Punkt 8). Desktop-Basis bleibt wie sie
   ist - hier nur die Stellen korrigiert, die auf einem Handy tatsaechlich
   unbrauchbar waeren (kein Redesign vor der Finetuning-Phase). */
@media (max-width: 600px) {
    body {
        margin: 1rem;
    }

    .kpi-cards {
        flex-direction: column;
    }

    .kpi-card {
        flex-basis: auto;
    }

    .order-form,
    .payment-form,
    .guest-form,
    .product-form,
    .login-form {
        max-width: none;
    }

    .action-buttons .btn {
        flex: 1 1 auto;
        text-align: center;
    }

    .guests-list-item,
    .products-list-item {
        flex-direction: column;
        align-items: stretch;
    }

    .guests-list-actions {
        justify-content: space-between;
    }

    .products-list-name {
        justify-content: space-between;
    }

    .products-list-actions {
        justify-content: space-between;
    }

    .month-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.35rem;
    }

    /* Touch-Ziele vergroessern (Google/Apple empfehlen min. ~44px) */
    .qty-btn {
        width: 2.5rem;
        height: 2.5rem;
        font-size: 1.1rem;
    }

    .month-tab {
        padding: 0.6rem 0.4rem;
    }

    .btn,
    .btn-danger,
    .btn-link,
    .filter-form button {
        padding-top: 0.7rem;
        padding-bottom: 0.7rem;
    }
}
