:root {
  --bg: #f4f6fa;
  --card: #fff;
  --text: #0f1b33;
  --muted: #5b6478;
  --line: #e3e7ef;
  --primary: #1554d1;
  --primary-ink: #fff;
  --ok: #157f3d;
  --ok-bg: #e6f6ec;
  --warn: #b42318;
  --warn-bg: #fdecea;
  --idle-bg: #eef1f6;
  color-scheme: light;
}
* {
  box-sizing: border-box;
}
html {
  font-size: 18px;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.5;
}
[hidden] {
  display: none !important;
}
h1,
h2 {
  margin: 0;
  line-height: 1.25;
}
h1 {
  font-size: 1.4rem;
}
h2 {
  font-size: 1.2rem;
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 0.85rem;
}
.row {
  display: flex;
  gap: 12px;
  align-items: center;
}
.row.end {
  justify-content: flex-end;
}
.sp {
  flex: 1;
}
.card {
  background: var(--card);
  border: 0;
  box-shadow: var(--sh-sm);
  border-radius: 14px;
  padding: 20px;
}

/* Nút: to, dễ bấm */
.btn {
  font: inherit;
  min-height: 44px;
  padding: 8px 18px;
  border-radius: 10px;
  border: 0;
  box-shadow: var(--sh-sm);
  background: #fff;
  color: var(--text);
  cursor: pointer;
}
.btn.big {
  min-height: 52px;
  padding: 10px 22px;
  font-weight: 600;
}
.btn.primary {
  background: var(--primary);
  color: var(--primary-ink);
}
.btn.danger {
  background: var(--warn);
  color: #fff;
}
.btn.ghost {
  background: transparent;
}
.btn:disabled {
  opacity: 0.55;
  cursor: progress;
}
.btn:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid #9cb8f0;
  outline-offset: 2px;
}

input,
textarea {
  font: inherit;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-radius: 10px;
  background: #fff;
  color: var(--text);
}
textarea {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.8rem;
  word-break: break-all;
}
.fld {
  display: grid;
  gap: 6px;
}
.fld > span {
  font-weight: 600;
}

/* Đăng nhập */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}
.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
}

/* Khung app */
.top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: #0f1b33;
  color: #fff;
}
.top .btn.ghost {
  color: #fff;
}
.wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  gap: 16px;
}

/* Trạng thái kết nối */
.conn {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: center;
}
.conn.ok {
  background: var(--ok-bg);
}
.conn.bad {
  background: var(--warn-bg);
}
.conn.idle {
  background: var(--idle-bg);
}
.conn .txt {
  flex: 1;
  min-width: 240px;
}
.conn b.state {
  display: block;
  font-size: 1.1rem;
}
.conn.ok b.state {
  color: var(--ok);
}
.conn.bad b.state {
  color: var(--warn);
}

/* Tìm kiếm */
.search {
  display: grid;
  gap: 14px;
}
.seg {
  display: inline-flex;
  background: var(--idle-bg);
  border-radius: 12px;
  padding: 4px;
  width: fit-content;
}
.seg-b {
  font: inherit;
  font-weight: 600;
  min-height: 48px;
  padding: 8px 22px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.seg-b.on {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.12);
}

/* Danh sách */
.list {
  display: grid;
  gap: 12px;
}
.item {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 16px;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  background: var(--card);
  border: 0;
  box-shadow: var(--sh-sm);
  border-radius: 14px;
  padding: 12px;
  cursor: pointer;
}
.item:hover {
  box-shadow: var(--sh-md);
}
.thumb {
  width: 120px;
  height: 96px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--idle-bg);
}
.item .t {
  font-weight: 700;
  font-size: 1.05rem;
}
.item .facts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  align-items: center;
  margin-top: 4px;
}
.price {
  color: var(--warn);
  font-weight: 700;
}
.empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--muted);
}
.pager {
  justify-content: center;
}

/* Hộp thoại */
.dlg {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  border: 0;
  border-radius: 16px;
  padding: 0;
  color: var(--text);
}
.dlg.wide {
  width: min(860px, calc(100vw - 32px));
}
.dlg::backdrop {
  background: rgb(15 27 51 / 0.55);
}
.dlg-body {
  padding: 20px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}
.dlg-h {
  display: flex;
  align-items: center;
  gap: 12px;
}
.dlg-h h2 {
  flex: 1;
}
.btn.x {
  font-size: 1.2rem;
  min-width: 48px;
}
.steps {
  margin: 0;
  padding-left: 1.4em;
  display: grid;
  gap: 8px;
}

/* Chi tiết */
.gallery {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.gallery img {
  height: 160px;
  border-radius: 10px;
  flex: none;
}
.kv {
  display: grid;
  grid-template-columns: minmax(120px, 220px) minmax(0, 1fr);
  gap: 6px 16px;
  margin: 0;
}
.kv dt {
  color: var(--muted);
  word-break: break-word;
}
.kv dd {
  margin: 0;
  white-space: pre-line;
  word-break: break-word;
}
section > h2 {
  margin: 8px 0 4px;
}
.cmt {
  padding: 10px 0;
}
.cmt .who {
  font-weight: 600;
}
details pre {
  max-height: 360px;
  overflow: auto;
  background: #0f1b33;
  color: #dfe7f7;
  padding: 12px;
  border-radius: 10px;
  font-size: 0.75rem;
}
summary {
  cursor: pointer;
  font-weight: 600;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.toast {
  position: fixed;
  inset: auto auto 24px 50%;
  margin: 0;
  border: 0;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  background: #0f1b33;
  color: #fff;
  padding: 14px 20px;
  border-radius: 12px;
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.25);
  z-index: 10;
}
.toast.err {
  background: var(--warn);
}

@media (max-width: 600px) {
  .wrap {
    padding: 12px;
  }
  .item {
    grid-template-columns: 88px minmax(0, 1fr);
  }
  .thumb {
    width: 88px;
    height: 76px;
  }
  .kv {
    grid-template-columns: 1fr;
    gap: 0 0;
  }
  .kv dd {
    margin-bottom: 8px;
  }
  #search-form {
    flex-wrap: wrap;
  }
  #search-form .btn {
    width: 100%;
  }
}

