/* ============ Màu & kích thước ============ */
:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f6f7fb;
  --surface-3: #eef0f6;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --line: #e4e7ef;
  --line-strong: #d3d8e4;
  --brand: #5b4ff5;
  --brand-2: #8b5cf6;
  --brand-ink: #4338ca;
  --brand-soft: rgba(91, 79, 245, 0.1);
  --ok: #16a34a;
  --ok-soft: rgba(22, 163, 74, 0.12);
  --warn: #c2700a;
  --warn-soft: rgba(217, 119, 6, 0.14);
  --err: #dc2626;
  --err-soft: rgba(220, 38, 38, 0.1);
  --sidebar: #ffffff;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 10px 30px -12px rgba(16, 24, 40, 0.2);
  --radius: 14px;
  --nav-w: 248px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0d12;
    --surface: #13161d;
    --surface-2: #1a1e27;
    --surface-3: #222734;
    --text: #e8ebf2;
    --text-2: #c3c9d6;
    --muted: #8f98aa;
    --line: #252a36;
    --line-strong: #323847;
    --brand: #8f87ff;
    --brand-2: #b18cff;
    --brand-ink: #b9b4ff;
    --brand-soft: rgba(143, 135, 255, 0.15);
    --ok: #3ccf6e;
    --ok-soft: rgba(60, 207, 110, 0.14);
    --warn: #ffb547;
    --warn-soft: rgba(255, 181, 71, 0.14);
    --err: #ff6b6b;
    --err-soft: rgba(255, 107, 107, 0.13);
    --sidebar: #0f1218;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 12px 34px -12px rgba(0, 0, 0, 0.75);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0d12;
  --surface: #13161d;
  --surface-2: #1a1e27;
  --surface-3: #222734;
  --text: #e8ebf2;
  --text-2: #c3c9d6;
  --muted: #8f98aa;
  --line: #252a36;
  --line-strong: #323847;
  --brand: #8f87ff;
  --brand-2: #b18cff;
  --brand-ink: #b9b4ff;
  --brand-soft: rgba(143, 135, 255, 0.15);
  --ok: #3ccf6e;
  --ok-soft: rgba(60, 207, 110, 0.14);
  --warn: #ffb547;
  --warn-soft: rgba(255, 181, 71, 0.14);
  --err: #ff6b6b;
  --err-soft: rgba(255, 107, 107, 0.13);
  --sidebar: #0f1218;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 12px 34px -12px rgba(0, 0, 0, 0.75);
  color-scheme: dark;
}

/* ============ Nền tảng ============ */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.5 "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; letter-spacing: -0.015em; }
a { color: var(--brand); }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "Cascadia Code", "JetBrains Mono", Consolas, monospace; }
.error { color: var(--err); margin: 0; }
[hidden] { display: none !important; }
svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
kbd { padding: 1px 6px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 6px; background: var(--surface); color: var(--muted); font: 600 10.5px/1.5 inherit; white-space: nowrap; }
::selection { background: var(--brand-soft); }

