:root {
    --bg-dark: #0f172a;
    --bg-panel: rgba(30, 41, 59, 0.7);
    --bg-solid: rgba(15, 23, 42, 0.95);
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.1);

    --status-green: #10b981;
    --status-yellow: #f59e0b;
    --status-red: #ef4444;

    --glass-blur: blur(12px);
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);

    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Inline-SVG-Icons (Sprite in index.html) */
.ico {
    width: 1.05em;
    height: 1.05em;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    vertical-align: -0.15em;
    flex-shrink: 0;
}
.ico-lg { width: 1.5em; height: 1.5em; }
.ico-xl { width: 2.2em; height: 2.2em; color: var(--primary); margin-bottom: 0.6rem; }
.search-ico {
    position: absolute;
    left: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    z-index: 2;
}

html, body {
    height: 100%;
    /* kein Browser-Pinch-Zoom und kein Doppeltipp-Zoom auf der App-Oberfläche;
       die Karte handhabt Pinch selbst (Google setzt dort eigene touch-action) */
    touch-action: pan-x pan-y;
    overscroll-behavior: none;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
}

/* Typography */
h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.025em; }
h2 { font-size: 1.25rem; font-weight: 600; margin-bottom: 0.5rem; }
h3 { font-size: 0.875rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 1rem; }
p { font-size: 0.9rem; line-height: 1.5; }
.highlight { color: var(--primary); }
.small-text { font-size: 0.75rem; color: var(--text-muted); }

/* Glassmorphism */
.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100dvh;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(5px);
}
.modal-overlay.hidden { display: none; }

.modal-content {
    padding: 2.5rem;
    border-radius: 1rem;
    width: 90%;
    max-width: 500px;
    text-align: center;
}
.modal-content input {
    width: 100%;
    padding: 0.75rem 1rem;
    margin: 1.5rem 0;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    background: rgba(0,0,0,0.2);
    color: white;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}
.modal-content input:focus { border-color: var(--primary); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    text-decoration: none;
    min-height: 48px;
}
.btn-primary { background: var(--primary); color: white; width: 100%; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }

.btn-tool {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.5rem 1rem;
}
.btn-tool:hover:not(:disabled) { background: rgba(255,255,255,0.1); }
.btn-tool:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-tool.active { background: var(--primary); border-color: var(--primary); color: white; }

.btn-action { padding: 0.5rem 1rem; font-size: 0.95rem; flex: 1; color: white; min-height: 52px; }
.btn-action.call { background: var(--status-green); }
.btn-action.mail { background: var(--primary); }
.btn-action.wa { background: #25D366; }
.btn-action:hover { opacity: 0.9; transform: translateY(-2px); }

.btn-small {
    padding: 0.4rem 1rem; font-size: 0.8rem;
    background: rgba(255,255,255,0.1); border: 1px solid var(--border-color); color: white;
    min-height: 44px;
}
.btn-small:hover { background: rgba(255,255,255,0.2); }
.btn-danger { color: var(--status-red); }

/* Layout */
/* Füllt den Viewport unabhängig von vw/dvh-Eigenheiten (Android-Tablets) */
.app-container {
    position: fixed;
    inset: 0;
    display: flex;
}

.sidebar {
    width: 340px;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    overflow-y: auto;
    z-index: 10;
    flex-shrink: 0;
}
#sidebar-slots > * { margin-bottom: 1.5rem; }

.map-area {
    flex: 1;
    position: relative;
    min-width: 0;
    min-height: 0;
}

#map {
    width: 100%;
    height: 100%;
}

/* Freihand-Lasso-Overlay — liegt über Suche/Bar/Panel, unter Snackbar */
#lasso-overlay {
    position: absolute; /* relativ zur .map-area, damit Pixel == Karten-Container-Pixel */
    inset: 0;
    z-index: 35;
    display: none;
    cursor: crosshair;
    touch-action: none;
    background: rgba(15, 23, 42, 0.15);
}
#lasso-overlay > svg { width: 100%; height: 100%; }
#lasso-overlay .lasso-cancel {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(1.25rem + var(--safe-bottom));
    background: var(--bg-solid);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    padding: 0 1.5rem;
    min-height: 48px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow);
}
#lasso-overlay > svg polyline {
    fill: rgba(59, 130, 246, 0.15);
    stroke: var(--primary);
    stroke-width: 2;
}