.demo-banner {
  margin: 0;
  padding: 12px 16px;
  background: #fde68a;
  color: #78350f;
  font-weight: 700;
  text-align: center;
}

/* ---------- Thẻ tin & chi tiết ---------- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0;
}
.chip,
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: #e8f0fe;
  color: #123c8c;
  font-size: 0.9em;
  font-weight: 600;
}
.badge.qualified {
  background: var(--ok-bg);
  color: var(--ok);
}
.badge.unqualified {
  background: #fff4e0;
  color: #9a5b00;
}
.gallery a,
.gallery .g-open {
  flex: none;
}
.g-open {
  display: block;
  padding: 0;
  border: 0;
  border-radius: 10px;
  overflow: hidden;
  background: none;
  cursor: zoom-in;
}
.g-open:focus-visible {
  outline: 3px solid var(--navy-950);
  outline-offset: 2px;
}
.g-item .g-open {
  width: 100%;
  height: 100%;
  border-radius: 0;
}

/* Xem ảnh lớn ngay trên màn hình */
.viewer {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: #000;
  color: #fff;
}
.viewer[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}
.viewer::backdrop {
  background: #000;
}
.vw-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
}
.vw-count {
  flex: 1;
  font-size: 1.1rem;
  font-weight: 600;
}
.vw-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  touch-action: pinch-zoom;
  user-select: none;
}
/* Ảnh luôn vừa một màn hình: phủ kín khung ảnh rồi thu theo tỉ lệ, không tràn xuống dưới */
.vw-stage img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  -webkit-user-drag: none;
}
.vw-btn {
  min-width: 56px;
  min-height: 56px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.2);
  color: #fff;
  font: inherit;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
}
.vw-btn:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}
.vw-btn[hidden],
.vw-hint[hidden] {
  display: none;
}
.vw-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  padding: 0;
  font-size: 2rem;
  line-height: 1;
}
.vw-prev {
  left: 8px;
}
.vw-next {
  right: 8px;
}
.vw-foot {
  display: grid;
  gap: 6px;
  padding: 8px 0 calc(10px + env(safe-area-inset-bottom));
}
.vw-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 12px;
  scrollbar-width: thin;
}
.vw-strip:empty {
  display: none;
}
.vw-th {
  flex: none;
  width: 88px;
  height: 64px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  overflow: hidden;
  background: #222;
  opacity: 0.55;
  cursor: pointer;
}
.vw-th img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.vw-th:hover,
.vw-th.on {
  opacity: 1;
}
.vw-th.on {
  outline: 3px solid #fff;
  outline-offset: -3px;
}
.vw-th:focus-visible {
  outline: 3px solid var(--blue-500, #2b92d1);
  outline-offset: -3px;
}
@media (max-width: 560px) {
  .vw-th {
    width: 64px;
    height: 48px;
  }
}
.vw-hint {
  margin: 0;
  padding: 0 12px;
  text-align: center;
  color: rgb(255 255 255 / 0.75);
}
.addr {
  margin: 8px 0 0;
}
.sec {
  padding: 10px 0;
}
.sec > summary {
  font-weight: 700;
  font-size: 1.05em;
  padding: 6px 0;
}
.sec h4 {
  margin: 10px 0 2px;
  color: var(--muted);
  font-weight: 600;
}
.desc {
  white-space: pre-line;
  word-break: break-word;
  margin-top: 8px;
}

/* ---------- Lưới thẻ ---------- */
.wrap {
  max-width: 1440px;
}
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.toolbar input[type='search'] {
  flex: 1 1 260px;
}
.count {
  display: inline-grid;
  place-items: center;
  min-width: 1.5em;
  height: 1.5em;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 0.8em;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.grid > .empty {
  grid-column: 1 / -1;
}
.tile {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 0;
  box-shadow: var(--sh-sm);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
}
.tile:hover,
.tile:focus-visible {
  box-shadow: var(--sh-md);
  box-shadow: 0 2px 10px rgb(15 27 51 / 0.08);
}
.tile-img {
  position: relative;
  flex: none;
  overflow: hidden;
  aspect-ratio: 2 / 1;
  background: var(--idle-bg);
}
.tile-img img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.tile-img .more {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 2px 8px;
  border-radius: 8px;
  background: rgb(0 0 0 / 0.6);
  color: #fff;
  font-size: 0.85em;
  font-weight: 600;
}
.tile-b {
  display: grid;
  gap: 8px;
  padding: 12px 14px 14px;
}
.tile .t {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}
.meta > * {
  white-space: nowrap;
}
.tile .chips {
  margin: 0;
}
.meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.92em;
}
.owner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--bg);
}
.ava {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--idle-bg);
  flex: none;
}
.owner .who {
  display: grid;
  min-width: 0;
  flex: 1;
}
.owner .who > * {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.circle {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  border: 0;
  box-shadow: var(--sh-sm);
  background: #fff;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}
.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}
.pages {
  display: flex;
  align-items: center;
  gap: 6px;
}
.pg {
  font: inherit;
  min-width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 0;
  box-shadow: var(--sh-sm);
  background: #fff;
  cursor: pointer;
}
.pg.on {
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}
.pg:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ---------- Bộ lọc, sắp xếp ---------- */
.pick {
  font: inherit;
  min-height: 44px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 0;
  box-shadow: var(--sh-sm);
  background: #fff;
  color: var(--text);
  cursor: pointer;
}
.pick.on {
  background: #e8f0fe;
  color: #123c8c;
  font-weight: 600;
}
.range {
  display: flex;
  align-items: center;
  gap: 8px;
}
.range input {
  flex: 1;
  min-width: 0;
}
select {
  font: inherit;
  min-height: 48px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 0;
  background: #fff;
}
.opts {
  display: grid;
  gap: 8px;
}
.opt {
  font: inherit;
  text-align: left;
  min-height: 56px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 0;
  box-shadow: var(--sh-sm);
  background: #fff;
  cursor: pointer;
}
.opt.on {
  background: #e8f0fe;
  font-weight: 700;
}
.sticky-foot {
  position: sticky;
  bottom: 0;
  background: var(--card);
  padding-top: 12px;
  box-shadow: 0 -6px 16px rgb(1 29 69 / 0.08);
}

/* Bộ lọc: các ô trong một mục cách nhau, ô tìm trong danh sách phường / đường */
.sec > .fld,
.sec > .area-box,
.area-box > .fld {
  margin-top: 12px;
}
.mpick {
  display: grid;
  gap: 8px;
}
.mpick .chips {
  max-height: 260px;
  overflow-y: auto;
}
/* Phường theo quận, đường theo phường */
.tree {
  display: grid;
  gap: 8px;
}
.tree .chips {
  max-height: none;
  overflow: visible;
}
.tree-g {
  border: 0;
  box-shadow: var(--sh-sm);
  border-radius: 10px;
  padding: 8px 10px;
}
.tree-g > summary {
  cursor: pointer;
  padding: 6px 0;
  font-size: 1rem;
}
.tree-g > summary > span,
.tree-g > b + span {
  margin-left: 4px;
}
.tree-g .chips {
  margin-top: 6px;
}
.tree-g > .btn {
  margin-top: 6px;
}
.tree-sel {
  display: grid;
  gap: 4px;
  padding-bottom: 8px;
}

/* ---------- Chế độ xem dạng bảng ---------- */
.seg-v {
  font: inherit;
  font-weight: 600;
  min-height: 44px;
  padding: 6px 16px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.seg-v.on {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.12);
}
.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 120px);
  background: var(--card);
  border: 0;
  box-shadow: var(--sh-sm);
  border-radius: 14px;
}
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.tbl th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f7f8fb;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  text-align: left;
  white-space: nowrap;
  padding: 10px 12px;
}
.tbl td {
  padding: 12px;
  vertical-align: top;
}
.tbl tbody tr {
  cursor: pointer;
}
.tbl tbody tr:hover,
.tbl tbody tr:focus-visible {
  background: #f2f6ff;
  outline: none;
}
.tbl .num {
  white-space: nowrap;
}
.addr-cell,
.price-cell,
.owner-cell {
  display: grid;
  gap: 2px;
}
.addr-cell {
  min-width: 240px;
  max-width: 340px;
}
.owner-cell {
  min-width: 150px;
}
.owner-cell a {
  color: var(--primary);
  font-weight: 600;
  white-space: nowrap;
}
.price-cell b {
  color: #c4161c;
}

