/* ============================================================================
   admin.css — Giao diện web QUẢN TRỊ (trang /admin)

   CHÂN LÝ: WA-09 (quy chuẩn giao diện) — mục 3.1 màu · 3.2 chữ · 3.3 khoảng
            cách · mục 4 phần tử · QT-40 (`hidden` luôn thắng).
            Bản demo đã duyệt: ProjectDocs/30-web-admin/demo/demo-admin-v2-2026-09-27.html

   ⚠️ WA-09 QT-1: CHỈ dùng màu qua biến, KHÔNG viết mã màu trực tiếp trong
      phần tử. ⚠️ QT-45: không thêm cỡ chữ / bán kính góc mới (chỉ 25 · 19 · 15
      · 14 · 13 · 12.5 · 11.5 · 11px và 12px của nhãn `.field`; bán kính chỉ
      10 / 7 / 999 / 12px).
   ⚠️ Không tải phông từ bên thứ ba: chỉ khai TÊN phông (Be Vietnam Pro / IBM
      Plex Mono — WA-09 QT-6) để dùng bản đã cài trên máy, còn lại rơi về phông
      hệ thống.
   ⚠️ File này ĐỘC LẬP với web.css (web khách): khung quản trị có thanh bên,
      tên lớp trùng (`.topbar`, `.brand`…) nhưng giá trị khác — không nạp chung.
   ============================================================================ */

/* ---------------------------------------------------------------------------
   0. `hidden` PHẢI LUÔN THẮNG — WA-09 QT-40
   (luật mặc định của trình duyệt thua mọi selector lớp có `display`)
   --------------------------------------------------------------------------- */
[hidden] {
  display: none !important;
}

/* ---------------------------------------------------------------------------
   1. Biến — WA-09 mục 3.1 (QT-4: đủ bộ ở :root, định nghĩa lại CHỈ biến)
   --------------------------------------------------------------------------- */
:root {
  --ground: #f5f7f5;
  --surface: #ffffff;
  --surface-2: #eef2ef;
  --line: #d9e0db;
  --line-soft: #e8ede9;
  --ink: #17211d;
  --ink-2: #435049;
  --muted: #6b7a72;
  --accent: #0d6e5e;
  --accent-ink: #ffffff;
  --accent-soft: #e2efeb;
  --ok: #2f7d4f;
  --ok-soft: #e6f2ea;
  --warn: #9a6207;
  --warn-soft: #f8eedb;
  --crit: #a3342a;
  --crit-soft: #f8e6e3;

  /* QT-5 — chỉ 4 bán kính này */
  --radius: 10px;
  --radius-ctl: 7px;
  --radius-pill: 999px;
  --radius-modal: 12px;

  --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas,
    monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #101613;
    --surface: #182220;
    --surface-2: #1f2b28;
    --line: #2c3a35;
    --line-soft: #243230;
    --ink: #e8eeea;
    --ink-2: #bcc9c3;
    --muted: #8b9a93;
    --accent: #4fbfa5;
    --accent-ink: #06211c;
    --accent-soft: #1d332e;
    --ok: #6cc98c;
    --ok-soft: #1a2f23;
    --warn: #e0ad5c;
    --warn-soft: #302714;
    --crit: #ef8b7d;
    --crit-soft: #35201d;
  }
}

:root[data-theme="dark"] {
  --ground: #101613;
  --surface: #182220;
  --surface-2: #1f2b28;
  --line: #2c3a35;
  --line-soft: #243230;
  --ink: #e8eeea;
  --ink-2: #bcc9c3;
  --muted: #8b9a93;
  --accent: #4fbfa5;
  --accent-ink: #06211c;
  --accent-soft: #1d332e;
  --ok: #6cc98c;
  --ok-soft: #1a2f23;
  --warn: #e0ad5c;
  --warn-soft: #302714;
  --crit: #ef8b7d;
  --crit-soft: #35201d;
}

/* ---------------------------------------------------------------------------
   2. Nền trang — WA-09 mục 3.2 (body 14px/400)
   --------------------------------------------------------------------------- */
* {
  box-sizing: border-box;
}

html {
  /* QT-11: trang không bao giờ cuộn ngang */
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

/* QT-42 — viền focus luôn thấy rõ, KHÔNG outline: none */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.mono {
  font-family: var(--font-mono);
}

/* QT-7 — số xếp cột không nhảy so le */
.num {
  font-variant-numeric: tabular-nums;
}

.hint {
  font-size: 11.5px;
  color: var(--muted);
}

.hint.sm {
  font-size: 11px;
}

.strong {
  font-weight: 600;
}

.strong.sm {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Trạng thái "đang kiểm tra quyền" — chiếm cả trang, chưa có khung */
.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
}

/* ---------------------------------------------------------------------------
   3. Khung — WA-09 mục 3.3 (thanh bên 236px, nền --surface, viền phải --line)
   --------------------------------------------------------------------------- */
.shell {
  display: grid;
  grid-template-columns: 236px 1fr;
  min-height: 100vh;
}

.side {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding-block: 18px 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px 16px;
}

.brand-mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-ctl);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 700;
}

.brand-name {
  font-size: 14px;
  font-weight: 600;
}

.brand-role {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 10px;
}

/* Nhãn nhóm — 11px / 600 / hoa / .07em (WA-09 mục 3.2) */
.nav-group {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  padding: 14px 8px 5px;
}

.nav-item {
  appearance: none;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  column-gap: 8px;
  width: 100%;
  text-align: left;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink-2);
  background: transparent;
  border: 0;
  border-radius: var(--radius-ctl);
  padding: 7px 9px;
  cursor: pointer;
}

.nav-item:hover:not([disabled]) {
  background: var(--surface-2);
}

