/* ---- Toast notification ---- */
.toast-wrap {
  position: fixed; top: 20px; right: 20px; z-index: 999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--brand-ink); color: var(--on-brand); padding: 12px 18px; border-radius: 8px;
  font-size: 13px; box-shadow: 0 6px 18px var(--shadow);
  display: flex; align-items: center; gap: 8px; min-width: 220px;
  animation: toast-in 0.2s ease;
}
.toast.toast-error { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.toast.toast-out { animation: toast-out 0.2s ease forwards; }
@keyframes toast-out { to { opacity: 0; transform: translateX(20px); } }

/* ---- Notice popup (thành công / thất bại) ---- */
.notice-box { text-align: center; }
/* Ghi đè tiêu đề sticky/margin âm của .modal-box > h3 (nó đè lên biểu tượng ở đầu popup). */
.modal-box.notice-box > h3 { position: static; margin: 12px 0 6px; padding: 0; background: none; }
.notice-box p { color: var(--text-muted); font-size: 14px; margin: 0 0 4px; word-break: break-word; }
.notice-box .modal-actions { justify-content: center; margin-top: 16px; }
.notice-icon {
  width: 48px; height: 48px; border-radius: 50%; margin: 0 auto;
  display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 700;
}
.notice-success .notice-icon { background: var(--success-soft); color: var(--success); }
.notice-error .notice-icon { background: var(--danger-soft); color: var(--danger); }

/* ---- Loading skeleton ---- */
.skeleton-bar {
  height: 14px; border-radius: 4px; width: 100%;
  background: linear-gradient(90deg, var(--skeleton-base) 25%, var(--skeleton-highlight) 37%, var(--skeleton-base) 63%);
  background-size: 400% 100%;
  animation: skeleton-shimmer 1.4s ease infinite;
}
@keyframes skeleton-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}
.toolbar input, .toolbar select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: var(--control-bg);
  color: var(--text);
}
.toolbar .search-input { width: 220px; }
.toolbar .grow { flex: 1; }
.toolbar.toolbar-sticky {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--card);
  padding: 6px 0;
}
/* Tab con dạng gạch chân (vd trang Hoa hồng NV: Báo cáo | Cấu hình) */
.subtabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.subtab {
  background: none; border: none; border-bottom: 2px solid transparent; margin-bottom: -1px;
  padding: 8px 14px; font: inherit; font-size: 14px; font-weight: 600;
  color: var(--text-muted); cursor: pointer;
}
.subtab:hover { color: var(--ink); }
.subtab.active { color: var(--ink); border-bottom-color: var(--accent); }
.subtab-count { font-weight: 500; color: var(--text-muted); }
.checkbox-inline { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); }
.admin-toggle-box {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-subtle);
  color: var(--text);
  font-size: 13px;
}
.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  margin-top: 6px;
}
.perm-grid.disabled { opacity: 0.5; pointer-events: none; }
.perm-grid .perm-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-subtle);
  font-size: 13px;
  color: var(--text);
}
.perm-grid .perm-item select { font-size: 13px; padding: 5px 6px; }

