/* Xem nhanh (CRM-53, 12/11/2026) — khung dùng chung của js/core/peek.js; nội dung theo trang (Clients: js/pages/client-peek.js).
   ≥ 768 px: trượt từ phải, rộng ~56% màn (420–880 px), nền mờ nhẹ — danh sách vẫn đọc được phía sau. < 768 px: tấm trượt từ dưới
   lên rộng hết màn, cao 92% (không cuộn ngang). Phẳng như phần còn lại (không gradient / blur / glow); chỉ transform / opacity
   200 ms ease-out; prefers-reduced-motion tắt mọi chuyển động (theme.css). Chỉ dùng biến màu của theme.css (sáng + tối). */
.qv-scrim { position: fixed; inset: 0; z-index: 44; background: var(--scrim); opacity: 0; transition: opacity .2s ease-out; }
.qv-scrim.on { opacity: 1; }
.qv-drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 45; width: clamp(420px, 56vw, 880px); max-width: 100vw;
  display: flex; flex-direction: column; background: var(--card); color: var(--ink); border-left: 1px solid var(--border);
  box-shadow: -6px 0 24px var(--shadow); transform: translateX(100%); transition: transform .2s ease-out; outline: none; }
.qv-drawer.on { transform: none; }
.qv-drawer[hidden], .qv-scrim[hidden] { display: none; }
html.qv-lock, html.qv-lock body { overflow: hidden; }   /* màn hẹp cuộn cả trang ⇒ khoá trang phía sau khi bảng mở */

.qv-drawer .ic { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.qv-head { flex: none; display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--line-2); }
.qv-nav { display: flex; align-items: center; gap: 4px; margin-right: auto; min-width: 0; }
.qv-icon { width: 32px; min-width: 32px; padding: 0; }
.qv-pos { margin-left: 6px; font-size: 13px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qv-full, .qv-copylink { gap: 6px; }
.qv-head .btn[hidden] { display: none; }   /* .btn đặt display ⇒ [hidden] cần luật riêng (Mở đầy đủ ẩn với người chỉ xem) */
.qv-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 18px 20px 24px; }
.qv-foot { flex: none; display: flex; align-items: center; gap: 8px; padding: 8px 16px; border-top: 1px solid var(--line-2); font-size: 12px; color: var(--text-muted); }
.qv-foot kbd { font: inherit; font-size: 11px; padding: 0 5px; border: 1px solid var(--border); border-radius: 3px; background: var(--surface-subtle); color: var(--ink); }
.qv-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* đầu nội dung: mã · id, tên, nhãn */
.qv-top { margin-bottom: 12px; }
.qv-ref { font-size: 13px; font-weight: 600; color: var(--text-muted); overflow-wrap: anywhere; }
.qv-title { margin: 2px 0 8px; font-size: 20px; line-height: 1.35; font-weight: 700; color: var(--ink); overflow-wrap: anywhere; }
.qv-rib { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.qv-acts { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.qv-acts .qv-danger { margin-left: auto; }   /* nút phá huỷ dồn cuối hàng, không tranh chú ý */
.qv-tabs { margin: 4px 0 12px; overflow-x: auto; scrollbar-width: none; }
.qv-tabs .subtab { white-space: nowrap; }
.qv-loading, .qv-none-p { margin: 6px 0; color: var(--text-muted); }
.qv-none { color: var(--text-muted); }
.qv-note { margin: 0 0 8px; font-size: 13px; color: var(--text-muted); }

/* khu (section): nền nhạt bo góc như thẻ, tiêu đề + nút Sửa */
.qv-sec { margin: 0 0 12px; padding: 12px 16px 14px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface-subtle); }
.qv-sec[hidden] { display: none; }
.qv-sec-editing { background: var(--card); border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.qv-sec-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 32px; margin: 0 0 8px; }
.qv-h { margin: 0; font-size: 15px; line-height: 22px; font-weight: 600; color: var(--ink); }
.qv-edit { gap: 6px; }
.qv-tag { font-size: 12px; font-weight: 600; color: var(--brand-ink); }
:root[data-theme="dark"] .qv-tag { color: var(--brand); }
.qv-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px 20px; margin: 0; }
.qv-f { min-width: 0; }
.qv-f.wide { grid-column: 1 / -1; }
.qv-f dt { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.qv-f dd { margin: 2px 0 0; min-width: 0; overflow-wrap: anywhere; white-space: pre-line; font-size: 14px; line-height: 1.5; color: var(--ink); }
.qv-f dd a { color: var(--brand-ink); }
:root[data-theme="dark"] .qv-f dd a { color: var(--brand); }
/* "Theo nền tảng" trong khu: không lồng thẻ trong thẻ — mỗi nền tảng là một cột, ngăn bằng đường kẻ mảnh */
.qv-sec .platform-summary-card { background: transparent; border: 0; border-top: 1px solid var(--line-2); border-radius: 0; padding: 8px 0 0; }

/* sửa tại chỗ: cùng lưới tự chia cột; thanh Lưu / Hủy cuối khu */
.qv-form .qv-fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0 16px; }
.qv-form .field { min-width: 0; margin-bottom: 12px; }
.qv-form .field[hidden] { display: none; }
.qv-form .field.wide { grid-column: 1 / -1; }
.qv-form .field.qv-pick { position: relative; }
.qv-form .qv-star { color: var(--danger); }
.qv-form .field input[aria-invalid="true"], .qv-form .field select[aria-invalid="true"] { border-color: var(--danger); }
.qv-hint { margin-top: 4px; font-size: 12px; color: var(--text-muted); }
.qv-ferr { font-size: 12px; color: var(--danger); }
.qv-ferr:empty { display: none; }
.qv-formerr:empty { display: none; }
/* thanh Lưu / Hủy dính đáy vùng cuộn (khu dài trên điện thoại vẫn thấy nút); bottom = −lề dưới của .qv-body */
.qv-ebar { position: sticky; bottom: -24px; z-index: 1; display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 8px 0 12px; background: var(--card); }
.qv-form[aria-busy="true"] [data-qv-save] { cursor: progress; }

