/* ===== Biến dùng chung: mỗi giao diện (tối / sáng) tự đặt giá trị; phần còn lại chỉ dùng biến ===== */
:root {
  --sidebar-w: 236px;
  --rail-w: 60px;
  --topbar-h: 56px;
  --brand: #4f6ef7;
  --brand-dark: #3b55d9;
  --radius: 14px;
}
[data-bs-theme=dark] {
  color-scheme: dark;
  --app-bg: #060a13;
  --surface: #0c1220;        /* thẻ, bảng */
  --surface-2: #101829;      /* ô nhập, dòng đang trỏ */
  --surface-3: #162036;
  --line: #18213a;
  --ink: #eef2fb;
  --ink-2: #9aa6c0;
  --ink-3: #64708c;
  --topbar-bg: #080d19;
  --topbar-ink: #eef2fb;
  --good: #34d399; --bad: #f87171; --warn: #fbbf24; --info: #60a5fa;
  --bs-body-bg: var(--app-bg);
  --bs-body-color: #d5dcec;
  --bs-emphasis-color: #fff;
  --bs-secondary-color: #8b97b3;
  --bs-tertiary-color: #64708c;
  --bs-secondary-bg: #131c31;
  --bs-tertiary-bg: #101829;
  --bs-border-color: var(--line);
  --bs-border-color-translucent: rgba(140, 160, 210, .14);
  --bs-link-color: #7fb0ff; --bs-link-color-rgb: 127, 176, 255;
  --bs-link-hover-color: #a9c9ff; --bs-link-hover-color-rgb: 169, 201, 255;
  --bs-code-color: #f0a3c4;
  --bs-success-text-emphasis: #4ade80; --bs-danger-text-emphasis: #f98b8b; --bs-warning-text-emphasis: #fbbf24; --bs-info-text-emphasis: #7dd3fc;
  --bs-success-bg-subtle: #0c2a1c; --bs-danger-bg-subtle: #2c1218; --bs-warning-bg-subtle: #2b2208; --bs-info-bg-subtle: #0b2233; --bs-primary-bg-subtle: #101f44;
  --bs-success-border-subtle: #14532d; --bs-danger-border-subtle: #5b1d24; --bs-warning-border-subtle: #5c4508; --bs-info-border-subtle: #0e4a66; --bs-primary-border-subtle: #1d3a80;
}
[data-bs-theme=light] {
  color-scheme: light;
  --app-bg: #f1f3f9;
  --surface: #fff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f7;
  --line: #e5e9f2;
  --ink: #0f172a;
  --ink-2: #475569;
  --ink-3: #94a3b8;
  --topbar-bg: linear-gradient(90deg, #4f46e5, #4338ca);
  --topbar-ink: #fff;
  --good: #15803d; --bad: #b91c1c; --warn: #b45309; --info: #1d4ed8;
}
* { -webkit-tap-highlight-color: transparent; }
body { background: var(--app-bg); font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
[data-bs-theme=dark] .text-success { color: var(--good) !important; }
[data-bs-theme=dark] .text-danger { color: var(--bad) !important; }
[data-bs-theme=dark] .text-muted { color: var(--ink-2) !important; }
[data-bs-theme=dark] ::-webkit-scrollbar { width: 10px; height: 10px; }
[data-bs-theme=dark] ::-webkit-scrollbar-thumb { background: #1c2742; border-radius: 8px; border: 2px solid var(--app-bg); }
[data-bs-theme=dark] ::-webkit-scrollbar-track { background: transparent; }

/* ===== Thanh trên ===== */
.app-topbar { height: var(--topbar-h); background: var(--topbar-bg); color: var(--topbar-ink); border-bottom: 1px solid var(--line); padding-top: 0; padding-bottom: 0; }
.app-topbar .navbar-brand { color: var(--topbar-ink); font-size: 1.05rem; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #4f6ef7, #7c5cf5); color: #fff; font-size: 1.05rem; }
.top-btn { width: 36px; height: 36px; border-radius: 10px; border: 0; background: transparent; color: var(--topbar-ink); opacity: .78;
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.1rem; text-decoration: none; }
.top-btn:hover { opacity: 1; background: rgba(140, 160, 210, .16); color: var(--topbar-ink); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, #2563eb, #4f6ef7); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 600; }
[data-bs-theme=light] .avatar { background: rgba(255,255,255,.25); }
.top-slot { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.sync-state { font-size: .82rem; color: var(--ink-2); white-space: nowrap; }
[data-bs-theme=light] .app-topbar .sync-state { color: rgba(255,255,255,.85); }
.sync-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--good); margin-right: .4rem; box-shadow: 0 0 0 3px rgba(52, 211, 153, .18); }
.sync-dot.stale { background: var(--warn); box-shadow: 0 0 0 3px rgba(251, 191, 36, .18); }
.sync-dot.dead { background: var(--bad); box-shadow: 0 0 0 3px rgba(248, 113, 113, .18); }
.acct-select { background: var(--surface-2); color: var(--topbar-ink); border: 1px solid var(--line); border-radius: 10px; padding: .4rem 2rem .4rem .8rem;
  font-weight: 600; font-size: .92rem; max-width: 280px; }
[data-bs-theme=light] .app-topbar .acct-select { background-color: rgba(255,255,255,.16); border-color: rgba(255,255,255,.3); color: #fff; }
[data-bs-theme=light] .app-topbar .acct-select option { color: #0f172a; }

/* ===== Khung + thanh bên ===== */
.app-shell { display: flex; align-items: flex-start; }
.app-sidebar { width: var(--sidebar-w); flex: 0 0 var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--line);
  height: calc(100vh - var(--topbar-h)); position: sticky; top: var(--topbar-h); overflow-y: auto; overflow-x: hidden; transition: width .15s ease, flex-basis .15s ease; }
[data-bs-theme=dark] .app-sidebar { background: var(--topbar-bg); }
.app-main { flex: 1 1 auto; min-width: 0; }
.app-nav { padding: .5rem; }
.app-nav .nav-link { display: flex; align-items: center; gap: .65rem; color: var(--ink-2); border-radius: 10px; padding: .55rem .75rem; margin-bottom: 2px; font-size: .925rem; white-space: nowrap; }
.app-nav .nav-link i { font-size: 1.05rem; width: 1.2rem; text-align: center; flex: 0 0 auto; }
.app-nav .nav-link:hover { background: var(--surface-2); color: var(--ink); }
.app-nav .nav-link.active { background: color-mix(in srgb, var(--brand) 16%, transparent); color: var(--ink); font-weight: 600; }
[data-bs-theme=light] .app-nav .nav-link.active { color: #4338ca; }
.nav-section { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); padding: .9rem .9rem .35rem; white-space: nowrap; }
@media (min-width: 992px) {
  html[data-nav=rail] .app-sidebar { width: var(--rail-w); flex-basis: var(--rail-w); }
  html[data-nav=rail] .app-nav .nav-link { justify-content: center; padding: .6rem 0; position: relative; }
  html[data-nav=rail] .app-nav .nav-link span:not(.badge) { display: none; }
  html[data-nav=rail] .app-nav .nav-link .badge { position: absolute; top: 2px; right: 4px; font-size: .6rem; }
  html[data-nav=rail] .nav-section { visibility: hidden; height: 12px; padding: 0; }
}
@media (max-width: 991.98px) { .app-sidebar.offcanvas-lg { height: 100%; position: fixed; } }

/* ===== Thẻ, số liệu ===== */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(16,24,40,.04); }
[data-bs-theme=dark] .card { box-shadow: none; }
.stat-card .stat-label { font-size: .78rem; color: var(--ink-2); text-transform: uppercase; letter-spacing: .03em; }
.stat-card .stat-value { font-size: 1.75rem; font-weight: 700; color: var(--ink); }
.stat-card .stat-sub { font-size: 1rem; color: var(--ink-3); font-weight: 500; }
.mini-value { font-weight: 700; font-size: 1.05rem; }
.mini-label { font-size: .72rem; color: var(--ink-3); }
.platform-badge { width: 42px; height: 42px; border-radius: .6rem; display: inline-flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--pc) 15%, var(--surface)); color: var(--pc); font-size: 1.3rem; }

/* Bootstrap trên nền tối: các lớp "sáng cứng" phải theo nền */
[data-bs-theme=dark] .table { --bs-table-bg: transparent; --bs-table-color: #d5dcec; --bs-table-border-color: var(--line); --bs-table-hover-bg: rgba(140,160,210,.06); --bs-table-hover-color: #fff; --bs-table-striped-bg: rgba(140,160,210,.04); }
[data-bs-theme=dark] .table-light { --bs-table-bg: var(--surface-2); --bs-table-color: #e6ebf7; --bs-table-border-color: var(--line); }
[data-bs-theme=dark] .table-primary { --bs-table-bg: #101f44; --bs-table-color: #e6ebf7; --bs-table-border-color: #1d3a80; }
[data-bs-theme=dark] .table > thead th { color: var(--ink-2); font-weight: 600; }
[data-bs-theme=dark] .text-bg-light, [data-bs-theme=dark] .bg-light, [data-bs-theme=dark] .bg-white { background-color: var(--surface-3) !important; color: #d5dcec !important; }
[data-bs-theme=dark] .text-bg-danger-subtle { background: #2c1218; }
[data-bs-theme=dark] .btn-light { --bs-btn-bg: #e9eefb; --bs-btn-color: #0b1220; }
[data-bs-theme=dark] .form-control, [data-bs-theme=dark] .form-select { background-color: var(--surface-2); border-color: var(--line); color: var(--ink); }
[data-bs-theme=dark] .form-control:focus, [data-bs-theme=dark] .form-select:focus { border-color: #2f4ea8; box-shadow: 0 0 0 .2rem rgba(79,110,247,.18); }
[data-bs-theme=dark] .form-control::placeholder { color: var(--ink-3); }
[data-bs-theme=dark] .input-group-text { background: var(--surface-3); border-color: var(--line); color: var(--ink-2); }
[data-bs-theme=dark] .modal-content, [data-bs-theme=dark] .dropdown-menu, [data-bs-theme=dark] .offcanvas, [data-bs-theme=dark] .offcanvas-lg { background-color: var(--surface); border-color: var(--line); }
[data-bs-theme=dark] .nav-tabs { --bs-nav-tabs-border-color: var(--line); --bs-nav-tabs-link-active-bg: var(--surface); --bs-nav-tabs-link-active-color: #fff; --bs-nav-tabs-link-active-border-color: var(--line) var(--line) var(--surface); --bs-nav-link-color: var(--ink-2); --bs-nav-link-hover-color: #fff; --bs-nav-tabs-link-hover-border-color: transparent; }
[data-bs-theme=dark] .btn-outline-secondary { --bs-btn-color: #b4bfd8; --bs-btn-border-color: #26324f; --bs-btn-hover-bg: #1a2440; --bs-btn-hover-border-color: #33426a; --bs-btn-hover-color: #fff; --bs-btn-active-bg: #1a2440; --bs-btn-active-border-color: #33426a; }
[data-bs-theme=dark] .btn-outline-primary { --bs-btn-color: #8fb4ff; --bs-btn-border-color: #2c4592; --bs-btn-hover-bg: #2748b8; --bs-btn-hover-border-color: #2748b8; --bs-btn-active-bg: #2f55d4; --bs-btn-active-border-color: #2f55d4; }
[data-bs-theme=dark] .alert { border-width: 1px; }
[data-bs-theme=dark] code { background: rgba(140,160,210,.08); padding: .05rem .3rem; border-radius: 4px; }
[data-bs-theme=dark] hr { border-color: var(--line); opacity: 1; }
[data-bs-theme=dark] .list-group-item { background: transparent; border-color: var(--line); }
[data-bs-theme=dark] .accordion { --bs-accordion-bg: var(--surface); --bs-accordion-border-color: var(--line); --bs-accordion-active-bg: var(--surface-2); --bs-accordion-active-color: #fff; --bs-accordion-btn-color: #d5dcec; }

/* Network tabs */
.network-tabs .nav-link { color: var(--ink-2); font-weight: 500; }
.network-tabs .nav-link.active { color: var(--ink); font-weight: 600; }
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: middle; }

/* ===== Đăng nhập / quên mật khẩu / 2 bước ===== */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--app-bg); }
.auth-side { position: relative; overflow: hidden; padding: 2.75rem 3.25rem 2rem; display: flex; flex-direction: column; gap: 2rem; color: #eef2fb;
  background: radial-gradient(820px 520px at 8% 0%, rgba(79,110,247,.62), transparent 62%),
              radial-gradient(680px 520px at 100% 100%, rgba(124,92,245,.48), transparent 60%), #070b16; }
.auth-side::before { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image: linear-gradient(rgba(255,255,255,.045) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.045) 1px, transparent 1px);
  background-size: 44px 44px; mask-image: radial-gradient(ellipse at 30% 30%, #000 20%, transparent 75%); -webkit-mask-image: radial-gradient(ellipse at 30% 30%, #000 20%, transparent 75%); }
.auth-side > * { position: relative; }
.auth-brand { display: flex; align-items: center; gap: .7rem; font-weight: 700; font-size: 1.15rem; letter-spacing: -.01em; }
.auth-brand .brand-mark { width: 40px; height: 40px; border-radius: 12px; font-size: 1.2rem; box-shadow: 0 8px 24px rgba(79,110,247,.45); }
.auth-brand-sm { display: none; margin-bottom: 1.75rem; color: var(--ink); }
.auth-pitch { margin-top: auto; max-width: 520px; }
.auth-pitch h2 { font-size: clamp(1.7rem, 2.6vw, 2.35rem); line-height: 1.18; font-weight: 700; letter-spacing: -.02em; margin: 0 0 .9rem; text-wrap: balance; }
.auth-pitch p { color: rgba(238,242,251,.78); font-size: 1.02rem; line-height: 1.55; margin: 0 0 1.75rem; max-width: 46ch; }
.auth-points { list-style: none; margin: 0; padding: 0; display: grid; gap: .85rem; }
.auth-points li { display: flex; gap: .85rem; align-items: flex-start; }
.auth-points i { flex: 0 0 38px; height: 38px; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.05rem;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.14); color: #c9d6ff; }
.auth-points b { display: block; font-weight: 600; font-size: .98rem; }
.auth-points span { display: block; color: rgba(238,242,251,.68); font-size: .88rem; line-height: 1.45; margin-top: .1rem; }
.auth-wave { width: calc(100% + 6.5rem); margin: 0 -3.25rem; height: 120px; display: block; margin-top: auto; opacity: .9; }
.auth-side-foot { font-size: .8rem; color: rgba(238,242,251,.6); }

.auth-main { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2.5rem 1.25rem 1.5rem; }
.auth-theme { position: absolute; top: 1rem; right: 1rem; width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center; font-size: 1.05rem; }
.auth-theme:hover { color: var(--ink); background: var(--surface-2); }
.auth-card { width: 100%; max-width: 408px; }
.auth-icon { width: 52px; height: 52px; border-radius: 15px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.45rem; margin-bottom: 1.1rem;
  color: #fff; background: linear-gradient(135deg, #4f6ef7, #7c5cf5); box-shadow: 0 10px 28px rgba(79,110,247,.35); }
.auth-icon.ok { background: linear-gradient(135deg, #12a36f, #2bbf8a); box-shadow: 0 10px 28px rgba(18,163,111,.3); }
.auth-icon.warn { background: linear-gradient(135deg, #d98a09, #f0a92b); box-shadow: 0 10px 28px rgba(217,138,9,.3); }
.auth-title { font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; color: var(--ink); margin: 0 0 .4rem; }
.auth-sub { color: var(--ink-2); font-size: .97rem; line-height: 1.5; margin: 0 0 1.5rem; }
.auth-sub b { color: var(--ink); font-weight: 600; overflow-wrap: anywhere; }
.auth-field { margin-bottom: 1.05rem; }
.auth-field label { display: block; font-size: .86rem; font-weight: 600; color: var(--ink); margin-bottom: .4rem; }
.auth-under { display: flex; align-items: baseline; gap: 1rem; margin-top: .5rem; }
.auth-under .auth-caps { margin-top: 0; }
.auth-under .auth-link { margin-left: auto; }
.auth-muted { color: var(--ink-3); font-weight: 400; }
.auth-input { display: flex; align-items: center; background: var(--surface); border: 1px solid var(--auth-line); border-radius: 12px; transition: border-color .12s ease, box-shadow .12s ease; }
.auth-input:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 22%, transparent); }
.auth-input > i { flex: 0 0 44px; text-align: center; color: var(--ink-3); font-size: 1.05rem; }
.auth-input input { flex: 1 1 auto; min-width: 0; height: 48px; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 1rem; padding: 0 .25rem 0 0; }
.auth-input input::placeholder { color: var(--ink-3); }
.auth-input input:-webkit-autofill { -webkit-text-fill-color: var(--ink); box-shadow: 0 0 0 100px var(--surface) inset; caret-color: var(--ink); border-radius: 12px; }
.auth-eye { flex: 0 0 46px; height: 48px; border: 0; background: transparent; color: var(--ink-3); font-size: 1.1rem; border-radius: 0 12px 12px 0; }
.auth-eye:hover { color: var(--ink); }
.auth-caps { font-size: .8rem; color: var(--warn); margin-top: .4rem; }
.auth-link { font-size: .86rem; font-weight: 600; color: var(--bs-link-color, #4f6ef7); text-decoration: none; }
.auth-link:hover { text-decoration: underline; }
[data-bs-theme=light] .auth-link { color: #3b55d9; }
.auth-btn { display: flex; align-items: center; justify-content: center; width: 100%; height: 48px; margin-top: 1.35rem; border: 0; border-radius: 12px; font-weight: 600; font-size: 1rem;
  color: #fff; text-decoration: none; background: linear-gradient(135deg, #4f6ef7, #6a5cf5); box-shadow: 0 10px 24px rgba(79,110,247,.32); transition: filter .12s ease, transform .05s ease; }
.auth-btn:hover { filter: brightness(1.08); color: #fff; }
.auth-btn:active { transform: translateY(1px); }
.auth-btn:disabled { opacity: .75; cursor: progress; }
.auth-btn:focus-visible, .auth-alt-btn:focus-visible, .auth-eye:focus-visible, .auth-theme:focus-visible, .auth-link:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; }
.auth-alert { display: flex; gap: .6rem; align-items: flex-start; border-radius: 12px; padding: .7rem .85rem; font-size: .9rem; line-height: 1.45; margin-bottom: 1.1rem; border: 1px solid; }
.auth-alert i { margin-top: .08rem; }
.auth-alert.bad { color: var(--bs-danger-text-emphasis); background: var(--bs-danger-bg-subtle); border-color: var(--bs-danger-border-subtle); }
.auth-alert.ok { color: var(--bs-success-text-emphasis); background: var(--bs-success-bg-subtle); border-color: var(--bs-success-border-subtle); }
.auth-alert.warn { color: var(--bs-warning-text-emphasis); background: var(--bs-warning-bg-subtle); border-color: var(--bs-warning-border-subtle); }
.auth-note { display: flex; gap: .6rem; align-items: flex-start; margin-top: 1.25rem; padding-top: 1.1rem; border-top: 1px solid var(--line); color: var(--ink-2); font-size: .86rem; line-height: 1.45; }
.auth-note b { color: var(--ink); font-weight: 600; }
.auth-code { width: 100%; height: 60px; border-radius: 12px; border: 1px solid var(--auth-line); background: var(--surface); color: var(--ink); text-align: center;
  font: 600 1.7rem/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .32em; padding-left: .32em; outline: 0; }
.auth-code:focus { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 22%, transparent); }
.auth-code::placeholder { color: var(--ink-3); letter-spacing: .2em; }
.auth-alt { margin-top: 1.25rem; padding-top: 1.1rem; border-top: 1px solid var(--line); display: grid; gap: .8rem; justify-items: start; }
.auth-alt form { width: 100%; }
.auth-alt-btn { width: 100%; height: 44px; border-radius: 12px; border: 1px solid var(--auth-line); background: var(--surface); color: var(--ink); font-weight: 600; font-size: .93rem; }
.auth-alt-btn:hover { background: var(--surface-2); }
.auth-hint { margin: 0; color: var(--ink-2); font-size: .86rem; }
.auth-list { color: var(--ink-2); font-size: .92rem; line-height: 1.55; padding-left: 1.15rem; margin: 0 0 .5rem; display: grid; gap: .45rem; }
.auth-list b { color: var(--ink); font-weight: 600; }
.auth-cmd { display: block; margin-top: .4rem; padding: .55rem .7rem; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); font-size: .78rem; overflow-wrap: anywhere; }
.auth-foot { margin: 2rem 0 0; color: var(--ink-3); font-size: .8rem; }
[data-bs-theme=dark] { --auth-line: #26324f; }
[data-bs-theme=light] { --auth-line: #cfd6e4; }
[data-bs-theme=light] .auth-main { background: #fff; }
[data-bs-theme=light] .auth-input, [data-bs-theme=light] .auth-code, [data-bs-theme=light] .auth-alt-btn, [data-bs-theme=light] .auth-theme { background: #fff; }
[data-bs-theme=light] .auth-input input:-webkit-autofill { box-shadow: 0 0 0 100px #fff inset; }
@media (max-width: 991.98px) {
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .auth-brand-sm { display: flex; }
  .auth-main { justify-content: flex-start; padding-top: 4.5rem;
    background: radial-gradient(700px 320px at 50% -8%, color-mix(in srgb, var(--brand) 20%, transparent), transparent 70%), var(--app-bg); }
  [data-bs-theme=light] .auth-main { background: radial-gradient(700px 320px at 50% -8%, rgba(79,110,247,.14), transparent 70%), #fff; }
  .auth-foot { margin-top: auto; padding-top: 2rem; }
}
@media (max-height: 760px) and (min-width: 992px) { .auth-wave { display: none; } .auth-side { gap: 1.25rem; } }
@media (prefers-reduced-motion: reduce) { .auth-btn, .auth-input { transition: none; } }

/* Nút đăng xuất + thẻ Bảo mật */
.top-logout { width: auto; padding: 0 .65rem; gap: .45rem; font-size: 1.05rem; }
.top-logout span { font-size: .86rem; font-weight: 600; }
.app-nav .nav-logout { margin-top: .5rem; padding-top: .5rem; border-top: 1px solid var(--line); }
.app-nav .nav-logout .nav-link:hover { color: var(--bad); }
.sec-row { display: flex; gap: .9rem; align-items: flex-start; padding: .95rem 0; border-top: 1px solid var(--line); }
.sec-row:first-child { border-top: 0; padding-top: 0; }
.sec-row:last-child { padding-bottom: 0; }
.sec-ico { flex: 0 0 40px; height: 40px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.1rem; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.sec-ico.on { color: var(--good); }
.sec-body { flex: 1 1 auto; min-width: 0; }
.sec-body .t { font-weight: 600; color: var(--ink); }
.sec-body .d { font-size: .86rem; color: var(--ink-2); line-height: 1.45; }
.sec-sub { margin-top: .8rem; padding-top: .7rem; border-top: 1px dashed var(--line); }
.sec-sub .form-check-label { font-size: .9rem; color: var(--ink); }
.qr-box { display: inline-block; background: #fff; padding: 12px; border-radius: 12px; line-height: 0; }
.qr-box svg, .qr-box img { width: 224px; height: 224px; display: block; }
.secret-key { font: 600 1rem/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .08em; overflow-wrap: anywhere; user-select: all; }
.backup-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
.backup-grid code { display: block; text-align: center; padding: .5rem; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink);
  font: 600 1rem/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .06em; }
.otp-input { text-align: center; font: 600 1.4rem/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .3em; }

.placeholder-icon { font-size: 3rem; color: var(--ink-3); }
.btn-primary { --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand-dark); --bs-btn-hover-border-color: var(--brand-dark);
  --bs-btn-active-bg: var(--brand-dark); --bs-btn-active-border-color: var(--brand-dark); --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand); }
[data-bs-theme=light] .text-bg-danger-subtle { background: #fef2f2; }

/* Toast lỗi rộng hơn, không tự tắt */
.toast-wide { max-width: 480px; width: auto; }
.toast-wide .toast-msg { white-space: pre-wrap; word-break: break-word; font-size: .9rem; }
/* Trung tâm lỗi */
.err-card { border-left: 4px solid #ef4444; }
.err-card.resolved { border-left-color: #22c55e; opacity: .75; }
.err-card .err-raw { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; white-space: pre-wrap; word-break: break-all;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: .5rem .75rem; max-height: 220px; overflow: auto; }
.err-card ol li { margin-bottom: .35rem; }
.err-card:target { box-shadow: 0 0 0 3px rgba(239,68,68,.35); }

/* Biểu đồ */
.viz { position: relative; height: 340px; }
.viz.viz-sm { height: 260px; }
.viz.viz-lg { height: 420px; }
@media (max-width: 768px) { .viz { height: 280px; } .viz.viz-sm { height: 220px; } .viz.viz-lg { height: 320px; } }
.viz canvas { position: absolute; inset: 0; }
.viz-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.viz-title { font-size: 1rem; font-weight: 600; color: var(--ink); margin-bottom: .5rem; display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.viz-title .text-muted { font-size: .85rem; font-weight: 400; }
.viz-sub { font-size: .9rem; font-weight: 600; color: var(--ink-2); margin: .25rem 0; }
.viz-card .card-body { padding: 1rem 1.1rem; }
.kpi-delta { font-size: .78rem; }

/* ===== Trang Tổng quan hiệu quả ===== */
.pf-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.pf-title { font-size: 1.9rem; font-weight: 800; letter-spacing: -.02em; color: var(--ink); line-height: 1.1; margin: 0; }
.pf-sub { color: var(--ink-2); font-size: .92rem; margin-top: .3rem; }
.pf-head > div { min-width: 0; max-width: 100%; }
.pf-seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.pf-seg::-webkit-scrollbar { display: none; }
.pf-seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 2px; }
.pf-seg button { border: 0; background: transparent; color: var(--ink-2); font-weight: 600; font-size: .9rem; padding: .42rem .85rem; border-radius: 9px; white-space: nowrap; }
.pf-seg button:hover { color: var(--ink); }
.pf-seg button.active { background: var(--surface-3); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.pf-btn { display: inline-flex; align-items: center; gap: .45rem; background: var(--surface); border: 1px solid var(--line); color: var(--ink); border-radius: 12px;
  padding: .5rem .9rem; font-weight: 600; font-size: .9rem; white-space: nowrap; }
.pf-btn:hover { background: var(--surface-2); }
.pf-btn.active { border-color: var(--brand); }
.pf-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.pf-tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
@media (max-width: 1199.98px) { .pf-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .pf-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 575.98px) {
  .pf-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } .pf-kpis { gap: 10px; } .pf-title { font-size: 1.45rem; }
  .pf-kpis { grid-template-columns: minmax(0, 1fr); }
  .pf-kpi { padding: .8rem 1rem .9rem; min-height: 0; } .pf-kpi .val { font-size: 1.55rem; margin-top: .15rem; }
  .pf-kpi .lbl { font-size: .88rem; } .pf-kpi .sub { font-size: .78rem; margin-top: .2rem; }
  .pf-tile { padding: .7rem .85rem; } .pf-tile .val { font-size: .95rem; letter-spacing: -.01em; }
  .pf-seg button { padding: .4rem .65rem; font-size: .84rem; }
  .pf-tools { width: 100%; } .pf-search { flex: 1 1 140px; } .pf-search input { width: 100%; max-width: none; }
  .pf-tabs { gap: 1.1rem; } .pf-tabs button { font-size: .95rem; }
}
@media (max-width: 767.98px) {
  .pf-table .c-name { position: static; min-width: 230px; max-width: 250px; box-shadow: none; }
  .pf-tablewrap { max-height: none; }
}
.pf-kpi, .pf-tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
.pf-kpi { padding: 1.15rem 1.4rem 1.2rem; min-height: 132px; display: flex; flex-direction: column; }
.pf-kpi .lbl { color: var(--ink-2); font-size: .95rem; font-weight: 500; }
.pf-kpi .val { font-size: 1.9rem; font-weight: 800; letter-spacing: -.02em; color: var(--ink); margin-top: .35rem; line-height: 1.15; overflow-wrap: anywhere; }
.pf-kpi .sub { color: var(--ink-3); font-size: .82rem; margin-top: .35rem; }
.pf-kpi .sub + .bar { margin-top: .75rem; }
.pf-kpi .bar { margin-top: auto; height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.pf-kpi .bar > i { display: block; height: 100%; border-radius: 6px; background: var(--info); width: 0; transition: width .3s ease; }
.pf-kpi .bar > i.good { background: var(--good); } .pf-kpi .bar > i.bad { background: var(--bad); } .pf-kpi .bar > i.warn { background: var(--warn); }
.pf-tile { padding: .85rem 1.1rem; }
.pf-tile .lbl { color: var(--ink-2); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pf-tile .val { font-size: 1.2rem; font-weight: 700; color: var(--ink); margin-top: .15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pf-val-na { color: var(--ink-3) !important; }
.pf-pos { color: var(--good) !important; } .pf-neg { color: var(--bad) !important; }
.pf-bar2 { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.pf-tabs { display: flex; gap: 1.6rem; overflow-x: auto; scrollbar-width: none; }
.pf-tabs::-webkit-scrollbar { display: none; }
.pf-tabs button { border: 0; background: transparent; color: var(--ink-2); font-weight: 600; font-size: 1.02rem; padding: .7rem 0 .8rem; white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.pf-tabs button:hover { color: var(--ink); }
.pf-tabs button.active { color: var(--ink); border-bottom-color: var(--brand); }
.pf-tools { display: flex; align-items: center; gap: .6rem; padding-bottom: .5rem; flex-wrap: wrap; }
.pf-search { position: relative; }
.pf-search i { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--ink-3); }
.pf-search input { background: var(--surface); border: 1px solid var(--line); color: var(--ink); border-radius: 12px; padding: .5rem .8rem .5rem 2.2rem; width: 260px; max-width: 60vw; font-size: .9rem; outline: 0; }
.pf-search input:focus { border-color: var(--brand); }
.pf-scale { display: inline-flex; align-items: center; gap: .4rem; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .32rem .7rem; font-size: .88rem; color: var(--ink-2); white-space: nowrap; }
.pf-scale input { width: 44px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink); border-radius: 8px; padding: .12rem .3rem; text-align: center; font-weight: 600; outline: 0; }
.pf-scale .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); display: inline-block; }
.pf-tablewrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; max-height: calc(100vh - 150px); }
.pf-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .86rem; font-variant-numeric: tabular-nums; }
.pf-table th, .pf-table td { padding: .62rem .55rem; white-space: nowrap; text-align: right; border-bottom: 1px solid var(--line); }
.pf-table thead th { position: sticky; background: var(--surface); z-index: 3; color: var(--ink-3); font-size: .7rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; cursor: pointer; user-select: none; }
.pf-table thead tr.grp th { top: 0; height: 30px; padding-top: .7rem; padding-bottom: .1rem; border-bottom: 0; cursor: default; text-align: left; }
.pf-table thead tr.cols th { top: 30px; }
.pf-table thead th.g-pos { color: var(--good); } .pf-table thead th.g-meta { color: var(--info); }
.pf-table thead th.sorted { color: var(--ink); }
.pf-table .c-name { text-align: left; position: sticky; left: 0; background: var(--surface); z-index: 2; min-width: 340px; max-width: 420px; }
.pf-table thead .c-name { z-index: 4; }
.pf-table td.c-name { box-shadow: 1px 0 0 var(--line); }
.pf-table .sep { border-left: 1px solid var(--line); }
.pf-table tbody tr:hover td { background: var(--surface-2); }
.pf-table tbody tr.child td { background: color-mix(in srgb, var(--surface-2) 60%, var(--surface)); }
.pf-table tbody tr.child:hover td { background: var(--surface-2); }
.pf-table tbody tr.soft td { color: var(--ink-2); font-style: italic; }
.pf-table tfoot td { position: sticky; bottom: 0; background: var(--surface-2); font-weight: 700; color: var(--ink); border-top: 1px solid var(--line); border-bottom: 0; z-index: 2; }
.pf-table tfoot td.c-name { z-index: 3; background: var(--surface-2); }
.pf-name { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.pf-name .nm { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; flex: 1 1 auto; min-width: 0; }
.pf-name .nm small { display: block; color: var(--ink-3); font-weight: 400; overflow: hidden; text-overflow: ellipsis; }
.pf-name a.nm { text-decoration: none; }
.pf-ic { width: 26px; height: 26px; flex: 0 0 26px; border-radius: 7px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2);
  display: inline-flex; align-items: center; justify-content: center; font-size: .85rem; padding: 0; }
.pf-ic:hover { color: var(--ink); border-color: #33426a; }
.pf-ic.blue { background: color-mix(in srgb, var(--brand) 22%, var(--surface)); border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); color: #b9c8ff; }
[data-bs-theme=light] .pf-ic.blue { color: #3b55d9; }
.pf-ic.ghost { visibility: hidden; }
.pf-toggle { position: relative; width: 38px; height: 22px; flex: 0 0 38px; border-radius: 22px; border: 0; background: #3a4563; padding: 0; transition: background .15s; }
[data-bs-theme=light] .pf-toggle { background: #cbd5e1; }
.pf-toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; }
.pf-toggle.on { background: #22c55e; } .pf-toggle.on::after { left: 19px; }
.pf-toggle.unknown { opacity: .35; cursor: not-allowed; }
.pf-toggle.busy { opacity: .5; }
.pf-tag { font-size: .66rem; font-weight: 700; padding: .12rem .4rem; border-radius: 6px; letter-spacing: .03em; flex: 0 0 auto; }
.pf-tag.scale { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }
.pf-tag.burn { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); }
.pf-na { color: var(--ink-3); }
.pf-budget { display: inline-flex; align-items: center; gap: .4rem; justify-content: flex-end; }
.pf-cols { min-width: 250px; max-height: 60vh; overflow: auto; padding: .5rem .75rem; }
.pf-cols label { display: flex; align-items: center; gap: .5rem; padding: .22rem 0; font-size: .88rem; cursor: pointer; }
.pf-cols .ttl { font-size: .7rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); margin: .5rem 0 .2rem; }
.pf-note { color: var(--ink-3); font-size: .8rem; margin-top: .6rem; }
.pf-alert { background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--warn); border-radius: 12px; padding: .6rem .9rem; font-size: .88rem; color: var(--ink-2); margin-bottom: 12px; }
.pf-alert.danger { border-left-color: var(--bad); }
.pf-plan { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
.pf-plan .it { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .8rem 1rem; }
.pf-plan .it .k { font-size: .68rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.pf-plan .it .n { font-weight: 600; color: var(--ink); margin: .15rem 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-plan .it .t { font-size: .88rem; color: var(--ink-2); }

/* ===== Trang Phân tích quảng cáo ===== */
.an-kpis { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
@media (max-width: 1599.98px) { .an-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 575.98px) { .an-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }
.an-sub { font-size: .78rem; color: var(--ink-2); margin-top: .15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.an-delta { font-weight: 700; font-size: .76rem; }
.an-mid { color: var(--ink-3); font-weight: 400; }
.an-sec { margin-bottom: 16px; }
.an-h { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; font-weight: 700; color: var(--ink); margin-bottom: .6rem; font-size: 1.02rem; }
.an-warn { color: var(--warn) !important; }
.an-tip { cursor: pointer; transition: border-color .12s; }
.an-tip:hover { border-color: var(--brand); }
.an-name { cursor: pointer; }
.an-fstep { margin-bottom: .75rem; }
.an-fhead { display: flex; justify-content: space-between; gap: 1rem; font-size: .9rem; }
.an-fhead .nm { color: var(--ink-2); }
.an-fhead .v { font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.an-fbar { height: 8px; background: var(--surface-3); border-radius: 6px; overflow: hidden; margin: .25rem 0; }
.an-fbar i { display: block; height: 100%; background: var(--info); border-radius: 6px; }
.an-fmeta { display: flex; justify-content: space-between; gap: 1rem; font-size: .76rem; color: var(--ink-3); }
.an-fmeta b { color: var(--ink-2); }
.an-share { display: inline-block; width: 68%; height: 6px; background: var(--surface-3); border-radius: 6px; overflow: hidden; vertical-align: middle; margin-right: .4rem; }
.an-share i { display: block; height: 100%; background: var(--info); border-radius: 6px; }
.an-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: .4rem; }
.an-legend { display: flex; gap: 1rem; justify-content: center; font-size: .82rem; color: var(--ink-2); margin-top: .3rem; min-height: 1.2rem; }
.an-run { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex: 0 0 8px; opacity: .45; }
.an-run.on { background: var(--good); opacity: 1; }
.pf-tag.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
@media (max-width: 575.98px) { .an-kpis .pf-tile .val { font-size: .92rem; } .an-h { font-size: .95rem; } }

/* Trang Telegram: bảng lệnh của bot */
.tg-cmd td { border-color: var(--line); vertical-align: top; padding: .35rem .5rem; }
.tg-cmd td:first-child { white-space: nowrap; width: 1%; }
