/* ============================================================
   QLUV V2 — Component library. Nút, thẻ, input, chip, bảng, modal,
   KPI card, toast, timeline, kanban. Tất cả dùng tokens.css.
   ============================================================ */

/* ---- Nút ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--sp-2);
  height: 38px; padding: 0 var(--sp-4);
  border-radius: var(--r-md);
  border: 1px solid var(--line-2);
  background: var(--surface-2);
  color: var(--text);
  font-size: var(--fs-md); font-weight: 600;
  white-space: nowrap;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.btn:hover { background: var(--surface); border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn .ic { font-size: 1.05em; line-height: 1; }

.btn-primary {
  background: linear-gradient(180deg, var(--brand-500), var(--brand-600));
  border-color: var(--brand-600); color: #fff;
  box-shadow: 0 4px 14px rgba(79,124,255,.35);
}
.btn-primary:hover { background: linear-gradient(180deg, var(--brand-500), var(--brand-700)); border-color: var(--brand-700); }
.btn-danger { background: var(--danger-bg); border-color: var(--danger); color: #fecaca; }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--primary-weak); }
.btn-sm { height: 30px; padding: 0 var(--sp-3); font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn-lg { height: 46px; padding: 0 var(--sp-6); font-size: var(--fs-lg); }
.btn-block { width: 100%; }
.btn-icon { width: 38px; padding: 0; }
.btn-icon.btn-sm { width: 30px; }

/* ---- Thẻ ---- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.card-pad { padding: var(--sp-5); }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--line);
}
.card-title { font-size: var(--fs-lg); font-weight: 700; }
.card-body { padding: var(--sp-5); }

/* ---- Input / form ---- */
.field { display: flex; flex-direction: column; gap: var(--sp-2); }
.label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.input, .select, .textarea {
  width: 100%;
  height: 40px; padding: 0 var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  color: var(--text);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.textarea { height: auto; min-height: 84px; padding: var(--sp-3); resize: vertical; }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}
.input::placeholder, .textarea::placeholder { color: var(--muted); }
.select { appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) center, calc(100% - 13px) center;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
  padding-right: var(--sp-8);
}
.input-search { padding-left: var(--sp-8);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236b7a99' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='M11 11l4 4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: var(--sp-3) center;
}

/* ---- Chip / badge ---- */
.chip {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  height: 22px; padding: 0 var(--sp-2);
  border-radius: var(--r-full);
  font-size: var(--fs-xs); font-weight: 700;
  background: var(--surface-2); color: var(--text-2);
  border: 1px solid var(--line-2);
}
.chip.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.chip.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.chip.danger { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.chip-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ---- Bảng ---- */
.table-wrap { overflow: auto; border-radius: var(--r-lg); border: 1px solid var(--line); }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-sm); }
.tbl thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-2); color: var(--text-2);
  text-align: left; font-weight: 700;
  padding: var(--sp-3) var(--sp-3); white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
.tbl tbody td { padding: var(--sp-3); border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr { background: var(--card); transition: background var(--dur) var(--ease); }
.tbl tbody tr:hover { background: var(--surface); }
.tbl tbody tr:last-child td { border-bottom: none; }
.cell-muted { color: var(--muted); }

/* ---- Modal ---- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(3,7,18,.62); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-4); animation: fade var(--dur) var(--ease);
}
.modal {
  width: 100%; max-width: 560px; max-height: 90vh; overflow: auto;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-xl); box-shadow: var(--shadow-3);
  animation: pop var(--dur) var(--ease);
}
.modal-lg { max-width: 860px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---- KPI card ---- */
.kpi {
  position: relative; overflow: hidden;
  padding: var(--sp-3) var(--sp-4);
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-1);
}
.kpi::after {
  content: ""; position: absolute; right: -30px; top: -30px;
  width: 90px; height: 90px; border-radius: 50%;
  background: var(--accent, var(--primary-weak)); opacity: .12;
}
.kpi-label { font-size: var(--fs-xs); color: var(--text-2); font-weight: 600; }
.kpi-value { font-size: var(--fs-2xl); font-weight: 800; margin-top: 2px; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi-trend { display: inline-flex; align-items: center; gap: 4px; margin-top: 2px;
  font-size: var(--fs-xs); font-weight: 700; }
.kpi-trend.up { color: var(--ok); }
.kpi-trend.down { color: var(--danger); }
.kpi-trend.flat { color: var(--muted); }

/* ---- Toast ---- */
.toast-wrap { position: fixed; right: var(--sp-5); bottom: var(--sp-5); z-index: 80;
  display: flex; flex-direction: column; gap: var(--sp-2); }
.toast {
  min-width: 240px; max-width: 380px;
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line-2); border-left: 3px solid var(--primary);
  border-radius: var(--r-md); box-shadow: var(--shadow-2);
  animation: slidein var(--dur) var(--ease);
}
.toast.ok { border-left-color: var(--ok); }
.toast.warn { border-left-color: var(--warn); }
.toast.danger { border-left-color: var(--danger); }
@keyframes slidein { from { opacity: 0; transform: translateX(16px); } }

/* ---- Timeline ---- */
.timeline { position: relative; padding-left: var(--sp-6); }
.timeline::before { content: ""; position: absolute; left: 9px; top: 4px; bottom: 4px; width: 2px; background: var(--line-2); }
.tl-item { position: relative; padding: 0 0 var(--sp-4) 0; }
.tl-item::before { content: ""; position: absolute; left: -21px; top: 4px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--primary); border: 2px solid var(--card); }
.tl-time { font-size: var(--fs-xs); color: var(--muted); }
.tl-summary { font-weight: 600; }

