:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #0f1b24;
  --muted: #5f6f7a;
  --line: #e3e8ec;
  --line-2: #eef2f5;
  --accent: #0d7a68;
  --accent-2: #0a6355;
  --accent-ink: #ffffff;
  --accent-soft: #e3f3ef;
  --side: #0e1a22;
  --side-text: #b9c6cf;
  --side-active: #18303b;
  --ok: #138a4a; --ok-soft: #e4f5eb;
  --warn: #a35f00; --warn-soft: #fff3df;
  --bad: #c0362c; --bad-soft: #fde9e7;
  --idle: #6b7a85; --idle-soft: #eef1f3;
  --input: #ffffff;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1117; --panel: #121a22; --text: #e3eaef; --muted: #8fa0ab; --line: #243039; --line-2: #1a242c;
    --accent: #2fb9a0; --accent-2: #4fcdb5; --accent-ink: #04221c; --accent-soft: #11302b;
    --side: #080d12; --side-text: #93a4b0; --side-active: #13232c;
    --ok: #4cc782; --ok-soft: #10291c; --warn: #e3a648; --warn-soft: #2d2210; --bad: #f07b70; --bad-soft: #321614;
    --idle: #8fa0ab; --idle-soft: #1b252d; --input: #0d141a; --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14.5px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif; }
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.inline { width: 15px; height: 15px; vertical-align: -3px; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
h2 { font-size: 16px; }
h3 { font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: "Cascadia Mono", ui-monospace, Consolas, monospace; font-size: 13.5px; }
.right { text-align: right; }
.error { color: var(--bad); min-height: 1em; margin: 8px 0 0; font-size: 13.5px; }

/* nút, ô nhập */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; font: inherit; font-weight: 600; cursor: pointer;
  border-radius: 8px; padding: 8px 14px; border: 1px solid var(--line); background: var(--panel); color: var(--text); white-space: nowrap; text-decoration: none !important; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { padding: 5px 9px; font-size: 13px; font-weight: 500; }
.btn.lg { padding: 11px 18px; font-size: 15px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 7px; border: 1px solid transparent;
  background: transparent; color: var(--muted); cursor: pointer; font-size: 20px; line-height: 1; }
.icon-btn:hover { background: var(--line-2); color: var(--text); border-color: var(--line); }
.icon-btn.del:hover { color: var(--bad); }
button:focus-visible, a:focus-visible, input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 12px; }
input, select { font: inherit; font-weight: 400; color: var(--text); background: var(--input); border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px; width: 100%; min-width: 0; }
.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; color: var(--text); }
.check input { width: auto; }
.actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.span2 { grid-column: 1 / -1; }
.suffix-wrap { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; background: var(--input); overflow: hidden; }
.suffix-wrap input { border: 0; border-radius: 0; }
.suffix-wrap span { padding: 0 11px; color: var(--muted); font-weight: 500; white-space: nowrap; font-size: 13.5px; }
.inline-row { display: flex; gap: 8px; }
.inline-row input { flex: 1; }

