:root {
    --bg: #f3f5f7;
    --surface: #ffffff;
    --ink: #14202b;
    --muted: #6b7785;
    --line: #dfe5ea;
    --soft: #eef2f5;
    --brand: #146c5b;
    --brand-dark: #0d4e42;
    --shadow: 0 16px 40px rgba(20,32,43,.12);
    --shadow-soft: 0 8px 24px rgba(20,32,43,.08);
    --radius: 18px;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); background: var(--bg); }
button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.is-hidden { display: none !important; }

.topbar { height: 70px; display: flex; align-items: center; justify-content: space-between; padding: 0 22px; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); position: relative; z-index: 1100; backdrop-filter: blur(12px); }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--brand); color: white; font-weight: 850; box-shadow: 0 5px 14px rgba(20,108,91,.18); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: .96rem; letter-spacing: -.015em; }
.brand small { color: var(--muted); font-size: .7rem; margin-top: 2px; }
.admin-link { padding: 8px 12px; border-radius: 10px; text-decoration: none; color: var(--muted); border: 1px solid var(--line); font-size: .82rem; background: #fff; }

.search-shell { height: calc(100vh - 70px); display: grid; grid-template-columns: minmax(410px, 43%) 1fr; overflow: hidden; }
.search-panel { overflow-y: auto; padding: 24px 26px 34px; background: var(--bg); }
.search-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 14px; }
.eyebrow { margin: 0 0 4px; color: var(--brand); font-size: .7rem; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(1.5rem, 2vw, 2.1rem); line-height: 1.05; letter-spacing: -.04em; }
.mobile-map-toggle { display: none; }