/* ---- Empty state ---- */
.empty { text-align: center; padding: var(--sp-10) var(--sp-4); color: var(--muted); }
.empty .emoji { font-size: 44px; margin-bottom: var(--sp-2); }

/* ---- Segmented / tabs ---- */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line-2);
  border-radius: var(--r-md); padding: 3px; gap: 2px; }
.seg button { padding: 6px var(--sp-3); border-radius: var(--r-sm); font-size: var(--fs-sm);
  font-weight: 600; color: var(--text-2); }
.seg button.active { background: var(--card); color: var(--text); box-shadow: var(--shadow-1); }

/* ---- View head + toolbar ---- */
.view-head { margin-bottom: var(--sp-4); }
.view-title-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.view-title { font-size: var(--fs-2xl); font-weight: 800; letter-spacing: -.02em; }
.view-actions { display: flex; gap: var(--sp-2); }
.toolbar { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }

/* ---- Search box ---- */
.search-box { position: relative; flex: 1 1 260px; min-width: 200px; }
.search-box .search-ic { position: absolute; left: var(--sp-3); top: 50%; transform: translateY(-50%);
  font-size: var(--fs-sm); opacity: .7; pointer-events: none; }
.search-box .input { padding-left: var(--sp-8); }

/* ---- Input nhỏ ---- */
.input-sm { height: 34px; font-size: var(--fs-sm); width: auto; }

/* ---- Chip button (lọc nhanh) ---- */
.quick-filters { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.chip-btn {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  height: 34px; padding: 0 var(--sp-3);
  border-radius: var(--r-full);
  border: 1px solid var(--line-2); background: var(--surface-2);
  color: var(--text-2); font-size: var(--fs-sm); font-weight: 600;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.chip-btn:hover { background: var(--surface); color: var(--text); }
.chip-btn.active { background: var(--primary-weak); border-color: var(--primary); color: var(--primary); }
.chip-btn .qn { font-size: var(--fs-xs); opacity: .8; font-variant-numeric: tabular-nums; }

/* ---- Data table (bảng ứng viên) ---- */
table.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-sm); }
.data-table thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-2); color: var(--text-2);
  text-align: left; font-weight: 700;
  padding: var(--sp-3); white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
.data-table tbody td { padding: var(--sp-3); border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table tbody tr { background: var(--card); transition: background var(--dur) var(--ease); }
.data-table tbody tr:hover { background: var(--surface); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .col-check { width: 34px; text-align: center; }
.data-table .col-actions { width: 1%; white-space: nowrap; text-align: right; }
.cand-name { font-weight: 700; color: var(--text); }
.cand-name:hover { color: var(--primary); text-decoration: underline; }
.td-loading, .td-error { text-align: center; color: var(--muted); padding: var(--sp-8) var(--sp-4) !important; }
.td-error { color: var(--danger); }
.table-empty { text-align: center; color: var(--muted); padding: var(--sp-10) var(--sp-4); }
.table-empty .empty-emoji { font-size: 40px; margin-bottom: var(--sp-2); }

/* ---- Pipeline select trong ô ---- */
.pipe-select {
  height: 30px; padding: 0 var(--sp-6) 0 var(--sp-3);
  border-radius: var(--r-full); font-size: var(--fs-xs); font-weight: 700;
  border: 1px solid var(--pc, var(--line-2)); color: var(--pc, var(--text-2));
  background: transparent; cursor: pointer; appearance: none; max-width: 190px;
}

/* ---- Icon button ---- */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: var(--r-sm);
  background: transparent; color: var(--text-2); font-size: var(--fs-md);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.icon-btn:hover { background: var(--primary-weak); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-bg); color: var(--danger); }

/* ---- Bulk bar ---- */
.bulk-bar {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-4); margin-bottom: var(--sp-3);
  background: var(--primary-weak); border: 1px solid var(--primary);
  border-radius: var(--r-md); font-size: var(--fs-sm); font-weight: 600;
}
.bulk-bar[hidden] { display: none; }

/* ---- Pager ---- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  margin-top: var(--sp-4); flex-wrap: wrap; }
.pager-info { color: var(--text-2); font-size: var(--fs-sm); }
.pager-btns { display: flex; gap: var(--sp-2); }

/* ---- Form grid (modal thêm/sửa) ---- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.form-grid .field-full { grid-column: 1 / -1; }
.modal-body { padding: var(--sp-5); }
.modal-head { display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: var(--fs-lg); font-weight: 700; }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--sp-2); margin-top: var(--sp-2); }
.form-err { grid-column: 1 / -1; color: var(--danger); font-size: var(--fs-sm); min-height: 18px; }
.field-label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }

@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

/* ---- View sub (dòng mô tả dưới tiêu đề) ---- */
.view-sub { font-size: var(--fs-sm); color: var(--muted); margin-top: 2px; }