input, select, textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
input:hover:not(:disabled), select:hover:not(:disabled), textarea:hover:not(:disabled) { border-color: var(--line-strong); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--muted); }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--brand); }
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); }
label > input, label > select, label > textarea { margin-top: 5px; color: var(--text); font-weight: 400; font-size: 14px; }
label.inline { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ============ Nút ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s, box-shadow 0.15s;
}
.btn:hover { border-color: var(--line-strong); background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn.primary { background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 88%, #fff), var(--brand)); border-color: var(--brand); color: #fff; box-shadow: 0 6px 16px -8px var(--brand); }
.btn.primary:hover { filter: brightness(1.06); color: #fff; }
.btn.danger { color: var(--err); }
.btn.danger:hover { border-color: var(--err); background: var(--err-soft); }
.btn.ghost { background: none; box-shadow: none; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-3); }
.btn.small { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.block { width: 100%; padding: 10px 14px; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 9px; background: none; color: var(--muted); cursor: pointer; transition: background 0.15s, color 0.15s; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-del { color: var(--muted); }
.icon-del:hover { color: var(--err); background: var(--err-soft); }

/* ============ Đăng nhập ============ */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
  background:
    radial-gradient(900px 500px at 15% -10%, color-mix(in srgb, var(--brand) 22%, transparent), transparent 60%),
    radial-gradient(700px 500px at 110% 110%, color-mix(in srgb, var(--brand-2) 18%, transparent), transparent 60%),
    var(--bg);
}
.login-card { width: min(400px, 100%); display: grid; gap: 14px; padding: 32px 28px; border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); border: 1px solid var(--line); }
.login-card h1 { font-size: 22px; }
.login-card p { margin: -6px 0 4px; }

.brand-mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; box-shadow: 0 8px 18px -8px var(--brand); flex: none; }
.brand-mark svg { width: 19px; height: 19px; stroke-width: 2; }
.brand-mark.big { width: 48px; height: 48px; border-radius: 14px; }
.brand-mark.big svg { width: 26px; height: 26px; }

/* ============ Khung ============ */
.app { display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns 0.2s ease; }
.content { min-width: 0; display: flex; flex-direction: column; }
main { padding: 26px 32px 90px; min-width: 0; max-width: 1480px; width: 100%; }
.topbar { display: none; }

.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 12px; padding: 16px 12px 12px; background: var(--sidebar); border-right: 1px solid var(--line); overflow: hidden; z-index: 30; }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 4px 2px 6px; min-height: 38px; }
.brand-text { flex: 1; min-width: 0; line-height: 1.25; }
.brand-text b { display: block; font-size: 15px; }
.brand-text small { display: block; color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.search-trigger { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; text-align: left; transition: border-color 0.15s, background 0.15s; }
.search-trigger:hover { border-color: var(--line-strong); color: var(--text-2); }
.search-trigger .label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-trigger svg { width: 16px; height: 16px; }

nav { display: grid; gap: 14px; flex: 1; align-content: start; overflow-y: auto; overflow-x: hidden; margin: 0 -4px; padding: 2px 4px; scrollbar-width: thin; }
.nav-group { display: grid; gap: 1px; }
.nav-sep { padding: 0 10px 4px; color: var(--muted); font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; white-space: nowrap; }
nav a { position: relative; display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 10px; color: var(--text-2); text-decoration: none; font-weight: 500; white-space: nowrap; transition: background 0.15s, color 0.15s; }
nav a svg { color: var(--muted); transition: color 0.15s; }
nav a .label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
nav a:hover { background: var(--surface-3); color: var(--text); }
nav a:hover svg { color: var(--text); }
nav a.active { background: var(--brand-soft); color: var(--brand-ink); font-weight: 650; }
nav a.active svg { color: var(--brand); }
nav a.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand); }

