/* Hallmark · genre: modern-minimal · macrostructure: Workbench (app shell) · theme: Cobalt · enrichment: none · design-system: design.md · designed-as-app */
/* Hallmark · pre-emit critique: P4 H5 E4 S4 R5 V4 */
:root {
  /* ==== Cobalt — bảng điều khiển lạnh (xem design.md) ==== */
  --brand: oklch(51% 0.21 259);      /* cobalt điện — màu nhấn DUY NHẤT */
  --brand-d: oklch(44% 0.19 259);    /* cobalt đậm (hover) */
  --brand-l: oklch(94.5% 0.03 255);  /* nền cobalt nhạt */
  --brand-bd: oklch(85% 0.06 255);   /* viền cobalt nhạt */
  --ok: oklch(56% 0.13 160);         /* xanh lãi */
  --ok-l: oklch(95.5% 0.025 160);
  --bad: oklch(55% 0.19 27);         /* đỏ lỗ */
  --bad-l: oklch(96% 0.02 27);
  --warn: oklch(60% 0.12 75);        /* hổ phách cảnh báo */
  --warn-l: oklch(96.5% 0.03 90);
  --bg: oklch(97.8% 0.004 250);      /* nền trang — trắng ngà lạnh */
  --card: oklch(99.5% 0.002 250);    /* bề mặt */
  --card-2: oklch(97.2% 0.005 250);  /* nền dòng nhóm / phụ */
  --zebra: oklch(98.4% 0.003 250);   /* sọc xen kẽ rất nhạt */
  --line: oklch(92.5% 0.006 250);    /* kẻ chỉ mảnh */
  --line2: oklch(88% 0.01 250);      /* kẻ chỉ đậm hơn / viền input */
  --text: oklch(24% 0.02 258);       /* than lạnh */
  --body: oklch(40% 0.02 257);
  --muted: oklch(56% 0.015 255);
  --side-bg: oklch(21% 0.018 260);   /* sidebar graphite — nhịp tối duy nhất */
  --side-color: oklch(72% 0.015 255);
  --side-active: #ffffff;
  --header: var(--card);
  --active-bg: oklch(95.5% 0.007 252);
  --radius: 6px;                     /* nút / input — "kẻ bằng thước" */
  --radius-lg: 10px;                 /* thẻ / hộp */
  --shadow: 0 1px 2px oklch(24% 0.02 258 / 0.05);
  --font-display: "Space Grotesk", "Inter", -apple-system, "Segoe UI", sans-serif;
  --font-body: "Inter", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: var(--font-body);
  font-size: 13px; color: var(--body); background: var(--bg); height: 100%;
}
body { height: 100vh; overflow: hidden; }
.hidden { display: none !important; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--brand); cursor: pointer; }

/* Focus ring cobalt — hiện tức thì, không animate */
:where(button, a, select, [tabindex]):focus-visible {
  outline: 2px solid var(--brand); outline-offset: 1px;
}

/* Số liệu = JetBrains Mono thẳng cột (kể cả ô căn phải do JS bơm) */
.num, .num-full, .num-short, .pct, .cell-id, tfoot .foot-num,
td[style*="text-align:right"] {
  font-family: var(--font-mono); font-size: 0.96em; letter-spacing: -0.01em;
}
td[style*="text-align:right"] .num-full, td[style*="text-align:right"] .num-short,
td[style*="text-align:right"] .pct { font-size: 1em; }