.nav-item[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

/* QT-23 — màn chưa dùng được: mờ 45%, con trỏ thường, KÈM LÝ DO */
.nav-item[disabled] {
  opacity: 0.45;
  cursor: default;
}

.nav-item .why {
  grid-column: 1 / -1;
  font-size: 11.5px;
  color: var(--muted);
}

.nav-item .count {
  font-size: 11.5px;
  color: var(--muted);
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 24px;
  background: var(--ground);
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
}

.topbar p {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
}

.topbar .right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

/* WA-00 5a QT-7b/7e: ô tài khoản (email) đang đăng nhập trên thanh trên */
.ad-user {
  font-size: 12.5px;
  color: var(--muted);
  max-width: 28ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

@media (max-width: 859px) {
  .ad-user {
    max-width: 9rem;
  }
}

@media (max-width: 479px) {
  .ad-user {
    max-width: 6.5rem;
  }
}

/* Cột nội dung — WA-09 mục 3.3: max-width: none (G33a), padding 20px 24px 48px, gap 20px */
.content {
  max-width: none;
  padding: 20px 24px 48px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.content > section {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* QT-10 — xếp hàng bằng flex/grid + gap, không margin từng phần tử */
.stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.stack.sm {
  gap: 8px;
}

.row.sm {
  gap: 6px;
}

.clean-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* Lưới 2 cột: danh sách rộng hơn chi tiết (mục 3.3) */
.cols {
  display: grid;
  gap: 20px;
  align-items: start;
}

.cols.two {
  grid-template-columns: 1.35fr 1fr;
}

/* `.content > section` (flex dọc) có độ ưu tiên cao hơn `.cols` nên phải đặt lại
   ngay cho section mang lớp `cols` — nếu không 2 khung xếp dọc (lỗi anh báo 2026-10-23) */
.content > section.cols {
  display: grid;
  gap: 20px;
  align-items: start;
}

.content > section.cols.two {
  grid-template-columns: 1.35fr 1fr;
}

.cols > * {
  min-width: 0;
}

/* ---------------------------------------------------------------------------
   4. Khối — WA-09 mục 4.2 (.panel)
   --------------------------------------------------------------------------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.panel > header {
  display: flex;
  align-items: center;
  gap: 4px 12px;
  flex-wrap: wrap;
  padding: 12px 15px;
  border-bottom: 1px solid var(--line-soft);
}

.panel > header h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.panel > header .sub {
  margin: 0;
  font-size: 11.5px;
  color: var(--muted);
}

.panel > header .right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.panel-body {
  padding: 15px;
}

/* QT-15 — chia nhỏ trong khối bằng vạch, không lồng khối trong khối */
.divide {
  border-top: 1px solid var(--line-soft);
}

.group-label {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Vạch chia trong khối + khoảng thở phía trên (QT-15) */
.sep {
  padding-top: 15px;
  border-top: 1px solid var(--line-soft);
}

/* Mục gập — WA-09 QT-39b */
.panel > details > summary {
  padding: 12px 15px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.panel > details[open] > summary {
  border-bottom: 1px solid var(--line-soft);
}

/* ---------------------------------------------------------------------------
   5. Bảng — WA-09 mục 4.3 (QT-16: LUÔN bọc trong .tbl-wrap)
   --------------------------------------------------------------------------- */
.tbl-wrap {
  overflow-x: auto;
}

.tbl-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.tbl-wrap th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  white-space: nowrap;
  text-align: left;
  padding: 9px 15px;
  border-bottom: 1px solid var(--line-soft);
}

.tbl-wrap td {
  padding: 10px 15px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}

.tbl-wrap tr:last-child td {
  border-bottom: 0;
}

/* QT-18 — hàng bấm được + hàng đang chọn */
.tbl-wrap tr.click {
  cursor: pointer;
}

.tbl-wrap tr.click:hover {
  background: var(--surface-2);
}

.tbl-wrap tr[aria-selected="true"] {
  background: var(--accent-soft);
}

/* QT-19 — mọi bảng phải có trạng thái rỗng, cấm bảng trắng */
.tbl-wrap td.empty {
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
  padding: 20px 15px;
}

/* QT-20 — cột phụ xếp dưới nội dung chính trong CÙNG một ô. Bọc trong
   `.cell` chứ không đặt flex lên chính `td` (mất table-cell là vỡ cột). */
.tbl-wrap td .cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.tbl-wrap td .row {
  gap: 6px;
}

.tbl-wrap td .mono {
  word-break: break-all;
}

.cell .sub-line {
  font-size: 11.5px;
  color: var(--muted);
}

/* Trích nội dung người dùng gửi — WA-09 mục 4.13 (.quote) */
.quote {
  border-left: 2px solid var(--line);
  padding-left: 11px;
  color: var(--ink-2);
  max-width: 340px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Chữ 12px (có trong thang WA-09) cho mã/URL trong ô bảng; URL dài ngắt dòng */
.t12 {
  font-size: 12px;
}

.url {
  display: inline-block;
  max-width: 220px;
  word-break: break-all;
}

/* Chân bảng: phân trang / tải thêm */
.pager {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 15px;
  border-top: 1px solid var(--line-soft);
}

.pager .spacer {
  margin-left: auto;
}

/* ---------------------------------------------------------------------------
   6. Nhãn trạng thái — WA-09 mục 4.4 (.pill); QT-21: luôn có chữ + chấm tròn
   --------------------------------------------------------------------------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--ink-2);
  white-space: nowrap;
}

.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: var(--radius-pill);
  background: currentColor;
}

.pill.nodot::before {
  display: none;
}

.pill.ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.pill.warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.pill.crit {
  background: var(--crit-soft);
  color: var(--crit);
}

.pill.mute {
  background: var(--surface-2);
  color: var(--muted);
}

.pill.accent {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ---------------------------------------------------------------------------
   7. Nút — WA-09 mục 4.5
   --------------------------------------------------------------------------- */
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-ctl);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover:not([disabled]) {
  background: var(--surface-2);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn.primary:hover:not([disabled]) {
  /* Không có biến "accent đậm hơn" trong WA-09 ⇒ dùng độ mờ */
  opacity: 0.9;
  background: var(--accent);
}

/* QT-23 — nút không dùng được: mờ 45%, con trỏ thường */
.btn[disabled] {
  opacity: 0.45;
  cursor: default;
}

/* Hành động PHÁ / KHÔNG LÙI ĐƯỢC */
.btn.danger {
  border-color: var(--crit);
  color: var(--crit);
}

.btn.danger:hover:not([disabled]) {
  background: var(--crit-soft);
}

.btn.sm {
  font-size: 11.5px;
  padding: 6px 10px;
}

.btn.active,
.btn[aria-pressed="true"],
.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn.active:hover:not([disabled]),
.btn[aria-pressed="true"]:hover:not([disabled]) {
  opacity: 0.9;
  background: var(--accent);
}

.btn-move {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  padding: 1px 5px;
  font-size: 10px;
  line-height: 1.2;
}
.btn-move:hover:not([disabled]) {
  background: var(--hover);
}
.btn-move[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
}
.stt-cell {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ---------------------------------------------------------------------------
   8. Ô nhập — WA-09 mục 4.9 (QT-28: bọc trong label.field, nhãn 12px --muted
   nằm TRÊN ô). Ô lọc đứng riêng trong header khối (`.right`) dùng cùng kiểu.
   --------------------------------------------------------------------------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

input[type="text"],
input[type="search"],
input[type="email"],
input[type="date"],
input[type="number"],
select,
textarea {
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-ctl);
  padding: 7px 10px;
  width: 100%;
}

textarea {
  line-height: 1.55;
  resize: vertical;
}

/* Ô lọc/tìm trong header khối: không chiếm cả hàng */
.panel > header .right input,
.panel > header .right select,
.pager select {
  width: auto;
}

.panel > header .right input[type="search"] {
  width: 170px;
}

/* Checkbox kèm chữ — chọn trong biểu mẫu phải bấm Lưu (WA-09 4.6) */
.check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: var(--ink);
}

.check input {
  margin-top: 3px;
}

/* ---------------------------------------------------------------------------
   9. Danh sách nhãn–giá trị — WA-09 mục 4.8 (.kv): nhãn 140px / giá trị
   --------------------------------------------------------------------------- */
.kv {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 7px 14px;
  margin: 0;
  font-size: 13px;
}

.kv dt {
  color: var(--muted);
}

.kv dd {
  margin: 0;
  color: var(--ink);
  min-width: 0;
  word-break: break-word;
}

/* Dòng thiết bị — WA-01 4.6 */
.dev {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.dev .meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dev .meta .hint {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* ---------------------------------------------------------------------------
   10. Ghi chú / thông báo — WA-09 mục 4.13
   --------------------------------------------------------------------------- */
.note {
  display: flex;
  gap: 10px;
  padding: 11px 13px;
  border: 1px solid var(--warn);
  border-radius: var(--radius);
  background: var(--warn-soft);
  color: var(--ink);
  font-size: 13px;
}

.note .ico {
  flex: none;
  font-size: 13px;
  line-height: 1.45;
}

.note p {
  margin: 0;
}

.note a {
  color: var(--accent);
}

/* Link văn bản trong vùng nội dung admin (không áp cho nút / mục menu / tab).
   Luôn gạch chân. Nền tối ⇒ chữ trắng ngà (--ink); nền sáng ⇒ chữ xanh (--accent).
   Hai theme dùng chung quy tắc vì token đã đổi theo theme (mục 1). */
.content a:not(.btn):not(.nav-item):not(.tab):not([role="tab"]) {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.content a:not(.btn):not(.nav-item):not(.tab):not([role="tab"]):hover {
  text-decoration-thickness: 2px;
}

.content a:not(.btn):not(.nav-item):not(.tab):not([role="tab"]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .content a:not(.btn):not(.nav-item):not(.tab):not([role="tab"]) {
    color: var(--ink);
  }
}

:root[data-theme="dark"] .content a:not(.btn):not(.nav-item):not(.tab):not([role="tab"]) {
  color: var(--ink);
}

/* Khung báo kết quả/lỗi trong một khối */
.formmsg {
  padding: 10px 13px;
  border: 1px solid var(--crit);
  border-radius: var(--radius-ctl);
  background: var(--crit-soft);
  color: var(--ink);
  font-size: 13px;
}

.formmsg p {
  margin: 0;
}

.formmsg p + p {
  margin-top: 4px;
}

.formmsg.ok {
  border-color: var(--ok);
  background: var(--ok-soft);
}

.formmsg.warn {
  border-color: var(--warn);
  background: var(--warn-soft);
}

/* Nhóm nút chọn nhanh (thời gian sống của mã) — nút có aria-pressed */
.cyc {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 3px;
  background: var(--surface-2);
  border-radius: var(--radius-ctl);
}

.cyc button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-ctl);
  cursor: pointer;
}

.cyc button:hover {
  color: var(--ink);
}

.cyc button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--accent);
}

/* Biểu mẫu trong khối: các phần xếp dọc, cách nhau bằng gap */
.form-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}

.form-stack .field {
  align-self: stretch;
}

/* ---------------------------------------------------------------------------
   11. Hộp thoại — WA-09 mục 4.10 (.modal): bán kính 12px
   --------------------------------------------------------------------------- */
.modal-back {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  /* Lớp phủ: WA-09 không có biến cho nền mờ ⇒ --ink + alpha, không sinh mã màu */
  background: color-mix(in srgb, var(--ink) 45%, transparent);
  overscroll-behavior: contain;
}

.modal {
  width: 100%;
  max-width: 540px;
  max-height: 86vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-modal);
  overscroll-behavior: contain;
}

.modal > header {
  padding: 15px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.modal > header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.modal > header .sub {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--ink-2);
}

.modal-body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-body p {
  margin: 0;
}

/* QT-32 — nút bên phải, Huỷ rồi mới hành động chính; lý do khoá nút đứng trái */
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  padding: 13px 18px;
  border-top: 1px solid var(--line-soft);
}

.modal-foot .hint {
  margin-right: auto;
}

.modal-foot-left {
  margin-right: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ---------------------------------------------------------------------------
   11b. Công tắc / thanh quota / hàng tính năng / xem trước popup / lưới biểu mẫu
   — WA-09 mục 4.6 (.sw), 4.7 (.bar), 4.9 (.form-grid), 4.11 (.feat), 4.12
   (.popup-prev). Hình dạng theo bản demo đã duyệt; màu CHỈ qua biến, bán kính
   chỉ trong bộ 10 / 7 / 999 (QT-1, QT-45).
   --------------------------------------------------------------------------- */
.sw {
  appearance: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  width: 38px;
  height: 21px;
  border-radius: var(--radius-pill);
  background: var(--line);
  position: relative;
  flex-shrink: 0;
  transition: background 0.15s;
}

.sw::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--surface);
  transition: transform 0.15s;
}

.sw[aria-pressed="true"],
.sw[aria-checked="true"] {
  background: var(--accent);
}

.sw[aria-pressed="true"]::after,
.sw[aria-checked="true"]::after {
  transform: translateX(17px);
}

.sw:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* QT-26: công tắc bị khoá thì mờ, con trỏ thường */
.sw[disabled] {
  opacity: 0.4;
  cursor: default;
}

.bar {
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  overflow: hidden;
  min-width: 90px;
}

.bar > i {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-pill);
}

.bar > i.warn {
  background: var(--warn);
}

.bar > i.crit {
  background: var(--crit);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.feat {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
}

.feat:last-child {
  border-bottom: 0;
}

.feat .body {
  flex: 1;
  min-width: 0;
}

.feat .t {
  font-weight: 500;
}

.feat .d {
  font-size: 11.5px;
  color: var(--muted);
}

.feat .sw {
  margin-left: auto;
  margin-top: 2px;
}

/* WA-02 khối 3: hàng đang tạm ngưng đổi sang nền cảnh báo */
.feat.paused {
  background: var(--warn-soft);
  padding-left: 10px;
  padding-right: 10px;
  border-radius: var(--radius-ctl);
}

.popup-prev {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.popup-prev .pp-title {
  font-weight: 600;
  font-size: 12px;
  margin-bottom: 8px;
}

.popup-prev .pp-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  padding: 5px 8px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-ctl);
  margin-bottom: 5px;
}

.popup-prev .pp-row.paused {
  opacity: 0.55;
}

.popup-prev .pp-note {
  color: var(--muted);
  font-size: 11.5px;
  margin-top: 7px;
}

/* ---------------------------------------------------------------------------
   12. Điện thoại — WA-09 QT-11 (ngưỡng 860px)
   Thanh bên thành dải tab cuộn ngang; lưới 2 cột xuống 1; lề còn 16px;
   trang KHÔNG BAO GIỜ cuộn ngang (bảng rộng cuộn trong .tbl-wrap).
   --------------------------------------------------------------------------- */
@media (max-width: 860px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .side {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding-block: 14px 8px;
  }

  .nav {
    flex-direction: row;
    overflow-x: auto;
    gap: 6px;
    padding-bottom: 4px;
  }

  .nav-group {
    display: none;
  }

  .nav-item {
    width: auto;
    white-space: nowrap;
  }

  /* Dải tab hẹp: lý do của mục mờ còn lại ở thuộc tính `title` */
  .nav-item .why {
    display: none;
  }

  .topbar {
    position: static;
    padding-left: 16px;
    padding-right: 16px;
  }

  .content {
    padding-left: 16px;
    padding-right: 16px;
  }

  .cols.two,
  .content > section.cols.two {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .kv {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .kv dd {
    margin-bottom: 8px;
  }
}

/* ---------------------------------------------------------------------------
   Màn Người dùng — WA-01 QT-21: hai khung cuộn riêng (chỉ từ 861px trở lên).
   `--ad-top` (khoảng từ đỉnh khung nhìn tới đầu khung) do admin-nguoi-dung.js đo
   lúc mở màn/đổi cỡ cửa sổ, vì thanh tiêu đề có thể xuống dòng nên cao không cố định.
   Dưới 860px không áp gì: xếp dọc, cuộn cả trang (WA-09 QT-11).
   --------------------------------------------------------------------------- */
@media (min-width: 861px) {
  .content > section.man-nguoi-dung {
    height: calc(100vh - var(--ad-top, 120px) - 48px);
    min-height: 320px;
    grid-template-rows: minmax(0, 1fr);
    align-items: stretch;
  }

  .man-nguoi-dung > .panel {
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
  }

  /* Khung trái: tiêu đề + phân trang đứng yên, chỉ bảng cuộn */
  .man-nguoi-dung > .panel.ds-trai {
    overflow: hidden;
  }

  .man-nguoi-dung > .panel.ds-trai > .tbl-wrap {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
  }

  .man-nguoi-dung > .panel.ds-trai > .panel-body,
  .man-nguoi-dung > .panel.ds-trai > .pager,
  .man-nguoi-dung > .panel > header {
    flex: 0 0 auto;
  }

  .man-nguoi-dung > .panel.ds-trai .tbl-wrap th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface);
  }

  /* Khung phải: tiêu đề khung dính đầu khi cuộn */
  .man-nguoi-dung > .panel.ct-phai > header {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--surface);
  }
}

