/* NEW-144: Hộp lead (views/leadhub.js, leadhub_lead.js, leadhub_admin.js — #/leadhub…). Tiền tố lh-. Chỉ dùng biến màu của app.css (sáng / tối),
   dựa trên card / btn / badge / msg / chip / path / timeline sẵn có. Trang bọc trong .lh-page (con đầu của #view không phải .page-head ⇒ control panel
   NEW-71 không sắp lại bộ lọc riêng của màn này). Bảng danh sách (.lh-table) thành thẻ ở ≤ 760 px; bảng báo cáo cuộn ngang trong khung, cột tên dính. */
.lh-lead { margin: -6px 0 14px; max-width: 900px; }
.lh-s { font-size: 13px; }
.lh-h2 { font-size: 16px; margin: 0 0 10px; }
.lh-sub { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.lh-mono { font-variant-numeric: tabular-nums; letter-spacing: .01em; white-space: nowrap; }
.lh-em { display: block; overflow-wrap: anywhere; }
.lh-wrap { overflow-wrap: anywhere; word-break: break-word; }
.lh-pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.lh-denied { max-width: 640px; }
.lh-links { margin: 12px 0 0; }
.lh-warn-t { color: var(--warn); font-weight: 600; }
.lh-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.lh-page code { font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 3px; padding: 0 4px; }

/* ---- Tab trạng thái (như .tabs của app.css, dạng nút) ---- */
.lh-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 0 0 12px; overflow-x: auto; scrollbar-width: thin; }
.lh-tab { flex: 0 0 auto; display: inline-flex; align-items: center; padding: 9px 14px; min-height: 40px; border: 0; border-bottom: 2px solid transparent; background: none;
  color: var(--muted); cursor: pointer; white-space: nowrap; font-weight: 500; }
.lh-tab:hover { color: var(--ink); background: var(--hover); }
.lh-tab.active { color: var(--brand-dark); border-bottom-color: var(--brand); font-weight: 600; }

/* ---- Bộ lọc ---- */
.lh-fbox { margin: 0 0 12px; }
.lh-fsum { display: none; }
.lh-fn { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: var(--brand); color: var(--on-brand); font-size: 12px; line-height: 20px; text-align: center; }
.lh-filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 12px; align-items: end; }
.lh-f-q { grid-column: span 2; }
.lh-f { display: flex; flex-direction: column; gap: 4px; min-width: 0; font-size: 13px; color: var(--muted); }
.lh-f input, .lh-f select { width: 100%; min-width: 0; color: var(--ink); }
.lh-f-x .btn { white-space: nowrap; }

/* ---- Bảng hàng chờ / lead của tôi / nguồn / thành viên ---- */
.lh-list { position: relative; }
.lh-v { min-width: 0; }
.lh-list.lh-busy { opacity: .6; pointer-events: none; }
.lh-tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); background: var(--surface); }
.lh-table td { font-size: 14px; }
.lh-table tr[data-id] { cursor: pointer; }
.lh-table tr.sel td { background: var(--brand-soft); }
.lh-table .lh-c-chk { width: 44px; padding: 4px 6px; vertical-align: middle; }
.lh-chk { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; cursor: pointer; border-radius: var(--radius-btn); }
.lh-chk:hover { background: var(--hover); }
.lh-chk input { width: 18px; height: 18px; margin: 0; accent-color: var(--brand); cursor: pointer; }
.lh-c-t { white-space: nowrap; font-variant-numeric: tabular-nums; }
.lh-c-name a { color: var(--ink); text-decoration: none; }
.lh-c-name a:hover { color: var(--brand-dark); text-decoration: underline; }
.lh-c-name { min-width: 160px; max-width: 260px; overflow-wrap: anywhere; }
.lh-c-ct { min-width: 140px; }
.lh-c-src, .lh-c-camp { min-width: 130px; max-width: 240px; overflow-wrap: anywhere; }
.lh-c-flag { min-width: 120px; }
.lh-c-st .badge { white-space: nowrap; }
.lh-c-err { max-width: 280px; }
.lh-errtxt { color: var(--err); font-size: 13px; overflow-wrap: anywhere; }
.lh-c-acts { width: 1%; }
.lh-rowacts { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: nowrap; }
.lh-rowacts .btn { white-space: nowrap; }
.lh-empty { margin-top: 4px; }
.lh-empty b { color: var(--ink); }
.lh-page .pager { margin-top: 10px; }

