/* ============ Chia Lead – giao diện ============ */
:root {
  /* Bảng màu lấy từ vmgland.vn */
  --bg: #f7f2eb;          /* nền kem ấm */
  --paper: #ffffff;
  --ink: #2a0a0d;         /* đỏ nâu rất đậm – chữ tiêu đề */
  --ink-2: #5a4440;
  --ink-3: #8d7a72;
  --line: #eadfd3;
  --brand: #8c1c24;       /* đỏ đô thanh đầu trang */
  --brand-2: #6b1820;
  --brand-deep: #2a0a0d;
  --brand-soft: #f6e6e1;
  --accent: #c89b55;      /* vàng đồng */
  --gold-1: #ba8a57;
  --gold-2: #e8c38f;
  --gold-grad: linear-gradient(90deg, #ba8a57 0%, #d7ad74 55%, #e8c38f 100%);
  --hero-grad: linear-gradient(135deg, #2a0a0d 0%, #6b1820 50%, #2a0a0d 100%);
  --ok: #2f7d55;
  --ok-soft: #e3f1e8;
  --warn: #a8641a;
  --warn-soft: #fbefdc;
  --bad: #c62828;
  --bad-soft: #fde7e5;
  --ice: #3d6a9e;
  --ice-soft: #e6eef8;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(42, 10, 13, .06), 0 6px 18px rgba(42, 10, 13, .07);
  --font: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Oswald', 'Be Vietnam Pro', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-2); }
.boot { padding: 40px; text-align: center; color: var(--ink-3); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* ---------- Thanh trên ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--brand); color: #fff; padding: 10px 16px; display: flex; align-items: center; gap: 12px; padding-top: max(10px, env(safe-area-inset-top)); }
.topbar { box-shadow: 0 2px 12px rgba(42, 10, 13, .25); }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; cursor: pointer; border-radius: 10px; -webkit-tap-highlight-color: transparent; }
.logo:hover img { filter: brightness(1.12); } .logo:active { transform: scale(.97); }
.logo img { height: 34px; width: auto; display: block; }
.logo .lt { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.05; border-left: 1px solid rgba(232, 195, 143, .45); padding-left: 10px; }
.logo .lt b { font-family: var(--display); font-weight: 600; letter-spacing: .14em; font-size: 15px; color: #fff; }
.logo .lt small { font-size: 8.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--gold-2); white-space: nowrap; margin-top: 2px; }
.topbar .sp { flex: 1; }
.clockpill { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 5px 10px; border-radius: 999px; background: rgba(255,255,255,.12); white-space: nowrap; }
.clockpill { border: 1px solid rgba(232, 195, 143, .35); }
.clockpill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold-2); box-shadow: 0 0 0 3px rgba(232,195,143,.28); }
.clockpill.frozen .dot { background: #9cc4ff; box-shadow: 0 0 0 3px rgba(156,196,255,.25); }
.iconbtn { background: transparent; border: 1px solid rgba(232, 195, 143, .55); color: #fff; width: 36px; height: 36px; border-radius: 10px; cursor: pointer; font-size: 18px; }
.menu { position: absolute; right: 12px; top: 54px; background: var(--paper); color: var(--ink); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.18); min-width: 220px; padding: 6px; z-index: 30; }
.menu button { display: block; width: 100%; text-align: left; padding: 10px 12px; background: none; border: 0; border-radius: 8px; cursor: pointer; }
.menu button:hover { background: var(--bg); }
.menu .who { padding: 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }

/* ---------- Bố cục ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 16px; }
.wrap.narrow { max-width: 720px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 2px; margin: 0 0 14px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { border: 1px solid var(--line); background: var(--paper); padding: 8px 14px; border-radius: 999px; cursor: pointer; white-space: nowrap; font-weight: 600; font-size: 14px; color: var(--ink-2); }
.tab.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.tab .c { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 6px; border-radius: 999px; background: var(--bg); color: var(--ink); font-size: 12px; text-align: center; }
.tab.on .c { background: var(--gold-grad); color: var(--brand-deep); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 900px) { .g5 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g3 { grid-template-columns: 1fr; } }
@media (max-width: 560px) { .g2 { grid-template-columns: 1fr; } }
.card { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card h3 { margin: 0 0 10px; font-family: var(--display); font-weight: 600; font-size: 17px; letter-spacing: .01em; color: var(--ink); }
.section-title { font-family: var(--display); font-size: 13.5px; text-transform: uppercase; letter-spacing: .12em; color: var(--gold-1); font-weight: 600; margin: 20px 0 8px; }

/* ---------- Nút, ô nhập ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--paper); padding: 9px 14px; border-radius: 10px; cursor: pointer; font-weight: 600; text-decoration: none; color: var(--ink); min-height: 40px; }
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { background: var(--brand-2); }
.btn.accent { background: var(--gold-grad); border-color: transparent; color: var(--brand-deep); box-shadow: 0 4px 14px rgba(186, 138, 87, .35); }
.btn.accent:hover { filter: brightness(1.04); border-color: transparent; }
.btn.danger { color: var(--bad); border-color: #efc7c2; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { padding: 5px 10px; min-height: 32px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
label.f { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 12px 0 6px; }
input.in, select.in, textarea.in { width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 10px 12px; outline: none; }
input.in:focus, select.in:focus, textarea.in:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea.in { min-height: 72px; resize: vertical; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 13px; cursor: pointer; font-size: 14px; font-weight: 500; }
.chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.stars { display: flex; gap: 4px; align-items: center; }
.star { font-size: 28px; line-height: 1; background: none; border: 0; cursor: pointer; color: #d6d0c2; padding: 0 2px; }
.star.on { color: var(--accent); }
.gold { background: var(--gold-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stars .lbl { margin-left: 8px; font-size: 13px; color: var(--ink-2); }

/* ---------- Thẻ lead ---------- */
.lead { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 14px 12px; margin-bottom: 10px; cursor: pointer; border-left: 4px solid transparent; transition: transform .12s; }
.lead:active { transform: scale(.995); }
.lead.p1 { border-left-color: var(--warn); }
.lead.p2 { border-left-color: var(--ice); }
.lead.won { border-left-color: var(--ok); }
.lead.late { border-left-color: var(--bad); }
.lead .top { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-3); }
.lead .nm { font-size: 18px; font-weight: 700; margin: 6px 0 2px; letter-spacing: -.01em; color: var(--ink); }
.lead .ph { font-size: 15px; color: var(--ink-2); }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: var(--bg); color: var(--ink-2); white-space: nowrap; }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.ice { background: var(--ice-soft); color: var(--ice); }
.tag.brand { background: var(--brand-soft); color: var(--brand-2); }
.dchips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.dchip { font-size: 12.5px; background: var(--bg); padding: 3px 9px; border-radius: 8px; color: var(--ink-2); }
.dchip b { font-weight: 600; color: var(--ink-3); margin-right: 4px; }
.cd { margin-left: auto; font-weight: 700; font-size: 14px; padding: 4px 10px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); white-space: nowrap; }
.cd.p2 { background: var(--ice-soft); color: var(--ice); }
.cd.urgent { background: var(--bad-soft); color: var(--bad); }
.cd.frozen { background: #eef0f3; color: #59708f; }
.empty { text-align: center; padding: 40px 16px; color: var(--ink-3); }
.empty .big { font-size: 34px; margin-bottom: 6px; }
.banner { display: flex; gap: 10px; align-items: center; background: #fff6e2; border: 1px solid #f4dca5; border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; font-size: 14px; }
.banner.ice { background: var(--ice-soft); border-color: #c8dbf5; }

/* ---------- Hộp thoại ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(20, 30, 27, .45); display: flex; align-items: flex-end; justify-content: center; }
.modal[hidden] { display: none; }
.sheet { background: var(--bg); width: 100%; max-width: 760px; max-height: 94vh; overflow: auto; border-radius: 18px 18px 0 0; box-shadow: 0 -10px 40px rgba(0,0,0,.2); }
@media (min-width: 760px) { .modal { align-items: center; } .sheet { border-radius: 18px; max-height: 90vh; } }
.sheet-h { position: sticky; top: 0; background: var(--bg); display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); z-index: 2; }
.sheet-h h2 { margin: 0; font-size: 17px; flex: 1; }
.sheet-b { padding: 14px 16px 28px; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 10px; font-size: 14px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; }
.contact-btns { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 12px 18px; font-size: 13.5px; }
.timeline li::before { content: ''; position: absolute; left: 4px; top: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.timeline li::after { content: ''; position: absolute; left: 7px; top: 15px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline .t { color: var(--ink-3); font-size: 12px; }
.handover { border: 1px dashed #cfc7b5; border-radius: 12px; padding: 12px; margin-bottom: 10px; background: #fbfaf6; }
.handover .hh { font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.formcount { font-size: 13px; padding: 8px 10px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-weight: 600; margin-top: 14px; }
.formcount.ok { background: var(--ok-soft); color: var(--ok); }
.opt { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 11px 12px; cursor: pointer; margin-bottom: 8px; }
.opt.on { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.opt .rec { margin-left: auto; }

/* ---------- Bảng ---------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px; border-bottom: 1px solid #efebe2; vertical-align: middle; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: #faf8f3; }
.kpi { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.kpi .l { font-size: 13px; color: var(--ink-3); font-weight: 600; }
.kpi { border-top: 3px solid transparent; background: linear-gradient(var(--paper), var(--paper)) padding-box, var(--gold-grad) border-box; }
.kpi .v { font-family: var(--display); font-size: 34px; font-weight: 600; color: var(--ink); margin-top: 2px; }
.kpi .s { font-size: 12.5px; color: var(--ink-3); }
.bar { height: 8px; border-radius: 6px; background: var(--bg); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--gold-grad); border-radius: 6px; }
.rank { width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--bg); }
.rank.r1 { background: var(--gold-grad); } .rank.r2 { background: #ddd6cf; } .rank.r3 { background: #d39b74; }

/* ---------- Đăng nhập ---------- */
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 28px 16px; background:
  radial-gradient(700px 420px at 50% 0%, rgba(232, 195, 143, .16) 0%, transparent 70%), var(--hero-grad); }
.auth-logo img { height: 132px; width: auto; display: block; filter: drop-shadow(0 6px 24px rgba(0,0,0,.35)); }
.auth-sub { color: var(--gold-2); font-family: var(--display); letter-spacing: .22em; text-transform: uppercase; font-size: 13px; margin-bottom: 6px; }
.auth .box { background: var(--paper); border-radius: 18px; padding: 24px 22px; width: 100%; max-width: 380px; box-shadow: 0 24px 60px rgba(0,0,0,.35); border-top: 4px solid transparent; background: linear-gradient(var(--paper), var(--paper)) padding-box, var(--gold-grad) border-box; }
.auth h1 { margin: 0 0 4px; font-family: var(--display); font-weight: 600; font-size: 26px; color: var(--ink); }
.auth .err { color: var(--bad); font-size: 14px; margin-top: 10px; min-height: 20px; }

/* ---------- Màn hình TV ---------- */
.tv { min-height: 100vh; background: radial-gradient(900px 500px at 80% -10%, rgba(232,195,143,.12) 0%, transparent 60%), var(--hero-grad); color: #f7efe4; padding: 24px 28px; }
.tv-h { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.tv-logo { height: 64px; width: auto; }
.tv-eyebrow { font-family: var(--display); letter-spacing: .24em; font-size: 12px; color: var(--gold-2); }
.tv-h h1 { margin: 0; font-family: var(--display); font-weight: 600; font-size: 34px; letter-spacing: .01em; }
.tv-clock { margin-left: auto; text-align: right; }
.tv-clock .tm { font-family: var(--display); font-size: 46px; font-weight: 600; line-height: 1; }
.tv-kpis { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 14px; margin-bottom: 18px; }
.tv-kpi { background: rgba(255,255,255,.06); border: 1px solid rgba(232,195,143,.25); border-radius: 16px; padding: 14px 16px; }
.tv-kpi .l { font-size: 14px; opacity: .75; }
.tv-kpi .v { font-family: var(--display); font-size: 52px; font-weight: 600; line-height: 1.05; }
.tv-boards { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; }
.tv-board { background: rgba(255,255,255,.05); border: 1px solid rgba(232,195,143,.22); border-radius: 16px; padding: 14px 16px; }
.tv-board h3 { margin: 0 0 10px; font-family: var(--display); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; font-size: 17px; color: var(--gold-2); }
.tv-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid rgba(255,255,255,.07); font-size: 17px; }
.tv-row .n { margin-left: auto; font-weight: 800; font-size: 20px; }
.tv-row .rank { color: var(--brand-deep); }
.tv .tbar { width: 70px; height: 6px; border-radius: 4px; background: rgba(255,255,255,.12); overflow: hidden; }
.tv .tbar i { display: block; height: 100%; background: var(--gold-grad); }
@media (max-width: 900px) { .tv-kpis { grid-template-columns: repeat(2, minmax(0,1fr)); } .tv-boards { grid-template-columns: 1fr; } }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 12px; z-index: 80; font-size: 14px; max-width: 92vw; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.toast.bad { background: var(--bad); }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--bg); border: 1px solid var(--line); padding: 8px 10px; border-radius: 8px; word-break: break-all; font-size: 13px; }
.steps { margin: 6px 0 0; padding-left: 20px; font-size: 14px; }
.steps li { margin-bottom: 6px; }

/* Ô chọn dạng chip & lựa chọn chốt: nhấn màu vàng đồng khi chọn */
.chip.on { box-shadow: 0 3px 10px rgba(140, 28, 36, .22); }
.opt.on { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(200, 155, 85, .25); }
@media (max-width: 480px) { .logo .lt small { display: none; } .logo img { height: 30px; } .auth-logo img { height: 108px; } }
/* Nút trên màn hình TV: viền vàng như nút "LIÊN HỆ NGAY" của vmgland.vn */
.tv .btn { background: transparent; color: var(--gold-2); border: 1px solid rgba(232, 195, 143, .7); border-radius: 2px; text-transform: uppercase; letter-spacing: .14em; font-size: 12px; font-weight: 600; }
.tv .btn:hover { background: rgba(232, 195, 143, .12); border-color: var(--gold-2); }

/* =====================  v2  ===================== */
.nowrap { white-space: nowrap; }
.red { color: var(--bad); }
.gold-t { color: var(--accent); }
.stars-s { color: var(--accent); letter-spacing: 1px; } .stars-s i { color: #ddd3c6; font-style: normal; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 1100px) { .g6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 700px) { .g6, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi.gold { background: linear-gradient(var(--paper), var(--paper)) padding-box, var(--gold-grad) border-box; border: 2px solid transparent; }
.kpi.gold .v { color: var(--brand); }
.in.sel { width: auto; padding: 8px 10px; }
.in.sel.sm { padding: 5px 8px; font-size: 13px; min-height: 32px; }
.cust-name { font-size: 21px; font-weight: 800; margin-top: 6px; color: var(--ink); }
.cust-phone { font-size: 16px; color: var(--ink-2); }

/* Thanh tìm kiếm trên thanh đỏ */
.gsearch { position: relative; flex: 0 1 460px; margin-left: 8px; }
.gsearch input { width: 100%; border: 1px solid rgba(232, 195, 143, .45); background: rgba(255, 255, 255, .12); color: #fff; border-radius: 999px; padding: 8px 14px 8px 34px; outline: none; font-size: 14px; }
.gsearch input::placeholder { color: rgba(255, 255, 255, .7); }
.gsearch input:focus { background: #fff; color: var(--ink); border-color: var(--gold-2); }
.gsearch input:focus::placeholder { color: var(--ink-3); }
.gs-ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 17px; color: var(--gold-2); pointer-events: none; }
.gsearch input:focus + .sres, .gsearch:focus-within .gs-ico { color: var(--ink-3); }
.sbtn { display: none; }
.sres { position: absolute; top: calc(100% + 8px); left: 0; right: 0; min-width: 320px; max-height: 70vh; overflow: auto; background: var(--paper); color: var(--ink); border-radius: 14px; box-shadow: 0 16px 40px rgba(0,0,0,.25); padding: 6px; z-index: 40; }
.sr-h { font-family: var(--display); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--gold-1); padding: 8px 10px 4px; }
.sr-i { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 10px; cursor: pointer; }
.sr-i:hover { background: var(--bg); }
.sr-m { display: block; font-size: 12px; margin-top: 2px; }
.sr-empty { padding: 14px; color: var(--ink-3); font-size: 14px; }
@media (max-width: 760px) {
  .gsearch { position: absolute; left: 10px; right: 10px; top: 100%; margin: 6px 0 0; display: none; }
  .gsearch.open { display: block; }
  .gsearch input { background: #fff; color: var(--ink); box-shadow: 0 8px 24px rgba(0,0,0,.2); }
  .sbtn { display: inline-block; }
  .clockpill .cl-t { display: none; }
  .clockpill { padding: 7px; }
  .topbar { gap: 8px; }
}
.bell { position: relative; }
.bell .badge { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--gold-2); color: var(--brand-deep); font-size: 11px; font-weight: 800; display: grid; place-items: center; padding: 0 4px; }
.npop { position: fixed; right: 12px; top: 58px; width: min(380px, calc(100vw - 24px)); max-height: 70vh; overflow: auto; background: var(--paper); border-radius: 14px; box-shadow: 0 16px 40px rgba(0,0,0,.25); z-index: 45; padding: 6px; }
.np-h { display: flex; justify-content: space-between; align-items: baseline; padding: 8px 10px; font-weight: 700; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.np-i { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 9px 10px; border-radius: 10px; cursor: pointer; font-size: 14px; }
.np-i:hover { background: var(--bg); }
.np-i.unread { background: var(--brand-soft); }
.demo-ribbon { background: var(--gold-grad); color: var(--brand-deep); text-align: center; font-size: 12px; font-weight: 600; letter-spacing: .04em; padding: 4px 10px; position: sticky; top: 56px; z-index: 19; }
.demo-hint { margin-top: 16px; padding: 12px; border-radius: 12px; background: #fbf4e8; border: 1px dashed var(--accent); font-size: 13px; }
.setup-opt { border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-top: 12px; }
.progress { height: 8px; border-radius: 6px; background: var(--bg); margin-top: 10px; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--gold-grad); transition: width .3s; }

/* Lead: nguồn gốc, AI, form 5 mục, nút chốt */
.origin { display: flex; gap: 10px; align-items: center; background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 12px; padding: 10px 12px; margin-top: 10px; }
.origin .oi { font-size: 22px; }
.aibox { margin-top: 10px; border-radius: 14px; padding: 12px 14px; background: linear-gradient(135deg, #2a0a0d, #5c1c21); color: #f7efe4; font-size: 14px; line-height: 1.55; box-shadow: var(--shadow); }
.ai-h { display: flex; justify-content: space-between; gap: 10px; font-family: var(--display); letter-spacing: .06em; color: var(--gold-2); font-size: 14px; margin-bottom: 4px; }
.ai-h span { font-family: var(--font); letter-spacing: 0; font-size: 11px; opacity: .75; }
.tl-ai { margin-top: 4px; font-size: 12.5px; color: #6b4a2a; background: #fbf4e8; border-radius: 8px; padding: 6px 8px; }
.ai-line { margin-top: 8px; font-size: 12.5px; color: #6b4a2a; background: #fbf4e8; border-radius: 8px; padding: 6px 8px; }
.fsec { display: flex; gap: 10px; padding: 6px 0 10px; border-bottom: 1px dashed var(--line); }
.fsec:last-of-type { border-bottom: 0; }
.fnum { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; margin-top: 10px; }
.fbody { flex: 1; min-width: 0; }
.fbody .chips + .chips, .fbody .chips + .in, .fbody .chips + .stars { margin-top: 8px; }
.goal { background: #fbf4e8; border: 1px solid #f0dfbd; border-radius: 10px; padding: 8px 10px; font-size: 13.5px; margin-bottom: 10px; }
.ogrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 640px) { .ogrid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.ocard { text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 10px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; position: relative; }
.ocard b { font-size: 14px; } .ocard span { font-size: 12px; color: var(--ink-3); }
.ocard i { font-style: normal; font-size: 11px; color: var(--ok); font-weight: 700; }
.ocard.rec { border-color: #b9dcc8; }
.ocard.hero { grid-column: span 2; background: linear-gradient(#fff, #fff) padding-box, var(--gold-grad) border-box; border: 2px solid transparent; }
.ocard.hero b { color: var(--brand); font-size: 16px; }
.ocard.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.ocard.on span, .ocard.on b, .ocard.on i { color: #fff; }
.dealf { margin-top: 10px; padding: 10px; border-radius: 12px; background: #fbf4e8; border: 1px solid #f0dfbd; }
.wonbox { border-left: 4px solid var(--ok); }
.handover.live { border-color: var(--brand-2); background: #fff; }

/* Trang sale */
.sale-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.sale-stats div { background: var(--paper); border-radius: 12px; box-shadow: var(--shadow); padding: 8px 10px; text-align: center; }
.sale-stats b { display: block; font-family: var(--display); font-size: 24px; font-weight: 600; color: var(--ink); }
.sale-stats span { font-size: 11.5px; color: var(--ink-3); }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: -4px 2px 12px; }
.hist { background: var(--paper); border-radius: 12px; box-shadow: var(--shadow); padding: 12px 14px; margin-bottom: 8px; cursor: pointer; }
.hist:hover { box-shadow: 0 0 0 2px var(--brand-soft), var(--shadow); }

/* Sếp */
.sales-grid { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
.bot-grid { grid-template-columns: 380px minmax(0, 1fr); align-items: start; }
@media (max-width: 900px) { .sales-grid, .bot-grid { grid-template-columns: 1fr; } }
.scard { margin-bottom: 10px; }
.sname { font-size: 16px; cursor: pointer; text-decoration: underline; text-decoration-color: var(--gold-2); text-underline-offset: 3px; }
.click-l { cursor: pointer; }
.sheet.wide { max-width: 1100px; }
.danger-card { border: 1px solid #efc7c2; }
.chat { display: flex; flex-direction: column; gap: 8px; max-height: 70vh; overflow: auto; }
.msg { border-radius: 12px; padding: 8px 10px; max-width: 92%; font-size: 13.5px; }
.msg.in { background: #eef3f9; align-self: flex-start; }
.msg.out { background: #fbf4e8; align-self: flex-end; }
.msg .mh { display: flex; justify-content: space-between; gap: 10px; font-size: 11.5px; color: var(--ink-3); margin-bottom: 2px; }
.msg .mb { white-space: pre-wrap; }
.rboard h3 { font-size: 16px; }
.rrow { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid #f1ebe2; cursor: pointer; }
.rrow:last-child { border-bottom: 0; }
.rrow .rn { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.rrow .rn b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tbl td.num.red { color: var(--bad); }

/* Sửa tràn ngang trên điện thoại */
.lead .top { flex-wrap: wrap; }
.lead .top .tag { white-space: normal; }
.toolbar > .muted { flex: 1 1 260px; }
.kpi .v .stars-s, .kpi .v.stars { color: var(--accent); }
html, body { overflow-x: hidden; } @supports (overflow: clip) { html, body { overflow-x: clip; } } /* clip: không chặn thanh dính (sticky) */

/* ---------- Kịch bản 2 bước, mẫu tin nhắn, sale 2 ---------- */
.stepsbox .steps-h { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--gold-1); font-weight: 600; margin: 10px 0 6px; }
.steps-g { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; }
.step { display: flex; align-items: center; gap: 8px; text-align: left; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); font: inherit; font-size: 13.5px; color: inherit; cursor: pointer; min-height: 40px; }
.step:disabled { cursor: default; }
.step .ck { flex: 0 0 20px; height: 20px; border-radius: 6px; border: 2px solid var(--line); display: grid; place-items: center; font-size: 13px; font-weight: 700; color: #fff; }
.step.on { background: var(--ok-soft); border-color: #b9dcc7; }
.step.on .ck { background: var(--ok); border-color: var(--ok); }
.step small { display: block; font-size: 11px; color: var(--ok); }
.kitbtns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.helperbox { border-left: 4px solid var(--gold-1); }
.lead.helping { border-left-color: var(--gold-1); background: linear-gradient(90deg, #fbf5ec, var(--paper) 40%); }
.stepmini { display: flex; align-items: center; gap: 3px; margin-top: 8px; font-size: 11.5px; color: var(--muted, #8a7f76); }
.stepmini i { width: 14px; height: 6px; border-radius: 3px; background: var(--line); }
.stepmini i.on { background: var(--ok); }
.stepmini span { margin-left: 6px; }
#incomplete { line-height: 1.5; }

/* ---------- Trang dự án ---------- */
.proj-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.pcard { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; cursor: pointer; transition: transform .15s, box-shadow .15s; }
.pcard:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(42, 10, 13, .14); }
.pcover, .phero { position: relative; background: linear-gradient(135deg, #8c1c24, #2a0a0d) center / cover no-repeat; color: #fff; display: flex; align-items: flex-end; }
.pcover { height: 190px; }
.phero { min-height: 240px; border-radius: var(--radius); overflow: hidden; margin-bottom: 12px; }
.pcover[style*="background-image"], .phero[style*="background-image"] { background-size: cover; background-repeat: no-repeat; }
.pshade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(20, 5, 7, .05) 20%, rgba(20, 5, 7, .95)); }
.pc-in { position: relative; padding: 14px 16px; width: 100%; }
.pc-in h3, .pc-in h2 { margin: 6px 0 2px; font-family: var(--display); letter-spacing: .03em; color: #fff; text-shadow: 0 1px 6px rgba(0, 0, 0, .4); }
.pc-in h3 { font-size: 22px; } .pc-in h2 { font-size: 30px; }
.pc-in .tag { background: rgba(255, 255, 255, .92); color: var(--brand); }
.ploc { font-size: 13px; opacity: .92; line-height: 1.4; }
.pbody { padding: 12px 16px 14px; display: grid; gap: 6px; }
.pstats { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; }
.warn-t { color: var(--warn); } .ice-t { color: var(--ice); } .ok-t { color: var(--ok); }
.pkpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.pk { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; text-align: left; cursor: pointer; font: inherit; color: inherit; display: grid; gap: 2px; }
.pk b { font-size: 22px; font-family: var(--display); } .pk span { font-size: 12px; color: var(--ink-3); }
.pk.on { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); background: #fbf5ef; }
.pinfo { grid-template-columns: 170px 1fr; }
.pinfo dd { white-space: pre-line; line-height: 1.5; }
.pgal { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.pgal figure { margin: 0; position: relative; background: var(--paper); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); cursor: zoom-in; }
.pgal.edit figure { cursor: default; }
.pgal img { width: 100%; height: 130px; object-fit: cover; display: block; background: #eee; }
.pgal figcaption { font-size: 12px; padding: 6px 8px; }
.pcov { position: absolute; top: 6px; left: 6px; }
.pimg-acts { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 6px 8px; }
.pbig { width: 100%; max-height: 75vh; object-fit: contain; border-radius: 10px; background: #111; }
@media (max-width: 640px) { .pinfo { grid-template-columns: 1fr; } .pinfo dt { margin-top: 6px; } .pc-in h2 { font-size: 24px; } .pcover { height: 160px; } }

/* ---------- Chấm màu + chú thích + biểu đồ ---------- */
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c); margin-right: 6px; vertical-align: -1px; box-shadow: 0 0 0 2px #fff, 0 0 0 3px rgba(0, 0, 0, .06); flex: 0 0 auto; }
.tag .dot { width: 8px; height: 8px; margin-right: 2px; box-shadow: none; }
.legends { display: grid; gap: 6px; margin: 0 2px 10px; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; font-size: 12.5px; color: var(--ink-2); margin-top: 8px; }
.legend b { font-weight: 600; color: var(--ink-3); margin-right: 2px; }
.legend span { display: inline-flex; align-items: center; white-space: nowrap; }
.legend small { color: var(--ink-3); margin-left: 3px; }
.legends .legend { margin-top: 0; }
.legend-d { margin: 10px 2px; font-size: 13px; color: var(--ink-3); }
.legend-d summary { cursor: pointer; }
.tier-t { display: inline-block; margin-left: 6px; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; color: var(--c); border: 1px solid var(--c); vertical-align: 1px; }
.charts { align-items: start; }
.chartc h3 { margin: 0; font-size: 16px; }
.ch-h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 2px; }
.ch-h .unit { font-size: 12px; color: var(--ink-3); background: var(--bg); padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.ch-box { position: relative; margin-top: 10px; }
.dtab { margin-top: 8px; font-size: 13px; }
.dtab summary { cursor: pointer; color: var(--ink-3); }
.dtab .tbl td, .dtab .tbl th { padding: 6px 8px; }
.cmp td { vertical-align: top; } .cmp td:first-child { font-weight: 600; white-space: nowrap; }
.dl { font-size: 12px; font-weight: 700; margin-left: 4px; color: var(--ink-3); white-space: nowrap; }
.dl.up { color: #0a7d0a; } .dl.down { color: #c0392b; }
@media (max-width: 900px) { .charts.g2 { grid-template-columns: minmax(0, 1fr); } }
.charts > *, .grid > .chartc { min-width: 0; }
@media (max-width: 640px) { .pkpis { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; } .pk { padding: 8px; } .pk b { font-size: 18px; } }

/* ---------- Dòng đậm / nhạt xen kẽ như Excel ---------- */
.tbl tbody tr:nth-child(odd) td { background: #fffdf9; }
.tbl tbody tr:nth-child(even) td { background: #f6efe4; }
.tbl tbody tr:nth-child(even) td:first-child { box-shadow: inset 3px 0 0 #e8d9c2; }
.tbl tr.click:hover td { background: #f1e3cf !important; }
.tbl tbody tr.click:hover td:first-child { box-shadow: inset 3px 0 0 var(--brand); }
.rrow { padding: 7px 8px; margin: 0 -8px; border-radius: 8px; }
.rrow:nth-child(even of .rrow) { background: #f6efe4; }
.rrow:hover { background: #f1e3cf; }
#leadlist .hist:nth-child(even) { background: #fbf6ee; }

/* ---------- Bảng giãn hết bề ngang + tab Lịch sử ---------- */
.wrap:not(.narrow) { max-width: 1880px; padding-left: 20px; padding-right: 20px; }
.tbl td.small, .tbl td { line-height: 1.45; }
.seg { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.chain { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.chain .ch { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); white-space: nowrap; font-size: 12px; }
.chain .ch i { font-style: normal; font-weight: 700; font-size: 11px; }
.chain .ch.ok { border-color: #9fd3a8; background: #e6f4e8; } .chain .ch.ok i { color: #0a7d0a; }
.chain .ch.bad { border-color: #f1b3b3; background: #fdecec; } .chain .ch.bad i { color: #c0392b; }
.chain .ch.warn { border-color: #f1d39a; background: #fdf3df; } .chain .ch.warn i { color: #a8641a; }
.chain .ch.ice { border-color: #b8cdea; background: #e6eef8; } .chain .ch.ice i { color: #3d6a9e; }
.chain .arr { color: var(--ink-3); font-weight: 400; }
.feed-day { font-family: var(--display); font-size: 15px; letter-spacing: .04em; color: var(--brand); margin: 16px 2px 6px; }
.feed .tbl td { vertical-align: top; }
.dot.ring { background: transparent; box-shadow: inset 0 0 0 1.5px #b5b2aa; }
.feed .tbl { table-layout: fixed; min-width: 860px; }

/* =====================================================================
   GIAO DIỆN ĐÁP ỨNG MỌI MÀN HÌNH: điện thoại · máy tính bảng · laptop
   ===================================================================== */
/* ---------- Ảnh đại diện ---------- */
.av { --s: 28px; width: var(--s); height: var(--s); flex: 0 0 var(--s); border-radius: 50%; display: inline-grid; place-items: center; overflow: hidden; vertical-align: middle;
  background: hsl(var(--h) 45% 88%); color: hsl(var(--h) 55% 28%); box-shadow: 0 0 0 2px #fff, 0 1px 3px rgba(42, 10, 13, .18); margin-right: 8px; }
.av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.av i { font-style: normal; font-weight: 700; font-size: calc(var(--s) * .38); letter-spacing: .02em; line-height: 1; }
.av.xs { --s: 20px; margin-right: 5px; } .av.xs i { font-size: 9px; }
.av.sm { --s: 28px; } .av.md { --s: 40px; } .av.lg { --s: 56px; } .av.xl { --s: 120px; margin: 0; }
.avbtn { width: auto !important; padding: 2px 8px 2px 2px !important; display: inline-flex; align-items: center; gap: 2px; border-radius: 999px !important; height: 38px !important; }
.avbtn .av { margin-right: 4px; box-shadow: 0 0 0 2px rgba(232, 195, 143, .8); }
.avbtn .hb { font-style: normal; font-size: 16px; }
.avpick { position: relative; border: 0; background: none; padding: 0; cursor: pointer; border-radius: 50%; }
.avpick > i { position: absolute; right: 2px; bottom: -2px; font-style: normal; font-size: 12px; background: #fff; border-radius: 50%; width: 20px; height: 20px; display: grid; place-items: center; box-shadow: 0 1px 4px rgba(0, 0, 0, .2); }
.avedit { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; } .avedit > div { flex: 1; min-width: 220px; display: grid; gap: 8px; justify-items: start; }
.hello { display: flex; align-items: center; gap: 4px; margin: 2px 2px 12px; } .hello > div { flex: 1; min-width: 0; } .hello b { font-size: 16px; }
.chain .ch .av, .who-l .av { margin-right: 4px; }
.who-l { display: flex; align-items: center; flex-wrap: wrap; }

/* ---------- Thanh tab dính dưới thanh trên cùng (trang sếp) ---------- */
.stickytabs { position: sticky; top: var(--tbh, 56px); z-index: 15; background: var(--bg); margin: -16px -20px 12px !important; padding: 10px 20px 8px !important;
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); }
.tab .ti { margin-right: 6px; } .tab .tl-short { display: none; }
.demo-ribbon { position: static; }

/* ---------- Thanh chọn kỳ: một hàng, vuốt ngang được ---------- */
.pbar { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; min-width: 0; flex: 1 1 auto; padding: 2px; }
.pbar::-webkit-scrollbar { display: none; } .pbar > * { flex: 0 0 auto; }
.toolbar2 { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.toolbar2 > .btn { flex: 0 0 auto; }

/* ---------- Chú thích màu gập / mở ---------- */
details.legends > summary { cursor: pointer; font-size: 13px; color: var(--ink-3); font-weight: 600; list-style: none; padding: 2px 0; }
details.legends > summary::-webkit-details-marker { display: none; }
details.legends > summary::after { content: ' ▾'; } details.legends[open] > summary::after { content: ' ▴'; }
details.legends[open] > summary { margin-bottom: 4px; }

/* ---------- Bấm dễ trên màn hình cảm ứng ---------- */
@media (pointer: coarse) {
  .btn, .btn.sm, .tab, .chip, .in, select.in, .iconbtn, .pk, .ocard, .step { min-height: 44px; }
  .btn.sm { padding-top: 8px; padding-bottom: 8px; }
  .iconbtn { width: 42px; height: 42px; }
  #mclose, #mback { min-width: 44px; min-height: 44px; font-size: 18px; }
  .star { min-width: 40px; min-height: 40px; }
  .menu button { padding: 13px 14px; }
  .tbl td { padding-top: 12px; padding-bottom: 12px; }
}
:focus-visible { outline: 3px solid var(--gold-1); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Máy tính bảng (dọc ≤ 1024px) ---------- */
@media (max-width: 1024px) {
  .wrap:not(.narrow) { padding-left: 14px; padding-right: 14px; }
  .stickytabs { margin-left: -14px !important; margin-right: -14px !important; padding-left: 14px !important; padding-right: 14px !important; }
  .logo .lt { white-space: nowrap; }
  .gsearch { flex: 1 1 260px; }
  .clockpill .cl-t { display: none; } .clockpill { padding: 7px; }
}

/* ---------- Điện thoại (≤ 760px) ---------- */
@media (max-width: 760px) {
  body { font-size: 15.5px; }
  .in, select.in, textarea.in, .gsearch input, input, select, textarea { font-size: 16px !important; } /* iPhone không tự phóng to khi gõ */
  .small, .legend, .legend small, .tag, .dchip, .sale-stats span, .muted.small { font-size: max(12px, 1em * .86); }
  .legend small { font-size: 12px; }
  .card { padding: 14px; border-radius: 14px; }
  .section-title { margin-top: 18px; }
  .toolbar { flex-direction: column; align-items: stretch; } .toolbar > .muted { flex: none; } .toolbar select.in { width: 100%; }
  .toolbar2 { flex-wrap: wrap; } .toolbar2 .pbar { flex-basis: 100%; order: 2; } .toolbar2 > .btn { margin-left: auto; }
  .row > select.in, .row > .in.sel { flex: 1 1 140px; min-width: 0; }
  .logo .lt { display: none; }
  .avbtn { padding: 2px !important; } .avbtn .hb { display: none; } .avbtn .av { margin: 0; }

  /* Hộp thoại phủ cả màn hình, tiêu đề dính trên */
  .modal { align-items: stretch; }
  .sheet { max-width: none; max-height: none; height: 100%; height: 100dvh; border-radius: 0; padding-bottom: env(safe-area-inset-bottom); }
  .sheet-h { padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top)); }
  .sheet-h h2 { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sheet-b { padding: 12px 12px 40px; }

  /* Lưới */
  .pgrid { grid-template-columns: 1fr; }
  .pkpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .chartc .ch-box { height: 240px !important; }
  #ch-sales, #ch-proj { min-height: 0; }
  .kv, .pinfo { grid-template-columns: 1fr; } .kv dt { margin-top: 6px; }
  .avedit { justify-content: center; text-align: center; } .avedit > div { justify-items: center; }
  .stickytabs { margin: -16px -16px 10px !important; padding: 8px 16px 6px !important; }
}

/* ---------- Sale trên điện thoại: thanh tab dưới đáy, bấm bằng ngón cái ---------- */
@media (max-width: 760px) {
  body.sale-ui { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  body.sale-ui .saletabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; margin: 0; background: rgba(255, 255, 255, .97); backdrop-filter: blur(8px);
    border-top: 1px solid var(--line); box-shadow: 0 -6px 18px rgba(42, 10, 13, .08); display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 0;
    padding: 4px 2px calc(4px + env(safe-area-inset-bottom)); overflow: visible; }
  body.sale-ui .saletabs .tab { border: 0; background: none; border-radius: 12px; padding: 6px 0 4px; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    font-size: 11px; font-weight: 600; color: var(--ink-3); position: relative; }
  body.sale-ui .saletabs .tab .ti { font-size: 21px; line-height: 1; margin: 0; }
  body.sale-ui .saletabs .tab .tl-long { display: none; } body.sale-ui .saletabs .tab .tl-short { display: inline; }
  body.sale-ui .saletabs .tab.on { color: var(--brand); background: var(--brand-soft); }
  body.sale-ui .saletabs .tab .c { position: absolute; top: 2px; left: calc(50% + 6px); margin: 0; min-width: 18px; padding: 0 5px; font-size: 10.5px; line-height: 17px; background: var(--brand); color: #fff; }
  body.sale-ui .saletabs .tab.on .c { background: var(--brand); color: #fff; }
  .sale-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .sale-stats b { font-size: 22px; }
  .lead { padding: 14px 14px 12px; }
  .lead .row .btn { min-width: 48px; }
}
/* Điện thoại nhỏ (iPhone SE, Android 360px) */
@media (max-width: 380px) {
  .sale-stats span { font-size: 11px; } .sale-stats b { font-size: 20px; }
  .pkpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body.sale-ui .saletabs .tab { font-size: 10px; }
  .g6, .g4 { gap: 8px; }
}
/* Laptop / màn rộng */
@media (min-width: 1500px) { .g6 { gap: 16px; } .charts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (pointer: coarse) {
  select.in.sm, .in.sel.sm, .in.sm { min-height: 44px; }
  .in, select.in, textarea.in, .gsearch input, input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea { font-size: 16px !important; } /* iPhone / iPad không tự phóng to khi gõ */
}

/* ---------- Bảng → thẻ: điện thoại (mọi bảng nhiều cột) và máy tính bảng (bảng rất nhiều cột, xếp 2 thẻ một hàng) ---------- */
@media (max-width: 760px) {
  .tbl.cardify, .tbl.cardify tbody { display: block; width: 100%; }
  .tbl.cardify thead, .tbl.cardify colgroup { display: none; }
  .tbl.cardify tr { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 12px; margin: 0 0 10px; padding: 8px 12px; background: #fffdf9; }
  .tbl.cardify tbody tr:nth-child(even) { background: #f7f0e5; }
  .tbl.cardify tbody tr td { display: block; position: relative; text-align: right; padding: 6px 0 6px 38%; min-height: 30px; border: 0; background: transparent !important; box-shadow: none !important; white-space: normal; width: auto !important; }
  .tbl.cardify td::before { content: attr(data-l); position: absolute; left: 0; top: 7px; width: 36%; text-align: left; color: var(--ink-3); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; line-height: 1.3; }
  .tbl.cardify td[data-l=""]::before { display: none; }
  .tbl.cardify td[data-l=""] { padding-left: 0; }
  .tbl.cardify td.td-main { order: -1; text-align: left; font-size: 16px; padding: 4px 0 8px; margin-bottom: 4px; border-bottom: 1px dashed var(--line); }
  .tbl.cardify td.td-main::before { display: none; }
  .tbl.cardify td .row, .tbl.cardify td.nowrap { justify-content: flex-end; white-space: normal; }
  .tbl.cardify td.td-main .row { justify-content: flex-start; }
  .tbl.cardify td .chain { justify-content: flex-end; }
  .tbl.cardify tr.click:active { background: #f1e3cf; }
  .tbl.cardify td:empty { display: none; }
  .card.tbl-wrap:has(> .tbl.cardify) { background: transparent; box-shadow: none; padding: 0; overflow: visible; }
}
@media (min-width: 761px) and (max-width: 1024px) {
  .tbl.cardify.wide, .tbl.cardify.wide tbody { display: block; width: 100%; }
  .tbl.cardify.wide thead, .tbl.cardify.wide colgroup { display: none; }
  .tbl.cardify.wide tr { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 12px; margin: 0 0 10px; padding: 8px 12px; background: #fffdf9; }
  .tbl.cardify.wide tbody tr:nth-child(even) { background: #f7f0e5; }
  .tbl.cardify.wide tbody tr td { display: block; position: relative; text-align: right; padding: 6px 0 6px 38%; min-height: 30px; border: 0; background: transparent !important; box-shadow: none !important; white-space: normal; width: auto !important; }
  .tbl.cardify.wide td::before { content: attr(data-l); position: absolute; left: 0; top: 7px; width: 36%; text-align: left; color: var(--ink-3); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; line-height: 1.3; }
  .tbl.cardify.wide td[data-l=""]::before { display: none; }
  .tbl.cardify.wide td[data-l=""] { padding-left: 0; }
  .tbl.cardify.wide td.td-main { order: -1; text-align: left; font-size: 16px; padding: 4px 0 8px; margin-bottom: 4px; border-bottom: 1px dashed var(--line); }
  .tbl.cardify.wide td.td-main::before { display: none; }
  .tbl.cardify.wide td .row, .tbl.cardify.wide td.nowrap { justify-content: flex-end; white-space: normal; }
  .tbl.cardify.wide td.td-main .row { justify-content: flex-start; }
  .tbl.cardify.wide td .chain { justify-content: flex-end; }
  .tbl.cardify.wide tr.click:active { background: #f1e3cf; }
  .tbl.cardify.wide td:empty { display: none; }
  .card.tbl-wrap:has(> .tbl.cardify.wide) { background: transparent; box-shadow: none; padding: 0; overflow: visible; }

  .tbl.cardify.wide tbody { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tbl.cardify.wide tr { margin: 0; }
}

.av i::before { content: attr(data-i); } /* chữ cái đầu vẽ bằng CSS để không lẫn vào tên khi đọc / chép chữ */
.kpi .v .stars-s { font-size: 22px; white-space: nowrap; letter-spacing: -1px; }
@media (max-width: 760px) { body.sale-ui .toast { bottom: calc(84px + env(safe-area-inset-bottom)); } .kpi .v .stars-s { font-size: 18px; } }

/* ===== Bản team · 24 tiếng · tương tác ===== */
.cd.paused { background: #eef0f3; color: #59708f; }
.tag.tstate { background: color-mix(in srgb, var(--c) 16%, #fff); color: color-mix(in srgb, var(--c) 70%, #222); border-color: color-mix(in srgb, var(--c) 40%, #fff); }
.formcount.draft { background: #fff4df; color: #9a6400; }
.btn.draftbtn { background: #fff4df; border-color: #f0d49c; color: #8a5a00; }
.passbox select optgroup { font-weight: 700; }
.touchbox .tgrp { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 8px 0; }
.touchbox .tgrp .tl { min-width: 150px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.touchbox .tgrp .tl b { margin-left: 4px; color: var(--ink); }
.rules ul { margin: 6px 0 0; padding-left: 18px; }
.rules li { margin: 3px 0; }
.teamtop { margin-bottom: 12px; }
.teams-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 12px; }
.teamcard { border-left: 4px solid var(--ok); }
.teamcard.invalid { border-left-color: var(--bad); }
.teamcard .tname { font-size: 16px; }
.tmrow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.tmrow:last-child { border-bottom: 0; }
.tmrow .rn { display: flex; flex-direction: column; min-width: 140px; flex: 1; }
.tmrow .tmact { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.zcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 10px; }
.zcard { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; border-top: 3px solid var(--line); }
.zcard.zalo { border-top-color: #2a78d6; }
.zcard.q { border-top-color: #1baf7a; }
.zcard.n { border-top-color: #86b6ef; }
.zcard.zgold { border-top-color: var(--accent); }
.zcard .zl { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.zcard .zv { margin: 6px 0 2px; }
.zcard .zv b { font-size: 30px; line-height: 1; }
.zcard .zv span { font-size: 14px; color: var(--ink-3); font-weight: 600; }
.zcard .zs { font-size: 12.5px; color: var(--ink-3); }
.zbig { font-size: 34px; font-weight: 800; margin-top: 6px; }
.zbig span { font-size: 14px; color: var(--ink-3); font-weight: 600; }
.tvz { margin: 18px 0; }
.tvz .zcard { background: rgba(255,255,255,.06); box-shadow: none; color: #fff; }
.tvz .zcard .zl, .tvz .zcard .zs, .tvz .zcard .zv span { color: rgba(255,255,255,.75); }
.tvz .zcard .zv b { font-size: 40px; color: #fff; }

/* ===== Ô tìm quận / tỉnh ===== */
.areabox { position: relative; margin-top: 8px; }
.areabox.hidden { display: none; }
.arealist { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); max-height: 260px; overflow-y: auto; padding: 4px; }
.arealist .ai-opt { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 10px 12px; border-radius: 8px; font-size: 15px; cursor: pointer; color: var(--ink); min-height: 40px; }
.arealist .ai-opt:hover, .arealist .ai-opt:focus { background: var(--bg); }
.arealist .ai-none { padding: 10px 12px; }
.areahint { font-size: 13px; margin-top: 6px; font-weight: 600; }
.areahint.ok { color: var(--ok); }
.areahint.need { color: var(--bad); }

/* ===== Chọn kỳ (nút nhanh + từ tháng … đến tháng) ===== */
.ppick { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.prange { gap: 6px; align-items: center; }
.prange input[type=month] { width: auto; min-width: 150px; padding: 6px 10px; }
.prange.on input[type=month] { border-color: var(--brand); }
/* ===== Xếp hạng nhân viên theo kỳ ===== */
.rankby { margin-bottom: 4px; }
.rklist { margin-top: 8px; }
.rkrow { display: grid; grid-template-columns: 34px 34px minmax(160px, 1.3fr) minmax(80px, 1fr) auto minmax(110px, auto); align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px dashed var(--line); cursor: pointer; }
.rkrow:last-child { border-bottom: 0; }
.rkrow:hover { background: var(--bg); }
.rkrow .rn { display: flex; flex-direction: column; min-width: 0; }
.rkbar, .pgbar { height: 10px; background: #f1e9df; border-radius: 99px; overflow: hidden; }
.rkbar i, .pgbar i { display: block; height: 100%; background: var(--gold-grad); border-radius: 99px; }
.rkv { text-align: right; white-space: nowrap; }
.rkd { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; text-align: right; }
.rkd.up { color: var(--ok); } .rkd.down { color: var(--bad); }
@media (max-width: 760px) {
  .rkrow { grid-template-columns: 30px 30px 1fr auto; }
  .rkrow .rkbar { grid-column: 3 / 5; }
  .rkrow .rkd { grid-column: 3 / 5; text-align: left; }
}
/* ===== Chân dung khách ===== */
.psum { margin: 10px 0 12px; line-height: 1.6; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); gap: 12px; }
.pgrow { display: grid; grid-template-columns: minmax(110px, 1.3fr) minmax(60px, 1fr) 34px 38px minmax(90px, auto); align-items: center; gap: 8px; width: 100%; border: 0; background: none; padding: 7px 6px; border-radius: 8px; cursor: pointer; text-align: left; color: var(--ink); font-size: 14px; min-height: 40px; }
.pgrow:hover { background: var(--bg); }
.pgrow.on { background: #fbeee0; box-shadow: inset 3px 0 0 var(--brand); }
.pgrow.none { opacity: .6; }
.pgrow .pgl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.pgrow .num { text-align: right; }
.pgrow .pgp { color: var(--ink-3); font-size: 12.5px; text-align: right; }
.pgrow .pgs { color: var(--ink-3); font-size: 12px; text-align: right; white-space: nowrap; }
@media (max-width: 760px) { .pgrow { grid-template-columns: 1fr 34px 38px; } .pgrow .pgbar { grid-column: 1 / 4; order: 5; } .pgrow .pgs { grid-column: 1 / 4; text-align: left; order: 6; } }
button.tag { cursor: pointer; border: 0; font: inherit; font-size: 13px; }

/* ---------- Tab Ảnh căn: công cụ vẽ ảnh thông tin căn 1080×1920 ---------- */
.cardtool { display: grid; grid-template-columns: minmax(320px, 420px) minmax(0, 1fr); gap: 18px; align-items: start; }
.ct-side { background: var(--card, #fff); border: 1px solid var(--line); border-radius: 18px; padding: 14px; display: grid; gap: 10px; min-width: 0; }
.ct-head { display: grid; gap: 2px; }
.ct-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.ct-tabs .btn { min-height: 42px; }
#ctform { display: grid; gap: 10px; min-width: 0; }
.ct-sec { font-weight: 700; font-size: 13px; color: var(--brand); margin-top: 6px; text-transform: uppercase; letter-spacing: .04em; }
.ct-f { display: grid; gap: 4px; min-width: 0; } .ct-f > span { font-size: 12.5px; color: var(--ink-3); }
.ct-f .in, .ct-row .in { width: 100%; min-width: 0; font-size: 16px; }
.ct-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ct-pal { display: flex; gap: 10px; flex-wrap: wrap; }
.ct-sw { width: 44px; height: 44px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; box-shadow: 0 0 0 1px var(--line); }
.ct-sw.on { border-color: #d8b36a; box-shadow: 0 0 0 2px #fff, 0 0 0 4px #d8b36a; }
.ct-row { display: flex; gap: 6px; align-items: center; min-width: 0; }
.ct-on { flex: none; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: transparent; font-weight: 800; cursor: pointer; }
.ct-on.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.ct-tot { font-weight: 700; color: var(--brand); font-size: 14px; }
.ct-slot { border: 1px dashed var(--line); border-radius: 14px; padding: 10px; display: grid; gap: 8px; background: rgba(0,0,0,.015); }
.ct-slot.has { border-style: solid; }
.ct-slot.over { border-color: var(--brand); background: var(--brand-soft); }
.ct-drop { display: flex; align-items: center; justify-content: center; text-align: center; min-height: 48px; border-radius: 10px; background: #fff; border: 1px solid var(--line);
  font-size: 13.5px; cursor: pointer; padding: 6px 10px; }
.ct-drop:hover { border-color: var(--brand); }
.ct-zoom { gap: 8px; flex-wrap: nowrap; } .ct-zoom input[type=range] { flex: 1; min-width: 0; height: 40px; }
.ct-box { border: 1px solid var(--line); border-radius: 14px; padding: 10px; display: grid; gap: 8px; }
.ct-vadj { display: grid; gap: 4px; border-top: 1px dashed var(--line); padding-top: 8px; } .ct-vadj .ct-zoom > .small:first-child, .ct-vadj > .row > .small:first-child { min-width: 78px; }
.ct-thumbs { display: grid; gap: 6px; }
.ct-tgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 6px; }
.ct-tgrid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; cursor: grab; border: 1px solid var(--line); }
.ct-pick { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; padding: 6px; background: var(--brand-soft); border-radius: 10px; }
.ct-main { position: sticky; top: 72px; display: grid; gap: 8px; min-width: 0; }
.ct-bar { gap: 8px; flex-wrap: wrap; }
.ct-mode { color: #b7791f; font-weight: 700; font-size: 13.5px; }
.ct-canvas { background: repeating-conic-gradient(#eee 0 25%, #f8f8f8 0 50%) 0 0 / 20px 20px; border-radius: 16px; padding: 10px; display: flex; justify-content: center; }
.ct-canvas canvas { display: block; width: min(100%, calc((100vh - 230px) * 9 / 16)); height: auto; border-radius: 10px; box-shadow: 0 12px 30px rgba(0,0,0,.25); touch-action: none; }
.ct-tip { text-align: center; }
@media (max-width: 900px) {
  .cardtool { grid-template-columns: minmax(0, 1fr); }
  .ct-main { position: static; order: -1; }
  .ct-canvas canvas { width: min(100%, calc(62vh * 9 / 16)); }
}
@media (max-width: 380px) {
  body.sale-ui .saletabs .tab { font-size: 10px; }
  .ct-2 { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Tab Tài chính (chỉ sếp) ---------- */
.fin { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
.fin > *, #fbody > *, .fin .grid > * { min-width: 0; }
#fbody { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
.fin .card { margin: 0; }
.fin-top { display: grid; gap: 10px; }
.fin-month { gap: 8px; flex-wrap: wrap; }
.fin-month select { max-width: 240px; }
.fin-views { gap: 6px; }
.fin-views .c { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 999px; background: var(--bad); color: #fff; font-size: 11px; line-height: 17px; text-align: center; }
.fin .pos { color: var(--ok); } .fin .neg { color: var(--bad); }
.fin-hero { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; align-items: center; color: #fff; border: 0;
  background: linear-gradient(135deg, #0f5132, #1c7a4c); }
.fin-hero.loss { background: linear-gradient(135deg, #6d1414, #b12a2a); }
.fh-l { font-size: 14px; opacity: .85; font-weight: 600; }
.fh-v { font-family: var(--display); font-size: 40px; font-weight: 700; letter-spacing: .02em; line-height: 1.15; }
.fh-v b { font-family: var(--display); }
.fh-s { font-size: 13px; opacity: .85; margin-top: 4px; }
.fh-side { display: grid; gap: 10px; }
.fh-side > div { background: rgba(255,255,255,.12); border-radius: 12px; padding: 10px 12px; display: grid; gap: 2px; }
.fh-side span { font-size: 12.5px; opacity: .85; } .fh-side b { font-size: 22px; } .fh-side i { font-size: 12px; opacity: .8; font-style: normal; }
.fin-hero .pos, .fin-hero .neg { color: #fff; }
.fin-kpis .kpi .v { font-size: 26px; }
.fin-mini { margin-top: 10px; gap: 8px; }
.fin-mini > div { background: var(--bg); border-radius: 12px; padding: 10px 12px; display: grid; gap: 2px; }
.fin-mini span { font-size: 12.5px; color: var(--ink-3); } .fin-mini b { font-size: 17px; }
.tbl.pl td { padding: 7px 10px; } .tbl.pl td.sub { padding-left: 30px; color: var(--ink-2); font-size: 13.5px; }
.tbl.pl tr.grp td { font-weight: 700; background: #faf5ec; }
.tbl.pl tr.tot td { font-weight: 700; border-top: 2px solid var(--line); }
.tbl.pl tr.net td { font-weight: 800; font-size: 15.5px; background: #f3ead9; border-top: 2px solid #ba8a57; }
.tbl.pl th:not(:first-child), .tbl.pl td.num { text-align: right; white-space: nowrap; }
.fin .fs { display: none; }
.fin-tools { gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.fin-tools #ftq { flex: 1 1 200px; min-width: 0; }
.tbl.ftx td.click { cursor: pointer; } .tbl.ftx td.click:hover b { text-decoration: underline; }
.tbl.ftx tr.unc { box-shadow: inset 3px 0 0 #eda100; }
.tbl.ftx select.fcat { min-width: 190px; max-width: 240px; }
.tbl tr.off td { opacity: .55; }
.tbl.fpay input.money { width: 100%; min-width: 110px; max-width: 160px; text-align: right; }
.tbl.fpay tr.tot td { font-weight: 700; background: #faf5ec; }
.fstaff { display: grid; gap: 6px; margin-top: 8px; }
.fstaff .row { gap: 8px; flex-wrap: nowrap; } .fstaff .rn { flex: 1; min-width: 0; }
.fstaff input.money { width: 170px; text-align: right; }
#fstf { gap: 8px; flex-wrap: wrap; } #fstf .in { flex: 1 1 160px; min-width: 0; }
.fin-form { display: grid; gap: 10px; }
.fpk { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); cursor: pointer; font-weight: 600; font-size: 14px; }
.fpk:has(input:checked) { border-color: var(--brand); background: #fbf5ef; box-shadow: inset 0 0 0 1px var(--brand); }
.fpk input { width: 18px; height: 18px; accent-color: var(--brand); }
.fsteps { margin: 8px 0 12px; padding-left: 20px; display: grid; gap: 6px; font-size: 14px; }
.fin .ct-f .row .in { flex: 1; min-width: 0; }
@media (max-width: 900px) { .fin-hero { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) {
  .fin .fx { display: none; } .fin .fs { display: inline; }
  .fh-v { font-size: 32px; }
  .fin-month select { flex: 1 1 160px; max-width: none; }
  .tbl.pl td, .tbl.pl th { padding: 6px 5px; font-size: 12.5px; } .tbl.pl td.sub { padding-left: 14px; font-size: 12px; }
  .tbl.ftx select.fcat { min-width: 0; max-width: 100%; width: 100%; }
  .tbl.fpay input.money { max-width: none; }
  .fstaff .row { flex-wrap: wrap; } .fstaff input.money { width: 100%; }
}
@media (max-width: 760px) { .tbl.pl th:nth-child(4), .tbl.pl td:nth-child(4) { display: none; } }
/* Chống tràn ngang trên điện thoại (bộ kiểm dò phần tử vượt mép màn hình) */
@media (max-width: 760px) {
  .legend span { white-space: normal; flex-wrap: wrap; }
  .chartc .tbl.cmp { display: block; overflow-x: auto; }
  .chartc .tbl.cmp td, .chartc .tbl.cmp th { white-space: normal; }
}
@media (max-width: 900px) { .sales-grid, .bot-grid { grid-template-columns: minmax(0, 1fr); } .sales-grid > * { min-width: 0; } }
/* Dự toán & hoà vốn */
.plan { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 12px; align-items: start; }
.plan-in, .plan-out { display: grid; gap: 12px; min-width: 0; grid-template-columns: minmax(0, 1fr); }
.plan-in > *, .plan-out > * { min-width: 0; }
.plan-out { position: sticky; top: 72px; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.plan .pval { font-size: 18px; padding-top: 8px; }
.pin { display: flex; align-items: center; gap: 4px; } .pin i { font-style: normal; color: var(--ink-3); }
.pin .in { width: 100%; text-align: right; }
.prow { display: grid; grid-template-columns: minmax(0, 1fr) 150px 130px 44px; gap: 6px; align-items: center; padding: 3px 0; border-bottom: 1px dashed var(--line); }
.prow .pname { min-width: 0; }
.prow .pamt { text-align: right; font-size: 13px; color: var(--ink-2); font-weight: 600; }
#pvar, #pfix { margin-bottom: 8px; }
.pl-line { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.pl-line b { text-align: right; } .pl-line.sub span { padding-left: 12px; color: var(--ink-2); }
.pl-line.tot { font-weight: 700; } .pl-line.net { font-weight: 800; font-size: 15.5px; border-bottom: 0; }
.fin-hero.pres { display: block; }
.tbl.psens tr.okrow td { background: #eaf6ee; } .tbl.psens tr.cur td { box-shadow: inset 0 2px 0 #ba8a57, inset 0 -2px 0 #ba8a57; font-weight: 700; }
.tbl.psens td.num, .tbl.pcmp td.num { text-align: right; white-space: nowrap; }
@media (max-width: 1100px) { .plan { grid-template-columns: minmax(0, 1fr); } .plan-out { position: static; } }
@media (max-width: 760px) {
  .prow { grid-template-columns: minmax(0, 1fr) auto 44px; grid-template-areas: "n n d" "v a a"; }
  .prow .pname { grid-area: n; } .prow .pin { grid-area: v; } .prow .pamt { grid-area: a; } .prow button { grid-area: d; }
}

/* ---------- Màu giao diện (Cài đặt → Màu giao diện) ---------- */
html[data-theme="white"] { --bg: #f4f5f7; --line: #e4e6ea; --brand-soft: #f6e6e1; }
html[data-theme="silver"] { --bg: #e9ebee; --line: #d8dce2; --brand: #3d4552; --brand-2: #2b313b; --brand-deep: #161a20; --brand-soft: #e3e7ee; --ink: #161a20; --ink-2: #444c58; --ink-3: #757d89;
  --hero-grad: linear-gradient(135deg, #161a20 0%, #3d4552 50%, #161a20 100%); }
html[data-theme="navy"] { --bg: #edf1f7; --line: #dae1ec; --brand: #1d3160; --brand-2: #15264d; --brand-deep: #0b1834; --brand-soft: #e3e9f5; --ink: #0f1a33; --ink-2: #3c4760; --ink-3: #6f7a90;
  --hero-grad: linear-gradient(135deg, #0b1834 0%, #1d3160 50%, #0b1834 100%); }
html[data-theme="green"] { --bg: #eef4f0; --line: #d9e6dd; --brand: #1f5a43; --brand-2: #174633; --brand-deep: #0a2219; --brand-soft: #e1efe6; --ink: #0d2219; --ink-2: #3b5248; --ink-3: #6c8277;
  --hero-grad: linear-gradient(135deg, #0a2219 0%, #1f5a43 50%, #0a2219 100%); }
html[data-theme="plum"] { --bg: #f2eff8; --line: #e1dbee; --brand: #4a2f7a; --brand-2: #3a2462; --brand-deep: #1c1033; --brand-soft: #ebe4f6; --ink: #1c1033; --ink-2: #4a3f60; --ink-3: #7d7290;
  --hero-grad: linear-gradient(135deg, #1c1033 0%, #4a2f7a 50%, #1c1033 100%); }
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.theme-sw { display: grid; gap: 6px; justify-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); cursor: pointer; font-size: 13px; font-weight: 600; min-height: 44px; }
.theme-sw i { width: 100%; height: 34px; border-radius: 8px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.theme-sw.on { border-color: var(--brand); box-shadow: inset 0 0 0 2px var(--brand); }
.clog { display: grid; gap: 12px; } .clog-i ul { margin: 6px 0 0; padding-left: 20px; } .clog-i .row { gap: 8px; }
.lang-sw { display: flex; gap: 6px; justify-content: center; margin-top: 12px; }
/* ---------- Cài đặt cá nhân + danh bạ ---------- */
.psettings { display: grid; gap: 12px; }
.psettings .card { margin: 0; }
.prof-top { gap: 14px; flex-wrap: nowrap; margin-bottom: 10px; } .prof-top .av { --s: 76px; } .prof-name { font-size: 19px; }
.psettings textarea.in { width: 100%; resize: vertical; }
.ver { font-size: 18px; }

.dc-main { flex: 1; min-width: 0; } .dc-links { display: flex; flex-wrap: wrap; gap: 6px; } .dc-bio { color: var(--ink-2); }
#dirq { width: 100%; }

/* =====================================================================
   v2.8 – tour hướng dẫn · thống kê · danh bạ theo team · màu tối · chân trang · canh chỉnh di động
   ===================================================================== */
/* ---------- Chân trang: phiên bản + developed by (nằm cuối trang, không đè nội dung) ---------- */
#appfoot { display: flex; justify-content: flex-end; align-items: center; gap: 10px; padding: 10px 16px calc(14px + env(safe-area-inset-bottom)); max-width: 1880px; margin: 0 auto; }
#appfoot .dev { font-size: 11.5px; color: var(--ink-3); letter-spacing: .02em; }
#verbadge { border: 1px solid var(--line); background: var(--paper); color: var(--ink-3); font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; cursor: pointer; min-height: 28px; }
#verbadge.new { position: fixed; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 26; background: var(--gold-grad); color: var(--brand-deep); border-color: transparent; font-size: 13px; padding: 8px 14px; box-shadow: 0 6px 18px rgba(0,0,0,.25); }
body.sale-ui #appfoot { padding-bottom: 14px; }
@media (max-width: 760px) { body.sale-ui #verbadge.new { bottom: calc(80px + env(safe-area-inset-bottom)); } }
body:has(.auth) #appfoot, body:has(.tv) #appfoot { position: fixed; right: 0; bottom: 0; background: transparent; }
body:has(.auth) #appfoot .dev, body:has(.tv) #appfoot .dev { color: rgba(255,255,255,.55); }
body:has(.tv) #appfoot { display: none; }
.devby { margin: 6px 0 2px; color: var(--ink-3); letter-spacing: .02em; }
.devby b { color: var(--accent); letter-spacing: .08em; }

/* ---------- Nút ? (tour) trên thanh trên ---------- */
.helpbtn { font-weight: 800; font-family: var(--display); font-size: 19px; line-height: 1; }

/* ---------- Tour hướng dẫn ---------- */
.tour { position: fixed; inset: 0; z-index: 90; }
.tour-block { position: absolute; inset: 0; }
.tour-spot { position: fixed; border-radius: 12px; box-shadow: 0 0 0 3px var(--gold-2), 0 0 0 9999px rgba(12, 8, 6, .66); transition: left .25s, top .25s, width .25s, height .25s; pointer-events: none; }
.tour-spot.none { box-shadow: 0 0 0 9999px rgba(12, 8, 6, .66); }
.tour-pop { position: fixed; width: min(380px, calc(100vw - 16px)); background: var(--paper); color: var(--ink); border-radius: 16px; padding: 14px 16px 14px; box-shadow: 0 20px 50px rgba(0,0,0,.4);
  border-top: 4px solid transparent; background: linear-gradient(var(--paper), var(--paper)) padding-box, var(--gold-grad) border-box; animation: tourIn .2s ease-out; }
.tour-pop.sheet-like { width: auto; }
@keyframes tourIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.tour-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tour-n { font-size: 12px; font-weight: 700; color: var(--ink-3); letter-spacing: .06em; }
.tour-x { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font-size: 17px; cursor: pointer; display: grid; place-items: center; margin: -4px -6px 0 0; }
.tour-x:hover { border-color: var(--ink-3); }
.tour-t { margin: 4px 0 6px; font-family: var(--display); font-size: 19px; font-weight: 600; letter-spacing: .01em; color: var(--ink); }
.tour-b { font-size: 14.5px; line-height: 1.55; color: var(--ink-2); }
.tour-b b { color: var(--ink); }
.tour-dots { display: flex; flex-wrap: wrap; gap: 4px; margin: 12px 0 10px; }
.tour-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.tour-dots i.done { background: var(--gold-1); } .tour-dots i.on { background: var(--brand); width: 18px; border-radius: 4px; }
.tour-f { display: flex; gap: 8px; justify-content: space-between; }
.tour-f .btn { flex: 1; min-height: 44px; }
.tourcard .tc-ic { font-size: 30px; }
.tourcard .row { gap: 12px; }
@media (max-width: 480px) { .tourcard .row { flex-wrap: wrap !important; } .tourcard .btn { width: 100%; } }

/* ---------- "Thêm" trên thanh tab dưới đáy + lưới "Tất cả mục" ---------- */
.moretab, .alltabs { display: none; }
.moresheet { position: fixed; left: 8px; right: 8px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 31; background: var(--paper); border-radius: 18px; padding: 12px; box-shadow: 0 -4px 30px rgba(0,0,0,.25); border: 1px solid var(--line); animation: tourIn .15s ease-out; }
.ms-h { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); margin: 0 4px 8px; }
.ms-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ms-grid.big { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.ms-i { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 78px; padding: 10px 6px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); color: var(--ink); font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; text-align: center; }
.ms-i .ti { font-size: 24px; line-height: 1; }
.ms-i.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.ms-i .c { position: absolute; top: 6px; right: 8px; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--brand); color: #fff; font-size: 11.5px; line-height: 19px; }
@media (max-width: 760px) {
  body.sale-ui .saletabs { grid-template-columns: repeat(5, minmax(0, 1fr)) !important; }
  body.sale-ui .saletabs .tab.more-item { display: none !important; }
  body.sale-ui .saletabs .moretab { display: flex; }
  body.sale-ui .saletabs .tab { font-size: 11.5px; }
}
@media (min-width: 761px) { body.sale-ui .saletabs { flex-wrap: wrap; overflow: visible; } }
@media (max-width: 1024px) {
  .alltabs { display: inline-flex; align-items: center; position: sticky; left: 0; z-index: 2; background: var(--brand); color: #fff; border-color: var(--brand); box-shadow: 6px 0 10px -4px var(--bg); }
  .alltabs .ti { margin-right: 6px; }
}
@media (max-width: 480px) { .alltabs .at-l { display: none; } .alltabs .ti { margin: 0; } }

/* ---------- Thống kê / Hiệu suất ---------- */
.stx { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
.stx > * { min-width: 0; margin: 0; }
.stx-top { display: grid; gap: 10px; }
.stx-seg .btn { min-height: 42px; }
.stx-pick { display: grid; gap: 4px; max-width: 420px; }
.stx-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin: 2px 2px -2px; }
.stx-head h2 { margin: 0; font-family: var(--display); font-weight: 600; font-size: 22px; letter-spacing: .01em; }
.stx-kpis { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 1400px) { .stx-kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); } .stx-kpis .kpi:last-child { grid-column: span 1; } }
@media (max-width: 1100px) { .stx-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.stx-kpis .kpi { padding: 12px 14px; }
.stx-kpis .kpi .v { font-size: 30px; }
.stx-kpis .kpi .s { display: flex; justify-content: space-between; gap: 6px; flex-wrap: wrap; }
.stx-g2 { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; }
.stx-g2 > * { min-width: 0; }
.pf-list { display: grid; gap: 4px; margin-top: 10px; }
.pf-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.pf-row:last-child { border-bottom: 0; }
.pf-l { display: flex; flex-direction: column; min-width: 0; } .pf-l b { font-size: 14.5px; }
.pf-v { display: flex; align-items: center; gap: 8px; justify-content: flex-end; } .pf-v b { font-size: 17px; }
.pf-bar { grid-column: 1 / -1; height: 6px; margin-top: 4px; }
.tag.pf-good { background: rgba(27,175,122,.15); color: #138a5f; } .tag.pf-ok { background: rgba(237,161,0,.16); color: #a46d00; } .tag.pf-low { background: rgba(208,59,59,.13); color: #b8302f; }
.pf-all { font-weight: 800; font-size: 14px; color: #fff; background: var(--c); padding: 4px 12px; border-radius: 999px; }
.sh-list { display: grid; gap: 10px; margin-top: 10px; }
.sh-row { display: grid; gap: 4px; } .sh-list > .sh-row:has(> span + b) { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.stx-tools { display: grid; gap: 8px; margin: 10px 0; }
.stx-tools .seg .c { display: inline-block; min-width: 18px; padding: 0 6px; margin-left: 2px; border-radius: 999px; background: var(--bg); color: var(--ink); font-size: 11.5px; }
.stx-tools .btn.primary .c { background: rgba(255,255,255,.22); color: inherit; }
.stx-tools2 { flex-wrap: nowrap; } .stx-tools2 .in { flex: 1 1 200px; min-width: 0; } .stx-tools2 select.in { flex: 0 1 260px; }
.sclist { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 10px; }
.scust { display: grid; gap: 6px; text-align: left; width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: 14px; background: var(--paper); color: var(--ink); font: inherit; cursor: pointer; min-height: 44px; }
.scust:hover { box-shadow: var(--shadow); }
.sc-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; } .sc-name { font-size: 16px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sc-meta { display: flex; flex-wrap: wrap; gap: 4px; } .sc-meta .tag { white-space: normal; }
.stx-tbl td .pgbar { margin-top: 4px; height: 6px; min-width: 60px; }
#stmore { margin-top: 10px; }
@media (max-width: 1000px) { .stx-g2 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) {
  .stx-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 8px; } .stx-kpis .kpi:last-child { grid-column: span 2; }
  .stx-kpis .kpi .v { font-size: 26px; }
  .stx-head h2 { font-size: 19px; }
  .stx-tools2 { flex-wrap: wrap; } .stx-tools2 select.in, .stx-tools2 .in { flex: 1 1 100%; }
  .stx-seg { display: grid; grid-template-columns: 1fr 1fr; } .stx-pick { max-width: none; }
  .sclist { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Danh bạ: nhóm theo team, cùng màu ---------- */
.dgroup { margin-top: 14px; }
.dg-h { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.dg-h i { width: 12px; height: 12px; border-radius: 4px; background: var(--tc); }
.dg-h b { color: var(--tc); font-size: 15px; letter-spacing: .02em; }
.dirlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); gap: 10px; }
.dcard { border: 1px solid var(--line); border-left: 5px solid var(--tc); border-radius: 14px; padding: 12px; display: grid; gap: 8px; cursor: pointer;
  background: linear-gradient(90deg, color-mix(in srgb, var(--tc) 9%, var(--paper)), var(--paper) 55%); transition: box-shadow .15s, transform .15s; }
.dcard:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.dcard.me { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--tc) 45%, transparent); }
.dc-main { flex: 1; min-width: 0; } .dc-main b { font-size: 15.5px; }
.dc-links { display: flex; flex-wrap: wrap; gap: 6px; }
.teamchip { display: inline-block; margin-top: 4px; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; color: var(--tc); background: color-mix(in srgb, var(--tc) 14%, transparent); border: 1px solid color-mix(in srgb, var(--tc) 35%, transparent); }
#dirq { width: 100%; margin-top: 8px; }
.person { display: grid; gap: 12px; }
.pp-top { display: flex; align-items: center; gap: 16px; padding: 14px; border-radius: 16px; background: linear-gradient(135deg, color-mix(in srgb, var(--tc) 16%, var(--paper)), var(--paper)); border-left: 5px solid var(--tc); }
.pp-top .av.xl { --s: 92px; }
.pp-name { font-family: var(--display); font-size: 24px; font-weight: 600; }
.pp-acts { display: flex; flex-wrap: wrap; gap: 8px; } .pp-acts .btn { flex: 1 1 150px; min-height: 46px; }
.pp-info { display: grid; gap: 10px; }
.pp-r { display: flex; gap: 12px; align-items: flex-start; } .pp-ic { font-size: 20px; width: 28px; text-align: center; } .pp-v { font-size: 15.5px; word-break: break-word; white-space: pre-line; }
.pp-mates .row { margin-top: 6px; gap: 6px; }
.th-g { font-size: 12.5px; font-weight: 700; color: var(--ink-3); margin: 10px 0 6px; letter-spacing: .02em; }
.th-g:first-of-type { margin-top: 0; }

/* ---------- Canh chỉnh điện thoại / iPad / máy tính bảng ---------- */
@media (max-width: 760px) {
  .small, .muted.small { font-size: 13.5px; }
  .tag { font-size: 12.5px; padding: 4px 9px; }
  .sale-stats span { font-size: 12px; line-height: 1.25; display: block; }
  .sale-stats div { padding: 9px 4px; }
  .hello b { font-size: 17px; }
  .lead .nm { font-size: 19px; }
  .lead .ph { font-size: 16px; }
  .card h3 { font-size: 18px; }
  .kpi .l { font-size: 13.5px; }
  .tab { font-size: 14.5px; }
  .menu { left: 8px; right: 8px; top: 60px; min-width: 0; }
  .npop { left: 8px; right: 8px; width: auto; }
  .toolbar .muted.small { line-height: 1.45; }
  .dc-links .btn { flex: 1 1 auto; }
  .pp-top { flex-direction: column; text-align: center; } .pp-acts .btn { flex: 1 1 100%; }
  .themes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 761px) and (max-width: 1024px) {
  body { font-size: 15.5px; }
  .wrap.narrow { max-width: 760px; }
  .tab { padding: 10px 16px; font-size: 15px; }
  .btn { min-height: 44px; } .btn.sm { min-height: 40px; }
  .g6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi .v { font-size: 30px; }
  .sheet { max-width: 92vw; }
}
/* Máy tính bảng nằm ngang / laptop nhỏ: thanh trên gọn lại */
@media (max-width: 1180px) { .gsearch { flex-basis: 300px; } }
@media (orientation: landscape) and (max-height: 520px) {
  /* điện thoại xoay ngang: thanh tab dưới thấp lại để còn chỗ xem nội dung */
  body.sale-ui .saletabs .tab { min-height: 44px !important; padding: 3px 0 !important; } body.sale-ui .saletabs .tab .ti { font-size: 18px !important; }
  .tour-pop { max-height: calc(100vh - 16px); overflow: auto; }
}

/* =====================================================================
   MÀU TỐI (Cài đặt → Màu giao diện → Tối)
   ===================================================================== */
html[data-theme="onyx"] { --bg: #0f0f11; --paper: #19191c; --paper-2: #222226; --line: #2f2d2a; --ink: #f2ede4; --ink-2: #cfc6b8; --ink-3: #978e81; --topbar: #141416;
  --brand: #c9a45c; --brand-2: #e0bd77; --brand-deep: #0b0b0c; --brand-soft: rgba(201,164,92,.14); --accent: #d4af6a; --gold-1: #c9a45c; --gold-2: #e8c38f; --on-brand: #17120a;
  --hero-grad: linear-gradient(135deg, #0b0b0c 0%, #26221b 50%, #0b0b0c 100%); }
html[data-theme="midnight"] { --bg: #0a1220; --paper: #111b2e; --paper-2: #18243b; --line: #24324c; --ink: #eef2f8; --ink-2: #c3cbd9; --ink-3: #8a96ab; --topbar: #0d1729;
  --brand: #d1a866; --brand-2: #e4c085; --brand-deep: #070d18; --brand-soft: rgba(209,168,102,.14); --accent: #d1a866; --gold-1: #c99d58; --gold-2: #e8c38f; --on-brand: #141006;
  --hero-grad: linear-gradient(135deg, #070d18 0%, #16243f 50%, #070d18 100%); }
html[data-theme="emerald"] { --bg: #08130f; --paper: #0f1d18; --paper-2: #152822; --line: #213b31; --ink: #ecf4ef; --ink-2: #bfd1c6; --ink-3: #86998e; --topbar: #0b1914;
  --brand: #c9a45c; --brand-2: #e0bd77; --brand-deep: #050c09; --brand-soft: rgba(201,164,92,.13); --accent: #d4af6a; --gold-1: #c9a45c; --gold-2: #e8c38f; --on-brand: #17120a;
  --hero-grad: linear-gradient(135deg, #050c09 0%, #143027 50%, #050c09 100%); }
html[data-theme="wine"] { --bg: #120a0c; --paper: #1d1215; --paper-2: #27181c; --line: #3b242a; --ink: #f6ece9; --ink-2: #d8c5c1; --ink-3: #a08a86; --topbar: #4a121a;
  --brand: #d4ad6a; --brand-2: #e6c486; --brand-deep: #0c0607; --brand-soft: rgba(212,173,106,.14); --accent: #d4ad6a; --gold-1: #c99d58; --gold-2: #e8c38f; --on-brand: #1a1108;
  --hero-grad: linear-gradient(135deg, #0c0607 0%, #4a121a 50%, #0c0607 100%); }
html.dark { color-scheme: dark; --ok: #4cc38a; --ok-soft: rgba(76,195,138,.15); --warn: #e8a94e; --warn-soft: rgba(232,169,78,.15); --bad: #f07272; --bad-soft: rgba(240,114,114,.15);
  --ice: #82acea; --ice-soft: rgba(130,172,234,.15); --shadow: 0 1px 2px rgba(0,0,0,.45), 0 8px 24px rgba(0,0,0,.32); --stripe: rgba(255,255,255,.028); --hover: rgba(255,255,255,.06); }
html.dark .topbar { background: var(--topbar); box-shadow: 0 1px 0 rgba(201,164,92,.35), 0 2px 14px rgba(0,0,0,.5); }
html.dark .btn.primary, html.dark .tab.on, html.dark .chip.on, html.dark .ocard.on, html.dark .ocard.on b, html.dark .ocard.on span, html.dark .ocard.on i, html.dark .ct-on.on, html.dark .fnum,
html.dark .pf-all, html.dark .alltabs, html.dark .ms-i .c, html.dark body.sale-ui .saletabs .tab .c { color: var(--on-brand) !important; }
html.dark .btn.primary:hover { background: var(--brand-2); }
html.dark .tab.on .c { background: var(--on-brand); color: var(--brand); }
html.dark input.in, html.dark select.in, html.dark textarea.in, html.dark .chip, html.dark .opt, html.dark .ocard, html.dark .origin, html.dark .arealist, html.dark .ct-drop, html.dark .ct-on,
html.dark .handover.live, html.dark .ct-side, html.dark .avpick > i { background: var(--paper-2); color: var(--ink); }
html.dark .ocard.hero { background: linear-gradient(var(--paper-2), var(--paper-2)) padding-box, var(--gold-grad) border-box; }
html.dark .banner { background: rgba(232,169,78,.1); border-color: rgba(232,169,78,.3); }
html.dark .handover { background: var(--paper-2); border-color: var(--line); }
html.dark .tbl td { border-bottom-color: var(--line); }
html.dark .tbl tbody tr:nth-child(odd) td { background: transparent; }
html.dark .tbl tbody tr:nth-child(even) td { background: var(--stripe); }
html.dark .tbl tbody tr:nth-child(even) td:first-child { box-shadow: inset 3px 0 0 var(--line); }
html.dark .tbl tr.click:hover td, html.dark .rrow:hover, html.dark .rkrow:hover, html.dark .pgrow:hover { background: var(--hover) !important; }
html.dark .rrow { border-bottom-color: var(--line); } html.dark .rrow:nth-child(even of .rrow) { background: var(--stripe); }
html.dark #leadlist .hist:nth-child(even) { background: var(--paper); }
html.dark .ai-line, html.dark .tl-ai { background: rgba(201,164,92,.1); color: #e2c48e; }
html.dark .goal, html.dark .dealf, html.dark .demo-hint { background: rgba(201,164,92,.08); border-color: rgba(201,164,92,.28); }
html.dark .msg.in { background: rgba(130,172,234,.12); } html.dark .msg.out { background: rgba(201,164,92,.1); }
html.dark .cd.frozen, html.dark .cd.paused { background: rgba(130,172,234,.14); color: #a9c4ee; }
html.dark .pk.on, html.dark .fpk:has(input:checked) { background: var(--brand-soft); }
html.dark .pgrow.on { background: var(--brand-soft); }
html.dark .rkbar, html.dark .pgbar, html.dark .bar, html.dark .progress { background: rgba(255,255,255,.08); }
html.dark .chain .ch { background: var(--paper-2); }
html.dark .chain .ch.ok { background: rgba(76,195,138,.12); border-color: rgba(76,195,138,.4); } html.dark .chain .ch.ok i { color: var(--ok); }
html.dark .chain .ch.bad { background: rgba(240,114,114,.12); border-color: rgba(240,114,114,.4); } html.dark .chain .ch.bad i { color: var(--bad); }
html.dark .chain .ch.warn { background: rgba(232,169,78,.12); border-color: rgba(232,169,78,.4); } html.dark .chain .ch.warn i { color: var(--warn); }
html.dark .chain .ch.ice { background: rgba(130,172,234,.12); border-color: rgba(130,172,234,.4); } html.dark .chain .ch.ice i { color: var(--ice); }
html.dark .formcount.draft, html.dark .btn.draftbtn { background: rgba(232,169,78,.14); color: #f0bf6e; border-color: rgba(232,169,78,.35); }
html.dark .lead.helping { background: linear-gradient(90deg, rgba(201,164,92,.1), var(--paper) 40%); }
html.dark .tbl.cardify tr, html.dark .tbl.cardify.wide tr { background: var(--paper) !important; }
html.dark .tbl.cardify tbody tr:nth-child(even), html.dark .tbl.cardify.wide tbody tr:nth-child(even) { background: var(--paper-2) !important; }
html.dark .tbl.pl tr.grp td, html.dark .tbl.fpay tr.tot td { background: rgba(201,164,92,.07); } html.dark .tbl.pl tr.net td { background: rgba(201,164,92,.14); }
html.dark .tbl.psens tr.okrow td { background: rgba(76,195,138,.1); }
html.dark body.sale-ui .saletabs { background: color-mix(in srgb, var(--paper) 96%, transparent); border-top-color: var(--line); box-shadow: 0 -6px 18px rgba(0,0,0,.4); }
html.dark .stars-s i { color: #4a453e; } html.dark .star { color: #4a453e; } html.dark .star.on { color: var(--accent); }
html.dark .rank.r2 { background: #6f6a63; }
html.dark .dot { box-shadow: 0 0 0 2px var(--paper), 0 0 0 3px rgba(255,255,255,.08); }
html.dark .av { box-shadow: 0 0 0 2px var(--paper), 0 1px 3px rgba(0,0,0,.4); background: hsl(var(--h) 30% 26%); color: hsl(var(--h) 60% 82%); }
html.dark .tag.tstate { background: color-mix(in srgb, var(--c) 18%, transparent); color: color-mix(in srgb, var(--c) 70%, #fff); border-color: color-mix(in srgb, var(--c) 40%, transparent); }
html.dark .btn.danger, html.dark .danger-card { border-color: rgba(240,114,114,.4); }
html.dark .toast { background: #2a2a2e; color: #f4efe6; border: 1px solid var(--line); } html.dark .toast.bad { background: #7a2323; }
html.dark .gsearch input:focus, html.dark .gsearch.open input { background: var(--paper-2); color: var(--ink); }
@media (max-width: 760px) { html.dark .gsearch input { background: var(--paper-2); color: var(--ink); } }
html.dark .ct-canvas { background: repeating-conic-gradient(#1e1e21 0 25%, #26262a 0 50%) 0 0 / 20px 20px; }
html.dark .pc-in .tag { background: rgba(0,0,0,.55); color: var(--gold-2); }
html.dark .handover .hh, html.dark .kv dd { color: var(--ink); }
html.dark .tag.pf-good { color: #5fd3a0; } html.dark .tag.pf-ok { color: #f0bd5c; } html.dark .tag.pf-low { color: #f38b8b; }
html.dark .menu, html.dark .sres, html.dark .npop, html.dark .moresheet { border: 1px solid var(--line); }
html.dark .fin-hero { box-shadow: var(--shadow); }
html.dark .dcard { background: linear-gradient(90deg, color-mix(in srgb, var(--tc) 14%, var(--paper)), var(--paper) 55%); }
html.dark .np-i.unread { background: var(--brand-soft); }
html.dark ::selection { background: rgba(201,164,92,.35); }
html.dark .theme-sw i { box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
html.dark .kpi.gold .v { color: var(--gold-2); }
html.dark .ocard.rec { border-color: rgba(76,195,138,.4); }
html.dark .step.on { border-color: rgba(76,195,138,.4); }
html.dark .chip.on, html.dark .ocard.on, html.dark .ct-on.on, html.dark .opt.on { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
html.dark .opt.on { background: var(--brand-soft); color: var(--ink); }
html.dark .star { color: #6f685d; }
@media (max-width: 760px) {
  html.dark body.sale-ui .saletabs .tab.on, html.dark body.sale-ui .saletabs .tab.on span:not(.c) { color: var(--brand) !important; }
  html.dark body.sale-ui .saletabs .tab .c { background: var(--brand); }
}
html.dark .rank { background: var(--paper-2); color: var(--ink); } html.dark .rank.r1, html.dark .rank.r2, html.dark .rank.r3 { color: #17120a; }
html.dark .tier-t { color: color-mix(in srgb, var(--c) 55%, #fff); border-color: color-mix(in srgb, var(--c) 60%, #fff); }
html.dark .fin-views .c { background: #c43c3c; }

/* ---------- Anh Lành AI: nút chat nổi + khung chat ---------- */
.botfab { position: fixed; z-index: 35; width: 58px; height: 58px; border-radius: 50%; border: 0; padding: 0; cursor: grab; touch-action: none; user-select: none;
  background: var(--gold-grad); box-shadow: 0 8px 22px rgba(0,0,0,.28), 0 0 0 3px var(--paper); display: grid; place-items: center; transition: transform .15s; }
.botfab .av { --s: 50px; margin: 0; box-shadow: none; }
.botfab .bf-ic { font-size: 28px; }
.botfab .bf-ai { position: absolute; right: -4px; bottom: -2px; font-size: 10.5px; font-weight: 800; letter-spacing: .04em; background: var(--brand); color: #fff; padding: 2px 6px; border-radius: 999px; box-shadow: 0 0 0 2px var(--paper); }
html.dark .botfab .bf-ai { color: var(--on-brand); }
.botfab:hover { transform: scale(1.05); } .botfab.open { transform: scale(.94); } .botfab.dragging { cursor: grabbing; transform: scale(1.1); transition: none; opacity: .92; }
.botfab[data-c="br"] { right: 16px; bottom: calc(52px + env(safe-area-inset-bottom)); } .botfab[data-c="bl"] { left: 16px; bottom: calc(52px + env(safe-area-inset-bottom)); }
.botfab[data-c="tr"] { right: 16px; top: calc(var(--tbh, 56px) + 60px); } .botfab[data-c="tl"] { left: 16px; top: calc(var(--tbh, 56px) + 60px); }
.botpanel { position: fixed; z-index: 36; width: min(400px, calc(100vw - 24px)); height: min(600px, calc(100vh - 130px)); display: flex; flex-direction: column; background: var(--paper); color: var(--ink);
  border-radius: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.35); border: 1px solid var(--line); overflow: hidden; animation: tourIn .18s ease-out; }
.botpanel[hidden] { display: none; }
.botpanel[data-c="br"] { right: 16px; bottom: calc(120px + env(safe-area-inset-bottom)); } .botpanel[data-c="bl"] { left: 16px; bottom: calc(120px + env(safe-area-inset-bottom)); }
.botpanel[data-c="tr"] { right: 16px; top: calc(var(--tbh, 56px) + 128px); } .botpanel[data-c="tl"] { left: 16px; top: calc(var(--tbh, 56px) + 128px); }
.bp-h { display: flex; align-items: center; gap: 8px; padding: 12px 12px 10px 14px; background: var(--hero-grad); color: #fff; }
.bp-h .av { margin: 0; box-shadow: 0 0 0 2px var(--gold-2); }
.bp-t { flex: 1; min-width: 0; display: flex; flex-direction: column; } .bp-t b { font-family: var(--display); font-size: 17px; letter-spacing: .02em; } .bp-t span { font-size: 11.5px; color: var(--gold-2); }
.bp-x { width: 40px; height: 40px; border-radius: 50%; border: 1px solid rgba(232,195,143,.45); background: transparent; color: #fff; cursor: pointer; font-size: 15px; flex: none; }
.bp-msgs { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; background: var(--bg); overscroll-behavior: contain; }
.bm { display: flex; } .bm.me { justify-content: flex-end; }
.bb { max-width: 86%; padding: 9px 12px; border-radius: 14px; font-size: 14.5px; line-height: 1.5; background: var(--paper); border: 1px solid var(--line); border-bottom-left-radius: 4px; word-break: break-word; }
.bm.me .bb { background: var(--brand); color: #fff; border-color: var(--brand); border-bottom-left-radius: 14px; border-bottom-right-radius: 4px; }
html.dark .bm.me .bb { color: var(--on-brand); }
.bm.typing .bb { display: flex; gap: 4px; padding: 12px 14px; } .bm.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); animation: bdot 1s infinite; }
.bm.typing i:nth-child(2) { animation-delay: .15s; } .bm.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes bdot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.bp-sug { display: flex; gap: 6px; overflow-x: auto; padding: 8px 10px 0; scrollbar-width: none; background: var(--paper); }
.bp-sug::-webkit-scrollbar { display: none; } .bp-sug .chip { white-space: nowrap; font-size: 13px; min-height: 36px; padding: 6px 11px; }
.bp-in { display: flex; gap: 8px; padding: 10px; background: var(--paper); border-top: 1px solid var(--line); margin-top: 8px; }
.bp-in textarea { flex: 1; min-height: 44px; max-height: 120px; resize: none; padding: 10px 12px; }
.bp-in .btn { min-width: 48px; font-size: 18px; }
@media (max-width: 760px) {
  body.sale-ui .botfab[data-c="br"], body.sale-ui .botfab[data-c="bl"] { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .botfab { width: 52px; height: 52px; } .botfab .av { --s: 44px; }
  .botpanel { left: 0 !important; right: 0 !important; top: auto !important; bottom: 0 !important; width: 100%; height: min(82vh, calc(100dvh - 60px)); border-radius: 18px 18px 0 0; z-index: 60; padding-bottom: env(safe-area-inset-bottom); }
}
body.tour-on .botfab, body.tour-on .botpanel { display: none; }
/* Công tắc bật / tắt */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch span { width: 50px; height: 30px; border-radius: 999px; background: var(--line); position: relative; transition: background .2s; flex: none; }
.switch span::after { content: ''; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.25); transition: left .2s; }
.switch input:checked + span { background: var(--ok); } .switch input:checked + span::after { left: 23px; }
.switch input:focus-visible + span { outline: 3px solid var(--gold-1); outline-offset: 2px; }
.botcard .row, .tourcard .row { gap: 12px; }
@media (max-width: 480px) { .botcard .row { flex-wrap: wrap !important; } }
.pushcard .push-st { margin: 10px 0 6px; gap: 8px; } .push-help { margin-top: 8px; font-size: 14px; } .push-help summary { cursor: pointer; font-weight: 600; color: var(--ink-2); }
.botadm { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; } .botadm > * { min-width: 0; margin: 0; }
@media (max-width: 1000px) { .botadm { grid-template-columns: minmax(0, 1fr); } }
.kblist { display: grid; gap: 8px; max-height: 620px; overflow-y: auto; }
.kbi { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: grid; gap: 4px; background: var(--paper); }
.kbi.need { border-left: 4px solid var(--bad); }
.kbi .row { gap: 6px; }
/* Tình trạng hệ thống + sao lưu */
.hl { display: grid; gap: 10px; }
.hl-r { display: flex; gap: 10px; align-items: flex-start; }
.hl-ic { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 14px; color: #fff; background: var(--ink-3); }
.hl-ic.ok { background: var(--ok); } .hl-ic.bad { background: var(--bad); } .hl-ic.warn { background: var(--warn); }
.rs-sum { padding: 10px 12px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); }
#rsfile { padding: 8px; }
html.dark .rank.r1 { background: var(--gold-grad); } html.dark .rank.r2 { background: #b9b2a8; } html.dark .rank.r3 { background: #d39b74; }
html.dark .dl.up { color: var(--ok); } html.dark .dl.down { color: var(--bad); } html.dark .dl { color: var(--ink-3); }
html.dark .hl-ic { color: #0d0d0e; }
@media (pointer: coarse) { .logo { min-height: 44px; min-width: 44px; } }

.rsoverlay { position: fixed; inset: 0; z-index: 95; background: rgba(12, 8, 6, .7); display: grid; place-items: center; padding: 16px; }
.rsoverlay .card { width: min(420px, 100%); }
.rsoverlay .progress { height: 10px; }
.logo { min-height: 40px; }

/* ---------- Thanh tab sếp trên máy tính: lưới 7 cột × 2 hàng (14 mục), đầy bề ngang, không phải kéo ngang ---------- */
@media (min-width: 1025px) {
  .stickytabs { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; overflow: visible; -webkit-mask-image: none; mask-image: none; padding-top: 10px !important; padding-bottom: 8px !important; }
  .stickytabs .tab { display: inline-flex; justify-content: center; align-items: center; min-width: 0; padding: 7px 8px; font-size: 14px; min-height: 38px; }
  .stickytabs .tab .tl-long, .stickytabs .tab .tl-short { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .stickytabs .tab .c { flex: none; }
  .stickytabs .tab.alltabs { display: none; }
  .stickytabs .tab .ti { margin-right: 5px; flex: none; }
}
@media (min-width: 1025px) and (max-width: 1399px) {
  .stickytabs .tab { font-size: 13.5px; padding: 7px 6px; }
  .stickytabs .tab.has-short .tl-long { display: none; } .stickytabs .tab.has-short .tl-short { display: inline; }
}

/* ===== 3 web app: nút chuyển app, app Thiết kế, app Tài chính & lương (v2.9.0) ===== */
.appsw { font-size: 19px; line-height: 1; }
.appmenu { min-width: 290px; max-width: calc(100vw - 24px); }
.appmenu .am-h { padding: 8px 12px 4px; text-transform: uppercase; letter-spacing: .06em; font-size: 11px; }
.appmenu button { display: flex; align-items: center; gap: 12px; }
.appmenu button b { display: block; }
.appmenu button small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.appmenu button .am-ic { font-size: 22px; width: 30px; text-align: center; flex: none; }
.appmenu button .tag { margin-left: auto; flex: none; }
.appmenu button.on { background: var(--brand-soft); }
.apptitle { color: #fff; font-weight: 700; font-size: 15px; margin-left: 4px; padding: 5px 12px; border-radius: 999px; background: rgba(255, 255, 255, .12); border: 1px solid rgba(232, 195, 143, .4); white-space: nowrap; }
@media (max-width: 560px) { .apptitle { font-size: 13px; padding: 4px 9px; max-width: 42vw; overflow: hidden; text-overflow: ellipsis; } }
body.mini-app .wrap { padding-top: 12px; }
.stickytabs.mini-tabs { display: flex !important; flex-wrap: wrap; gap: 8px; overflow: visible; mask-image: none; -webkit-mask-image: none; }
@media (min-width: 1025px) { .stickytabs.mini-tabs .tab { padding: 8px 16px; } }
.stickytabs.mini-tabs .tab { flex: 0 0 auto; min-width: 0; }
@media (max-width: 560px) { .stickytabs.mini-tabs .tab { flex: 1 1 0; min-width: 0; justify-content: center; padding: 8px 6px; font-size: 13px; line-height: 1.15; text-align: center; } .stickytabs.mini-tabs .tab .tl-long { white-space: normal; min-width: 0; } .stickytabs.mini-tabs .tab .ti { margin-right: 4px; } }
.soon { text-align: center; padding: 28px 18px; }
.soon .soon-ic { font-size: 44px; }
.soon h2 { margin: 8px 0 6px; display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.soon p { max-width: 640px; margin: 6px auto; }
.soon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin: 16px auto; max-width: 760px; }
.soon-i { border: 1px dashed var(--line); border-radius: 14px; padding: 18px 10px; background: var(--bg); display: grid; gap: 4px; }
.soon-i small { color: var(--muted); }
.mypay { display: grid; gap: 14px; }
.payhero { background: linear-gradient(135deg, var(--brand), #3a0d12); color: #fff; }
html.dark .payhero { background: linear-gradient(135deg, #2a2418, #141210); border-color: rgba(201, 164, 92, .35); }
.payhero .muted { color: rgba(255, 255, 255, .78) !important; }
.payhero select.in { background: rgba(255, 255, 255, .95); color: #222; }
.payhero .payname { font-size: 15px; margin-top: 14px; opacity: .9; }
.payhero .paytotal { font-family: var(--display); font-size: clamp(30px, 7vw, 46px); font-weight: 800; letter-spacing: .01em; margin: 2px 0 6px; color: #f3dda7; }
.paytbl td { padding: 9px 6px; }
.paytbl tr.sum td { border-top: 2px solid var(--line); font-size: 16px; }
#payhist tr.on td { background: var(--brand-soft); }
