/* =====================================================================
   Giao diện chung của bộ khung. Màu thương hiệu: chọn ở trang Setup → bước "Thương hiệu"
   (BRAND_COLOR, tự sinh --brand / --brand-600 / --brand-50 / --brand-100). Style riêng của dự án:
   app/static/css/theme.css — KHÔNG sửa file này.
   ===================================================================== */
:root {
  --brand: #2563eb;
  --brand-600: #1d4ed8;
  --brand-50: #eff6ff;
  --brand-100: #dbeafe;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --surface: #ffffff;
  --bg: #f8fafc;
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 8px 24px -10px rgba(15, 23, 42, .18);
  --bs-primary: var(--brand);
  --bs-link-color: var(--brand);
  --bs-link-hover-color: var(--brand-600);
  --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bs-border-radius: 10px;
}
body { background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
a { text-decoration: none; }
.text-muted, .text-secondary { color: var(--muted) !important; }

/* ---------- Nút ---------- */
.btn { border-radius: 10px; font-weight: 500; }
.btn-primary { --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand-600);
  --bs-btn-hover-border-color: var(--brand-600); --bs-btn-active-bg: var(--brand-600); --bs-btn-disabled-bg: var(--brand);
  --bs-btn-disabled-border-color: var(--brand); }
.btn-outline-primary { --bs-btn-color: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand);
  --bs-btn-hover-border-color: var(--brand); --bs-btn-active-bg: var(--brand-600); }
.btn-soft { background: var(--brand-50); color: var(--brand-600); border: 1px solid var(--brand-100); }
.btn-soft:hover { background: var(--brand-100); color: var(--brand-600); }
.btn-google { background: #fff; border: 1px solid var(--line); color: var(--ink); display: inline-flex; align-items: center;
  justify-content: center; gap: .6rem; }
.btn-google:hover { background: #f8fafc; border-color: #cbd5e1; }
.btn-google img { width: 18px; height: 18px; }

/* ---------- Thanh điều hướng ---------- */
.app-nav { background: rgba(255, 255, 255, .85); backdrop-filter: saturate(180%) blur(12px); border-bottom: 1px solid var(--line); }
.app-nav .navbar-brand { font-weight: 700; letter-spacing: -.01em; display: flex; align-items: center; gap: .5rem; }
.brand-img { width: 32px; height: 32px; border-radius: 9px; }
.brand-wide { height: 32px; width: auto; max-width: 180px; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, var(--brand), var(--brand-600));
  color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 1rem; }
.app-nav .nav-link { color: var(--muted); font-weight: 500; border-radius: 8px; padding: .4rem .75rem !important; }
.app-nav .nav-link:hover, .app-nav .nav-link.active { color: var(--ink); background: #f1f5f9; }
.credit-pill { display: inline-flex; align-items: center; gap: .4rem; padding: .3rem .75rem; border-radius: 999px;
  background: var(--brand-50); color: var(--brand-600); font-weight: 600; font-size: .875rem; border: 1px solid var(--brand-100); }
.credit-pill:hover { background: var(--brand-100); color: var(--brand-600); }
.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--brand-100); color: var(--brand-600);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: .85rem; }
.dropdown-menu { border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 12px; padding: .4rem; }
.dropdown-item { border-radius: 8px; padding: .45rem .75rem; }

/* ---------- Thẻ / khối ---------- */
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-header { background: transparent; border-bottom: 1px solid var(--line); font-weight: 600; }
.surface { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.page-title { font-weight: 700; letter-spacing: -.02em; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; font-weight: 600; color: var(--brand); }
.stat { padding: 1.1rem 1.25rem; }
.stat .label { color: var(--muted); font-size: .8rem; font-weight: 500; }
.stat .value { font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em; }
.stat .sub { font-size: .8rem; color: var(--muted); }
.table { --bs-table-bg: transparent; }
.table > thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600;
  border-bottom-width: 1px; white-space: nowrap; }