.badge { min-width: 20px; padding: 0 6px; border-radius: 99px; background: var(--surface-3); color: var(--text-2); font-size: 11px; font-weight: 700; line-height: 19px; text-align: center; font-variant-numeric: tabular-nums; }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err); color: #fff; }
.badge.info { background: var(--brand); color: #fff; } /* không đặt tên .brand: trùng khung logo đầu menu */

.sidebar-foot { display: grid; gap: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.theme-seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 3px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }
.theme-seg button { display: grid; place-items: center; height: 28px; border: 0; border-radius: 7px; background: none; color: var(--muted); cursor: pointer; }
.theme-seg button svg { width: 16px; height: 16px; }
.theme-seg button:hover { color: var(--text); }
.theme-seg button.on { background: var(--surface); color: var(--brand); box-shadow: var(--shadow-sm); }
.me { display: flex; align-items: center; gap: 10px; padding: 2px 2px 2px 4px; }
.avatar { display: grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: 50%; background: linear-gradient(135deg, #f59e0b, #ec4899); color: #fff; font-weight: 700; font-size: 13px; text-transform: uppercase; }
.me-text { flex: 1; min-width: 0; line-height: 1.25; }
.me-text b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-text small { display: block; color: var(--muted); font-size: 11.5px; }

/* menu thu gọn (chỉ biểu tượng) — chỉ trên màn hình rộng */
@media (min-width: 901px) {
  .nav-collapsed { --nav-w: 68px; }
  .nav-collapsed .brand-text, .nav-collapsed .nav-sep, .nav-collapsed nav a .label, .nav-collapsed .search-trigger .label,
  .nav-collapsed .search-trigger kbd, .nav-collapsed .me-text, .nav-collapsed #logout, .nav-collapsed .theme-seg button:not(.on) { display: none; }
  .nav-collapsed .brand { flex-direction: column; padding: 0; gap: 8px; }
  .nav-collapsed .search-trigger { justify-content: center; padding: 8px 0; }
  .nav-collapsed nav { gap: 6px; }
  .nav-collapsed .nav-group + .nav-group { padding-top: 6px; border-top: 1px solid var(--line); }
  .nav-collapsed nav a { justify-content: center; padding: 9px 0; }
  .nav-collapsed nav a .badge { position: absolute; top: 2px; right: 4px; min-width: 16px; padding: 0 4px; font-size: 9.5px; line-height: 15px; }
  .nav-collapsed nav a .badge ~ .badge { top: auto; bottom: 2px; }
  .nav-collapsed .theme-seg { grid-template-columns: 1fr; }
  .nav-collapsed .me { justify-content: center; padding: 0; }
  .nav-collapsed #collapseNav svg { transform: scaleX(-1); }
}

/* ============ Đầu trang & thanh công cụ ============ */
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin-bottom: 18px; }
.page-head h2 { font-size: 22px; font-weight: 750; flex: 1; min-width: 180px; }
.page-head .sub { flex-basis: 100%; margin-top: -8px; color: var(--muted); font-size: 13px; }
.page-head select, .card .row > select { width: auto; min-width: 180px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.toolbar > * { width: auto; }
.toolbar input[type="search"] { min-width: 240px; flex: 1; }

/* thanh chọn sản phẩm + tab con */
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.product-tabs { margin: -4px 0 16px; }
.product-tabs button { display: inline-flex; align-items: center; gap: 8px; padding: 7px 13px 7px 11px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface); color: var(--text-2); font: inherit; font-weight: 600; font-size: 13px; cursor: pointer; box-shadow: var(--shadow-sm); transition: border-color 0.15s, background 0.15s, color 0.15s; }
.product-tabs button:hover { border-color: var(--line-strong); color: var(--text); }
.product-tabs button.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-ink); }
.product-tabs .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--dot, var(--brand)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--dot, var(--brand)) 22%, transparent); }
.product-tabs small { color: var(--muted); font-weight: 500; }
.subtabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.subtabs button { position: relative; flex: none; white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; border: 0; background: none; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; }
.subtabs button:hover { color: var(--text); }
.subtabs button.on { color: var(--brand-ink); }
.subtabs button.on::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--brand); }
.subtabs .badge { line-height: 18px; }
.subtabs .spacer { flex: 1; }
.subtabs > .btn { align-self: center; margin-bottom: 6px; }

/* ============ Thẻ & số liệu ============ */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow-sm); }
.card h3 { font-size: 15px; font-weight: 700; margin-bottom: 10px; }
.card > .row:first-child h3 { margin-bottom: 0; flex: 1; }
.card > .row:first-child { margin-bottom: 8px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.stat::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--line-strong); }
.stat b { display: block; font-size: 25px; font-weight: 750; line-height: 1.2; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 12.5px; }
.stat.ok b { color: var(--ok); }
.stat.ok::after { background: var(--ok); }
.stat.warn b { color: var(--warn); }
.stat.warn::after { background: var(--warn); }
.stat.err b { color: var(--err); }
.stat.err::after { background: var(--err); }
a.stat { color: inherit; text-decoration: none; transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s; }
a.stat:hover { border-color: var(--line-strong); transform: translateY(-2px); box-shadow: var(--shadow); }

/* ============ Bảng ============ */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card .table-wrap { box-shadow: none; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); color: var(--muted); font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.04em; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background 0.12s; }
tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--brand-soft); }
td.wrap { white-space: normal; }
td.note { max-width: 220px; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 650; white-space: nowrap; }
.chip.active::before, .chip.expiring::before, .chip.expired::before, .chip.suspended::before, .chip.pending::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.active { background: var(--ok-soft); color: var(--ok); }
.chip.pending { background: var(--brand-soft); color: var(--brand-ink); }
.chip.expiring { background: var(--warn-soft); color: var(--warn); }
.chip.expired, .chip.suspended { background: var(--err-soft); color: var(--err); }
.chip.neutral { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }

.copy { margin-left: 6px; padding: 1px 7px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--muted); font: inherit; font-size: 11px; cursor: pointer; }
.copy:hover { color: var(--brand); border-color: var(--brand); }

/* ============ Ma trận gói ============ */
.matrix-wrap { max-height: calc(100vh - 250px); overflow: auto; }
.matrix td, .matrix th { white-space: normal; }
.matrix th { z-index: 2; }
.matrix th:first-child, .matrix td.feature { position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: 1px 0 0 var(--line); }
.matrix th:first-child { z-index: 3; background: var(--surface-2); vertical-align: bottom; }
.matrix th.plan { min-width: 168px; padding: 12px; text-transform: none; letter-spacing: 0; color: var(--text); font-size: 13px; vertical-align: top; background: var(--surface-2); }
.plan-head { display: grid; gap: 6px; }
.plan-head input { padding: 6px 9px; }
.plan-head input.plan-name { font-weight: 700; }
.plan-head input.plan-code { font: 12px/1.4 ui-monospace, Consolas, monospace; color: var(--muted); }
.plan-head .row { justify-content: space-between; font-size: 12px; color: var(--muted); font-weight: 600; }
.matrix td.feature { min-width: 240px; max-width: 320px; font-weight: 500; }
.matrix td.feature small { display: block; color: var(--muted); font-family: ui-monospace, Consolas, monospace; font-size: 11px; font-weight: 400; }
.matrix tr.group td { position: static; background: var(--surface-2); font-weight: 700; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; padding-top: 9px; padding-bottom: 9px; }
.matrix tr.group td:first-child { position: sticky; left: 0; z-index: 1; }
.matrix td.cell { text-align: center; }
.matrix td.cell input[type="number"] { width: 100px; text-align: center; }
.matrix tr.meta td { background: color-mix(in srgb, var(--brand-soft) 35%, var(--surface)); }
.matrix tr.meta td.feature { background: color-mix(in srgb, var(--brand-soft) 35%, var(--surface)); }
.matrix tr.meta input { width: 120px; text-align: center; }
.matrix tbody tr:hover td { background: color-mix(in srgb, var(--brand-soft) 40%, var(--surface)); }
.hint { color: var(--muted); font-size: 12.5px; margin: 6px 0 12px; }

/* công tắc bật/tắt */
.switch { position: relative; display: inline-block; width: 38px; height: 22px; vertical-align: middle; cursor: pointer; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: inherit; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--line-strong); transition: background 0.18s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.18s; }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.switch input:disabled + span { opacity: 0.5; }
.switch:has(input:disabled) { cursor: default; }