/* Cờ dạng nhãn nhỏ trong bảng */
.lh-flag { display: inline-block; margin: 0 4px 4px 0; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 18px; white-space: nowrap; }
.lh-flag.warn { background: var(--warn-soft); color: var(--warn); }
.lh-flag.info { background: var(--brand-soft); color: var(--brand-dark); }

/* Thanh thao tác hàng loạt: dính đáy vùng nội dung */
.lh-bulk { position: sticky; bottom: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 12px; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--brand); border-radius: var(--radius); box-shadow: var(--shadow-pop); }
.lh-bulk[hidden] { display: none; }
.lh-bulk-n { font-size: 14px; }
.lh-bulk-a { display: flex; flex-wrap: wrap; gap: 8px; }
.lh-bulk-x { margin-left: 4px; }
.lh-prev { margin: 0 0 12px; padding-left: 18px; font-size: 13px; }
.lh-prev li { margin: 3px 0; overflow-wrap: anywhere; }

/* ---- Trang lead ---- */
.lh-crumbbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 6px; flex-wrap: wrap; }
.lh-crumb { margin: 0; flex-wrap: wrap; }
.lh-nav { display: inline-flex; align-items: center; gap: 6px; }
.lh-nav .btn[aria-disabled="true"] { opacity: .4; pointer-events: none; }
.lh-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; margin: 0 0 10px; }
.lh-head-t { min-width: 0; flex: 1 1 260px; }
.lh-head h1 { font-size: 22px; line-height: 1.3; margin: 0 0 2px; overflow-wrap: anywhere; }
.lh-head-t p { margin: 0; }
.lh-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.lh-acts .btn { display: inline-flex; align-items: center; gap: 8px; }
.lh-kbd { display: inline-block; min-width: 18px; padding: 0 4px; border: 1px solid currentColor; border-radius: 3px; font: 600 11px/16px var(--font); text-align: center; opacity: .75; }
.lh-path { margin: 6px 0 6px; }
.lh-path .path-step.lh-off { opacity: .45; }
.lh-st-hint { margin: 0 0 4px; color: var(--muted); }
.lh-keys { margin: 0 0 12px; }
.lh-keys kbd, .lh-page kbd { display: inline-block; min-width: 18px; padding: 0 5px; border: 1px solid var(--btn-border); border-bottom-width: 2px; border-radius: 3px; background: var(--surface);
  font: 600 11.5px/17px var(--font); color: var(--ink); text-align: center; }
.lh-outcome { margin: 0 0 12px; }
.lh-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 12px; align-items: start; }
.lh-col-main, .lh-col-side { display: grid; gap: 12px; min-width: 0; }
.lh-sec { padding: 16px; min-width: 0; }
.lh-kv { display: grid; grid-template-columns: minmax(110px, max-content) minmax(0, 1fr); gap: 8px 16px; margin: 0; }
.lh-kv dt { color: var(--muted); font-size: 13px; padding-top: 1px; }
.lh-kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.lh-ans dt { color: var(--ink); font-weight: 600; font-size: 13.5px; }
.lh-noflags { display: flex; gap: 8px; align-items: flex-start; margin: 0; color: var(--ok-text); }
.lh-noflags .ic { flex: none; margin-top: 2px; }
.lh-flags { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.lh-fl { display: flex; gap: 10px; padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--line-2); }
.lh-fl.warn { background: var(--warn-soft); }
.lh-fl.info { background: var(--brand-soft); }
.lh-fl-ic { flex: none; display: inline-flex; padding-top: 2px; }
.lh-fl.warn .lh-fl-ic { color: var(--warn); }
.lh-fl.info .lh-fl-ic { color: var(--brand-dark); }
.lh-fl-b { min-width: 0; }
.lh-fl-b b { color: var(--ink); }
.lh-fl-b p { margin: 2px 0 0; color: var(--ink); }
.lh-refs { margin: 6px 0 0; padding-left: 18px; font-size: 13px; }
.lh-refs li { margin: 4px 0; overflow-wrap: anywhere; }
.lh-refs .btn { margin-left: 4px; }
.lh-tl { margin: 4px 0 0 8px; padding: 0; list-style: none; }
.lh-tl .timeline-head .badge { font-size: 11.5px; }