.profile-menu-wrap { position: relative; }
.profile-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px 6px 6px;
  border-radius: 999px;
  background: var(--control-bg);
  border: 1px solid var(--border);
  cursor: pointer;
}
.profile-chip:hover { border-color: var(--accent); }
.profile-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: var(--brand-ink); color: var(--on-brand);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.profile-meta { text-align: left; line-height: 1.35; }
.profile-name { font-size: 13px; font-weight: 600; color: var(--ink); }
.profile-role {
  display: inline-block; margin-top: 2px; font-size: 11px; font-weight: 600;
  padding: 1px 8px; border-radius: 999px;
}
.profile-role.admin { background: var(--success-soft); color: var(--success); }
.profile-role.staff { background: var(--surface-neutral); color: var(--text-muted); }
.profile-dropdown {
  display: none;
  position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 24px var(--shadow);
  min-width: 190px; padding: 6px; z-index: 45;
}
.profile-dropdown.open { display: block; }
.profile-dropdown-item {
  display: block; width: 100%; text-align: left;
  padding: 9px 10px; border: none; background: none;
  font-size: 13px; color: var(--text); border-radius: 6px; cursor: pointer;
}
.profile-dropdown-item:hover { background: var(--surface-hover); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
/* Bảng tự có vùng cuộn riêng, dòng tiêu đề cột đứng yên khi cuộn —
   giống cách diem-van-hoa đang làm, áp dụng cho các bảng danh sách chính. */
.table-scroll { overflow: auto; max-height: calc(100vh - 320px); }
.table-scroll table thead th { position: sticky; top: 0; z-index: 3; background: var(--card); }
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--ink); }
thead th.sortable .sort-arrow { display: inline-block; width: 10px; opacity: 0.5; }
thead th.sortable.sort-active { color: var(--ink); }
thead th.sortable.sort-active .sort-arrow { opacity: 1; }
tbody td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
tbody tr:hover { background: var(--surface-hover); }
.muted { color: var(--text-muted); }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-selected);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
}
.badge.warn { background: var(--warning-soft); color: var(--warning-text); }
.badge.off { background: var(--surface-neutral); color: var(--text-muted); }
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.platform-badges { display: flex; flex-wrap: wrap; gap: 4px; min-width: 72px; }
.badge.platform-badge { border: 1px solid var(--section-accent-border); white-space: nowrap; }
/* Báo cáo tháng: loại tiền tài khoản của khách — 1 viên chia ô [USD 1 | VND 2] */
.currency-badges {
  display: flex; width: max-content; margin-top: 5px; border: 1px solid var(--border); border-radius: 999px;
  overflow: hidden; white-space: nowrap; font-size: 11px; font-weight: 600; line-height: 18px; vertical-align: middle;
}
.currency-badges.multi { border-color: var(--warning-text); box-shadow: 0 0 0 2px var(--warning-soft); }
.currency-badge { display: inline-flex; align-items: center; gap: 5px; padding: 0 8px; }
.currency-badge + .currency-badge { border-left: 1px solid var(--border); }
.currency-badge b { font-weight: 800; }
.currency-badge.cur-usd { background: var(--success-soft); color: var(--success); }
.currency-badge.cur-vnd { background: var(--surface-selected); color: var(--accent); }
.currency-badge.cur-other { background: var(--surface-neutral); color: var(--text-muted); }
.client-duplicate-help { margin: 0 0 12px; color: var(--text-muted); font-size: 14px; }
.client-duplicate-list { display: grid; gap: 8px; }
.client-duplicate-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-subtle);
}
.client-duplicate-info { min-width: 0; }
.client-duplicate-code { margin-top: 3px; color: var(--text-muted); font-size: 12px; }
.client-duplicate-current { color: var(--warning-text); font-size: 12px; font-weight: 600; }
.client-duplicate-item .btn { flex: 0 0 auto; }
@media (max-width: 560px) {
  .client-duplicate-item { align-items: stretch; flex-direction: column; }
}
tr.group-tier td { background: var(--brand-ink); color: var(--on-brand); font-weight: 700; padding: 8px 10px; }
tr.currency-group-row td { background: var(--section-accent-bg); padding: 7px 10px; } /* Chi tiết theo Account: nhóm theo Currency */
tr.group-market td { background: var(--group-market); color: var(--ink); font-weight: 600; padding: 7px 10px 7px 26px; }
tr.group-product td { background: var(--surface-subtle); color: var(--ink); font-weight: 500; padding: 6px 10px 6px 42px; }
tr.group-product a { color: var(--accent); text-decoration: none; }
tr.group-product a:hover { text-decoration: underline; }
.row-actions { display: flex; gap: 6px; flex-wrap: nowrap; }
.empty-state { text-align: center; padding: 40px 0; color: var(--text-muted); }

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
  font-size: 13px;
  color: var(--text-muted);
}
.page-jump-input {
  width: 64px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--control-bg);
  color: var(--text);
}