/* ---- KPI row (7 thẻ khóa 1 hàng trên màn rộng -> đều mắt) ---- */
.kpi-row {
  display: grid; gap: var(--sp-3); margin-bottom: var(--sp-4);
  grid-template-columns: repeat(7, minmax(0, 1fr));
}
@media (max-width: 1280px) { .kpi-row { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 1100px) { .kpi-row { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 720px)  { .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 440px)  { .kpi-row { grid-template-columns: 1fr; } }

/* ---- Dashboard grid: 6 cột có chủ đích, phân cấp rõ ràng ----
   Hàng 1: Phễu tuyển dụng (1/2, span 3) + khối 4 chart lưới 2×2 (1/2, span 3)
   Hàng 2: Ứng viên mới theo ngày (full 6) */
.dash-grid {
  display: grid; gap: var(--sp-4);
  grid-template-columns: repeat(6, minmax(0, 1fr));
  align-items: stretch;
}
.dash-card { display: flex; flex-direction: column; min-width: 0; }
.dash-card .card-body { flex: 1; min-width: 0; }
/* Phễu (1/2 trái) + khối 2×2 (1/2 phải) khóa cùng chiều cao. Donut to nhờ
   legend nằm bên phải (vòng tròn bên trái chiếm phần lớn ô), không bị
   align-items:stretch kéo giãn lệch nhau. */
.dash-funnel { grid-column: span 3; height: 480px; }
.dash-quad   { grid-column: span 3; height: 480px; }
.dash-wide   { grid-column: span 6; }   /* thời gian full-width */

/* Khối 4 chart: lưới 2×2 bên trong nửa phải, 2 hàng chia đều chiều cao */
.dash-quad {
  display: grid; gap: var(--sp-4);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
}
/* Chart trong quad co giãn lấp đầy ô (không đặt chiều cao cứng) */
.dash-quad .card-body { display: flex; }

/* tablet: phễu và khối 2×2 xếp dọc, mỗi cái full-width, cao tự nhiên */
@media (max-width: 960px) {
  .dash-funnel, .dash-quad { grid-column: 1 / -1; height: auto; }
}

/* mobile: mọi card full-width, xếp dọc; 2×2 -> 1 cột */
@media (max-width: 640px) {
  .dash-grid { grid-template-columns: 1fr; }
  .dash-funnel, .dash-quad, .dash-wide { grid-column: 1 / -1; }
  .dash-quad { grid-template-columns: 1fr; }
}

/* ---- Chart box (giữ chiều cao ổn định cho canvas) ---- */
.chart-box { position: relative; height: 260px; }
.chart-box-lg { height: 300px; }
.chart-box canvas { max-width: 100%; }
/* Chart trong khối 2×2: bỏ chiều cao cứng, để canvas lấp đầy ô lưới (đã khóa 420px) */
.dash-quad .chart-box { height: auto; flex: 1; min-height: 0; }
.chart-empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--sp-2); color: var(--muted); font-size: var(--fs-sm);
}
.chart-empty-ic { font-size: 32px; opacity: .5; }

/* ---- Funnel pipeline ---- */
/* Phễu lấp đầy đều chiều cao card (khóa 420px cùng khối 2×2): các hàng
   phân bố cách đều, không dư khoảng trống dưới cũng không tràn khi đủ 9 stage. */
#funnelBox { display: flex; flex-direction: column; justify-content: space-between; gap: var(--sp-2); }
.funnel-row {
  display: grid; grid-template-columns: 150px 1fr auto;
  align-items: center; gap: var(--sp-3);
}
.funnel-label {
  font-size: var(--fs-sm); font-weight: 600; color: var(--text-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.funnel-track { background: var(--surface-2); border-radius: var(--r-full); height: 22px; overflow: hidden; }
.funnel-fill {
  height: 100%; border-radius: var(--r-full); min-width: 2px;
  transition: width var(--dur) var(--ease);
}
.funnel-num {
  font-size: var(--fs-sm); font-weight: 700; text-align: right;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.funnel-pct { color: var(--muted); font-weight: 600; margin-left: var(--sp-2); }
@media (max-width: 560px) { .funnel-row { grid-template-columns: 100px 1fr auto; } }

/* ---- Cây Khu vực → Công ty ---- */
.org-tree { padding: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-3); }
.org-region { border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: var(--surface); }
.org-region-head {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-2); border-bottom: 1px solid var(--line);
}
.org-region-name { font-weight: 700; font-size: var(--fs-md); }
.org-count { color: var(--text-2); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.org-actions { margin-left: auto; display: inline-flex; gap: 2px; }
.org-region-head .org-actions { margin-left: auto; }
.org-companies { display: flex; flex-direction: column; }
.org-company {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--line);
  transition: background var(--dur) var(--ease);
}
.org-company:last-child { border-bottom: none; }
.org-company:hover { background: var(--surface-2); }
.org-company-name { font-weight: 600; color: var(--text); }
.org-company-name:hover { color: var(--primary); }
.org-company .org-count { margin-left: auto; }
.org-company .org-actions { margin-left: 0; }
.org-empty { padding: var(--sp-3) var(--sp-4); color: var(--muted); font-size: var(--fs-sm); font-style: italic; }

/* ---- AI button ---- */
.btn-ai {
  background: linear-gradient(180deg, #a855f7, #7c3aed);
  border-color: #7c3aed; color: #fff;
  box-shadow: 0 4px 14px rgba(168,85,247,.35);
}
.btn-ai:hover { background: linear-gradient(180deg, #9333ea, #6d28d9); border-color: #6d28d9; }

/* ============================================================
   Kanban (Pipeline)
   ============================================================ */
.kanban {
  display: flex; gap: var(--sp-3); overflow-x: auto;
  padding-bottom: var(--sp-3); align-items: flex-start;
}
.kb-col {
  flex: 0 0 240px; max-width: 240px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); display: flex; flex-direction: column;
  max-height: calc(100vh - 180px);
  border-top: 3px solid var(--c, var(--line-2));   /* dải màu stage trên đỉnh cột */
}
.kb-col-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-2); padding: var(--sp-3);
  border-bottom: 1px solid var(--line);
  border-top-left-radius: var(--r-lg); border-top-right-radius: var(--r-lg);
  position: sticky; top: 0; z-index: 1;
  /* nền header nhuốm nhẹ theo màu stage -> nhận diện cột nhanh */
  background:
    linear-gradient(0deg, color-mix(in srgb, var(--c, var(--muted)) 12%, var(--surface-2)),
                          color-mix(in srgb, var(--c, var(--muted)) 12%, var(--surface-2)));
}
.kb-col-name::before {
  content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 6px;
  border-radius: 50%; background: var(--c, var(--muted)); vertical-align: middle;
}
.kb-col-name { font-weight: 700; font-size: var(--fs-sm); color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kb-col-count {
  min-width: 22px; height: 22px; padding: 0 var(--sp-2);
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-full); background: var(--c, var(--muted)); color: #fff;
  font-size: var(--fs-xs); font-weight: 700; font-variant-numeric: tabular-nums;
}
.kb-list { padding: var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-2);
  overflow-y: auto; flex: 1; min-height: 60px; }