.feat-table input, .feat-table select { min-width: 120px; }
.feat-table td { padding: 7px 10px; }
.feat-table td:nth-child(2) input { min-width: 260px; }
.feat-table td:first-child input { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.feat-table tr.group td { background: var(--surface-2); font-weight: 700; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; padding: 8px 14px; }

/* thanh lưu nổi */
.savebar { position: sticky; bottom: 16px; z-index: 15; display: flex; align-items: center; gap: 10px; width: fit-content; max-width: 100%; margin: 16px auto 0; padding: 10px 10px 10px 16px; border-radius: 14px; background: #111827; color: #fff; box-shadow: 0 18px 40px -14px rgba(0, 0, 0, 0.55); animation: pop-up 0.2s ease-out; }
.savebar .savebar-text { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13.5px; }
.savebar .savebar-text::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #fbbf24; box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.25); }
.savebar .btn.ghost { color: #d1d5db; }
.savebar .btn.ghost:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
@keyframes pop-up { from { transform: translateY(14px); opacity: 0; } }

pre.code {
  margin: 8px 0 0;
  padding: 14px 16px;
  border-radius: 12px;
  background: #0d1117;
  color: #c9d1d9;
  font: 12.5px/1.6 ui-monospace, "Cascadia Code", Consolas, monospace;
  overflow-x: auto;
  white-space: pre;
}

/* ============ Thành phần khác ============ */
.callout { margin-bottom: 14px; padding: 11px 14px; border-radius: 12px; background: var(--brand-soft); border: 1px solid color-mix(in srgb, var(--brand) 25%, transparent); font-size: 13.5px; }
.callout.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pay-box { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px dashed var(--line-strong); }
.small-input { width: 80px !important; }
.bulk-bar { position: sticky; top: 8px; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 10px; padding: 10px 14px; border-radius: 12px; background: var(--surface); border: 2px solid var(--brand); box-shadow: var(--shadow); }
.bulk-bar .row { gap: 6px; }
.bulk-bar select { width: auto; }
.tag { display: inline-block; margin: 0 4px 2px 0; padding: 1px 8px; border-radius: 99px; background: var(--brand-soft); color: var(--brand-ink); font-size: 11.5px; font-weight: 600; }
.tag-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: -4px 0 12px; }
.chip-btn { padding: 4px 11px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface); color: var(--text-2); font: inherit; font-size: 12.5px; cursor: pointer; }
.chip-btn:hover { border-color: var(--line-strong); }
.chip-btn.on { background: var(--brand); border-color: var(--brand); color: #fff; }
tr.refunded td { color: var(--muted); text-decoration: line-through; }
tr.refunded td:last-child { text-decoration: none; }
tr.lapsed td { background: color-mix(in srgb, var(--err-soft) 45%, transparent); }
.ok-text { color: var(--ok); }
.err-text { color: var(--err); }

/* biểu đồ cột doanh thu 12 tháng */
.bars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 8px; align-items: end; height: 210px; padding-top: 8px; }
.bar { display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; min-width: 0; }
.bar-track { flex: 1; width: 100%; max-width: 46px; display: flex; align-items: flex-end; border-radius: 8px 8px 3px 3px; background: var(--surface-2); }
.bar-fill { width: 100%; min-height: 2px; border-radius: 8px 8px 3px 3px; background: linear-gradient(180deg, var(--brand-2), var(--brand)); transition: height 0.4s ease-out; }
.bar-value { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; min-height: 15px; }
.bar-label { font-size: 11px; color: var(--muted); }

/* điều khiển từ xa */
.notice-list { display: grid; gap: 12px; }
.notice-edit { display: grid; gap: 10px; padding: 14px; border-radius: 12px; border: 1px solid var(--line); border-left: 4px solid var(--brand); background: var(--surface-2); }
.notice-edit.warn { border-left-color: var(--warn); }
.notice-edit.promo { border-left-color: #ec4899; }
.notice-edit .row { gap: 12px; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 14px; }
textarea.code-input { font: 12.5px/1.55 ui-monospace, "Cascadia Code", Consolas, monospace; }

/* mẫu tin nhắn */
.tpl-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; align-items: start; padding: 12px 0; border-top: 1px dashed var(--line); }
pre.preview { margin: 4px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); font: 13px/1.5 inherit; white-space: pre-wrap; }
ol.steps { margin: 0 0 10px; padding-left: 20px; display: grid; gap: 6px; }
code { padding: 0 5px; border-radius: 5px; background: var(--surface-3); font-size: 0.92em; }