/* không mở được bản ghi (link sâu tới bản ghi lạ / đã xoá / không có quyền / không có trên trang — CRM-56) */
.qv-missing { padding: 4px 0; }
.qv-missing p { max-width: 62ch; margin: 0 0 16px; font-size: 14px; line-height: 1.6; color: var(--text); }

/* tab Contacts — xem + sửa tại chỗ (CRM-56): mỗi Contact một dòng, nút Sửa / Deactive bên phải; đang sửa = khung viền nhấn như khu */
.qv-contacts { list-style: none; margin: 0 0 12px; padding: 0; }
.qv-contacts li { padding: 10px 0; border-bottom: 1px solid var(--line-2); min-width: 0; overflow-wrap: anywhere; }
.qv-contacts li:last-child { border-bottom: 0; }
.qv-contacts li.qv-inactive { color: var(--text-muted); }
.qv-ct-name { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.qv-ct-title { font-size: 13px; color: var(--text-muted); }
.qv-ct-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 2px; font-size: 13px; color: var(--text-muted); }
.qv-ct-meta .copy-text { color: var(--ink); }
.qv-contacts li { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px 12px; }
.qv-contacts li.qv-ct-editing { display: block; }
.qv-ct-main { flex: 1 1 240px; min-width: 0; }
.qv-ct-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.qv-ct-tools { display: flex; justify-content: flex-end; margin: 0 0 4px; }
.qv-ct-form { padding: 12px 14px 0; border: 1px solid var(--brand); border-radius: 8px; box-shadow: 0 0 0 1px var(--brand); background: var(--card); }
.qv-ct-new { margin: 8px 0 12px; }
.qv-ct-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 10px; }

