:root {
    --brand: #0b6e4f;
    --brand-dark: #084f39;
    --bread: #c4693a;
    --bg: #f7f6f2;
    --surface: #ffffff;
    --border: #e2e0d8;
    --text: #1b1f1a;
    --muted: #6b6f68;
    --danger: #a4311a;
    --info: #1f5f8f;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

/* iOS Safari + Chrome Mobile blasen den Text in schmalen Tabellen-Spalten
   automatisch auf („text inflation", wenn z. B. Funktion bzw. einzelne
   td-Werte schmaler sind als die übrigen Spalten). Mit 100% bleibt die
   tatsächlich gesetzte Schriftgröße erhalten und die Spalten sehen
   konsistent zum Desktop aus. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    /* Lange Woerter, Namen, Mailadressen und Links duerfen nie aus Karten,
       Kacheln oder dem Bildschirm laufen (11.11.2026: „Datenschutzschulung"
       ragte auf dem Handy aus der Newskarte). anywhere statt break-word,
       weil es auch die Mindestbreite senkt: sonst wird ein Flex-/Grid-
       Element nie schmaler als sein laengstes Wort. */
    overflow-wrap: anywhere;
}
/* Ueberschriften trennen deutsch (lang="de") statt mitten im Wort zu
   brechen, aber erst ab 10 Buchstaben. */
h1, h2, h3, h4 {
    -webkit-hyphens: auto; hyphens: auto;
    hyphenate-limit-chars: 10 4 4;
}
/* Tabellen, Knoepfe, Badges: kurze feste Texte nicht zerbrechen. Tabellen
   scrollen auf dem Handy in ihrem Wrapper (.data-table/.table-scroll). */
table, button, .btn, .badge, time { overflow-wrap: break-word; }

a { color: var(--brand); }
a:hover { color: var(--brand-dark); }

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    /* fixed statt sticky – sticky hat sich auf breiten Displays in
       Kombination mit FullCalendar als unzuverlässig erwiesen. fixed
       ist garantiert sichtbar, der body bekommt unten padding-top zum
       Ausgleich. */
    position: fixed; top: 0; left: 0; right: 0; z-index: 1500;
    gap: 12px;
}
body.app-body {
    /* Höhe des fixierten App-Headers (Default-Logo 32 px + 12 px Padding
       oben/unten + 1 px Border = ca. 57 px). Etwas Reserve für höhere
       Logos. */
    padding-top: 60px;
}
@media (max-width: 840px) {
    body.app-body { padding-top: 56px; }
}
.app-header .brand {
    display: flex;
    gap: 10px;
    align-items: center;
    color: var(--brand);
    font-weight: 700;
    text-decoration: none;
}
.app-nav { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.app-nav a { color: var(--text); text-decoration: none; font-weight: 500; padding: 6px 2px; }
.app-nav a:hover { color: var(--brand); }

.nav-toggle {
    display: none;
    background: transparent;
    border: 0;
    font-size: 1.7em;
    line-height: 1;
    cursor: pointer;
    padding: 4px 10px;
    color: var(--text);
}

.user-menu { position: relative; }
.user-menu summary {
    list-style: none; cursor: pointer; padding: 6px 10px;
    border-radius: var(--radius); background: var(--bg);
}
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu .menu-panel {
    position: absolute; right: 0; top: 100%; margin-top: 4px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    min-width: 200px; padding: 8px;
    z-index: 1600;
}
/* Leaflet-Tiles dürfen nicht über die Sticky-Navigation rutschen */
.leaflet-pane, .leaflet-top, .leaflet-bottom { z-index: 400 !important; }
.map-canvas { position: relative; z-index: 1; }
.user-menu .menu-panel a, .user-menu .menu-panel button {
    display: block; padding: 8px 10px; text-decoration: none;
    color: var(--text); border-radius: 6px; width: 100%; text-align: left;
}
.user-menu .menu-panel a:hover, .user-menu .menu-panel button:hover {
    background: var(--bg);
}

/* Verwaltungs-Mega-Menue: mehrspaltiges Aufklapp-Panel mit Abschnitten.
   Desktop: auto-fit-Grid faechert die Abschnitte nebeneinander auf,
   sodass das Menue nicht endlos in die Hoehe waechst. Auf dem Handy
   greift die Stack-Regel weiter unten. */
.user-menu.mega-menu .menu-panel.mega-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    width: max-content;
    max-width: min(720px, 95vw);
    gap: 8px 14px;
    padding: 14px;
}
.user-menu.mega-menu .mega-section { min-width: 0; }
.user-menu.mega-menu .mega-h {
    margin: 0 0 6px;
    padding: 0 4px 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
}
.user-menu.mega-menu .mega-section a {
    padding: 6px 8px;
    font-size: 14px;
    border-radius: 6px;
}
.linklike { border: 0; background: transparent; cursor: pointer; font: inherit; }

/* Anbieter-Header-Galerie: mehrere Header-Bilder lueckenlos in einer
   Reihe am PC, untereinander am Handy. object-fit: cover sorgt fuer
   gleiche Hoehe ohne weisse Raender. */
.vendor-header-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    grid-auto-flow: column;
    gap: 0;
    margin-bottom: 14px;
    border-radius: var(--radius);
    overflow: hidden;
    background: #f4f4f0;
}
.vendor-header-gallery img {
    display: block;
    width: 100%;
    height: 320px;
    object-fit: cover;
}
@media (max-width: 720px) {
    .vendor-header-gallery {
        grid-auto-flow: row;
        grid-template-columns: 1fr;
    }
    .vendor-header-gallery img { height: auto; max-height: 360px; }
}

/* Tippspiel-Kachel-Layout: jede Spielphase hat einen farbig hinter-
   legten Bereich, darin liegen die einzelnen Spiele als helle Kacheln.
   Desktop: Auto-fill mit minmax(260px, 1fr); Mobile (<560px): 1 Spalte. */