/* ---------- Phân tích thị trường ---------- */
.mode-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.mode-b {
  font: inherit;
  font-weight: 700;
  min-height: 52px;
  padding: 8px 20px;
  border: 0;
  box-shadow: var(--sh-sm);
  border-radius: 12px;
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
}
.mode-b.on {
  color: var(--primary);
  background: #eef3ff;
}
.ana {
  display: grid;
  /* cột minmax(0, 1fr): bảng rộng cuộn trong khung của nó, không kéo giãn cả trang */
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}
.ana-note {
  margin: 0;
}
.ana-sec {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  min-width: 0;
}
.ana-h h2 {
  margin: 0;
  font-size: 1.15rem;
}
.ana-h p {
  margin: 4px 0 0;
}
.chart-t {
  margin: 8px 0 0;
  font-size: 0.95rem;
}
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
}
.kpi {
  display: grid;
  gap: 4px;
  align-content: start;
  padding: 12px 14px;
  border: 0;
  box-shadow: var(--sh-sm);
  border-radius: 12px;
  background: #fafbfd;
}
.kpi-l {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}
.kpi-v {
  font-size: 1.3rem;
  line-height: 1.2;
}
.n-tag {
  display: inline-block;
  padding: 0 6px;
  border-radius: 6px;
  background: var(--idle-bg);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}