/* Upload Zone */
.upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: 0.75rem;
    padding: 1.5rem 1rem;
    text-align: center;
    margin-bottom: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    background: rgba(0,0,0,0.1);
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
}
.upload-zone i { font-size: 2rem; color: var(--primary); margin-bottom: 0.75rem; }

/* Stats */
.stats-container {
    display: flex;
    gap: 1rem;
}
.stat-box {
    flex: 1;
    background: rgba(255,255,255,0.03);
    border-radius: 0.5rem;
    padding: 1rem;
    text-align: center;
    border: 1px solid var(--border-color);
}
.stat-value { display: block; font-size: 1.35rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; }

/* Filter-Chips */
.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}
.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.5rem 0.9rem;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: rgba(255,255,255,0.05);
    color: var(--text-main);
    font-size: 0.8rem;
    cursor: pointer;
    min-height: 42px;
    transition: background 0.15s, border-color 0.15s;
}
.chip .dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.chip .count { color: var(--text-muted); font-size: 0.7rem; }
.chip.active { background: var(--primary); border-color: var(--primary); }
.chip.active .count { color: rgba(255,255,255,0.8); }
.chip-row-sub {
    padding-left: 0.6rem;
    border-left: 2px solid var(--border-color);
}
.chip-row-sub.hidden { display: none; }
.chip-row-sub .chip { min-height: 44px; font-size: 0.75rem; padding: 0.4rem 0.75rem; }

/* Aktive Filter über der Karte */
.active-chips {
    position: absolute;
    top: calc(var(--safe-top) + 0.75rem);
    left: calc(0.75rem + var(--safe-left));
    right: calc(0.75rem + var(--safe-right));
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    z-index: 15;
    pointer-events: none;
}
.active-chips .chip {
    pointer-events: auto;
    background: var(--bg-solid);
    min-height: 44px;
    font-size: 0.72rem;
    padding: 0.3rem 0.8rem;
}

/* Toggle-Reihen (ganze Zeile antippbar) */
.control-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: 48px;
    cursor: pointer;
    font-size: 0.9rem;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(255,255,255,0.1);
    transition: .4s;
    border-radius: 34px;
}
.slider:before {
    position: absolute; content: "";
    height: 18px; width: 18px; left: 3px; bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}
input:checked + .slider { background-color: var(--primary); }
input:checked + .slider:before { transform: translateX(20px); }

/* Suche */
.search-box {
    position: relative;
}
.search-box i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    z-index: 2;
}
.search-box input {
    width: 100%;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    color: white;
    outline: none;
    min-height: 48px;
    font-size: 1rem;
}
.search-box input:focus { border-color: var(--primary); }

.search-suggest {
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: var(--bg-solid);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    z-index: 45;
    max-height: 40dvh;
    overflow-y: auto;
    box-shadow: var(--shadow);
}
.search-suggest.hidden { display: none; }
.search-suggest button {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-main);
    padding: 0.75rem 1rem;
    min-height: 48px;
    cursor: pointer;
    text-align: left;
    font-size: 0.85rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.search-suggest button:hover { background: rgba(255,255,255,0.06); }
.search-suggest .count { color: var(--text-muted); font-size: 0.72rem; }

.search-float {
    position: absolute;
    top: calc(var(--safe-top) + 0.75rem);
    left: calc(0.75rem + var(--safe-left));
    right: calc(0.75rem + var(--safe-right));
    z-index: 40; /* über dem mobilen Kundenpanel (32), damit Vorschläge sichtbar bleiben */
}
.search-float .search-box input {
    background: var(--bg-solid);
    box-shadow: var(--shadow);
}

/* Tools */
.tool-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Customer Panel (fixed: eigener Stapel über Bottom-Bar/Sheets, unabhängig vom App-Container) */
.customer-panel {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    width: 370px;
    max-height: calc(100dvh - 3rem);
    border-radius: 1rem;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    z-index: 22;
    transform: translateX(0);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s;
    overflow-y: auto;
    background: var(--bg-solid);
}
.customer-panel.hidden {
    transform: translateX(130%);
    visibility: hidden; /* nicht mehr fokussierbar, wenn unsichtbar */
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s linear 0.3s;
}

/* Fester Panel-Kopf: Handle + Schließen + Name bleiben beim Scrollen sichtbar */
.panel-head {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--bg-solid);
    margin: 0 -1.5rem;
    padding: 0 1.5rem 0.25rem;
}
.panel-handle {
    position: relative;
}
.panel-handle::before { /* unsichtbare 44px-Trefferfläche */
    content: '';
    position: absolute;
    inset: -20px -80px;
}
.close-btn {
    position: absolute;
    top: 0.5rem; right: 0.5rem;
    background: transparent; border: none; color: var(--text-muted);
    cursor: pointer; font-size: 1.25rem;
    min-width: 48px; min-height: 48px;
    z-index: 2;
}
.close-btn:hover { color: white; }

