:root, :root[data-theme="dark"] {
  --bg: #0b0f1a;
  --bg-grad: radial-gradient(1200px 600px at 80% -10%, rgba(79,124,255,.10), transparent 60%),
             radial-gradient(900px 500px at -10% 10%, rgba(139,92,246,.10), transparent 55%);
  --surface: #141b2b;
  --surface-2: #1b2338;
  --surface-3: #222d47;
  --border: #29334d;
  --border-soft: #1f2840;
  --text: #eef2fb;
  --muted: #8b99ba;
  --primary: #5b8bff;
  --primary-d: #3f6ae6;
  --ai: #a06bff;
  --ok: #2ec26e;
  --warn: #f7ab34;
  --danger: #f2564d;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 10px 34px rgba(0, 0, 0, .42);
  --shadow-sm: 0 3px 12px rgba(0, 0, 0, .28);
  --grad: linear-gradient(135deg, #5b8bff, #a06bff);
}
:root[data-theme="light"] {
  --bg: #eef1f8;
  --bg-grad: radial-gradient(1200px 600px at 80% -10%, rgba(79,124,255,.10), transparent 60%),
             radial-gradient(900px 500px at -10% 10%, rgba(139,92,246,.08), transparent 55%);
  --surface: #ffffff;
  --surface-2: #f3f6fd;
  --surface-3: #e9eef9;
  --border: #dbe2f1;
  --border-soft: #e8edf7;
  --text: #131b30;
  --muted: #64708c;
  --primary: #3f6ae6;
  --primary-d: #2f52c4;
  --ai: #7c48e8;
  --ok: #12a350;
  --warn: #c47a00;
  --danger: #dc3b34;
  --shadow: 0 10px 34px rgba(30, 50, 90, .14);
  --shadow-sm: 0 3px 12px rgba(30, 50, 90, .09);
  --grad: linear-gradient(135deg, #3f6ae6, #7c48e8);
}
body { transition: background .2s, color .2s; }

* { box-sizing: border-box; margin: 0; padding: 0; }

/* Thuộc tính hidden phải luôn thắng mọi quy tắc display bên dưới
   (nếu không, .lock-screen / .bulk-bar có display:grid|flex sẽ hiện dù đã hidden) */
[hidden] { display: none !important; }

body {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Thanh cuộn mảnh, hợp tông */
* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--border); background-clip: content-box; }

/* ---------- Layout: sidebar + main ---------- */
.layout { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---------- Sidebar dọc ---------- */
.sidebar {
  width: 244px; flex: none;
  background: linear-gradient(180deg, var(--surface), var(--bg));
  border-right: 1px solid var(--border-soft);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
  transition: width .22s ease;
}
.side-collapsed .sidebar { width: 64px; }
.sidebar-head {
  display: flex; align-items: center; gap: .6rem;
  padding: 1.1rem .9rem; border-bottom: 1px solid var(--border-soft);
  position: sticky; top: 0; background: var(--surface); z-index: 2;
}
.logo {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  background: var(--grad);
  border-radius: 12px; font-size: 1.25rem;
  box-shadow: 0 4px 14px rgba(91,139,255,.4);
}
.brand-name { font-weight: 800; font-size: .95rem; letter-spacing: .01em; }
.brand-sub { color: var(--muted); font-size: .72rem; }
.side-collapsed .sidebar-brand { display: none; }

.side-nav { padding: .55rem; display: flex; flex-direction: column; gap: .15rem; }
.side-group-label {
  font-size: .66rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); font-weight: 700;
  padding: .85rem .6rem .3rem;
}
.side-collapsed .side-group-label { text-align: center; padding: .6rem 0 .2rem; font-size: 0; }
.side-collapsed .side-group-label::before { content: "•••"; font-size: .6rem; letter-spacing: 0; }
.side-btn {
  position: relative;
  display: flex; align-items: center; gap: .7rem;
  width: 100%; border: 1px solid transparent; background: transparent;
  color: var(--text); cursor: pointer; text-align: left;
  padding: .58rem .65rem; border-radius: 10px;
  font-size: .86rem; font-weight: 600; font-family: inherit;
  transition: background .14s, color .14s;
}
.side-btn:hover { background: var(--surface-2); }
.side-btn .si { width: 22px; flex: none; text-align: center; font-size: 1.05rem; }
.side-btn .sl { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-btn .qn {
  font-size: .72rem; font-weight: 800; color: var(--muted);
  background: var(--surface-3); border-radius: 999px; padding: .05rem .45rem; min-width: 22px; text-align: center;
}
.side-btn.primary { background: var(--grad); color: #fff; box-shadow: 0 4px 14px rgba(91,139,255,.35); margin-bottom: .2rem; }
.side-btn.primary:hover { filter: brightness(1.06); background: var(--grad); }
.side-btn.ai { background: rgba(160,107,255,.14); color: var(--ai); border-color: rgba(160,107,255,.3); }
.side-btn.ai:hover { background: rgba(160,107,255,.22); }
.side-btn.danger { color: #ff9b95; }
.side-btn.danger:hover { background: rgba(242, 86, 77, .13); }
.side-btn.quick.active {
  background: linear-gradient(90deg, rgba(91,139,255,.16), transparent);
  color: #fff;
}
.side-btn.quick.active::before {
  content: ""; position: absolute; left: 0; top: 20%; bottom: 20%;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--primary);
}
.side-btn.quick.active .qn { background: var(--primary); color: #fff; }
/* Thư mục công ty (sidebar) */
#companyFolders { display: flex; flex-direction: column; gap: .12rem; margin-bottom: .3rem; }
.side-btn.folder.active {
  background: linear-gradient(90deg, rgba(91,139,255,.16), transparent);
  color: #fff;
}
.side-btn.folder.active::before {
  content: ""; position: absolute; left: 0; top: 20%; bottom: 20%;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--primary);
}
.side-btn.folder.active .qn { background: var(--primary); color: #fff; }
/* Thẻ công ty trong bảng */
.folder-tag {
  display: inline-flex; align-items: center; gap: .25rem;
  font-size: .8rem; font-weight: 700; white-space: nowrap;
  color: var(--primary); background: rgba(91,139,255,.12);
  border: 1px solid rgba(91,139,255,.28); border-radius: 999px; padding: .1rem .5rem;
}
.cell-time { font-size: .76rem; color: var(--muted); white-space: nowrap; }
.side-collapsed .side-btn .sl, .side-collapsed .side-btn .qn { display: none; }
.side-collapsed .side-btn { justify-content: center; padding: .58rem 0; }

/* ---------- Menu KHU VỰC (danh mục cha) → CÔNG TY (con) ---------- */
#pipelineNav { display: flex; flex-direction: column; gap: .12rem; margin-bottom: .3rem; }
.side-btn.region { font-weight: 700; }
.side-btn.region .caret {
  width: 16px; flex: none; text-align: center; font-size: .72rem;
  color: var(--muted); cursor: pointer; border-radius: 4px;
  transition: background .12s, color .12s; margin-right: -.15rem;
}
.side-btn.region .caret:hover { background: var(--surface-3); color: var(--text); }
.side-btn.region.open .caret { color: var(--ok); }
.side-btn.region.active {
  background: linear-gradient(90deg, rgba(34,197,94,.15), transparent);
  color: #fff;
}
.side-btn.region.active::before {
  content: ""; position: absolute; left: 0; top: 20%; bottom: 20%;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--ok);
}
.region-children {
  display: flex; flex-direction: column; gap: .1rem;
  margin-left: .55rem; padding-left: .4rem;
  border-left: 1px dashed var(--border);
}
.side-btn.folder.sub .sl { font-size: .86rem; }
.side-btn.folder.sub .caret {
  width: 14px; flex: none; text-align: center; font-size: .68rem;
  color: var(--muted); cursor: pointer; border-radius: 4px; margin-right: -.15rem;
  transition: background .12s, color .12s;
}
.side-btn.folder.sub .caret:hover { background: var(--surface-3); color: var(--text); }
.side-btn.folder.sub.open .caret { color: var(--primary); }
.side-mini-label {
  font-size: .66rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); padding: .35rem .6rem .1rem; opacity: .75;
}

/* ---- Cấp 3: danh sách ứng viên trong công ty ---- */
.company-children {
  display: flex; flex-direction: column; gap: .05rem;
  margin-left: .9rem; padding-left: .4rem;
  border-left: 1px dashed var(--border-soft);
}
.side-btn.cand.sub2 { padding: .34rem .6rem; }
.side-btn.cand.sub2 .sl { font-size: .82rem; color: var(--muted); }
.side-btn.cand.sub2:hover .sl { color: var(--text); }
.side-btn.cand.sub2 .si { font-size: .8rem; }
.tree-empty { padding: .2rem .6rem; }

/* ---- Kéo-thả sắp xếp công ty ---- */
.side-btn.folder.sub[draggable="true"] { cursor: grab; }
.side-btn.folder.sub.dragging { opacity: .45; }
.side-btn.folder.sub.drag-over {
  background: var(--surface-3);
  box-shadow: inset 0 -2px 0 var(--primary);
}
.side-btn.region.drag-over,
.side-mini-label.drag-over {
  background: linear-gradient(90deg, rgba(91,139,255,.18), transparent);
  outline: 1px dashed var(--primary); border-radius: 8px;
}

.side-collapsed .region-children,
.side-collapsed .company-children { margin-left: 0; padding-left: 0; border-left: none; }
.side-collapsed .side-mini-label { display: none; }
.side-collapsed .side-btn.region .caret,
.side-collapsed .side-btn.folder.sub .caret { display: none; }
.side-collapsed .side-btn.cand .sl { display: none; }

/* ---------- Quản lý khu vực / công ty (modal) ---------- */
.comp-manage-row {
  display: flex; gap: .6rem; align-items: flex-end;
  padding: .5rem 0; border-bottom: 1px solid var(--border-soft);
}
.comp-manage-row:last-child { border-bottom: none; }
.comp-manage-row .field { margin: 0; }
.comp-manage-row .btn { flex: none; margin-bottom: .1rem; }

/* ---------- Hộp trợ giúp (đồng bộ Google Form) ---------- */
.help-box {
  background: var(--surface-2); border: 1px solid var(--border-soft);
  border-radius: 10px; padding: .5rem .75rem; font-size: .84rem;
}
.help-box summary { cursor: pointer; font-weight: 700; color: var(--text); }
.help-list { margin: .5rem 0 .2rem; padding-left: 1.2rem; line-height: 1.7; color: var(--muted); }
.help-list li { margin-bottom: .15rem; }

/* ---------- Menu PIPELINE (trạng thái xử lý) ---------- */
.side-btn.pipe.active {
  background: linear-gradient(90deg, rgba(160,107,255,.16), transparent);
  color: #fff;
}
.side-btn.pipe.active::before {
  content: ""; position: absolute; left: 0; top: 20%; bottom: 20%;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--ai);
}
.pipe-dot {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  margin-right: .4rem; vertical-align: middle; flex: none;
}

/* ---------- Dropdown trạng thái xử lý trên bảng ---------- */
.col-pipe { min-width: 172px; }
.pipe-select {
  width: 100%; max-width: 172px;
  font-size: .8rem; font-weight: 700;
  padding: .32rem .5rem; border-radius: 8px;
  color: var(--pc, var(--text));
  background: color-mix(in srgb, var(--pc, var(--surface-3)) 14%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--pc, var(--border)) 45%, transparent);
  cursor: pointer; transition: border-color .12s, background .12s;
}
.pipe-select:hover { border-color: var(--pc, var(--primary)); }
.pipe-select:focus { outline: 2px solid color-mix(in srgb, var(--pc, var(--primary)) 40%, transparent); outline-offset: 1px; }
.pipe-select option { color: var(--text); background: var(--surface); font-weight: 600; }
/* Nhãn trạng thái xử lý trong card tra cứu */
.pipe-badge {
  display: inline-flex; align-items: center; font-size: .8rem; font-weight: 800;
  color: var(--pc, var(--text));
  background: color-mix(in srgb, var(--pc, var(--surface-3)) 16%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--pc, var(--border)) 50%, transparent);
  border-radius: 999px; padding: .12rem .6rem;
}