.kb-locked { opacity: .96; }
.kb-card {
  background: var(--card); border: 1px solid var(--line-2);
  border-left: 3px solid var(--c, var(--line-2));   /* dải màu stage theo cột chứa thẻ */
  border-radius: var(--r-md); padding: var(--sp-3);
  box-shadow: var(--shadow-1); cursor: grab;
  display: flex; flex-direction: column; gap: var(--sp-2);
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.kb-card:hover { border-color: var(--primary); border-left-color: var(--c, var(--primary)); }
.kb-card:active { cursor: grabbing; }
.kb-card-name { font-weight: 700; color: var(--text); }
.kb-card-name:hover { color: var(--primary); }
.kb-card-meta { display: flex; flex-wrap: wrap; gap: 4px; }
.kb-card-sub { font-size: var(--fs-xs); color: var(--text-2); }
.chip-muted { background: var(--surface-2); color: var(--text-2); }
.kb-ghost { opacity: .4; }
.kb-drag { transform: rotate(2deg); box-shadow: var(--shadow-3); }

/* ============================================================
   Profile (hồ sơ + timeline + scorecard)
   ============================================================ */
.profile-head { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.profile-grid { display: grid; grid-template-columns: 1fr 380px; gap: var(--sp-4); align-items: start; }
.profile-main { min-width: 0; }
.profile-side { display: flex; flex-direction: column; gap: var(--sp-4); }
@media (max-width: 900px) { .profile-grid { grid-template-columns: 1fr; } }

.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
.info-item { min-width: 0; }
.info-full { grid-column: 1 / -1; }
.info-label { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.info-value { font-size: var(--fs-md); color: var(--text); margin-top: 2px; word-break: break-word; }
@media (max-width: 560px) { .info-grid { grid-template-columns: 1fr; } }

.scorecard { overflow: hidden; }
.score-big { display: flex; align-items: baseline; gap: var(--sp-2); color: var(--c, var(--muted)); }
.score-num { font-size: 52px; font-weight: 800; line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.score-unit { font-size: var(--fs-sm); color: var(--text-2); font-weight: 600; }
.score-reason { margin-top: var(--sp-3); font-size: var(--fs-sm); color: var(--text-2); }
.score-breakdown { margin-top: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-1); }
.sb-row {
  display: grid; grid-template-columns: 20px 1fr auto; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2); border-radius: var(--r-sm); font-size: var(--fs-sm);
}
.sb-row.ok { background: var(--ok-bg); }
.sb-row.no { background: var(--danger-bg); }
.sb-ic { font-weight: 800; }
.sb-row.ok .sb-ic { color: var(--ok); }
.sb-row.no .sb-ic { color: var(--danger); }
.sb-label { color: var(--text-2); }
.sb-pts { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }

/* ============================================================
   Import / Export + Sync (P5)
   ============================================================ */
.check-row { display: flex; align-items: center; gap: var(--sp-2); margin: var(--sp-3) 0;
  font-size: var(--fs-sm); color: var(--text-2); cursor: pointer; }
.check-row input { width: 16px; height: 16px; accent-color: var(--primary); }
.import-preview { margin: var(--sp-3) 0; }
.import-count { font-size: var(--fs-sm); color: var(--text-2); margin-bottom: var(--sp-3); }
.import-count b { color: var(--text); }

.sync-guide { font-size: var(--fs-sm); color: var(--text-2); line-height: 1.6;
  padding: var(--sp-3) var(--sp-4); background: var(--surface-2);
  border-radius: var(--r-md); border: 1px solid var(--line); }
.sync-guide b { color: var(--text); }
.sync-status { margin-top: var(--sp-3); font-size: var(--fs-sm); }
.sync-result { margin-top: var(--sp-3); }
.sync-done { padding: var(--sp-3) var(--sp-4); background: var(--ok-bg); color: var(--ok);
  border-radius: var(--r-md); font-size: var(--fs-sm); font-weight: 600; }
.sync-done b { color: var(--text); }

/* ---- Phạm vi công ty (gán scope cho user) ---- */
.scope-box { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-1) var(--sp-3);
  max-height: 180px; overflow-y: auto; padding: var(--sp-2) var(--sp-3);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); }
.scope-box .check-row { margin: 0; padding: 2px 0; font-size: var(--fs-sm); }