.customer-header { margin-bottom: 1.1rem; position: relative; padding-right: 2.5rem; }
.customer-header h2 { font-size: 1.35rem; line-height: 1.25; margin-bottom: 0.3rem; }
.status-indicator {
    width: 12px; height: 12px; border-radius: 50%;
    display: inline-block;
    margin-right: 0.5rem;
}
.subtitle { color: var(--text-muted); font-size: 0.88rem; line-height: 1.45; margin-top: 0.35rem; }
#panel-visit {
    display: inline-block;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border-color);
    font-weight: 600;
    margin-top: 0.55rem;
}

.customer-section {
    border-top: 1px solid var(--border-color);
    padding-top: 1.1rem;
    margin-bottom: 1.4rem;
}
.customer-section.compact .customer-name { margin-bottom: 0.5rem; }
.section-title { margin-bottom: 0.75rem; }
.customer-name {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text-main);
    font-size: 1.05rem;
    margin-bottom: 0.85rem;
}

.action-buttons {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

/* IBAN-Zeile (maskiert + Copy-on-Tap) */
.iban-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Contract Cards */
.contract-card {
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1rem 1.1rem;
    margin-bottom: 0.9rem;
}
.contract-card h4 { color: var(--primary); margin: 0.35rem 0 0.7rem; font-size: 0.95rem; line-height: 1.35; }
.contract-details { font-size: 0.85rem; line-height: 1.4; display: grid; grid-template-columns: 1fr 1fr; gap: 0.65rem 1rem; }
.detail-label { color: var(--text-muted); }

.status-pill {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 0.5rem;
}
.contract-meta { margin-top: 0.5rem; font-size: 0.7rem; color: var(--text-muted); }

/* Notes */
.notes-section textarea {
    width: 100%; height: 80px;
    background: rgba(0,0,0,0.2); border: 1px solid var(--border-color);
    border-radius: 0.5rem; padding: 0.75rem; color: white; resize: none;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

/* Progress Bar */
.progress-container { margin-top: 1rem; }
.progress-bar-bg { width: 100%; height: 6px; background: rgba(255,255,255,0.1); border-radius: 3px; margin-top: 0.5rem; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--primary); width: 0%; transition: width 0.3s; }

/* Route steps */
.route-info { margin-top: 1rem; background: rgba(0,0,0,0.2); padding: 1rem; border-radius: 0.5rem; border: 1px solid var(--border-color); }
.route-steps-list { max-height: 200px; overflow-y: auto; margin-top: 1rem; font-size: 0.8rem; color: var(--text-muted); list-style: none; }
.route-steps-list li { margin-bottom: 0.5rem; border-bottom: 1px solid rgba(255,255,255,0.05); padding-bottom: 0.5rem; }

/* Dateiliste (Menü) */
.file-list { margin-bottom: 1.5rem; }
.file-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    font-size: 0.8rem;
}
.file-row .file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row .btn-remove {
    background: transparent; border: none; color: var(--status-red);
    min-width: 44px; min-height: 44px; cursor: pointer; flex-shrink: 0;
    font-size: 0.9rem;
}

/* Statistik-Dashboard (Menü) */
.stats-dashboard { margin-bottom: 1.5rem; }
.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.4rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    font-size: 0.85rem;
    cursor: pointer;
    min-height: 46px;
}
.stat-row:hover { background: rgba(255,255,255,0.04); }
.stat-row .label { display: flex; align-items: center; gap: 0.5rem; }
.stat-row .dot { width: 10px; height: 10px; border-radius: 50%; }

/* Einstellungen */
.settings { display: flex; flex-direction: column; gap: 0.75rem; padding-bottom: 1rem; }
.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 48px;
    font-size: 0.9rem;
}
.settings select {
    background: rgba(0,0,0,0.2);
    color: white;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.6rem;
    min-height: 44px;
}

