/* Tin đăng thị trường — tra cứu theo địa bàn (token Banggia navy) */

@font-face {
  font-family: "Be Vietnam Pro"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("/assets/fonts/be-vietnam-pro-400-full.woff2") format("woff2");
}
@font-face {
  font-family: "Be Vietnam Pro"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("/assets/fonts/be-vietnam-pro-600-full.woff2") format("woff2");
}
@font-face {
  font-family: "Be Vietnam Pro"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("/assets/fonts/be-vietnam-pro-700-full.woff2") format("woff2");
}

:root {
  --bg: #f6f7fa;
  --sf: #ffffff;
  --sf2: #f2f4f8;
  --bd: #e4e7ee;
  --bd2: #cdd4e0;
  --t1: #101828;
  --t2: #475467;
  --t3: #98a2b3;
  --navy: #12308a;
  --blue: #1e4fd1;
  --soft: #f4f7ff;
  --soft2: #fbfdff;
  --money: #0e7a4f;
  --danger: #b4232c;
  --warn: #b54708;
  --ring: 0 0 0 3px rgba(30, 79, 209, 0.25);
  --sh1: 0 1px 3px rgba(16, 24, 40, 0.06);
  --sh2: 0 12px 32px rgba(16, 24, 40, 0.22);
  --r: 10px;
  --r-md: 12px;
  --r-xs: 6px;
  --font: "Be Vietnam Pro", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --max: 1220px;
  --tx: var(--t1);
  --tx2: var(--t2);
  --tx3: var(--t3);
  --price: var(--money);
  --err: var(--danger);
}

html { color-scheme: light; }
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1424;
  --sf: #131c30;
  --sf2: #1a2438;
  --bd: #243252;
  --bd2: #33415f;
  --t1: #e9edf6;
  --t2: #a6b0c8;
  --t3: #6e7c99;
  --navy: #3e63d4;
  --blue: #8db0ff;
  --soft: #182643;
  --soft2: #141f38;
  --money: #45c690;
  --danger: #ff8d94;
  --warn: #f79009;
  --ring: 0 0 0 3px rgba(141, 176, 255, 0.3);
  --sh1: 0 1px 3px rgba(0, 0, 0, 0.4);
  --sh2: 0 12px 34px rgba(0, 0, 0, 0.55);
}

html, body { overflow-x: clip; }
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--t1);
  line-height: 1.5;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--navy); }
.skip-link {
  position: absolute; left: -9999px; top: 8px; z-index: 100;
  background: var(--navy); color: #fff; padding: 8px 12px; border-radius: var(--r-xs);
}
.skip-link:focus { left: 8px; }