.table > tbody td { vertical-align: middle; }
.badge-status { font-weight: 600; font-size: .72rem; padding: .35em .65em; border-radius: 999px; }
.st-PAID { background: #dcfce7; color: #166534; } .st-PENDING { background: #fef9c3; color: #854d0e; }
.st-CANCELLED, .st-EXPIRED { background: #f1f5f9; color: #475569; } .st-FAILED { background: #fee2e2; color: #991b1b; }
.amount-pos { color: #16a34a; font-weight: 600; } .amount-neg { color: #dc2626; font-weight: 600; }
.form-control, .form-select { border-radius: 10px; border-color: var(--line); padding: .6rem .8rem; }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 .2rem var(--brand-100); }
.form-label { font-weight: 500; font-size: .9rem; }
.flash-wrap .alert { border-radius: 12px; border: 0; box-shadow: var(--shadow-sm); }

/* ---------- Đăng nhập ---------- */
.auth-wrap { min-height: calc(100vh - 140px); display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; }
.auth-card { width: 100%; max-width: 420px; padding: 2rem; }
.divider { display: flex; align-items: center; gap: .75rem; color: var(--muted); font-size: .8rem; margin: 1.25rem 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- Bảng giá ---------- */
.price-card { position: relative; padding: 1.75rem; height: 100%; display: flex; flex-direction: column; transition: transform .15s, box-shadow .15s; }
.price-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.price-card.featured { border: 2px solid var(--brand); box-shadow: var(--shadow); }
.price-card .ribbon { position: absolute; top: -12px; left: 50%; transform: translateX(-50%); background: var(--brand); color: #fff;
  font-size: .72rem; font-weight: 600; padding: .25rem .75rem; border-radius: 999px; white-space: nowrap; }
.price-card .price { font-size: 2rem; font-weight: 800; letter-spacing: -.03em; }
.price-card .credits { font-size: 1.05rem; font-weight: 600; color: var(--brand-600); }

/* ---------- Admin ---------- */
.admin-side { position: sticky; top: 84px; }
.admin-side a { display: flex; align-items: center; gap: .6rem; padding: .55rem .8rem; border-radius: 10px; color: var(--muted);
  font-weight: 500; font-size: .92rem; }
.admin-side a:hover { background: #f1f5f9; color: var(--ink); }
.admin-side a.active { background: var(--brand-50); color: var(--brand-600); }
.admin-side .sep { height: 1px; background: var(--line); margin: .6rem .5rem; }

/* ---------- Footer ---------- */
.app-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; }

/* ---------- Trang Setup / Wizard (giữ nguyên) ---------- */
.setup-nav { top: 80px; }
.setup-nav a { display: block; padding: .3rem .5rem; border-radius: .375rem; color: var(--bs-body-color); font-size: .875rem; }
.setup-nav a:hover { background: var(--bs-secondary-bg); }
section[id] { scroll-margin-top: 80px; }
.status-dot { width: .75rem; height: .75rem; border-radius: 50%; flex: none; background: var(--bs-secondary-bg); }
.status-dot[data-status="ok"] { background: var(--bs-success); }
.status-dot[data-status="warn"] { background: var(--bs-warning); }
.status-dot[data-status="fail"] { background: var(--bs-danger); }
.status-dot[data-status="skip"] { background: var(--bs-gray-400); }
.status-dot[data-status="running"] { background: var(--brand); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.check-card[data-status="fail"] { border-color: var(--bs-danger-border-subtle); }
.check-card[data-status="warn"] { border-color: var(--bs-warning-border-subtle); }
.check-steps li { display: flex; gap: .4rem; padding: .15rem 0; word-break: break-word; }
.check-steps .ic { flex: none; width: 1rem; }
.cmd-box { position: relative; background: #1e2430; color: #e6e9ef; border-radius: .5rem; margin-top: .35rem; }
.cmd-box pre { padding: .6rem 2.8rem .6rem .8rem; font-size: .8rem; white-space: pre-wrap; word-break: break-all; color: inherit; }
.cmd-box .copy-btn { position: absolute; top: .35rem; right: .35rem; padding: .1rem .4rem; }
.badge.src-default { background: var(--bs-secondary-bg); color: var(--bs-secondary-color); }
.badge.src-env, .badge.src-env { background: var(--bs-success-bg-subtle); color: var(--bs-success-text-emphasis); }
.wizard-steps { position: sticky; top: 80px; display: flex; flex-direction: column; gap: 2px; }
.wizard-steps a { display: flex; align-items: center; gap: .5rem; padding: .45rem .6rem; border-radius: .5rem;
  color: var(--bs-body-color); font-size: .875rem; }
.wizard-steps a:hover { background: var(--bs-secondary-bg); }
.wizard-steps a.active { background: var(--brand-50); color: var(--brand-600); font-weight: 600; }
.wizard-steps .num { width: 1.6rem; height: 1.6rem; border-radius: 50%; display: inline-flex; align-items: center;
  justify-content: center; background: var(--bs-secondary-bg); font-size: .75rem; flex: none; }
.wizard-steps a.active .num { background: var(--brand); color: #fff; }
.wiz-section { border-top: 1px solid var(--line); padding-top: 1.25rem; margin-top: 1.25rem; }
.sec-num { display: inline-flex; width: 1.5rem; height: 1.5rem; border-radius: 50%; align-items: center; justify-content: center;
  background: var(--brand); color: #fff; font-size: .75rem; margin-right: .35rem; }
.wiz-tasks { padding-left: 1.2rem; }
.wiz-tasks > li { margin-bottom: 1rem; }
.cmd-box .cmd-actions { position: absolute; top: .35rem; right: .35rem; display: flex; gap: .25rem; }
.cmd-box .cmd-actions .copy-btn { position: static; }
.wiz-tasks .cmd-box pre { padding-right: 9rem; }
.run-log { background: #11151c; color: #d8dee9; border-radius: .375rem; padding: .75rem; font-size: .78rem;
  max-height: 55vh; overflow: auto; white-space: pre-wrap; word-break: break-all; }

/* ---------- Điện thoại / app (PWA) ---------- */
html { -webkit-tap-highlight-color: transparent; }
.app-nav { padding-top: calc(.5rem + env(safe-area-inset-top)); }
.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030; display: flex; background: rgba(255, 255, 255, .96);
  backdrop-filter: saturate(180%) blur(12px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 58px; color: var(--muted); font-size: .7rem; font-weight: 500; }
.bottom-nav a i { font-size: 1.3rem; line-height: 1; }
.bottom-nav a.active { color: var(--brand); }
.bottom-nav a.active i { transform: translateY(-1px); }
@media (max-width: 991.98px) {
  body.has-bottom-nav { padding-bottom: calc(58px + env(safe-area-inset-bottom)); }
  body.has-bottom-nav .app-footer { display: none; }
  .btn, .form-control, .form-select { min-height: 42px; }
  .btn-sm { min-height: 34px; }
}
.is-standalone .app-footer { display: none; }
.pwa-steps { list-style: none; padding: 0; margin: 0 0 1rem; display: flex; flex-direction: column; gap: .75rem; font-size: .92rem; }
.pwa-steps li { display: flex; gap: .75rem; align-items: center; }
.pwa-steps .ic { width: 38px; height: 38px; flex: none; border-radius: 10px; background: var(--brand-50); color: var(--brand);
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.15rem; }
.pwa-toast-wrap { top: calc(70px + env(safe-area-inset-top)); z-index: 1080; }

/* ---------- Trang nội dung (điều khoản, bảo mật) ---------- */
.legal { max-width: 820px; padding: 2rem 2.25rem; line-height: 1.7; }
.legal h2 { font-size: 1.05rem; font-weight: 700; margin-top: 1.75rem; }
@media (max-width: 575.98px) { .legal { padding: 1.25rem; border-radius: 0; border-left: 0; border-right: 0; } }

/* ---------- Tài khoản ---------- */
.account-head { display: flex; align-items: center; gap: 1rem; }
.account-head .avatar { width: 64px; height: 64px; font-size: 1.5rem; }
.list-menu { list-style: none; padding: 0; margin: 0; }
.list-menu a, .list-menu button { display: flex; align-items: center; gap: .8rem; width: 100%; padding: .85rem 1rem; color: var(--ink);
  background: none; border: 0; border-top: 1px solid var(--line); text-align: left; font-weight: 500; }
.list-menu li:first-child a, .list-menu li:first-child button { border-top: 0; }
.list-menu a:hover, .list-menu button:hover { background: #f8fafc; }
.list-menu .bi:first-child { width: 1.4rem; font-size: 1.15rem; color: var(--brand); }
.list-menu .chev { margin-left: auto; color: var(--muted); }

/* ---------- Thương hiệu (Setup) ---------- */
.brand-preview { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; }
.brand-preview figure { margin: 0; text-align: center; font-size: .75rem; color: var(--muted); }
.brand-preview img { display: block; margin: 0 auto .35rem; background: repeating-conic-gradient(#eef2f7 0 25%, #fff 0 50%) 0 0 / 14px 14px; }

/* ---------- Nút quay lại (chỉ hiện khi mở như app trên điện thoại) + thông báo nhanh ---------- */
.nav-back { display: none; align-items: center; justify-content: center; width: 36px; height: 36px; margin-right: .25rem;
  border: 0; border-radius: 10px; background: #f1f5f9; color: var(--ink); font-size: 1.1rem; }
.is-standalone .nav-back { display: inline-flex; }
.app-toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 2100;
  display: flex; flex-direction: column; gap: .5rem; width: min(92vw, 420px); pointer-events: none; }
.app-toast { background: #0f172a; color: #fff; padding: .7rem 1rem; border-radius: 12px; font-size: .9rem;
  box-shadow: 0 12px 30px -10px rgba(15,23,42,.5); transition: opacity .4s, transform .4s; }
.app-toast.ok .bi { color: #4ade80; } .app-toast.err { background: #991b1b; }
.app-toast.hide { opacity: 0; transform: translateY(8px); }
@media (min-width: 992px) { .app-toasts { bottom: 24px; } }
.is-standalone .d-standalone-none { display: none !important; }

/* ---------- Hạng thành viên ---------- */
.plan-badge { font-weight: 600; border-radius: 999px; padding: .3em .7em; }
.plan-free { background: #f1f5f9; color: #475569; }
.plan-plus { background: var(--brand-50); color: var(--brand-600); border: 1px solid var(--brand-100); }
.plan-pro { background: linear-gradient(135deg, #f59e0b, #ef4444); color: #fff; }
.perk-list { list-style: none; padding: 0; margin: 0 0 1rem; font-size: .9rem; }
.perk-list li { display: flex; gap: .5rem; padding: .22rem 0; }
.perk-list li .bi { color: var(--brand); flex: none; margin-top: .1rem; }
.perk-list li.main { font-weight: 600; }
.plans-table th, .plans-table td { text-align: center; vertical-align: middle; }
.plans-table td:first-child, .plans-table th:first-child { text-align: left; }
.plans-table .cur { background: var(--brand-50); }
.price-card .per { font-size: .8rem; color: var(--muted); }
/* link theo màu thương hiệu (Bootstrap dùng --bs-link-color-rgb cố định) */
a:not(.btn):not(.nav-link):not(.dropdown-item):not(.navbar-brand) { color: var(--brand); }
a:not(.btn):not(.nav-link):not(.dropdown-item):not(.navbar-brand):hover { color: var(--brand-600); }
.text-reset { color: inherit !important; }
/* ---------- Admin: tổng quan ---------- */
.delta { font-weight: 600; } .delta.up { color: #16a34a; } .delta.down { color: #dc2626; }
.insight-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; margin-top: .45rem; }
.stat-project { border-left: 3px solid var(--brand); }
.first-bonus { max-width: 760px; display: flex; gap: .6rem; align-items: center; justify-content: center; padding: .75rem 1rem;
  border-radius: 14px; background: linear-gradient(90deg, #fef3c7, #fde68a); color: #78350f; }
.referral-card { background: linear-gradient(135deg, var(--brand-50), #fff); }
.flex-none { flex: none; }

/* ---------- Bảng gợi ý cài app ---------- */
.pwa-sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1045; background: #fff; border-radius: 20px 20px 0 0;
  padding: 1.1rem 1.1rem calc(1rem + env(safe-area-inset-bottom)); box-shadow: 0 -18px 40px -16px rgba(15, 23, 42, .35);
  transform: translateY(105%); transition: transform .25s ease; }
.pwa-sheet.show { transform: translateY(0); }
.pwa-sheet-close { position: absolute; top: .9rem; right: .9rem; }
.pwa-sheet-icon { width: 56px; height: 56px; border-radius: 14px; box-shadow: 0 6px 16px -8px rgba(15,23,42,.4); }
.pwa-shots { display: flex; gap: .5rem; overflow-x: auto; margin: .9rem 0 .2rem; }
.pwa-shots img { height: 150px; border-radius: 10px; border: 1px solid var(--line); flex: none; }
.pwa-sheet-perks { list-style: none; padding: 0; margin: .8rem 0 1rem; color: var(--muted); }
.pwa-sheet-perks li { display: flex; gap: .5rem; padding: .15rem 0; } .pwa-sheet-perks .bi { color: var(--brand); }
@media (min-width: 992px) { .pwa-sheet { left: auto; right: 1.5rem; bottom: 1.5rem; width: 380px; border-radius: 20px; } }
.pwa-arrow { position: fixed; left: 50%; bottom: calc(6px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 2000;
  font-size: 2.4rem; color: var(--brand); animation: pwa-bounce 1s infinite; pointer-events: none;
  text-shadow: 0 2px 6px rgba(255,255,255,.9); }
.pwa-arrow.top { top: 6px; bottom: auto; left: auto; right: 70px; transform: none; }
.pwa-arrow.top .bi::before { transform: rotate(180deg); display: inline-block; }
@keyframes pwa-bounce { 50% { margin-bottom: 10px; } }

/* hộp xác nhận (window.appConfirm) */
.app-confirm { border-radius: 18px; border: 0; }
.app-confirm-ic { width: 48px; height: 48px; margin: 0 auto 12px; border-radius: 50%; background: #fee2e2; color: #dc2626;
  display: flex; align-items: center; justify-content: center; font-size: 1.6rem; }

/* thanh gợi ý mở bằng trình duyệt thật (khi đang ở trong Zalo / Facebook) */
.inapp-bar { position: relative; z-index: 1035; display: flex; align-items: center; gap: .6rem; padding: .5rem .75rem;
  background: var(--brand); color: var(--on-brand, #fff); font-size: .82rem; line-height: 1.3; }
.inapp-bar .btn-light { font-weight: 600; padding: .25rem .8rem; }
.inapp-bar .btn-close { font-size: .7rem; }

/* khoá app (vân tay / Face ID) */
.app-lock { display: none; }
html.app-locked body > *:not(.app-lock):not(script) { visibility: hidden !important; }
html.app-locked .app-lock { display: flex; position: fixed; inset: 0; z-index: 3000; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--brand), var(--brand-600)); color: #fff; text-align: center; padding: 24px; }
.app-lock-box img { border-radius: 18px; box-shadow: 0 10px 30px -10px rgba(0,0,0,.5); }
.list-menu .list-switch { display: flex; align-items: center; gap: .8rem; padding: .7rem 1rem; margin: 0; cursor: pointer; width: 100%;
  border-top: 1px solid var(--line); font-weight: 500; }
.list-menu li:first-child .list-switch { border-top: 0; }
.list-menu .list-switch small { font-size: .75rem; }

/* nút hỗ trợ nổi (Zalo) */
.support-fab { position: fixed; right: 14px; bottom: calc(78px + env(safe-area-inset-bottom)); z-index: 1025; display: flex;
  align-items: center; gap: .4rem; height: 48px; padding: 0 14px 0 12px; border-radius: 999px; background: #0068ff; color: #fff !important;
  text-decoration: none; box-shadow: 0 8px 22px -6px rgba(0,104,255,.6); font-weight: 600; font-size: .9rem; transition: transform .15s; }
.support-fab:hover { transform: translateY(-2px); color: #fff !important; }
.support-fab.away { transform: translateX(calc(100% + 24px)); }
.support-fab i { font-size: 1.25rem; }
.support-fab-tag { font-size: .62rem; font-weight: 700; letter-spacing: .02em; background: rgba(255,255,255,.22); border-radius: 6px; padding: 1px 5px; }
body:not(.has-bottom-nav) .support-fab { bottom: calc(18px + env(safe-area-inset-bottom)); }
body.has-action-bar .support-fab { bottom: calc(150px + env(safe-area-inset-bottom)); }
@media (max-width: 575.98px) {
  .support-fab { width: 48px; padding: 0; justify-content: center; }
  .support-fab-text { display: none; }
  .support-fab-tag { position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%); background: #fff; color: #0068ff;
    box-shadow: 0 1px 4px rgba(0,0,0,.2); }
}
@media (min-width: 992px) { .support-fab, body.has-action-bar .support-fab { bottom: 24px; right: 24px; } }
html.app-locked .support-fab { display: none; }
@media print { .support-fab { display: none; } }