/* ---------- Topbar (trong main) ---------- */
.topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: .85rem 1.5rem;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-soft);
  position: sticky; top: 0; z-index: 20;
}
.hamburger {
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); cursor: pointer;
  width: 38px; height: 38px; border-radius: 10px; font-size: 1.1rem; flex: none;
  transition: .14s;
}
.hamburger:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.topbar-title { font-weight: 800; font-size: 1.05rem; white-space: nowrap; letter-spacing: .01em; }
.topbar .search-wrap { margin-left: auto; }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--text);
  padding: .55rem .9rem;
  border-radius: 9px;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: .15s;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-ai { background: var(--ai); color: #fff; }
.btn-ai:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-outline { background: transparent; border-color: var(--primary); color: var(--primary); }
.btn-danger-ghost { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger-ghost:hover { background: rgba(242, 86, 77, .12); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

/* ---------- Stat bar ---------- */
.statbar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 1rem;
  padding: 1.4rem 1.5rem .4rem;
}
.stat-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.stat-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--muted); opacity: .5;
}
.stat-card.accent::before { background: var(--primary); opacity: 1; }
.stat-card.ai::before { background: var(--ai); opacity: 1; }
.stat-card.ok::before { background: var(--ok); opacity: 1; }
.stat-card.danger::before { background: var(--danger); opacity: 1; }
.stat-card .val { font-size: 1.85rem; font-weight: 800; line-height: 1.1; letter-spacing: -.01em; }
.stat-card .lbl { color: var(--muted); font-size: .8rem; margin-top: .2rem; font-weight: 500; }
.stat-card.accent .val { color: var(--primary); }
.stat-card.ai .val { color: var(--ai); }
.stat-card.ok .val { color: var(--ok); }
.stat-card.danger .val { color: var(--danger); }
.stat-card.wide::before { display: none; }

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.4rem 1rem;
  flex-wrap: wrap;
}
.search-wrap {
  position: relative;
  flex: 1;
  min-width: 240px;
  max-width: 520px;
}
.search-icon {
  position: absolute; left: .8rem; top: 50%;
  transform: translateY(-50%); opacity: .6;
}
#search {
  width: 100%;
  padding: .62rem .8rem .62rem 2.4rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: .9rem;
  transition: .15s;
}
#search:focus { outline: none; border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 3px rgba(91,139,255,.16); }
.toolbar-right { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---------- Table ---------- */
.table-wrap {
  margin: 1rem 1.5rem 2rem;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow: auto;                     /* cuộn cả ngang lẫn dọc trong khung này */
  max-height: calc(100vh - 250px);    /* giới hạn cao -> header dính, cuộn gọn */
  box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; min-width: 1480px; }
thead th {
  background: var(--surface-3);
  text-align: left;
  padding: .85rem .7rem;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  position: sticky;
  top: 0;
  z-index: 5;
  border-bottom: 2px solid var(--border);
  border-right: 1px solid var(--border);      /* đường kẻ dọc phân chia cột (header) */
  white-space: nowrap;
}
thead th:last-child { border-right: none; }
thead th.sortable { transition: color .12s; }
thead th.sortable:hover { color: var(--text); background: var(--surface-2); }
tbody td {
  padding: .75rem .7rem;
  border-bottom: 1px solid var(--border-soft);
  border-right: 1px solid var(--border-soft);  /* đường kẻ dọc phân chia cột (ô dữ liệu) */
  vertical-align: middle;
}
tbody td:last-child { border-right: none; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: color-mix(in srgb, var(--primary) 8%, transparent); }
tbody tr:last-child td { border-bottom: none; }
/* hàng ô lọc dưới tiêu đề: giữ kẻ dọc mảnh cho đều khung */
thead tr.filter-row th { border-right: 1px solid var(--border-soft); border-bottom: 1px solid var(--border); }
thead tr.filter-row th:last-child { border-right: none; }
.col-idx { width: 42px; text-align: center; }
.col-addr { min-width: 220px; }
.col-score { width: 120px; }
.col-act { width: 96px; }
.cell-name { font-weight: 700; }
.cell-cccd { font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.cell-muted { color: var(--muted); font-size: .82rem; }

/* status note chips */
.note {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.note.ok { color: #86efac; border-color: rgba(34, 197, 94, .4); background: rgba(34, 197, 94, .1); }
.note.warn { color: #fcd34d; border-color: rgba(245, 158, 11, .4); background: rgba(245, 158, 11, .1); }
.note.danger { color: #fca5a5; border-color: rgba(239, 68, 68, .4); background: rgba(239, 68, 68, .1); }

/* AI score */
.score {
  display: flex;
  align-items: center;
  gap: .5rem;
}
.score-ring {
  --v: 0;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: conic-gradient(var(--sc, var(--ai)) calc(var(--v) * 1%), var(--surface-2) 0);
  display: grid; place-items: center;
  flex: none;
}
.score-ring i {
  width: 30px; height: 30px;
  background: var(--surface);
  border-radius: 50%;
  display: grid; place-items: center;
  font-style: normal;
  font-size: .72rem;
  font-weight: 800;
}
.score-empty { color: var(--muted); font-size: .8rem; }

.row-act { display: flex; gap: .3rem; }
.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  width: 30px; height: 30px;
  border-radius: 8px;
  cursor: pointer;
  font-size: .85rem;
}
.icon-btn { transition: .13s; }
.icon-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); transform: translateY(-1px); }
.icon-btn.del:hover { background: var(--danger); border-color: var(--danger); }

.empty { padding: 3.5rem 1rem; text-align: center; color: var(--muted); }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0;
  display: none;
  z-index: 50;
}
.modal.open { display: grid; place-items: center; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(5, 8, 15, .7);
  backdrop-filter: blur(3px);
}
.modal-panel {
  position: relative;
  width: min(680px, 94vw);
  max-height: 90vh;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.6rem;
  box-shadow: var(--shadow);
}
.modal-close {
  position: absolute; top: .9rem; right: .9rem;
  width: 34px; height: 34px;
  border: none; border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer; font-size: 1rem;
}
.modal-title { font-size: 1.25rem; font-weight: 800; margin-bottom: .3rem; }
.modal-sub { color: var(--muted); margin-bottom: 1.2rem; font-size: .88rem; }

.field { margin-bottom: 1rem; }
.field label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: .35rem; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: .6rem .75rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  font-size: .9rem;
  font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--primary);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
.form-hint { font-size: .78rem; color: var(--muted); margin-top: -.5rem; margin-bottom: 1rem; }

/* score breakdown */
.score-detail { margin: 1rem 0; }
.score-big {
  display: flex; align-items: center; gap: 1rem;
  padding: 1rem;
  background: var(--surface-2);
  border-radius: 12px;
  margin-bottom: 1rem;
}
.score-big .big-num { font-size: 2.4rem; font-weight: 800; }
.score-item {
  display: flex; justify-content: space-between;
  padding: .5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: .88rem;
}
.score-item:last-child { border-bottom: none; }
.score-item .pts { font-weight: 700; }
.pts.plus { color: var(--ok); }
.pts.minus { color: var(--danger); }

/* ---------- Toast ---------- */
.toast-wrap {
  position: fixed; right: 1.2rem; bottom: 1.2rem;
  display: flex; flex-direction: column; gap: .6rem;
  z-index: 100;
}
.toast {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  padding: .75rem 1rem;
  border-radius: 9px;
  box-shadow: var(--shadow);
  max-width: 340px;
  font-size: .88rem;
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }

.mono { font-family: "Consolas", monospace; }
.muted { color: var(--muted); }
.small { font-size: .8rem; }
.mt { margin-top: 1rem; }
.col-note { min-width: 180px; }

/* ---------- Modal wide + tab switch ---------- */
.modal-panel.wide { width: min(820px, 95vw); }
.tab-switch {
  display: flex; gap: .4rem;
  background: var(--surface-2);
  padding: .3rem; border-radius: 10px;
  margin-bottom: 1rem; flex-wrap: wrap;
}
.tab-switch button {
  flex: 1; min-width: 90px;
  border: none; background: transparent;
  color: var(--muted); padding: .5rem .7rem;
  border-radius: 8px; cursor: pointer;
  font-weight: 600; font-size: .82rem;
}
.tab-switch button.active { background: var(--primary); color: #fff; }
.btn-sm { padding: .4rem .6rem; font-size: .78rem; }

/* ---------- Bank box ---------- */
.bank-box {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
  background: rgba(79, 124, 255, .04);
}
.bank-box-title { font-weight: 700; margin-bottom: .8rem; font-size: .9rem; }

/* ---------- Lookup ---------- */
.lookup-result { display: flex; flex-direction: column; gap: .5rem; max-height: 55vh; overflow: auto; }
.lookup-item {
  display: flex; align-items: center; gap: .7rem;
  padding: .7rem; border: 1px solid var(--border);
  border-radius: 10px; cursor: pointer; background: var(--surface-2);
}
.lookup-item:hover { border-color: var(--primary); }
.li-avatar {
  width: 40px; height: 40px; flex: none;
  border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--ai));
  font-weight: 700;
}
.li-name { font-weight: 700; }
.li-sub { color: var(--muted); font-size: .8rem; margin-top: .15rem; }
.li-score { font-weight: 800; font-size: 1.2rem; margin-left: auto; }