/* Hộp thoại */
.lh-reasons { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px 10px; margin: 0 0 12px; }
.lh-reasons legend { font-size: 13px; color: var(--muted); padding: 0 4px; }
.lh-radio { display: flex; align-items: flex-start; gap: 8px; padding: 6px 0; cursor: pointer; overflow-wrap: anywhere; }
.lh-radio input { margin: 3px 0 0; accent-color: var(--brand); flex: none; }
.lh-person { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 8px; }
.lh-conseq { font-size: 13px; }
.lh-dupbox .lh-radio > span { min-width: 0; }
.lh-dupbox .badge { margin-left: 4px; }
.lh-force { margin-bottom: 4px; }
.lh-force-hint { margin: 0 0 12px; }
.lh-skip { margin: 0; padding-left: 18px; font-size: 14px; }
.lh-skip li { margin: 6px 0; overflow-wrap: anywhere; }
.lh-conseq div { margin-top: 3px; }
.lh-chk-l { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; cursor: pointer; }
.lh-chk-l input { width: 18px; height: 18px; accent-color: var(--brand); }
.lh-secret { display: flex; gap: 8px; }
.lh-secret input { flex: 1; min-width: 0; font-variant-numeric: tabular-nums; letter-spacing: .02em; }

/* ---- Báo cáo ---- */
.lh-rbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px; margin: 0 0 14px; }
.lh-seg { display: inline-flex; flex-wrap: wrap; gap: 0; }
.lh-seg .btn { border-radius: 0; margin-left: -1px; }
.lh-seg .btn:first-child { border-radius: var(--radius-btn) 0 0 var(--radius-btn); margin-left: 0; }
.lh-seg .btn:last-child { border-radius: 0 var(--radius-btn) var(--radius-btn) 0; }
.lh-quick { display: flex; flex-wrap: wrap; gap: 6px; }
.lh-rbar .lh-f-d { width: 160px; }
.lh-rtable th, .lh-rtable td { white-space: nowrap; }
.lh-rtable td.num, .lh-rtable th.num { text-align: right; font-variant-numeric: tabular-nums; }
.lh-rtable .lh-sticky { position: sticky; left: 0; z-index: 2; background: var(--surface); max-width: 320px; white-space: normal; overflow-wrap: anywhere; box-shadow: 1px 0 0 var(--line); }
.lh-rtable th.lh-sticky { background: var(--surface-2); z-index: 3; }
.lh-rtable tbody tr:hover td.lh-sticky { background: var(--hover); }
.lh-rtable .lh-zero { color: var(--muted); }
.lh-rtable tfoot td { font-weight: 700; border-top: 2px solid var(--line); background: var(--surface-2); }
.lh-rtable tfoot td.lh-sticky { background: var(--surface-2); }
.lh-note { margin: 8px 0 0; }

/* Nguồn / thành viên */
.lh-howto, .lh-roles { margin-top: 16px; max-width: 900px; }
.lh-role { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; }
.lh-role select { min-width: 170px; }

/* ---- Màn vừa ---- */
@media (max-width: 1100px) {
  .lh-grid { grid-template-columns: minmax(0, 1fr); }
  .lh-col-side { order: -1; }   /* cờ + lịch sử lên trước: cờ là thứ cần xem trước khi duyệt */
}

