/*
 * Design-System Gemeinde-App (Strom W3, 11/2026) – wird NACH allen anderen CSS-Dateien geladen.
 * Reine Optik: Variablen (Farben, Abstände, Radius, Schatten, Schrift) + ruhige Überschreibungen.
 * Keine Funktion, keine IDs/Klassen entfernt. Kontraste mind. WCAG AA, Touch-Ziele >= 44 px.
 */
:root {
    /* Farben */
    --c-primary: #1a5276;
    --c-primary-dark: #12384f;
    --c-primary-soft: #e6eef4;
    --c-accent: #00695c;            /* Kontrast auf Weiss 6,5:1 */
    --c-accent-soft: #e0f2f1;
    --c-ok: #2e7d32;                /* 5,1:1 auf Weiss */
    --c-ok-soft: #e8f5e9;
    --c-link: #1565c0;              /* 5,7:1 */
    --c-link-soft: #e3f2fd;
    --c-warn: #8a5300;
    --c-warn-soft: #fff3e0;
    --c-danger: #c62828;            /* 5,6:1 */
    --c-danger-soft: #fdecea;
    --c-text: #1f2d3a;              /* 13:1 */
    --c-text-2: #4a5b69;            /* 6,6:1 */
    --c-text-3: #5f7080;            /* 4,9:1 */
    --c-line: #d5dde3;
    --c-surface: #ffffff;
    --c-bg: #eef2f5;
    /* Abstände */
    --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px;
    /* Radius */
    --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-pill: 999px;
    /* Schatten */
    --sh-1: 0 1px 2px rgba(18,56,79,.10), 0 1px 3px rgba(18,56,79,.08);
    --sh-2: 0 2px 6px rgba(18,56,79,.14), 0 4px 14px rgba(18,56,79,.08);
    /* Schrift */
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --fs-xs: 12px; --fs-sm: 13px; --fs-md: 15px; --fs-lg: 17px;
    --touch: 44px;

    /* bestehende Variablen auf das System mappen */
    --primary: var(--c-primary);
    --primary-light: #2a6f97;
    --bg-header: var(--c-primary);
    --text-dark: var(--c-text);
    --shadow: var(--sh-1);
    --radius: var(--r-sm);
}

html, body { font-family: var(--font); background: var(--c-bg); color: var(--c-text); }
button, input, select, textarea { font-family: inherit; }
:focus-visible { outline: 3px solid #4d90c3; outline-offset: 2px; }

/* === Kopfzeile === */
#app-header {
    background: linear-gradient(180deg, var(--c-primary) 0%, var(--c-primary-dark) 100%);
    box-shadow: var(--sh-2);
}
#app-header h1 { font-size: 16px; font-weight: 600; }
.header-btn { background: rgba(255,255,255,.16); min-width: 40px; min-height: 40px; }
.header-btn:active { background: rgba(255,255,255,.3); }