.wm-stage {
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 18px;
    border: 1px solid transparent;
}
.wm-stage h2 { font-size: 18px; }
.wm-stage-group        { background: #f3f4f6; border-color: #d1d5db; }
.wm-stage-round_of_32  { background: #e0f2fe; border-color: #93c5fd; }
.wm-stage-round_of_16  { background: #dcfce7; border-color: #86efac; }
.wm-stage-quarter      { background: #fef3c7; border-color: #fcd34d; }
.wm-stage-semi         { background: #ffedd5; border-color: #fdba74; }
.wm-stage-third_place  { background: #ede9fe; border-color: #c4b5fd; }
.wm-stage-final        { background: #fef9c3; border-color: #facc15; box-shadow: 0 0 0 3px #fde68a inset; }
.wm-match-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 10px;
}
@media (max-width: 560px) {
    .wm-match-grid { grid-template-columns: 1fr; }
}
.wm-match {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 140px;
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.wm-points-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 12px;
}
.wm-points-good { background: #dcfce7; color: #14532d; }
.wm-points-ok   { background: #fef3c7; color: #7a4a00; }
.wm-points-zero { background: #f3f4f6; color: #4b5563; }


/* Chat-Kachel-Grid: zeilenweise auto-Fill, max. 5 Spalten am PC,
   1 Spalte auf dem Handy. */
.chat-tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    max-width: 1240px;
}
@media (min-width: 1080px) {
    .chat-tile-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}
@media (max-width: 720px) {
    .chat-tile-grid { grid-template-columns: 1fr; }
}
.chat-tile {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface, #fff);
    text-decoration: none;
    color: inherit;
    min-height: 140px;
    transition: box-shadow .12s, border-color .12s;
}
.chat-tile:hover { border-color: var(--brand); box-shadow: 0 2px 6px rgba(0,0,0,.06); }
.chat-tile-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}
.chat-tile-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
.chat-tile-time { margin-top: auto; font-size: 11px; }
.chat-tile-badge {
    flex: 0 0 auto;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--brand);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
}
.chat-tile-add {
    align-items: center;
    justify-content: center;
    text-align: center;
    border: 2px dashed var(--brand);
    color: var(--brand);
    font-weight: 600;
    background: transparent;
}
.chat-tile-add .chat-tile-plus { font-size: 32px; line-height: 1; }
.chat-tile-add:hover { border-color: var(--brand); background: rgba(11,110,79,.04); }

.app-main {
    max-width: 1400px; margin: 0 auto;
    /* Bottom-Padding gross genug, damit der letzte Button auch dann
       sichtbar ist, wenn iOS Safari die Bottom-Bar einblendet und der
       Viewport schrumpft. env(safe-area-inset-bottom) deckt zusaetzlich
       die Home-Indicator-Zone auf iPhones mit Notch ab. */
    padding: 24px 20px;
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
}
.app-footer { text-align: center; color: var(--muted); padding: 24px; }

.page-header {
    display: flex; justify-content: space-between; align-items: center;
    gap: 16px; flex-wrap: wrap; margin-bottom: 16px;
}

.auth-card {
    max-width: 420px; margin: 40px auto; padding: 28px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
}
.auth-card h1 { margin-top: 0; }

form label { display: block; margin-bottom: 12px; font-weight: 500; }
form input, form select, form textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border);
    border-radius: 8px; background: var(--surface); font: inherit;
    box-sizing: border-box;
}
/* Datums- und Zeitfelder auf dem iPhone: Safari zeichnet sie als eigenes
   Bedienelement und rechnet dabei Innenabstand und Rahmen ZUSAETZLICH zur
   Breite (box-sizing wirkt dort nicht). Bei width:100% ragten sie 26 px aus
   Karte oder Bildschirm und waren hoeher als die anderen Felder
   (12.11.2026, „Stunden & Taetigkeit erfassen", 55 Felder auf 32 Seiten).
   appearance:none macht daraus ein normales Feld; Antippen oeffnet
   weiterhin die Datumsauswahl. max-width/min-width halten Filter-Leisten
   mit fester Mindestbreite im Rahmen — auch ausserhalb von <form>. */
input[type="date"], input[type="datetime-local"], input[type="time"],
input[type="month"], input[type="week"] {
    max-width: 100%; min-width: 0; box-sizing: border-box;
    -webkit-appearance: none; appearance: none;
}
/* Ohne eigenes Bedienelement setzt iOS den Wert mittig und laesst ein
   leeres Feld zusammenfallen. Eigene Regel: Browser ohne dieses
   Pseudo-Element verwerfen sonst die ganze Liste. */
input::-webkit-date-and-time-value {
    text-align: left; min-height: 1.25em;
}
/* iOS zoomt beim Antippen in jedes Feld mit weniger als 16 px Schrift hinein
   und bleibt danach gezoomt – die Seite wirkt verrutscht, bis man von Hand
   herauszoomt. Felder in <form> erben 16 px ueber font: inherit; Such- und
   Filterfelder ausserhalb eines Formulars hatten die Browser-Vorgabe (13 px)
   oder eine kleinere Inline-Schrift (Postfach-Suche, Pflicht-Uebersicht,
   Tippspiel-Verwaltung, Kalender-Abo-Link). Handys ueber die Breite,
   Tablets ueber die Touch-Erkennung; breite Desktop-Fenster bleiben wie sie
   sind. */
@media (max-width: 820px), (hover: none), (pointer: coarse) {
    input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]):not([type=file]):not([type=submit]):not([type=button]):not([type=reset]):not([type=image]),
    select, textarea {
        font-size: 16px !important;
    }
}
/* Einheitliche feste Höhe für Eingabefelder. Browser-Defaults rendern
   <select> deutlich kürzer als <input> — erst explizite height + custom
   Pfeil-Icon zwingt sie auf dieselbe Linie. */
form input, form select {
    height: 42px;
    line-height: 20px;
}
form select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%236b7280' stroke='%236b7280' d='M1 1l5 5 5-5' fill-opacity='0'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px 8px;
    padding-right: 32px;
}
form input[type=color], form input[type=checkbox], form input[type=radio],
form input[type=file] {
    height: auto;
}
form textarea { min-height: 80px; }
form input[type=color] {
    width: 80px; height: 44px; padding: 4px;
    cursor: pointer;
}
form input:focus, form select:focus, form textarea:focus {
    outline: 2px solid var(--brand); outline-offset: 1px;
}
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin: 0 0 12px 0; }
fieldset legend { font-weight: 600; padding: 0 6px; }
label.checkbox { font-weight: 400; display: inline-flex; align-items: center; gap: 6px; margin-right: 16px; }
label.checkbox input { width: auto; }

.btn {
    display: inline-block; padding: 10px 16px; border: 1px solid var(--border);
    background: var(--surface); border-radius: 8px; text-decoration: none;
    color: var(--text); cursor: pointer; font: inherit;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-dark); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #862815; color: #fff; }
.btn-sm { padding: 6px 10px; font-size: 0.9em; }

/* Globaler Zurück-Pfeil: kompakt (nur „←"), sitzt links neben der
   Seitenüberschrift. Wird per JS aus base.html in den page-header bzw.
   neben das erste <h1> einsortiert. */
