:root {
    --bg-base: #0f172a;
    --bg-surface: #1e293b;
    --bg-surface-elevated: #334155;
    --border-color: rgba(255, 255, 255, 0.1);
    --border-highlight: rgba(255, 255, 255, 0.18);
    
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-light: rgba(59, 130, 246, 0.15);
    
    --chotot-color: #f59e0b;
    --nhagoc-color: #10b981;
    --benchmark-color: #8b5cf6;
    
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-full: 9999px;
    
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.25);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.35);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.5);
    --glass-bg: rgba(15, 23, 42, 0.85);
    --glass-blur: blur(12px);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body, html {
    width: 100%;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    background: var(--bg-base);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

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

/* ── HEADER ── */
.app-header {
    position: absolute;
    top: 14px;
    left: 14px;
    right: 14px;
    height: 56px;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 1000;
}

.header-left, .header-center, .header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--primary);
    font-size: 20px;
    user-select: none;
}

.logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.logo-text .brand {
    font-size: 14px;
    font-weight: 800;
    color: #fff;
    letter-spacing: 0.5px;
}

.logo-text .sub-brand {
    font-size: 10px;
    font-weight: 700;
    color: var(--chotot-color);
    letter-spacing: 1px;
}

/* Search Box */
.search-box {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    padding: 4px 6px 4px 12px;
    width: 290px;
    transition: all 0.2s;
}

.search-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
    width: 320px;
}

.search-icon {
    color: var(--text-muted);
    font-size: 15px;
    margin-right: 6px;
}

.search-box input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 12.5px;
    width: 100%;
}

.search-box button {
    background: var(--primary);
    border: none;
    color: #fff;
    width: 26px;
    height: 26px;
    border-radius: var(--radius-full);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

/* Segmented Control */
.segmented-control {
    display: flex;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    padding: 3px;
    gap: 2px;
}

.segment-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: var(--radius-full);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s;
}

.segment-btn.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.segment-btn.active.btn-rent {
    background: #2563eb !important;
    color: #fff !important;
}
.segment-btn.active.btn-sell {
    background: #dc2626 !important;
    color: #fff !important;
}

/* Source Toggles */
.source-toggles {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chip-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 11.5px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    transition: all 0.2s;
}

.chip-toggle input {
    display: none;
}

.chip-toggle .indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: all 0.2s;
}

.chotot-chip input:checked ~ .indicator { background: var(--chotot-color); box-shadow: 0 0 6px var(--chotot-color); }
.nhagoc-chip input:checked ~ .indicator { background: var(--nhagoc-color); box-shadow: 0 0 6px var(--nhagoc-color); }
.benchmark-chip input:checked ~ .indicator { background: var(--benchmark-color); box-shadow: 0 0 6px var(--benchmark-color); }

.chip-toggle .badge {
    font-size: 10px;
    background: rgba(255,255,255,0.08);
    padding: 1px 5px;
    border-radius: var(--radius-full);
    color: var(--text-muted);
}

/* Action Buttons */
.action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.15s;
}

.action-btn:hover {
    background: var(--bg-surface-elevated);
    border-color: var(--border-highlight);
    color: #fff;
}

.action-btn.primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.action-btn.primary:hover {
    background: var(--primary-hover);
}

.action-btn.icon-only {
    padding: 6px 8px;
}

/* ── FLOATING MAP CONTROLS ── */
.floating-map-controls {
    position: absolute;
    bottom: 24px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
}

.map-ctrl-btn {
    width: 44px;
    height: 44px;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-md);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.map-ctrl-btn:hover {
    background: var(--bg-surface-elevated);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-2px);
}

.map-ctrl-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.6);
}