/* ---------- Modal ---------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--overlay);
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--card);
  border-radius: 12px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
}
.modal-box.small { max-width: 380px; }
.modal-box.wide { max-width: 1100px; }
/* Thêm nhanh Account từ Client: ô nhập kín cột, đủ rộng để đọc */
.quick-accounts-table input, .quick-accounts-table select { width: 100%; min-width: 130px; }
.quick-accounts-table td { padding: 6px 4px; }
.bp-bulk-tabs { display: flex; gap: 8px; margin-bottom: 10px; }
.modal-box h3 { margin: 0 0 16px; color: var(--ink); }
/* Tiêu đề modal (luôn là phần tử con đầu tiên của .modal-box) đứng yên
   khi cuộn nội dung dài bên trong — bleed ra hết padding của .modal-box
   bằng margin âm, giống cách .topbar làm ở khung trang chính. */
.modal-box > h3 {
  position: sticky; top: -24px; z-index: 2;
  margin: -24px -24px 16px; padding: 24px 24px 0;
  background: var(--card);
}
.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 14px;
}
.modal-grid .full { grid-column: 1 / -1; }
.modal-grid .span-2 { grid-column: span 2; }
/* Modal rộng (.modal-box.wide) dùng 3 cột cho đỡ trống — form Client */
.modal-box.wide .modal-grid { grid-template-columns: 1fr 1fr 1fr; }
/* Mỗi khu vực trong form đóng khung riêng, có nền phân biệt với modal
   (nền trắng) — dùng luôn --bg của trang (xám xanh nhạt) cho đồng bộ
   màu hệ thống thay vì bịa màu mới. */
.modal-section {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 14px;
}
.modal-section:last-of-type { margin-bottom: 0; }
/* Mỗi khu vực 1 màu nền khác nhau (pastel nhạt, pha từ màu thương hiệu
   --accent/--ink + amber trung tính) để phân biệt nhanh bằng mắt, viền
   giữ cùng tông cho đỡ chói. */
.modal-section--accent { background: var(--section-accent-bg); border-color: var(--section-accent-border); }
.modal-section--ink { background: var(--section-ink-bg); border-color: var(--section-ink-border); }
.modal-section--amber { background: var(--section-amber-bg); border-color: var(--section-amber-border); }
/* Toàn bộ field trong khu "Thông tin bắt buộc" đều required — tô đỏ +
   đậm tên field (không phải input) để nhận ra ngay field nào bắt buộc. */
.modal-section--accent .field label:not(.checkbox-inline) {
  color: var(--danger); font-weight: 700;
}
.modal-section-title {
  margin: 0 0 10px; font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted);
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}
/* Hàng nút Lưu/Huỷ CUỐI CÙNG của modal đứng yên ở đáy khi cuộn, cùng lý
   do như tiêu đề — chỉ gắn class này cho đúng 1 hàng cuối mỗi modal (vài
   modal có nhiều .modal-actions rải rác giữa nội dung, kiểu "Tài khoản
   của tôi" có 3 hàng, không phải hàng nào cũng nên dính đáy). */
.modal-actions.sticky-footer {
  position: sticky; bottom: -24px; z-index: 2;
  padding: 12px 24px 24px; margin-left: -24px; margin-right: -24px; margin-bottom: -24px;
  background: var(--card);
}
.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
}

.pick-list { max-height: 220px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; margin-top: 8px; }
.pick-list-float {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 30;
  max-height: 220px; overflow-y: auto; background: var(--card);
  border: 1px solid var(--border); border-radius: 8px; margin-top: 4px;
  box-shadow: 0 8px 24px var(--shadow);
}
.pick-item { padding: 8px 10px; cursor: pointer; font-size: 13px; border-bottom: 1px solid var(--border); }
.pick-item:last-child { border-bottom: none; }
.pick-item:hover { background: var(--surface-selected); }
.pick-item .sub { color: var(--text-muted); font-size: 11px; }
.selected-client-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-selected);
  color: var(--ink);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13px;
}
.selected-client-chip button {
  border: none; background: none; color: var(--danger); cursor: pointer; font-weight: 700;
}