/* ---------- Card tra cứu ---------- */
.card-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.card-avatar {
  width: 54px; height: 54px; flex: none;
  border-radius: 14px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--ai));
  font-size: 1.5rem; font-weight: 800;
}
.card-score {
  margin-left: auto; border: 2px solid;
  border-radius: 12px; padding: .3rem .7rem;
  font-size: 1.5rem; font-weight: 800;
}
.card-score small { font-size: .7rem; color: var(--muted); }
.card-warn {
  background: rgba(239, 68, 68, .12);
  border: 1px solid rgba(239, 68, 68, .4);
  color: #fca5a5; padding: .6rem .8rem;
  border-radius: 9px; margin-bottom: 1rem; font-weight: 600;
}
.card-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: .1rem .8rem;
}
.card-row {
  display: flex; justify-content: space-between; gap: .5rem;
  padding: .45rem 0; border-bottom: 1px solid var(--border);
}
.cr-label { color: var(--muted); font-size: .82rem; }
.cr-val { font-weight: 600; text-align: right; word-break: break-word; }
.card-note {
  margin-top: 1rem; padding: .7rem .8rem;
  background: var(--surface-2); border-radius: 9px; font-size: .88rem;
}
.card-meta { margin-top: 1rem; color: var(--muted); font-size: .78rem; }