/* === Panels (Aufträge, Route, Mähen, Weihnacht, Garage) === */
.panel-header {
    background: linear-gradient(180deg, var(--c-primary) 0%, var(--c-primary-dark) 100%);
    padding: 10px 16px; min-height: 56px; box-shadow: var(--sh-2);
}
.panel-header h2 { font-size: var(--fs-lg); font-weight: 650; }
.panel-body { padding: var(--sp-3); background: var(--c-bg); }
.panel-add-btn { width: var(--touch); height: var(--touch); background: #d32f2f; box-shadow: var(--sh-2); }
.empty-state { color: var(--c-text-3); }

/* === Untere Navigation === */
#bottom-nav { background: var(--c-surface); border-top: 1px solid var(--c-line); box-shadow: 0 -2px 10px rgba(18,56,79,.08); }
.nav-tab { color: var(--c-text-3); min-height: var(--touch); position: relative; }
#bottom-nav .nav-tab span { font-size: 10.5px; font-weight: 600; }
.nav-tab.active { color: var(--c-primary); }
.nav-tab.active::before {
    content: ''; position: absolute; top: 0; left: 28%; right: 28%; height: 3px;
    background: var(--c-primary); border-radius: 0 0 3px 3px;
}

/* === Knöpfe === */
.dc-btn {
    min-height: var(--touch); padding: 8px 14px; border-radius: var(--r-sm);
    border: 1px solid var(--c-line); background: var(--c-surface); color: var(--c-text);
    font-size: var(--fs-sm); font-weight: 600; box-shadow: var(--sh-1);
}
.dc-btn:active { background: var(--c-primary-soft); }
.dc-btn.primary { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.dc-btn.danger { background: var(--c-danger-soft); border-color: #f1bcbc; color: var(--c-danger); }
.dc-btn.ok { background: var(--c-ok-soft); border-color: #b9dcbb; color: var(--c-ok); }

/* === Karten / Listen === */
.data-card, .mow-card {
    border-radius: var(--r-md); box-shadow: var(--sh-1); border: 1px solid #e3e9ee;
}
.dc-title { color: var(--c-text); }
.dc-sub, .dc-meta { color: var(--c-text-2); }
.panel-form { border-radius: var(--r-md); box-shadow: var(--sh-1); border: 1px solid #e3e9ee; }

/* === Formulare (inkl. Pin-Editor) === */
.panel-form label, .me-body label { color: var(--c-text-2); font-weight: 600; font-size: var(--fs-xs); }
.panel-form input, .panel-form select, .panel-form textarea,
.me-body input[type=text], .me-body input[type=number], .me-body input[type=date], .me-body select, .me-body textarea {
    border: 1px solid #b7c3cc; border-radius: var(--r-sm); min-height: var(--touch);
    font-size: 16px; color: var(--c-text); background: #fff;
}
.panel-form input:focus, .panel-form select:focus, .panel-form textarea:focus,
.me-body input:focus, .me-body select:focus, .me-body textarea:focus {
    border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(26,82,118,.18); outline: none;
}
.me-sheet { border-radius: var(--r-lg) var(--r-lg) 0 0; box-shadow: 0 -6px 24px rgba(0,0,0,.2); }
.me-header h3 { color: var(--c-primary); font-weight: 650; }
.me-close { min-width: var(--touch); min-height: var(--touch); }

/* === Filter-Leiste === */
.filter-pill { min-height: 36px; font-weight: 600; }
.filter-scroll-btn { min-width: 36px; min-height: 36px; }

/* === Karten-Popup === */
.leaflet-popup-content-wrapper { border-radius: var(--r-md); box-shadow: var(--sh-2); }
.popup-btn { min-height: var(--touch); border-radius: var(--r-sm); font-weight: 600; }
.popup-task-btn { min-height: 36px; }
.leaflet-popup-close-button { width: 36px !important; height: 36px !important; font-size: 22px !important; line-height: 36px !important; }

/* ============================================================
   Weihnacht-Tab (xm-*) – kompakt, klare Haken
   ============================================================ */
#xmas-body { padding-bottom: 80px; }
.xm-seg { display: flex; gap: var(--sp-2); margin-bottom: var(--sp-2); }
.xm-seg-btn {
    flex: 1; min-height: var(--touch); padding: 4px 8px; border: 2px solid var(--c-line); border-radius: var(--r-md);
    background: var(--c-surface); color: var(--c-text); font-weight: 700; font-size: var(--fs-md); cursor: pointer;
    display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.15;
}
.xm-seg-btn small { font-size: var(--fs-xs); font-weight: 500; color: var(--c-text-3); }
.xm-seg-btn.active { border-color: var(--c-accent); background: var(--c-accent-soft); color: #004d40; }

.xm-progress { padding: var(--sp-2) var(--sp-3); margin-bottom: var(--sp-2); border-radius: var(--r-md); }
.xm-progress-txt { font-size: var(--fs-sm); color: var(--c-text); margin-top: 2px; }
.xm-bar { height: 8px; margin: 3px 0 5px; }
.xm-bar-fill.step-aufbau, .xm-bar-fill.step-abbau { background: var(--c-ok); }
.xm-bar-fill.step-anschluss { background: var(--c-link); }
.xm-hint { color: var(--c-text-3); font-size: var(--fs-xs); }

/* Werkzeugleiste: Suche + Filter */
.xm-tools { display: flex; gap: var(--sp-2); align-items: center; margin: var(--sp-2) 0; }
.xm-search {
    flex: 1; min-width: 0; min-height: var(--touch); box-sizing: border-box; padding: 0 12px;
    border: 1px solid #b7c3cc; border-radius: var(--r-pill); font-size: 16px; background: #fff; color: var(--c-text);
}
.xm-search:focus { border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(26,82,118,.18); outline: none; }
.xm-open-btn {
    min-height: var(--touch); padding: 0 14px; border-radius: var(--r-pill); border: 2px solid var(--c-line);
    background: var(--c-surface); color: var(--c-text-2); font-weight: 700; font-size: var(--fs-sm); cursor: pointer; white-space: nowrap;
}
.xm-open-btn.on { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }

/* Spaltenköpfe fixiert */
.xm-cols {
    position: sticky; top: -12px; z-index: 5; display: flex; align-items: center; gap: 6px;
    background: var(--c-bg); padding: 6px 8px 6px 6px; margin: 0 0 4px;
    border-bottom: 1px solid var(--c-line); font-size: var(--fs-xs); font-weight: 700;
}
.xm-cols-name { order: 3; flex: 1; padding-left: 2px; color: var(--c-text-2); }
.xm-col-h { flex: 0 0 60px; text-align: center; font-size: 11px; line-height: 1.1; hyphens: manual; }
.xm-col-h.step-aufbau { order: 1; color: var(--c-ok); }
.xm-col-h.step-anschluss { order: 2; color: var(--c-link); }
.xm-col-h.step-abbau { order: 1; color: var(--c-ok); }

/* Gruppen */
.xm-group { margin-bottom: var(--sp-2); }
.xm-group-h {
    display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; box-sizing: border-box;
    min-height: 40px; padding: 4px 10px; background: var(--c-surface); border: none; border-left: 5px solid #999;
    border-radius: var(--r-sm); box-shadow: var(--sh-1); font-size: var(--fs-md); font-weight: 700; color: var(--c-text);
    cursor: pointer; text-align: left; margin-bottom: 4px;
}
.xm-group-h small { font-weight: 600; color: var(--c-text-2); font-size: var(--fs-xs); white-space: nowrap; }
.xm-group-h .xm-chev { display: inline-block; width: 14px; transition: transform .15s; color: var(--c-text-3); font-size: 12px; }
.xm-group.collapsed .xm-chev { transform: rotate(-90deg); }
.xm-group.collapsed .xm-row { display: none; }

/* Zeilen */
.xm-row {
    display: flex; align-items: center; gap: 6px; min-height: 48px; padding: 2px 6px 2px 6px; margin-bottom: 3px;
    background: var(--c-surface); border-radius: var(--r-sm); box-shadow: var(--sh-1);
}
.xm-row.done { background: #f3f9f4; }
.xm-row.hidden { display: none; }

/* Haken-Knöpfe: leer = klar umrandet, erledigt = gefüllt mit Icon */
.xm-check {
    flex: 0 0 60px; height: 44px; min-width: 60px; padding: 0; border-radius: 10px; margin: 0;
    display: inline-flex; align-items: center; justify-content: center; gap: 2px;
    font-size: 20px; font-weight: 800; line-height: 1; cursor: pointer; background: #fff;
    border: 2.5px solid currentColor; box-sizing: border-box;
}
.xm-check::before { content: attr(data-ico); font-size: 20px; opacity: .5; font-weight: 800; }
.xm-check.step-aufbau, .xm-check.step-abbau { color: var(--c-ok); }
.xm-check.step-anschluss { color: var(--c-link); }
.xm-check.on { color: #fff; border-color: transparent; }
.xm-check.on::before { opacity: 1; }
.xm-check.step-anschluss.on::after { content: '✓'; font-size: 18px; }
.xm-check.step-aufbau.on, .xm-check.step-abbau.on { background: var(--c-ok); }
.xm-check.step-anschluss.on { background: var(--c-link); }
.xm-check:disabled { opacity: .5; cursor: default; }
/* alte Sonderregeln neutralisieren */
.xm-check.step-anschluss { margin-left: 0; border-radius: 10px; }
.xm-row .xm-check:first-child:not(:only-of-type) { border-radius: 10px; }
.xm-row .xm-check[data-step=aufbau] { order: 1; }
.xm-row .xm-check[data-step=anschluss] { order: 2; }
.xm-row .xm-name { order: 3; }

.xm-name { flex: 1; min-width: 0; background: none; border: none; text-align: left; padding: 4px 2px; cursor: pointer; display: flex; flex-direction: column; justify-content: center; }
.xm-name-t { font-size: var(--fs-md); font-weight: 600; color: var(--c-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xm-name-s { display: none; font-size: 11px; color: var(--c-text-3); line-height: 1.25; }
.xm-name-s.ok { color: var(--c-ok); }
.xm-row.open-detail { align-items: flex-start; padding-top: 2px; }
.xm-row.open-detail .xm-name-t { white-space: normal; }
.xm-row.open-detail .xm-name-s { display: block; }
.xm-info {
    flex: 0 0 32px; height: 44px; border: none; background: none; color: var(--c-text-3); font-size: 16px; cursor: pointer; padding: 0;
}
.xm-info.on { color: var(--c-primary); }
.xm-sack { margin-left: 4px; padding: 0 6px; border-radius: 8px; background: var(--c-accent-soft); color: #00574c; font-size: 11px; font-weight: 700; vertical-align: 1px; }
.xm-sacks { margin: 2px 0; }
.xm-empty-filter { text-align: center; color: var(--c-text-3); padding: 16px; font-size: var(--fs-sm); }
.xm-modal { border-radius: var(--r-lg); }