.topup-tabbar { margin-bottom: 16px; border-bottom: 1px solid var(--border); padding-bottom: 12px; }
.calculation-preview {
  min-height: 38px; display: flex; align-items: center; padding: 8px 10px;
  border-radius: 8px; border: 1px dashed var(--accent); background: var(--surface-selected);
  color: var(--ink); font-weight: 700;
}
.topup-bc-name { font-weight: 600; color: var(--ink); }
.topup-bc-id { color: var(--text-muted); font-size: 11px; white-space: nowrap; }
.topup-transaction-row, .bp-profile-row, .row-menu-row { cursor: pointer; transition: background-color 120ms ease; }
.topup-transaction-row:hover > td,
.topup-transaction-row:focus-visible > td,
.bp-profile-row:hover > td,
.bp-profile-row:focus-visible > td,
.row-menu-row:hover > td,
.row-menu-row:focus-visible > td { background: var(--row-hover); }
.topup-transaction-row:hover > td:first-child,
.topup-transaction-row:focus-visible > td:first-child,
.bp-profile-row:hover > td:first-child,
.bp-profile-row:focus-visible > td:first-child,
.row-menu-row:hover > td:first-child,
.row-menu-row:focus-visible > td:first-child { box-shadow: inset 3px 0 0 var(--row-hover-bar); }
.topup-transaction-row:focus-visible,
.bp-profile-row:focus-visible,
.row-menu-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
/* Bấm vào dòng -> menu thao tác (core/ui.js): ô nút cũ ẩn đi, menu lấy nút trong ô làm mục */
th.row-actions, td.row-actions { display: none; }
/* Chữ bấm là copy (mã/tên ở Clients, Accounts, Hồ sơ doanh nghiệp) — chỉ đúng phần chữ: span inline nên vùng bấm
   khớp chữ, xuống dòng theo chữ (core/ui.js copyTd). Phần trống của ô (td.copy-cell) như ô thường: bấm mở menu dòng */
