/* ============================================================
   gROwKI — Map-Centric Design System
   Inspired by outletbuddy-style full-screen map + sidebar
   ============================================================ */

:root {
    /* Gemeinde Rommerskirchen Farben */
    --primary: #2F3E74;
    --primary-light: #3d4f8f;
    --primary-dark: #232e58;
    --primary-50: rgba(47, 62, 116, 0.06);
    --primary-100: rgba(47, 62, 116, 0.12);

    --accent: #AFD21D;
    --accent-light: #c2e040;
    --accent-dark: #8fb317;

    --green: #AFD21D;
    --green-bg: #f7fbe8;
    --orange: #f59e0b;
    --orange-bg: #fffbeb;
    --red: #ef4444;
    --red-bg: #fef2f2;
    --blue: #2F3E74;
    --blue-bg: #eef0f6;
    --purple: #2F3E74;
    --purple-bg: #eef0f6;

    --text: #111827;
    --text-2: #4b5563;
    --text-3: #9ca3af;
    --text-inv: #ffffff;

    --bg: #eef1f6;
    --bg-white: #ffffff;
    --border: #e5e7eb;
    --border-light: #f3f4f6;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.1);
    --shadow-lg: 0 20px 48px rgba(0,0,0,0.14);

    --r-sm: 8px;
    --r: 12px;
    --r-lg: 16px;
    --r-xl: 20px;
    --r-full: 9999px;

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --ease: cubic-bezier(0.4, 0, 0.2, 1);

    --sidebar-w: 380px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body:has(.app) { overflow: hidden; }

body {
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: var(--primary); color: white; }

/* ============================================================
   APP SHELL — Full-screen map + right sidebar
   ============================================================ */
.app {
    display: flex;
    height: 100vh;
    background: var(--bg);
    padding: 12px;
    gap: 0;
}

/* ── Map Area ── */
.map-area {
    flex: 1;
    position: relative;
    border-radius: var(--r-xl);
    overflow: hidden;
    box-shadow: var(--shadow);
}

#map {
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Floating controls on map */
.map-float-tl {
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 500;
    display: flex;
    gap: 8px;
}

.map-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--r-full);
    font-family: var(--font);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-2);
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: all 0.2s var(--ease);
}
.map-pill:hover { background: var(--primary-50); color: var(--primary); border-color: var(--primary-100); }
.map-pill.active { background: var(--primary); color: white; border-color: var(--primary); }
.map-pill.active i { color: white; }
.map-pill i { width: 16px; height: 16px; color: var(--primary); }

/* Floating bottom-right on map */
.map-float-br {
    position: absolute;
    bottom: 16px;
    right: 16px;
    z-index: 500;
}

.measure-result {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    background: var(--bg-white);
    border-radius: var(--r-full);
    box-shadow: var(--shadow-md);
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text);
}

.measure-clear {
    width: 28px; height: 28px;
    border-radius: var(--r-full);
    border: 1px solid var(--border);
    background: var(--bg-white);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-3);
    transition: all 0.15s;
}
.measure-clear:hover { background: var(--red-bg); color: var(--red); border-color: var(--red); }
.measure-clear i { width: 14px; height: 14px; }

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    background: var(--bg-white);
    flex-shrink: 0;
    border-radius: var(--r-xl);
    margin-left: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

/* Brand */
.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}
.brand-link:hover { text-decoration: none; }

.brand-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.8125rem;
    color: white;
    letter-spacing: -0.02em;
}

.brand-name {
    font-size: 1.375rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.04em;
}
.brand-name .hi {
    color: var(--accent);
    -webkit-text-fill-color: var(--accent);
}

.sidebar-brand-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--r);
    border: 1px solid var(--border);
    background: var(--bg-white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-3);
    transition: all 0.15s var(--ease);
}
.icon-btn:hover { background: var(--border-light); color: var(--text-2); }
.icon-btn i { width: 18px; height: 18px; }

/* Search */
.sidebar-search {
    padding: 12px 20px;
    position: relative;
    border-bottom: 1px solid var(--border-light);
}