.warn-tag {
  color: #9a5b00;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}
/* Thông tin khách nói mâu thuẫn — cần hỏi lại */
.warn-box {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 0;
  box-shadow: var(--sh-sm);
  border-radius: 10px;
  background: #fff8e6;
  color: #6b4200;
  font-size: 0.9rem;
}
.warn-box[hidden] {
  display: none;
}
.warn-box ul {
  margin: 6px 0 0;
}
.warn-box li + li {
  margin-top: 4px;
}
/* Nhận định */
.ins-g h3 {
  margin: 4px 0 6px;
  font-size: 0.95rem;
  color: var(--muted);
}
.ins-g {
  display: grid;
  gap: 6px;
}
.ins {
  display: flex;
  gap: 12px;
  align-items: center;
  width: 100%;
  text-align: left;
  font: inherit;
  padding: 10px 14px;
  border: 0;
  box-shadow: var(--sh-sm);
  border-radius: 10px;
  background: var(--card);
  cursor: pointer;
}
.ins:hover {
  box-shadow: var(--sh-md);
  background: #f5f8ff;
}
.ins > span:first-child {
  flex: 1;
}
.ins-n {
  color: var(--primary);
  font-weight: 700;
  white-space: nowrap;
  font-size: 0.85rem;
}
/* Biểu đồ thanh ngang (1 màu) */
.bars {
  display: grid;
  gap: 2px;
}
.bars-ref {
  text-align: right;
}
.bar-row {
  display: grid;
  /* cột giá trị cố định để mọi thanh cùng chiều dài trục, vạch trung vị thẳng hàng */
  grid-template-columns: minmax(110px, 220px) 1fr 160px;
  gap: 10px;
  align-items: center;
  font: inherit;
  font-size: 0.85rem;
  padding: 5px 6px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: var(--text);
}
.bar-row:disabled {
  cursor: default;
}
.bar-row:hover:not(:disabled) {
  background: #f2f6ff;
}
.bar-l {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bar-t {
  position: relative;
  height: 16px;
}
.bar-f {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 0 4px 4px 0;
  background: var(--primary);
}
.bar-refline {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  background: var(--text);
  opacity: 0.55;
}
.bar-v {
  min-width: 90px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.th-sort {
  font: inherit;
  text-transform: inherit;
  color: inherit;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  font-weight: 700;
  text-align: left;
}
.tbl tr.picked {
  background: #eef3ff;
}
.cmp-box {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 0;
  box-shadow: var(--sh-sm);
  border-radius: 12px;
  margin-bottom: 12px;
}
/* Ma trận */
.heat th[scope='row'] {
  white-space: nowrap;
  font-weight: 600;
  text-align: left;
  /* cuộn ngang sang các phân khúc sau vẫn thấy tên đường */
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--card);
}
.heat thead th:first-child {
  left: 0;
  z-index: 2;
}
.heat td {
  padding: 3px;
}
.heat .cell {
  width: 100%;
  min-width: 64px;
  min-height: 40px;
  border: 2px solid #fff;
  border-radius: 6px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.heat .cell:disabled {
  cursor: default;
  color: var(--muted) !important;
}
.heat tfoot td,
.heat tfoot th {
}
.heat-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
}
.sw {
  width: 22px;
  height: 14px;
  border-radius: 3px;
}
/* Nổi bật */
.hl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}
.hl {
  display: grid;
  gap: 6px;
  align-content: start;
}
.hl h3 {
  margin: 0;
  font-size: 0.95rem;
}
.hl-i,
.pair-i {
  display: grid;
  gap: 2px;
  text-align: left;
  font: inherit;
  padding: 8px 12px;
  border: 0;
  box-shadow: var(--sh-sm);
  border-radius: 10px;
  background: var(--card);
  cursor: pointer;
}
.hl-i:hover,
.pair-i:hover {
  box-shadow: var(--sh-md);
}
/* Cạnh tranh */
.tols {
  gap: 16px;
  flex-wrap: wrap;
}
.tol input {
  width: 90px;
}
.pairs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 12px;
}
.pair {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: stretch;
  padding: 10px;
  border: 0;
  box-shadow: var(--sh-sm);
  border-radius: 12px;
  background: #fafbfd;
}
.pair .vs {
  align-self: center;
  color: var(--muted);
  font-weight: 700;
}
.pair-r {
  grid-column: 1 / -1;
  margin: 0;
}
.pair > .btn {
  grid-column: 1 / -1;
  justify-self: start;
}
.survey {
  display: grid;
  gap: 8px;
  padding-left: 1.4em;
  margin: 0;
}
/* So sánh */
.compare-bar {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--text);
  color: #fff;
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.25);
}
.tbl.cmp th[scope='row'] {
  white-space: nowrap;
  text-align: left;
}
.tbl.cmp td.best {
  font-weight: 800;
  background: var(--ok-bg);
}
.price {
  color: #c4161c;
}
/* Vị thế */
.pos {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  margin-top: 16px;
  padding-top: 12px;
}
.pos h3,
.pos h4 {
  margin: 8px 0 0;
}
.pos-tabs {
  flex-wrap: wrap;
  width: auto;
}
.pos-tabs .seg-b {
  min-height: 40px;
  padding: 6px 12px;
  font-size: 0.85rem;
}
.script {
  margin: 8px 0;
  padding: 10px 14px;
  background: #f5f8ff;
  border-radius: 0 10px 10px 0;
}
.script p {
  margin: 6px 0 0;
}
@media (max-width: 640px) {
  .bar-row {
    grid-template-columns: 1fr auto;
  }
  .bar-t {
    grid-column: 1 / -1;
    grid-row: 2;
  }
  .pairs {
    grid-template-columns: 1fr;
  }
  .pair {
    grid-template-columns: 1fr;
  }
  .pair .vs {
    justify-self: center;
  }
}
.tbl th[scope='row'] {
  text-transform: none;
  font-size: 0.9rem;
  color: var(--text);
  background: transparent;
  position: static;
}
.heat td {
  vertical-align: middle;
}
/* đặt sau luật chung .tbl th[scope='row'] để cột tên đường dính bên trái khi cuộn ngang */
.tbl.heat th[scope='row'] {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--card);
}
.ana-sec .table-wrap {
  max-height: none;
}
#ana-items .table-wrap,
#items-body .table-wrap {
  max-height: 70vh;
}