/* ---------- Classify list ---------- */
.cls-list { display: flex; flex-direction: column; gap: .5rem; max-height: 58vh; overflow: auto; }
.cls-item {
  display: flex; align-items: center; gap: .8rem;
  padding: .7rem; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface-2);
}
.cls-info { flex: 1; min-width: 0; }
.cls-actions { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.cls-move {
  padding: .4rem .5rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: .8rem;
}

/* ---------- Chart (SVG) ---------- */
.chart-svg {
  width: 100%; height: auto; display: block;
  background: var(--surface-2); border-radius: 12px;
  padding: .6rem; margin-bottom: 1.2rem;
}
.chart-svg rect { transition: opacity .15s; }
.chart-svg rect:hover { opacity: .8; }

.donut-wrap {
  display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
  background: var(--surface-2); border-radius: 12px; padding: 1rem;
}
.donut { width: 180px; height: 180px; flex: none; }
.donut-legend { flex: 1; min-width: 180px; display: flex; flex-direction: column; gap: .35rem; }
.lg-row { display: flex; align-items: center; gap: .5rem; font-size: .84rem; }
.lg-row i { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.lg-row .lg-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lg-row b { font-variant-numeric: tabular-nums; }

/* ---------- Báo cáo tổng hợp ---------- */
.report-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: .8rem;
  margin-bottom: 1rem;
}
.report-kpis .stat-card { padding: .9rem 1rem; }
.report-kpis .stat-card .val { font-size: 1.5rem; }
.report-sec-title {
  font-weight: 700; font-size: .95rem; margin-bottom: .6rem; color: var(--text);
}
.report-sec-title.mt { margin-top: 1.4rem; }
.report-funnel {
  display: flex; flex-direction: column; gap: .5rem;
  background: var(--surface-2); border-radius: 12px; padding: 1rem;
}
.fn-row { display: flex; align-items: center; gap: .7rem; }
.fn-label {
  width: 150px; flex: none; font-size: .84rem; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fn-track {
  flex: 1; min-width: 0; height: 22px; background: var(--surface-3);
  border-radius: 6px; overflow: hidden;
}
.fn-fill { height: 100%; border-radius: 6px; transition: width .3s; min-width: 4px; }
.fn-num {
  width: 78px; flex: none; text-align: right; font-weight: 700;
  font-variant-numeric: tabular-nums; font-size: .9rem;
}
.fn-num .fn-pct { color: var(--muted); font-weight: 500; font-size: .78rem; margin-left: .3rem; }
@media (max-width: 620px) {
  .fn-label { width: 100px; }
  .fn-num { width: 62px; }
}

/* ---------- Báo cáo: cây phân nhánh (Decomposition Tree) ---------- */
.decomp-controls {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: .6rem; margin: .2rem 0 .8rem; padding: .6rem .7rem;
  background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: 10px;
}
.decomp-path { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.decomp-level { display: flex; align-items: center; gap: .25rem; }
.decomp-level-idx {
  display: inline-grid; place-items: center; width: 18px; height: 18px;
  background: var(--primary); color: #fff; border-radius: 50%; font-size: .68rem; font-weight: 800;
}
.decomp-dim {
  padding: .3rem .5rem; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: .82rem; cursor: pointer;
}
.decomp-x {
  border: none; background: transparent; color: var(--muted); cursor: pointer;
  font-size: .8rem; padding: 0 .2rem; border-radius: 5px;
}
.decomp-x:hover { color: var(--danger); background: rgba(242,86,77,.12); }
.decomp-arrow { color: var(--muted); font-weight: 700; margin: 0 .1rem; }
.decomp-actions { display: flex; gap: .4rem; flex-wrap: wrap; }

.decomp-tree { display: flex; flex-direction: column; gap: .25rem; }
.dc-children {
  display: flex; flex-direction: column; gap: .25rem;
  margin-left: .8rem; padding-left: .7rem; margin-top: .25rem;
  border-left: 2px solid var(--border);
}
.dc-node { display: flex; flex-direction: column; }
.dc-bar-wrap {
  display: flex; align-items: center; gap: .5rem;
  padding: .3rem .4rem; border-radius: 8px;
}
.dc-bar-wrap.dc-clickable { cursor: pointer; }
.dc-bar-wrap.dc-clickable:hover { background: var(--surface-2); }
.dc-root .dc-bar-wrap { background: var(--surface-2); }
.dc-caret {
  width: 14px; flex: none; text-align: center; font-size: .72rem; color: var(--muted);
}
.dc-caret.dc-leaf { color: var(--border); }
.dc-label {
  flex: 0 0 auto; width: 150px; font-size: .84rem; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dc-track {
  flex: 1; min-width: 40px; height: 16px; background: var(--surface-3);
  border-radius: 5px; overflow: hidden;
}
.dc-fill { height: 100%; border-radius: 5px; transition: width .3s; min-width: 3px; }
.dc-num {
  width: 74px; flex: none; text-align: right; font-weight: 700;
  font-variant-numeric: tabular-nums; font-size: .84rem;
}
.dc-num .dc-pct { color: var(--muted); font-weight: 500; font-size: .74rem; margin-left: .3rem; }

/* ---------- Báo cáo: khối AI đánh giá tổng hợp ---------- */
.ai-eval {
  margin: 1rem 0 .4rem; padding: .8rem 1rem;
  background: rgba(160,107,255,.08); border: 1px solid rgba(160,107,255,.25);
  border-radius: 12px;
}
.ai-eval-head { font-weight: 700; color: var(--ai); margin-bottom: .5rem; }
.ai-note-list { list-style: none; display: flex; flex-direction: column; gap: .4rem; }
.ai-note {
  position: relative; padding: .45rem .6rem .45rem 1.8rem;
  background: var(--surface); border-radius: 8px; font-size: .86rem; line-height: 1.5;
  border-left: 3px solid var(--muted);
}
.ai-note::before { position: absolute; left: .55rem; top: .45rem; font-size: .9rem; }
.ai-note.ai-ok { border-left-color: var(--ok); }
.ai-note.ai-ok::before { content: "✅"; }
.ai-note.ai-warn { border-left-color: var(--warn); }
.ai-note.ai-warn::before { content: "⚠️"; }
.ai-note.ai-info { border-left-color: var(--primary); }
.ai-note.ai-info::before { content: "ℹ️"; }
@media (max-width: 620px) {
  .dc-label { width: 96px; }
  .dc-num { width: 60px; }
  .dc-children { margin-left: .4rem; padding-left: .4rem; }
}

@media (max-width: 620px) {
  .card-grid, .field-row { grid-template-columns: 1fr; }
  .chart-label { width: 90px; }
}

/* ---------- Checkbox + sortable header + selected row ---------- */
.col-check { width: 38px; text-align: center; }
.col-check input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary); }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
tbody tr.row-sel { background: rgba(79, 124, 255, .14); }
tbody tr.row-sel:hover { background: rgba(79, 124, 255, .2); }

/* ---------- Filter count badge ---------- */
.badge-num {
  display: inline-grid; place-items: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--primary); color: #fff;
  border-radius: 999px; font-size: .72rem; font-weight: 800;
  margin-left: .1rem;
}

/* ---------- Bulk action bar ---------- */
.bulk-bar {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  margin: .8rem 1.5rem 0;
  padding: .75rem 1.1rem;
  background: linear-gradient(90deg, rgba(91,139,255,.18), rgba(160,107,255,.1));
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.bulk-count { font-weight: 600; margin-right: .3rem; }
.bulk-count b { color: var(--primary); }

/* ---------- Duplicate list (import) ---------- */
.dup-list {
  list-style: none; margin: 0 0 1.2rem;
  max-height: 40vh; overflow: auto;
  border: 1px solid var(--border); border-radius: 10px;
}
.dup-list li {
  padding: .55rem .8rem;
  border-bottom: 1px solid var(--border);
  font-size: .86rem;
}
.dup-list li:last-child { border-bottom: none; }

/* ---------- Hàng ô lọc theo cột ---------- */
.filter-row th { padding: .3rem .4rem; background: var(--surface); position: sticky; top: 37px; z-index: 4; }
.col-filter {
  width: 100%; min-width: 60px;
  padding: .3rem .45rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: .78rem; font-family: inherit;
}
.col-filter:focus { outline: none; border-color: var(--primary); }
.col-filter::placeholder { color: var(--muted); opacity: .6; }

/* ---------- Dropdown menu ---------- */
.menu { position: relative; }
.menu-list {
  position: absolute; top: calc(100% + 6px); right: 0;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: .4rem;
  display: none;
  z-index: 40;
}
.menu.open .menu-list { display: block; }
.menu-item {
  display: block; width: 100%; text-align: left;
  border: none; background: transparent;
  color: var(--text); cursor: pointer;
  padding: .55rem .7rem; border-radius: 8px;
  font-size: .85rem; font-weight: 600;
  font-family: inherit;
}
.menu-item:hover { background: var(--surface-2); }
.menu-item.danger { color: #ff8f8f; }
.menu-item.danger:hover { background: rgba(239, 68, 68, .12); }
.menu-sep { height: 1px; background: var(--border); margin: .35rem .3rem; }
.btn.icon-only { padding: .55rem .65rem; }

/* ---------- Overview: distribution bar ---------- */
.stat-card.wide { grid-column: 1 / -1; }
.stat-card.danger .val { color: var(--danger); }
.stat-card.clickable { cursor: pointer; transition: .15s; }
.stat-card.clickable:hover { border-color: var(--primary); transform: translateY(-1px); }
.stat-card.active { border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger) inset; }
.dist-bar {
  display: flex; height: 14px; border-radius: 7px; overflow: hidden;
  background: var(--surface-2); margin: .7rem 0 .6rem;
}
.dist-bar .seg { height: 100%; transition: width .4s; }
.dist-bar .seg.ok { background: var(--ok); }
.dist-bar .seg.warn { background: var(--warn); }
.dist-bar .seg.danger { background: var(--danger); }
.dist-legend { display: flex; gap: 1rem; font-size: .78rem; color: var(--muted); }
.dist-legend .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: .25rem; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.danger { background: var(--danger); }

/* ---------- Lock screen (login) ---------- */
.lock-screen {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background: var(--bg);
  z-index: 200;
  padding: 1rem;
}
.lock-box {
  width: min(400px, 94vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 2rem 1.8rem;
  box-shadow: var(--shadow);
  text-align: center;
}
.lock-logo {
  width: 64px; height: 64px; margin: 0 auto 1rem;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--ai));
  border-radius: 18px; font-size: 1.8rem;
}
.lock-title { font-size: 1.35rem; font-weight: 800; }
.lock-sub { color: var(--muted); font-size: .88rem; margin: .3rem 0 1.3rem; }
.lock-box input {
  width: 100%; padding: .7rem .8rem;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); font-size: 1rem;
  text-align: center; margin-bottom: .8rem;
}
.lock-box input:focus { outline: none; border-color: var(--primary); }
.lock-link {
  margin-top: 1rem; background: none; border: none;
  color: var(--primary); cursor: pointer; font-size: .85rem; font-weight: 600;
}
.lock-link:hover { text-decoration: underline; }