/* Ô chọn số dòng/trang ở thanh phân trang (WA-01 QT-22) */
.pager .per-page {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ============================================================================
   Màn "Nhà cung cấp dịch" (WA-05 / G20b)
   ============================================================================ */
.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.flex-center {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.panel-block {
  margin-bottom: 24px;
}

.panel-block:last-child {
  margin-bottom: 0;
}

.log-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  font-size: 13px;
}

.log-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line-soft);
}

.log-list .time {
  font-family: var(--font-mono);
  color: var(--muted);
  font-size: 12px;
}

.cb-logs {
  margin-top: 12px;
}

.sw-lydo {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.3;
  margin-top: 4px;
  max-width: 140px;
  white-space: normal;
}

.acts-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

/* ============================================================================
   Màn "Nhật ký thao tác" (WA-06 v1.5 / Demo v3)
   ============================================================================ */
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.filters select,
.filters input[type=date] {
  width: auto;
}

.filters .arrow {
  color: var(--muted);
}

.filters input[type=search] {
  width: 190px;
}

.filters .csv {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  flex: 1 0 100%;
  flex-wrap: nowrap;
  padding-top: 4px;
}

.filters .csv .hint {
  white-space: nowrap;
  text-align: left;
}

.filters .csv .hint b {
  color: var(--ink);
  font-weight: 600;
}

/* ============================================================================
   Khu vực trạng thái (tải, rỗng, lỗi) & Bộ lọc — WA-09 mục 6, WA-10 2.1
   ============================================================================ */
.state-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 20px;
  min-height: 120px;
  gap: 10px;
}

.state-wrap .loading,
.loading {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}

.state-wrap .err,
.err {
  color: var(--crit);
  font-size: 13px;
  margin: 0;
}

.filters input[type="search"].mono {
  flex: 1 1 200px;
  min-width: 180px;
  max-width: 320px;
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-group {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.note-warn {
  display: flex;
  gap: 10px;
  padding: 11px 13px;
  border: 1px solid var(--warn);
  border-radius: var(--radius);
  background: var(--warn-soft);
  color: var(--ink);
  font-size: 13px;
}

.cols.audit-cols {
  display: grid;
  grid-template-columns: 45fr 55fr;
  gap: 20px;
  align-items: start;
}

.cols.audit-cols > * {
  min-width: 0;
}

.list-scroll {
  height: 560px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.item {
  appearance: none;
  display: block;
  width: 100%;
  text-align: left;
  font-family: inherit;
  color: inherit;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  border-left: 3px solid transparent;
  padding: 9px 15px 9px 12px;
  cursor: pointer;
}

.item:hover {
  background: var(--surface-2);
}

.item[aria-current=true] {
  background: var(--accent-soft);
  border-left-color: var(--accent);
}

.item .l1 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.item .when {
  font-size: 12.5px;
  font-weight: 600;
}

.item .ago {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}

.item .l2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.item .who {
  font-size: 12.5px;
  color: var(--ink-2);
}

.item .tgt {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail {
  padding: 20px 22px;
  min-height: 560px;
}

.detail .guide {
  color: var(--muted);
  font-size: 13px;
  padding: 40px 0;
  text-align: center;
}

.ba {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.ba h3 {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
}

.code {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-ctl);
  padding: 10px 0;
  min-height: 110px;
  overflow-x: auto;
}

.code .ln {
  padding: 1px 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.code .ln.diff.before {
  background: var(--crit-soft);
  color: var(--crit);
}

.code .ln.diff.after {
  background: var(--ok-soft);
  color: var(--ok);
}

.code .none {
  padding: 1px 12px;
  color: var(--muted);
}

@media (max-width: 860px) {
  .cols.audit-cols {
    grid-template-columns: 1fr;
  }
  .list-scroll {
    height: 420px;
  }
  .detail {
    min-height: 0;
    padding: 15px;
  }
  .ba {
    grid-template-columns: 1fr;
  }
  .filters .csv {
    flex-wrap: wrap;
  }
  .filters .csv .hint {
    white-space: normal;
  }
  .filters input[type=search] {
    width: 100%;
  }
  .filters select {
    flex: 1 1 140px;
  }
}

/* ---------------------------------------------------------------------------
   18. Phân quyền & Quản lý user — WA-09 4.16 -> 4.24, WA-13, WA-14
   --------------------------------------------------------------------------- */
table.perm-matrix {
  width: 100%;
  border-collapse: collapse;
}

table.perm-matrix th,
table.perm-matrix td {
  padding: 10px 12px;
  vertical-align: top;
  border-bottom: 1px solid var(--line-soft);
}

table.perm-matrix th {
  font-weight: 600;
  color: var(--ink);
  background: var(--surface-2);
}

table.perm-matrix td:first-child,
table.perm-matrix th:first-child {
  width: 180px;
  font-weight: 500;
}

/* Cột đủ rộng để nhãn quyền không bị cắt (WA-13 4.3 1.2) */
table.perm-matrix th:not(:first-child),
table.perm-matrix td:not(:first-child) {
  min-width: 180px;
}

table.perm-matrix th {
  position: relative;
}

/* ⓘ chú giải cột Đặc biệt */
.info-btn {
  background: none;
  border: 0;
  padding: 0 2px;
  font-size: 14px;
  line-height: 1;
  color: var(--muted);
  cursor: help;
}

.info-tip {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 5;
  width: 220px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.45;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-ctl);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.perm-legend {
  margin: 8px 0 0;
}

/* Ma trận: Vai trò + "Đã chọn x / N quyền" CÙNG MỘT dòng (WA-13 4.3 1.2) */
.mt-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
}

.mt-head-sel {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: none;
  min-width: 0;
}

/* Nhãn "Vai trò:" không bao giờ bẻ dòng; cỡ/màu theo nhãn WA-09 (12px --muted) */
.mt-head-sel label {
  flex: none;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

/* Ô chọn vai trò: co giãn 220-360px, cao >= 40px (vùng chạm) */
.mt-head-sel select {
  flex: 1 1 auto;
  width: auto;
  min-width: 220px;
  max-width: 360px;
  min-height: 40px;
}

@media (max-width: 859px) {
  .mt-head-sel select {
    min-height: 44px;
  }
}

@media (max-width: 639px) {
  .mt-head {
    flex-wrap: wrap;
  }

  .mt-head-sel {
    flex: 1 1 100%;
  }

  .mt-head-sel select {
    max-width: none;
  }
}

/* Thanh dưới ma trận: padding, nút cách 8px, dính đáy khung */
.mt-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 16px;
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.mt-bar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Dòng được chọn trong bảng (Vai trò, Người dùng admin): nền nổi + viền trái accent */
tr[aria-current=true],
tr[aria-selected=true] {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

tr[data-role-id],
tr[data-admin-id] {
  cursor: pointer;
}

.perm-cell-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.perm-box {
  display: inline-flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 12.5px;
  line-height: 1.4;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-ctl);
  border: 1px solid transparent;
  color: var(--ink);
}

.perm-box input[type="checkbox"] {
  cursor: pointer;
  flex: none;
  margin-top: 2px;
}

.perm-box .perm-text {
  white-space: normal;
  overflow-wrap: anywhere;
}

.perm-box.sens {
  border-color: var(--crit);
  background: var(--crit-soft);
}

.perm-box.disabled,
.perm-box input:disabled + span {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Tab ngang — WA-09 4.20 */
.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 18px;
  overflow-x: auto;
}

.tabs button[role="tab"] {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  outline: none;
}

.tabs button[role="tab"]:hover {
  color: var(--ink);
}

.tabs button[role="tab"][aria-selected="true"] {
  color: var(--ink);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* Chip vai trò — WA-09 4.21 */
.role-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  color: var(--ink);
  white-space: nowrap;
}

.role-chip button.chip-x {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 2px;
  font-size: 14px;
  line-height: 1;
  color: var(--muted);
}

.role-chip button.chip-x:hover {
  color: var(--crit);
}

/* Khối tóm tắt thay đổi — WA-09 4.22 (.diff-sum) */
.diff-sum {
  display: flex;
  gap: 14px;
  align-items: center;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  background: var(--surface-2);
  border-radius: var(--radius-ctl);
  margin: 10px 0;
}

.diff-sum .add {
  color: var(--ok);
}

.diff-sum .del {
  color: var(--crit);
}

.diff-sum .aff {
  color: var(--ink-2);
}

/* Khung hiện một lần — WA-09 4.18 (.once-box) */
.once-box {
  background: var(--surface-2);
  border: 1px solid var(--warn);
  border-radius: var(--radius-ctl);
  padding: 14px;
  margin: 12px 0;
}

.once-box .once-val {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 600;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px dashed var(--warn);
  border-radius: var(--radius-ctl);
  user-select: all;
  text-align: center;
  margin: 10px 0;
  letter-spacing: .08em;
}

/* Hộp thoại nhiều bước — WA-09 4.19 (.modal.steps) */
.modal.steps ol.stepper {
  display: flex;
  gap: 12px;
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
  border-bottom: 1px solid var(--line-soft);
}

.modal.steps ol.stepper li {
  font-size: 12px;
  color: var(--muted);
  padding-bottom: 6px;
  position: relative;
}

.modal.steps ol.stepper li[aria-current="step"] {
  color: var(--ink);
  font-weight: 600;
  border-bottom: 2px solid var(--accent);
}

.modal.steps ol.stepper li.done {
  color: var(--ok);
}

/* Ô nhập mã xác nhận — WA-09 4.23 (input.code-input) */
input.code-input {
  font-family: var(--font-mono);
  font-size: 15px;
  letter-spacing: .12em;
  text-transform: uppercase;
  text-align: center;
  max-width: 170px;
}

/* Cảnh báo nghiêm trọng — WA-09 4.24 (.note.crit) */
.note.crit {
  border-color: var(--crit);
  background: var(--crit-soft);
  color: var(--ink);
}

/* Hàng đã xoá mềm — WA-09 4.24 (tr.row-deleted) */
tr.row-deleted {
  color: var(--muted);
}

tr.row-deleted .mono {
  color: var(--muted);
}

/* Danh sách key-value — dl.kv (WA-14 4.3) */
dl.kv {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 8px 12px;
  font-size: 13px;
  margin: 0;
}

dl.kv dt {
  color: var(--muted);
  font-weight: 500;
}

dl.kv dd {
  margin: 0;
  color: var(--ink);
  word-break: break-word;
}

/* Cảnh báo hết phiên ngồi im (WA-15 4) */
.session-warning {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--warn, #f59e0b);
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  z-index: 9999;
  font-weight: 500;
  font-size: 14px;
}
.session-warning:hover {
  filter: brightness(0.95);
}

tr.highlight {
  background-color: rgba(66, 133, 244, 0.05);
}

/* Tab Người dùng admin (WA-13 / G22u) — Tránh tràn cuộn ngang & Padding khối quyền hiệu lực */
#panel-nguoi-dung-admin.cols.two {
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
}

@media (max-width: 1100px) {
  #panel-nguoi-dung-admin.cols.two {
    grid-template-columns: 1fr;
  }
}

#panel-nguoi-dung-admin > .panel:first-child .tbl-wrap {
  overflow-x: visible;
}

#panel-nguoi-dung-admin table.tbl-nguoi-dung-admin {
  width: 100%;
  table-layout: fixed;
}

#panel-nguoi-dung-admin table.tbl-nguoi-dung-admin th,
#panel-nguoi-dung-admin table.tbl-nguoi-dung-admin td {
  padding: 10px 10px;
  overflow-wrap: break-word;
  word-break: normal;
}

