:root {
    --sbw: 360px;
    --brand: #e74c3c;
    --fab: #16a34a;
    --navH: 64px;
}
* {
    box-sizing: border-box;
}
html,
body {
    height: 100%;
    margin: 0;
    font-family:
            system-ui,
            -apple-system,
            Segoe UI,
            Arial,
            sans-serif;
}
.app {
    position: relative;
    height: 100%;
    width: 100%;
    overflow: hidden;
}
#map {
    position: absolute;
    inset: 0;
}
.sidebar {
    position: absolute;
    top: 0;
    left: 0;
    bottom: var(--navH);
    width: var(--sbw);
    background: #fff;
    border-right: 1px solid #eee;
    display: flex;
    flex-direction: column;
    transform: translateX(0);
    transition: transform 0.25s ease;
    z-index: 1000;
}
.sidebar.hidden {
    transform: translateX(calc(-1 * var(--sbw)));
}
.sb-header {
    padding: 12px;
    border-bottom: 1px solid #eee;
    background: #fafafa;
}
.sb-title {
    margin: 0 0 8px;
    font-size: 18px;
    font-weight: 700;
}
.sb-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}
.sb-input,
.sb-select {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 10px;
}
.filters {
    padding: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    border-bottom: 1px solid #eee;
}
.chip {
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid #ddd;
    cursor: pointer;
    font-size: 13px;
    background: #fff;
}
.chip.active {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
}
.list {
    flex: 1;
    overflow: auto;
    padding: 10px;
}
.item {
    border: 1px solid #eee;
    border-radius: 12px;
    padding: 10px;
    margin-bottom: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    cursor: pointer;
}
.item h4 {
    margin: 0 0 6px;
    font-size: 14px;
    display: flex;
    gap: 6px;
    align-items: center;
}
.meta {
    font-size: 12px;
    color: #666;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.sb-close {
    position: absolute;
    top: 10px;
    right: -36px;
    width: 36px;
    height: 36px;
    border-radius: 8px 8px 8px 0;
    background: #fff;
    border: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    cursor: pointer;
}
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(calc(-1 * var(--sbw)));
    }
}

.map-search {
    position: absolute;
    top: 15px; left: 50%;
    transform: translateX(-50%);
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 3px 10px rgba(0,0,0,.2);
    padding: 6px 10px;
    width: 320px;
    z-index: 500; /* vừa đủ cao để nổi lên layer map */
}

.map-search input {
    width: 100%;
    border: none;
    outline: none;
    font-size: 14px;
}
.suggest-list {
    position: absolute;
    left: 0;
    right: 0;
    top: 44px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    max-height: 220px;
    overflow: auto;
    z-index: 1401;
    display: none;
}
.suggest-item {
    padding: 8px 10px;
    font-size: 13px;
    cursor: pointer;
}
.suggest-item:hover {
    background: #f5f5f5;
}
.fab {
    position: absolute;
    right: 12px;
    bottom: calc(env(safe-area-inset-bottom, 0px)+var(--navH)+12px);
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 1200;
}
.fab .btn,
.fab .pill {
    border: none;
    cursor: pointer;
    color: #fff;
    font-weight: 700;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
}
.fab .btn {
    width: 52px;
    height: 52px;
    background: var(--fab);
}
.fab .pill {
    min-width: 64px;
    height: 40px;
    background: var(--fab);
    padding: 0 10px;
}
.badge {
    position: absolute;
    top: -7px;
    right: -7px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 999px;
    padding: 2px 6px;
    border: 2px solid #fff;
}
.navbar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: var(--navH);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(8px);
    border-top: 1px solid #eaeaea;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    align-items: center;
    padding: 8px 12px;
    z-index: 1300;
}
.nav-btn {
    height: 44px;
    border-radius: 12px;
    border: 1px solid #ddd;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 700;
    cursor: pointer;
    position: relative;
}
.nav-btn .nbadge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 999px;
    padding: 2px 6px;
    border: 2px solid #fff;
}
.sheet-close {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    z-index: 1301;
}
.sheet {
    position: absolute;
    left: 0;
    right: 0;
    bottom: var(--navH);
    transform: translateY(105%);
    transition: transform 0.25s ease;
    background: #fff;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.12);
    z-index: 1250;
    max-height: 80%;
    display: flex;
    flex-direction: column;
}
.sheet.show {
    transform: translateY(0);
}
.sheet .handle {
    width: 42px;
    height: 4px;
    background: #ddd;
    border-radius: 999px;
    margin: 8px auto;
}
.sheet header {
    padding: 6px 12px 8px;
    border-bottom: 1px solid #eee;
}
.sheet .stats {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
}
.chipStat {
    flex: 1;
    background: #fafafa;
    border: 1px solid #eee;
    border-radius: 12px;
    padding: 8px;
    text-align: center;
    font-size: 12px;
}
.sheet .body {
    overflow: auto;
    padding: 10px 12px 14px;
}
.modal {
    position: fixed;
    inset: 0;
    display: none;
    z-index: 1500;
    background: rgba(0, 0, 0, 0.35);
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal.show {
    display: flex;
}
.card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    padding: 18px;
}
.card h3 {
    margin: 0 0 12px;
}
.rows {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
}
.row input {
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid #ddd;
    font-size: 14px;
}
.row button {
    height: 44px;
    border-radius: 12px;
    background: #0ea5e9;
    color: #fff;
    border: none;
    font-weight: 700;
    cursor: pointer;
}
.hdr-search {
    position: relative;
    flex: 1;
    margin: 0 10px;
}

