:root {
    --accent: #2563eb;
    --accent-light: #ebf3ff;
    --dark: #0f172a;
    --dark2: #16213e;
    --bg: #f8f9fb;
    --card: #ffffff;
    --border: #e8ecf1;
    --muted: #94a3b8;
    --text: #334155;
    --text-dark: #0f172a;
    --green: #059669;
    --green-bg: #ecfdf5;
    --radius: 16px;
    --radius-sm: 10px;
    --radius-pill: 100px;
    --shadow: 0 1px 3px rgba(0,0,0,.04);
    --shadow-lg: 0 8px 32px rgba(0,0,0,.12);
    --nav-h: 56px;
    --header-h: auto;
}
* { margin:0; padding:0; box-sizing:border-box; }
body {
    font-family: 'Inter', -apple-system, system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    padding-bottom: calc(var(--nav-h) + 16px);
}

/* ─── Header ─── */
#header {
    background: var(--dark);
    padding: 14px 16px 10px;
    position: sticky; top: 0; z-index: 1000;
}
.header-top {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 10px;
}
.logo { display: flex; align-items: center; gap: 8px; }
.logo-icon {
    width: 30px; height: 30px; border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--accent), #7c3aed);
}
.logo-text { font-size: 18px; font-weight: 800; color: #fff; letter-spacing: -.3px; }
.logo-badge {
    font-size: 8px; color: #64748b; margin-left: 5px;
    font-weight: 600; vertical-align: super;
}
.lang-btn {
    background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12);
    border-radius: 8px; color: #cbd5e1; padding: 5px 11px;
    font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.city-scroll {
    display: flex; gap: 5px; overflow-x: auto; padding-bottom: 2px;
    scrollbar-width: none;
}
.city-scroll::-webkit-scrollbar { display: none; }
.city-btn {
    padding: 5px 13px; border-radius: var(--radius-pill); border: none;
    background: rgba(255,255,255,.07); color: rgba(255,255,255,.5);
    font-size: 12px; font-weight: 400; cursor: pointer;
    white-space: nowrap; font-family: inherit; transition: all .15s;
}
.city-btn.active {
    background: var(--accent); color: #fff; font-weight: 600;
}

/* ─── Toolbar ─── */
.toolbar {
    padding: 10px 16px 6px;
    display: flex; justify-content: space-between; align-items: center;
}
.toolbar-left { display: flex; gap: 5px; }
.chip {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 7px 14px; border-radius: var(--radius-pill);
    border: 1.5px solid var(--border); background: var(--card);
    color: #475569; font-size: 13px; font-weight: 500;
    cursor: pointer; white-space: nowrap; font-family: inherit;
    transition: all .15s;
}
.chip[data-active="true"], .chip.active {
    border-color: var(--accent); background: rgba(37,99,235,.05);
    color: var(--accent);
}
.view-toggle {
    display: flex; background: #e8ecf1; border-radius: var(--radius-sm);
    padding: 3px; gap: 2px;
}
.view-btn {
    width: 34px; height: 28px; border-radius: 7px; border: none;
    cursor: pointer; background: transparent;
    display: flex; align-items: center; justify-content: center;
    color: var(--muted); transition: all .15s;
}
.view-btn.active {
    background: var(--card); color: var(--text-dark);
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

/* ─── Filters ─── */
.filters-panel {
    margin: 0 16px 8px; padding: 16px; background: var(--card);
    border-radius: var(--radius); border: 1px solid var(--border);
    box-shadow: 0 4px 16px rgba(0,0,0,.04);
    animation: slideDown .2s ease;
}
.filters-panel.hidden { display: none; }
@keyframes slideDown { from { opacity:0; transform:translateY(-8px); } to { opacity:1; transform:translateY(0); } }

.filter-row { display: flex; gap: 8px; margin-bottom: 14px; }
.filter-col { flex: 1; }
.filter-col label, .filter-group label {
    font-size: 11px; color: var(--muted); font-weight: 600;
    display: block; margin-bottom: 6px;
}
.filter-col input, .filter-col select {
    width: 100%; padding: 9px 12px; border-radius: var(--radius-sm);
    border: 1.5px solid var(--border); font-size: 14px;
    font-family: inherit; background: #f8fafc;
}
.filter-col select { appearance: none; }
.filter-group { margin-bottom: 14px; }
.room-btns { display: flex; gap: 5px; }
.room-btn {
    flex: 1; padding: 7px 0; border-radius: 8px;
    border: 1.5px solid var(--border); background: #f8fafc;
    color: #475569; font-size: 13px; font-weight: 600;
    cursor: pointer; font-family: inherit; transition: all .15s;
}
.room-btn.active {
    border-color: var(--accent); background: rgba(37,99,235,.04);
    color: var(--accent);
}
.furn-btns { display: flex; gap: 5px; flex-wrap: wrap; }
.furn-btn { font-size: 12px; padding: 6px 12px; }
.filter-actions { display: flex; gap: 8px; }
.btn-secondary {
    flex: 1; padding: 11px; border-radius: var(--radius-sm);
    border: 1.5px solid var(--border); background: var(--card);
    color: #64748b; font-size: 13px; font-weight: 600;
    cursor: pointer; font-family: inherit;
}
.btn-primary {
    flex: 2; padding: 11px; border-radius: var(--radius-sm);
    border: none; background: var(--accent); color: #fff;
    font-size: 13px; font-weight: 600; cursor: pointer;
    font-family: inherit;
}

/* ─── Results bar ─── */
.results-bar {
    padding: 2px 16px 6px;
    display: flex; justify-content: space-between; align-items: center;
}
.results-count { font-size: 13px; color: var(--muted); font-weight: 500; }
.sort-btn {
    display: flex; align-items: center; gap: 4px;
    background: none; border: none; color: var(--muted);
    font-size: 12px; cursor: pointer; font-family: inherit;
}

/* ─── Map ─── */
.map-container {
    position: relative; margin: 0 16px 12px;
    border-radius: 18px; overflow: hidden;
    height: 300px;
}
.map-container.hidden { display: none; }
#map { width: 100%; height: 100%; z-index: 1; }
.leaflet-container { background: #eef1f6; }

/* Custom map markers */
.pin-marker {
    background: var(--card); border: 1px solid #d1d5db;
    border-radius: 14px; padding: 4px 10px;
    font-size: 11px; font-weight: 700; color: var(--text-dark);
    font-family: 'Inter', sans-serif;
    box-shadow: 0 2px 6px rgba(0,0,0,.12);
    white-space: nowrap; text-align: center;
    transition: all .15s;
}
.pin-marker.active {
    background: var(--accent); color: #fff;
    border-color: var(--accent);
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(37,99,235,.3);
    z-index: 1000 !important;
}

/* Map preview card */
.map-preview {
    position: absolute; bottom: 12px; left: 12px; right: 12px;
    z-index: 1000; background: var(--card);
    border-radius: var(--radius); padding: 14px;
    box-shadow: var(--shadow-lg);
    animation: slideUp .25s ease;
}
.map-preview.hidden { display: none; }
@keyframes slideUp { from { transform:translateY(20px); opacity:0; } to { transform:translateY(0); opacity:1; } }
.preview-close {
    position: absolute; top: 10px; right: 10px;
    background: #f1f5f9; border: none; border-radius: 8px;
    width: 28px; height: 28px; display: flex; align-items: center;
    justify-content: center; cursor: pointer;
}
.preview-body { display: flex; gap: 12px; }
.preview-img {
    width: 90px; height: 90px; border-radius: 12px; flex-shrink: 0;
    background-size: cover; background-position: center;
    background-color: #e8ecf1; display: flex; align-items: center;
    justify-content: center; position: relative;
}
.preview-info { flex: 1; min-width: 0; }
.preview-price { font-size: 20px; font-weight: 800; color: var(--text-dark); }
.preview-price span { font-size: 12px; color: var(--muted); margin-left: 3px; }
.preview-title {
    font-size: 13px; color: var(--text); line-height: 1.35;
    margin: 4px 0 6px; overflow: hidden; text-overflow: ellipsis;
    white-space: nowrap;
}
.preview-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.preview-detail-btn {
    width: 100%; margin-top: 10px; padding: 10px;
    border-radius: var(--radius-sm); border: none;
    background: var(--accent); color: #fff;
    font-size: 13px; font-weight: 600; cursor: pointer;
    font-family: inherit; display: flex; align-items: center;
    justify-content: center; gap: 6px;
}

/* ─── Tag ─── */
.tag {
    display: inline-flex; align-items: center; gap: 3px;
    background: #f1f5f9; border-radius: 6px;
    padding: 2px 7px; font-size: 11px; color: #64748b; font-weight: 500;
}
.tag.green { background: var(--green-bg); color: var(--green); }

/* ─── Listing cards ─── */
.list-container { padding: 0 16px; }
.list-container.hidden { display: none; }
.listing-card {
    background: var(--card); border-radius: var(--radius);
    overflow: hidden; margin-bottom: 10px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow); cursor: pointer;
    transition: all .15s;
}
.listing-card.active {
    border: 2px solid var(--accent);
    box-shadow: 0 0 0 3px rgba(37,99,235,.08);
}
.card-img {
    height: 150px; position: relative;
    background-size: cover; background-position: center;
    background-color: #e8ecf1;
}
.card-img-placeholder {
    width: 100%; height: 100%; display: flex;
    align-items: center; justify-content: center;
    color: var(--muted); opacity: .3;
}
.card-badge {
    position: absolute; padding: 3px 9px; border-radius: 8px;
    font-size: 11px; font-weight: 600;
    backdrop-filter: blur(8px);
}
.card-source { top: 10px; left: 10px; background: rgba(255,255,255,.92); color: #475569; }
.card-pet { top: 10px; right: 10px; background: var(--green-bg); color: var(--green); display: flex; align-items: center; gap: 3px; }
.card-photos {
    position: absolute; bottom: 10px; left: 10px;
    background: rgba(0,0,0,.55); color: #fff; border-radius: 8px;
    padding: 3px 8px; font-size: 11px; font-weight: 500;
    display: flex; align-items: center; gap: 4px;
}
.card-fav {
    position: absolute; bottom: 10px; right: 10px;
    background: rgba(255,255,255,.85); border: none; border-radius: 8px;
    width: 32px; height: 32px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(8px);
}
.card-body { padding: 12px 14px 14px; }
.card-price {
    font-size: 22px; font-weight: 800; color: var(--text-dark);
    letter-spacing: -.3px;
}
.card-price span { font-size: 12px; color: var(--muted); margin-left: 3px; }
.card-title {
    font-size: 13px; color: var(--text); line-height: 1.4;
    margin: 4px 0 8px;
}
.card-location {
    display: flex; align-items: center; gap: 4px;
    margin-bottom: 8px; font-size: 12px; color: var(--muted);
}
.card-tags { display: flex; gap: 6px; flex-wrap: wrap; }

/* ─── Loading ─── */
.loading {
    display: flex; justify-content: center; padding: 40px;
}
.loading.hidden { display: none; }
.spinner {
    width: 32px; height: 32px; border: 3px solid var(--border);
    border-top-color: var(--accent); border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Bottom nav ─── */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: rgba(255,255,255,.92);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
    padding: 8px 0 max(10px, env(safe-area-inset-bottom));
    display: flex; justify-content: space-around;
    z-index: 1000;
}
.nav-btn {
    background: none; border: none; cursor: pointer;
    display: flex; flex-direction: column; align-items: center;
    gap: 3px; padding: 2px 12px; color: var(--muted);
    font-family: inherit;
}
.nav-btn span { font-size: 10px; font-weight: 400; }
.nav-btn.active { color: var(--accent); }
.nav-btn.active span { font-weight: 600; }
.nav-btn.active svg { stroke-width: 2.2; }

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 0; height: 0; }

/* ─── Detail modal ─── */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.5);
    z-index: 2000; display: flex; align-items: flex-end;
    animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
.modal-content {
    width: 100%; max-height: 85vh; background: var(--card);
    border-radius: 20px 20px 0 0; overflow-y: auto;
    animation: slideUp .3s ease; padding-bottom: env(safe-area-inset-bottom);
}
.modal-handle {
    width: 36px; height: 4px; background: #d1d5db;
    border-radius: 2px; margin: 10px auto 0;
}
.modal-gallery {
    height: 220px; overflow-x: auto; display: flex; gap: 2px;
    scroll-snap-type: x mandatory;
}
.modal-gallery img {
    height: 100%; min-width: 100%; object-fit: cover;
    scroll-snap-align: start;
}
.modal-gallery-placeholder {
    width: 100%; height: 100%; background: #e8ecf1;
    display: flex; align-items: center; justify-content: center;
    color: var(--muted);
}
.modal-body { padding: 16px; }
.modal-price {
    font-size: 28px; font-weight: 800; color: var(--text-dark);
}
.modal-price span { font-size: 14px; color: var(--muted); }
.modal-title { font-size: 15px; color: var(--text); margin: 8px 0 12px; line-height: 1.5; }
.modal-props {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 8px; margin-bottom: 16px;
}
.modal-prop {
    background: #f8fafc; border-radius: var(--radius-sm);
    padding: 10px; text-align: center;
}
.modal-prop-val { font-size: 16px; font-weight: 700; color: var(--text-dark); }
.modal-prop-label { font-size: 11px; color: var(--muted); margin-top: 2px; }
.modal-desc {
    font-size: 14px; color: var(--text); line-height: 1.6;
    margin-bottom: 16px; white-space: pre-wrap;
}
.modal-source-link {
    display: block; width: 100%; padding: 12px; text-align: center;
    background: #f1f5f9; border-radius: var(--radius-sm);
    color: var(--accent); font-size: 13px; font-weight: 600;
    text-decoration: none; margin-bottom: 8px;
}