.kini-back {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; flex: 0 0 34px; padding: 0;
    border: 1px solid var(--border); border-radius: 8px;
    background: var(--surface); color: var(--text);
    font-size: 20px; line-height: 1; text-decoration: none;
}
.kini-back:hover { background: var(--bg); }
.kini-back--standalone { margin: 10px 0 4px; }
/* In der page-header-Flexzeile: Pfeil + Titel links zusammenhalten,
   evtl. vorhandene Action-Buttons bleiben rechts. */
.page-header.has-back > h1 { margin-right: auto; }
/* Seiten ohne page-header: Pfeil + <h1> in einer Flex-Zeile. */
.kini-back-row { display: flex; align-items: center; gap: 12px; }
.kini-back-row > h1 { margin-top: 0; margin-bottom: 0; }
/* Titel neben dem Pfeil darf schmaler werden als sein laengstes Wort. */
.kini-back-row > h1, .page-header > h1, .page-header > div { min-width: 0; }

.form-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.stacked { max-width: 520px; }

.alert { padding: 10px 14px; border-radius: 8px; margin: 0 0 16px; }
.alert-error { background: #fbe7e1; color: var(--danger); border: 1px solid #f1b8a8; }
.alert-info  { background: #e3eef9; color: var(--info);   border: 1px solid #b9d2e9; }
/* Mehrere Seiten nutzen die Bootstrap-Namen – sie waren ungestylt (QA 17.11.2026). */
.alert-danger { background: #fbe7e1; color: var(--danger); border: 1px solid #f1b8a8; }
.alert-success { background: #e6f4ec; color: #0b6e4f; border: 1px solid #b7dcc7; }
.alert ul { margin: 0; padding-left: 20px; }
/* Interne Notiz im Ticket: auf einen Blick von Nachrichten an den
   Einreicher zu unterscheiden (Christiani 2026-11-17). */
.ticket-nachricht--intern { background: #fff8db; border-color: #ecd77a !important; }
.ticket-nachricht__intern { font-size: 12px; font-weight: 600; color: #7a5d00; margin-bottom: 2px; }

.muted { color: var(--muted); }

.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px 20px; margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.grid-2 { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

.news-list, .event-list, .location-list { list-style: none; margin: 0; padding: 0; }
.news-list li, .event-list li { padding: 8px 0; border-bottom: 1px dashed var(--border); }
.news-list li:last-child, .event-list li:last-child { border-bottom: 0; }
.news-list h3, .event-list h3 { margin: 4px 0; }
.news-list time, .event-list time { color: var(--muted); font-size: 0.9em; }

.data-table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.data-table th, .data-table td {
    padding: 10px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top;
}
.data-table th { background: var(--bg); }

/* Wrapper für horizontale Scrollbarkeit auf Handy. Auf Wide ohne
   Effekt – das umschlossene Table behält seine 100%-Breite.
   Innerhalb der mobilen Breakpoints lassen wir das Table seine
   natürliche Breite annehmen, sodass overflow-x echte Spalten
   nach rechts scrollen lässt. */
.table-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.table-scroll .data-table {
    min-width: 720px;
    white-space: nowrap;
}
.table-scroll .data-table th,
.table-scroll .data-table td { white-space: nowrap; }
/* Opt-in: Spalten / Zellen, die längere Beschreibungstexte enthalten und
   in der Tabelle umbrechen sollen, statt seitlich rauszuwachsen. */
.table-scroll .data-table th.cell-wrap,
.table-scroll .data-table td.cell-wrap,
.data-table th.cell-wrap,
.data-table td.cell-wrap {
    white-space: normal;
    max-width: 360px;
}
.data-table .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Ticketliste (Christiani 2026-11-07: Liste statt Kacheln, Gruppen mit
   einer Zeile Abstand). Auf dem Handy fallen Spalten weg; Datum, Melder
   und Prioritaet stehen dann unter dem Titel. */
.ticket-liste { width: 100%; border-collapse: collapse; margin: 8px 0 16px; }
.ticket-liste th, .ticket-liste td {
    padding: 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top;
}
.ticket-liste thead th { background: var(--bg); font-size: 0.9em; }
.ticket-liste td.nr { white-space: nowrap; font-variant-numeric: tabular-nums; }
/* Die Liste hat keinen Scroll-Wrapper: ein langer Titel bricht um statt
   die Tabelle ueber den Bildschirm hinaus aufzureissen. Nur der Titel –
   sonst quetscht die Tabelle Status und Namen mitten im Wort. */
.ticket-liste td.titel { overflow-wrap: anywhere; -webkit-hyphens: auto; hyphens: auto; }
.ticket-liste tr.gruppe th { border-bottom: 2px solid var(--border); padding-top: 14px; }
.ticket-liste tbody.abstand td { border: 0; height: 22px; padding: 0; }
.ticket-liste .nur-schmal { display: none; }
@media (max-width: 720px) {
    .ticket-liste .nur-breit { display: none; }
    .ticket-liste .nur-schmal { display: block; }
    .ticket-liste th, .ticket-liste td { padding: 8px 4px; }
}
.data-table .actions form { margin: 0; }

.role-tag {
    display: inline-block; margin: 1px 2px; padding: 2px 8px;
    border-radius: 999px; background: #e6efe9; color: var(--brand-dark);
    font-size: 0.8em; font-weight: 600;
}

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.75em; font-weight: 700; vertical-align: middle; }
.badge-bread { background: var(--bread); color: #fff; }
.badge-snack { background: #1f5f8f; color: #fff; }

.map-canvas { height: 420px; border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 16px; }

.code-block {
    display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
    padding: 16px; border: 2px dashed var(--brand);
    background: #ecf5f0; border-radius: var(--radius); margin: 16px 0;
}
.code-block code {
    font-size: 1.7em; font-weight: 700; letter-spacing: 2px;
    color: var(--brand-dark); font-family: "SF Mono", Menlo, monospace;
}

/* Brot / Bäckerei */
.bread-grid {
    display: grid; gap: 16px;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.bread-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden;
    box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.bread-card.bread-inactive { opacity: 0.55; }
.bread-card-wide { flex-direction: row; align-items: center; gap: 16px; padding-right: 20px; }
.bread-card-wide .bread-image { max-width: 200px; border-right: 1px solid var(--border); }
.bread-image {
    width: 100%; height: 160px; object-fit: contain;
    background: #f6ecd6;
}
/* .bread-body wird zur flex column und streckt sich auf die volle Hoehe,
   damit der Preis unten-links fixiert werden kann (margin-top:auto),
   egal wie lang der Beschreibungstext ist. */
.bread-body {
    padding: 16px 20px; display: flex; flex-direction: column; gap: 6px;
    flex: 1 1 auto;
}
.bread-body h2 { margin: 0; }
.bread-body h3 { margin: 0; }
.bread-price {
    font-size: 1.2em; font-weight: 700; color: var(--bread);
    margin: 12px 0 0; padding-top: 8px;
    align-self: flex-start;
    margin-top: auto;
}

.card-link { display: block; text-decoration: none; color: var(--text); }
.card-link:hover { box-shadow: 0 3px 8px rgba(0,0,0,0.1); }

.filter-row {
    display: flex; gap: 12px; align-items: end; flex-wrap: wrap;
    margin: 0 0 16px 0;
}
.filter-row label { margin: 0; }
.filter-row label input[type=date] { min-width: 170px; }

.image-picker {
    display: grid; gap: 8px;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
}
.image-option {
    border: 2px solid var(--border); border-radius: 8px; padding: 6px;
    text-align: center; cursor: pointer; background: var(--surface); font-weight: 400;
    display: flex; flex-direction: column; align-items: center; gap: 4px; margin: 0;
}
.image-option.selected { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(11,110,79,0.2); }
.image-option input { display: none; }
.image-option img { width: 100%; height: 70px; object-fit: contain; background: #f6ecd6; border-radius: 4px; }
.image-option span { font-size: 0.8em; }

.row-cancelled td { text-decoration: line-through; color: var(--muted); }

/* Bild-Galerie für Admin und Public-Detail */
.image-grid {
    display: grid; gap: 10px;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    margin: 0 0 12px 0;
}
.image-tile {
    margin: 0; padding: 0;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 8px; overflow: hidden;
    display: flex; flex-direction: column;
}
.image-tile img {
    width: 100%; height: 140px; object-fit: contain; background: var(--bg);
}
.image-tile figcaption {
    padding: 6px 8px; font-size: 0.85em; color: var(--text);
    border-top: 1px solid var(--border);
}
.image-tile form { padding: 0 8px 8px 8px; }
.image-tile form button { width: 100%; }

/* Spalten-Header mit Sort-Link + Filter-Popover */
.colhead-table th { position: relative; }
.col-head-row { display: inline-flex; align-items: center; gap: 4px; }
.col-sort {
    color: var(--text); text-decoration: none; font-weight: 600;
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 6px; border-radius: 6px;
    cursor: pointer;
}
.col-sort:hover { background: var(--bg); color: var(--brand); }
/* Neutraler Sortier-Indikator auf inaktiven Spalten: dezent gemutet,
   damit erkennbar ist, dass die Spalte überhaupt sortierbar ist. Wird
   im Template als <span class="col-sort-arrow">↕</span> ausgegeben. */
.col-sort-arrow { color: var(--muted); font-size: 12px; }
.col-sort-arrow.active { color: var(--brand); font-size: 13px; }
.col-filter-btn {
    background: transparent; border: 0; padding: 2px 8px; cursor: pointer;
    color: var(--muted); border-radius: 4px;
    font-size: 18px; line-height: 1;
}
.col-filter-btn:hover { background: var(--bg); color: var(--text); }
.col-filter-btn.active { background: var(--brand); color: #fff; }
.col-filter-pop {
    /* Position:fixed escape klippender Tabellen-Container (table-scroll
       hat overflow-x:auto → setzt implizit overflow-y auch auf auto und
       würde sonst das Popup abschneiden).
       Desktop: JS verankert das Popup direkt unter der Lupe (siehe
       app.js → placeFilterPops()). Mobile: CSS überschreibt unten zu
       einem zentrierten Viewport-Modal. */
    position: fixed; z-index: 1500;
    top: 60px; left: 50%; transform: translateX(-50%);
    background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: 0 12px 32px rgba(0,0,0,0.28);
    padding: 16px;
    width: 320px;
    box-sizing: border-box;
    max-height: calc(100vh - 32px);
    /* overflow-x: hidden ist die Sicherheitsleine: selbst wenn ein
       Input doch zu breit wird, schneidet der Card-Rand es ab. Y bleibt
       scrollbar für lange Formulare. */
    overflow-x: hidden; overflow-y: auto;
    font-weight: 400;
}
/* Im Popup alles strikt auf Container-Breite zwingen. */
.col-filter-pop form,
.col-filter-pop label {
    display: block; max-width: 100%; box-sizing: border-box;
}
.col-filter-pop input, .col-filter-pop select, .col-filter-pop textarea {
    width: 100%; max-width: 100%; box-sizing: border-box; min-width: 0;
    display: block;
}
@media (max-width: 720px) {
    /* Mobile: zentriertes Modal über dem ganzen Viewport. */
    .col-filter-pop {
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        width: min(360px, calc(100vw - 24px)) !important;
    }
}
.col-filter-pop label { display: block; margin: 0 0 10px 0; font-size: 0.9em; }
.col-filter-pop input,
.col-filter-pop select {
    width: 100%; padding: 8px 10px; box-sizing: border-box;
}
.filter-pop-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 4px; }

/* Badge-Punkt mit Zahl (Burger-Menü + Menü-Einträge). Farbe = Mandanten-
   Primärfarbe, weiße Schrift. Erscheint absolute oben-rechts am
   Trigger-Element (Burger-Icon oder Menü-Link). Kompakte zweistellige
   Anzeige (99+ bei Überlauf). */
.badge-dot {
    display: inline-flex;
    align-items: center; justify-content: center;
    min-width: 18px; height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--brand, #0b6e4f);
    color: #fff;
    font-size: 11px; font-weight: 700; line-height: 1;
    white-space: nowrap;
    border: 2px solid var(--surface, #fff);
    box-sizing: content-box;
}
.badge-dot--corner {
    position: absolute; top: -6px; right: -8px; pointer-events: none;
}
.badge-trigger { position: relative; }
.menu-panel a { position: relative; }
.menu-panel .badge-dot {
    margin-left: auto; border: 0; padding: 0 6px;
}

[x-cloak] { display: none !important; }

/* Dashboard-Kacheln (Challenges, Tippspiele …) – einheitliche Maße,
   damit Bike-to-Work + WM + CL untereinander gleich breit sind. */
.wm-tile-row {
    display: grid;
    gap: 16px;
    /* Auf Desktop: jede Kachel zwischen 280 und 420 px breit, mehrere
       passen nebeneinander. Bei nur einer Challenge bleibt die Kachel
       kompakt statt die ganze Zeile zu füllen. */
    grid-template-columns: repeat(auto-fit, minmax(280px, 420px));
    justify-content: start;
    margin-bottom: 18px;
}
@media (max-width: 720px) {
    /* Auf dem Handy nimmt jede Kachel die volle Breite ein. */
    .wm-tile-row { grid-template-columns: 1fr; }
}
.wm-tile {
    --tile-c1: #0b6e4f;
    --tile-c2: #14a273;
    /* Kein Fußball-Wasserzeichen auf Nicht-Fußball-Kacheln (QA 17.11.2026):
       das Motiv hängt am Ziel der Kachel; eigenes per --tile-emoji im style. */
    --tile-emoji: "";
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: #fff;
    background: linear-gradient(135deg, var(--tile-c1) 0%, var(--tile-c2) 100%);
    border-radius: 14px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.12);
    padding: 16px 18px;
    min-height: 240px;
    transition: transform 0.12s ease, box-shadow 0.15s ease;
    position: relative;
    overflow: hidden;
}
.wm-tile[href^="/wm"] { --tile-emoji: "⚽"; }
.wm-tile[href^="/service/pinguin-weitwurf"] { --tile-emoji: "🐧"; }
.wm-tile[href^="/service/schaetzfrage"] { --tile-emoji: "🤔"; }
.wm-tile[href^="/service/zahlensprint"] { --tile-emoji: "🔢"; }
.wm-tile::after {
    content: var(--tile-emoji);
    position: absolute;
    right: -10px; bottom: -16px;
    font-size: 110px; opacity: 0.10;
    line-height: 1; pointer-events: none;
}
.wm-tile:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,0.18); color: #fff; }
.wm-tile-head {
    display: flex; align-items: baseline; justify-content: space-between;
    /* rechts Platz lassen, damit die Punktzahl nicht unter dem
       Ausblenden-Knopf (× oben rechts) sitzt. */
    gap: 10px; margin-bottom: 10px; padding-right: 26px;
}
.wm-tile-title { font-size: 0.85em; text-transform: uppercase; letter-spacing: 0.6px; opacity: 0.9; }
.wm-tile-points {
    font-size: 1.5em; font-weight: 800; line-height: 1;
}
.wm-tile-points small { font-size: 0.55em; font-weight: 500; opacity: 0.85; display: block; }
.wm-tile-section { margin-top: 10px; }
.wm-tile-section h4 {
    margin: 0 0 2px 0; font-size: 0.75em; text-transform: uppercase;
    letter-spacing: 0.5px; opacity: 0.8;
}
.wm-tile-match { font-size: 0.97em; line-height: 1.3; }
.wm-tile-when { font-size: 0.78em; opacity: 0.78; }
.wm-tile-leaders {
    margin: 4px 0 0 0; padding: 0; list-style: none;
    font-size: 0.85em;
}
.wm-tile-leaders li {
    display: flex; gap: 6px; padding: 1px 0;
    border-bottom: 1px dashed rgba(255,255,255,0.18);
}
.wm-tile-leaders li:last-child { border-bottom: 0; }
.wm-tile-leaders .pts { margin-left: auto; opacity: 0.9; }
.wm-tile .muted { color: rgba(255,255,255,0.7); }
/* Persoenliches Ausblenden einer Challenge-Kachel: der ×-Knopf darf NICHT
   im <a> liegen (ungueltiges HTML + wuerde die Kachel-Navigation ausloesen),
   deshalb ein relativer Wrapper mit dem Knopf als Geschwister-Element. */
.wm-tile-wrap { position: relative; display: flex; }
.wm-tile-wrap > .wm-tile { flex: 1 1 auto; width: 100%; }
/* Die Form beansprucht kein eigenes Layout; nur der absolute Knopf zaehlt. */
.wm-tile-hide-form { display: contents; }
.wm-tile-hide {
    position: absolute; top: 6px; right: 6px; z-index: 3;
    /* 26 px waren auf dem Handy kaum zu treffen (QA 17.11.2026). */
    width: 36px; height: 36px; padding: 0;
    display: flex; align-items: center; justify-content: center;
    border: 0; border-radius: 50%;
    background: rgba(0,0,0,0.28); color: #fff;
    font-size: 20px; line-height: 1; cursor: pointer;
    opacity: 0.72; transition: opacity 0.12s ease, background 0.12s ease;
}
.wm-tile-hide:hover { opacity: 1; background: rgba(0,0,0,0.45); }
/* Schalter 'Auf meinem Dashboard anzeigen' auf den Challenge-Seiten. */
.dash-toggle { margin: 10px 0; }
.dash-toggle-lbl {
    display: inline-flex; align-items: center; gap: 8px;
    margin: 0; cursor: pointer; font-size: 0.92em; color: var(--text);
}

/* Sub-Navigation auf den Tippspiel-Unterseiten */
.wm-subnav {
    display: flex; gap: 8px; flex-wrap: wrap;
    margin: 0 0 18px 0; padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

/* Allgemeine Sub-Navigation für Backoffice-Seiten (Vendor-Backoffice etc.) */
.subnav {
    display: flex; gap: 12px; flex-wrap: wrap;
    margin: 4px 0 18px 0; padding: 6px 0 10px 0;
    border-bottom: 1px solid var(--border);
}
.subnav a { color: var(--text); text-decoration: none; padding: 4px 6px; }
.subnav a.is-active { font-weight: 700; border-bottom: 2px solid var(--brand); }
.subnav a:hover { text-decoration: underline; }

/* Vorrundentabellen */
.group-grid {
    display: grid; gap: 14px;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    margin-bottom: 24px;
}
.group-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    overflow: hidden;
}
.group-card-head {
    padding: 6px 10px;
    background: var(--brand); color: #fff; font-weight: 700;
}
.group-card-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.group-table {
    width: 100%; min-width: 100%;
    border-collapse: collapse;
    background: transparent;
}
.group-table th, .group-table td {
    padding: 4px 4px; font-size: 0.82em; text-align: center;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.group-table td:nth-child(2) { white-space: normal; }
.group-table th { background: var(--bg); }
.group-table td:nth-child(2) { text-align: left; }
.group-table tr.rank-1 { background: rgba(11,110,79,0.10); }
.group-table tr.rank-2 { background: rgba(11,110,79,0.05); }
.group-table tr.rank-3 { background: rgba(180,134,11,0.06); }

/* Aufklapp-Sektion 'bereits abgelaufene Spiele' im Tippspiel */
.wm-stage details > summary::-webkit-details-marker { display: none; }
details.wm-stage[open] > summary { border-bottom: 1px solid var(--border); }

/* Trichter-Spielbaum von oben nach unten */
.bracket-funnel {
    display: flex; flex-direction: column; gap: 14px;
    align-items: stretch;
}
.bracket-funnel .funnel-row { width: 100%; }
.bracket-funnel .funnel-row h3 {
    text-align: center; margin: 0 0 8px 0;
    font-size: 0.95em; text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--muted);
}
.funnel-matches {
    display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
}
.funnel-cell {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; padding: 8px 10px; min-width: 160px;
    box-shadow: var(--shadow); text-align: center; font-size: 0.9em;
}
.funnel-cell.is-done { border-color: var(--brand); }
.funnel-when { font-size: 0.75em; color: var(--muted); margin-bottom: 4px; }
.funnel-team { line-height: 1.3; }
.funnel-slot { color: var(--muted); font-style: italic; font-size: 0.92em; }
.funnel-score { margin-top: 4px; color: var(--brand-dark); font-size: 1.05em; }

/* Mannschaftspfad-Hervorhebung */
.bracket-team-picker {
    display: flex; gap: 12px; flex-wrap: wrap; align-items: center;
    margin: 0 0 16px 0; padding: 10px 14px;
    background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
}
.bracket-team-picker label { margin: 0; }
.path-legend { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.legend-pill {
    padding: 2px 10px; border-radius: 999px; font-size: 0.82em; font-weight: 600;
    color: #fff;
}
.legend-pill.path-first  { background: #d1495b; }
.legend-pill.path-second { background: #2e86ab; }
.legend-pill.path-third  { background: #e29c3b; }

.funnel-cell.path-first  { box-shadow: 0 0 0 3px #d1495b inset, var(--shadow); }
.funnel-cell.path-second { box-shadow: 0 0 0 3px #2e86ab inset, var(--shadow); }
.funnel-cell.path-third  { box-shadow: 0 0 0 3px #e29c3b inset, var(--shadow); }
/* Wenn ein Match in mehreren Pfaden liegt: kombinierte Border über mehrere Insets. */
.funnel-cell.path-first.path-second {
    box-shadow: 0 0 0 3px #d1495b inset, 0 0 0 6px #2e86ab inset, var(--shadow);
}
.funnel-cell.path-first.path-third {
    box-shadow: 0 0 0 3px #d1495b inset, 0 0 0 6px #e29c3b inset, var(--shadow);
}
.funnel-cell.path-second.path-third {
    box-shadow: 0 0 0 3px #2e86ab inset, 0 0 0 6px #e29c3b inset, var(--shadow);
}
.funnel-cell.path-first.path-second.path-third {
    box-shadow:
        0 0 0 3px #d1495b inset,
        0 0 0 6px #2e86ab inset,
        0 0 0 9px #e29c3b inset,
        var(--shadow);
}

/* Letzte Reihe: Spiel um Platz 3 links außen, Finale zentriert. */
.funnel-row-final {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 14px;
    align-items: start;
}
.funnel-row-final .funnel-side h3 {
    text-align: center; margin: 0 0 8px 0;
    font-size: 0.95em; text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--muted);
}
.funnel-row-final .funnel-side-left { justify-self: start; }
.funnel-row-final .funnel-side-center { justify-self: center; }
.funnel-row-final .funnel-side-right { /* Platzhalter für Symmetrie */ }
@media (max-width: 720px) {
    .funnel-row-final { grid-template-columns: 1fr; }
    .funnel-row-final .funnel-side-left,
    .funnel-row-final .funnel-side-center { justify-self: stretch; }
}

/* Eingebettete externe Anwendungen (z. B. Minijob-Zeitapp) */
.iframe-wrap {
    position: relative;
    width: 100%;
    height: calc(100vh - 240px);
    min-height: 500px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
}
.iframe-wrap iframe {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    border: 0;
}

/* ----------------------------------------------------------
 * Mobile-Layout (schmale Displays, z. B. Handy)
 * Desktop-first: nur hier überschreiben
 * ---------------------------------------------------------- */
@media (max-width: 840px) {
    .app-header { padding: 10px 14px; }
    .nav-toggle { display: block; }

    .app-nav {
        display: none;
        flex-direction: column;
        /* WICHTIG: flex-wrap explizit auf nowrap. Der Desktop-Default
           ist 'wrap' – in Kombination mit flex-direction:column und
           max-height führt das dazu, dass das Menü in eine zweite
           Spalte rechts daneben umbricht, sobald die Inhalte zu
           hoch werden (z. B. Verwaltungs-Submenü mit vielen Items). */
        flex-wrap: nowrap;
        align-items: stretch;
        position: absolute;
        top: 100%;
        left: 0; right: 0;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
        padding: 10px 16px 16px;
        gap: 4px;
        box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
        max-height: calc(100dvh - 60px);
        overflow-y: auto;
    }
    .app-nav.nav-open { display: flex; }

    .app-nav > a,
    .app-nav > details > summary {
        padding: 10px 6px;
        border-bottom: 1px solid var(--border);
    }
    .app-nav > a:last-child,
    .app-nav > details:last-child summary { border-bottom: 0; }

    .user-menu { width: 100%; display: block; }
    .user-menu summary { list-style: revert; }
    .user-menu .menu-panel {
        position: static !important;
        right: auto !important;
        top: auto !important;
        left: auto !important;
        display: block !important;
        width: 100%;
        box-shadow: none;
        border: 0;
        margin: 0;
        padding: 0 0 0 14px;
        background: transparent;
        min-width: 0;
    }
    /* Mega-Panel auf dem Handy: Abschnitte uebereinander, jeweils mit
       Heading sichtbar. Grid wird wieder zu single column. */
    .user-menu.mega-menu .menu-panel.mega-panel {
        display: block !important;
        grid-template-columns: none;
        width: auto;
        max-width: none;
        padding: 0 0 0 14px;
        gap: 0;
    }
    .user-menu.mega-menu .mega-section { margin-top: 8px; }
    .user-menu.mega-menu .mega-section:first-child { margin-top: 0; }
    .user-menu .menu-panel a,
    .user-menu .menu-panel button {
        display: block;
        padding: 8px 6px;
        width: 100%;
    }
}

@media (max-width: 720px) {
    .app-main {
        padding: 16px 12px;
        padding-bottom: calc(100px + env(safe-area-inset-bottom, 0px));
    }
    .page-header { gap: 10px; }
    .page-header h1 { font-size: 1.45em; margin: 0; }
    .kini-back-row > h1 { font-size: 1.45em; }
    .auth-card { margin: 20px 4px; padding: 20px; }

    /* Tabellen horizontal scrollbar statt Seite sprengen.
       WICHTIG: thead/tbody/tr behalten ihr natives display
       (table-row-group / table-row), damit der Browser die Spalten-
       breiten ÜBER ALLE ZEILEN HINWEG berechnet. Vorher hatten wir
       hier display:table auf <tr>, das macht jede Zeile zu einer
       eigenen Mini-Tabelle und Spalten verschieben sich zwischen
       Zeilen – sah auf Handy chaotisch aus.
       Kein white-space:nowrap – sonst wird der Titel unter dem
       Mobile-Breakpoint nicht mehr umgebrochen, während cell-wrap-
       Spalten weiter wrappen, was zu inkonsistenten Spalten führt. */
    .data-table:not(.table-scroll *) {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .data-table td.actions { white-space: normal; }

    /* Landkarte + Kalender kleiner */
    .map-canvas { height: 320px; }
    #calendar { font-size: 0.9em; }

    /* Karten-Abstände enger */
    .card { padding: 14px 16px; }
    .filter-row { gap: 8px; }
    .filter-row label input[type=date] { min-width: 0; width: 100%; }

    /* Bestellformular: Bild über Beschreibung auf Handy */
    .bread-card-wide { flex-direction: column; align-items: stretch; padding: 0; gap: 0; }
    .bread-card-wide .bread-image {
        max-width: 100%;
        width: 100%;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    /* Actions in Listen stapeln */
    .data-table .actions { flex-direction: column; gap: 4px; align-items: stretch; }
    .data-table .actions .btn-sm { text-align: center; }

    /* Code-Block (Recovery-Code) mittig + umbrechen */
    .code-block { justify-content: center; flex-direction: column; text-align: center; }
    .code-block code { font-size: 1.4em; word-break: break-all; }

    /* Brand-Schrift dezenter, damit Platz bleibt */
    .app-header .brand span { font-size: 0.95em; }

    .grid-2 .data-table th,
    .grid-2 .data-table td { padding: 8px 6px; }
}

@media (max-width: 420px) {
    .app-header .brand span { display: none; } /* nur Icon, Platz sparen */
    .btn { padding: 10px 14px; } /* größere Touch-Ziele */
    .btn-sm { padding: 8px 12px; font-size: 0.95em; }
}

/* =====================================================================
   Kacheloptik (Tiles)
   =====================================================================
   Gemeinsame Klassen fuer die Kachel-Darstellung von Listen. Vorlage sind
   die Standort- und Kontaktlisten, die das Muster bisher als Inline-Styles
   trugen — hier einmal zentral, damit alle Verwaltungs-Listen gleich
   aussehen und sich an einer Stelle pflegen lassen.

   Aufbau einer Liste:
       <div class="tiles">            Grid, bricht von selbst um
         <div class="tile">           eine Kachel
           <div class="tile-body">    Inhalt oben
             <strong class="tile-title">…</strong>
             <div class="tile-meta">…</div>          Zeilen aus Label+Wert
             <span class="tile-badge ok|warn|info|muted">…</span>
           </div>
           <div class="tile-actions">…Buttons…</div>  immer unten
         </div>
         <a class="tile tile-new" href="…">+ Neu</a>
       </div>

   Breite der Spalten per Modifier: .tiles.narrow (200px) fuer kurze
   Eintraege, Standard 240px, .tiles.wide (300px) fuer Kacheln mit viel
   Text. Inaktive Eintraege bekommen .tile.is-inactive.
   ===================================================================== */
.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 10px;
}
.tiles.narrow { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.tiles.wide   { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

.tile {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    min-height: 140px;
    /* Lange Mailadressen und URLs duerfen die Kachel nicht aufreissen. */
    overflow-wrap: anywhere;
}
.tile.is-inactive { opacity: .55; }
/* Farbige Kante links zur schnellen Statuserkennung. */
.tile.accent-ok     { border-left: 3px solid var(--brand); }
.tile.accent-warn   { border-left: 3px solid var(--bread); }
.tile.accent-danger { border-left: 3px solid var(--danger); }
.tile.accent-info   { border-left: 3px solid var(--info); }

.tile-body { min-width: 0; }
.tile-title {
    display: block;
    font-size: 15px;
    line-height: 1.25;
}
.tile-sub {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    color: var(--muted);
}

/* Label-Wert-Zeilen innerhalb einer Kachel — ersetzt die Spalten, die in
   der Tabellenfassung die Kopfzeile lieferte. */
.tile-meta { margin-top: 8px; font-size: 13px; }
.tile-meta > div {
    display: flex;
    gap: 8px;
    justify-content: space-between;
    padding: 2px 0;
}
.tile-meta dt, .tile-meta .k { color: var(--muted); flex: 0 0 auto; }
.tile-meta dd, .tile-meta .v { margin: 0; text-align: right; min-width: 0; }

.tile-badge {
    display: inline-block;
    margin-top: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    /* Kurze Badges bleiben einzeilig (inline-block nimmt seine natuerliche
       Breite), ein ueberlanger Text bricht um statt Kachel und Raster
       breiter als den Bildschirm zu ziehen (war nowrap, 11.11.2026). */
    max-width: 100%;
    overflow-wrap: break-word;
    background: #eef2f6;
    color: #5a6b78;
}
.tile-badge.ok    { background: #e3f6ec; color: var(--brand); }
.tile-badge.warn  { background: #fdf1e5; color: #8a4b1c; }
.tile-badge.info  { background: #e8f1f8; color: var(--info); }
.tile-badge.danger{ background: #fbeae6; color: var(--danger); }

.tile-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* „+ Neu"-Kachel: gestrichelter Rahmen, zentriert, gleiche Hoehe. */
.tile-new {
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--brand);
    background: transparent;
    color: var(--brand);
    font-weight: 600;
    text-decoration: none;
    text-align: center;
}
.tile-new:hover { background: rgba(11, 110, 79, 0.05); }
.tile-new .plus { font-size: 32px; line-height: 1; }

/* Kachel-Raster bleibt auf schmalen Geraeten einspaltig lesbar. */
@media (max-width: 420px) {
    .tiles, .tiles.narrow, .tiles.wide { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------------
   Aufklappbarer Filterblock ueber Kachel-Listen (_macros/tiles.html).
   Standardmaessig zu; oeffnet sich automatisch, wenn Filter aktiv sind.
   --------------------------------------------------------------------- */
.filter-panel {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    margin: 0 0 14px 0;
    max-width: 1000px;
}
.filter-panel > summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    list-style: none;
    border-radius: var(--radius);
}
/* Standard-Dreieck weg, eigenes Zeichen rechts — klarer und in beiden
   Browsern gleich. */
.filter-panel > summary::-webkit-details-marker { display: none; }
.filter-panel > summary::marker { content: ''; }
.filter-panel > summary::after {
    content: '▾';
    margin-left: auto;
    color: var(--muted);
    font-size: 12px;
    transition: transform .15s;
}
.filter-panel[open] > summary::after { transform: rotate(180deg); }
.filter-panel > summary:hover { background: var(--bg); }
.filter-panel-label { color: var(--text); }
.filter-panel-hint { color: var(--muted); font-weight: 400; font-size: 13px; }
.filter-panel-count {
    background: #e3f6ec; color: var(--brand);
    border-radius: 999px; padding: 1px 9px;
    font-size: 12px; font-weight: 700;
}
.filter-panel-body {
    padding: 4px 14px 12px;
    border-top: 1px solid var(--border);
}
/* Die Filterzeile sitzt im Block, braucht dort keinen eigenen Abstand. */
.filter-panel-body .filter-row { margin-bottom: 0; }

/* --- Datei-Vollbild (Bilder, PDFs) ------------------------------------
   Siehe app/static/js/dateiviewer.js: In der installierten PWA gibt es
   keine Browser-Leiste, mit der man von einer geoeffneten Datei
   zurueckkaeme. Deshalb Overlay statt Navigation — mit Schliessen-Knopf. */
.dateiviewer {
    position: fixed; inset: 0; z-index: 10000;
    background: rgba(8, 12, 10, .94);
    display: flex; flex-direction: column;
}
.dateiviewer[hidden] { display: none; }
.dateiviewer__kopf {
    flex: 0 0 auto;
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    /* Unter der Statusleiste des Handys bleiben (Notch/Dynamic Island). */
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
    background: rgba(0, 0, 0, .35);
    color: #fff;
}
.dateiviewer__titel {
    flex: 1 1 auto; min-width: 0;
    font-size: 14px; font-weight: 600;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dateiviewer__knoepfe { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; }
.dateiviewer__knopf {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 38px; padding: 6px 12px;
    border: 1px solid rgba(255, 255, 255, .35); border-radius: 999px;
    background: rgba(255, 255, 255, .08); color: #fff;
    font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer;
}
.dateiviewer__knopf:hover { background: rgba(255, 255, 255, .18); }
.dateiviewer__zu {
    /* Der wichtigste Knopf: gross genug fuer den Daumen, immer sichtbar. */
    min-width: 44px; font-size: 26px; line-height: 1; padding: 2px 10px 6px;
    background: rgba(255, 255, 255, .95); color: #16211c; border-color: transparent;
}
.dateiviewer__zu:hover { background: #fff; }
.dateiviewer__buehne {
    flex: 1 1 auto; min-height: 0;
    display: flex; align-items: center; justify-content: center;
    padding: 12px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    overflow: auto;
}
.dateiviewer__bild { max-width: 100%; max-height: 100%; object-fit: contain; }
.dateiviewer__rahmen { width: 100%; height: 100%; border: 0; background: #fff; border-radius: 6px; }
.dateiviewer__hinweis {
    max-width: 420px; padding: 24px; text-align: center; color: #fff;
    overflow-wrap: anywhere;
}
.dateiviewer__hinweis p { color: rgba(255, 255, 255, .8); margin: 10px 0 0; }
/* Die Seite darunter nicht mitscrollen lassen. */
body.dateiviewer-offen { overflow: hidden; }

@media (max-width: 480px) {
    /* Auf dem Handy zaehlt der Schliessen-Knopf; die beiden Textknoepfe
       duerfen schrumpfen, damit der Dateiname nicht verdraengt wird. */
    .dateiviewer__knopf { padding: 6px 10px; font-size: 13px; }
    .dateiviewer__titel { font-size: 13px; }
}

/* Sprachnachricht laedt noch: dezent, damit der Player nicht springt. */
.voice-msg--laedt .voice-msg__play { opacity: .6; }

/* --- Reaktionen auf Chat-Nachrichten ----------------------------------
   Kleine Chips unter der Nachricht: vergebene Emojis mit Anzahl, eigene
   hervorgehoben. Der Knopf ganz rechts oeffnet die Auswahlleiste. */
.chat-reaktionen {
    display: flex; flex-wrap: wrap; gap: 6px;
    margin-top: 6px;
}
.chat-reaktion {
    display: inline-flex; align-items: center;
    /* 32px hoch: mit dem Daumen auf dem Handy sicher zu treffen. */
    min-height: 32px; padding: 2px 10px;
    border: 1px solid var(--border); border-radius: 999px;
    background: #fff; color: var(--text);
    font-size: 14px; line-height: 1; cursor: pointer;
}
.chat-reaktion:hover { background: var(--bg); }
.chat-reaktion.ist-meine {
    border-color: var(--brand);
    background: color-mix(in srgb, var(--brand) 12%, #fff);
    font-weight: 600;
}
.chat-reaktion__n { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chat-reaktion.ist-meine .chat-reaktion__n { color: var(--brand); }
.chat-reaktion--plus {
    /* Unaufdringlich, solange niemand reagiert hat — aber auffindbar. */
    opacity: .55; font-size: 15px; padding: 2px 9px;
}
.chat-reaktion--plus:hover { opacity: 1; }

.chat-emojiwahl {
    position: fixed; z-index: 10001;
    display: flex; gap: 2px; padding: 6px;
    background: #fff; border: 1px solid var(--border); border-radius: 999px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
}
.chat-emojiwahl[hidden] { display: none; }
.chat-emojiwahl__knopf {
    border: 0; background: transparent; cursor: pointer;
    font-size: 22px; line-height: 1;
    min-width: 42px; min-height: 42px; border-radius: 999px;
}
.chat-emojiwahl__knopf:hover { background: var(--bg); transform: scale(1.12); }

/* Drucken (z. B. QR-Schild fürs Fahrzeug): nur der Inhalt – vorher kamen
   Hinweis-Banner und der ←-Pfeil mit aufs Papier (QA 17.11.2026). */
@media print {
    .app-header, .app-nav, .nav-toggle, .kini-back, #kini-back-btn,
    #module-activation-banner-host, [data-banner-key], #app-version-toast,
    #kini-ring, #kini-call { display: none !important; }
}

/* Handy: Listen statt breiter Zeitbalken (z. B. Fahrzeug-Kalender). */
.nur-schmal { display: none; }
@media (max-width: 720px) {
    .nur-schmal { display: block; }
    .nur-breit { display: none !important; }
}

/* Formulare, die direkt auf dem (je nach Mandant farbigen) Seitenhintergrund
   standen, bekommen dieselbe Karte wie der Rest der App – vorher lagen
   Eingabefelder z. B. direkt auf Pink (offene Punkte 18.11.2026). */
.page > form.stacked:not([method="get"]):not([method="GET"]) {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px 20px; margin-bottom: 16px;
    box-shadow: var(--shadow);
}