/* ---------- Khách hàng ---------- */
.lv {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  vertical-align: middle;
  border: 0;
  box-shadow: var(--sh-sm);
}
.lv-HOT {
  background: var(--warn-bg);
  color: var(--warn);
}
.lv-WARM {
  background: #fff4dc;
  color: #7a4d00;
}
.lv-COLD {
  background: #e7f0fa;
  color: #1f4e79;
}
.lv-UNKNOWN {
  background: var(--idle-bg);
  color: var(--muted);
}
.kpi-b {
  font: inherit;
  text-align: left;
  color: inherit;
  cursor: pointer;
}
.kpi-b.on {
  border: 0;
  box-shadow: var(--sh-sm);
  background: #eef3ff;
}
.cu-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: 10px;
}
.cu-card {
  font: inherit;
  color: inherit;
  text-align: left;
  display: grid;
  gap: 6px;
  align-content: start;
  padding: 14px;
  border: 0;
  box-shadow: var(--sh-sm);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  min-height: 48px;
}
.cu-card:hover,
.cu-card:focus-visible {
  box-shadow: var(--sh-md);
}
.cu-top {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 1.05rem;
}
.cu-prog {
  display: block;
  height: 8px;
  border-radius: 99px;
  background: var(--idle-bg);
  overflow: hidden;
}
.cu-prog > span {
  display: block;
  height: 100%;
  background: var(--primary);
}
.tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--idle-bg);
  color: var(--text);
}
.tag.ok {
  background: var(--ok-bg);
  color: var(--ok);
}
.tag.warn {
  background: var(--warn-bg);
  color: var(--warn);
}
.task-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: 16px;
}
.task-cols h3 {
  margin: 0 0 8px;
  font-size: 1rem;
  letter-spacing: 0.02em;
}
.task-item {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 0;
  box-shadow: var(--sh-sm);
  border-radius: 10px;
}
.link-b {
  font: inherit;
  color: var(--primary);
  background: none;
  border: 0;
  padding: 4px 0;
  text-align: left;
  cursor: pointer;
  min-height: 32px;
}
.gaps > summary {
  cursor: pointer;
  font-size: 1.05rem;
  padding: 4px 0;
}
.gap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 14px;
}
.gap-grid h4 {
  margin: 0 0 4px;
}
.gap-grid p {
  margin: 0 0 4px;
}
ul.plain {
  margin: 0;
  padding-left: 1.1em;
  display: grid;
  gap: 4px;
}
.notes li {
  color: #7a4d00;
}
.src {
  display: inline-block;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  vertical-align: 1px;
}
.src-confirmed {
  background: var(--ok-bg);
  color: var(--ok);
}
.src-inferred {
  background: #fff4dc;
  color: #7a4d00;
}
.checks {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
}
.checks li.ok b {
  color: var(--ok);
}
.checks li.bad b {
  color: var(--warn);
}
.checks li.unk b {
  color: #7a4d00;
}
.ins-block {
  display: grid;
  gap: 6px;
}
.ins-block h4 {
  margin: 6px 0 0;
}
.flex3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: 12px;
}
.flex-col {
  border: 0;
  box-shadow: var(--sh-sm);
  border-radius: 12px;
  padding: 10px 12px;
}
.flex-col h4 {
  margin: 0 0 6px;
}
.flex-col .kv {
  grid-template-columns: minmax(0, 1fr);
}
.flex-col .kv dt {
  margin-top: 4px;
}
.opt-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 0;
  box-shadow: var(--sh-sm);
  border-radius: 12px;
  background: #fafbfd;
}
.opt-card h4 {
  margin: 0;
}
.opt-card p {
  margin: 0;
}
.mi-list {
  display: grid;
  gap: 8px;
}
.mi {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 0;
  box-shadow: var(--sh-sm);
  border-radius: 10px;
  background: #fff;
}
.mi p {
  margin: 0;
}
.hist-list {
  display: grid;
  gap: 10px;
}
.hist {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 0;
  box-shadow: var(--sh-sm);
  border-radius: 10px;
}
.hist p {
  margin: 0;
}
.hist.pending {
  background: #fffafa;
}
.row.wrap-row,
.opt-card .row,
.mi .row,
.hist .row {
  flex-wrap: wrap;
}
.chips.big .pick {
  min-height: 52px;
  padding: 8px 18px;
}
.range2,
.grid3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
  gap: 10px;
}
.anchor {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 0;
  box-shadow: var(--sh-sm);
  border-radius: 12px;
  margin-bottom: 10px;
}
.anchor .range2 {
  grid-template-columns: minmax(0, 180px) minmax(0, 1fr);
}
.anchor > .btn:last-child {
  justify-self: start;
}
.ok-line {
  margin: 0;
  color: #1d6b35;
  font-weight: 600;
}
.more > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 4px 0;
}
.more > input {
  width: 100%;
  margin-top: 6px;
}
.crit {
  display: grid;
  gap: 6px;
  padding: 10px 0;
}
.check {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 48px;
}
.check input {
  width: 24px;
  height: 24px;
}
select {
  font: inherit;
  min-height: 48px;
  padding: 6px 10px;
  border: 0;
  border-radius: 10px;
  background: #fff;
}
.fb-body,
.wz-sec {
  display: grid;
  gap: 14px;
}
/* Wizard: câu hỏi to, nút cố định đáy */
.wiz .dlg-body {
  padding-bottom: 0;
}
.wz-head {
  flex: 1;
  display: grid;
}
.wz-head h2 {
  font-size: 1.2rem;
}
.wz-prog {
  height: 8px;
  border-radius: 99px;
  background: var(--idle-bg);
  overflow: hidden;
}
.wz-prog > span {
  display: block;
  height: 100%;
  background: var(--primary);
  transition: width 0.2s;
}
.wz-body {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1fr);
}
.wz-ask {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1.4;
  color: #123c8c;
}
.wz-foot {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding: 12px 0 16px;
  background: var(--card);
  box-shadow: 0 -6px 16px rgb(1 29 69 / 0.08);
}
@media (max-width: 767px) {
  .dlg.full-m {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
  }
  .full-m .dlg-body {
    padding: 14px;
  }
  .wz-foot .sp {
    display: none;
  }
  .wz-foot #wz-saved {
    order: -1;
    width: 100%;
  }
  .wz-foot #wz-next {
    flex: 1 1 100%;
    order: 3;
  }
  .wz-foot #wz-back,
  .wz-foot #wz-skip {
    flex: 1;
  }
  .anchor .range2 {
    grid-template-columns: minmax(0, 1fr);
  }
  .wz-ask {
    font-size: 1.1rem;
  }
}