#panel-nguoi-dung-admin table.tbl-nguoi-dung-admin th {
  white-space: normal;
  line-height: 1.35;
}

#panel-nguoi-dung-admin table.tbl-nguoi-dung-admin th:nth-child(1),
#panel-nguoi-dung-admin table.tbl-nguoi-dung-admin td.col-admin-user {
  width: 23%;
}

#panel-nguoi-dung-admin table.tbl-nguoi-dung-admin th:nth-child(2),
#panel-nguoi-dung-admin table.tbl-nguoi-dung-admin td.col-admin-level {
  width: 52px;
}

#panel-nguoi-dung-admin table.tbl-nguoi-dung-admin th:nth-child(3),
#panel-nguoi-dung-admin table.tbl-nguoi-dung-admin td.col-admin-roles {
  width: 19%;
}

#panel-nguoi-dung-admin table.tbl-nguoi-dung-admin th:nth-child(4),
#panel-nguoi-dung-admin table.tbl-nguoi-dung-admin td.col-admin-manager {
  width: 17%;
}

#panel-nguoi-dung-admin table.tbl-nguoi-dung-admin th:nth-child(5),
#panel-nguoi-dung-admin table.tbl-nguoi-dung-admin td.col-admin-approver {
  width: 17%;
}

#panel-nguoi-dung-admin table.tbl-nguoi-dung-admin th:nth-child(6),
#panel-nguoi-dung-admin table.tbl-nguoi-dung-admin td.col-admin-actions {
  width: 24%;
}

#panel-nguoi-dung-admin td .admin-email {
  word-break: normal;
  overflow-wrap: anywhere;
  line-height: 1.4;
}

#panel-nguoi-dung-admin .role-chip {
  white-space: normal;
  max-width: 100%;
}

#panel-nguoi-dung-admin .admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.quyen-hieu-luc-panel > header.head-row {
  justify-content: space-between;
  padding: 12px 15px;
}

.quyen-hieu-luc-panel > header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  overflow-wrap: anywhere;
  flex: 1 1 auto;
  min-width: 0;
}

.quyen-hieu-luc-panel > .panel-body {
  padding: 15px;
}

.quyen-hieu-luc-panel > .panel-body > p {
  margin: 0;
}

/* ============================================================================
   Màn "Quản lý user" (WA-14 1.1 / G22g) & Chip lọc (WA-09 mục 4.24b)
   - Bố cục rộng (bỏ max-width, padding 28px quanh trang)
   - Cuộn trong khung danh sách (.tbl-wrap flex:1, thead sticky, pager dính dưới)
   - Panel thông tin ~400px
   - Chip lọc aria-pressed sáng rõ kèm ✓
   ============================================================================ */
.seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  appearance: none;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 6px 14px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--ink);
}

.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.chip[aria-pressed="true"]::before {
  content: "✓ ";
}

.chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Phân trang có số trang */
.pager button[aria-current="page"],
.pager .chip[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}

.pager .pages {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.pager .pager-dots {
  color: var(--muted);
  padding: 0 4px;
  user-select: none;
}

/* Bố cục rộng cho màn Quản lý user */
.content:has(#s-quan-ly-user:not([hidden])) {
  padding: 20px 28px 24px;
}

#s-quan-ly-user.cols.two,
.content > section.man-quan-ly-user.cols.two {
  max-width: none;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 20px;
}

.man-quan-ly-user {
  max-width: none;
}

.man-quan-ly-user .toolbar,
#s-quan-ly-user .toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--line-soft);
}

.man-quan-ly-user input[type="search"],
#s-quan-ly-user input[type="search"] {
  width: 220px;
  max-width: 100%;
}

.man-quan-ly-user tbody td:first-child,
#s-quan-ly-user tbody td:first-child {
  white-space: nowrap;
}

.man-quan-ly-user td .mono,
#s-quan-ly-user td .mono {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 34ch;
}

.man-quan-ly-user td .sub,
#s-quan-ly-user td .sub {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 34ch;
}

/* Tiêu đề panel phải cùng lề với thanh lọc bên trái */
#s-quan-ly-user > .panel > header {
  padding: 18px 22px 14px;
}

/* Nút thao tác trên hàng: lưới 2 cột gọn thay vì xếp dọc 4 tầng */
#s-quan-ly-user .row-actions {
  display: grid;
  grid-template-columns: repeat(2, max-content);
  gap: 6px;
  justify-content: start;
}

#s-quan-ly-user .row-actions .btn[disabled] {
  opacity: 0.35;
  border-style: dashed;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

@media (min-width: 861px) {
  .content > section.man-quan-ly-user,
  .content > section#s-quan-ly-user {
    height: calc(100vh - var(--ad-top, 120px) - 48px);
    min-height: 480px;
    grid-template-columns: minmax(0, 1fr) 400px;
    grid-template-rows: minmax(0, 1fr);
    align-items: stretch;
  }

  .man-quan-ly-user .btn-back-qlu,
  #s-quan-ly-user .btn-back-qlu {
    display: none;
  }

  .man-quan-ly-user > .panel,
  #s-quan-ly-user > .panel {
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .man-quan-ly-user .tbl-wrap,
  #s-quan-ly-user .tbl-wrap {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
  }

  .man-quan-ly-user thead th,
  #s-quan-ly-user thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface);
    padding: 11px 22px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
  }

  .man-quan-ly-user tbody td,
  #s-quan-ly-user tbody td {
    padding: 11px 22px;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: middle;
  }

  .man-quan-ly-user .pager,
  #s-quan-ly-user .pager {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 11px 22px;
    border-top: 1px solid var(--line);
    background: var(--surface);
  }

  .man-quan-ly-user .user-detail-body,
  #s-quan-ly-user .user-detail-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 18px 22px 22px;
  }
}

@media (max-width: 860px) {
  .content > section.man-quan-ly-user,
  .content > section#s-quan-ly-user {
    grid-template-columns: 1fr;
    height: auto;
  }

  /* Quy tắc nền `.cols.two` có độ ưu tiên cao hơn khối trên nên lưới vẫn 2 cột (cột 2 = 400px)
     làm cột danh sách bị ép về 0px — đặt lại 1 cột với selector cùng độ ưu tiên (G64a) */
  #s-quan-ly-user.cols.two,
  .content > section.man-quan-ly-user.cols.two {
    grid-template-columns: minmax(0, 1fr);
  }

  .man-quan-ly-user > .panel.list-panel,
  #s-quan-ly-user > .panel:first-child {
    height: auto;
    display: flex;
    flex-direction: column;
  }

  /* QT-72: 2 bước dưới 860px — danh sách hoặc chi tiết có nút Quay lại */
  .man-quan-ly-user.xem-chi-tiet > .panel.list-panel,
  #s-quan-ly-user.xem-chi-tiet > .panel:first-child {
    display: none;
  }

  .man-quan-ly-user:not(.xem-chi-tiet) > .panel.detail-panel,
  .man-quan-ly-user:not(.xem-chi-tiet) > .panel:not(.list-panel),
  #s-quan-ly-user:not(.xem-chi-tiet) > .panel:nth-child(2) {
    display: none;
  }

  .man-quan-ly-user .btn-back-qlu,
  #s-quan-ly-user .btn-back-qlu {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 44px;
    padding: 0 10px 0 0;
    border: 0;
    background: transparent;
    color: var(--accent);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
  }

  .man-quan-ly-user .tbl-wrap,
  #s-quan-ly-user .tbl-wrap {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
  }

  .man-quan-ly-user thead th,
  #s-quan-ly-user thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface);
  }

  .man-quan-ly-user .pager,
  #s-quan-ly-user .pager {
    flex: 0 0 auto;
  }

  .man-quan-ly-user .user-detail-body,
  #s-quan-ly-user .user-detail-body {
    overflow: visible;
  }
}

/* ============================================================================
   Màn "Chờ duyệt" (WA-16) & các thành phần duyệt thao tác nhạy cảm
   ============================================================================ */
#s-cho-duyet,
.screen-cho-duyet {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  flex: 1 1 auto;
}

#s-cho-duyet .split-cho-duyet {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 20px;
  align-items: stretch;
}

@media (min-width: 861px) {
  #s-cho-duyet .split-cho-duyet {
    height: calc(100vh - var(--ad-top, 140px) - 60px);
    min-height: 480px;
  }
}

#s-cho-duyet .split-cho-duyet > .panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#s-cho-duyet .tbl-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

#s-cho-duyet thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
  padding: 11px 22px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

#s-cho-duyet tbody td {
  padding: 11px 22px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}

#s-cho-duyet .pager {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 11px 22px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

#s-cho-duyet .detail-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 22px 22px;
}

@media (max-width: 860px) {
  #s-cho-duyet .split-cho-duyet {
    grid-template-columns: 1fr;
    height: auto;
  }

  #s-cho-duyet .split-cho-duyet > .panel:first-child {
    height: 72vh;
    height: 72dvh;
  }

  #s-cho-duyet .detail-body {
    overflow: visible;
  }
}

/* Nút lọc chip (WA-16 4.0, demo) — sáng lên khi chọn */
.chip {
  appearance: none;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 6px 14px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--ink);
}

.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.chip[aria-pressed="true"]::before {
  content: "✓ ";
}

.chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Khối xem thay đổi diffbox (WA-16 4.3) */
.diffbox {
  font-family: var(--font-mono);
  font-size: 11.5px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-ctl);
  padding: 9px 11px;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--ink-2);
}

.diffbox b.old {
  color: var(--crit);
  font-weight: 600;
}

.diffbox b.new {
  color: var(--ok);
  font-weight: 600;
}

/* Dòng thời gian timeline (WA-16 4.3) */
.timeline {
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
  font-size: 12.5px;
}

.timeline li {
  padding: 5px 0 5px 16px;
  position: relative;
  color: var(--ink-2);
}

.timeline li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 11px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--line);
}

.timeline li.done::before {
  background: var(--ok);
}

.timeline li.now::before {
  background: var(--warn);
}

.timeline li.bad::before {
  background: var(--crit);
}

/* Khối thông tin người duyệt approver-box (WA-16 4.1) */
.approver-box {
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  border-radius: var(--radius-ctl);
  padding: 10px 12px;
  font-size: 13px;
}

.approver-box .lbl {
  display: block;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 3px;
}

.approver-box .chain {
  display: block;
  font-size: 12px;
  color: var(--warn);
  margin-top: 6px;
}

.chain {
  color: var(--warn);
  font-weight: 500;
}

/* Ô nhập mã 8 ký tự (WA-16 4.4) */
.code-input {
  font-family: var(--font-mono);
  font-size: 18px;
  letter-spacing: 0.25em;
  text-align: center;
  text-transform: uppercase;
  width: 11ch !important;
}