/* ============ Ngăn chi tiết ============ */
.backdrop { position: fixed; inset: 0; background: rgba(10, 12, 18, 0.45); backdrop-filter: blur(2px); z-index: 40; }
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 41;
  width: min(580px, 100vw);
  overflow-y: auto;
  padding: 20px 22px 40px;
  background: var(--bg);
  border-left: 1px solid var(--line);
  box-shadow: -24px 0 50px -20px rgba(0, 0, 0, 0.4);
  animation: slide-in 0.25s ease-out;
}
@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.drawer-head h2 { flex: 1; font-size: 17px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 7px 12px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row > input, .row > select { width: auto; flex: 1; min-width: 120px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ============ Hộp thoại ============ */
dialog { width: min(540px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: 18px; padding: 0; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
dialog[open] { animation: pop-up 0.18s ease-out; }
dialog::backdrop { background: rgba(10, 12, 18, 0.5); backdrop-filter: blur(2px); }
dialog form { display: grid; gap: 12px; padding: 22px; }
dialog h3 { font-size: 17px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
textarea.keys { min-height: 140px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }

/* tìm nhanh */
dialog.palette { width: min(620px, calc(100vw - 24px)); margin-top: 12vh; padding: 0; overflow: hidden; }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); color: var(--muted); }
.palette-input input { border: 0; padding: 6px 0; background: none; font-size: 15px; box-shadow: none !important; }
.palette-list { max-height: 55vh; overflow-y: auto; padding: 6px; }
.palette-sec { padding: 8px 10px 4px; color: var(--muted); font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; }
.palette-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 10px; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.palette-item svg { color: var(--muted); }
.palette-item .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-item small { color: var(--muted); }
.palette-item .go { opacity: 0; }
.palette-item.sel { background: var(--brand-soft); color: var(--brand-ink); }
.palette-item.sel svg, .palette-item.sel .go { color: var(--brand); opacity: 1; }
.palette-empty { padding: 26px; text-align: center; color: var(--muted); }

/* ============ Toast ============ */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 60; display: grid; gap: 8px; }
.toast { padding: 11px 15px; border-radius: 12px; background: #111827; color: #fff; font-size: 13.5px; box-shadow: var(--shadow); animation: slide-in 0.25s ease-out; max-width: min(420px, calc(100vw - 36px)); }
.toast.err { background: #991b1b; }
.toast.ok { background: #166534; }

/* ============ Điện thoại / máy tính bảng ============ */
.side-backdrop { display: none; }
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 272px; height: 100%; transform: translateX(-102%); transition: transform 0.22s ease; box-shadow: var(--shadow); }
  .nav-open .sidebar { transform: none; }
  .nav-open .side-backdrop { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(10, 12, 18, 0.45); }
  .desk-only { display: none !important; }
  .topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
  .topbar b { flex: 1; font-size: 15px; }
  main { padding: 16px 16px 90px; }
  .page-head h2 { font-size: 19px; }
  .grid2, .grid3, .tpl-row { grid-template-columns: 1fr; }
  .bars { gap: 3px; }
  .toolbar input[type="search"] { min-width: 0; flex-basis: 100%; }
  .matrix-wrap { max-height: none; }
  .matrix td.feature, .matrix th:first-child { min-width: 128px; max-width: 150px; }
  .matrix th.plan { min-width: 150px; }
  .product-tabs { flex-wrap: nowrap; overflow-x: auto; margin: -4px -16px 14px; padding: 2px 16px 6px; scrollbar-width: none; }
  .product-tabs button { flex: none; }
  .search-trigger kbd { display: none; }
  .kv { grid-template-columns: 110px 1fr; }
}

/* ============ Phiên bản & báo lỗi giao diện (trang của FB Auto Poster) ============ */
.bars.days14 { grid-template-columns: repeat(14, 1fr); gap: 5px; }
.section-title { font-size: 16px; margin: 22px 0 10px; }
.label-list { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; max-height: 260px; overflow-y: auto; font-weight: 400; }
.label-list .tag { margin: 0; font-size: 12.5px; }
.promo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.promo-grid > .card { margin-bottom: 0; }
.promo-wrap { margin-bottom: 16px; }
tr.off td { color: var(--muted); }
.grow { flex: 1; }
.rn-list { display: grid; gap: 8px; margin-bottom: 14px; }
.rn-item { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.rn-item ul { margin: 6px 0 0; padding-left: 20px; display: grid; gap: 3px; font-size: 13px; }
.vbars { display: grid; gap: 8px; margin-bottom: 4px; }
.vbar { display: grid; grid-template-columns: 90px 1fr 130px 190px; gap: 10px; align-items: center; font-size: 13px; }
.vbar-label { font-weight: 700; }
.vbar-track { height: 18px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.vbar-fill { height: 100%; min-width: 2px; border-radius: 6px; background: var(--brand); transition: width 0.4s ease-out; }
.vbar.latest .vbar-fill, .vbar.newer .vbar-fill { background: var(--ok); }
.vbar.old .vbar-fill { background: var(--warn); }
.vbar.below-min .vbar-fill { background: var(--err); }
.vbar.unknown .vbar-fill { background: var(--muted); }
.vbar-value { color: var(--muted); font-variant-numeric: tabular-nums; }
.rollout-value { color: var(--text); font-size: 14px; }
input[type="range"] { padding: 0; border: 0; background: none; box-shadow: none; accent-color: var(--brand); }

/* ============ Góp ý ============ */
.fb-list { display: grid; gap: 10px; }
.fb-item { display: grid; gap: 8px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.fb-item.done { opacity: 0.72; }
.fb-item.new { border-left: 3px solid var(--brand); }
.fb-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; color: var(--muted); font-size: 12.5px; }
.fb-msg { margin: 0; white-space: pre-wrap; word-break: break-word; font-size: 14px; color: var(--text); }
.fb-note { display: flex; gap: 8px; align-items: center; }
.fb-note input { flex: 1; }
.chip.bug { background: var(--err-soft); color: var(--err); }
.chip.idea { background: var(--ok-soft); color: var(--ok); }
.chip.other { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }

@media (max-width: 900px) {
  .promo-grid { grid-template-columns: 1fr; }
  .bars.days14 { gap: 3px; }
  .vbar { grid-template-columns: 70px 1fr; }
  .vbar-value, .vbar > span:last-child { grid-column: 2; }
}

/* ============ Khu nhiều tab (menu gộp) ============ */
.sec-head h1 { font-size: 22px; font-weight: 750; margin-bottom: 10px; }
.sectabs { display: flex; gap: 2px; margin: 0 0 20px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.sectabs::-webkit-scrollbar { display: none; }
.sectabs a { display: inline-flex; align-items: center; gap: 7px; padding: 9px 12px; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--muted); font-size: 13.5px; font-weight: 600; text-decoration: none; white-space: nowrap; transition: color 0.15s, border-color 0.15s; }
.sectabs a:hover { color: var(--text); border-bottom-color: var(--line-strong); }
.sectabs a.on { color: var(--brand-ink); border-bottom-color: var(--brand); }
.sectabs .badge { line-height: 18px; }
/* Tiêu đề trang trùng tên tab → ẩn; hàng tiêu đề chỉ có tiêu đề thì ẩn luôn, còn ô lọc / nút / mô tả thì giữ. */
.tabbed .page-head > h2 { display: none; }
.tabbed .page-head:not(:has(> :not(h2))) { display: none; }
.tabbed .page-head .sub { margin-top: 0; }
/* Điện thoại: thanh trên cùng đã ghi tên khu. */
@media (max-width: 900px) { .sec-head { display: none; } }

/* ============ Đơn hàng / giao dịch ============ */
.chip-row { margin-bottom: 12px; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush .table-wrap { border: 0; border-radius: 0; }
td .hint { margin: 2px 0 0; font-size: 12px; }
.warn-text { color: var(--warn) !important; font-weight: 600; }
tr.row-pending td { background: color-mix(in srgb, var(--brand-soft) 60%, transparent); }
tr.row-review td { background: color-mix(in srgb, var(--warn-soft) 60%, transparent); }
td.actions { text-align: right; }
/* Menu "⋯": mở ra ngay trên hàng (không nổi lên) để không bị khung cuộn của bảng cắt mất. */
.more { display: inline-flex; align-items: center; gap: 6px; margin-left: 6px; vertical-align: middle; }
.more > summary { list-style: none; display: grid; place-items: center; width: 30px; height: 28px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); font-weight: 700; letter-spacing: 1px; cursor: pointer; user-select: none; }
.more > summary::-webkit-details-marker { display: none; }
.more > summary:hover, .more[open] > summary { border-color: var(--line-strong); color: var(--text); background: var(--surface-2); }
.more-menu { display: inline-flex; gap: 6px; }

/* ============ Khuyến mãi ============ */
.promo-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.promo-head h3 { margin-bottom: 2px; }
.promo-head small { color: var(--muted); font-size: 12px; }
.promo-card:not(.off) .promo-head small { color: var(--ok); font-weight: 600; }
.promo-card.off .grid2, .promo-card.off .grid3 { opacity: 0.55; transition: opacity 0.15s; }
.promo-card.off .grid2:focus-within, .promo-card.off .grid3:focus-within { opacity: 1; }

/* ============ Chi tiết đơn ============ */
.drawer-sec { margin-bottom: 18px; }
.drawer-sec h3 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 8px; }
.drawer-sec .kv { grid-template-columns: 120px 1fr; }
.drawer-sec .kv dd { overflow-wrap: anywhere; }
.drawer-sec .hint { margin: 6px 0 0; }
.note-wrap { color: var(--muted); font-size: 12px; line-height: 1.4; }
td .hint.anon { max-width: 300px; white-space: normal; font-style: italic; }