/* ---------- Giỏ hàng khảo sát ---------- */
.bk-total {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 0;
  box-shadow: var(--sh-sm);
  border-radius: 12px;
  background: #f7faff;
}
.bk-total .cu-prog {
  height: 12px;
}
.bk-total p {
  margin: 0;
}
.bk-big {
  font-size: 1.5rem;
}
.bk-card-top {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.bk-card-top img,
.bk-noimg {
  flex: 0 0 84px;
  width: 84px;
  height: 64px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--idle-bg);
  display: grid;
  place-items: center;
  font-size: 1.6rem;
}
.bk-card-t {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.bk-why {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.bk-sv {
  display: grid;
  gap: 14px;
}
.bk-sv-row {
  display: grid;
  gap: 6px;
}
.bk-sv-row .row {
  gap: 8px;
}
.bk-block p {
  margin: 0 0 8px;
}

/* Phiếu khảo sát */
.sv-body {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr);
}
.sv-body textarea {
  font-family: inherit;
  font-size: 1rem;
  word-break: normal;
}
.sv-sec {
  border: 0;
  box-shadow: var(--sh-sm);
  border-radius: 12px;
  background: #fff;
}
.sv-sec[open] {
}
.sv-sec > summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: center;
  min-height: 56px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 1.05rem;
}
.sv-no {
  display: inline-grid;
  place-items: center;
  min-width: 36px;
  height: 36px;
  border-radius: 99px;
  background: #e8f0fe;
  color: #123c8c;
  font-weight: 700;
}
.sv-st {
  margin-left: auto;
}
.sv-in {
  display: grid;
  gap: 14px;
  padding: 4px 14px 16px;
  grid-template-columns: minmax(0, 1fr);
}
.sv-in h4 {
  margin: 6px 0 0;
}
.sv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr));
  gap: 12px;
}
.sv-owner {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: 12px;
  background: #f7faff;
  border: 0;
  box-shadow: var(--sh-sm);
}
.sv-owner h4,
.sv-owner p {
  margin: 0;
}
.sv-gps {
  display: grid;
  gap: 8px;
}
.sv-gps p {
  margin: 0;
}
.sv-media {
  display: grid;
  gap: 10px;
}
.sv-media p {
  margin: 0;
}
.sv-media label.btn {
  cursor: pointer;
}
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
}
.gallery > p {
  grid-column: 1 / -1;
}
.g-item {
  position: relative;
  margin: 0;
  aspect-ratio: 4 / 3;
  border-radius: 10px;
  overflow: hidden;
  background: var(--idle-bg);
}
.g-item img,
.g-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.g-item:has(video) {
  grid-column: span 2;
  aspect-ratio: 16 / 9;
  background: #000;
}
.g-item video {
  object-fit: contain;
}
.g-del {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 99px;
  background: rgb(15 27 51 / 0.7);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
}
.am-g h4 {
  margin: 4px 0;
}
.am-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
}
.am-list li {
  display: flex;
  align-items: center;
  gap: 8px;
}
.am-list .check {
  flex: 1;
}
.pc-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: 16px;
}
.pc-col h4 {
  margin: 0 0 8px;
}
.pc-list {
  margin: 0;
  padding-left: 1.6em;
  display: grid;
  gap: 8px;
}
.pc-sug {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 10px;
}
.pc-sug .pick {
  text-align: left;
  font-size: 0.9rem;
}
@media (max-width: 767px) {
  #dlg-survey .wz-foot .btn {
    flex: 1;
    padding-inline: 10px;
  }
  #dlg-survey .wz-foot #sv-saved {
    order: -1;
    width: 100%;
  }
}
a.btn,
label.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.sv-actions {
  padding-top: 8px;
}
@media (max-width: 767px) {
  .bk-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .sv-actions .btn {
    flex: 1;
  }
}
.msg-step {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 0;
  box-shadow: var(--sh-sm);
  border-radius: 10px;
  background: #fff;
}
.msg-step.on {
  border: 0;
  box-shadow: var(--sh-sm);
}
.msg-step .row {
  justify-content: space-between;
}
.msg-text {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f4f6fa;
  white-space: pre-wrap;
  user-select: text;
}
.sv-owner textarea {
  min-height: 96px;
}
.bk-group {
  grid-column: 1 / -1;
  margin: 10px 0 0;
  font-size: 1rem;
  color: #123c8c;
}
.bk-rank {
  display: inline-block;
  margin-right: 6px;
  padding: 0 8px;
  border-radius: 99px;
  background: #e8f0fe;
  color: #123c8c;
  font-size: 0.85rem;
}
.bk-filter {
  grid-column: 1 / -1;
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: #eef3ff;
  font-size: 1rem;
  font-weight: 400;
}
.bk-note {
  grid-column: 1 / -1;
  margin: 0;
}
/* Hoa hồng đầu khách */
.cm {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 8px;
  background: #fff4d6;
  color: #7a4b00;
  font-weight: 700;
}
.cm-how {
  font-weight: 400;
  font-size: 0.85rem;
}
.cm-t {
  color: #7a4b00;
  font-size: 0.85rem;
}
.bk-cm {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #fff8e6;
  border: 0;
  box-shadow: var(--sh-sm);
}
.bk-cm p {
  margin: 0;
}
.bk-cm .bk-big {
  color: #7a4b00;
}
#sv-cm {
  display: block;
  margin-top: 4px;
}
#sv-cm:empty {
  display: none;
}
/* Mục tiêu khảo sát hết giỏ */
.bk-goal {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #eef6ff;
  border: 0;
  box-shadow: var(--sh-sm);
}
.bk-goal p {
  margin: 0;
}
.bk-goal.behind,
.bk-goal.overdue {
  background: #fff4ec;
}
.bk-goal.done {
  background: var(--ok-bg);
}
.bk-goal-today {
  font-size: 1.05rem;
}
.bk-goal-prev {
  padding: 10px 12px;
  border-radius: 10px;
  background: #eef6ff;
}
.goal-l {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
}
.goal-in {
  width: 6em;
  font-size: 1.1rem;
}
/* Mỗi nhu cầu nắm ít nhất 3 căn trong giỏ */
.cov {
  display: grid;
  gap: 8px;
  margin: 8px 0;
  padding: 12px 14px;
  border-radius: 12px;
}
.cov p {
  margin: 0;
}
.cov.ok {
  background: var(--ok-bg);
}
.cov.warn {
  background: #fff4ec;
  border: 0;
  box-shadow: var(--sh-sm);
}
.cov-list {
  display: grid;
  gap: 6px;
}
.cov-list:empty {
  display: none;
}
.sug {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff;
  border: 0;
  box-shadow: var(--sh-sm);
  cursor: pointer;
}
.sug input {
  width: 22px;
  height: 22px;
  margin-top: 2px;
  flex: none;
}

/* =====================================================================
   Quy tắc giao diện (docs/phan-tich.md A4–A7): token màu đo từ logo, font, bóng thay viền,
   ô nhập nền xám, mục đang chọn nền xanh nhạt + chữ đậm + ✓, điện thoại không zoom / không tràn ngang.
   Khối này đặt cuối file để thắng các quy tắc cũ cùng độ ưu tiên.
   ===================================================================== */