.search-icon {
    position: absolute;
    right: 32px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-3);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 10px 40px 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--r);
    font-family: var(--font);
    font-size: 0.875rem;
    color: var(--text);
    background: var(--bg-white);
    transition: all 0.2s var(--ease);
    outline: none;
}
.search-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-50); }
.search-input::placeholder { color: var(--text-3); }

/* Filters */
.sidebar-filters {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-row-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-3);
    min-width: 48px;
    flex-shrink: 0;
}

.filter-pills {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.pill {
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: var(--r-full);
    font-family: var(--font);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-2);
    background: var(--bg-white);
    cursor: pointer;
    transition: all 0.15s var(--ease);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
}
.pill:hover { border-color: var(--primary); color: var(--primary); }
.pill.active { background: var(--primary); color: white; border-color: var(--primary); }
.pill i { width: 14px; height: 14px; }

.pill-icon {
    margin-left: auto;
}

.filter-expanded {
    padding-top: 4px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mini-input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    font-family: var(--font);
    font-size: 0.75rem;
    color: var(--text);
    outline: none;
    min-width: 0;
    transition: border-color 0.15s;
}
.mini-input:focus { border-color: var(--primary); }
.mini-input::placeholder { color: var(--text-3); }

/* Infra checkbox filters */
.infra-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.infra-check {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: var(--r-full);
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text-2);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.infra-check:hover { border-color: var(--primary); color: var(--primary); }
.infra-check:has(input:checked) { background: var(--primary); color: white; border-color: var(--primary); }
.infra-check:has(input:checked) i { color: white; }
.infra-check input { display: none; }
.infra-check i { width: 12px; height: 12px; }

/* Parcel List */
.sidebar-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-list::-webkit-scrollbar { width: 4px; }
.sidebar-list::-webkit-scrollbar-track { background: transparent; }
.sidebar-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    cursor: pointer;
    transition: background 0.15s var(--ease);
    border-bottom: 1px solid var(--border-light);
    position: relative;
}
.list-item:hover { background: var(--primary-50); }
.list-item:last-child { border-bottom: none; }
.list-item.selected { background: var(--primary-50); }

/* Favorite button on list items */
.fav-btn {
    width: 28px; height: 28px;
    border: none; background: none;
    cursor: pointer; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-3);
    transition: all 0.15s;
    border-radius: var(--r-full);
}
.fav-btn:hover { color: var(--red); background: var(--red-bg); }
.fav-btn.active { color: var(--red); }
.fav-btn i { width: 16px; height: 16px; }

/* Compare checkbox on list items */
.compare-check {
    width: 20px; height: 20px;
    border: 2px solid var(--border);
    border-radius: 4px;
    cursor: pointer; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
    background: var(--bg-white);
}
.compare-check:hover { border-color: var(--primary); }
.compare-check.active { background: var(--primary); border-color: var(--primary); color: white; }
.compare-check i { width: 14px; height: 14px; }

.list-item-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--primary);
}
.list-item-icon.ge { color: var(--primary); }
.list-item-icon.gi { color: var(--primary); }
.list-item-icon i { width: 20px; height: 20px; }

.list-item-info {
    flex: 1;
    min-width: 0;
}

.list-item-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.list-item-meta {
    font-size: 0.75rem;
    color: var(--text-3);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.list-item-meta .dot {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--text-3);
}

.meta-status { font-weight: 600; }
.meta-status.available { color: var(--accent-dark); }
.meta-status.reserved { color: var(--orange); }
.meta-status.sold { color: var(--red); }
.meta-status.planning { color: var(--primary); }

.list-item-badge {
    width: 32px;
    height: 32px;
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.list-item-badge.available { background: var(--green-bg); color: var(--green); }
.list-item-badge.reserved { background: var(--orange-bg); color: var(--orange); }
.list-item-badge.sold { background: var(--red-bg); color: var(--red); }
.list-item-badge.planning { background: var(--blue-bg); color: var(--blue); }
.list-item-badge i { width: 16px; height: 16px; }

.list-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.list-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-3);
}
.list-empty i { width: 32px; height: 32px; margin-bottom: 8px; opacity: 0.4; }
.list-empty p { font-size: 0.875rem; }

/* Sidebar Footer / Stats */
.sidebar-footer {
    display: flex;
    padding: 14px 20px;
    border-top: 1px solid var(--border-light);
    background: var(--border-light);
    gap: 4px;
}