.filters { background: var(--surface); border: 1px solid var(--line); border-radius: 15px; box-shadow: 0 4px 16px rgba(20,32,43,.045); }
.filters-compact { padding: 8px; }
.filter-primary-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 7px; align-items: stretch; }
.search-box { display: grid; grid-template-columns: 1fr auto; border: 1px solid #cfd8df; border-radius: 11px; overflow: hidden; background: #fff; min-width: 0; }
.search-box input { min-width: 0; border: 0; padding: 10px 11px; outline: 0; font-size: .82rem; background: transparent; }
.search-box button { border: 0; background: var(--brand); color: white; padding: 0 13px; font-size: .76rem; font-weight: 800; }
.search-box:focus-within { border-color: #78ad9f; box-shadow: 0 0 0 3px rgba(20,108,91,.08); }
.show-filters-btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line); background: #fff; color: #34424e; border-radius: 11px; min-width: 104px; padding: 0 11px; font-size: .74rem; font-weight: 800; white-space: nowrap; }
.show-filters-btn:hover { background: #f7f9fa; }
.show-filters-btn b { min-width: 19px; height: 19px; padding: 0 5px; border-radius: 999px; display: inline-grid; place-items: center; background: #e5f3ef; color: var(--brand-dark); font-size: .65rem; }
.advanced-filters { padding: 9px 3px 3px; border-top: 1px solid var(--soft); margin-top: 8px; }
.category-tabs { display: flex; gap: 6px; overflow-x: auto; padding: 1px 1px 8px; scrollbar-width: none; }
.category-tabs::-webkit-scrollbar { display: none; }
.category-tab { flex: 0 0 auto; border: 1px solid var(--line); background: var(--surface); color: #4f5d69; border-radius: 999px; padding: 6px 9px; font-size: .7rem; }
.category-tab.is-active { background: #e7f4f0; color: var(--brand-dark); border-color: #b9ddd3; font-weight: 800; }
.filter-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 3px; }
.filter-grid label { min-width: 0; }
.filter-grid label > span { display: block; font-size: .63rem; color: var(--muted); font-weight: 800; margin: 0 0 4px 2px; }
.filter-grid input, .filter-grid select { width: 100%; height: 36px; border: 1px solid var(--line); border-radius: 9px; padding: 0 9px; background: #fff; color: var(--ink); outline: none; font-size: .75rem; }
.filter-grid input:focus, .filter-grid select:focus { border-color: #78ad9f; box-shadow: 0 0 0 3px rgba(20,108,91,.07); }
.filter-actions { display: flex; align-items: center; gap: 7px; margin-top: 10px; }
.primary-btn, .ghost-btn { border-radius: 9px; height: 35px; padding: 0 12px; font-size: .73rem; font-weight: 800; }
.primary-btn { border: 1px solid var(--brand); background: var(--brand); color: white; }
.ghost-btn { border: 1px solid var(--line); background: white; color: var(--muted); }
.map-bounds-status { margin-left: auto; color: var(--brand); font-size: .67rem; }

.results-heading { display: flex; align-items: center; justify-content: space-between; padding: 17px 2px 10px; }
.results-heading strong { font-size: .92rem; }
.results-heading span { font-size: .73rem; color: var(--muted); margin-left: 3px; }
.loading-dot { width: 10px; height: 10px; border: 2px solid #c5d0d8; border-top-color: var(--brand); border-radius: 999px; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.results-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
.property-card { overflow: hidden; border-radius: 15px; background: var(--surface); border: 1px solid var(--line); text-decoration: none; transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease; min-width: 0; }
.property-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-soft); border-color: #cfd9df; }
.property-image { aspect-ratio: 1.52 / 1; background: #dfe5e8; overflow: hidden; position: relative; }
.property-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.property-image .no-photo { height: 100%; display: grid; place-items: center; color: #71808c; font-size: .75rem; }
.property-tag { position: absolute; top: 8px; left: 8px; background: rgba(255,255,255,.94); border-radius: 999px; padding: 4px 7px; font-size: .6rem; font-weight: 850; text-transform: capitalize; backdrop-filter: blur(8px); }
.property-body { padding: 11px; }
.property-price { font-size: 1rem; font-weight: 875; letter-spacing: -.025em; }
.property-address { margin-top: 4px; min-height: 32px; color: #3e4b56; font-size: .75rem; line-height: 1.34; }
.property-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; color: var(--muted); font-size: .65rem; }
.property-meta span { padding-right: 6px; border-right: 1px solid var(--line); }
.property-meta span:last-child { border-right: 0; }
.property-type { margin-top: 7px; color: var(--brand-dark); font-size: .65rem; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty-state { text-align: center; padding: 38px 15px; border: 1px dashed #cad4db; border-radius: 14px; background: rgba(255,255,255,.55); color: var(--muted); }
.empty-state strong { color: var(--ink); display: block; margin-bottom: 6px; }
.empty-state p { margin: 0; font-size: .8rem; }
.pagination { display: flex; justify-content: center; gap: 7px; padding: 18px 0 8px; }
.pagination button { border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 8px 11px; color: var(--ink); font-size: .75rem; }
.pagination button:disabled { opacity: .4; cursor: default; }

.map-panel { position: relative; min-width: 0; }
#map { width: 100%; height: 100%; background: #dbe2e5; }
.search-area-btn { position: absolute; z-index: 900; top: 16px; left: 50%; transform: translateX(-50%); border: 0; border-radius: 999px; background: #182630; color: white; padding: 9px 15px; font-size: .76rem; font-weight: 800; box-shadow: 0 8px 22px rgba(0,0,0,.16); }
.map-note { position: absolute; z-index: 850; bottom: 20px; left: 50%; transform: translateX(-50%); background: rgba(255,255,255,.94); border: 1px solid var(--line); color: var(--muted); border-radius: 999px; padding: 6px 10px; font-size: .64rem; white-space: nowrap; backdrop-filter: blur(8px); }
.price-marker { background: transparent; border: 0; }
.price-marker span { display: inline-block; transform: translate(-50%,-50%); background: #fff; border: 2px solid #182630; color: #182630; border-radius: 999px; padding: 5px 8px; min-width: 45px; text-align: center; font-size: 10px; font-weight: 900; white-space: nowrap; box-shadow: 0 3px 10px rgba(0,0,0,.16); transition: transform .15s ease; }
.price-marker:hover span { transform: translate(-50%,-54%) scale(1.04); }
.modern-property-popup .leaflet-popup-content-wrapper { border-radius: 17px; box-shadow: 0 18px 48px rgba(20,32,43,.24); padding: 0; overflow: hidden; border: 1px solid rgba(20,32,43,.08); }
.modern-property-popup .leaflet-popup-content { margin: 0; width: 300px !important; }
.modern-property-popup .leaflet-popup-tip { box-shadow: 3px 3px 8px rgba(20,32,43,.08); }
.modern-property-popup .leaflet-popup-close-button { width: 28px; height: 28px; line-height: 26px; top: 8px; right: 8px; border-radius: 999px; background: rgba(255,255,255,.94); color: #263541; font-size: 17px; z-index: 2; box-shadow: 0 3px 10px rgba(0,0,0,.1); }
.map-popup-card { display: block; text-decoration: none; background: #fff; color: var(--ink); }
.map-popup-media { height: 154px; background: #e4e9ec; overflow: hidden; position: relative; }
.map-popup-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.map-popup-no-photo { height: 100%; display: grid; place-items: center; color: var(--muted); font-size: .74rem; }
.map-popup-badge { position: absolute; left: 10px; top: 10px; padding: 5px 8px; border-radius: 999px; background: rgba(255,255,255,.94); color: #34424e; font-size: .61rem; font-weight: 850; text-transform: capitalize; backdrop-filter: blur(7px); }
.map-popup-content { padding: 12px 13px 13px; }
.map-popup-price-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.map-popup-price-row strong { font-size: 1.05rem; letter-spacing: -.02em; }
.map-popup-price-row span { width: 25px; height: 25px; display: grid; place-items: center; border-radius: 999px; background: #edf5f2; color: var(--brand-dark); font-weight: 900; }
.map-popup-content p { margin: 5px 0 0; color: #52606b; font-size: .73rem; line-height: 1.35; }
.map-popup-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; color: #53616d; font-size: .66rem; }
.map-popup-meta span { padding-right: 6px; border-right: 1px solid var(--line); }
.map-popup-meta span:last-child { border-right: 0; }
.map-popup-content small { display: block; margin-top: 9px; color: var(--brand-dark); font-size: .65rem; font-weight: 800; }
.marker-cluster-small, .marker-cluster-medium, .marker-cluster-large { background: rgba(20,108,91,.22); }
.marker-cluster-small div, .marker-cluster-medium div, .marker-cluster-large div { background: var(--brand); color: white; font-weight: 850; }
.server-cluster-icon { background: transparent; border: 0; }
.server-cluster-icon span { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 999px; background: #146c5b; color: #fff; border: 5px solid rgba(255,255,255,.86); box-shadow: 0 7px 20px rgba(20,32,43,.24); font-size: 11px; font-weight: 900; }

/* Listing detail */
.detail-page { min-height: 100%; background: #f4f6f7; }
.detail-wrap { max-width: 1380px; margin: 0 auto; padding: 24px 26px 70px; }
.detail-gallery-shell { position: relative; }
.detail-gallery { display: grid; grid-template-columns: 2fr 1fr 1fr; grid-template-rows: 235px 235px; gap: 7px; border-radius: 22px; overflow: hidden; background: #dfe4e7; box-shadow: 0 7px 24px rgba(20,32,43,.06); }
.detail-gallery button { border: 0; padding: 0; background: #dfe4e7; overflow: hidden; position: relative; }
.detail-gallery button:first-child { grid-row: 1 / 3; }
.detail-gallery img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s ease; }
.detail-gallery button:hover img { transform: scale(1.015); }
.detail-gallery.single { grid-template-columns: 1fr; grid-template-rows: min(65vh, 620px); }
.detail-gallery.single button:first-child { grid-row: auto; }
.detail-photo-empty { min-height: 430px; display: grid; place-items: center; color: var(--muted); grid-column: 1 / -1; }
.gallery-all-btn { position: absolute; right: 14px; bottom: 14px; border: 1px solid rgba(20,32,43,.12); background: rgba(255,255,255,.94); color: var(--ink); border-radius: 10px; padding: 9px 12px; font-size: .73rem; font-weight: 850; box-shadow: 0 6px 18px rgba(20,32,43,.12); backdrop-filter: blur(8px); }
.detail-summary { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 24px; align-items: start; padding: 27px 4px 22px; border-bottom: 1px solid var(--line); }
.detail-kicker { color: var(--brand); font-weight: 850; text-transform: capitalize; font-size: .7rem; letter-spacing: .05em; }
.detail-price { font-size: clamp(2rem, 4vw, 3.4rem); margin: 7px 0 4px; letter-spacing: -.05em; }
.detail-address { color: #52606b; margin: 0; font-size: .97rem; line-height: 1.45; }
.detail-stats { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 17px; }
.detail-stats span { background: #fff; border: 1px solid var(--line); border-radius: 11px; padding: 8px 10px; font-size: .76rem; }
.detail-stats strong { margin-right: 3px; }
.detail-summary-side { min-width: 220px; display: grid; gap: 8px; }
.detail-summary-side a, .detail-summary-side div { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; text-decoration: none; font-size: .72rem; }
.detail-summary-side small { display: block; color: var(--muted); font-size: .62rem; margin-bottom: 3px; }
.detail-summary-side strong { display: block; }
.detail-content-grid { display: grid; grid-template-columns: minmax(0,1fr) 345px; gap: 28px; align-items: start; padding-top: 25px; }
.detail-primary { min-width: 0; }
.detail-section { background: #fff; border: 1px solid var(--line); border-radius: 17px; padding: 20px; margin-bottom: 14px; }
.detail-section h2 { margin: 0 0 14px; font-size: 1rem; letter-spacing: -.02em; }
.detail-section-sub { margin: -7px 0 14px; color: var(--muted); font-size: .73rem; line-height: 1.5; }
.detail-remarks p { margin: 0; color: #4f5d68; line-height: 1.75; font-size: .9rem; }
.open-house-list { display: grid; gap: 9px; }
.open-house-card { display: grid; grid-template-columns: 72px minmax(0,1fr) auto; gap: 12px; align-items: center; border: 1px solid #d9e8e3; background: #f7fbfa; border-radius: 13px; padding: 11px; }
.open-house-date { width: 64px; height: 60px; display: grid; place-items: center; align-content: center; border-radius: 11px; background: #fff; border: 1px solid #dbe7e3; }
.open-house-date b { font-size: 1.2rem; line-height: 1; }
.open-house-date span { margin-top: 3px; color: var(--muted); font-size: .62rem; text-transform: uppercase; font-weight: 850; }
.open-house-copy strong { display: block; font-size: .83rem; }
.open-house-copy p { margin: 4px 0 0; color: var(--muted); font-size: .69rem; line-height: 1.4; }
.open-house-link { text-decoration: none; border-radius: 9px; padding: 7px 9px; background: var(--brand); color: #fff; font-size: .66rem; font-weight: 800; white-space: nowrap; }
.fact-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 0 22px; }
.fact-row { display: flex; justify-content: space-between; gap: 18px; padding: 9px 0; border-top: 1px solid var(--soft); font-size: .73rem; min-width: 0; }
.fact-row:nth-child(-n+2) { border-top: 0; }
.fact-row span { color: var(--muted); min-width: 0; }
.fact-row strong { text-align: right; font-weight: 750; overflow-wrap: anywhere; }
.fact-row a { color: var(--brand-dark); text-decoration: underline; text-underline-offset: 2px; }
.detail-sidebar { position: sticky; top: 14px; }
.detail-sidebar .detail-section { margin-bottom: 12px; }
.detail-sidebar .fact-grid { grid-template-columns: 1fr; }
.detail-sidebar .fact-row:nth-child(2) { border-top: 1px solid var(--soft); }
.detail-map-card { overflow: hidden; padding: 0; }
.detail-map-placeholder { min-height: 180px; display: grid; place-items: center; background: linear-gradient(145deg,#e7ecee,#f7f9fa); color: var(--muted); text-align: center; padding: 20px; font-size: .74rem; }
.detail-data-groups { display: grid; gap: 12px; }
.detail-data-group { border-top: 1px solid var(--soft); padding-top: 13px; }
.detail-data-group:first-child { border-top: 0; padding-top: 0; }
.detail-data-group h3 { margin: 0 0 7px; font-size: .81rem; }
.detail-data-group .fact-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
.detail-data-empty { color: var(--muted); font-size: .74rem; }
.detail-system-note { margin-top: 10px; color: var(--muted); font-size: .64rem; }

.gallery-lightbox[hidden] { display: none; }
.gallery-lightbox { position: fixed; inset: 0; z-index: 3000; background: rgba(8,13,18,.94); display: grid; grid-template-rows: auto minmax(0,1fr) auto; }
.gallery-lightbox-top { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; color: white; }
.gallery-lightbox-top span { font-size: .76rem; color: #d3d9de; }
.gallery-lightbox-close { width: 38px; height: 38px; border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.08); color: white; border-radius: 999px; font-size: 1.25rem; }
.gallery-stage { min-height: 0; display: grid; grid-template-columns: 58px minmax(0,1fr) 58px; align-items: center; gap: 10px; padding: 0 12px; }
.gallery-stage img { width: 100%; height: 100%; max-height: calc(100vh - 190px); object-fit: contain; }
.gallery-nav { width: 46px; height: 46px; border: 1px solid rgba(255,255,255,.15); background: rgba(255,255,255,.09); color: white; border-radius: 999px; font-size: 1.5rem; }
.gallery-thumbs { display: flex; gap: 7px; overflow-x: auto; padding: 12px 16px 15px; justify-content: flex-start; }
.gallery-thumbs button { flex: 0 0 auto; width: 76px; height: 52px; padding: 0; border: 2px solid transparent; border-radius: 7px; overflow: hidden; background: #222; opacity: .65; }
.gallery-thumbs button.is-active { border-color: #fff; opacity: 1; }
.gallery-thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
body.gallery-open { overflow: hidden; }

.detail-not-found { max-width: 700px; margin: 90px auto; padding: 30px; text-align: center; }
.detail-not-found p { color: var(--muted); }
.detail-not-found a { color: var(--brand); }

@media (max-width: 1180px) {
    .search-shell { grid-template-columns: minmax(390px, 48%) 1fr; }
    .results-grid { grid-template-columns: 1fr; }
    .detail-content-grid { grid-template-columns: minmax(0,1fr) 310px; }
}
@media (max-width: 900px) {
    .detail-wrap { padding: 14px 14px 50px; }
    .detail-gallery { grid-template-columns: 1fr 1fr; grid-template-rows: 260px 145px; }
    .detail-gallery button:first-child { grid-column: 1 / -1; grid-row: 1; }
    .detail-gallery button:nth-child(n+4) { display: none; }
    .detail-summary { grid-template-columns: 1fr; }
    .detail-summary-side { grid-template-columns: repeat(2,minmax(0,1fr)); min-width: 0; }
    .detail-content-grid { grid-template-columns: 1fr; }
    .detail-sidebar { position: static; }
}
@media (max-width: 760px) {
    .topbar { height: 64px; padding: 0 14px; }
    .brand small { display: none; }
    .search-shell { display: block; height: calc(100vh - 64px); position: relative; }
    .search-panel { height: 100%; padding: 17px 13px 30px; }
    .map-panel { display: none; position: absolute; inset: 0; z-index: 1000; }
    .search-shell.map-open .map-panel { display: block; }
    .mobile-map-toggle { display: inline-flex; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 8px 11px; font-size: .74rem; font-weight: 800; }
    .search-shell.map-open .mobile-map-toggle { position: fixed; z-index: 1200; top: 76px; right: 12px; }
    .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .results-grid { grid-template-columns: 1fr; }
    .property-card { display: grid; grid-template-columns: 128px 1fr; }
    .property-image { aspect-ratio: auto; height: 100%; min-height: 136px; }
    .map-note { bottom: 14px; }
    .fact-grid, .detail-data-group .fact-grid { grid-template-columns: 1fr; }
    .fact-row:nth-child(2) { border-top: 1px solid var(--soft); }
    .gallery-stage { grid-template-columns: 44px minmax(0,1fr) 44px; padding: 0 5px; }
    .gallery-nav { width: 38px; height: 38px; }
}
@media (max-width: 500px) {
    .search-head h1 { font-size: 1.35rem; }
    .filter-primary-row { grid-template-columns: minmax(0,1fr) auto; }
    .search-box button { padding: 0 10px; }
    .show-filters-btn { min-width: 92px; padding: 0 8px; }
    .filter-grid { grid-template-columns: 1fr; }
    .property-card { grid-template-columns: 108px 1fr; }
    .property-address { min-height: 0; }
    .detail-gallery { grid-template-rows: 235px 110px; }
    .detail-summary-side { grid-template-columns: 1fr; }
    .open-house-card { grid-template-columns: 62px minmax(0,1fr); }
    .open-house-link { grid-column: 1 / -1; text-align: center; }
}
