/* "Xem nhanh" (03/11/2026): bảng trượt dùng chung UI.drawer (ui.js) + nội dung Sales.peek (peek.js) — hiện gắn cho Lead.
   Laptop / máy tính bảng ≥ 768 px: trượt từ phải, rộng ~40% (420–640 px), nền mờ nhẹ (--scrim) — danh sách vẫn đọc được.
   Điện thoại < 768 px: tấm trượt từ dưới lên ~90% chiều cao, tay nắm kéo xuống để đóng. Chỉ transform / opacity, 200 ms ease-out;
   prefers-reduced-motion ⇒ không chuyển động (app.css tắt transition chung). Chỉ dùng biến màu của app.css (sáng + tối). */
.drawer-scrim { position: fixed; inset: 0; z-index: 44; background: var(--scrim); opacity: 0; transition: opacity .2s ease-out; }
.drawer-scrim.on { opacity: 1; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 45; width: clamp(420px, 65vw, 1280px); max-width: 100vw; display: flex; flex-direction: column;
  background: var(--surface); color: var(--ink); border-left: 1px solid var(--line); box-shadow: var(--shadow-pop); transform: translateX(100%);
  transition: transform .22s ease-out; outline: none; }
.drawer.on { transform: none; }
.drawer:focus { outline: none; }   /* focus vào chính hộp thoại khi mở (không phải phần tử bấm được) — các nút bên trong vẫn có vòng focus */
.drawer.dragging { transition: none; }
.drawer[hidden], .drawer-scrim[hidden] { display: none; }
.drawer-grip { display: none; }
.drawer-head { flex: none; display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--line); }
.drawer-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px 20px 24px; }
.drawer-foot { flex: none; display: flex; align-items: center; gap: 8px; padding: 8px 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
html.drawer-open, html.drawer-open body { overflow: hidden; }   /* màn hẹp cuộn cả trang ⇒ khoá trang phía sau khi bảng mở */

@media (max-width: 767.98px) {
  .drawer { top: auto; left: 0; width: 100%; height: 90vh; height: 90dvh; border-left: 0; border-top: 1px solid var(--line); border-radius: 12px 12px 0 0;
    transform: translateY(100%); }
  .drawer-grip { display: flex; justify-content: center; align-items: center; height: 20px; flex: none; cursor: grab; touch-action: none; }
  .drawer-grip span { width: 40px; height: 4px; border-radius: 2px; background: var(--btn-border); }
  .drawer-head { padding: 2px 8px 8px 12px; touch-action: none; }
  .drawer-body { padding: 14px 16px 24px; }
  .drawer-foot { display: none; }
}

/* ---- Dòng danh sách mở được bằng Xem nhanh ---- */
table.data tbody tr.peek-row { cursor: pointer; }
table.data tbody tr.peek-on td { background: var(--brand-soft); }
table.data tbody tr.peek-on td:first-child { box-shadow: inset 3px 0 0 var(--brand); }

/* ---- Nội dung bảng Xem nhanh ---- */
.peek .qv-nav { display: flex; align-items: center; gap: 4px; margin-right: auto; min-width: 0; }
.peek .qv-move { display: inline-grid; place-items: center; }
.peek .qv-up { transform: rotate(180deg); }
.peek .qv-pos { margin-left: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.peek .qv-full { display: inline-flex; align-items: center; gap: 4px; color: var(--brand-dark); font-weight: 600; text-decoration: none; white-space: nowrap; }
.peek .qv-full:hover { text-decoration: underline; }
.peek .qv-x { display: inline-grid; place-items: center; }
.qv-top { margin-bottom: 12px; }
.qv-ref { font-size: 12px; font-weight: 600; color: var(--muted); }
.qv-title { margin: 2px 0 8px; font-size: 20px; line-height: 1.3; font-weight: 700; overflow-wrap: anywhere; }
.qv-rib { display: flex; flex-wrap: wrap; gap: 6px; }
.qv-stb .fv-stb { margin: 0; width: 100%; }
.qv-stb .fv-stb .path-step { flex: 1 0 auto; justify-content: center; }
/* theme tối: --brand-soft trong suốt ⇒ mũi tên (::after, background: inherit) chồng màu thành hình thoi đậm — dùng màu đặc tương đương */
:root[data-theme="dark"] .qv-stb .fv-stb .path-step.current { background: color-mix(in srgb, var(--brand) 16%, var(--surface)); }
.peek .qv-guide { margin: 8px 0 0; }
.qv-links { margin: 10px 0 0; overflow-wrap: anywhere; }
.qv-err { margin: 12px 0 0; }
.qv-acts { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 0; }
.qv-acts .btn.qv-danger { color: var(--err); }
.qv-sec { margin: 16px 0 0; padding: 12px 0 0; border-top: 1px solid var(--line-2); }
.qv-sec-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 32px; margin: 0 0 8px; }
.qv-sec-h .qv-h { margin: 0; }
.peek .qv-edit { display: inline-flex; align-items: center; gap: 6px; }
.qv-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 20px; margin: 0; }
.qv-f { min-width: 0; }
.qv-f.wide { grid-column: 1 / -1; }
.qv-f dt { font-size: 12px; font-weight: 600; color: var(--muted); }
.qv-f dd { margin: 2px 0 0; display: flex; align-items: center; gap: 6px; min-width: 0; overflow-wrap: anywhere; }
.qv-f dd a { color: var(--brand-dark); }
.qv-msg { white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.qv-tl { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--line-2); }
.qv-h { margin: 0 0 2px; font-size: 14px; font-weight: 700; }
.qv-tl .fc-sec { padding: 2px 0; }
.qv-tl .fc-sep { padding: 10px 0 4px; }
.qv-tl .fc-msg { padding: 8px 0; }
.qv-tl .fc-arr { color: var(--muted); }   /* mũi tên "A → B" (--soon chỉ 2,4:1) ⇒ đạt AA trong bảng */
.qv-empty { margin: 6px 0; color: var(--muted); }
.qv-more { display: inline-block; margin-top: 8px; font-weight: 600; color: var(--brand-dark); }
.qv-keys kbd { font: inherit; font-size: 11px; padding: 0 5px; border: 1px solid var(--line); border-radius: 3px; background: var(--surface-2); color: var(--ink); }