/* ô chọn có tìm kiếm trong khu sửa (Account: Client, Hồ sơ doanh nghiệp — CRM-54): chip đang chọn + ô tìm + danh sách nổi */
.qv-form .qv-star[hidden] { display: none; }
.qv-pick-sel { margin: 2px 0 6px; min-height: 24px; }
.qv-pick-sel .selected-client-chip { max-width: 100%; overflow-wrap: anywhere; }
.qv-pick-box { position: relative; }
.qv-pick-list[hidden] { display: none; }
.qv-pick-list .pick-item { display: block; width: 100%; margin: 0; text-align: left; font: inherit; font-size: 13px; color: var(--ink);
  background: var(--card); border: 0; border-bottom: 1px solid var(--border); }
.qv-pick-list .pick-item:last-child { border-bottom: 0; }
.qv-pick-list button.pick-item:hover, .qv-pick-list button.pick-item:focus-visible { background: var(--surface-selected); outline: none; }
.qv-pick-list .pick-item .sub { display: block; }
.qv-pick-list p.pick-item { cursor: default; color: var(--text-muted); }

/* CRM-55 — kiểu trường dùng chung: chọn nhiều (chip), ô tick, ảnh chỉ xem */
.qv-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 6px; min-height: 24px; align-items: center; }
.qv-chip { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; min-height: 26px; padding: 2px 4px 2px 10px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface-selected); color: var(--ink); font-size: 13px;
  line-height: 1.4; overflow-wrap: anywhere; }
.qv-chip-fixed { padding-right: 10px; background: var(--surface-neutral); }
.qv-chip-note { color: var(--text-muted); }
.qv-chip-note::before { content: "· "; }
.qv-chip button { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; padding: 0; border: 0;
  border-radius: 50%; background: transparent; color: var(--text-muted); font: inherit; font-size: 16px; line-height: 1; cursor: pointer; }
.qv-chip button:hover, .qv-chip button:focus-visible { background: var(--surface-hover); color: var(--ink); outline: 2px solid var(--accent); outline-offset: -2px; }
dd .qv-chips { margin: 2px 0 0; }
.qv-flabel { display: block; margin-bottom: 4px; font-size: 13px; font-weight: 500; color: var(--text); }
/* label.qv-check: thắng ".field label:not(.checkbox-inline)" (display:block, chữ mờ) của base.css — trước CRM-56 ô tick dính chữ */
.qv-form .field label.qv-check { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; margin: 0; font-size: 14px;
  color: var(--ink); cursor: pointer; }
.qv-form .qv-check input { width: 18px; height: 18px; min-height: 0; margin: 0; accent-color: var(--brand); }
.qv-imgs { display: flex; flex-wrap: wrap; gap: 10px; margin: 4px 0 2px; }
.qv-img { display: inline-flex; flex-direction: column; align-items: stretch; gap: 4px; width: 168px; max-width: 100%; padding: 6px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--brand-ink); font: inherit; font-size: 13px;
  font-weight: 500; cursor: zoom-in; }
:root[data-theme="dark"] .qv-img { color: var(--brand); }
.qv-img:hover { border-color: var(--brand); }
.qv-img:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.qv-img-box { display: block; height: 108px; border-radius: 4px; background: var(--surface-neutral); overflow: hidden; }
.qv-img-box img { display: block; width: 100%; height: 100%; object-fit: contain; }
.qv-img-box img:not([src]) { visibility: hidden; }
.qv-img-err .qv-img-box img { display: none; }
.qv-img-err .qv-img-box::after { content: "Không tải được ảnh"; display: block; padding: 40px 8px 0; text-align: center; font-size: 12px; color: var(--text-muted); }
.qv-img-cap { text-align: center; }
.qv-form .qv-viewonly { margin-bottom: 12px; }
/* bảng nhỏ trong tab (Lịch sử gán Client, Accounts của BC): cuộn ngang trong khung riêng, không tràn bảng trượt */
.qv-table { overflow-x: auto; margin: 0 0 10px; border: 1px solid var(--line-2); border-radius: 8px; }
.qv-table table { width: 100%; margin: 0; font-size: 13px; }
.qv-table th, .qv-table td { white-space: nowrap; }