/* ── LISTINGS DRAWER ── */
.listings-drawer {
    position: absolute;
    top: 84px;
    right: 14px;
    bottom: 24px;
    width: 360px;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    z-index: 999;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.listings-drawer.hidden {
    transform: translateX(390px);
    pointer-events: none;
    opacity: 0;
}

.drawer-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.drawer-header h3 {
    font-size: 14px;
    font-weight: 700;
}

.drawer-sub {
    font-size: 11px;
    color: var(--text-muted);
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
}
.close-btn:hover { color: #fff; }

.drawer-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mobile-floating-list-btn,
.drawer-backdrop {
    display: none;
}

.listing-card-compact {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    gap: 12px;
    overflow: hidden;
    position: relative;
    flex-shrink: 0 !important; /* PREVENTS CARDS FROM BEING SQUISHED */
    min-height: 120px !important; /* ENSURES FULL CARD HEIGHT FOR THUMBNAIL + TITLE + PRICE + BUTTONS */
    box-sizing: border-box;
}

.listing-card-compact:hover {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.08);
}

.thumb-wrapper {
    width: 75px !important;
    height: 75px !important;
    min-width: 75px !important;
    max-width: 75px !important;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #0f172a;
    flex-shrink: 0 !important;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.thumb-wrapper img, .drawer-thumb-img {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: cover !important;
    display: block !important;
}

.listing-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 4px;
}

.listing-title {
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
}

.listing-price {
    font-size: 13px;
    font-weight: 700;
    color: #10b981;
}

.listing-meta {
    font-size: 10px;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
}

/* ── MODALS ── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-highlight);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 440px;
    max-width: 90vw;
    overflow: hidden;
}

.modal-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-header h3 { font-size: 15px; font-weight: 700; display:flex; align-items:center; gap:8px;}

.modal-body { padding: 18px; }
.modal-footer {
    padding: 12px 18px;
    background: rgba(0,0,0,0.15);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.form-row { display: flex; gap: 10px; }

.form-control {
    width: 100%;
    background: var(--bg-base);
    border: 1px solid var(--border-color);
    color: #fff;
    padding: 8px 12px;
    font-size: 13px;
    border-radius: var(--radius-sm);
    outline: none;
}
.form-control:focus { border-color: var(--primary); }

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    cursor: pointer;
    user-select: none;
}

.btn {
    border: none;
    padding: 7px 14px;
    font-size: 12.5px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: var(--bg-surface-elevated); color: var(--text-secondary); }
.btn-warning { background: var(--chotot-color); color: #000; font-weight:700; }
.btn-success { background: var(--nhagoc-color); color: #fff; }

.crawler-action-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-base);
    padding: 12px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}
.source-info strong { display: block; font-size: 13px; }
.source-info span { font-size: 11px; color: var(--text-muted); }

/* ── STREET VIEW 360 FLOATING WINDOW ── */
.sv-window {
    position: fixed;
    width: 480px;
    height: 340px;
    background: #000;
    border: 1px solid var(--border-highlight);
    border-radius: var(--radius-md);
    box-shadow: 0 12px 36px rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    z-index: 5000;
    overflow: hidden;
    resize: both;
    min-width: 300px;
    min-height: 200px;
}

.sv-header {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: move;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    user-select: none;
}

.sv-title {
    font-size: 11.5px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
    color: #fff;
}

.sv-controls button {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    margin-left: 6px;
}
.sv-controls button:hover { color: #fff; }

.sv-body {
    flex: 1;
    position: relative;
    background: #000;
}

.sv-body iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* ── LEAFLET CUSTOM POPUP ── */
.leaflet-popup-content-wrapper {
    background: var(--bg-surface) !important;
    color: var(--text-primary) !important;
    border-radius: var(--radius-md) !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: var(--shadow-lg) !important;
    padding: 0 !important;
    overflow: hidden !important;
}

.leaflet-popup-content {
    margin: 0 !important;
    padding: 12px 14px !important;
    line-height: 1.4 !important;
    font-size: 12px !important;
    width: 295px !important;
    max-width: 320px !important;
    box-sizing: border-box !important;
}

.popup-close-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 15px;
    z-index: 50;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.6);
    transition: all 0.15s ease;
    padding: 0;
    outline: none;
}

.popup-close-btn:hover, .popup-close-btn:active {
    background: #ef4444;
    border-color: #ef4444;
    color: #ffffff;
    transform: scale(1.08);
}

.leaflet-popup-close-button {
    display: none !important;
}