/* ---- Điện thoại: bảng thành thẻ ---- */
@media (max-width: 760px) {
  .lh-page input[type=text], .lh-page input[type=search], .lh-page input[type=date], .lh-page input[type=number], .lh-page select, .lh-page textarea,
  .modal input[type=text], .modal input[type=search], .modal input[type=number], .modal select, .modal textarea { font-size: 16px; }   /* iOS không tự phóng to khi gõ */
  .lh-fsum { display: flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 12px; border: 1px solid var(--btn-border); border-radius: var(--radius-btn);
    background: var(--surface); cursor: pointer; font-weight: 600; list-style: none; }
  .lh-fsum::-webkit-details-marker { display: none; }
  .lh-fsum::after { content: ""; margin-left: auto; width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-2px); }
  .lh-fbox[open] .lh-fsum { margin-bottom: 10px; }
  .lh-fbox[open] .lh-fsum::after { transform: rotate(-135deg) translateY(-2px); }
  .lh-filters { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .lh-f-q { grid-column: 1 / -1; }
  .lh-f-x { grid-column: 1 / -1; }

  .lh-tablewrap:not(.lh-rwrap) { border: 0; box-shadow: none; background: none; overflow: visible; }
  .lh-table, .lh-table tbody { display: block; }
  .lh-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .lh-table thead .lh-chk { display: none; }
  .lh-table tr { display: grid; grid-template-columns: minmax(0, 1fr); position: relative; margin: 0 0 10px; padding: 10px 12px; background: var(--surface);
    border: 1px solid var(--line); border-radius: var(--radius); }
  .lh-table tr.sel { border-color: var(--brand); }
  table.data.lh-table tr.sel td, table.data.lh-table tbody tr:hover td { background: none; }
  table.data.lh-table td { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 8px; padding: 4px 0; border: 0; white-space: normal; max-width: none; min-width: 0; }
  table.data.lh-table td[data-l]::before { content: attr(data-l); color: var(--muted); font-size: 12.5px; padding-top: 1px; }
  table.data.lh-table td.lh-c-name { grid-template-columns: minmax(0, 1fr); padding-right: 44px; font-size: 15px; }
  table.data.lh-table td.lh-c-name::before { display: none; }
  table.data.lh-table .lh-c-chk { position: absolute; top: 4px; right: 4px; width: auto; padding: 0; display: block; }
  .lh-table .lh-chk { width: 44px; height: 44px; }
  table.data.lh-table td.lh-c-acts { grid-template-columns: minmax(0, 1fr); width: auto; padding-top: 8px; }
  .lh-table .lh-rowacts { justify-content: flex-start; flex-wrap: wrap; }
  .lh-table .lh-noflag { display: none; }
  table.data.lh-table td.lh-c-flag:has(.lh-noflag) { display: none; }
  table.data.lh-mem td { grid-template-columns: 70px minmax(0, 1fr); }
  .lh-role { flex-wrap: wrap; }
  .lh-role select { min-width: 0; flex: 1 1 160px; }

  .lh-bulk { bottom: 8px; padding: 8px 10px; }
  .lh-bulk-a { width: 100%; }
  .lh-bulk-a .btn { flex: 1 1 auto; }
  .lh-head h1 { font-size: 20px; }
  .lh-acts { width: 100%; }
  .lh-acts .btn { flex: 1 1 auto; justify-content: center; }
  .lh-acts .lh-kbd, .lh-page .lh-keys { display: none; }   /* điện thoại không có bàn phím vật lý */
  .lh-kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .lh-kv dd { margin-bottom: 8px; }
  .lh-person { grid-template-columns: minmax(0, 1fr); }
  .lh-rbar .lh-f-d { width: calc(50% - 7px); }
  .lh-seg { width: 100%; }
  .lh-seg .btn { flex: 1 1 0; }
  .lh-rtable .lh-sticky { max-width: 150px; }
}
@media (max-width: 400px) {
  table.data.lh-table td { grid-template-columns: 82px minmax(0, 1fr); }
  .lh-filters { grid-template-columns: minmax(0, 1fr); }
}
@media (pointer: coarse) {
  .lh-page .btn, .modal .btn, .lh-tab, .lh-page .chip { min-height: 44px; }
  .lh-page .btn.small { min-height: 40px; }
  .lh-radio { padding: 10px 0; }
}