/* ---- Chip màu động (dùng inline style --c) ---- */
.chip[style*="--c"] {
  background: color-mix(in srgb, var(--c) 16%, transparent);
  color: var(--c);
  border-color: color-mix(in srgb, var(--c) 32%, transparent);
}

/* ---- Kế hoạch tuyển dụng (hiring plans) ---- */
.plan-grid {
  display: grid; gap: var(--sp-4);
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
}
.plan-card { display: flex; flex-direction: column; gap: var(--sp-3); padding: var(--sp-4); }
.plan-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-2); }
.plan-title { font-weight: 700; font-size: var(--fs-md); color: var(--text); }
.plan-scope { font-size: var(--fs-xs); color: var(--text-2); margin-top: 2px; }
.plan-progress { display: flex; flex-direction: column; gap: var(--sp-2); }
.plan-progress-bar {
  height: 8px; border-radius: var(--r-full);
  background: var(--surface-2); overflow: hidden;
}
.plan-progress-fill { height: 100%; border-radius: var(--r-full); transition: width var(--dur) var(--ease); }
.plan-progress-meta {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--sp-2);
  font-size: var(--fs-xs); color: var(--text-2); font-variant-numeric: tabular-nums;
}
.plan-progress-meta b { color: var(--text); }
.plan-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.plan-funnel { display: flex; flex-wrap: wrap; gap: 4px; }
.plan-funnel-item {
  font-size: var(--fs-xs); color: var(--text-2);
  padding: 2px var(--sp-2); border-radius: var(--r-full);
  background: var(--surface-2); border: 1px solid var(--line-2);
  font-variant-numeric: tabular-nums;
}
.plan-funnel-item b { color: var(--text); }
.plan-note {
  font-size: var(--fs-xs); color: var(--text-2);
  padding: var(--sp-2) var(--sp-3); background: var(--surface-2);
  border-radius: var(--r-md); border: 1px solid var(--line-2);
}
.plan-card-foot { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: auto; }
.btn.danger, .icon-btn.danger { color: var(--danger); }
.field-hint { margin-top: var(--sp-1); font-size: var(--fs-xs, 12px); color: var(--text-2); line-height: 1.5; }

/* ============================================================
   Users + Settings + Anomaly (P6)
   ============================================================ */
/* Settings note */
.settings-note {
  margin: var(--sp-4) 0; padding: var(--sp-3) var(--sp-4);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-md); font-size: var(--fs-sm); color: var(--text-2); line-height: 1.6;
}
.settings-note code {
  background: var(--bg-2); padding: 1px 6px; border-radius: var(--r-sm);
  font-size: .92em; color: var(--text); border: 1px solid var(--line-2);
}

/* Anomaly */
.an-summary { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap;
  margin-bottom: var(--sp-4); font-size: var(--fs-sm); color: var(--text-2); }
.an-summary b { color: var(--text); }
.an-groups { display: flex; flex-direction: column; gap: var(--sp-3); }
.an-group { overflow: hidden; }
.an-group-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); background: var(--surface-2); border-bottom: 1px solid var(--line);
}
.an-group-title { font-weight: 600; font-size: var(--fs-sm); }
.an-group-title code { background: var(--bg-2); padding: 1px 6px; border-radius: var(--r-sm);
  color: var(--danger); font-weight: 700; }