/* Bottom-Bar (Mobil) */
.bottom-bar {
    display: none;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 30;
    padding: 0.35rem calc(0.6rem + var(--safe-right)) calc(0.35rem + var(--safe-bottom)) calc(0.6rem + var(--safe-left));
    justify-content: space-between;
    align-items: center;
    gap: 0.4rem;
    border-radius: 1rem 1rem 0 0;
    background: var(--bg-solid);
}
.bar-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 0.68rem;
    min-height: 52px;
    cursor: pointer;
    border-radius: 0.5rem;
}
.bar-btn i { font-size: 1.15rem; }
.bar-btn.active { color: var(--primary); background: rgba(59,130,246,0.12); }
.stats-pill {
    flex: 1.5;
    text-align: center;
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    padding: 0.5rem 0.5rem;
    font-size: 0.68rem;
    color: var(--text-muted);
    line-height: 1.3;
}

/* Bottom-Sheets (Mobil) */
.sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 25;
}
.sheet-backdrop.hidden { display: none; }

.bottom-sheet {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 28;
    max-height: 75vh;
    max-height: 78dvh;
    border-radius: 1.25rem 1.25rem 0 0;
    padding: 0.4rem 1.25rem calc(4.5rem + var(--safe-bottom));
    overflow-y: auto;
    background: var(--bg-solid);
}
.bottom-sheet.hidden { display: none; }

.sheet-handle {
    width: 44px;
    height: 5px;
    border-radius: 3px;
    background: rgba(255,255,255,0.25);
    margin: 0.4rem auto 0.85rem;
    flex-shrink: 0;
}
.panel-handle { display: none; touch-action: none; }

/* Karte offline */
.map-offline {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
    background: var(--bg-dark);
    z-index: 5;
}
.map-offline.hidden { display: none; }
.geo-warn { color: var(--status-yellow) !important; }
.geo-warn.hidden { display: none; }
.legend { margin: -0.5rem 0 1rem; }

/* Kompletter Datensatz im Auftrag (aufklappbar) */
.contract-full { margin-top: 0.6rem; }
.contract-full summary {
    cursor: pointer;
    color: var(--primary);
    font-size: 0.8rem;
    min-height: 40px;
    display: flex;
    align-items: center;
}
.contract-full dl {
    display: grid;
    grid-template-columns: minmax(120px, 40%) 1fr;
    gap: 0.35rem 0.75rem;
    margin-top: 0.5rem;
    font-size: 0.8rem;
}
.contract-full dt { color: var(--text-muted); }
.contract-full dd { word-break: break-word; }
.writer { color: var(--text-main); font-weight: 600; }

/* Hotspots */
.sort-label { align-self: center; margin-right: 0.25rem; }
#hotspot-scope:empty { display: none; }

/* Gebiete (PLZ) */
.gebiete-list { display: flex; flex-direction: column; gap: 0.35rem; }
.gebiet-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
    width: 100%;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.55rem 0.8rem;
    color: var(--text-main);
    text-align: left;
    cursor: pointer;
    min-height: 48px;
}
.gebiet-row:hover { background: rgba(255,255,255,0.08); }
.gebiet-name { font-weight: 600; font-size: 0.9rem; }
.gebiet-stats { font-size: 0.72rem; color: var(--text-muted); }

/* Touren: Modus, Etappen, Navigation */
.seg-row { margin-bottom: 0.75rem; }
.etappen { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.75rem 0; }
.nav-links { display: flex; flex-direction: column; gap: 0.5rem; margin: 0.75rem 0; }
.nav-link { text-decoration: none; }
#route-selection { margin-bottom: 0.75rem; }

/* Geocoding-Status (Menü) */
.geo-status { margin-bottom: 1.5rem; }
.stat-row.static { cursor: default; }
.stat-row.static:hover { background: transparent; }
.geo-failed-list {
    list-style: none;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    max-height: 160px;
    overflow-y: auto;
}
.geo-failed-list li { padding: 0.3rem 0; border-bottom: 1px solid rgba(255,255,255,0.05); }

/* Such-Vorschlag: Einzeladresse */
.search-suggest .suggest-addr { font-size: 0.8rem; }

/* Schwebende Karten-Buttons (Maps-App-Look) */
.map-fabs {
    position: absolute;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    z-index: 16;
}
.map-fabs-top { top: 0.75rem; right: 0.75rem; }
.map-fabs-bottom { bottom: 7rem; right: 0.75rem; }
.map-fab {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--bg-solid);
    color: var(--text-main);
    box-shadow: var(--shadow);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.map-fab .ico { width: 1.35em; height: 1.35em; }
.map-fab:hover { background: rgba(30, 41, 59, 1); }
.map-fab.active { color: var(--primary); border-color: var(--primary); }