/* Thông báo nổi toast */
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9999;
  background: var(--ok-soft);
  color: var(--ok);
  border: 1px solid var(--ok);
  border-radius: var(--radius-ctl);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  max-width: 340px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Huy hiệu số chờ duyệt (WA-16 4.0) */
#ad-count-cho-duyet,
.nav-item[data-screen="cho-duyet"] .count {
  display: inline-block;
  min-width: 18px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--warn);
  color: #201500;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

/* Hiệu ứng rung nhẹ khi click ra ngoài backdrop (WA-09 QT-31) */
.modal.pulse {
  animation: modal-pulse 0.35s ease-out;
}

@keyframes modal-pulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.015); box-shadow: 0 0 0 3px var(--accent-soft); }
  100% { transform: scale(1); }
}

/* Chữ mờ placeholder (WA-09 3.1 --muted, phông chữ thường, không monospace) */
.muted {
  color: var(--muted);
  font-family: var(--font);
  font-weight: 400;
}

.row.between {
  justify-content: space-between;
}

.panel-body > p {
  margin: 0;
}

/* Tab Bảo mật (WA-13 4.7 / G22v) */
#panel-bao-mat {
  max-width: 820px;
}

#panel-bao-mat .panel-body.stack {
  gap: 12px;
}

#panel-bao-mat .panel-body > p.hint {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--ink-2);
  margin: 0;
}

#panel-bao-mat .note {
  line-height: 1.55;
  padding: 12px 15px;
  border-radius: var(--radius-ctl);
}

#panel-bao-mat .note.stack {
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

/* ============================================================================
   Màn Tài khoản nhận tiền (WA-04 1.4 / G26a)
   ============================================================================ */
.pay-accs {
  gap: 12px;
}

.pay-acc {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  transition: background var(--dur-norm) ease;
}

.pay-acc:hover {
  background: var(--surface-2);
}

.pay-acc .qr-box {
  width: 96px;
  height: 96px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 6px;
  background: var(--surface-soft, var(--ground));
  border: 1px solid var(--line);
  border-radius: var(--radius-ctl);
  overflow: hidden;
  box-sizing: border-box;
}

.pay-acc .qr-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.pay-acc .qr-box .qr-err,
.pay-acc .qr-box .hint {
  font-size: 11px;
  line-height: 1.35;
  color: var(--muted);
  word-break: break-word;
}

.pay-acc .qr-box .qr-err {
  color: var(--warn);
}

.pay-acc .meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pay-acc .meta-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.4;
  word-break: break-word;
}

.pay-acc .meta-desc {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-2);
  white-space: pre-line;
  word-break: break-word;
}

.pay-acc .meta-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 2px;
}

.pay-acc .meta-warning {
  margin-top: 2px;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--warn);
  word-break: break-word;
}

.pay-acc .acts {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  min-width: max-content;
}

.pay-acc .acts-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (max-width: 720px) {
  .pay-acc {
    grid-template-columns: 96px minmax(0, 1fr);
  }
  .pay-acc .acts {
    grid-column: 1 / -1;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    width: 100%;
    margin-top: 4px;
    padding-top: 8px;
    border-top: 1px dashed var(--line);
  }
}

/* Khối Quy tắc mua gói (WA-04 1.4 / G26a) */
.rules-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rule-item {
  display: grid;
  grid-template-columns: minmax(120px, auto) minmax(0, 1fr);
  gap: 12px;
  align-items: baseline;
}

.rule-item .rule-badge {
  flex-shrink: 0;
  white-space: nowrap;
}

.rule-item .rule-text {
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-2);
  word-break: break-word;
}

/* Modal xem trước ảnh QR khi chọn file */
.modal-qr-preview {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-qr-preview .qr-box {
  width: 80px;
  height: 80px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-soft, var(--ground));
  border: 1px solid var(--line);
  border-radius: var(--radius-ctl);
  overflow: hidden;
}

.modal-qr-preview .qr-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* WA-04 1.5 — hộp Thêm/Sửa tài khoản nhận tiền: lưới 2 cột cố định, ô dài chiếm cả hàng, không nhảy khi hiện/ẩn gợi ý */
.pay-form {
  align-items: start;
}

.pay-form > * {
  min-width: 0;
}

.pay-form .pay-hint-slot {
  min-height: 2.9em;
}

.pay-form .pay-hint-slot .hint {
  margin: 0;
}

.pay-form .qr-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.pay-form .qr-actions .hint {
  word-break: break-all;
}

/* Rê chuột vào ảnh QR: con trỏ kính lúp (+); bấm để xem ảnh lớn (WA-04 1.5 mục 4.2b) */
.pay-acc .qr-box.zoomable {
  cursor: zoom-in;
}

.pay-acc .qr-box.zoomable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.qr-zoom {
  text-align: center;
}

.qr-zoom img {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  background: #fff;
  border-radius: var(--radius-ctl);
}

/* QT-44 — tôn trọng prefers-reduced-motion (trang này không có chuyển động) */
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}

/* Khối "Đơn hết hạn giữ giá": khoảng thở + ô tìm kiếm đúng kiểu ô nhập khác */
.panel > details > .pad-top { padding: 14px 15px 4px; }
.exp-search { flex: 1 1 260px; max-width: 420px; width: auto; }
.exp-search:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.panel > details > summary { display: flex; align-items: center; gap: 6px; }
.panel > details .row.align-center { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Màn Duyệt thanh toán: bảng rộng hết khung, co giãn theo cửa sổ (anh yêu cầu 2026-11-10) */
/* Ảnh minh chứng thu nhỏ — giống ảnh QR: rê chuột kính lúp, bấm xem lớn */
.proof-thumb {
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-soft, var(--ground));
  border: 1px solid var(--line);
  border-radius: var(--radius-ctl);
  overflow: hidden;
  margin-bottom: 6px;
}
.proof-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.proof-thumb.zoomable { cursor: zoom-in; }
.proof-thumb.zoomable:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.proof-thumb .proof-pdf { font-weight: 700; color: var(--muted); }
.proof-thumb .hint { font-size: 11px; text-align: center; padding: 4px; }

/* Màn Duyệt thanh toán: khối Đã xử lý (WA-03 mục 4.3, task G53e) */
.handled-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}
.handled-title-wrap {
  min-width: 0;
}
.handled-toolbar {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}
.handled-search-box {
  position: relative;
  min-width: 250px;
}
.handled-search-box input[type="search"] {
  width: 100%;
}
.handled-search-hint {
  margin: 4px 0 0;
}

/* Modal Chi tiết đơn (WA-03 mục 4.3) */
.pay-detail-wrap {
  max-width: 600px;
}
.pay-detail-group {
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 12px;
  margin-bottom: 12px;
}
.pay-detail-group:last-child {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
}
.pay-detail-heading {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin: 0 0 8px;
}
.pay-detail-skel .skel-block {
  height: 36px;
  background: var(--surface-2);
  border-radius: var(--radius-ctl);
  animation: pulse 1.5s infinite ease-in-out;
}
.pay-detail-skel .skel-line {
  color: var(--muted);
  font-size: 13px;
}
.pager-more {
  padding: 12px 0 4px;
}

@media (max-width: 860px) {
  .handled-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .handled-toolbar {
    flex-direction: column;
    width: 100%;
    gap: 10px;
  }
  .handled-toolbar .seg {
    display: flex;
    overflow-x: auto;
    flex-wrap: nowrap;
    width: 100%;
    gap: 8px;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }
  .handled-toolbar .seg .chip {
    flex: 0 0 auto;
    min-height: 44px;
  }
  .handled-search-box {
    width: 100%;
    min-width: 0;
  }
  .handled-search-box input[type="search"] {
    width: 100%;
    min-height: 44px;
    font-size: 16px;
  }
  .modal.modal-pay-detail,
  .modal:has(.pay-detail-wrap) {
    max-height: 94%;
  }
}

/* ---------------------------------------------------------------------------
   Tổng quan — ô số bấm được (WA-09 mục 4.1, QT-12/QT-13)
   Lưới tự xuống 1–2 cột trên điện thoại, không bao giờ cuộn ngang trang.
   --------------------------------------------------------------------------- */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(178px, 100%), 1fr));
  gap: 12px;
}

button.tile {
  all: unset;
  box-sizing: border-box;
  cursor: pointer;
  display: block;
  text-align: left;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 15px;
  font-family: var(--font);
  color: var(--ink);
}

button.tile:hover {
  border-color: var(--accent);
}

button.tile:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.tile .k {
  font-size: 11.5px;
  color: var(--muted);
}

.tile .v {
  font-size: 25px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-top: 2px;
}

.tile .s {
  font-size: 11.5px;
  color: var(--muted);
}

.tile .s.crit {
  color: var(--crit);
}

.tile .go {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--accent);
  margin-top: 4px;
}

button.tile.flag {
  border-color: color-mix(in srgb, var(--crit) 40%, transparent);
  background: var(--crit-soft);
}

button.tile.flag:hover {
  border-color: var(--crit);
}

button.tile.flag .v,
button.tile.flag .k,
button.tile.flag .go {
  color: var(--crit);
}

/* Chỗ dành sẵn khi đang tải — không nhảy bố cục (WA-09 mục 6) */
.tq-so-lieu.tq-cho {
  min-height: 120px;
}

.todo-row {
  justify-content: space-between;
  gap: 9px;
}

.todo-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* ===========================================================================
   Màn Gói cước (WA-02 1.9, task G28a) — danh sách rút gọn + popup
   Chi tiết / Tạo / Sửa. Chỉ dùng token WA-09; ngoại lệ cỡ chữ / vùng chạm
   dưới 860px theo QT-45 bản 1.6 (QT-63/64/67/69).
   =========================================================================== */

/* Tên gói là NÚT bấm được (cả dòng không bấm được để công tắc "Bán" không nhầm) */
button.link {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: var(--accent);
  text-align: left;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

button.link:hover {
  opacity: 0.85;
}

button.link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-ctl);
}

.goi-ds td.ten-goi .sub-line {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* ---- Popup (WA-09 4.10 bản 1.6): đầu + chân cố định, thân cuộn bên trong ---- */
.pop-back {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  background: color-mix(in srgb, var(--ink) 45%, transparent);
}

.pop {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 720px;
  max-height: calc(100vh - 32px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-modal);
  overflow: hidden;
}

.pop.pop-ct {
  max-width: 560px;
}

.pop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: 0 0 auto;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.pop-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  min-width: 0;
  overflow-wrap: anywhere;
}

.pop-x {
  appearance: none;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius-ctl);
  background: var(--surface);
  color: var(--ink);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.pop-x:hover {
  background: var(--surface-2);
}

.pop-x:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.pop-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 18px;
}

.pop-foot {
  flex: 0 0 auto;
  padding: 13px 18px;
  border-top: 1px solid var(--line-soft);
  background: var(--surface);
}