@font-face {
  font-family: 'Inter';
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/inter-vietnamese-400-normal.woff2') format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
@font-face {
  font-family: 'Inter';
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/inter-latin-400-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter';
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/inter-vietnamese-500-normal.woff2') format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
@font-face {
  font-family: 'Inter';
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/inter-latin-500-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter';
  font-weight: 600 700;
  font-display: swap;
  src: url('/fonts/inter-vietnamese-600-normal.woff2') format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
@font-face {
  font-family: 'Inter';
  font-weight: 600 700;
  font-display: swap;
  src: url('/fonts/inter-latin-600-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Be Vietnam Pro';
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/be-vietnam-pro-vietnamese-700-normal.woff2') format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
@font-face {
  font-family: 'Be Vietnam Pro';
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/be-vietnam-pro-latin-700-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Be Vietnam Pro';
  font-weight: 800;
  font-display: swap;
  src: url('/fonts/be-vietnam-pro-vietnamese-800-normal.woff2') format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
@font-face {
  font-family: 'Be Vietnam Pro';
  font-weight: 800;
  font-display: swap;
  src: url('/fonts/be-vietnam-pro-latin-800-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* A4: màu đo từ logo */
  --navy-950: #011d45;
  --navy-900: #002551;
  --navy-100: #e6ebf2;
  --navy-50: #f3f6fa;
  --blue-700: #0166a3;
  --blue-600: #017bc4;
  --blue-500: #2b92d1;
  --blue-100: #e1f0fa;
  --blue-50: #f0f8fd;
  --accent: #c2410c;
  --accent-50: #fff1e8;
  --gray-900: #1f2a37;
  --gray-600: #6e7275;
  --gray-400: #9ea1a4;
  --gray-200: #e3e5e7;
  --gray-100: #f1f3f5;
  --gray-50: #f6f7f8;
  --success: #16a34a;
  --warning: #d97706;
  --error: #dc2626;
  --sh-sm: 0 1px 3px rgb(1 29 69 / 0.08);
  --sh-md: 0 6px 16px rgb(1 29 69 / 0.1);
  --sh-lg: 0 16px 40px rgb(1 29 69 / 0.16);
  --ring: 0 0 0 3px rgb(1 123 196 / 0.25);
  --font-head: 'Be Vietnam Pro', 'Inter', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  /* Tên biến cũ trỏ sang token mới */
  --bg: var(--gray-50);
  --card: #fff;
  --text: var(--gray-900);
  --muted: var(--gray-600);
  --line: var(--gray-200);
  --primary: var(--blue-600);
  --primary-ink: #fff;
  --ok: #15803d;
  --ok-bg: #e8f6ee;
  --warn: var(--error);
  --warn-bg: #fef2f2;
  --idle-bg: var(--gray-100);
}
body {
  font-family: var(--font-body);
  font-variant-numeric: tabular-nums;
  overflow-x: hidden;
}
h1,
h2,
h3,
h4 {
  font-family: var(--font-head);
  color: var(--navy-950);
  font-weight: 700;
}
.price,
.bk-big {
  font-family: var(--font-head);
  font-weight: 700;
  color: var(--accent);
}
/* Số căn, tiến độ: chữ đậm xanh đậm (màu cam chỉ dành cho giá, tiền) */
.bk-total-t .bk-big,
.bk-goal .bk-big,
.bk-goal-prev .bk-big {
  color: var(--navy-950);
}
a {
  color: var(--blue-700);
}

/* Thẻ, khối nội dung: nền trắng + bóng, bo 12 */
.card {
  border-radius: 12px;
  box-shadow: var(--sh-sm);
}

/* Nút: bo 8, nút chính xanh, nút phụ trắng + bóng */
.btn {
  border-radius: 8px;
  font-weight: 600;
}
.btn.primary {
  background: var(--blue-600);
  color: #fff;
  box-shadow: none;
}
.btn.primary:hover {
  background: var(--blue-500);
}
.btn.primary:active {
  background: var(--blue-700);
}
.btn.danger {
  background: var(--error);
  color: #fff;
  box-shadow: none;
}
.btn.ghost {
  box-shadow: none;
  color: var(--blue-700);
}
.btn:hover {
  box-shadow: var(--sh-md);
}
.btn.ghost:hover {
  background: var(--blue-50);
  box-shadow: none;
}

/* Ô nhập: nền xám, không viền; focus nền trắng + vòng xanh; lỗi nền đỏ nhạt + vòng đỏ */
input,
textarea,
select {
  border: 0;
  border-radius: 8px;
  background: var(--gray-100);
  color: var(--text);
}
input[type='checkbox'],
input[type='radio'] {
  width: auto;
  accent-color: var(--blue-600);
}
input:focus,
textarea:focus,
select:focus {
  outline: none;
  background: #fff;
  box-shadow: var(--ring);
}
.btn:focus-visible,
.pick:focus-visible,
.opt:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
input[aria-invalid='true'],
textarea[aria-invalid='true'] {
  background: #fef2f2;
  box-shadow: 0 0 0 3px rgb(220 38 38 / 0.25);
}
textarea {
  font-family: var(--font-body);
  font-size: 1rem;
  word-break: normal;
  overflow-wrap: anywhere;
}

/* Lựa chọn: nền trắng + bóng; đang chọn: nền xanh nhạt + chữ đậm + ✓ (không đổi màu viền) */
.pick.on,
.opt.on,
.mode-b.on,
.kpi-b.on,
.msg-step.on,
.seg-b.on,
.seg-v.on {
  background: var(--blue-100);
  color: var(--blue-700);
  font-weight: 700;
  box-shadow: none;
}
.pick.on::before,
.opt.on::before {
  content: '✓ ';
}
.pg.on {
  background: var(--blue-600);
  color: #fff;
}

/* Tag trạng thái: nền nhạt + chữ đậm cùng tông */
.tag {
  background: var(--gray-100);
  color: var(--gray-900);
}
.tag.ok {
  background: #e8f6ee;
  color: #15803d;
}
.tag.warn {
  background: #fef3e2;
  color: #b45309;
}
.tag.bad {
  background: #fef2f2;
  color: var(--error);
}

/* Bảng: không kẻ ô, header nền xám nhạt, hàng tách bằng khoảng đệm */
.table-wrap {
  box-shadow: var(--sh-sm);
  border-radius: 12px;
  background: #fff;
}
.tbl th {
  background: #f7f8fa;
}
.tbl tbody tr:nth-child(even) td {
  background: #fbfcfd;
}

/* Khối nhấn không dùng vạch màu bên trái */
.script {
  background: var(--blue-50);
  border-radius: 12px;
  padding: 8px 14px;
}

/* Thanh trên: navy */
.top {
  background: var(--navy-950);
}
.toast {
  background: var(--navy-950);
  box-shadow: var(--sh-lg);
}
.dlg {
  box-shadow: var(--sh-lg);
}
.dlg::backdrop {
  background: rgb(1 29 69 / 0.55);
}

/* Khối thông tin trong giỏ / tìm nhà: bóng thay viền */
.bk-cm,
.bk-goal,
.cov,
.sug,
.sv-owner,
.bk-total {
  border: 0;
  box-shadow: var(--sh-sm);
}
.bk-cm {
  background: var(--accent-50);
}
.bk-goal {
  background: var(--blue-50);
}
.bk-goal.behind,
.bk-goal.overdue,
.cov.warn {
  background: #fef6ec;
}
.cm {
  background: var(--accent-50);
  color: var(--accent);
}
.cm-t,
.bk-cm .bk-big {
  color: var(--accent);
}

/* A7: điện thoại – ô nhập >= 16px (iOS không tự zoom), vùng chạm >= 44px, không tràn ngang, 100dvh + safe-area */
html,
body {
  max-width: 100%;
}
.login {
  min-height: 100dvh;
}
.dlg {
  max-height: calc(100dvh - 32px);
}
.sticky-foot,
.wz-foot,
.dlg-foot {
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}
.row,
.wrap-row {
  min-width: 0;
}
.row > *,
.wrap > * {
  min-width: 0;
}
.pick,
.opt,
.btn,
.seg-b,
.mode-b,
summary {
  min-height: 44px;
}
@media (max-width: 1023px) {
  input,
  textarea,
  select {
    font-size: 16px !important;
  }
}

/* PWA: thanh mất mạng, chạy như app (không thanh địa chỉ) */
.net-bar {
  position: sticky;
  top: 0;
  z-index: 60;
  margin: 0;
  padding: 8px 16px;
  padding-top: calc(8px + env(safe-area-inset-top));
  background: var(--warning);
  color: #fff;
  font-weight: 600;
  text-align: center;
}
@media (display-mode: standalone) {
  .top {
    padding-top: calc(12px + env(safe-area-inset-top));
  }
}

/* Trang phân tích: mỗi phần một tab */
.ana-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 12px;
}
.ana-tabs a.pick {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}
.ana-tabs a.pick.on {
  background: var(--navy-950, #123c8c);
  color: #fff;
}

/* Giá đất từng căn (danh sách ưu tiên khảo sát) */
.sv-view,
.sv-cost {
  align-items: center;
  gap: 8px;
  margin: 10px 0 4px;
}
.sv-lands {
  list-style: none;
  margin: 8px 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.sv-land {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--sh-sm);
}
.sv-rank {
  min-width: 28px;
  height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #e8f0fe;
  color: #123c8c;
  font-weight: 700;
}
.sv-land-main {
  font: inherit;
  text-align: left;
  border: 0;
  background: none;
  padding: 0;
  color: inherit;
  cursor: pointer;
  display: grid;
  gap: 2px;
  min-width: 0;
}
.sv-land-v {
  display: grid;
  justify-items: end;
  line-height: 1.2;
}
.sv-land-v b {
  font-size: 1.3rem;
  color: var(--navy-950);
}
.pick-cell {
  display: grid;
  gap: 6px;
  justify-items: start;
}
.pick-cell > .btn,
.pick-cell > .tag {
  white-space: nowrap;
}
.cmp-l {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  cursor: pointer;
}
.linkish {
  font: inherit;
  border: 0;
  background: none;
  padding: 0;
  color: #123c8c;
  text-decoration: underline;
  cursor: pointer;
}
@media (max-width: 560px) {
  .sv-land {
    grid-template-columns: auto 1fr auto;
  }
  .sv-land > :last-child {
    grid-column: 2 / -1;
    justify-self: start;
  }
}

/* Danh sách nguồn hàng chi tiết: số thứ tự, dòng đang mở chi tiết, dải ảnh nhỏ trong dòng */
.tbl td.stt {
  color: var(--muted);
  font-weight: 600;
  min-width: 2.5em;
}
.tbl tbody tr.is-open td {
  background: var(--blue-100);
}
.tbl tbody tr.is-open td.stt {
  color: var(--blue-700);
  font-weight: 800;
}
.tbl tbody tr.is-open td:first-child {
  box-shadow: inset 4px 0 0 var(--blue-600);
}
.row-thumbs {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
.row-thumbs .rt {
  position: relative;
  width: 64px;
  height: 48px;
  border-radius: 8px;
  background: var(--gray-100);
}
.row-thumbs .rt img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.row-thumbs .rt:hover img {
  opacity: 0.85;
}
.rt-more {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgb(1 29 69 / 0.55);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
}
@media (max-width: 560px) {
  .row-thumbs .rt {
    width: 52px;
    height: 40px;
  }
}

/* Số căn / tiến độ trên nút tab Giỏ khảo sát */
.mode-n {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--gray-100);
  color: var(--gray-900);
  font-size: 0.85em;
  font-weight: 700;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.mode-n[hidden] {
  display: none;
}
.mode-b.on .mode-n {
  background: #fff;
  color: var(--blue-700);
}
.mode-n.all-done {
  background: var(--ok-bg);
  color: var(--ok);
}

/* Nút giỏ khảo sát ở đầu hộp chi tiết; nút ngoài danh sách bọc trong .bk-cell để tự đồng bộ */
#detail-body > .bk-block:first-child {
  margin: 0 0 14px;
  padding: 12px 14px;
  background: var(--blue-50);
  border-radius: 12px;
}
#detail-body > .bk-block:first-child h3 {
  margin: 0;
}
.bk-cell > .btn,
.bk-cell > .tag {
  white-space: nowrap;
}
.bk-cell {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.bk-cell .bk-rm {
  min-height: 36px;
  padding: 4px 10px;
  font-size: 0.85rem;
}