/* Ebenen-Karte */
.layers-card {
    position: absolute;
    bottom: 1rem;
    left: 1rem;
    width: 360px;
    max-width: calc(100% - 2rem);
    background: var(--bg-solid);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    box-shadow: var(--shadow);
    padding: 1rem 1.25rem;
    z-index: 34;
}
.layers-card.hidden { display: none; }
.layers-head { display: flex; justify-content: space-between; align-items: center; position: relative; padding-right: 2.5rem; }
.layers-head .close-btn { top: -0.6rem; right: -0.6rem; }
.map-type-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}
.map-type {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 0.8rem;
    cursor: pointer;
    min-height: 48px;
}
.map-type-thumb {
    width: 72px;
    height: 72px;
    border-radius: 0.85rem;
    border: 2px solid transparent;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
}
.map-type.active .map-type-thumb { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(59,130,246,0.35); }
.map-type.active span:last-child { color: var(--primary); font-weight: 600; }
.thumb-road {
    background:
        linear-gradient(90deg, transparent 46%, #9ca5b3 46%, #9ca5b3 54%, transparent 54%),
        linear-gradient(0deg, transparent 30%, #746855 30%, #746855 38%, transparent 38%),
        #242f3e;
}
.thumb-sat {
    background:
        radial-gradient(circle at 30% 35%, rgba(34,197,94,0.55), transparent 45%),
        radial-gradient(circle at 70% 70%, rgba(120,113,108,0.7), transparent 50%),
        linear-gradient(135deg, #1f3a2a, #3f4a2f 60%, #5b4a36);
}
.thumb-terrain {
    background:
        radial-gradient(ellipse at 50% 60%, transparent 38%, rgba(120,100,70,0.35) 40%, transparent 44%),
        radial-gradient(ellipse at 50% 60%, transparent 55%, rgba(120,100,70,0.35) 57%, transparent 61%),
        linear-gradient(180deg, #dfe8d2, #c9d3b5);
}

/* Panel-Kopf: Aktionsleiste im Maps-Look (Icon über Beschriftung) */
.panel-actions {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 0.6rem;
    margin-top: 0.9rem;
}
.panel-actions.hidden { display: none; }
.pact {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    padding: 0.7rem 0.25rem;
    border-radius: 0.9rem;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    text-decoration: none;
    font-size: 0.78rem;
    min-height: 64px;
}
.pact:hover { background: rgba(255,255,255,0.1); }
.pact-ico {
    width: 34px; height: 34px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--primary); color: #fff;
}
.pact-ico .ico { width: 1.15em; height: 1.15em; }
.pact.call .pact-ico { background: var(--status-green); }
.pact.wa .pact-ico { background: #25D366; }
.pact.mail .pact-ico { background: #6366f1; }

/* Globaler Fortschrittsbalken (Import / Geocoding) */
.global-progress {
    position: absolute;
    top: calc(var(--safe-top) + 4.25rem);
    left: 50%;
    transform: translateX(-50%);
    width: min(92%, 420px);
    background: var(--bg-solid);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 0.6rem 0.9rem;
    box-shadow: var(--shadow);
    z-index: 36;
    font-size: 0.8rem;
}
.global-progress.hidden { display: none; }
.gp-text { margin-bottom: 0.4rem; color: var(--text-main); }
.gp-bar { height: 6px; background: rgba(255,255,255,0.1); border-radius: 3px; overflow: hidden; }
.gp-fill { height: 100%; width: 0; background: var(--primary); transition: width 0.2s; }

/* Sperr-Regeln */
.rules { display: flex; flex-direction: column; gap: 0.25rem; margin-bottom: 1.5rem; }
.rules input[type="number"] {
    width: 90px;
    background: rgba(0,0,0,0.2);
    color: white;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.5rem 0.6rem;
    min-height: 44px;
    font-size: 1rem;
    text-align: right;
}

/* Snackbar */
.snackbar {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(5.5rem + var(--safe-bottom));
    background: var(--bg-solid);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.75rem 1.25rem;
    border-radius: 0.75rem;
    z-index: 60;
    font-size: 0.85rem;
    box-shadow: var(--shadow);
    max-width: 90vw;
    text-align: center;
}
.snackbar.hidden { display: none; }

/* ============================================================
   Mobil / Tablet: schmale Fenster ODER Touch-Geräte (auch breite Tablets)
   -> Vollbild-Karte, Bottom-Bar, Sheets
   ============================================================ */
@media (max-width: 899px), (pointer: coarse) {
    .sidebar { display: none; }
    .bottom-bar { display: flex; }

    .active-chips {
        top: calc(var(--safe-top) + 4.25rem);
        right: calc(0.75rem + 56px + var(--safe-right)); /* Platz für den Ebenen-Button */
    }
    .search-float .search-box input { border-radius: 999px; padding-left: 2.75rem; } /* Maps-Pill */
    .search-float .search-ico { left: 1.1rem; }
    .map-fabs-top { top: calc(var(--safe-top) + 4.25rem); right: calc(0.75rem + var(--safe-right)); }
    .map-fabs-bottom { bottom: calc(5.25rem + var(--safe-bottom)); right: calc(0.75rem + var(--safe-right)); }
    .layers-card {
        left: 0; right: 0; bottom: 0;
        width: auto; max-width: none;
        border-radius: 1.25rem 1.25rem 0 0;
        padding-bottom: calc(4.75rem + var(--safe-bottom));
    }

    .customer-panel {
        top: auto;
        left: 0; right: 0; bottom: 0;
        width: 100%;
        max-height: none;
        height: 45vh;
        height: 45dvh;
        border-radius: 1.25rem 1.25rem 0 0;
        padding: 0.25rem 1.25rem calc(1rem + var(--safe-bottom));
        transition: none;
        z-index: 32;
    }
    .customer-panel.hidden { transform: translateY(115%); transition: none; }
    .customer-panel:not(.hidden) { transform: none; }
    .panel-handle { display: block; }
    .panel-head { margin: 0 -1.25rem; padding: 0 1.25rem 0.25rem; }
}

/* ============================================================
   Desktop (≥900px UND Maus/Trackpad): Sidebar-Layout, keine Mobile-Elemente
   ============================================================ */
@media (min-width: 900px) and (pointer: fine) {
    .bottom-bar, .bottom-sheet, .sheet-backdrop, .search-float { display: none !important; }
    .panel-handle { display: none; }
}

/* ============================================================
   Breite Touch-Geräte (Tablet): Mobile-UI, aber zentriert statt bandbreit
   ============================================================ */
@media (pointer: coarse) and (min-width: 700px) {
    .bottom-sheet,
    .customer-panel {
        left: max(0px, calc(50% - 300px));
        right: max(0px, calc(50% - 300px));
        border-radius: 1.25rem 1.25rem 0 0;
    }
    .search-float {
        left: max(0.75rem, calc(50% - 300px));
        right: max(0.75rem, calc(50% - 300px));
    }
    .bottom-bar {
        left: max(0px, calc(50% - 300px));
        right: max(0px, calc(50% - 300px));
    }
    .active-chips {
        left: max(0.75rem, calc(50% - 300px));
        right: max(0.75rem, calc(50% - 300px + 56px));
    }
    .map-fabs-top { right: max(0.75rem, calc(50% - 300px)); }
    .layers-card {
        left: max(0px, calc(50% - 300px));
        right: max(0px, calc(50% - 300px));
        border-radius: 1.25rem 1.25rem 0 0;
    }
}

/* ============================================================
   Tablet im Querformat (Touch, ≥900px): Kundenpanel als Seitenpanel in
   voller Höhe (wie die Maps-App auf Tablets) statt halbhohem Bottom-Sheet
   ============================================================ */
@media (pointer: coarse) and (min-width: 900px) {
    .customer-panel {
        top: 0;
        bottom: 0;
        left: 0;
        right: auto;
        width: 440px;
        max-width: 46vw;
        height: auto !important;     /* überschreibt die per Drag gesetzte Höhe */
        max-height: none;
        border-radius: 0 1.25rem 1.25rem 0;
        padding: 0.75rem 1.5rem calc(1rem + var(--safe-bottom)) calc(1.5rem + var(--safe-left));
        z-index: 32;
    }
    .customer-panel.hidden { transform: translateX(-115%); }
    .customer-panel:not(.hidden) { transform: none; }
    .customer-panel .panel-handle { display: none; }
    .panel-head { margin: 0 -1.5rem; padding: 0.75rem 1.5rem 0.25rem; }
    .customer-header h2 { font-size: 1.5rem; }
    .subtitle { font-size: 0.95rem; }
    .pact { min-height: 72px; font-size: 0.85rem; }
    .pact-ico { width: 40px; height: 40px; }
    .contract-card { padding: 1.1rem 1.25rem; }
    .contract-details { font-size: 0.9rem; }
    .notes-section textarea { height: 100px; }
}