/* OVERRIDE LEAFLET .leaflet-container img { max-width: none !important; } */
.popup-thumb-wrapper {
    width: 100% !important;
    height: 120px !important;
    max-height: 120px !important;
    border-radius: 6px !important;
    overflow: hidden !important;
    margin-bottom: 8px !important;
    background: #0f172a !important;
    position: relative !important;
}

.popup-thumb-img {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: cover !important;
    display: block !important;
}

.popup-brand-logo {
    width: 13px !important;
    height: 13px !important;
    max-width: 13px !important;
    max-height: 13px !important;
    object-fit: contain !important;
    border-radius: 2px !important;
    display: inline-block !important;
    vertical-align: middle !important;
}

/* Map marker custom pins */
.brand-pin-rent, .brand-pin-sell {
    background: transparent !important;
    border: none !important;
}

.marker-logo-wrapper {
    background: #ffffff !important;
    width: 38px !important;
    height: 38px !important;
    max-width: 38px !important;
    max-height: 38px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: hidden !important;
    padding: 2px !important;
    box-sizing: border-box !important;
}

.marker-brand-logo {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain !important;
    border-radius: 50% !important;
    display: block !important;
}

.leaflet-popup-tip {
    background: var(--bg-surface) !important;
}

/* Marker Cluster Styling */
.marker-cluster-small, .marker-cluster-medium, .marker-cluster-large {
    background-color: rgba(59, 130, 246, 0.4) !important;
}
.marker-cluster-small div, .marker-cluster-medium div, .marker-cluster-large div {
    background-color: rgba(30, 58, 138, 0.8) !important;
    color: #fff !important;
    font-weight: 700 !important;
    font-size: 12px !important;
}

/* ── LEAFLET CONTROL LAYERS ── */
.leaflet-control-layers {
    background: var(--glass-bg) !important;
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius-md) !important;
    color: var(--text-primary) !important;
    box-shadow: var(--shadow-md) !important;
    padding: 8px 12px !important;
    font-size: 12.5px !important;
    font-family: inherit !important;
}

.leaflet-control-layers-base label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 5px;
    cursor: pointer;
    font-size: 12px;
}

.leaflet-control-layers-toggle {
    background-color: var(--bg-surface) !important;
    border-radius: var(--radius-sm) !important;
}

/* Custom Marker Cluster Badges */
.custom-cluster-rent, .custom-cluster-sell, .custom-cluster-chotot, .custom-cluster-nhagoc, .custom-cluster-benchmark {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

/* Floating offset for bottom-left control */
.leaflet-bottom.leaflet-left {
    margin-bottom: 14px;
    margin-left: 14px;
}
.leaflet-bottom.leaflet-left .leaflet-control {
    margin: 0;
}

/* ── VISUAL FILTER ENGINE STYLES ── */
.visual-filter-card {
    width: 520px;
    max-width: 94vw;
}

.visual-filter-body {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-height: 78vh;
    overflow-y: auto;
}

.filter-section {
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 14px;
}

.slider-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.filter-section-title {
    font-size: 12.5px;
    font-weight: 700;
    color: #e2e8f0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.slider-badge {
    font-size: 12px;
    font-weight: 700;
    color: var(--primary);
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(59, 130, 246, 0.3);
    padding: 2px 8px;
    border-radius: 4px;
}

.range-slider-wrap {
    position: relative;
    height: 28px;
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.slider-track-bg {
    position: absolute;
    width: 100%;
    height: 6px;
    background: #334155;
    border-radius: 3px;
    z-index: 1;
}

.slider-track-fill {
    position: absolute;
    height: 6px;
    background: linear-gradient(90deg, #3b82f6, #60a5fa);
    border-radius: 3px;
    z-index: 2;
    left: 0%;
    width: 100%;
}

.range-slider-input {
    position: absolute;
    width: 100%;
    background: none;
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
    z-index: 3;
    margin: 0;
    outline: none;
}

.range-slider-input::-webkit-slider-thumb {
    pointer-events: auto;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ffffff;
    border: 3px solid #3b82f6;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    cursor: grab;
    transition: transform 0.1s ease, border-color 0.1s ease;
}

.range-slider-input::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    border-color: #60a5fa;
}

.range-slider-input::-webkit-slider-thumb:active {
    cursor: grabbing;
    transform: scale(1.25);
}

.range-slider-input::-moz-range-thumb {
    pointer-events: auto;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #ffffff;
    border: 3px solid #3b82f6;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    cursor: grab;
}

.quick-chips-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chip-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}

.chip-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-color: var(--border-highlight);
}