.footer-stat {
    flex: 1;
    text-align: center;
}

.footer-stat-value {
    font-size: 1.125rem;
    font-weight: 800;
    color: var(--text);
    display: block;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.footer-stat-label {
    font-size: 0.625rem;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.compare-btn {
    padding: 10px 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--r);
    font-family: var(--font);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s;
    flex-shrink: 0;
}
.compare-btn:hover { background: var(--primary-light); }
.compare-btn i { width: 16px; height: 16px; }
.compare-count {
    background: var(--accent);
    color: var(--primary-dark);
    border-radius: var(--r-full);
    padding: 1px 7px;
    font-size: 0.6875rem;
    font-weight: 800;
}

/* ============================================================
   MAP POPUP — Rich card (Mapbox)
   ============================================================ */

.popup-card { padding: 0; }

.popup-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 16px 12px;
}

.popup-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--primary);
}
.popup-icon.ge { color: var(--primary); }
.popup-icon.gi { color: var(--primary); }
.popup-icon i { width: 22px; height: 22px; }

.popup-title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.3;
}

.popup-subtitle {
    font-size: 0.75rem;
    color: var(--text-3);
    display: flex;
    align-items: center;
    gap: 4px;
}
.popup-subtitle a { color: var(--primary); font-weight: 500; }

.popup-verified {
    width: 18px;
    height: 18px;
    color: var(--primary);
    flex-shrink: 0;
    margin-left: auto;
}

/* Popup badges row */
.popup-badges {
    display: flex;
    gap: 8px;
    padding: 0 16px 12px;
    flex-wrap: wrap;
}

.popup-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--border-light);
    border-radius: var(--r-full);
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-2);
}
.popup-badge i { width: 13px; height: 13px; }

/* Popup stats grid */
.popup-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: var(--border-light);
    border-top: 1px solid var(--border-light);
    border-bottom: 1px solid var(--border-light);
}

.popup-stat {
    background: var(--bg-white);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.popup-stat i { width: 16px; height: 16px; color: var(--text-3); }

.popup-stat-value {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}

.popup-stat-label {
    font-size: 0.6875rem;
    color: var(--text-3);
    font-weight: 500;
}

/* Popup footer */
.popup-footer {
    padding: 12px 16px;
    text-align: center;
}

.popup-link {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.popup-link:hover { text-decoration: underline; }
.popup-link i { width: 14px; height: 14px; }

/* ============================================================
   DETAIL PANEL — Slides up on map (mobile: bottom sheet)
   ============================================================ */
.detail-panel {
    position: absolute;
    bottom: 16px;
    left: 16px;
    right: 16px;
    z-index: 600;
    background: var(--bg-white);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-lg);
    max-height: 60%;
    overflow-y: auto;
    transform: translateY(calc(100% + 32px));
    transition: transform 0.35s var(--ease);
    pointer-events: none;
}
.detail-panel.active {
    transform: translateY(0);
    pointer-events: auto;
}

.detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    background: var(--bg-white);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    z-index: 1;
}

.detail-title h2 {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -0.02em;
}

.detail-title-badges {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}

.d-badge {
    padding: 3px 10px;
    border-radius: var(--r-full);
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.d-badge.available { background: var(--green-bg); color: var(--green); }
.d-badge.reserved { background: var(--orange-bg); color: var(--orange); }
.d-badge.sold { background: var(--red-bg); color: var(--red); }
.d-badge.planning { background: var(--blue-bg); color: var(--blue); }
.d-badge.ge { background: var(--blue-bg); color: var(--blue); }
.d-badge.gi { background: var(--purple-bg); color: var(--purple); }
.d-badge.neutral { background: var(--border-light); color: var(--text-2); }

.detail-close {
    width: 32px; height: 32px;
    border-radius: var(--r-full);
    border: 1px solid var(--border);
    background: var(--bg-white);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-3);
    flex-shrink: 0;
    transition: all 0.15s;
}
.detail-close:hover { background: var(--border-light); color: var(--text); }

.detail-body {
    padding: 20px 24px;
}

.detail-desc {
    font-size: 0.875rem;
    color: var(--text-2);
    line-height: 1.65;
    margin-bottom: 20px;
}