.an-members { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4); }
.an-member {
  display: flex; flex-direction: column; gap: 2px;
  padding: var(--sp-2) var(--sp-3); border: 1px solid var(--line-2);
  border-radius: var(--r-md); background: var(--surface);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.an-member:hover { border-color: var(--primary); background: var(--surface-2); }
.an-member-name { font-weight: 700; color: var(--text); }
.an-member-info { font-size: var(--fs-xs); color: var(--muted); }

/* ============================================================
   Dashboard: widget "Kế hoạch tuyển dụng"
   ============================================================ */
.dash-plans {
  margin-bottom: var(--sp-4);
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: var(--sp-3) var(--sp-4);
}
.dash-plans-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3); margin-bottom: var(--sp-2);
}
.dash-plans-head .card-title { font-weight: 800; }
.dash-plans-link { font-size: var(--fs-sm); font-weight: 600; color: var(--primary); white-space: nowrap; }
.dash-plans-link:hover { text-decoration: underline; }
.dash-plans-grid {
  display: grid; gap: var(--sp-3);
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
@media (max-width: 960px) { .dash-plans-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .dash-plans-grid { grid-template-columns: 1fr; } }

.plan-mini {
  display: flex; flex-direction: column; gap: 6px;
  padding: var(--sp-2) var(--sp-3); border: 1px solid var(--line-2);
  border-radius: var(--r-md); background: var(--surface);
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.plan-mini:hover { border-color: var(--primary); transform: translateY(-1px); }
.plan-mini-top { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.plan-mini-title { font-weight: 700; color: var(--text); font-size: var(--fs-sm);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plan-mini-bar { height: 6px; border-radius: var(--r-full); background: var(--surface-2); overflow: hidden; }
.plan-mini-fill { height: 100%; border-radius: var(--r-full); min-width: 2px;
  transition: width var(--dur) var(--ease); }
.plan-mini-foot { display: flex; align-items: center; justify-content: space-between;
  font-size: var(--fs-xs); color: var(--text-2); }
.plan-mini-foot b { color: var(--text); font-variant-numeric: tabular-nums; }
.plan-mini-pct { font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }

/* ============================================================
   Mobile: gom bộ lọc vào nút "Lọc" + ẩn cột phụ của bảng
   ============================================================ */
/* Nút "Lọc" chỉ dùng trên mobile; desktop hiện đủ dropdown nên ẩn nút đi */
.toolbar-filter-toggle { display: none; }
/* Chấm báo đang có bộ lọc áp dụng (hiện cạnh chữ "Lọc") */
.filter-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--primary); vertical-align: middle; margin-left: 2px; }
/* filter-group: desktop hiển thị inline như cũ (các control nằm trên toolbar) */
.filter-group { display: contents; }

@media (max-width: 820px) {
  /* Trên mobile: nút Lọc hiện ra, cụm dropdown gom lại và mặc định ẩn */
  .toolbar-filter-toggle { display: inline-flex; }
  .filter-group {
    display: none; flex-basis: 100%; flex-wrap: wrap; gap: var(--sp-2);
  }
  .filter-group.open { display: flex; }
  /* Các dropdown trong nhóm giãn đều cho dễ chạm */
  .filter-group .input-sm { flex: 1 1 45%; min-width: 140px; }
  .filter-group #btnClearFilters { flex: 1 1 100%; }
}

/* Ẩn cột phụ của bảng ứng viên trên màn nhỏ (giữ: chọn, Họ tên, SĐT, Pipeline, thao tác) */
@media (max-width: 560px) {
  .data-table .col-opt { display: none; }
}

/* ============================================================
   Khu vực & Công ty: nút thu gọn/mở rộng + Nhập/Xuất actions
   ============================================================ */
/* Nút mũi tên thu gọn/mở rộng từng khu vực */
.org-toggle {
  flex: none; width: 22px; height: 22px; margin-right: 2px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm); color: var(--text-2);
  font-size: var(--fs-sm); line-height: 1;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.org-toggle:hover { background: var(--surface); color: var(--text); }

/* ============================================================
   Phát hiện bất thường: hàng thành viên + chọn giữ/gộp
   ============================================================ */
.an-member-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.an-member-row:first-child { border-top: 0; }
.an-pick {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--fs-sm); color: var(--text-2); cursor: pointer;
  white-space: nowrap;
}
.an-pick input { cursor: pointer; }
.an-member-row .an-member { flex: 1 1 220px; min-width: 0; }
.an-member-tags { display: inline-flex; gap: 4px; flex: none; }
.an-group-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3); flex-wrap: wrap;
  padding: var(--sp-3);
  border-top: 1px solid var(--border);
}
.an-hint { font-size: var(--fs-sm); color: var(--text-2); flex: 1 1 240px; }

/* Card Xuất: dải thông tin bộ lọc + cụm nút */
.export-filter-info {
  font-size: var(--fs-sm); color: var(--text-2);
  margin-bottom: var(--sp-3); line-height: 1.5;
}
.export-filter-info b { color: var(--text); }
.export-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }

/* ============================================================
   Cần xử lý hôm nay (worklist)
   ============================================================ */