.copy-text { cursor: copy; }
.copy-text:hover { color: var(--accent); text-decoration: underline dotted; text-underline-offset: 3px; }
.copy-text.copied { background: color-mix(in srgb, var(--accent) 22%, transparent); transition: background .2s; }
/* Ô Lưu/Hủy của dòng đang sửa nhanh ghim mép phải khung bảng (như Hồ sơ doanh nghiệp) */
td.quick-edit-actions {
  position: sticky; right: 0; z-index: 2; background: var(--surface-selected);
  box-shadow: -6px 0 8px -6px rgba(0, 0, 0, 0.35); border-left: 1px solid var(--border);
}
.topup-row-menu {
  position: fixed; z-index: 1200; min-width: 190px; padding: 5px;
  border: 1px solid var(--border); border-radius: 9px; background: var(--card);
  box-shadow: 0 14px 36px rgba(15, 23, 42, .32);
}
.topup-row-menu button {
  display: block; width: 100%; padding: 9px 11px; border: 0; border-radius: 6px;
  background: transparent; color: var(--ink); text-align: left; font: inherit; cursor: pointer;
}
.topup-row-menu button:hover,
.topup-row-menu button:focus-visible { background: var(--surface-selected); outline: none; }
.topup-row-menu button + button { margin-top: 2px; }
.topup-row-menu button.danger { color: var(--danger); border-top: 1px solid var(--border); border-radius: 0 0 6px 6px; margin-top: 4px; }
.topup-row-menu button.danger:hover, .topup-row-menu button.danger:focus-visible { background: var(--danger-soft); }
.topup-day-group > td {
  padding: 9px 12px; background: var(--surface-selected); border-top: 2px solid var(--border);
  color: var(--ink);
}
.topup-day-group-content { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.topup-day-group-content > strong { color: var(--accent); font-size: 14px; }
.topup-day-group-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
/* COPY luôn là phần tử CUỐI, sát mép phải: tổng tiền dài ngắn khác nhau (VND, USD) không đẩy nút đi */
.topup-day-group-actions > span { color: var(--text-muted); font-size: 12px; white-space: nowrap; }
.copy-topup-day-btn { min-width: 66px; font-weight: 700; }
.topup-quick-edit-row > td { background: var(--surface-selected); padding: 7px 6px; vertical-align: middle; }
.topup-quick-edit-row > td:first-child { border-left: 2px solid var(--accent); }
.topup-quick-control {
  width: 100%; min-width: 72px; padding: 7px 8px; border: 1px solid var(--border);
  border-radius: 7px; background: var(--surface); color: var(--ink); font-size: 12px;
}
.topup-quick-control:focus { border-color: var(--accent); outline: 2px solid color-mix(in srgb, var(--accent) 20%, transparent); }
.topup-quick-date { min-width: 156px; }
.topup-quick-bc { min-width: 255px; }
.topup-quick-operation { min-width: 68px; }
.topup-quick-number { min-width: 112px; }
.topup-quick-rate { min-width: 92px; }
.topup-quick-status { min-width: 105px; }
.topup-quick-tax { display: flex; align-items: center; gap: 5px; min-width: 112px; }
.topup-quick-tax label { display: flex; align-items: center; gap: 3px; white-space: nowrap; font-size: 12px; }
.topup-quick-tax .topup-quick-control { min-width: 60px; }
.topup-quick-preview { display: block; min-width: 105px; white-space: nowrap; }
.topup-quick-failure { min-width: 130px; margin-top: 5px; }
.topup-quick-actions { display: flex; gap: 5px; white-space: nowrap; }
.topup-quick-requester { margin-bottom: 6px; }
.topup-quick-error { display: block; min-width: 130px; margin-top: 4px; font-size: 11px; }
/* Sửa nhanh Hồ sơ doanh nghiệp (Business Center) — dùng chung kiểu ô của Top-up */
/* Hồ sơ doanh nghiệp: cột Số TK canh giữa, số là nhãn tròn gọn (cao bằng dòng chữ) */
.bp-count-cell { width: 76px; text-align: center; white-space: nowrap; }
.bp-count-link {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 20px; margin: -4px 0; vertical-align: middle; padding: 0 9px; border-radius: 999px;
  border: 1px solid var(--border); background: transparent; color: var(--accent);
  font: inherit; font-size: 12px; font-weight: 600; line-height: 1; cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}
.bp-count-link:hover, .bp-count-link:focus-visible { background: var(--accent); border-color: var(--accent); color: #fff; outline: none; }
.bp-count-zero { color: var(--text-muted); }
.bp-client-cell { padding-left: 16px; min-width: 180px; }
.bp-quick-name { min-width: 150px; }
.bp-quick-tax { min-width: 95px; }
.bp-quick-city { min-width: 95px; }
.bp-quick-industry { min-width: 115px; }
/* Nhiều Khách hàng / hồ sơ: chip tự động (theo TK Ads, không bỏ được) + chip chọn tay (có ×) + ô thêm */
.bp-client-more { cursor: help; white-space: nowrap; font-weight: 600; }
.bp-client-manual { font-size: 11px; white-space: nowrap; }
.bp-clients { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.bp-quick-clients .bp-clients { min-width: 240px; }
.bp-client-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.bp-client-chip {
  display: inline-flex; align-items: center; gap: 4px; max-width: 100%; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-neutral); color: var(--text);
  font-size: 12px; line-height: 18px;
}
.bp-client-chip.auto { background: var(--section-accent-bg); border-color: var(--section-accent-border); cursor: default; }
.bp-client-chip.manual { background: var(--card); border-style: dashed; padding-right: 3px; }
.bp-client-chip-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bp-client-chip-meta { color: var(--text-muted); white-space: nowrap; }
.bp-client-chip-remove {
  display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; padding: 0;
  border: 0; border-radius: 999px; background: transparent; color: var(--text-muted);
  font: inherit; font-size: 14px; line-height: 1; cursor: pointer;
}
.bp-client-chip-remove:hover, .bp-client-chip-remove:focus-visible { background: var(--danger-soft); color: var(--danger); outline: none; }
.bp-client-empty { font-size: 12px; }
.bp-client-add { display: flex; align-items: center; gap: 5px; }
.bp-client-add .bp-client-input { flex: 1; min-width: 0; }
.bp-client-add .btn { flex-shrink: 0; }
.bp-quick-note { min-width: 140px; resize: vertical; font-family: inherit; }
.bp-quick-paid { display: flex; align-items: center; gap: 4px; white-space: nowrap; font-size: 12px; }
.bp-address-cell { white-space: nowrap; } /* nút Copy địa chỉ, không xuống dòng */
.bp-stage-bar { gap: 6px; margin-bottom: 10px; } /* NEW / Có khách hàng / Tất cả */
.bp-stage-bar .btn { white-space: nowrap; flex: 0 0 auto; gap: 4px; } /* .btn là flex: cần gap để "NEW" và "(2)" không dính */
.bp-stage-bar .bp-stage-count { opacity: .8; font-weight: 400; }
.bp-quick-actions { margin-top: 6px; }
.bp-accounts-modal { max-width: 920px; }
/* Popup Xem tài khoản của hồ sơ: chỉ còn nút mở bảng Thêm nhanh tài khoản (14/10/2026) */
.bp-account-tools { display: flex; justify-content: flex-end; margin-bottom: 12px; }
.bp-accounts-table-wrap { max-height: 38vh; overflow: auto; }
.bp-accounts-table-wrap thead th { position: sticky; top: 0; z-index: 1; background: var(--card); }
/* Ô Lưu/Hủy của dòng đang sửa ghim mép phải khung bảng: bảng rộng hơn màn hình vẫn thấy nút, không phải kéo ngang (#231).
   z-index dưới tiêu đề cột dính (3) để khi cuộn dọc tiêu đề vẫn đè lên. */
.bp-quick-edit-row > td:last-child {
  position: sticky; right: 0; z-index: 2;
  box-shadow: -6px 0 8px -6px rgba(0, 0, 0, 0.35); border-left: 1px solid var(--border);
}

@media (max-width: 720px) {
  .app-layout { flex-direction: column; }
  .sidebar {
    width: 100%; flex-direction: row; overflow-x: auto; overflow-y: visible; padding: 10px;
    flex-shrink: 0; height: auto;
  }
  .sidebar .brand { display: none; }
  .nav-spacer { display: none; }
  .modal-grid, .modal-box.wide .modal-grid { grid-template-columns: 1fr; }
  .modal-grid .span-2 { grid-column: auto; }
  .global-header-row { padding: 12px 16px 0; }
  .topbar { padding: 16px 16px 10px; }
  .page-body { padding: 6px 16px 16px; }
  .topup-day-group-content { align-items: flex-start; flex-direction: column; gap: 3px; }
  .topup-day-group-actions { align-items: flex-start; flex-direction: column; gap: 5px; }
  .bp-account-tools { grid-template-columns: 1fr; }
  .bp-accounts-table-wrap { max-height: 32vh; }
}

/* ---------- Đa nền tảng: bộ chọn của admin, khối "Theo nền tảng", chi tiêu gộp (#191) ---------- */
.platform-select {
  height: 32px; padding: 0 8px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--control-bg); color: var(--text); font-size: 13px;
}
.platform-summary-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.platform-summary-card {
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  background: var(--surface-subtle); font-size: 13px; display: grid; gap: 3px;
}
.platform-summary-head { display: flex; gap: 6px; align-items: center; margin-bottom: 4px; }
.platform-summary-total { margin-top: 10px; font-size: 14px; color: var(--ink); }
.platform-spend-totals { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; margin-bottom: 10px; font-size: 14px; color: var(--ink); }
.platform-spend-total { display: inline-flex; gap: 6px; align-items: center; }

/* ---------- Phân quyền (RBAC) ---------- */
.rbac-topbar > div { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.rbac-warning {
  padding: 10px 12px; margin-bottom: 12px; border: 1px solid var(--section-amber-border);
  border-radius: 8px; background: var(--section-amber-bg); color: var(--warning-text); font-size: 13px;
}
.rbac-chip-list { display: flex; flex-wrap: wrap; gap: 5px; }
.rbac-membership-chip {
  display: inline-block; padding: 3px 8px; border-radius: 999px;
  background: var(--surface-neutral); color: var(--text-muted); font-size: 12px;
}
.rbac-membership-chip.primary { color: var(--ink); font-weight: 700; background: var(--surface-selected); }
.rbac-user-name, .rbac-role-description { margin-top: 3px; font-size: 12px; }
.rbac-membership-list { display: grid; gap: 10px; margin-bottom: 12px; }
.rbac-membership-row {
  display: grid; grid-template-columns: minmax(180px, .8fr) minmax(260px, 1.4fr) auto auto;
  gap: 10px; align-items: start; padding: 10px; border: 1px solid var(--border); border-radius: 8px;
}
.rbac-membership-row .field { margin: 0; }
.rbac-membership-roles { display: flex; flex-wrap: wrap; gap: 7px 12px; min-height: 38px; align-items: center; }
.rbac-membership-roles .muted { font-size: 12px; }
.rbac-primary-choice { min-height: 38px; white-space: nowrap; align-items: center; }
.rbac-membership-warning, .rbac-role-warning { margin: 10px 0 0; white-space: pre-line; }
.rbac-effective-summary { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-bottom: 14px; font-size: 13px; }
.rbac-effective-summary span { padding: 6px 9px; background: var(--surface-subtle); border-radius: 7px; }
.rbac-effective-source { display: block; margin-top: 4px; font-size: 11px; color: var(--text-muted); }
.rbac-radio-row { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 7px; }
.rbac-data-scope-note { margin-top: 7px; font-size: 12px; }
.rbac-matrix-tools { display: grid; grid-template-columns: auto 1fr auto auto auto; gap: 7px; align-items: center; margin: 14px 0 8px; }
.rbac-permission-matrix { max-height: 330px; margin-bottom: 14px; }
.rbac-permission-matrix th:not(:first-child), .rbac-permission-matrix td:not(:first-child) { width: 80px; text-align: center; }
.rbac-system-permissions > div { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; }
.rbac-team-lock-note { padding: 8px 10px; border-radius: 7px; background: var(--surface-neutral); }
.upf-rbac-locked-note { padding: 9px 11px; margin-bottom: 12px; border-radius: 7px; background: var(--surface-neutral); color: var(--text-muted); font-size: 13px; }
.rbac-status-tabs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

@media (max-width: 760px) {
  .rbac-membership-row { grid-template-columns: 1fr; }
  .rbac-matrix-tools { grid-template-columns: 1fr 1fr; }
  .rbac-matrix-tools strong, .rbac-matrix-tools span { grid-column: 1 / -1; }
}

/* Order GPKD — giao diện nhân viên */
/* Chỉ có 1 đối tác: ẩn ô chọn / lọc / cột Đối tác (gpkd-orders-admin.js gắn class) */
body.gpkd-single-partner .gpkd-col-partner { display: none; }
.gpkd-toolbar { margin-bottom: 10px; }
.gpkd-orders-table-wrap, .gpkd-items-table-wrap { overflow-x: auto; }
#gpkdOrdersCount { margin-top: 10px; font-size: 13px; }
.gpkd-pending-badge {
  display: inline-flex;
  min-width: 24px;
  height: 24px;
  align-items: center;
  justify-content: center;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--warning-bg, #fff3cd);
  color: var(--warning-text, #8a5300);
  font-weight: 700;
}
.gpkd-review-box { width: min(1500px, 96vw); max-width: 96vw; }
.gpkd-review-box:focus { outline: none; }
.gpkd-review-heading, .gpkd-review-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.gpkd-review-heading h3 { margin-bottom: 4px; }
.gpkd-review-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
/* Bảng order: bấm dòng mở thẳng Xem & duyệt (không qua menu) */
.gpkd-order-row { cursor: pointer; transition: background-color 120ms ease; }
.gpkd-order-row:hover > td, .gpkd-order-row:focus-visible > td { background: var(--row-hover); }
.gpkd-order-row:hover > td:first-child, .gpkd-order-row:focus-visible > td:first-child { box-shadow: inset 3px 0 0 var(--row-hover-bar); }
.gpkd-order-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.gpkd-counts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 10px;
  margin: 16px 0;
}
.gpkd-counts > div { padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.gpkd-counts span { display: block; color: var(--text-muted); font-size: 12px; }
.gpkd-counts strong { display: block; margin-top: 3px; font-size: 20px; }
.gpkd-items-table-wrap { max-height: min(60vh, 620px); margin-top: 12px; }
.gpkd-thumb-btn { padding: 0; border: 0; background: transparent; cursor: zoom-in; }
.gpkd-thumb { width: 64px; height: 64px; display: block; object-fit: cover; border: 1px solid var(--border); border-radius: 6px; }
.gpkd-duplicate { margin-top: 4px; color: var(--danger); font-size: 12px; font-weight: 600; }
.gpkd-approve-layout { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(300px, 1fr); gap: 20px; }
.gpkd-approve-image { min-height: 360px; display: flex; align-items: center; justify-content: center; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.gpkd-approve-image img { width: 100%; max-height: 65vh; object-fit: contain; }
.bp-license-file-section { padding-top: 4px; }
.bp-license-file-current-row, .bp-license-file-edit {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.bp-license-file-current-row { margin-bottom: 8px; }
.bp-license-file-current-row span { color: var(--text-muted); overflow-wrap: anywhere; }
.bp-license-file-edit input[type="file"] { flex: 1 1 260px; min-width: 0; }
.bp-license-drive-status {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 8px; padding: 7px 9px; border-radius: 7px;
  font-size: 12px; background: var(--surface-neutral); color: var(--text-muted);
}
.bp-license-drive-status[hidden] { display: none; }
.bp-license-drive-status.is-synced { background: var(--success-soft); color: var(--success); }
.bp-license-drive-status.is-pending { background: var(--warning-soft); color: var(--warning-text); }
.bp-license-drive-status.is-error { background: var(--danger-soft); color: var(--danger); }
.bp-license-drive-status-text { flex: 1 1 190px; overflow-wrap: anywhere; }
.bp-license-drive-status a { color: inherit; font-weight: 600; }

.license-image-box {
  width: min(1200px, 94vw);
  max-width: 94vw;
  max-height: 92vh;
  padding: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.license-image-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}
.license-image-header h3 { margin: 0; overflow-wrap: anywhere; }
.license-image-stage {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.license-image-stage img { display: block; max-width: 100%; height: auto; object-fit: contain; }
.license-image-actions { flex: 0 0 auto; margin-top: 12px; }
#noticeModalText { white-space: pre-line; }

@media (max-width: 760px) {
  .gpkd-counts { grid-template-columns: repeat(2, minmax(100px, 1fr)); }
  .gpkd-approve-layout { grid-template-columns: 1fr; }
  .gpkd-approve-image { min-height: 240px; }
  .gpkd-review-heading, .gpkd-review-toolbar { align-items: stretch; flex-direction: column; }
  .license-image-box { width: 100%; max-width: 100%; max-height: calc(100vh - 24px); padding: 12px; }
  .license-image-stage { justify-content: flex-start; }
  .license-image-actions { margin: 10px -12px -12px; padding: 10px 12px 12px; }
}
.bp-license-view-btn { white-space: nowrap; }

/* Báo cáo tháng: cột "Xu hướng 6 tháng" (biểu đồ đường nhỏ, 19/10/2026) */
.trend-col { white-space: nowrap; }
.trend-spark { display: block; overflow: visible; }
