:root {
  --bg: #f6f6f8;
  --card: #ffffff;
  --text: #1d1d22;
  --muted: #6b6b76;
  --line: #e6e6ec;
  --primary: #ee4d2d;      /* cam Shopee */
  --primary-2: #ff7337;
  --tiktok: #111111;
  --tiktok-accent: #fe2c55;
  --ok: #15a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0f12; --card: #19191e; --text: #ececf1; --muted: #9a9aa6; --line: #2a2a31;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--primary); text-decoration: none; }
h1, h2, h3 { margin: 0 0 12px; line-height: 1.25; }
h1 { font-size: 26px; } h2 { font-size: 20px; } h3 { font-size: 16px; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); font-size: 17px; }
.logo { font-size: 22px; }
nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
nav a { padding: 7px 12px; border-radius: 999px; color: var(--muted); font-weight: 500; white-space: nowrap; }
nav a.active { background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); }
.userbox { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; margin-left: auto; }

main { max-width: 1040px; margin: 0 auto; padding: 20px 16px 60px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.stack > * + * { margin-top: 16px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.hero {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; border: 0;
}
.hero h1 { color: #fff; }
.hero p { margin: 0 0 14px; opacity: .92; }

input, textarea, select {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--text); font: inherit;
}
textarea { resize: vertical; min-height: 84px; }
input:focus, textarea:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--primary) 40%, transparent); border-color: var(--primary); }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field + .field { margin-top: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 18px; border-radius: 10px; border: 1px solid transparent;
  background: var(--primary); color: #fff; font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { filter: brightness(1.05); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn.white { background: #fff; color: var(--primary); }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn.dark { background: var(--tiktok); color: #fff; }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn.ok { background: var(--ok); } .btn.bad { background: var(--bad); }
.btn.block { width: 100%; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.shopee { background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); }
.badge.tiktok { background: color-mix(in srgb, var(--tiktok-accent) 14%, transparent); color: var(--tiktok-accent); }
.badge.pending { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.badge.approved, .badge.paid { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.badge.completed { background: color-mix(in srgb, #2563eb 14%, transparent); color: #2563eb; }
.alert.bad { border-color: var(--bad); color: var(--bad); font-weight: 500; }
.badge.cancelled, .badge.rejected { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }

.stat { padding: 16px; }
.stat .k { font-size: 13px; color: var(--muted); }
.stat .v { font-size: 22px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat.main .v { color: var(--primary); }

.result { border: 2px dashed var(--primary); }
.linkbox { word-break: break-all; font-family: ui-monospace, Consolas, monospace; font-size: 13px; background: var(--bg); padding: 10px; border-radius: 8px; }

.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.steps li { counter-increment: s; padding-left: 40px; position: relative; }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px;
}

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td input, td select { padding: 6px 8px; font-size: 13px; min-width: 90px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs button { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; font: inherit; }
.tabs button.active { background: var(--text); color: var(--card); border-color: var(--text); }

.auth { max-width: 400px; margin: 30px auto; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--text); color: var(--card); padding: 10px 18px; border-radius: 10px; font-weight: 500;
  box-shadow: 0 6px 24px rgba(0,0,0,.2); z-index: 100; max-width: calc(100% - 32px);
}
.toast.err { background: var(--bad); color: #fff; }

@media (max-width: 640px) {
  .userbox #userName { display: none; }
  /* Menu xuống hàng riêng, chia đều — tránh bị logo đẩy khuất "Đơn hàng", "Ví" */
  .topbar { gap: 8px 12px; padding: 8px 12px; }
  nav { order: 3; flex: 1 1 100%; overflow: visible; }
  nav { flex-wrap: wrap; gap: 4px; }
  nav a { flex: 1 0 auto; text-align: center; padding: 7px 8px; font-size: 14px; }
  h1 { font-size: 22px; }
  .card { padding: 16px; }
}

/* Hộp mã VietQR chuyển tiền */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal { width: 100%; max-width: 420px; max-height: 92vh; overflow: auto; }
.qrbox { background: #fff; border-radius: 12px; padding: 8px; margin: 0 auto 8px; width: 260px; max-width: 100%; }
.qrbox svg { display: block; width: 100%; height: auto; }
.kv { width: 100%; border-collapse: collapse; }
.kv td { padding: 6px 4px; border-top: 1px solid var(--line); vertical-align: middle; }
.kv td:first-child { color: var(--muted, #6b7280); white-space: nowrap; }
.kv td:last-child { text-align: right; }

/* SP hoàn cao */
.hot-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.hot-card { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.hot-img { position: relative; aspect-ratio: 1 / 1; background: var(--bg); display: flex; align-items: center; justify-content: center; font-size: 48px; }
.hot-img.noimg { aspect-ratio: 2 / 1; font-size: 34px; }
.hot-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hot-note { position: absolute; top: 8px; left: 8px; background: var(--primary); color: #fff; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 999px; }
.hot-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.hot-body .btn { margin-top: auto; }
.hot-name { font-weight: 600; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hot-cb { font-size: 18px; font-weight: 700; color: var(--ok, #16a34a); }
.hot-price { font-size: 17px; font-weight: 700; color: var(--primary); }
.hot-meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 640px) { .hot-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; } .hot-body { padding: 10px; } .hot-cb { font-size: 16px; } }

/* Hướng dẫn */
.guide-list { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
.faq { border-top: 1px solid var(--line); padding: 10px 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq div { margin-top: 8px; color: var(--muted); line-height: 1.55; }

/* Lịch sử rút tiền */
.wd-list { display: flex; flex-direction: column; gap: 12px; }
.wd-item { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--warn); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.wd-item.paid { border-left-color: var(--ok); }
.wd-item.rejected { border-left-color: var(--bad); }
.wd-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.wd-amt { font-size: 20px; font-weight: 700; }
.wd-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.wd-steps li { position: relative; padding-left: 22px; display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; opacity: .55; }
.wd-steps li::before { content: ''; position: absolute; left: 2px; top: 5px; width: 8px; height: 8px; border-radius: 50%; border: 2px solid var(--line); background: var(--card); }
.wd-steps li.done, .wd-steps li.now, .wd-steps li.bad { opacity: 1; }
.wd-steps li.done::before { background: var(--ok); border-color: var(--ok); }
.wd-steps li.now { font-weight: 500; }
.wd-steps li.now::before { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 35%, transparent); }
.wd-steps li.bad { color: var(--bad); }
.wd-steps li.bad::before { background: var(--bad); border-color: var(--bad); }
.wd-stats { grid-template-columns: repeat(3, 1fr); gap: 8px; }
.wd-stats .stat { padding: 12px; }
.wd-stats .k { font-size: 12px; }
.wd-stats .v { font-size: 17px; }