.header {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 58px;
    background: rgba(255,255,255,0.96);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid #e5e5e5;
    z-index: 1400;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    gap: 12px;
}
.hdr-left { display: flex; align-items: center; gap: 10px; }
.hdr-left h1 { font-size: 17px; margin: 0; font-weight: 700; white-space: nowrap; }

.hdr-btn {
    border: none;
    background: #fff;
    width: 36px; height: 36px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,.1);
    font-size: 18px;
}
.hdr-btn:hover { background: #f3f3f3; }

.hdr-center {
    flex: 1;
    position: relative;
    max-width: 400px;
}
.hdr-input {
    width: 100%;
    height: 36px;
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 0 10px;
    font-size: 14px;
    outline: none;
}
.suggest-list {
    position: absolute;
    top: 42px;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,.2);
    z-index: 1500;
    display: none;
    max-height: 220px;
    overflow: auto;
}
.suggest-item { padding: 8px 10px; font-size: 13px; cursor: pointer; }
.suggest-item:hover { background: #f0f0f0; }

.hdr-right {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}
.hdr-link {
    color: #0369a1;
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
}
.hdr-link:hover { text-decoration: underline; }

@media (max-width: 720px) {
    .hdr-right .hdr-link { display: none; }
    .hdr-center { max-width: 200px; }
    .hdr-left h1 { font-size: 15px; }
}

/* ===== SIDEBAR sửa lại để không bị header che ===== */
.sidebar {
    position: absolute;
    top: 58px; /* ✅ đẩy xuống dưới header */
    left: 0;
    bottom: var(--navH);
    width: var(--sbw);
    background: #fff;
    border-right: 1px solid #eee;
    display: flex;
    flex-direction: column;
    transform: translateX(0);
    transition: transform .25s ease;
    z-index: 1000;
}

/* ===== MAP ===== */
#map {
    position: absolute;
    top: 58px; /* ✅ dịch map xuống dưới header */
    left: 0;
    right: 0;
    bottom: 0;
}


/* ===== MODAL CHI TIẾT CỨU HỘ ===== */
#modalDetail {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.4);
    z-index: 1600;
    padding: 20px;
}
#modalDetail.show { display: flex; }

.detail-card {
    width: 100%;
    max-width: 900px;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(0,0,0,.25);
    display: flex;
    flex-direction: column;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #0ea5e9;
    color: #fff;
    padding: 12px 16px;
}
.detail-header h2 { margin: 0; font-size: 18px; }
.detail-header button {
    border: none;
    background: rgba(255,255,255,0.25);
    color: #fff;
    font-size: 18px;
    border-radius: 6px;
    width: 32px; height: 32px;
    cursor: pointer;
}

.detail-body {
    display: flex;
    flex-wrap: wrap;
    min-height: 420px;

}
.detail-body .col {
    flex: 1;
    min-width: 300px;
    padding: 16px;
    border-right: 1px solid #eee;
}
.detail-body .col:last-child { border-right: none; }

.info-col h3, .comment-col h3 {
    margin-top: 0; font-size: 16px;
    border-bottom: 2px solid #0ea5e9;
    padding-bottom: 6px;
    margin-bottom: 10px;
}
#detailInfo {
    font-size: 14px;
    line-height: 1.5;
    max-height: 320px;
    overflow-y: auto;
    padding-left: 30px;
}
#detailInfo div { margin-bottom: 6px; }

.comments {
    max-height: 320px;
    overflow-y: auto;
    font-size: 14px;
    padding-right: 6px;
}
.comment {
    background: #f8fafc;
    border-radius: 8px;
    padding: 8px;
    margin-bottom: 8px;
    border: 1px solid #e5e7eb;
}
.comment strong { color: #0369a1; }

.comment-input {
    display: flex;
    gap: 6px;
    margin-top: 10px;
}
.comment-input input {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 8px;
}
.comment-input button {
    background: #0ea5e9;
    border: none;
    color: #fff;
    border-radius: 8px;
    padding: 0 12px;
    cursor: pointer;
}
@media (max-width: 720px) {
    .detail-body { flex-direction: column; }
    .detail-body .col { border-right: none; border-bottom: 1px solid #eee; }
}


.pin-blink {
    box-shadow: 0 0 6px 2px rgba(255,255,255,0.6);
    animation: blink 0.5s infinite alternate;
}

@keyframes blink {
    0% { opacity: 1; box-shadow: 0 0 5px rgba(255,255,255,0.8); transform: scale(1); }
    50% { opacity: 0.6; box-shadow: 0 0 10px rgba(255,255,255,1); transform: scale(1.1); }
    100% { opacity: 1; box-shadow: 0 0 5px rgba(255,255,255,0.8); transform: scale(1); }
}

.detailInfo {
    font-size: 14px;
    line-height: 1.5;
    max-height: 320px;
    overflow-y:  auto;
    overflow-x: hidden;
    padding-left: 30px;
}