/* Stats grid in detail */
.detail-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.detail-stat-card {
    background: var(--border-light);
    border-radius: var(--r);
    padding: 14px;
    text-align: center;
}

.detail-stat-card i { width: 20px; height: 20px; color: var(--text-3); margin-bottom: 4px; }
.detail-stat-card .val { font-size: 1.125rem; font-weight: 800; color: var(--text); display: block; letter-spacing: -0.02em; }
.detail-stat-card .lbl { font-size: 0.625rem; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; }

/* Infra tags in detail */
.detail-infra {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 20px;
}

.infra-chip {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    background: var(--green-bg);
    border-radius: var(--r-full);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
}
.infra-chip i { width: 14px; height: 14px; }

/* Detail section titles */
.detail-section-label {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-3);
    margin-bottom: 10px;
}

/* Detail row */
.detail-kv {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.8125rem;
}
.detail-kv:last-child { border-bottom: none; }
.detail-kv .k { color: var(--text-3); }
.detail-kv .v { font-weight: 600; color: var(--text); }

/* Detail actions */
.detail-actions {
    display: flex;
    gap: 8px;
    margin-top: 20px;
}

.detail-actions .btn { flex: 1; }

/* ============================================================
   BUTTONS (shared)
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: 1px solid transparent;
    border-radius: var(--r);
    font-family: var(--font);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s var(--ease);
    white-space: nowrap;
    text-decoration: none;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn i { width: 16px; height: 16px; }

.btn-primary { background: var(--primary); color: white; box-shadow: 0 2px 8px rgba(47,62,116,0.25); }
.btn-primary:hover { background: var(--primary-light); color: white; box-shadow: 0 4px 12px rgba(47,62,116,0.3); }

.btn-accent { background: var(--accent); color: var(--primary-dark); font-weight: 700; box-shadow: 0 2px 8px rgba(175,210,29,0.3); }
.btn-accent:hover { background: var(--accent-light); color: var(--primary-dark); }

.btn-outline { background: var(--bg-white); border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--text-3); }

.btn-sm { padding: 6px 14px; font-size: 0.75rem; }
.btn-lg { padding: 12px 24px; font-size: 0.9375rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.35);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
    opacity: 0; visibility: hidden;
    transition: all 0.25s var(--ease);
}
.modal-overlay.active { opacity: 1; visibility: visible; }

.modal {
    background: var(--bg-white);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-lg);
    width: 100%; max-width: 420px; max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.96) translateY(8px);
    transition: transform 0.25s var(--ease);
}
.modal-overlay.active .modal { transform: scale(1) translateY(0); }

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-light);
    display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 1.125rem; font-weight: 700; }

.modal-close {
    width: 32px; height: 32px;
    border-radius: var(--r-full);
    background: var(--border-light);
    border: none;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-3);
    font-size: 1.125rem;
    transition: all 0.15s;
}
.modal-close:hover { background: var(--border); color: var(--text); }

.modal-body { padding: 24px; }

/* ============================================================
   FORMS (shared)
   ============================================================ */
.form-group { margin-bottom: 16px; }

.form-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--r);
    font-family: var(--font);
    font-size: 0.875rem;
    color: var(--text);
    background: var(--bg-white);
    transition: all 0.15s;
    outline: none;
}
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-50); }
.form-input::placeholder { color: var(--text-3); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ============================================================
   TOAST
   ============================================================ */
.toast-container {
    position: fixed; top: 20px; right: 20px;
    z-index: 3000;
    display: flex; flex-direction: column; gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--r);
    color: white;
    font-size: 0.8125rem;
    font-weight: 600;
    box-shadow: var(--shadow-md);
    animation: toastIn 0.35s var(--ease);
    max-width: 360px;
}
.toast-success { background: var(--accent-dark); color: white; }
.toast-error   { background: var(--red); }
.toast-warning { background: var(--orange); }
.toast-info    { background: var(--primary); }

@keyframes toastIn {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

/* ============================================================
   INFO OVERLAY
   ============================================================ */
.info-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(4px);
    z-index: 1500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.info-card {
    background: var(--bg-white);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 440px;
    overflow: hidden;
}

.info-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-light);
}
.info-card-header h3 { font-size: 1.125rem; font-weight: 700; }