.pop-acts {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.pop-ct .pop-acts > :first-child {
  margin-right: auto;
}

.pop-why {
  margin: 0;
  text-align: right;
}

.pop .dong-gia,
.pop .dong-tn {
  line-height: 1.6;
}

/* ---- Dưới 860px: bottom-sheet (QT-67), thẻ gọn thay bảng (QT-66) ---- */
@media (max-width: 860px) {
  .pop-back {
    place-items: end stretch;
    padding: 0;
  }

  .pop {
    max-width: none;
    max-height: 88%;
    border-radius: var(--radius-modal) var(--radius-modal) 0 0;
    border-bottom: 0;
  }

  .pop.pop-ct {
    max-width: none;
  }

  /* popup form dài (Tạo / Sửa gói): cao ~94% */
  .pop.pop-form {
    height: 94%;
    max-height: 94%;
  }

  .pop-head {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }

  .pop-body {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    font-size: 15px;
  }

  .pop-foot {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-bottom: max(13px, env(safe-area-inset-bottom));
  }

  .pop-x {
    width: 44px;
    height: 44px;
  }

  .pop input[type="text"],
  .pop input[type="number"],
  .pop select,
  .pop textarea {
    font-size: 16px;
    min-height: 44px;
    max-width: 100%;
    min-width: 0;
  }

  .pop .btn {
    min-height: 44px;
  }

  /* Lưới nút 2 cột đều; nút nguy hiểm đứng riêng 1 hàng full ngang, lý do nằm DƯỚI nút (QT-65) */
  .pop-acts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .pop-ct .pop-acts > :first-child {
    margin-right: 0;
  }

  .pop-acts .full {
    grid-column: 1 / -1;
    order: 5;
  }

  .pop-why {
    text-align: left;
  }

  /* vùng chạm công tắc >= 44px mà không đổi hình dạng công tắc */
  .pop .sw::before,
  .goi-ds .sw::before {
    content: "";
    position: absolute;
    inset: -12px -4px;
  }

  .pop .dong-gia,
  .pop .dong-tn {
    font-size: 15px;
  }

  .pop .hint {
    font-size: 12px;
  }

  /* Danh sách rút gọn thành thẻ gọn: không bao giờ cuộn ngang */
  .goi-ds table,
  .goi-ds tbody,
  .goi-ds tr,
  .goi-ds td {
    display: block;
  }

  .goi-ds thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .goi-ds tbody tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 14px;
    padding: 12px 15px;
    border-bottom: 1px solid var(--line-soft);
  }

  .goi-ds tbody tr:last-child {
    border-bottom: 0;
  }

  .goi-ds td {
    border-bottom: 0;
    padding: 0;
    min-width: 0;
  }

  .goi-ds td.ten-goi {
    flex: 1 1 100%;
  }

  .goi-ds td.ten-goi button.link {
    min-height: 44px;
    font-size: 15px;
  }

  .goi-ds td[data-nhan]::before {
    content: attr(data-nhan);
    display: block;
    font-size: 12px;
    color: var(--ink-2);
  }

  .goi-ds td.empty {
    flex: 1 1 100%;
  }

  .goi-ds td.empty::before {
    content: none;
  }
}

/* ---------------------------------------------------------------------------
   Sửa giao diện theo ảnh anh gửi 2026-11-11 (UX): ô nhập thiếu `type`/mật khẩu
   phải theo theme như mọi ô khác; hộp thoại Nhà cung cấp dùng lớp
   .modal-backdrop/.modal-box; khối Xuất báo cáo CSV; panel Phân quyền.
   --------------------------------------------------------------------------- */
input:not([type]),
input[type="password"],
input[type="url"],
input[type="tel"],
input.input {
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-ctl);
  padding: 7px 10px;
  width: 100%;
  box-sizing: border-box;
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--accent);
}

/* Hộp thoại kiểu cũ của màn Nhà cung cấp (đổi khoá, đổi endpoint, xoá): cùng
   hình dạng với .modal-back / .modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  background: color-mix(in srgb, var(--ink) 45%, transparent);
}

.modal-box {
  width: 100%;
  max-width: 540px;
  max-height: 86vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-modal);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-box > h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.modal-box .form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-box .form-group label {
  font-size: 12px;
  color: var(--muted);
}

.modal-box .modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 13px;
  border-top: 1px solid var(--line-soft);
}

.modal-box .formmsg {
  margin: 0;
}

/* Khối Xuất báo cáo CSV (Tổng quan): thân có lề, mỗi hàng xuống dòng gọn */
.export-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 15px;
}

.export-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.export-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
}

.export-row label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  flex: 1 1 180px;
  min-width: 0;
}

.export-row input[type="date"] {
  width: 100%;
  min-width: 0;
}

.export-row .why {
  flex: 1 1 100%;
  font-size: 11.5px;
  color: var(--muted);
}

@media (min-width: 861px) {
  .export-row .why {
    flex: 1 1 auto;
  }
}

/* Panel "Người đang giữ vai trò" (Phân quyền): chữ gợi ý không dính viền */
#panel-vai-tro > .panel.stack {
  gap: 0;
}

#panel-vai-tro > .panel.stack > .hint {
  padding: 15px;
  margin: 0;
}

#panel-vai-tro header.head-row {
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px 16px;
}

/* ---------------------------------------------------------------------------
   Khối Nguồn tỷ giá, Lịch tự lấy JST và Bảng Tất cả tỷ giá (WA-04 4.9b, G44f, G52a)
   --------------------------------------------------------------------------- */
.cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.card {
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.card h3 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.card .line {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: space-between;
}

.card .val {
  font-weight: 600;
  word-break: break-word;
}

.sched-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.time {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.time .colon {
  font-weight: 700;
  color: var(--muted);
}

.time select {
  padding-right: 6px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.tz {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
}

.sched-row .btn {
  margin-left: auto;
}

.sw-wrap {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
}

.c-code {
  width: 34%;
}

.c-rate {
  width: 28%;
  text-align: right;
}

.c-act {
  width: 38%;
  text-align: right;
}

th.c-rate,
th.c-act {
  text-align: right;
}

td.c-rate {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

td.c-act {
  text-align: right;
}

.cname {
  display: block;
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
  font-family: var(--font);
}

tr.inuse td {
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}

.state {
  padding: 28px 16px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
}

.state.err {
  border-color: var(--crit);
  color: var(--crit);
  background: var(--crit-soft);
  border-style: solid;
}

.state .btn {
  margin-top: 10px;
}

.fx-source-row,
.fx-schedule-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}

.fx-source-left,
.fx-schedule-left {
  flex: 1 1 auto;
}

.fx-source-right,
.fx-schedule-right {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.table-scroll {
  max-height: 420px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-ctl, 6px);
}

.table-scroll table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-soft);
}

.table-scroll td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}

.table-scroll tr:last-child td {
  border-bottom: 0;
}

.fx-sub-name-360 {
  display: none;
}

.fx-btn-short {
  display: none;
}

/* ---------------------------------------------------------------------------
   Giao diện di động chung (dưới 860px) — WA-09 1.6 mục 3.4 (QT-61→72), task G28b.
   CHỈ áp dưới ngưỡng; trên máy tính giữ nguyên mọi khối ở trên. Khối này nằm
   CUỐI file để thắng các luật di động cũ cùng độ ưu tiên (QT-61→72 thắng QT cũ).
   Ngoại lệ chữ/kích thước so với mục 3.2 và QT-45: anh duyệt 2026-11-11 (QT-69).
   --------------------------------------------------------------------------- */
