:root {
    --gruen: #2e7d32;
    --gruen-dunkel: #1b5e20;
    --gruen-hell: #e8f5e9;
    --rot: #c62828;
    --rot-hell: #ffebee;
    --blau: #1565c0;
    --blau-hell: #e3f2fd;
    --orange: #e65100;
    --orange-hell: #fff3e0;
    --grau: #616161;
    --grau-hell: #f5f5f5;
    --rand: #ddd;
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--gruen-dunkel);
    background-image: url("/static/wald_breit.gif");
    background-repeat: repeat;
    background-position: center top;
    background-size: 1600px auto;
    color: #212121;
}

/* Kopfleiste */
.topbar {
    background: var(--gruen-dunkel);
    color: white;
    padding: 12px 16px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 8px;
    border-bottom: 2px solid white;
}

.topbar-links {
    justify-self: start;
}

.topbar-mitte {
    justify-self: center;
}

.topbar-mitte-gruppe {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.3;
}

.topbar-nutzer-info {
    font-size: 0.7rem;
    opacity: 0.85;
}

.topbar-rechts {
    justify-self: end;
    display: flex;
    align-items: center;
}

.topbar-zurueck {
    color: white;
    text-decoration: none;
    font-size: 1.4rem;
    line-height: 1;
    opacity: 0.9;
    display: flex;
    align-items: center;
}

.topbar-zurueck:hover {
    opacity: 1;
}

.topbar .logo {
    color: white;
    text-decoration: none;
    font-weight: bold;
    font-size: 1.1rem;
}

.content {
    max-width: 700px;
    margin: 0 auto;
    padding: 16px;
    background: var(--grau-hell);
    border-left: 2px solid white;
    border-right: 2px solid white;
    min-height: 100vh;
    box-sizing: border-box;
}

h1 {
    font-size: 1.4rem;
    color: var(--gruen-dunkel);
    margin-top: 0;
}

a {
    color: var(--gruen-dunkel);
}

/* Buttons */
.btn, button {
    display: inline-block;
    padding: 9px 14px;
    border: none;
    border-radius: var(--radius);
    background: var(--gruen);
    color: white;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
}

.btn:hover, button:hover {
    background: var(--gruen-dunkel);
}

.btn-danger {
    background: var(--rot);
}

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

.btn-small {
    padding: 6px 10px;
    font-size: 0.85rem;
}

.btn-block {
    display: block;
    width: 100%;
    margin-bottom: 8px;
}

.ist_bezahlt {
    background: var(--gruen);
}

.ist_unbezahlt {
    background: var(--rot);
}

/* Formulare */
form.karten-form {
    margin: 0;
    display: inline-block;
}

label {
    display: block;
    margin-top: 12px;
    font-size: 0.9rem;
    color: var(--grau);
}

label.inline-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: normal;
    margin-right: 14px;
}

label.inline-label input {
    width: auto;
    margin-top: 0;
}

input[type="text"], input[type="tel"], input[type="password"],
input[type="date"], input[type="time"], input[type="number"],
select, textarea {
    width: 100%;
    padding: 9px;
    border: 1px solid var(--rand);
    border-radius: var(--radius);
    font-size: 1rem;
    margin-top: 4px;
    font-family: inherit;
}

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