/* ===== Khung app ===== */
.app { display: flex; height: 100vh; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.view { display: none; flex-direction: column; flex: 1; min-height: 0; }
.view.active { display: flex; }

/* ===== Sidebar graphite ===== */
.sidebar { display: flex; flex-shrink: 0; height: 100vh; background: var(--side-bg); }
.side-rail {
  width: 44px; display: flex; flex-direction: column; align-items: center; gap: 16px;
  padding: 16px 0; color: oklch(100% 0 0 / .5);
  border-right: 1px solid oklch(100% 0 0 / .06);
}
.rail-ico { font-size: 17px; cursor: default; line-height: 1; }
.rail-top { color: var(--brand); }
.rail-spacer { flex: 1; }
.side-menu { width: 210px; background: var(--side-bg); display: flex; flex-direction: column; padding: 14px 12px; overflow-y: auto; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.side-brand-txt { display: flex; flex-direction: column; line-height: 1.2; }
.side-brand-txt b { font-size: 15px; color: #fff; font-weight: 600; font-family: var(--font-display); letter-spacing: -0.01em; }
.side-brand-txt span { font-size: 10px; color: var(--side-color); font-family: var(--font-mono); letter-spacing: .05em; }
.side-menu-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: .09em;
  font-family: var(--font-mono); color: oklch(88% 0.01 255); opacity: .5; padding: 10px 8px 6px;
}
.side-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left; border: none; background: transparent;
  padding: 11px 12px; border-radius: var(--radius); cursor: pointer;
  font-size: 13.5px; color: var(--side-color); margin-bottom: 2px;
  border-left: 3px solid transparent;
  text-decoration: none;   /* bỏ gạch chân cho mục dạng <a> (Cảnh báo / Nguồn) */
  font-family: inherit; box-sizing: border-box;
}
/* Link <a> mặc định có màu/đổi màu khi đã ghé thăm -> ép giữ đúng màu sidebar */
a.side-item, a.side-item:visited { color: var(--side-color); }
.side-item:hover, a.side-item:hover { color: #fff; background: oklch(100% 0 0 / .05); text-decoration: none; }
.side-item.active { color: #fff; background: oklch(100% 0 0 / .07); border-left-color: var(--brand); font-weight: 600; }
.side-item.active .si-ico { color: oklch(68% 0.17 259); }
.si-ico { font-size: 16px; display: inline-flex; align-items: center; justify-content: center; width: 18px; flex-shrink: 0; }
.si-ico svg { width: 18px; height: 18px; stroke-width: 2; }
.badge-new { margin-left: auto; background: var(--brand); color: #fff; font-size: 10px; font-weight: 700; padding: 1px 7px; border-radius: 4px; font-family: var(--font-mono); }
.side-foot { margin-top: auto; padding: 12px 8px 2px; border-top: 1px solid oklch(100% 0 0 / .08); }
.side-foot .login-status { font-size: 11px; color: var(--side-color); }
.side-foot .login-status.in { color: oklch(72% 0.13 160); font-weight: 600; }
.side-foot .login-status.out { color: oklch(72% 0.14 27); font-weight: 600; }

/* ===== Thu gon sidebar (desktop) — chi con icon, tang dien tich lam viec ===== */
.side-mini-btn {
  margin-left: auto; background: none; border: 1px solid oklch(100% 0 0 / .14);
  color: var(--side-color); border-radius: 6px; width: 24px; height: 24px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; padding: 0;
}
.side-mini-btn:hover { color: #fff; border-color: oklch(100% 0 0 / .35); }
.side-mini-btn svg { width: 14px; height: 14px; }
@media (min-width: 821px) {
  body.side-mini .side-rail { display: none; }
  body.side-mini .side-menu { width: 60px; padding: 14px 9px; }
  body.side-mini .side-brand { padding: 4px 0 14px; justify-content: center; }
  body.side-mini .side-brand-txt, body.side-mini .side-menu-label,
  body.side-mini .si-txt, body.side-mini .badge-new, body.side-mini .login-status { display: none; }
  body.side-mini .side-mini-btn { margin: 0; }
  body.side-mini .side-mini-btn svg { transform: rotate(180deg); } /* chevrons-left quay nguoc = huong mo ra */
  body.side-mini .side-item { justify-content: center; padding: 11px 0; gap: 0; }
  body.side-mini .side-foot { display: flex !important; justify-content: center; padding: 12px 0 2px; }
}

/* ===== Header / toolbar ===== */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px; background: var(--header);
  border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page-title { margin: 0; font-size: 15.5px; font-weight: 600; color: var(--text); font-family: var(--font-display); letter-spacing: -0.01em; }
.topbar .spacer { flex: 1; }
/* Tầng lọc (dưới topbar): tìm kiếm + các bộ lọc */
.filterbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 18px; background: var(--header); border-bottom: 1px solid var(--line);
}
/* Nút chỉ-icon (gọn cho cột Thao tác) */
.btn-ico { padding: 6px 8px; }
.btn-ico svg { margin-right: 0 !important; }
.login-status { font-size: 12px; color: var(--muted); }
.login-status.in { color: var(--ok); font-weight: 600; }
.login-status.out { color: var(--bad); font-weight: 600; }

.search {
  border: 1px solid var(--line2); border-radius: var(--radius); padding: 7px 12px; width: 220px;
  outline: none; font-size: 13px; color: var(--text); background: var(--card); font-family: inherit;
}
.search:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-l); }

/* Bộ tìm kiếm đã lưu (chip viền) */
.saved-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 18px 0; }
.saved-label { font-size: 11px; color: var(--muted); font-weight: 600; }
.chip { display: inline-flex; align-items: center; gap: 2px; background: var(--brand-l); color: var(--brand-d); border: 1px solid var(--brand-bd); border-radius: 5px; padding: 3px 4px 3px 10px; font-size: 12px; }
.chip-text { cursor: pointer; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-text:hover { text-decoration: underline; }
.chip-x { border: none; background: transparent; color: var(--brand-d); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 5px; border-radius: 4px; }
.chip-x:hover { background: oklch(51% 0.21 259 / .15); }
.ctl {
  border: 1px solid var(--line2); border-radius: var(--radius); padding: 7px 10px; background: var(--card);
  outline: none; font-size: 13px; color: var(--body); cursor: pointer; font-family: inherit;
}
.ctl:focus { border-color: var(--brand); }

.btn {
  position: relative; border: 1px solid var(--line2); background: var(--card); border-radius: var(--radius);
  padding: 7px 14px; cursor: pointer; font-size: 13px; color: var(--body); font-weight: 500;
  font-family: inherit;
  transition: background-color .15s ease-out, border-color .15s ease-out, color .15s ease-out;
}
.btn:hover { background: var(--active-bg); color: var(--text); }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); box-shadow: 0 1px 2px oklch(51% 0.21 259 / .3); }
.btn-primary:hover { background: var(--brand-d); border-color: var(--brand-d); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--active-bg); }
/* Biến thể nút màu (Chặn/Xóa = đỏ, Bỏ chặn = xanh) — viền nhạt, hover tô đậm */
.btn-danger { color: var(--bad); border-color: oklch(80% 0.08 27); }
.btn-danger:hover { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn-success { color: var(--ok); border-color: oklch(80% 0.08 160); }
.btn-success:hover { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:disabled:hover { background: var(--card); color: var(--body); }
/* Icon feather trong nút: căn giữa với chữ */
.btn svg { width: 15px; height: 15px; vertical-align: -3px; margin-right: 5px; stroke-width: 2; }
.btn svg:last-child { margin-right: 0; }
.btn.has-dot::after {
  content: ""; position: absolute; top: -3px; right: -3px;
  width: 9px; height: 9px; background: var(--bad); border: 2px solid var(--card); border-radius: 50%;
}

/* ===== Hộp nội dung (bề mặt hairline) ===== */
.token-box { background: var(--card); margin: 12px 18px 0; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.token-box > label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.token-row { display: flex; gap: 8px; align-items: center; }
.token-row input { flex: 1; border: 1px solid var(--line2); border-radius: var(--radius); padding: 7px 12px; outline: none; font-family: var(--font-mono); background: var(--card); color: var(--text); }
.token-row input:focus { border-color: var(--brand); }

/* ===== Banner ===== */
.banner { margin: 12px 18px 0; padding: 12px 16px; font-size: 13px; border-radius: var(--radius-lg); }
.banner.error { background: var(--bad-l); color: var(--bad); border: 1px solid oklch(85% 0.07 27); }
.banner.info { background: var(--brand-l); color: var(--brand-d); border: 1px solid var(--brand-bd); }
.banner svg { width: 14px; height: 14px; vertical-align: -2px; margin-right: 5px; }
/* Icon nhỏ trong tiêu đề mục / ghi chú / ô cảnh báo trong bảng */
.sec-head h5 svg, .muted-note svg, .warn-sku svg, .tr-unassigned svg.ico-warn { width: 14px; height: 14px; vertical-align: -2px; margin-right: 3px; }

/* ===== Tabs (TK Cá nhân / BM / Page) ===== */
.tabs { display: flex; gap: 6px; padding: 14px 18px 0; }
.tab {
  border: 1px solid transparent; background: transparent; padding: 8px 15px; cursor: pointer;
  border-radius: var(--radius); font-size: 13px; color: var(--body); font-weight: 500; font-family: inherit;
}
.tab:hover { background: var(--active-bg); }
.tab.active { background: var(--brand); color: #fff; font-weight: 600; border-color: var(--brand); }

/* ===== Vùng bảng ===== */
main { flex: 1; overflow: hidden; padding: 14px 18px 18px; }
.panel { display: none; height: 100%; }
.panel.active { display: block; height: 100%; }
.table-wrap {
  overflow: auto; height: 100%; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
table { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; }

thead th {
  position: sticky; top: 0; background: var(--card); z-index: 3;
  text-align: left; padding: 11px 14px; font-weight: 600; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: .06em;
  white-space: nowrap; color: var(--muted); border-bottom: 1px solid var(--line2);
}
.th-sort { cursor: grab; user-select: none; }
.th-sort:active { cursor: grabbing; }
.th-sort:hover { background: var(--active-bg); color: var(--text); }
.th-sort.th-dragging { opacity: 0.4; }
.th-sort.th-drop { background: var(--brand-l); box-shadow: inset 0 -3px 0 var(--brand); }
.sort-arrow { color: var(--brand); font-size: 11px; }

tbody td { padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; color: var(--body); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:nth-child(even) { background: var(--zebra); } /* sọc xen kẽ (zebra) — luôn đều dù lọc hay không */
tbody tr:hover { background: var(--active-bg); }
tbody tr.row-sel { background: var(--brand-l) !important; }
/* Cảnh báo: viền màu bên trái thay vì tô cả dòng (gọn, không phá sọc) */
tbody tr.row-warn td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
tbody tr.row-bad td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
.col-check { width: 40px; text-align: center; padding-left: 8px; padding-right: 8px; }

.cell-name { font-weight: 600; color: var(--text); }
.cell-id { color: var(--muted); font-size: 11px; }

/* Cột dính bên phải (Thao tác / ô nhập giá) — không bị trôi mất khi cuộn ngang */
th.stick-r, td.stick-r { position: sticky; right: 0; z-index: 2; background: var(--card); box-shadow: -8px 0 8px -8px oklch(24% 0.02 258 / 0.16); }
thead th.stick-r { z-index: 4; background: var(--card); }
tbody tr:nth-child(even) td.stick-r { background: var(--zebra); }
tbody tr:hover td.stick-r { background: var(--active-bg); }

/* Ô tên dài: tự rút gọn "..." (rê chuột xem đủ qua title); co theo bề rộng màn hình */
td.ellip { max-width: min(420px, 34vw); overflow: hidden; text-overflow: ellipsis; }

.cur-pill { display: inline-block; padding: 2px 8px; border-radius: 4px; background: var(--brand-l); color: var(--brand-d); border: 1px solid var(--brand-bd); font-size: 10.5px; font-weight: 600; font-family: var(--font-mono); }

/* Badge = chip viền + chấm màu (instrument style) */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2.5px 9px; border-radius: 5px; font-size: 11.5px; font-weight: 600; border: 1px solid; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; }
.badge.ok { color: var(--ok); background: var(--ok-l); border-color: oklch(82% 0.08 160); }
.badge.bad { color: var(--bad); background: var(--bad-l); border-color: oklch(84% 0.08 27); }
.badge.warn { color: var(--warn); background: var(--warn-l); border-color: oklch(84% 0.07 85); }

.note-input { border: 1px solid transparent; border-radius: var(--radius); padding: 5px 8px; width: 130px; background: transparent; font-size: 13px; font-family: inherit; color: var(--body); }
.note-input:hover { border-color: var(--line2); }
.note-input:focus { border-color: var(--brand); background: var(--card); outline: none; }

/* ===== Footer tổng (dính đáy) ===== */
tfoot .foot-row td {
  position: sticky; bottom: 0; background: var(--card-2); border-top: 2px solid var(--line2);
  padding: 12px 14px; font-weight: 700; white-space: nowrap; z-index: 2; color: var(--text);
}
tfoot .foot-num { color: var(--text); }
tfoot .foot-label { color: var(--text); }
tfoot .foot-logo { text-align: center; }
tfoot .foot-logo img { vertical-align: middle; border-radius: 4px; }

/* ===== Quản lý cột ===== */
.col-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 16px; max-height: 320px; overflow: auto; }
.col-mgr-title { margin-bottom: 8px; color: var(--muted); }
.col-item { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; border: 1px solid var(--line2); border-radius: var(--radius); background: var(--card); }
.col-item label { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; }

.empty { padding: 32px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.tick { color: var(--ok); font-weight: 700; }

/* ===== Popup "Tải tài khoản" (dropdown) ===== */
.load-wrap { position: relative; display: inline-block; }
.load-pop {
  position: absolute; top: calc(100% + 8px); left: 0; width: 360px; max-width: 90vw;
  background: var(--card); border: 1px solid var(--line2); border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px oklch(24% 0.02 258 / 0.12); padding: 14px; z-index: 60;
  display: flex; flex-direction: column; gap: 8px;
}
.load-opt {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 13px 16px; border: 1px solid var(--line2); border-radius: var(--radius-lg); cursor: pointer;
  font-size: 14px; color: var(--text); margin: 0;
}
.load-opt:hover { background: var(--active-bg); }
.load-opt:has(input:checked) { border-color: var(--brand); background: var(--brand-l); font-weight: 600; color: var(--brand-d); }
.load-opt input[type="radio"] { width: 18px; height: 18px; flex-shrink: 0; }
.load-ids {
  width: 100%; min-height: 150px; border: 1px solid var(--line2); border-radius: var(--radius-lg);
  padding: 10px 12px; outline: none; font-family: var(--font-mono); font-size: 12.5px; resize: vertical; line-height: 1.7;
  background: var(--card); color: var(--text);
}
.load-ids:focus { border-color: var(--brand); }
.btn-load-now {
  width: 100%; border: none; border-radius: var(--radius); padding: 13px; margin-top: 2px;
  font-size: 15px; font-weight: 600; color: #fff; cursor: pointer; font-family: inherit;
  background: var(--brand);
  box-shadow: 0 1px 2px oklch(51% 0.21 259 / .3);
}
.btn-load-now:hover { background: var(--brand-d); }
.load-remember { display: flex; align-items: center; gap: 8px; margin: 2px 0 0; font-size: 13px; color: var(--text); cursor: pointer; }

/* ===== Footer chú thích ===== */
.legend { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; padding: 8px 18px; background: var(--card); border-top: 1px solid var(--line); font-size: 11px; color: var(--muted); }
.legend-note { flex: 1; }

/* ===== Trình quản lý (Ads Manager) — tab kiểu pill giống tab Ads Check ===== */
.mgr-tabs { display: flex; gap: 6px; padding: 14px 18px 0; flex-wrap: wrap; }
.mgr-tab {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid transparent; background: transparent; padding: 8px 15px;
  border-radius: var(--radius); cursor: pointer;
  font-size: 13px; font-weight: 500; color: var(--body); font-family: inherit;
}
.mgr-tab:hover { background: var(--active-bg); }
.mgr-tab.active { color: #fff; background: var(--brand); font-weight: 600; border-color: var(--brand); }
.mgr-tab svg { width: 15px; height: 15px; stroke-width: 2; }
.mgr-selbadge { background: oklch(100% 0 0 / .25); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 4px; font-family: var(--font-mono); }
.mgr-bar { display: flex; align-items: center; gap: 10px; padding: 12px 18px; }
.mgr-hint { flex: 1; font-size: 12px; color: var(--muted); }
.mgr-main { flex: 1; overflow: hidden; padding: 0 18px 18px; }
.mgr-kw-row { cursor: pointer; }
.mgr-kw-row:hover { background: var(--brand-l); }

/* ===== Overlay ===== */
.overlay { position: fixed; inset: 0; background: oklch(97.8% 0.004 250 / 0.82); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; z-index: 50; }
.spinner { width: 40px; height: 40px; border: 4px solid var(--brand-l); border-top-color: var(--brand); border-radius: 50%; animation: spin 0.8s linear infinite; }

/* ===== Pill tiến trình nổi (góc dưới phải) — báo trạng thái mà KHÔNG chen vào bố cục ===== */
.progress-pill {
  position: fixed; right: 18px; bottom: 18px; z-index: 80;
  display: flex; align-items: center; gap: 9px; max-width: min(86vw, 420px);
  background: var(--card); border: 1px solid var(--line2); border-radius: var(--radius-lg); padding: 9px 16px;
  box-shadow: 0 8px 24px oklch(24% 0.02 258 / 0.14);
  font-size: 12.5px; font-weight: 600; color: var(--text);
}
.progress-pill .spinner-sm { width: 15px; height: 15px; border-width: 3px; flex-shrink: 0; }
.progress-pill.ok { color: var(--ok); }
.progress-pill.err { color: var(--bad); }
.progress-pill.ok .spinner-sm, .progress-pill.err .spinner-sm { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
#overlayText { font-weight: 600; color: var(--brand-d); }

/* ===== Thẻ (mobile) — chỉ hiện trên màn hẹp; desktop dùng bảng ===== */
.cards-wrap { display: none; height: 100%; overflow: auto; padding: 2px; }
.cards-wrap > * + * { margin-top: 12px; }
.acc-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 12px 14px; font-size: 13px; line-height: 1.5; box-shadow: var(--shadow);
}
.acc-card .head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.acc-card .nm { font-weight: 600; font-size: 14px; color: var(--text); word-break: break-word; }
.acc-card .id { color: var(--muted); font-size: 11.5px; font-family: var(--font-mono); word-break: break-all; }
.acc-card .kv { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.acc-card .kv:last-child { border-bottom: 0; }
.acc-card .kv .k { color: var(--muted); flex: 0 0 auto; }
.acc-card .kv .v { flex: 1 1 auto; min-width: 0; font-weight: 500; text-align: right; word-break: break-word; overflow-wrap: anywhere; color: var(--text); }
.acc-card .empty { padding: 24px; text-align: center; color: var(--muted); }
.acc-badge { display: inline-block; padding: 2.5px 9px; border-radius: 5px; font-size: 11.5px; font-weight: 700; white-space: nowrap; color: #fff; background: var(--body); }
.acc-badge.ok { background: var(--ok); }
.acc-badge.bad { background: var(--bad); }
.acc-badge.warn { background: var(--warn); }

/* ===== Vung cuon cua cac view gop (SPA): noi dung dai tu cuon trong view ===== */
.vscroll { flex: 1; min-height: 0; overflow-y: auto; padding-bottom: 16px; }

/* ===== Mobile: thanh tren cung + drawer (nut ☰ mo menu truot tu trai) ===== */
.mobile-bar { display: none; }
.drawer-backdrop { display: none; }

/* ===== Tự co thành thẻ trên điện thoại ===== */
@media (max-width: 820px) {
  body { overflow: auto; }
  /* Thanh tren cung co dinh: nut ☰ + ten muc dang xem */
  .mobile-bar {
    display: flex; position: fixed; top: 0; left: 0; right: 0; height: 46px; z-index: 50;
    background: var(--side-bg); color: #fff; align-items: center; gap: 10px; padding: 0 12px;
    box-shadow: 0 1px 8px oklch(0% 0 0 / .18);
  }
  .mobile-bar .mb-btn {
    background: none; border: none; color: #fff; font-size: 21px; cursor: pointer;
    padding: 6px 8px; line-height: 1; border-radius: var(--radius);
  }
  .mobile-bar .mb-title { font-size: 14.5px; font-weight: 600; font-family: var(--font-display); }
  .app { flex-direction: column; height: auto; min-height: 100vh; padding-top: 46px; }
  /* Sidebar = drawer truot tu canh trai, mac dinh giau */
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 248px; height: 100vh; z-index: 70;
    flex-direction: column; transform: translateX(-105%); transition: transform .22s ease;
  }
  body.drawer-open .sidebar { transform: none; box-shadow: 0 0 34px oklch(0% 0 0 / .4); }
  .side-rail { display: none; }
  .side-menu { width: 100%; height: 100%; }
  /* Nen mo phia sau drawer — bam vao la dong */
  body.drawer-open .drawer-backdrop { display: block; position: fixed; inset: 0; background: oklch(20% 0.015 258 / .45); z-index: 65; }
  .main { height: auto; overflow: visible; }
  .view { min-height: 0; }
  .vscroll { overflow: visible; }
  .topbar { padding: 10px 12px; }
  .actions { width: 100%; }
  .search { width: 100%; }
  .filterbar { padding: 10px 12px; }
  .filterbar .search { flex: 1 1 150px; width: auto; }
  main { overflow: visible; padding: 12px; height: auto; }
  .panel.active { height: auto; }
  .mgr-main { overflow: visible; padding: 0 12px 16px; height: auto; }
  /* Ẩn bảng, hiện thẻ */
  .table-wrap { display: none !important; }
  .cards-wrap { display: block; height: auto; }
  .mgr-tabs { flex-wrap: wrap; }
  .mgr-tab { flex: 1 1 40%; }
}

/* Giảm chuyển động theo yêu cầu hệ điều hành */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation-duration: 0.01ms !important; }
  .spinner, .spinner-sm { animation: spin 1.5s linear infinite !important; }
}

/* Overlay loading phai phu len ca mobile-bar/drawer (z-index cao hon 50/65/70) */
.overlay { z-index: 90; }
