:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --ink: #1d232b;
  --muted: #6b7280;
  --line: #e4e2dc;
  --accent: #0f6e5a;
  --accent-ink: #ffffff;
  --chip: #f0efe9;
  --shadow: 0 6px 24px rgba(20, 24, 30, .14);
  --radius: 12px;
  --panel-w: 320px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171b; --surface: #1c2026; --ink: #e8eaed; --muted: #9aa1ab;
    --line: #2c323a; --chip: #262b32; --accent: #3fb79a; --accent-ink: #0d1512;
    --shadow: 0 6px 24px rgba(0, 0, 0, .5);
  }
}
:root[data-theme="dark"] {
  --bg: #14171b; --surface: #1c2026; --ink: #e8eaed; --muted: #9aa1ab;
  --line: #2c323a; --chip: #262b32; --accent: #3fb79a; --accent-ink: #0d1512;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px;
  display: flex; flex-direction: column; overflow: hidden;
}
sup { font-size: .68em; line-height: 0; }
.muted { color: var(--muted); font-weight: 400; }

/* Topbar */
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 10px 16px;
  background: var(--surface); border-bottom: 1px solid var(--line); z-index: 1000;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo {
  width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 700; font-size: 18px; flex: none;
}
.brand h1 { font-size: 16px; margin: 0; letter-spacing: -.01em; }
.brand .sub { margin: 0; font-size: 11.5px; color: var(--muted); }
.search {
  flex: 1; max-width: 460px; margin-left: auto; display: flex; align-items: center; gap: 8px;
  background: var(--chip); border-radius: 10px; padding: 0 12px; color: var(--muted);
}
.search input {
  border: 0; background: transparent; outline: none; color: var(--ink);
  font: inherit; padding: 9px 0; width: 100%;
}
.call {
  display: flex; align-items: center; gap: 6px; text-decoration: none; white-space: nowrap;
  background: var(--accent); color: var(--accent-ink); padding: 8px 12px; border-radius: 10px; font-weight: 600;
}
.icon-btn {
  display: none; border: 0; background: var(--chip); color: var(--ink);
  width: 36px; height: 36px; border-radius: 10px; cursor: pointer; flex: none;
}