.formular-karte {
    background: white;
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Listen als Karten - Info links, Aktionen rechts */
.karten-liste {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.karte {
    position: relative;
    background: white;
    border-radius: var(--radius);
    padding: 12px 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
}

.karte-info {
    flex: 1 1 200px;
    min-width: 160px;
}

.karte-titel {
    font-weight: bold;
    margin-bottom: 4px;
}

.karte-details {
    font-size: 0.9rem;
    color: var(--grau);
    line-height: 1.5;
}

.karte-aktionen {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: flex-start;
    justify-content: flex-end;
    flex-shrink: 0;
    margin-left: auto;
}

.karte-status-aktionen-zeile {
    flex-basis: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

/* Restbetrag rot hervorheben, solange unbezahlt - damit er nicht übersehen wird */
.rest-offen {
    color: var(--rot);
    font-weight: bold;
}

.nutzer-loeschen-ecke {
    position: absolute;
    top: 12px;
    right: 14px;
}

/* "Meine Lieferungen": Statusauswahl bei schmaler Breite auf eigene Zeile
   umbrechen, dabei rechtsbündig bleiben statt an den linken Rand zu rutschen */
@media (max-width: 480px) {
    .meine_lieferungen-status-formular {
        flex-basis: 100%;
        display: flex;
        justify-content: flex-end;
    }
}

/* Am Handy: "Bezahlt/Unbezahlt"-Button ausblenden, um Platz zu sparen -
   die Information ist über die rote Restbetrag-Zahl in den Details trotzdem
   sichtbar. Übernehmen/Freigeben, Status-Auswahl und Menü bleiben immer da. */
@media (max-width: 480px) {
    .karte form.bezahlt_formular {
        display: none;
    }
}

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: bold;
}

.badge-gruen { background: var(--gruen-hell); color: var(--gruen-dunkel); }
.badge-rot { background: var(--rot-hell); color: var(--rot); }
.badge-blau { background: var(--blau-hell); color: var(--blau); }
.badge-orange { background: var(--orange-hell); color: var(--orange); }

/* Filter-/Sortierleiste */
.filterleiste {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.filterleiste a {
    padding: 5px 11px;
    border-radius: 14px;
    background: white;
    border: 1px solid var(--rand);
    text-decoration: none;
    font-size: 0.85rem;
    color: var(--grau);
}

.filterleiste a.aktiv {
    background: var(--gruen);
    color: white;
    border-color: var(--gruen);
}

/* Dashboard: gruppierte, klickbare Kennzahlen */
.kennzahl-gruppen {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.kennzahl-gruppe {
    background: white;
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    flex: 1 1 150px;
    overflow: hidden;
}

.kennzahl-gruppe-titel {
    background: var(--grau-hell);
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: bold;
    color: var(--grau);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.kennzahl-zeile {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 10px 12px;
    text-decoration: none;
    color: inherit;
    border-top: 1px solid var(--grau-hell);
}

.kennzahl-zeile:first-of-type {
    border-top: none;
}

.kennzahl-zeile:hover {
    background: var(--gruen-hell);
}

.kennzahl-zeile .zahl {
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--gruen-dunkel);
}

.kennzahl-zeile .label {
    font-size: 0.8rem;
    color: var(--grau);
}

.kennzahl-zeile .zahl.zahl-warnung {
    color: var(--rot);
}

.kennzahl-zeile .zahl.zahl-null {
    color: var(--gruen-dunkel);
}

.menu-liste {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Kunden-Autocomplete */
#vorschlaege {
    list-style: none;
    padding: 0;
    margin: 4px 0 0 0;
    background: white;
    border: 1px solid var(--rand);
    border-radius: var(--radius);
    overflow: hidden;
}

#vorschlaege li {
    padding: 9px;
    cursor: pointer;
    border-bottom: 1px solid var(--grau-hell);
}

#vorschlaege li:last-child {
    border-bottom: none;
}

#vorschlaege li:hover {
    background: var(--gruen-hell);
}

/* Login */
.login-box {
    max-width: 320px;
    margin: 60px auto;
    background: white;
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

/* Hinweistext, z.B. "Zeige 50 von 200" */
.hinweistext {
    font-size: 0.85rem;
    color: var(--grau);
    margin: 8px 0;
}

/* Overflow-Menü (Bearbeiten/Löschen bei Lieferungen) */
.mini-menu {
    position: relative;
}

.mini-menu summary {
    list-style: none;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: var(--radius);
    background: var(--grau-hell);
    border: 1px solid var(--rand);
    font-size: 0.85rem;
    color: var(--grau);
}

.mini-menu summary::-webkit-details-marker {
    display: none;
}

.mini-menu summary::marker {
    display: none;
}

.mini-menu[open] summary {
    background: var(--rand);
}

.mini-menu-inhalt {
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 4px;
    background: white;
    border: 1px solid var(--rand);
    border-radius: var(--radius);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 140px;
    z-index: 10;
}

/* Countdown-Zahlen: rot solange > 0, grün sobald erledigt (= 0) */
.kennzahl .zahl.zahl-warnung {
    color: var(--rot);
}

.kennzahl .zahl.zahl-null {
    color: var(--gruen-dunkel);
}

/* Flash-Nachrichten (kurze Rückmeldungen nach Aktionen) */
.flash-container {
    position: fixed;
    top: 64px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
    max-width: 700px;
    padding: 0 16px;
    pointer-events: none;
}
 
.flash {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    color: white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    transition: opacity 0.4s ease, transform 0.4s ease;
}
 
.flash-ausblendend {
    opacity: 0;
    transform: translateY(-8px);
}
 
.flash-erfolg { background: var(--gruen); }
.flash-warnung { background: var(--orange); }
.flash-fehler { background: var(--rot); }
.flash-info { background: var(--blau); }
 
.flash-schliessen {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    opacity: 0.85;
}
 
.flash-schliessen:hover {
    opacity: 1;
}


/* Chat */
.chat-symbol-button {
    position: relative;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius);
    line-height: 1;
    text-decoration: none;
    display: inline-block;
}

.chat-symbol-button:hover {
    background: rgba(255, 255, 255, 0.25);
}

.chat-benachrichtigung {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 9px;
    height: 9px;
    background: var(--rot);
    border-radius: 50%;
    border: 1.5px solid var(--gruen-dunkel);
}

.chat-verlauf {
    background: white;
    border-radius: var(--radius);
    padding: 12px 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 16px;
    max-height: 60vh;
    overflow-y: auto;
}

.chat-zeile {
    margin: 0 0 10px 0;
    font-size: 0.95rem;
    line-height: 1.4;
}

.chat-zeit {
    color: var(--grau);
    font-size: 0.75rem;
}

.chat-formular {
    display: flex;
    gap: 8px;
}

.chat-formular input[type="text"] {
    flex: 1;
    margin-top: 0;
}

.chat-name {
    font-weight: bold;
}

.chat-farbe-0 { color: #1b5e20; }
.chat-farbe-1 { color: #0d47a1; }
.chat-farbe-2 { color: #e65100; }
.chat-farbe-3 { color: #4a148c; }
.chat-farbe-4 { color: #b71c1c; }
.chat-farbe-5 { color: #004d40; }
.chat-farbe-6 { color: #795548; }
.chat-farbe-7 { color: #37474f; }