/* ---------- Recovery code ---------- */
.recovery-code {
  font-family: "Consolas", monospace;
  font-size: 1.5rem; font-weight: 800; letter-spacing: .1em;
  text-align: center; padding: 1.1rem;
  background: var(--surface-2);
  border: 2px dashed var(--primary);
  border-radius: 12px; margin-bottom: 1rem;
  color: var(--primary); word-break: break-all;
}

/* ---------- Shared form helpers ---------- */
.btn-block { width: 100%; display: block; }
.form-error {
  color: #ff8f8f; font-size: .84rem; min-height: 1em;
  margin-bottom: .6rem; display: none;
}
.form-error.show { display: block; }

/* ---------- Chip lọc bất thường trong statbar ---------- */
.stat-card.filter-active {
  grid-column: 1 / -1;
  background: rgba(239, 68, 68, .12);
  border-color: var(--danger);
  color: #ff9a9a; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.stat-card.filter-active:hover { background: rgba(239, 68, 68, .2); }

/* ---------- Panel phát hiện bất thường ---------- */
.anomaly-list { display: flex; flex-direction: column; gap: .6rem; }
.anomaly {
  display: flex; align-items: center; justify-content: space-between; gap: .8rem;
  padding: .8rem 1rem; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2);
}
.anomaly.high { border-color: rgba(239, 68, 68, .5); }
.anomaly.warn { border-color: rgba(245, 158, 11, .5); }
.an-head { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.an-msg { font-size: .88rem; font-weight: 600; }

/* ---------- Trợ lý AI ---------- */
.assist-samples { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .8rem; }
.sample-chip {
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); cursor: pointer;
  padding: .35rem .6rem; border-radius: 999px; font-size: .78rem; font-family: inherit;
}
.sample-chip:hover { border-color: var(--primary); }
.assist-log {
  display: flex; flex-direction: column; gap: .6rem;
  max-height: 46vh; overflow: auto;
  padding: .6rem; margin-bottom: .8rem;
  background: var(--surface-2); border-radius: 10px; min-height: 60px;
}
.assist-log:empty::before { content: "Hỏi gì đó về dữ liệu ứng viên…"; color: var(--muted); font-size: .84rem; }
.msg-q {
  align-self: flex-end; max-width: 85%;
  background: var(--primary); color: #fff;
  padding: .5rem .8rem; border-radius: 12px 12px 2px 12px; font-size: .86rem;
}
.msg-a {
  align-self: flex-start; max-width: 90%;
  background: var(--surface); border: 1px solid var(--border);
  padding: .6rem .8rem; border-radius: 12px 12px 12px 2px; font-size: .88rem; line-height: 1.55;
}
.msg-a.err { color: #ff9a9a; border-color: var(--danger); }
.assist-form { display: flex; gap: .5rem; }
.assist-form input {
  flex: 1; padding: .6rem .8rem;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 9px; color: var(--text); font-size: .9rem; font-family: inherit;
}
.assist-form input:focus { outline: none; border-color: var(--primary); }

/* ---------- Hộp xuất tài khoản trong Thông tin ngân hàng ---------- */
.bank-export-box {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
  background: rgba(79, 124, 255, .05);
}
.type-pick { display: flex; flex-wrap: wrap; gap: .5rem; }
.type-opt {
  display: flex; align-items: center; gap: .4rem;
  padding: .45rem .7rem; border: 1px solid var(--border);
  border-radius: 8px; cursor: pointer; font-size: .84rem; background: var(--surface-2);
}
.type-opt input { accent-color: var(--primary); }

/* ---------- Dropdown chọn nhiều vị trí ---------- */
.ms-dropdown { position: relative; }
.ms-toggle {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .6rem .75rem;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 9px; color: var(--text); cursor: pointer;
  font-size: .9rem; font-family: inherit; text-align: left;
}
.ms-toggle:hover { border-color: var(--primary); }
.ms-toggle:disabled { opacity: .5; cursor: not-allowed; }
.ms-toggle #posSummary { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-caret { color: var(--muted); transition: transform .15s; }
.ms-toggle.open .ms-caret { transform: rotate(180deg); }
.ms-panel {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30;
  max-height: 240px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--primary);
  border-radius: 10px; box-shadow: var(--shadow); padding: .35rem;
}
.ms-actions { display: flex; gap: .8rem; padding: .3rem .5rem .5rem; border-bottom: 1px solid var(--border); margin-bottom: .3rem; }
.ms-actions a { color: var(--primary); text-decoration: none; font-size: .78rem; font-weight: 600; }
.ms-actions a:hover { text-decoration: underline; }
.ms-item {
  display: flex; align-items: center; gap: .5rem;
  padding: .45rem .55rem; border-radius: 7px; cursor: pointer; font-size: .86rem;
}
.ms-item:hover { background: var(--surface-2); }
.ms-item input { accent-color: var(--primary); margin: 0; }