/* đăng nhập */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-side { background: var(--side); color: #dbe5ea; padding: 56px 64px; display: flex; flex-direction: column; justify-content: center; gap: 18px; }
.login-side h1 { font-size: 30px; color: #fff; max-width: 480px; }
.login-side p { color: var(--side-text); max-width: 480px; margin: 0; }
.ticks { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 10px; }
.ticks li { display: flex; gap: 10px; align-items: center; color: #dbe5ea; }
.ticks svg { color: #3fc7ac; }
.login-card { align-self: center; justify-self: center; width: min(380px, calc(100vw - 32px)); background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 28px; box-shadow: var(--shadow); }
.login-card h2 { font-size: 22px; margin-bottom: 18px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; color: #fff; }
.brand small { display: block; font-size: 11.5px; font-weight: 500; color: var(--side-text); letter-spacing: .04em; }
.brand.big { font-size: 19px; }
.logo-mark { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, #1aa38a, #0d6e5e); display: grid; place-items: center;
  font-weight: 800; color: #fff; font-size: 17px; }

/* khung chính */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-text); display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
.side .brand { padding: 2px 8px 18px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.side-nav a { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 8px; color: var(--side-text); font-weight: 500; text-decoration: none; }
.side-nav a:hover { background: var(--side-active); color: #fff; }
.side-nav a.active { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 #2fb9a0; }
.side-group { margin: 16px 10px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #6d7f8b; }
.side-foot { border-top: 1px solid #1d2b34; padding-top: 12px; }
.who { display: flex; gap: 10px; align-items: center; padding: 0 6px 10px; }
.who b { color: #fff; display: block; font-size: 14px; }
.who small { color: var(--side-text); font-size: 12px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #1f3a46; color: #fff; display: grid; place-items: center; font-weight: 700; text-transform: uppercase; }
.side-actions { display: flex; gap: 4px; }
.side-actions .btn { color: var(--side-text); }
.side-actions .btn:hover { color: #fff; background: var(--side-active); }
.main { min-width: 0; padding: 0 28px 40px; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 22px 0 18px; }
.topbar h1 { font-size: 22px; flex: 1; }
.top-right { display: flex; gap: 8px; align-items: center; }
.banner { border-radius: 9px; padding: 10px 14px; margin-bottom: 14px; font-size: 14px; }
.banner.warn { background: var(--warn-soft); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.panel > h2, .panel > h3 { margin-bottom: 12px; }
.panel h2 + .form-grid { margin-top: 4px; }
.panel-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.panel-head h2 { flex: 1; }
.search { flex: 1; min-width: 200px; display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; background: var(--input); color: var(--muted); }
.search input { border: 0; padding: 8px 0; background: transparent; }
.search input:focus { outline: none; }
.panel-head select { width: auto; }

/* thẻ số liệu */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat small { color: var(--muted); font-size: 12.5px; display: block; }
.stat b { font-size: 22px; font-weight: 700; display: block; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .bar { height: 5px; background: var(--line-2); border-radius: 9px; margin-top: 8px; overflow: hidden; }
.stat .bar i { display: block; height: 100%; background: var(--accent); border-radius: 9px; }

/* bảng */
.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table.grid { width: 100%; border-collapse: collapse; }
table.grid th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--line-2); }
table.grid th:first-child { border-top-left-radius: 8px; }
table.grid th:last-child { border-top-right-radius: 8px; }
table.grid td { padding: 11px 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.grid tbody tr:hover { background: color-mix(in srgb, var(--line-2) 60%, transparent); }
table.grid td.right { white-space: nowrap; }
.hn { font-weight: 600; }
.note { color: var(--muted); font-size: 12.5px; }
.sub { color: var(--muted); font-size: 12px; }
.copyable { display: inline-flex; align-items: center; gap: 4px; }
.copy-btn { border: 0; background: none; padding: 2px; color: var(--muted); cursor: pointer; border-radius: 5px; display: inline-flex; }
.copy-btn svg { width: 15px; height: 15px; }
.copy-btn:hover { color: var(--accent); background: var(--accent-soft); }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 3px 10px; border-radius: 99px; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.idle { background: var(--idle-soft); color: var(--idle); }
.empty { text-align: center; padding: 36px 10px 20px; color: var(--muted); }
.empty svg { width: 36px; height: 36px; opacity: .5; }
.empty p { margin: 8px 0 14px; }

/* gói */
.current-plan { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: 18px; align-items: center; }
.current-plan small { color: var(--muted); display: block; font-size: 12.5px; }
.current-plan b { font-size: 18px; }
.months { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 4px; gap: 4px; margin: 4px 0 14px; flex-wrap: wrap; }
.months button { border: 0; background: none; font: inherit; font-weight: 600; padding: 7px 14px; border-radius: 7px; color: var(--muted); cursor: pointer; }
.months button.active { background: var(--accent); color: var(--accent-ink); }
.months em { font-style: normal; font-size: 11.5px; margin-left: 4px; color: var(--ok); }
.months button.active em { color: inherit; opacity: .85; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin-bottom: 14px; }
.plan { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow); position: relative; }
.plan.hot { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.plan .tag { position: absolute; top: -10px; right: 16px; background: var(--accent); color: var(--accent-ink); font-size: 11.5px; font-weight: 700; padding: 2px 9px; border-radius: 99px; }
.plan h3 { font-size: 17px; }
.plan .price { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.plan .price small { font-size: 13px; font-weight: 500; color: var(--muted); }
.plan ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 7px; flex: 1; align-content: start; }
.plan li { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.plan li svg { color: var(--ok); width: 16px; height: 16px; }
.plan .total { font-size: 13px; color: var(--muted); }
.plan .total s { margin-right: 6px; }

/* thanh toán QR */
.pay { display: grid; grid-template-columns: 220px 1fr; gap: 18px; align-items: start; }
.pay img { width: 220px; height: auto; min-height: 220px; border-radius: 10px; border: 1px solid var(--line); background: #fff; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 0; align-items: center; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; word-break: break-all; }
.waiting { display: flex; align-items: center; gap: 8px; color: var(--warn); font-weight: 600; margin-top: 12px; }
.spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: sp 0.8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }

/* tải agent, liên hệ */
.dl-hero { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.dl-hero > div:nth-child(2) { flex: 1; min-width: 240px; }
.dl-hero h2 { font-size: 18px; margin-bottom: 4px; }
.dl-hero p { margin: 0 0 4px; }
.dl-icon { width: 56px; height: 56px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.dl-icon svg { width: 28px; height: 28px; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 16px; }
.step { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.step span { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; margin-bottom: 8px; }
.step p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }
.contact-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.contact { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow); }
.contact .ic { width: 42px; height: 42px; border-radius: 11px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin-bottom: 6px; }
.contact b { font-size: 17px; }
.contact .btn { margin-top: 8px; align-self: flex-start; }

/* hộp thoại */
dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; background: var(--panel); color: var(--text); width: min(560px, calc(100vw - 24px)); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
dialog.wide { width: min(720px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(8, 14, 20, .55); }
.dlg { padding: 20px; }
.dlg-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.dlg-head h3 { flex: 1; font-size: 17px; }
.events { max-height: 380px; overflow: auto; font-size: 13.5px; }
.events div { padding: 8px 0; border-bottom: 1px solid var(--line-2); }
.secret { display: flex; gap: 6px; align-items: center; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; }

#toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(16px); opacity: 0; background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 9px; font-size: 14px; transition: opacity .2s, transform .2s; pointer-events: none; max-width: calc(100vw - 32px); z-index: 50; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--bad); color: #fff; }
.mobile-only { display: none; }
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 30; }

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .current-plan { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; }
  .login-side { padding: 32px 20px; }
  .login-side h1 { font-size: 24px; }
  .login-card { margin: 24px 0 40px; }
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .mobile-only { display: inline-flex; }
  .main { padding: 0 16px 32px; }
  .topbar { padding: 14px 0; }
  .topbar h1 { font-size: 19px; }
  .steps { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .pay { grid-template-columns: 1fr; }
  .pay img { margin: 0 auto; }
  /* bảng thành thẻ */
  .table-wrap { margin: 0; padding: 0; }
  table.grid thead { display: none; }
  table.grid, table.grid tbody, table.grid tr, table.grid td { display: block; width: 100%; }
  table.grid tr { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
  table.grid td { border: 0; padding: 3px 0; display: flex; gap: 8px; justify-content: space-between; align-items: center; }
  table.grid td[data-l]::before { content: attr(data-l); color: var(--muted); font-size: 12.5px; }
  table.grid td.right { justify-content: flex-end; border-top: 1px solid var(--line-2); margin-top: 6px; padding-top: 6px; }
}
@media (max-width: 520px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat b { font-size: 19px; }
  .current-plan { grid-template-columns: 1fr; gap: 10px; }
}
@media (prefers-reduced-motion: reduce) { #toast, .side { transition: none; } .spin { animation: none; } }
#dlgBody h3 { font-size: 15px; margin: 14px 0 6px; }
#dlgBody h3:first-child { margin-top: 0; }
#dlgBody .kv { margin-bottom: 10px; }