.info-card-body { padding: 24px; }
.info-card-body > p { font-size: 0.875rem; color: var(--text-2); line-height: 1.65; margin-bottom: 20px; }

.info-features { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }

.info-feature {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 0.8125rem;
}
.info-feature i { width: 20px; height: 20px; color: var(--primary); flex-shrink: 0; margin-top: 2px; }
.info-feature strong { color: var(--text); display: block; margin-bottom: 2px; }
.info-feature span { color: var(--text-3); font-size: 0.75rem; }

.info-links {
    display: flex; gap: 12px; margin-bottom: 20px;
    padding-top: 16px; border-top: 1px solid var(--border-light);
}
.info-links a {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--r);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-2);
    transition: all 0.15s;
}
.info-links a:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }

.info-copy { font-size: 0.6875rem; color: var(--text-3); }

/* ============================================================
   MAPBOX GL OVERRIDES
   ============================================================ */
.mapboxgl-popup-content {
    border-radius: var(--r-lg) !important;
    box-shadow: var(--shadow-md) !important;
    border: none !important;
    padding: 0 !important;
    font-family: var(--font) !important;
    font-size: 0.875rem !important;
    min-width: 280px;
    max-width: 320px;
    overflow: hidden;
}
.mapboxgl-popup-tip { border-top-color: var(--bg-white) !important; }
.mapboxgl-popup-close-button { display: none !important; }

.mapboxgl-ctrl-group {
    border-radius: var(--r) !important;
    box-shadow: var(--shadow-sm) !important;
    border: 1px solid var(--border) !important;
    overflow: hidden;
}
.mapboxgl-ctrl-group button {
    width: 36px !important;
    height: 36px !important;
}
.mapboxgl-ctrl-group button:hover {
    background-color: var(--primary-50) !important;
}

.mapboxgl-ctrl-attrib {
    font-size: 0.625rem !important;
    background: rgba(255,255,255,0.7) !important;
    border-radius: var(--r-sm) !important;
}

.mapboxgl-map { font-family: var(--font); }

/* ============================================================
   SPINNER
   ============================================================ */
.spinner {
    width: 24px; height: 24px;
    border: 2.5px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   UTILITY
   ============================================================ */
.text-center { text-align: center; }
.text-muted { color: var(--text-3); }
.text-small { font-size: 0.8125rem; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.hidden { display: none !important; }

/* ============================================================
   BADGES (shared, for subpages)
   ============================================================ */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: var(--r-full);
    font-size: 0.6875rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.03em;
}
.badge-info { background: var(--blue-bg); color: var(--blue); }

/* ============================================================
   SUBPAGES (cockpit, portal, dashboard stubs)
   ============================================================ */
.page-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.page-nav {
    background: var(--primary-dark);
    color: white;
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.page-nav .brand-link { text-decoration: none; display: flex; align-items: center; gap: 10px; }
.page-nav .brand-icon { width: 32px; height: 32px; font-size: 0.75rem; border-radius: 8px; }
.page-nav .brand-name { color: white; font-size: 1.125rem; }

.page-nav-links {
    display: flex; gap: 4px; list-style: none;
}
.page-nav-links a {
    color: rgba(255,255,255,0.6);
    padding: 8px 14px;
    border-radius: var(--r-sm);
    font-size: 0.8125rem;
    font-weight: 500;
    transition: all 0.15s;
}
.page-nav-links a:hover { color: white; background: rgba(255,255,255,0.1); text-decoration: none; }
.page-nav-links a.active { color: white; background: rgba(255,255,255,0.15); }

.page-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.page-card {
    background: var(--bg-white);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow);
    padding: 48px;
    max-width: 520px;
    text-align: center;
}
.page-card h2 { margin-bottom: 8px; }
.page-card p { color: var(--text-2); margin-bottom: 20px; font-size: 0.9375rem; }
.page-card ul {
    text-align: left; max-width: 320px; margin: 0 auto 24px;
    list-style: none;
}
.page-card ul li {
    padding: 6px 0; font-size: 0.875rem; color: var(--text-2);
    display: flex; align-items: center; gap: 8px;
}
.page-card ul li::before {
    content: ''; width: 6px; height: 6px;
    border-radius: 50%; background: var(--primary); flex-shrink: 0;
}

.page-footer {
    padding: 16px 24px;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-3);
    border-top: 1px solid var(--border-light);
}