@media (max-width: 860px) {
  /* QT-69: chữ phụ sáng hơn để đủ tương phản 4.5:1 (chỉ ở chế độ sáng, không đổi biến ở máy tính) */
  :root {
    --muted: #5d6b64;
  }

  body {
    font-size: 15px;
  }

  /* QT-62: không tràn ngang; chữ dài tự xuống dòng */
  .shell,
  .main,
  .content,
  .content > section,
  .panel,
  .panel > header,
  .panel-body,
  .row,
  .tile {
    min-width: 0;
  }

  .content,
  .panel,
  .modal {
    overflow-wrap: anywhere;
  }

  /* QT-68: lề trái / phải / đáy theo vùng an toàn */
  .side,
  .topbar,
  .content {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }

  .content {
    padding-top: 16px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }

  .brand {
    padding-left: 0;
    padding-right: 0;
  }

  /* QT-61: dải tab cuộn ngang, KHÔNG nhãn nhóm, mép phải mờ dần báo còn tab */
  .nav {
    padding-left: 0;
    padding-right: 0;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    -webkit-mask-image: linear-gradient(to right, var(--ink) calc(100% - 28px), transparent);
    mask-image: linear-gradient(to right, var(--ink) calc(100% - 28px), transparent);
  }

  .nav::-webkit-scrollbar {
    display: none;
  }

  .nav-group {
    display: none;
  }

  .nav-item {
    flex: none;
    width: auto;
    min-height: 44px;
    padding: 8px 14px;
    font-size: 15px;
    white-space: nowrap;
  }

  /* Chữ phụ không nhỏ hơn 12px (QT-69) */
  .nav-item .count,
  .brand-role,
  .hint,
  .field,
  .kv dt,
  .tbl-wrap th,
  .pill,
  .tile .s {
    font-size: 12px;
  }

  /* QT-63: vùng chạm >= 44px */
  .btn,
  .btn.sm,
  .chip,
  .topbar .btn,
  button.link,
  [role="tab"] {
    min-height: 44px;
  }

  .tbl-wrap tr.click {
    min-height: 44px;
  }

  /* QT-64: ô nhập 16px, cao >= 44px, nhãn nằm TRÊN ô */
  input[type="text"],
  input[type="search"],
  input[type="email"],
  input[type="date"],
  input[type="number"],
  input[type="password"],
  input:not([type]),
  select,
  textarea {
    font-size: 16px;
    min-height: 44px;
    min-width: 0;
    max-width: 100%;
  }

  .field {
    display: flex;
    flex-direction: column;
  }

  /* Thanh lọc / ô tìm: full ngang */
  .filters {
    flex-direction: column;
    align-items: stretch;
  }

  .filters > *,
  .filters select,
  .filters input[type="date"],
  .filters input[type="search"] {
    width: 100%;
    min-width: 0;
  }

  .panel > header {
    flex-wrap: wrap;
    padding-left: 15px;
    padding-right: 15px;
  }

  .panel > header .right {
    flex: 1 1 100%;
    flex-wrap: wrap;
    margin-left: 0;
  }

  .panel > header .right input,
  .panel > header .right select,
  .panel > header .right input[type="search"] {
    width: 100%;
  }

  /* QT-65: lưới nút 2 cột; nút chính / nguy hiểm riêng một hàng; ghi chú DƯỚI nút */
  .acts,
  .acts-cell {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    align-items: stretch;
    white-space: normal;
  }

  .acts > .full,
  .acts-cell > .full,
  .acts-cell > .btn.primary,
  .acts-cell > .btn.danger {
    grid-column: 1 / -1;
  }

  .acts > .why,
  .acts > .hint,
  .acts-cell > .why,
  .acts-cell > .hint {
    grid-column: 1 / -1;
    order: 9;
    margin: 0;
    text-align: left;
  }

  /* QT-66: bảng chung thành thẻ — không bao giờ cuộn ngang trên điện thoại.
     Nhãn cột lấy từ thuộc tính data-label do admin.js gắn; ma trận quyền
     (perm-matrix) giữ dạng bảng cuộn trong khung của nó. */
  .tbl-wrap table:not(.perm-matrix),
  .tbl-wrap table:not(.perm-matrix) tbody {
    display: block;
    width: 100%;
  }

  .tbl-wrap table:not(.perm-matrix) thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .tbl-wrap table:not(.perm-matrix) tr {
    display: block;
    padding: 10px 15px;
    border-bottom: 1px solid var(--line-soft);
  }

  .tbl-wrap table:not(.perm-matrix) tr:last-child {
    border-bottom: 0;
  }

  .tbl-wrap table:not(.perm-matrix) td {
    display: block;
    padding: 4px 0;
    border: 0;
    min-width: 0;
    white-space: normal;
  }

  .tbl-wrap table:not(.perm-matrix) td[data-label] {
    display: grid;
    grid-template-columns: minmax(88px, 38%) minmax(0, 1fr);
    column-gap: 10px;
    align-items: start;
  }

  .tbl-wrap table:not(.perm-matrix) td[data-label]::before {
    content: attr(data-label);
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
  }

  .tbl-wrap table:not(.perm-matrix) td.empty {
    padding: 22px 0;
    text-align: center;
  }

  /* Phân trang gọn: Trước / Sau 44px, dòng "Trang x / y" xuống dòng riêng (QT-70) */
  .pager {
    padding-left: 15px;
    padding-right: 15px;
    gap: 8px;
  }

  .pager .spacer {
    margin-left: 0;
  }

  .pager select {
    width: auto;
  }

  /* QT-67: hộp thoại = bottom-sheet; đầu / chân cố định, thân tự cuộn */
  .modal-back {
    place-items: end stretch;
    padding: 0;
  }

  .modal {
    display: flex;
    flex-direction: column;
    max-width: none;
    max-height: 88%;
    overflow: hidden;
    border-radius: var(--radius-modal) var(--radius-modal) 0 0;
    border-bottom: 0;
  }

  .modal > header,
  .modal-body,
  .modal-foot {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }

  .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
  }

  .modal > header,
  .modal-foot {
    flex: none;
  }

  .modal-foot {
    padding-bottom: max(13px, env(safe-area-inset-bottom));
  }

  .modal-foot .btn {
    flex: 1 1 auto;
  }

  /* Tổng quan: ô số 1–2 cột */
  .tiles {
    grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr));
  }

  /* Khối "Xuất báo cáo CSV": mỗi nút full ngang, ô ngày mỗi ô một hàng,
     nhãn trên ô; chỉ khi khung >= 370px thì cặp Từ / Đến thành 2 cột (QT-64) */
  .export-body {
    container-type: inline-size;
    padding: 15px;
  }

  .export-row {
    flex-direction: column;
    align-items: stretch;
    flex-wrap: nowrap;
    gap: 10px;
  }

  .export-row label {
    flex: none;
    width: 100%;
    font-size: 12px;
  }

  .export-row input[type="date"] {
    width: 100%;
    min-width: 0;
  }

  .export-row .btn {
    width: 100%;
  }

  .export-row .why {
    flex: none;
    font-size: 12px;
  }

  @container (min-width: 370px) {
    .export-row:has(input[type="date"]) {
      display: grid;
      grid-template-columns: 1fr 1fr;
    }

    .export-row:has(input[type="date"]) > .btn,
    .export-row:has(input[type="date"]) > .why {
      grid-column: 1 / -1;
    }
  }

  /* -------------------------------------------------------------------------
     G28c1: Nhóm Người dùng & tiền (WA-09 1.6 QT-61→72, task G28c1)
     ------------------------------------------------------------------------- */

  /* QT-65: mở rộng .acts cho nút chính/nguy hiểm */
  .acts > .btn.primary,
  .acts > .btn.danger {
    grid-column: 1 / -1;
  }

  /* Bảng hành động cuối thẻ: .acts-col / :has(.acts-cell) / :has(.row-actions) */
  .tbl-wrap table:not(.perm-matrix) td.acts-col,
  .tbl-wrap table:not(.perm-matrix) td:has(.acts-cell),
  .tbl-wrap table:not(.perm-matrix) td:has(.row-actions) {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding-top: 8px;
    border-top: 1px dashed var(--line-soft);
  }

  .tbl-wrap table:not(.perm-matrix) td.acts-col::before,
  .tbl-wrap table:not(.perm-matrix) td:has(.acts-cell)::before,
  .tbl-wrap table:not(.perm-matrix) td:has(.row-actions)::before {
    display: none;
  }

  /* Quản lý user: thanh công cụ và ô tìm full ngang */
  .man-quan-ly-user .toolbar,
  #s-quan-ly-user .toolbar {
    padding: 12px 15px;
    gap: 8px;
  }

  .man-quan-ly-user input[type="search"],
  #s-quan-ly-user input[type="search"] {
    width: 100%;
    max-width: 100%;
  }

  .man-quan-ly-user .row-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
  }

  .man-quan-ly-user .row-actions > .btn.primary,
  .man-quan-ly-user .row-actions > .btn.danger {
    grid-column: 1 / -1;
  }

  /* Hộp thoại nhiều bước: stepper quấn dòng gọn gàng, ô nhập mã >= 44px */
  .modal.steps ol.stepper {
    flex-wrap: wrap;
    gap: 8px;
  }

  input.code-input {
    font-size: 16px;
    min-height: 44px;
  }

  /* Duyệt thanh toán: ô tìm đơn hết hạn full ngang (QT-64) */
  .exp-search-row {
    flex-wrap: wrap;
    gap: 8px;
  }

  .exp-search {
    flex: 1 1 100%;
    max-width: 100%;
    width: 100%;
  }

  .exp-search-row .btn {
    width: 100%;
  }

  /* Nhận tiền: thẻ tài khoản co giãn, không tràn ở 360px */
  .pay-acc {
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 12px;
    padding: 12px;
  }

  .pay-acc .qr-box {
    width: 88px;
    height: 88px;
  }

  .pay-acc .acts {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    width: 100%;
    margin-top: 6px;
    padding-top: 10px;
    border-top: 1px dashed var(--line);
  }

  .pay-acc .acts .btn {
    min-height: 44px;
    flex: 1 1 auto;
  }

  /* Công tắc .sw: vùng chạm >= 44px (QT-63) */
  .sw {
    min-width: 48px;
    min-height: 28px;
  }

  .sw::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: 48px;
    min-height: 44px;
  }

  /* Khối tỷ giá quy đổi: xếp dọc nhãn và input */
  .fx-rate-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .fx-rate-right {
    display: flex;
    gap: 8px;
    width: 100%;
  }

  .fx-rate-right input {
    flex: 1 1 auto;
    width: 100% !important;
  }

  .fx-rate-right .btn {
    min-width: 72px;
  }

/* ---------------------------------------------------------------------------
   Khối Nguồn tỷ giá, Lịch tự lấy JST và Bảng Tất cả tỷ giá (WA-04 4.9b, G44f, G52a)
   --------------------------------------------------------------------------- */
@media (max-width: 760px) {
  .cards {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .fx-search-rates {
    max-width: none;
  }

  .table-scroll.tbl-scroll {
    border: 0;
    overflow: visible;
    max-height: none;
  }

  table.fx-rates-table {
    min-width: 0;
    table-layout: auto;
  }

  table.fx-rates-table thead {
    display: none;
  }

  table.fx-rates-table tbody,
  table.fx-rates-table tr,
  table.fx-rates-table td {
    display: block;
  }

  table.fx-rates-table tr {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2px 12px;
    align-items: center;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
    padding: 10px 12px;
    margin-bottom: 8px;
    background: var(--surface-2);
  }

  table.fx-rates-table td {
    border: 0;
    padding: 2px 0;
  }

  table.fx-rates-table td.c-code {
    grid-column: 1;
    grid-row: 1;
  }

  table.fx-rates-table td.c-rate {
    grid-column: 2;
    grid-row: 1;
    width: auto;
    text-align: right;
  }

  table.fx-rates-table td.c-act {
    grid-column: 1 / -1;
    grid-row: 2;
    width: auto;
    text-align: left;
    padding-top: 6px;
  }

  table.fx-rates-table td.c-act:empty {
    display: none;
  }

  table.fx-rates-table tr.inuse td {
    background: transparent;
  }

  table.fx-rates-table tr.inuse {
    border-color: var(--accent);
  }

  table.fx-rates-table td.c-rate::before {
    content: "1 USD = ";
    font-family: var(--font);
    font-size: 12px;
    color: var(--muted);
  }

  .modal-foot {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .modal-foot .modal-foot-left {
    margin: 0;
  }

  .modal-foot .btn {
    width: 100%;
  }
}

/* Responsive màn hẹp 360px (WA-04 4.9b, G44f) */
@media (max-width: 360px) {
  .table-scroll {
    max-height: 60vh;
  }

  .table-scroll th.col-name,
  .table-scroll td.col-name {
    display: none;
  }

  .fx-sub-name-360 {
    display: block;
    font-size: 12px;
    font-weight: normal;
    color: var(--muted);
  }

  .fx-btn-full {
    display: none;
  }

  .fx-btn-short {
    display: inline;
  }

  .fx-source-row,
  .fx-schedule-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .fx-source-right,
  .fx-schedule-right {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}

  /* -------------------------------------------------------------------------
     G28c2: Nhóm Theo dõi và Hệ thống (WA-09 1.6 QT-61→72, task G28c2)
     ------------------------------------------------------------------------- */

  /* QT-63: Nút điều chỉnh thứ tự ưu tiên ▲▼ (btn-move) có vùng chạm >= 44px */
  .btn-move {
    min-width: 44px;
    min-height: 44px;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* QT-47 / QT-62: Thanh quota co giãn linh hoạt, không tràn ở 360px */
  .bar {
    min-width: 0;
    width: 100%;
  }

  /* Email: các hàng nhập liệu SMTP và vai trò co giãn gọn gàng */
  .smtp-inputs {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .smtp-inputs label.field {
    width: 100%;
  }

  .email-add-row {
    flex-wrap: wrap;
    gap: 8px;
  }

  .email-add-row input[type="email"] {
    flex: 1 1 100%;
    width: 100% !important;
    min-height: 44px;
    font-size: 16px;
  }

  .email-add-row .btn,
  .email-add-row select {
    min-height: 44px;
  }

  /* Ô nhập email và chân thư: cỡ chữ 16px (QT-64 chống phóng to trên iOS) */
  #s-email input,
  #s-email textarea,
  #s-email select,
  #s-transcript input,
  #s-transcript select {
    font-size: 16px;
    min-height: 44px;
  }

  #s-email textarea {
    min-height: 88px;
  }

  /* Transcript: khối gỡ transcript và blocklist */
  #s-transcript .cols.two {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  /* -------------------------------------------------------------------------
     G28c3: Nhóm Chờ duyệt, Phân quyền, Tài khoản, Nhật ký (WA-09 1.6 mục 3.4 QT-61→72)
     ------------------------------------------------------------------------- */

  /* Chờ duyệt (#s-cho-duyet, .screen-cho-duyet) */
  .split-cho-duyet {
    grid-template-columns: 1fr;
  }

  .actions .act {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .actions .act .why {
    grid-column: 1 / -1;
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
  }

  .actions .act .btn {
    min-height: 44px;
    font-size: 14px;
  }

  .actions .act .btn:only-of-type {
    grid-column: 1 / -1;
    width: 100%;
  }

  /* Phân quyền (#s-phan-quyen) */
  table.perm-matrix {
    max-width: 100%;
    overflow-x: auto;
    min-width: 0;
  }

  .perm-box {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  .mt-bar .btn {
    min-height: 44px;
  }

  /* Tài khoản (#s-tai-khoan) */
  #btnDangXuatKhac {
    width: 100%;
    min-height: 44px;
    margin-top: 8px;
  }

  #s-tai-khoan .acts-col .btn {
    min-height: 44px;
    min-width: 44px;
  }

  /* Nhật ký (#s-nhat-ky) */
  .cols.audit-cols {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .filters input[type="date"],
  .filters input[type="search"],
  .filters select {
    min-height: 44px;
    font-size: 16px;
    width: 100%;
  }

  #ad-audit-export {
    width: 100%;
    min-height: 44px;
  }

  #ad-audit-prev,
  #ad-audit-next {
    min-height: 44px;
    min-width: 48px;
  }

  .item {
    min-height: 44px;
  }

  /* Màn Mã kích hoạt (WA-10) di động */
  .filters .seg {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
  }

  .filters .seg .btn {
    flex: 1 1 auto;
    min-height: 44px;
  }

  .state-wrap {
    padding: 24px 16px;
  }
}

@media (max-width: 860px) and (prefers-reduced-motion: reduce) {
  .nav {
    scroll-behavior: auto;
  }
}

/* Hết khối di động chung G28b (khối Điều khoản G29c đứng sau để thắng khi cùng độ ưu tiên) */

/* ===========================================================================
   Màn "Điều khoản" (WA-17, task G29c) — chỉ dùng token WA-09 (màu, bán kính,
   cỡ chữ). Ngoại lệ có tên: ô Markdown cỡ 16px theo đúng WA-17 4.5. Dưới 860px
   theo WA-09 3.4: danh sách thành thẻ .rc (QT-66), hai bước danh sách → chi tiết
   (QT-72), màn soạn thành hai tab Soạn | Xem trước, hộp là bottom-sheet (QT-67).
   =========================================================================== */
.man-dk,
.man-dk * {
  min-width: 0;
}

.man-dk .mono,
.man-dk td,
.man-dk dd,
.dk-hop dd {
  overflow-wrap: anywhere;
}

.man-dk .dk-note-nhap {
  margin: 12px 15px 0;
}

/* Danh sách các bản: cuộn trong khung, tiêu đề cột dính (WA-17 QT-11) */
.man-dk .tbl-wrap.dk-cuon {
  max-height: 60vh;
  overflow: auto;
}

.man-dk .tbl-wrap.dk-cuon-dy {
  max-height: 300px;
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-ctl);
}