/* Layout */
.layout { flex: 1; display: flex; min-height: 0; }
.panel {
  width: var(--panel-w); flex: none; overflow-y: auto; padding: 14px 16px 24px;
  background: var(--surface); border-right: 1px solid var(--line);
}
.map { flex: 1; min-width: 0; background: #ddd; }

.summary {
  background: var(--chip); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 6px;
}
.summary .big { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.summary .big small { font-size: 13px; font-weight: 500; color: var(--muted); }
.summary .row { display: flex; justify-content: space-between; color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.summary .row b { color: var(--ink); font-weight: 600; }

.group { padding: 12px 0; border-bottom: 1px solid var(--line); }
.group h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-size: 13px;
  padding: 5px 10px; border-radius: 999px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center;
}
.chip .n { color: var(--muted); font-size: 11.5px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip.on .n { color: inherit; opacity: .8; }
.range { display: flex; align-items: center; gap: 8px; }
.range input {
  width: 100%; font: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink);
}
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.presets .chip { font-size: 12px; padding: 3px 9px; }
.trend { margin-top: 10px; }
.trend .bars { display: flex; align-items: flex-end; gap: 5px; height: 96px; padding-top: 16px; }
.trend .bar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
  border: 0; background: none; padding: 0; cursor: pointer; font: inherit; color: var(--muted); font-size: 10.5px; }
.trend .bar i { display: block; width: 100%; background: var(--accent); opacity: .45; border-radius: 4px 4px 0 0; position: relative; min-height: 2px; }
.trend .bar.on i { opacity: 1; }
.trend .bar.on { color: var(--ink); font-weight: 600; }
.trend .bar i em { position: absolute; top: -15px; left: 50%; transform: translateX(-50%); font-style: normal; color: var(--ink); font-weight: 600; font-size: 10.5px; white-space: nowrap; }
.trend .cap { font-size: 11.5px; color: var(--muted); margin-top: 6px; line-height: 1.45; }
.pp-years div.on { color: var(--ink); font-weight: 700; }
.pp-years div:not(.on) i { opacity: .55; }
.pp-years.anyon div:not(.on) i { opacity: .35; }
.pp-years:not(.anyon) div i { opacity: 1; }
.check { display: flex; gap: 8px; align-items: center; margin-top: 8px; cursor: pointer; }
.legend { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.legend span { font-size: 11.5px; text-align: center; padding: 4px 0; border-radius: 6px; color: #fff; font-weight: 600; }
.ghost {
  margin-top: 14px; width: 100%; padding: 9px; font: inherit; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: transparent; color: var(--ink);
}
.note { font-size: 11.5px; color: var(--muted); line-height: 1.5; margin-top: 14px; }

/* Price markers */
.pin { background: transparent; border: 0; }
.pin b {
  display: inline-block; transform: translate(-50%, -100%); position: relative;
  padding: 2px 6px; border-radius: 7px; color: #fff; font: 700 11.5px/1.3 "Be Vietnam Pro", system-ui, sans-serif;
  white-space: nowrap; box-shadow: 0 0 0 1px rgba(0,0,0,.35), 0 1px 4px rgba(0,0,0,.45); border: 1.5px solid rgba(255,255,255,.9);
}
.pin b::after {
  content: ""; position: absolute; left: 50%; bottom: -5px; transform: translateX(-50%);
  border: 5px solid transparent; border-bottom: 0; border-top-color: inherit;
}
.pin b.cam::before { content: "◉ "; font-size: 8px; vertical-align: 1px; opacity: .85; }
.pin.dim b { background: #6b7280 !important; }
.pin.moc b { background: #fff; color: #333; font-weight: 600; border-color: #999; }
.pin.duan b { background: #1d4ed8; }
.pin.ban b { background: #b91c1c; border-top-color: #b91c1c; font-size: 12.5px; padding: 3px 8px; box-shadow: 0 0 0 3px rgba(185,28,28,.35), 0 2px 6px rgba(0,0,0,.4); }
.pin.sel b { outline: 3px solid #facc15; z-index: 1000; }

.cl {
  background: transparent; border: 0;
}
.cl div {
  width: 100%; height: 100%; border-radius: 50%; display: grid; place-items: center; color: #fff;
  border: 3px solid rgba(255,255,255,.85); box-shadow: 0 2px 8px rgba(0,0,0,.35); text-align: center;
  font: 700 12px/1.05 "Be Vietnam Pro", system-ui, sans-serif;
}
.cl small { display: block; font-weight: 500; font-size: 9.5px; opacity: .9; }

/* Popup */
.leaflet-popup-content-wrapper { border-radius: 14px; padding: 0; overflow: hidden; background: var(--surface); color: var(--ink); }
.leaflet-popup-tip { background: var(--surface); }
.leaflet-popup-content { margin: 0; width: 290px !important; font-family: inherit; font-size: 13px; }
.pp-img { position: relative; height: 160px; background: var(--chip); display: flex; overflow-x: auto; scroll-snap-type: x mandatory; }
.pp-img img { height: 160px; width: 290px; object-fit: cover; flex: none; scroll-snap-align: start; cursor: zoom-in; }
.pp-img .cnt { position: sticky; right: 8px; left: auto; align-self: flex-end; margin: 0 8px 8px auto; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; padding: 2px 7px; border-radius: 999px; flex: none; }
.pp-body { padding: 12px 14px 12px; }
.pp-price { display: flex; align-items: baseline; gap: 8px; }
.pp-price .v { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.pp-price .u { color: var(--muted); font-size: 12px; }
.pp-tags { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0 8px; }
.pp-tags span { background: var(--chip); border-radius: 6px; padding: 2px 7px; font-size: 11.5px; }
.pp-tags .vt { color: #fff; }
.pp-dl { display: grid; grid-template-columns: 92px 1fr; gap: 3px 8px; margin: 0; }
.pp-dl dt { color: var(--muted); }
.pp-dl dd { margin: 0; font-weight: 500; }
.pp-years { display: flex; align-items: flex-end; gap: 6px; height: 64px; margin: 10px 0 2px; padding-top: 14px; }
.pp-years div { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; font-size: 10.5px; color: var(--muted); }
.pp-years i { display: block; width: 100%; background: var(--accent); border-radius: 3px 3px 0 0; position: relative; min-height: 2px; }
.pp-years i em { position: absolute; top: -14px; left: 50%; transform: translateX(-50%); font-style: normal; color: var(--ink); font-weight: 600; font-size: 10.5px; }
.pp-raw { margin-top: 8px; font-size: 12px; color: var(--muted); white-space: pre-wrap; max-height: 90px; overflow: auto; border-top: 1px dashed var(--line); padding-top: 6px; }
.pp-act { display: flex; gap: 6px; margin-top: 10px; }
.pp-act a, .pp-act button {
  flex: 1; text-align: center; text-decoration: none; font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
  padding: 7px 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.pp-act a.pri { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.leaflet-container a.leaflet-popup-close-button { color: #fff; text-shadow: 0 0 4px #000; z-index: 2; }

/* Công cụ bản đồ */
.map-tools { display: flex; flex-direction: column; gap: 6px; }
.map-tools button {
  font: 600 12.5px/1 "Be Vietnam Pro", system-ui, sans-serif; text-align: left; cursor: pointer;
  background: var(--surface); color: var(--ink); border: 0; border-radius: 9px; padding: 9px 11px; box-shadow: var(--shadow);
}
.map-tools button.on { background: #facc15; color: #1d232b; }
.map.probing, .map.probing .leaflet-interactive { cursor: crosshair !important; }
.probe-pin span { display: block; width: 22px; height: 22px; border-radius: 50%; background: #facc15; border: 3px solid #fff; box-shadow: 0 0 0 2px #1d232b, 0 2px 8px rgba(0,0,0,.5); cursor: move; }
.near { list-style: none; margin: 4px 0 0; padding: 0; }
.near button { display: flex; width: 100%; align-items: center; gap: 8px; border: 0; background: none; padding: 4px 0; cursor: pointer; font: inherit; color: var(--ink); text-align: left; border-bottom: 1px solid var(--line); }
.near b { color: #fff; border-radius: 6px; padding: 1px 6px; font-size: 12px; min-width: 38px; text-align: center; }
.near span { flex: 1; font-size: 12px; color: var(--muted); }
.near em { font-style: normal; font-size: 12px; color: var(--muted); }
.pp-act .pri-b { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.cmp { margin-top: 10px; padding: 8px 10px; background: var(--chip); border-radius: 8px; font-size: 12.5px; line-height: 1.5; }
.pp-body .chips .chip { font-size: 12px; padding: 3px 9px; }

/* Nội bộ */
.icon-btn.lock { display: grid; place-items: center; }
.icon-btn.lock[hidden] { display: none; }
.icon-btn.lock.on { background: #facc15; color: #1d232b; }
body.noibo .topbar { box-shadow: inset 0 -3px 0 #facc15; }
.nb-tag { display: inline-block; background: #facc15; color: #1d232b; font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 5px; margin-left: 6px; vertical-align: 2px; }
.nb-box { margin-top: 10px; padding: 8px 10px; border: 1px dashed #d4a20a; border-radius: 8px; font-size: 12.5px; }
.nb-box b { display: block; font-size: 11px; color: #b45309; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.dlg { border: 0; border-radius: 14px; padding: 0; width: min(92vw, 360px); background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.dlg::backdrop { background: rgba(0,0,0,.45); }
.dlg form { padding: 18px; }
.dlg h3 { margin: 0 0 6px; font-size: 16px; }
.dlg p { margin: 0 0 12px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.dlg input { width: 100%; font: inherit; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--ink); }
.dlg .err { color: #b91c1c; margin: 8px 0 0; }
.dlg .row { display: flex; gap: 8px; margin-top: 14px; }
.dlg .row button { flex: 1; margin: 0; padding: 9px; font: inherit; font-weight: 600; border-radius: 9px; cursor: pointer; }
.dlg .primary { background: var(--accent); color: var(--accent-ink); border: 0; }

/* Lightbox */
.lb { position: fixed; inset: 0; background: rgba(0,0,0,.88); z-index: 3000; display: grid; place-items: center; }
.lb img { max-width: 94vw; max-height: 90vh; border-radius: 8px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg);
  padding: 8px 14px; border-radius: 8px; z-index: 4000; font-size: 13px;
}

.scrim { display: none; }

/* Mobile */
@media (max-width: 760px) {
  .icon-btn { display: grid; place-items: center; }
  .topbar { flex-wrap: wrap; gap: 10px; padding: 8px 16px; }
  .brand .sub { display: none; }
  .search { order: 3; max-width: none; flex-basis: 100%; margin: 0; }
  .call { margin-left: auto; padding: 7px 10px; }
  .call span { display: none; }
  .panel {
    position: fixed; top: 0; bottom: 0; left: 0; width: min(86vw, 340px); z-index: 2000;
    transform: translateX(-105%); transition: transform .22s ease; box-shadow: var(--shadow);
  }
  body.panel-open .panel { transform: none; }
  body.panel-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 1500; }
  .leaflet-popup-content { width: 260px !important; }
  .pp-img img { width: 260px; }
}