.wl-summary {
  display: flex; flex-wrap: wrap; gap: var(--sp-2);
  margin-bottom: var(--sp-4);
}
.wl-section { margin-bottom: var(--sp-4); padding: var(--sp-3) var(--sp-4); }
.wl-section-head {
  display: flex; align-items: center; gap: var(--sp-2);
  font-weight: 600; margin-bottom: var(--sp-3);
}
.wl-rows { display: flex; flex-direction: column; }
.wl-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-top: 1px solid var(--border);
}
.wl-row:first-child { border-top: 0; }
.wl-main { flex: 1 1 auto; min-width: 0; }
.wl-name {
  font-weight: 600; color: var(--text); text-decoration: none;
  display: inline-block; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wl-name:hover { text-decoration: underline; }
.wl-meta {
  font-size: var(--fs-sm); color: var(--text-2);
  margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wl-tags {
  flex: none; display: flex; align-items: center; gap: var(--sp-2);
  flex-wrap: wrap; justify-content: flex-end;
}
.wl-since { font-size: var(--fs-sm); color: var(--text-2); white-space: nowrap; }
.wl-act { flex: none; }

@media (max-width: 640px) {
  .wl-row { flex-wrap: wrap; align-items: flex-start; }
  .wl-tags { justify-content: flex-start; width: 100%; }
  .wl-act { width: 100%; }
  .wl-act .btn { width: 100%; }
}

/* ============================================================
   Thông báo tự động (view notifications)
   ============================================================ */
.nt-list { display: flex; flex-direction: column; gap: var(--sp-3); }

/* Mỗi thẻ có viền trái theo màu loại (--nt). Đã đọc -> viền nhạt đi. */
/* .card không có padding sẵn (padding vốn đến từ .card-body) nên thêm ở đây. */
.nt-card {
  cursor: default;
  padding: var(--sp-4) var(--sp-5);
  border-left: 4px solid var(--nt, var(--primary, #3b82f6));
}
.nt-card:not(.unread) { border-left-color: color-mix(in srgb, var(--nt, #3b82f6) 35%, transparent); }
.nt-card.unread { background: color-mix(in srgb, var(--nt, #3b82f6) 5%, var(--card)); }

.nt-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-2); margin-bottom: var(--sp-1);
}
.nt-kind {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--fs-sm); font-weight: 700; color: var(--nt, var(--text-2));
}
.nt-icon { font-size: 1.05em; }
.nt-time {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--fs-sm); color: var(--text-2); white-space: nowrap;
}
/* Chấm nổi bật cho thẻ chưa đọc. */
.nt-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--nt, var(--primary, #3b82f6));
}
.nt-title { font-weight: 600; margin-bottom: var(--sp-2); line-height: 1.4; }

/* ---- Báo cáo ngày: ô số + chip nguồn + kế hoạch ---- */
.nt-tiles { display: flex; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.nt-tile {
  flex: 1 1 120px; min-width: 110px;
  background: var(--surface); border-radius: var(--r-md);
  padding: var(--sp-3); text-align: center;
}
.nt-tile-num {
  font-size: 1.9rem; font-weight: 800; line-height: 1.1;
  color: var(--nt, var(--text)); font-variant-numeric: tabular-nums;
}
.nt-tile-label { font-size: var(--fs-sm); color: var(--text-2); margin-top: 2px; }

.nt-sub-label {
  display: block; font-size: var(--fs-sm); font-weight: 600;
  color: var(--text-2); margin-bottom: var(--sp-2);
}
.nt-sources { margin-bottom: var(--sp-3); }
.nt-chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.nt-src-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  font-size: var(--fs-sm); color: var(--text-2);
}
.nt-src-chip b { color: var(--text); }

.nt-plans { border-top: 1px solid var(--border); padding-top: var(--sp-3); }
.nt-plan-row {
  display: flex; justify-content: space-between; gap: var(--sp-2);
  font-size: var(--fs-sm); padding: 3px 0;
}
.nt-plan-due { color: var(--text-2); white-space: nowrap; }

/* ---- Follow-up / Reawaken: hàng ứng viên có nút Gọi ---- */
.nt-cands {
  display: flex; flex-direction: column; gap: 2px;
  margin-top: var(--sp-2); padding-top: var(--sp-3);
  border-top: 1px solid var(--border);
}
.nt-cand {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2); border-radius: var(--r-sm);
  transition: background var(--dur) var(--ease);
}
.nt-cand:hover { background: var(--surface); }
.nt-cand-main {
  flex: 1 1 auto; min-width: 0;
  display: flex; align-items: center; gap: var(--sp-2);
  color: inherit; text-decoration: none;
}
.nt-cand-name {
  font-weight: 500; flex: none;
  max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nt-cand-meta {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  margin-left: auto; overflow: hidden;
}
.nt-cand-since { font-size: var(--fs-sm); color: var(--text-2); white-space: nowrap; }
.nt-call { flex: none; }
.nt-more { font-size: var(--fs-sm); color: var(--text-2); padding: var(--sp-2); }
.nt-empty-line { font-size: var(--fs-sm); color: var(--text-2); padding: var(--sp-2) 0; }

@media (max-width: 640px) {
  .nt-cand { flex-wrap: wrap; }
  .nt-cand-main { width: 100%; }
  .nt-call { width: 100%; margin-top: 4px; }
}

/* ============================================================
   Tự động đồng bộ Form: công tắc gạt + khối cấu hình
   ============================================================ */
.sync-auto {
  margin-top: var(--sp-4); padding-top: var(--sp-4);
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: var(--sp-3);
}
.sync-auto-head { display: flex; align-items: flex-start; gap: var(--sp-3); }
.sync-auto-label { display: flex; flex-direction: column; gap: 2px; }
.sync-auto-label .cell-muted { font-size: var(--fs-sm); }
.sync-interval { max-width: 220px; }
.sync-auto-hint { font-size: var(--fs-sm); }

/* Công tắc gạt (checkbox ẩn + track/thumb) */
.switch { position: relative; display: inline-block; flex: none; width: 42px; height: 24px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--border); border-radius: 999px;
  transition: background var(--dur) var(--ease);
}
.switch-track::before {
  content: ""; position: absolute; left: 3px; top: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25);
  transition: transform var(--dur) var(--ease);
}
.switch input:checked + .switch-track { background: var(--primary, #3b82f6); }
.switch input:checked + .switch-track::before { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--primary, #3b82f6); outline-offset: 2px; }

/* ============================================================
   Chấm AI hàng loạt (view Cấu hình)
   ============================================================ */
.batch-stat { font-size: var(--fs-sm); color: var(--text); margin-bottom: var(--sp-3); }
.batch-stat b { color: var(--primary, #3b82f6); font-variant-numeric: tabular-nums; }
.batch-progress { margin-bottom: var(--sp-3); }
.batch-bar {
  height: 10px; border-radius: 999px; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
}
.batch-bar-fill {
  height: 100%; width: 0;
  background: var(--primary, #3b82f6);
  transition: width var(--dur) var(--ease);
}
.batch-progress-text {
  font-size: var(--fs-sm); color: var(--text-2);
  margin-top: var(--sp-2); font-variant-numeric: tabular-nums;
}

/* ============================================================
   Hiệu suất nguồn (Source ROI)
   ============================================================ */
.ss-filter {
  display: flex; align-items: flex-end; gap: var(--sp-3);
  flex-wrap: wrap; margin-top: var(--sp-3);
}
.field-inline {
  display: flex; flex-direction: column; gap: 4px;
  font-size: var(--fs-sm); color: var(--text-2);
}
.field-inline .input { min-width: 150px; }

.ss-kpis {
  display: grid; gap: var(--sp-3);
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  margin-bottom: var(--sp-4);
}
.ss-kpi {
  background: var(--card, #fff); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4);
  display: flex; flex-direction: column; gap: 2px;
}
.ss-kpi-val { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.ss-kpi-lbl { font-size: var(--fs-sm); color: var(--text-2); }
.ss-kpi.tone-ok .ss-kpi-val { color: var(--ok, #22c55e); }
.ss-kpi.tone-danger .ss-kpi-val { color: var(--danger, #ef4444); }

.ss-card { padding: 0; overflow: hidden; }
.ss-table-wrap { overflow-x: auto; }
.ss-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.ss-table th, .ss-table td {
  padding: var(--sp-3) var(--sp-3); text-align: left;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.ss-table th {
  font-weight: 600; color: var(--text-2);
  background: var(--surface); position: sticky; top: 0;
}
.ss-table td.num, .ss-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.ss-rank { width: 40px; text-align: center; }
.ss-table td.ss-rank { text-align: center; font-weight: 600; }
.ss-src { font-weight: 600; color: var(--text); max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.ss-table tbody tr:hover { background: var(--surface); }
.ss-total td { font-weight: 700; border-top: 2px solid var(--border); background: var(--surface); }

.ss-conv { display: inline-flex; align-items: center; gap: var(--sp-2); justify-content: flex-end; }
.ss-conv-val { font-variant-numeric: tabular-nums; min-width: 42px; text-align: right; }
.ss-bar {
  width: 70px; height: 7px; border-radius: 999px; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); flex: none;
}
.ss-bar-fill { height: 100%; border-radius: 999px; transition: width var(--dur) var(--ease); }
.ss-bar-fill.tone-ok { background: var(--ok, #22c55e); }
.ss-bar-fill.tone-warn { background: var(--warn, #f59e0b); }
.ss-bar-fill.tone-danger { background: var(--danger, #ef4444); }

.ss-note {
  font-size: var(--fs-sm); color: var(--text-2);
  padding: var(--sp-3) var(--sp-4); border-top: 1px solid var(--border);
  background: var(--surface);
}

.ss-kpi.tone-warn .ss-kpi-val { color: var(--warn, #f59e0b); }

@media (max-width: 640px) {
  .ss-src { max-width: 120px; }
}

/* ---- Nhập chi phí quảng cáo theo nguồn (A2) ---- */
.cost-form { display: flex; flex-direction: column; gap: var(--sp-3); }
.cost-list-head {
  margin-top: var(--sp-4); padding-top: var(--sp-3);
  border-top: 1px solid var(--border);
  font-weight: 600; font-size: var(--fs-sm);
}
.cost-list { display: flex; flex-direction: column; gap: 2px; margin-top: var(--sp-2); }
.cost-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-2); border-radius: var(--r-sm);
}
.cost-row:hover { background: var(--surface); }
.cost-row-src { font-weight: 600; flex: none; min-width: 120px; }
.cost-row-amt {
  font-variant-numeric: tabular-nums; color: var(--warn, #f59e0b);
  font-weight: 600; flex: none; min-width: 100px; text-align: right;
}
.cost-row-note {
  flex: 1 1 auto; min-width: 0; color: var(--text-2); font-size: var(--fs-sm);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---- Gộp nguồn trùng nghĩa (B1) ---- */
.merge-hint {
  font-size: var(--fs-sm); color: var(--text-2);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: var(--sp-3); margin-bottom: var(--sp-3);
}
.merge-hint b { color: var(--text); }
.merge-list {
  display: flex; flex-direction: column; gap: 2px;
  max-height: 300px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: var(--r-sm); padding: var(--sp-2);
}
.merge-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-2); border-radius: var(--r-sm); cursor: pointer;
}
.merge-item:hover { background: var(--surface); }
.merge-item input { flex: none; }
.merge-item-name { font-weight: 500; flex: 1 1 auto; }
.merge-item-count {
  flex: none; font-size: var(--fs-sm); color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

/* ---- Nhiều Google Form theo nguồn (C1) ---- */
.forms-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.form-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3); border: 1px solid var(--border);
  border-radius: var(--r-md); background: var(--card, #fff);
  transition: opacity var(--dur) var(--ease);
}
.form-row.form-off { opacity: .55; }
.form-row-main { flex: 1 1 auto; min-width: 0; }
.form-row-title {
  display: flex; align-items: center; gap: var(--sp-2);
  font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.form-row-sub {
  font-size: var(--fs-sm); color: var(--text-2); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.form-row-actions { flex: none; display: inline-flex; align-items: center; gap: var(--sp-2); }

@media (max-width: 640px) {
  .form-row { flex-wrap: wrap; }
  .form-row-main { width: 100%; order: 3; }
}

/* ---- Link tuyển dụng gắn nguồn (C2) ---- */
.rl-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.rl-row {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-3); border: 1px solid var(--border);
  border-radius: var(--r-md); background: var(--card, #fff);
  transition: opacity var(--dur) var(--ease);
}
.rl-row.rl-off { opacity: .55; }
.rl-row .switch { margin-top: 2px; }
.rl-main { flex: 1 1 auto; min-width: 0; }
.rl-title {
  display: flex; align-items: center; gap: var(--sp-2);
  font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rl-url {
  display: flex; align-items: center; gap: var(--sp-2);
  margin-top: 4px; min-width: 0;
}
.rl-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: var(--fs-sm); color: var(--primary, #3b82f6);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 2px 8px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%;
}
.rl-sub {
  font-size: var(--fs-sm); color: var(--text-2); margin-top: 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rl-actions { flex: none; display: inline-flex; align-items: center; gap: var(--sp-2); }
.rl-form-hint {
  font-size: var(--fs-sm); color: var(--text-2);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: var(--sp-3); line-height: 1.5;
}

@media (max-width: 640px) {
  .rl-row { flex-wrap: wrap; }
  .rl-main { width: 100%; order: 3; }
}