/* tên trong bảng mở Xem nhanh (bảng không có "bảng gọn" của control-panel, vd Business Center): nút trông như chữ, như a.lv-link */
button.qv-link { padding: 0; border: 0; background: none; font: inherit; font-weight: 500; color: var(--ink); text-align: left; cursor: pointer; }
button.qv-link:hover, button.qv-link:focus-visible { color: var(--brand); text-decoration: underline; outline: none; }
:root[data-theme="dark"] button.qv-link:hover, :root[data-theme="dark"] button.qv-link:focus-visible { color: var(--brand-hover); }

/* dòng danh sách mở được bằng Xem nhanh + dòng đang mở */
tr.qv-row { cursor: pointer; }
tr.qv-row:hover > td, tr.qv-row:focus-visible > td { background: var(--row-hover); }
tr.qv-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
tr.qv-row.qv-on > td { background: var(--surface-selected); }
/* vạch trái ở ô ĐẦU TIÊN đang hiện (cột ID ẩn mặc định — .lv-off của Chọn cột) */
tr.qv-row.qv-on > td:not(.lv-off) { box-shadow: inset 3px 0 0 var(--brand); }
tr.qv-row.qv-on > td:not(.lv-off) ~ td { box-shadow: none; }
td.row-actions .qv-open { display: none; }

@media (max-width: 767.98px) {
  .qv-drawer { top: auto; left: 0; width: 100%; height: 92vh; height: 92dvh; border-left: 0; border-top: 1px solid var(--border);
    border-radius: 12px 12px 0 0; box-shadow: 0 -6px 24px var(--shadow); transform: translateY(100%); }
  .qv-head { padding: 8px 8px 8px 12px; }
  .qv-body { padding: 14px 16px calc(20px + env(safe-area-inset-bottom, 0px)); }
  .qv-foot { display: none; }
  .qv-title { font-size: 18px; }
  .qv-fields, .qv-form .qv-fgrid { grid-template-columns: minmax(0, 1fr); }
  .qv-sec { padding: 12px; }
  .qv-ebar { bottom: calc(-20px - env(safe-area-inset-bottom, 0px)); }
  .qv-ebar .btn { flex: 1 1 0; }
  .qv-copylink { width: 44px; min-width: 44px; padding: 0; }   /* điện thoại: chỉ biểu tượng (nhãn đọc qua aria-label) */
  .qv-copylink-t { display: none; }
  .qv-ct-acts { width: 100%; }
  .qv-ct-acts .btn, .qv-ct-tools .btn { flex: 1 1 0; }
}
@media (max-width: 379.98px) {
  .qv-pos { display: none; }
  /* 320 px: ↑ ↓ + Copy link + Mở đầy đủ + ✕ vừa một hàng (CRM-56 thêm Copy link) — khít khoảng cách, nút không bị ép chồng */
  .qv-head { gap: 4px; padding: 8px; }
  .qv-full { padding-left: 10px; padding-right: 10px; }
}
.qv-nav .btn { flex: none; }
/* điện thoại + màn cảm ứng: ô chữ 16 px (iOS không phóng to), vùng bấm 44 px, không có phím tắt */
@media (max-width: 767.98px), (pointer: coarse) {
  .qv-drawer .btn { min-height: 44px; }
  .qv-icon { width: 44px; min-width: 44px; }
  .qv-tabs .subtab { min-height: 44px; }
  .qv-form input, .qv-form select, .qv-form textarea { font-size: 16px; }
  .qv-form input, .qv-form select { min-height: 44px; }
  .qv-pick-list .pick-item { min-height: 44px; }
  .qv-pick-sel .selected-client-chip { padding-top: 0; padding-bottom: 0; }   /* nút × 44 px quyết chiều cao chip */
  .qv-pick-sel .selected-client-chip button { min-width: 44px; min-height: 44px; }
  .qv-chip button { width: 44px; height: 44px; margin: -8px -4px -8px 0; }
  .qv-form .field label.qv-check { min-height: 44px; }
  .qv-img { min-height: 44px; }
}
@media (pointer: coarse) { .qv-foot { display: none; } }