.site-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--sf) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--bd);
}
.nav {
  max-width: var(--max); margin: 0 auto;
  padding: 10px 16px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--tx); font-weight: 600; text-decoration: none;
}
.brand:hover { color: var(--navy); text-decoration: none; }
.brand strong { color: var(--navy); }
.brand svg .lg-bg { fill: var(--navy); }
.brand svg .lg-pin { fill: #fff; }
.brand svg .lg-hole { fill: var(--navy); }
.brand svg .lg-cross { stroke: #fff; }
.pill {
  font-size: 12px; font-weight: 600; color: var(--navy);
  background: var(--soft); border: 1px solid var(--bd);
  padding: 4px 10px; border-radius: 999px;
}
.nav-meta { margin-left: auto; color: var(--tx3); font-size: 12px; }
.theme-toggle { flex: none; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
html[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

main { max-width: var(--max); margin: 0 auto; padding: 20px 16px 64px; }

.intro h1 {
  margin: 0 0 8px;
  font-size: clamp(1.35rem, 2.5vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}
.intro p { margin: 0; color: var(--tx2); max-width: 65ch; }
.note {
  margin-top: 12px; padding: 10px 12px;
  background: var(--sf); border: 1px solid var(--bd); border-radius: var(--r);
  color: var(--tx2); font-size: 13px;
}
.note strong { color: var(--warn); font-weight: 600; }

.filters {
  margin-top: 18px;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
@media (max-width: 900px) {
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .filters { grid-template-columns: minmax(0, 1fr); }
}

.field {
  position: relative;
  background: var(--sf); border: 1px solid var(--bd); border-radius: var(--r);
  padding: 8px 12px 10px; display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
.field:focus-within,
.field:has(.combo-btn[aria-expanded="true"]) {
  border-color: var(--navy); box-shadow: var(--ring); z-index: 20;
}
.field-label { font-size: 10.5px; font-weight: 700; color: var(--t3); text-transform: uppercase; letter-spacing: 0.05em; }
.field-label .req { color: var(--err); }

.combo { position: static; }
.combo-btn {
  appearance: none; border: 0; background: transparent;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; min-height: 28px; padding: 0;
  font: inherit; font-size: 13.5px; font-weight: 600; color: var(--t1);
  text-align: left; cursor: pointer;
}
.combo-btn:disabled { color: var(--t3); font-weight: 500; cursor: not-allowed; }
.combo-value { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-caret { flex: none; color: var(--t3); }
.combo-btn[aria-expanded="true"] .combo-caret { transform: rotate(180deg); }
.combo-list {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  margin: 0; padding: 6px; list-style: none;
  background: var(--sf);
  color: var(--t1);
  border: 1px solid var(--bd2);
  border-radius: var(--r-md);
  box-shadow: var(--sh2);
  max-height: min(58vh, 320px); overflow: auto;
  z-index: 30;
  isolation: isolate;
}
.combo-list li[role="option"] {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  padding: 8px 10px; border-radius: var(--r-xs); cursor: pointer;
  color: var(--t1); font-size: 13.5px; font-weight: 500;
}
.combo-list li[role="option"]:hover,
.combo-list li[role="option"].focused { background: var(--soft); }
.combo-list li[role="option"][aria-selected="true"] { color: var(--navy); font-weight: 700; }
.combo-list .p-name { min-width: 0; overflow-wrap: anywhere; }

.field-seg { grid-column: 1 / -1; align-self: start; }

.seg-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.seg-tabs button {
  appearance: none; border: 1px solid var(--bd); background: var(--sf);
  color: var(--tx2); font: inherit; font-weight: 600; font-size: 13px;
  padding: 8px 12px; border-radius: 999px; cursor: pointer;
}
.seg-tabs button:hover { color: var(--navy); border-color: var(--bd2); }
.seg-tabs button[aria-pressed="true"] {
  background: var(--navy); color: #fff; border-color: var(--navy);
}
.seg-tabs button:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }

.status {
  margin-top: 12px; font-size: 13px; color: var(--tx2); min-height: 1.25em;
}
.status.loading { color: var(--navy); }
.status.error { color: var(--err); }

.empty-wrap, .listings-wrap { position: relative; z-index: 0; margin-top: 16px; }
.empty {
  padding: 28px; text-align: center; color: var(--tx3);
  background: var(--sf); border: 1px dashed var(--bd); border-radius: var(--r);
}
.boot { padding: 40px; text-align: center; color: var(--tx3); }
.spin {
  display: inline-block; width: 18px; height: 18px; margin-right: 8px;
  border: 2px solid var(--bd); border-top-color: var(--navy);
  border-radius: 50%; vertical-align: -3px;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.listings-wrap { margin-top: 12px; min-width: 0; }
.list-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap; margin-bottom: 8px;
  font-size: 13px; color: var(--tx2);
}
.pager { display: flex; align-items: center; gap: 8px; }
.pager button {
  appearance: none; border: 1px solid var(--bd); background: var(--sf);
  color: var(--tx); font: inherit; font-size: 13px; font-weight: 600;
  padding: 6px 12px; border-radius: var(--r-xs); cursor: pointer;
}
.pager button:hover:not(:disabled) { border-color: var(--navy); color: var(--navy); }
.pager button:disabled { opacity: 0.45; cursor: not-allowed; }

.table-wrap {
  overflow: auto;
  background: var(--sf);
  border: 1px solid var(--bd);
  border-radius: var(--r);
  max-height: min(70vh, 720px);
}
.table-wrap:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }

table.listings {
  width: 100%; border-collapse: collapse; font-size: 13px; min-width: 960px;
}
table.listings th, table.listings td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--bd);
  text-align: left;
  vertical-align: top;
}
table.listings th {
  position: sticky; top: 0; z-index: 1;
  background: var(--sf2);
  color: var(--tx3);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
table.listings tbody tr:hover { background: var(--sf2); }
table.listings td.num, table.listings th.num {
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
table.listings td.price { color: var(--price); font-weight: 600; }
table.listings td.muted { color: var(--tx3); }
table.listings td.proj {
  max-width: 180px;
  overflow-wrap: anywhere;
  font-size: 12px;
}
.tag {
  display: inline-block;
  font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px;
  background: var(--soft); color: var(--blue);
  border: 1px solid var(--bd);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tag.muted { color: var(--t2); background: var(--sf2); }

.cards {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.card {
  background: var(--sf);
  border: 1px solid var(--bd);
  border-radius: var(--r);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.card:hover { border-color: var(--navy); }
.thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: var(--sf2);
  display: block;
}
.thumb.empty {
  display: flex; align-items: center; justify-content: center;
  color: var(--tx3); font-size: 13px;
}
.card-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; }
.card-body .price { margin: 0; color: var(--money); font-weight: 700; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.card-body .meta, .card-body .where { margin: 0; color: var(--tx2); font-size: 13px; }
.card-body .where { overflow-wrap: anywhere; }
.card-body .tags { margin: 4px 0 0; display: flex; flex-wrap: wrap; gap: 4px; }

.hidden { display: none !important; }
.modal-bg {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(16, 24, 40, 0.45);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 16px;
}
@media (min-width: 720px) {
  .modal-bg { align-items: center; }
}
.modal {
  width: min(760px, 100%);
  max-height: min(92vh, 880px);
  overflow: auto;
  background: var(--sf);
  border: 1px solid var(--bd);
  border-radius: 14px;
  padding: 16px 16px 20px;
}
.modal-head {
  display: flex; justify-content: space-between; gap: 12px; align-items: flex-start;
}
.modal-head h3 { margin: 0; font-size: 1.1rem; }
.modal-head p { margin: 4px 0 0; color: var(--tx2); font-size: 13px; }
.icon-btn {
  appearance: none; border: 1px solid var(--bd); background: var(--sf);
  width: 34px; height: 34px; border-radius: 8px; cursor: pointer;
  display: inline-grid; place-items: center; flex: none;
  font-size: 20px; line-height: 1; color: var(--t2);
}
.icon-btn:hover { border-color: var(--navy); color: var(--navy); }
.shots {
  display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  margin: 14px 0;
}
.shot img {
  width: 100%; aspect-ratio: 4 / 3; object-fit: contain;
  background: var(--sf2);
  border-radius: 8px; border: 1px solid var(--bd); display: block;
}
.facts { margin: 0; display: grid; gap: 8px 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 560px) { .facts { grid-template-columns: 1fr; } }
.kv { margin: 0; }
.kv dt { font-size: 11px; font-weight: 700; color: var(--tx3); text-transform: uppercase; letter-spacing: 0.03em; }
.kv dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.gcn-note {
  margin: 14px 0 0; padding: 10px 12px;
  background: var(--sf2); border-radius: 8px;
  color: var(--tx2); font-size: 13px; overflow-wrap: anywhere;
}
.ext { font-weight: 600; }
.empty-inline { color: var(--tx3); }