.man-dk .dk-cuon thead th,
.man-dk .dk-cuon-dy thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
}

/* Thẻ .rc chỉ dùng dưới 860px; nút Quay lại chỉ có ở bước 2 điện thoại */
.man-dk .dk-the-ds,
.man-dk .dk-lui,
.man-dk .dk-sx {
  display: none;
}

.man-dk .rc {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 15px;
  border-bottom: 1px solid var(--line-soft);
}

.man-dk .rc-dau {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  overflow-wrap: anywhere;
}

.man-dk dl.kvl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  margin: 0;
  font-size: 13px;
}

.man-dk dl.kvl dt {
  color: var(--muted);
}

.man-dk dl.kvl dd {
  margin: 0;
  overflow-wrap: anywhere;
}

/* Khung xem trước — iframe sandbox do server dựng (WA-17 4.3, QT-5) */
.dk-frame {
  display: block;
  width: 100%;
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: var(--radius-ctl);
  background: var(--surface);
}

.man-dk .chip.dk-thieu,
.man-dk .chip[disabled] {
  opacity: 0.45;
  cursor: default;
}

.man-dk .dk-md-doc {
  margin: 0;
  max-height: 420px;
  overflow: auto;
  padding: 10px 13px;
  font-family: inherit;
  font-size: 13px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--surface-2);
  border-radius: var(--radius-ctl);
}

.man-dk .dk-tt-chu {
  margin: 0;
  white-space: pre-line;
}

.man-dk .dk-dy {
  padding-top: 15px;
  border-top: 1px solid var(--line-soft);
}

.man-dk .dk-dy-tieu-de,
.dk-hop-khach h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.man-dk .dk-dy p {
  margin: 0;
}

.man-dk .dk-dy .pager {
  padding-left: 0;
  padding-right: 0;
}

.man-dk .dk-acts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Màn soạn */
.man-dk .dk-soan-tieu-de {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.man-dk .dk-cuon-ngang {
  overflow-x: auto;
}

.man-dk .dk-hai-cot {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  align-items: start;
}

/* WA-17 4.5: ô Markdown 16px, xuống dòng mềm */
.man-dk textarea.dk-md {
  font-size: 16px;
  min-height: 420px;
  white-space: pre-wrap;
}

.man-dk .dk-cham-do {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 6px;
  border-radius: var(--radius-pill);
  background: var(--crit);
  vertical-align: middle;
}

.man-dk .dk-cu-phap > summary {
  cursor: pointer;
  font-size: 13px;
}

/* Hộp của màn: rộng hơn khi có khung xem trước */
.modal.dk-hop.dk-hop-rong,
.modal.dk-hop.steps {
  max-width: 760px;
}

.dk-hop > header .row.between {
  align-items: center;
}

.dk-hop .dk-xem .dk-frame {
  min-height: 320px;
}

/* G29e: máy tính — "Các bản" giữ cỡ cũ cố định (≈650px), "Chi tiết" bên phải tự co giãn (1fr)
   chiếm hết bề ngang còn lại; riêng màn Điều khoản bỏ giới hạn max-width của .content.
   Chỉ đổi lưới riêng của màn, không đụng `.cols.two`/`.content` của màn khác */
@media (min-width: 861px) {
  .man-dk .dk-cols {
    grid-template-columns: 650px minmax(0, 1fr);
  }
}

@media (max-width: 860px) {
  .man-dk {
    font-size: 15px;
  }

  /* QT-72: hai bước danh sách → chi tiết */
  .man-dk:not(.dk-buoc-ct) .dk-ct {
    display: none;
  }

  .man-dk.dk-buoc-ct .dk-ds,
  .man-dk.dk-buoc-ct .dk-hh {
    display: none;
  }

  .man-dk .dk-lui {
    display: inline-flex;
  }

  /* QT-66: bảng thành thẻ, không cuộn ngang */
  .man-dk .tbl-wrap.dk-cuon,
  .man-dk .tbl-wrap.dk-cuon-dy {
    display: none;
  }

  .man-dk .dk-the-ds {
    display: flex;
    flex-direction: column;
  }

  .man-dk .dk-dy .dk-the-ds {
    max-height: min(56vh, 400px);
    overflow-y: auto;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-ctl);
  }

  /* Màn soạn: hai tab Soạn | Xem trước thay cho hai cột */
  .man-dk .dk-sx {
    display: block;
  }

  .man-dk .dk-hai-cot {
    grid-template-columns: 1fr;
  }

  .man-dk .dk-hai-cot.dk-dang-soan .dk-cot-xem,
  .man-dk .dk-hai-cot.dk-dang-xem .dk-cot-soan {
    display: none;
  }

  .man-dk .dk-chips {
    flex-wrap: nowrap;
  }

  /* QT-63 / QT-64: vùng chạm 44px, ô nhập 16px */
  .man-dk .btn,
  .man-dk .chip,
  .man-dk [role="tab"],
  .man-dk button.link,
  .dk-hop .btn,
  .dk-hop .chip {
    min-height: 44px;
  }

  .man-dk input[type="text"],
  .man-dk input[type="search"],
  .man-dk textarea,
  .dk-hop input[type="text"],
  .dk-hop input[type="password"],
  .dk-hop input:not([type]),
  .dk-hop textarea {
    font-size: 16px;
    min-height: 44px;
  }

  .man-dk .hint,
  .dk-hop .hint {
    font-size: 12px;
  }

  /* QT-65: hàng nút 2 cột, [Đăng bản…] đứng riêng một hàng full ngang */
  .man-dk .dk-acts {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .man-dk .dk-acts .full {
    grid-column: 1 / -1;
  }

  /* QT-67: hộp = bottom-sheet (kể cả hộp đăng bản ba bước) */
  .modal-back.dk-back {
    place-items: end stretch;
    padding: 0;
  }

  .modal.dk-hop,
  .modal.dk-hop.dk-hop-rong,
  .modal.dk-hop.steps {
    max-width: none;
    max-height: 88%;
    border-radius: var(--radius-modal) var(--radius-modal) 0 0;
    border-bottom: 0;
  }

  .dk-hop .pop-x {
    width: 44px;
    height: 44px;
  }

  .dk-hop > header,
  .dk-hop .modal-body {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }

  .dk-hop .modal-foot {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-bottom: max(13px, env(safe-area-inset-bottom));
  }
}

/* Responsive mobile dưới 480px: bộ lọc và nút full width */
@media (max-width: 480px) {
  .filters input[type="search"],
  .filters .btn,
  .filters .seg,
  .filters .seg .btn {
    width: 100%;
    min-height: 44px;
  }
}

/* ---------------------------------------------------------------------------
   G62c — Màn Transcript theo domain: modal List, popup người dùng đang giữ,
   khối Lịch sử xoá (WA-11 1.4 mục 5). Dùng token WA-09, không mã màu mới.
   --------------------------------------------------------------------------- */
.toast.crit {
  background: var(--crit-soft);
  color: var(--crit);
  border-color: var(--crit);
}

.modal.wide {
  max-width: 960px;
}

.tx-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.tx-tools input[type="search"] {
  flex: 1 1 220px;
  max-width: 340px;
  min-width: 0;
}

.tx-tools > .btn:last-child {
  margin-left: auto;
}

.tx-rong {
  text-align: center;
  padding: 22px 8px;
}

.tx-ck {
  width: 44px;
  text-align: center;
  vertical-align: middle;
}

.tx-ten {
  overflow-wrap: anywhere;
}

/* Cột Ngày xem (popup người dùng): RỘNG hơn, ngày + "(đã ẩn)" trên MỘT dòng */
.tx-xem {
  white-space: nowrap;
  min-width: 150px;
}

.tx-email {
  overflow-wrap: anywhere;
}

/* G62g — hộp Xoá: Chặn lưu lại (radio), số lượng, hộp xem trước thông báo */
.tx-chon {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tx-chon-nhan {
  font-weight: 600;
}

.tx-soluong {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.tx-xemtruoc ul {
  margin: 0;
  padding-left: 18px;
  overflow-wrap: anywhere;
}

@media (max-width: 860px) {
  .modal.wide {
    max-width: none;
  }

  .tx-tools > * {
    min-width: 0;
  }

  .tx-tools input[type="search"],
  .tx-tools select {
    flex: 1 1 100%;
    max-width: none;
    width: 100%;
    font-size: 16px;
    min-height: 44px;
  }

  .tx-tools > .btn:last-child {
    margin-left: 0;
  }

  .tbl-wrap table:not(.perm-matrix) td.tx-ck {
    text-align: left;
  }

  .tbl-wrap table:not(.perm-matrix) td.tx-xem {
    white-space: nowrap;
    min-width: 0;
  }

  .tx-chon .row {
    min-height: 44px;
  }

  .modal select,
  .modal input[type="text"] {
    font-size: 16px;
  }
}