/* ---- Sửa trong Xem nhanh (03/11/2026): form thay chỗ danh sách trường, cùng lưới tự chia cột; thanh Lưu / Huỷ dính đáy thân bảng ---- */
.qv-editing .qv-acts, .qv-editing .qv-guide { display: none; }   /* đang sửa: thao tác (vẽ lại bảng) tạm ẩn */
.qv-form .qv-fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0 20px; }   /* ≥ 240 px: email dài không bị cắt; 12 ô ⇒ 2 / 3 / 4 cột */
.qv-form .field { min-width: 0; }
.qv-form .field input:not([type=checkbox]):not([type=radio]), .qv-form .field select, .qv-form .ss-btn { width: 100%; }
.qv-form .check-list { max-height: 220px; }
/* bottom = −(lề dưới 24 px của .drawer-body): thanh dính SÁT mép dưới vùng cuộn — không để lộ ô phía sau trong dải lề */
.qv-ebar { position: sticky; bottom: -24px; z-index: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 4px 0 0; padding: 10px 0 12px;
  background: var(--surface); border-top: 1px solid var(--line-2); }
.qv-ekeys { font-size: 12px; color: var(--muted); }
.qv-emore { margin: 8px 0 0; font-size: 13px; }
.qv-emore a { color: var(--brand-dark); }
.drawer-body.qv-editing { scroll-padding-bottom: 80px; }   /* ô đang focus không bị thanh Lưu / Huỷ dính đáy che */
@media (pointer: coarse) { .qv-ekeys { display: none; } }   /* màn cảm ứng: không có phím tắt */
@media (min-width: 768px) { .qv-ekeys { display: none; } }   /* chân bảng đã ghi phím tắt của chế độ sửa (peek.js) — không lặp */
.qv-form[aria-busy="true"] [data-qv-save] { opacity: .7; cursor: progress; }

@media (max-width: 479.98px) {
  .qv-fields { grid-template-columns: minmax(0, 1fr); }
  .peek .qv-pos { display: none; }
}
@media (pointer: coarse) {
  .peek .btn { min-height: 44px; }
  .peek .btn.icon { min-width: 44px; }
  .qv-f dd a, .qv-more { display: inline-flex; align-items: center; min-height: 44px; }
  .drawer-foot { display: none; }
}
/* Nút "Gọi" (tel:) chỉ trên màn cảm ứng; điện thoại: tên dài cắt còn 3 dòng (tên đầy đủ ở title) ⇒ SĐT / nút lên màn đầu */
a.btn.qv-call { display: none; color: var(--ink); text-decoration: none; }
.qv-acts.qv-call-only { display: none; }   /* vai trò không có nút thao tác: hàng chỉ còn nút Gọi ⇒ chỉ hiện trên màn cảm ứng */
@media (pointer: coarse) { .qv-acts a.btn.qv-call { display: inline-flex; align-items: center; } .qv-acts.qv-call-only { display: flex; } }
/* điện thoại + màn cảm ứng (máy tính bảng): chữ ô 16 px (iOS không phóng to khi chạm), vùng bấm 44 px */
@media (max-width: 767.98px), (pointer: coarse) {
  .qv-form input[type=text], .qv-form input[type=email], .qv-form input[type=search], .qv-form select, .qv-form .ss-btn { font-size: 16px; min-height: 44px; }
  .qv-form .check-list label { min-height: 44px; align-items: center; }
  .qv-form .check-list input { margin-top: 0; width: 20px; height: 20px; }
  .qv-ebar .btn { min-height: 44px; }
  .qv-emore a { display: inline-flex; align-items: center; min-height: 44px; }
}
@media (max-width: 767.98px) {
  .qv-form .qv-fgrid { grid-template-columns: minmax(0, 1fr); }   /* tấm trượt điện thoại: form một cột, nút Lưu / Huỷ chia đôi bề ngang */
  .qv-ebar .btn { flex: 1 1 0; }
  .qv-ebar { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }   /* tấm trượt sát đáy màn: chừa vạch Home của iPhone */
  .qv-title { font-size: 18px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
}