/* ============================================================
   WIDE MODAL + COMPARE TABLE
   ============================================================ */
.modal-wide .modal { max-width: 720px; }

.compare-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}
.compare-table th {
    text-align: left;
    padding: 8px 12px;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-3);
    background: var(--border-light);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0;
}
.compare-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: top;
}
.compare-table tr:last-child td { border-bottom: none; }
.compare-table .compare-label {
    font-weight: 600;
    color: var(--text-2);
    min-width: 100px;
    white-space: nowrap;
}
.compare-table .compare-val {
    font-weight: 500;
    color: var(--text);
}
.compare-table .compare-name {
    font-weight: 700;
    color: var(--primary);
    cursor: pointer;
}
.compare-table .compare-name:hover { text-decoration: underline; }

/* ============================================================
   IMAGE GALLERY IN DETAIL PANEL
   ============================================================ */
.detail-gallery {
    margin-bottom: 20px;
    border-radius: var(--r);
    overflow: hidden;
    position: relative;
}

.gallery-main {
    width: 100%;
    height: 200px;
    position: relative;
    background: var(--border-light);
}
.gallery-main img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 32px; height: 32px;
    border-radius: var(--r-full);
    background: rgba(255,255,255,0.9);
    border: none;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--text);
    box-shadow: var(--shadow-sm);
    transition: all 0.15s;
    z-index: 2;
}
.gallery-nav:hover { background: white; box-shadow: var(--shadow); }
.gallery-nav.prev { left: 8px; }
.gallery-nav.next { right: 8px; }
.gallery-nav i { width: 16px; height: 16px; }

.gallery-counter {
    position: absolute;
    bottom: 8px; right: 8px;
    background: rgba(0,0,0,0.6);
    color: white;
    padding: 2px 8px;
    border-radius: var(--r-full);
    font-size: 0.6875rem;
    font-weight: 600;
    z-index: 2;
}

.gallery-thumbs {
    display: flex;
    gap: 4px;
    padding: 6px;
    background: var(--border-light);
    overflow-x: auto;
}
.gallery-thumb {
    width: 48px; height: 36px;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    flex-shrink: 0;
    border: 2px solid transparent;
    transition: border-color 0.15s;
}
.gallery-thumb.active { border-color: var(--primary); }
.gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ============================================================
   IMPORT MODAL (WiFö Flurstück → Parzelle)
   ============================================================ */
.import-preview {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 12px;
    background: var(--border-light);
    border-radius: var(--r);
    margin-bottom: 16px;
    font-size: 0.8125rem;
}
.import-preview .k { color: var(--text-3); font-weight: 500; }
.import-preview .v { color: var(--text); font-weight: 600; }

.import-infra-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.import-infra-grid label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8125rem;
    color: var(--text-2);
    cursor: pointer;
}
.import-infra-grid input[type="checkbox"] {
    accent-color: var(--primary);
}

/* Flurstueck layer label on map */
.flurstueck-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-2);
    text-shadow: 0 0 3px white, 0 0 3px white;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .app {
        flex-direction: column;
        padding: 0;
        gap: 0;
    }

    .map-area {
        border-radius: 0;
        height: 55vh;
        flex: none;
    }

    .sidebar {
        width: 100%;
        border-radius: 0;
        margin: 0;
        flex: 1;
        min-height: 45vh;
    }

    .detail-panel {
        bottom: 0;
        left: 0;
        right: 0;
        border-radius: var(--r-xl) var(--r-xl) 0 0;
        max-height: 70%;
    }

    .form-row { grid-template-columns: 1fr; }

    .map-float-tl { flex-wrap: wrap; gap: 4px; }
    .map-pill { padding: 6px 10px; font-size: 0.75rem; }
    .map-pill span { display: none; }

    .modal-wide .modal { max-width: 100%; }
    .compare-table { font-size: 0.75rem; }

    .import-preview { grid-template-columns: 1fr; }
    .import-infra-grid { grid-template-columns: 1fr; }
}