.chip-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.4);
}

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

.smart-select {
    cursor: pointer;
    font-size: 12px;
}
.smart-select optgroup {
    background: #0f172a;
    color: #94a3b8;
    font-weight: 700;
}
.smart-select option {
    background: #1e293b;
    color: #fff;
    font-weight: 500;
}

.visual-filter-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
}

.live-counter-box {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.live-counter-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 6px #10b981;
    display: inline-block;
}

.live-counter-box strong {
    color: #fff;
    font-weight: 700;
}

.active-filter-badge {
    background: #3b82f6;
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    margin-left: 4px;
}

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE DESIGN FOR TABLETS & MOBILE DEVICES
   ═══════════════════════════════════════════════════════════════════ */

/* ── TABLETS & SMARTPHONES (<= 860px) ── */
@media (max-width: 860px) {
    /* Responsive Header: Grid layout with swipeable filter strip */
    .app-header {
        top: max(8px, env(safe-area-inset-top));
        left: max(8px, env(safe-area-inset-left));
        right: max(8px, env(safe-area-inset-right));
        height: auto;
        padding: 8px 12px;
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "left right"
            "center center";
        row-gap: 8px;
        border-radius: 16px;
    }

    .header-left {
        grid-area: left;
    }

    .header-right {
        grid-area: right;
        gap: 6px;
    }

    .header-center {
        grid-area: center;
        width: 100%;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        display: flex;
        align-items: center;
        gap: 8px;
        padding-bottom: 2px;
    }
    .header-center::-webkit-scrollbar {
        display: none;
    }

    .segmented-control {
        flex-shrink: 0;
    }

    .source-toggles {
        flex-shrink: 0;
    }

    /* Position Leaflet controls so they don't collide with mobile header */
    .leaflet-top.leaflet-left {
        top: 105px !important;
        left: 10px !important;
    }

    /* Floating Map Controls */
    .floating-map-controls {
        bottom: max(20px, env(safe-area-inset-bottom));
        right: max(14px, env(safe-area-inset-right));
        gap: 8px;
    }

    .map-ctrl-btn {
        width: 42px;
        height: 42px;
        font-size: 17px;
    }

    /* Floating List Button (Bottom Center Pill for Mobile) */
    .mobile-floating-list-btn {
        display: flex !important;
        align-items: center;
        gap: 8px;
        position: fixed;
        bottom: max(22px, env(safe-area-inset-bottom, 22px));
        left: 50%;
        transform: translateX(-50%);
        background: #2563eb;
        color: #ffffff;
        padding: 10px 18px;
        border-radius: var(--radius-full);
        border: 1px solid rgba(255, 255, 255, 0.25);
        box-shadow: 0 8px 24px rgba(37, 99, 235, 0.55), 0 2px 8px rgba(0, 0, 0, 0.4);
        font-size: 13px;
        font-weight: 700;
        cursor: pointer;
        z-index: 1050;
        transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-floating-list-btn:active {
        transform: translateX(-50%) scale(0.96);
        background: #1d4ed8;
    }

    .floating-pill-badge {
        background: rgba(255, 255, 255, 0.25);
        color: #ffffff;
        padding: 2px 7px;
        border-radius: var(--radius-full);
        font-size: 11px;
        font-weight: 800;
    }

    /* Drawer Backdrop (Dims map when bottom sheet is open) */
    .drawer-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.55);
        backdrop-filter: blur(2px);
        -webkit-backdrop-filter: blur(2px);
        z-index: 1400;
    }

    /* Listings Drawer: Transforms into a Native Mobile Bottom Sheet */
    .listings-drawer {
        position: fixed !important;
        top: auto !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        height: 75vh !important;
        max-height: 85vh !important;
        border-radius: 20px 20px 0 0 !important;
        border: none !important;
        border-top: 1px solid var(--border-highlight) !important;
        box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.85) !important;
        transform: translateY(0);
        transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
        padding-bottom: env(safe-area-inset-bottom, 10px);
        z-index: 1500 !important; /* Above backdrop and all map controls */
    }

    .listings-drawer.hidden {
        transform: translateY(105%) !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    .drawer-header {
        padding: 16px 18px 12px;
        position: relative;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    /* Bottom sheet drag handle indicator */
    .drawer-header::before {
        content: '';
        position: absolute;
        top: 6px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background: rgba(255, 255, 255, 0.35);
        border-radius: 2px;
    }

    .drawer-header .close-btn {
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(255, 255, 255, 0.1);
        border-radius: 50%;
        color: #fff;
        font-size: 16px;
    }

    .drawer-content {
        padding: 10px 14px;
        gap: 8px;
    }

    .listing-card-compact {
        padding: 10px 12px;
        flex-shrink: 0 !important;
        min-height: 120px !important;
    }

    .thumb-wrapper {
        width: 75px !important;
        height: 75px !important;
        min-width: 75px !important;
        max-width: 75px !important;
        flex-shrink: 0 !important;
    }

    /* Street View 360 Window: Docked Mobile Bottom Panel */
    .sv-window {
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        top: auto !important;
        width: 100vw !important;
        height: 55vh !important;
        max-height: 70vh !important;
        border-radius: 18px 18px 0 0 !important;
        border-left: none !important;
        border-right: none !important;
        border-bottom: none !important;
        box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.85) !important;
        resize: none !important;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .sv-header {
        padding: 10px 14px;
        border-radius: 18px 18px 0 0;
        cursor: default;
    }

    .sv-controls button {
        padding: 6px 10px;
        font-size: 16px;
    }

    /* Visual Filter Modal: Mobile Bottom Sheet */
    .modal-backdrop {
        align-items: flex-end;
        padding: 0;
    }

    .visual-filter-card, .modal-card {
        width: 100vw !important;
        max-width: 100vw !important;
        margin: 0 !important;
        border-radius: 20px 20px 0 0 !important;
        max-height: 86vh !important;
        border-left: none !important;
        border-right: none !important;
        border-bottom: none !important;
        padding-bottom: env(safe-area-inset-bottom, 10px);
    }

    .visual-filter-body {
        padding: 14px 16px;
        max-height: 62vh;
        gap: 12px;
    }

    .droplists-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .chip-btn {
        padding: 5px 11px;
        font-size: 11.5px;
    }

    .range-slider-wrap {
        height: 32px;
    }

    .range-slider-input::-webkit-slider-thumb {
        width: 24px;
        height: 24px;
    }
    .range-slider-input::-moz-range-thumb {
        width: 24px;
        height: 24px;
    }

    .visual-filter-footer {
        padding: 12px 16px;
    }

    /* Leaflet Popups */
    .leaflet-popup-content-wrapper {
        border-radius: 14px !important;
    }

    .leaflet-popup-content {
        margin: 0 !important;
        padding: 12px 14px !important;
        width: 295px !important;
        max-width: calc(100vw - 36px) !important;
    }
}

/* ── COMPACT SMARTPHONES (<= 480px) ── */
@media (max-width: 480px) {
    .app-header {
        padding: 6px 10px;
        row-gap: 6px;
    }

    .logo-text .brand {
        font-size: 13px;
    }
    .logo-text .sub-brand {
        font-size: 9px;
    }

    .logo {
        gap: 6px;
        font-size: 18px;
    }

    #lastUpdatedBadge {
        margin-right: 4px !important;
        font-size: 10px !important;
    }

    .action-btn {
        padding: 5px 9px;
        font-size: 11.5px;
    }

    .segment-btn {
        padding: 4px 9px;
        font-size: 11px;
    }

    .chip-toggle {
        padding: 3px 8px;
        font-size: 11px;
    }

    .leaflet-top.leaflet-left {
        top: 96px !important;
    }

    .listing-title {
        font-size: 12px;
    }

    .listing-price {
        font-size: 13px;
    }
}

