:root {
  --bg: #f3f6f4;
  --bg-2: #e7f1ec;
  --card: #ffffff;
  --text: #15221d;
  --muted: #5f6e68;
  --line: #e1e8e4;
  --brand: #0f765c;
  --brand-2: #14956f;
  --brand-dark: #0a5543;
  --brand-soft: #e3f3ec;
  --brand-ink: #ffffff;
  --accent: #f2a93b;
  --accent-soft: #fff3de;
  --zalo: #0068ff;
  --error-bg: #fdecec;
  --error: #a4262c;
  --warn-bg: #fff6e0;
  --info-bg: #e9f4f0;
  --shadow: 0 1px 2px rgba(16, 40, 32, .05), 0 8px 24px rgba(16, 40, 32, .07);
  --shadow-lg: 0 12px 32px rgba(10, 85, 67, .22);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1412;
    --bg-2: #122019;
    --card: #17201d;
    --text: #e8efec;
    --muted: #9aaaa4;
    --line: #26332e;
    --brand: #22a37f;
    --brand-2: #2bbd93;
    --brand-dark: #0d5a47;
    --brand-soft: #16302a;
    --accent: #f5b953;
    --accent-soft: #3a2f14;
    --error-bg: #3a1c1e;
    --error: #ffb3b6;
    --warn-bg: #3a2f14;
    --info-bg: #16302a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }
body {
  background: linear-gradient(180deg, var(--bg-2) 0, var(--bg) 320px) no-repeat, var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

a { color: var(--brand); }

.ic { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: linear-gradient(120deg, var(--brand-dark), var(--brand) 60%, var(--brand-2));
  color: #fff;
  box-shadow: 0 2px 12px rgba(10, 85, 67, .18);
}
.topbar a { color: inherit; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 1.08rem; letter-spacing: -.01em; }
.brand img { border-radius: 9px; box-shadow: 0 0 0 2px rgba(255, 255, 255, .85); }
.user { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; min-width: 0; }
.user img { border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 2px rgba(255, 255, 255, .7); }
.user span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 9em; font-weight: 600; }
.topbar .link-btn { color: rgba(255, 255, 255, .85); }

.wrap { max-width: 560px; margin: 0 auto; padding: 16px; }
.wrap.narrow { max-width: 440px; padding-top: 48px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.center { text-align: center; }

h1 { font-size: 1.45rem; line-height: 1.3; margin: 0 0 14px; }
.h2 { font-size: 1.2rem; }
.h3 { font-size: 1.05rem; margin: 0 0 8px; }
.accent { color: var(--accent); }

.steps { padding-left: 1.2em; margin: 0 0 18px; }
.steps li { margin-bottom: 6px; }

.label { display: block; font-size: 0.85rem; color: var(--muted); margin: 0 0 6px; }
textarea {
  display: block;
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  resize: vertical;
}
textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; }

.row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.row .btn { flex: 1 1 auto; white-space: nowrap; }
.row .btn:not(.ghost) { flex-grow: 2; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 10px 18px;
  border: 0;
  border-radius: 12px;
  background: var(--brand);
  color: var(--brand-ink);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.btn:disabled { opacity: 0.6; cursor: default; }
.btn { gap: 8px; transition: transform .08s ease, box-shadow .15s ease, filter .15s ease; }
.btn:active:not(:disabled) { transform: translateY(1px) scale(.99); }
.btn.ghost { background: transparent; color: var(--brand); border: 1.5px solid var(--brand); }
.btn.zalo { width: 100%; min-height: 56px; background: var(--zalo); color: #fff; font-size: 1.08rem; border-radius: 14px; box-shadow: 0 10px 24px rgba(0, 104, 255, .28); }
.btn.warn { background: #b36b00; color: #fff; }
.btn.small { min-height: 38px; padding: 6px 14px; font-size: 0.9rem; }
.link-btn { background: none; border: 0; color: var(--muted); font: inherit; font-size: 0.85rem; cursor: pointer; padding: 4px; }

.result .short { font-size: 1.25rem; font-weight: 700; margin: 0; word-break: break-all; }
.tips { margin: 16px 0 0; padding-left: 1.2em; color: var(--muted); font-size: 0.9rem; }
.tips li { margin-bottom: 4px; }

.recent { list-style: none; margin: 0; padding: 0; }
.recent li { padding: 10px 0; border-top: 1px solid var(--line); }
.recent a { word-break: break-all; font-weight: 600; }
.recent .muted { display: block; }
.recent li:first-child { border-top: 0; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

.notice { border-radius: 12px; padding: 12px 14px; margin: 0 0 16px; background: var(--info-bg); word-break: break-word; }
.notice.error { background: var(--error-bg); color: var(--error); }
.notice.warn { background: var(--warn-bg); }

.install {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  background: var(--info-bg);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 16px;
}
.install div { flex: 1 1 200px; }
.install p { margin: 2px 0 0; font-size: 0.9rem; color: var(--muted); }

.guide h2 { font-size: 1.1rem; margin: 18px 0 8px; }
.guide ol { padding-left: 1.3em; }
.guide li { margin-bottom: 6px; }
.guide code { background: var(--bg); padding: 2px 6px; border-radius: 6px; word-break: break-all; }
.brand-link { text-decoration: none; color: inherit; }

.tabs { display: flex; gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 5px; margin-bottom: 16px; box-shadow: var(--shadow); }
.tab { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 46px; border: 0; border-radius: 12px; background: transparent; color: var(--muted); font: inherit; font-weight: 700; cursor: pointer; transition: background .15s ease, color .15s ease; }
.tab .ic { width: 20px; height: 20px; }
.tab.active { background: linear-gradient(120deg, var(--brand), var(--brand-2)); color: var(--brand-ink); box-shadow: 0 6px 14px rgba(15, 118, 92, .25); }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.tile { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow); overflow: hidden; }
.tile strong { font-size: 1.45rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tile-label { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.tile-ic { display: inline-flex; width: 36px; height: 36px; border-radius: 11px; align-items: center; justify-content: center; margin-bottom: 8px; }
.tile-ic.wait { background: var(--accent-soft); color: #b36b00; }
.tile-ic.paid { background: rgba(255, 255, 255, .2); color: #fff; }
.tile.highlight { background: linear-gradient(135deg, var(--brand), var(--brand-2)); border-color: transparent; color: #fff; box-shadow: var(--shadow-lg); }
.tile.highlight .tile-label { color: rgba(255, 255, 255, .85); }
.tile.highlight strong { color: #fff; }

.form { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.form .btn { margin-top: 8px; }
select, input {
  width: 100%; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; min-height: 46px;
}
select:focus, input:focus { outline: 2px solid var(--brand); outline-offset: 1px; }

.orders { list-style: none; margin: 0; padding: 0; }
.orders li { padding: 12px 0; border-top: 1px solid var(--line); }
.orders li:first-child { border-top: 0; }
.order-head { display: flex; justify-content: space-between; gap: 12px; }
.order-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.order-head strong { font-variant-numeric: tabular-nums; white-space: nowrap; }
.order-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 6px; }
.chip { font-size: 0.78rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--bg); color: var(--muted); }
.chip.src-tiktok { background: #111; color: #fff; }
.chip.stage-awaiting { background: var(--warn-bg); color: var(--text); }
.chip.stage-eligible { background: var(--info-bg); color: var(--brand); }
.chip.stage-paid { background: var(--brand); color: var(--brand-ink); }
.chip.stage-cancelled { text-decoration: line-through; }

table.admin { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.admin th, table.admin td { text-align: left; padding: 8px 6px; border-top: 1px solid var(--line); vertical-align: top; }
table.admin th { color: var(--muted); font-weight: 600; border-top: 0; }
.scroll-x { overflow-x: auto; }
.payout { border-top: 1px solid var(--line); padding: 14px 0; }
.payout:first-child { border-top: 0; }
.payout-head { display: flex; justify-content: space-between; gap: 10px; }
.payout-head strong { font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.payout .qr { display: block; width: 220px; max-width: 100%; margin: 10px 0; background: #fff; border-radius: 10px; }
.payout .pay-info { font-variant-numeric: tabular-nums; }
.payout.done { opacity: .8; }
.export-links { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.qr { max-width: 240px; background: #fff; border-radius: 12px; padding: 6px; margin-top: 10px; }
.inline { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.inline input { flex: 1 1 160px; }
.wrap.wide { max-width: 860px; }

.btn.big { width: 100%; min-height: 58px; font-size: 1.1rem; }
.quick-steps { padding-left: 1.2em; margin: 0 0 14px; }
.quick-steps li { margin-bottom: 4px; }
.manual { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.manual summary { cursor: pointer; color: var(--muted); font-size: 0.9rem; padding: 4px 0; }
.manual[open] summary { margin-bottom: 8px; }
.lead { margin: 0 0 12px; }
#manualBox { display: grid; gap: 8px; margin-top: 12px; }
#manualBox[hidden] { display: none; }
#payoutBox .form { margin-top: 10px; }
.site-footer { margin: 20px 0 8px; }
.site-footer p { margin: 4px 0; }
.guide details.manual p { margin: 6px 0 4px; }
.contact-list { list-style: none; padding: 0; }
.contact-list li { margin-bottom: 8px; }
.site-footer a { white-space: nowrap; }
.guide > h2:first-child { margin-top: 0; }

/* ---- Giao diện 0.5.8 ---- */
.loading { padding: 36px 20px; }
.spinner { display: inline-block; width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--brand-soft); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.hero {
  position: relative;
  overflow: hidden;
  border-radius: 24px;
  padding: 26px 22px 22px;
  margin-bottom: 16px;
  color: #fff;
  background:
    radial-gradient(circle at 110% -10%, rgba(242, 169, 59, .55) 0, rgba(242, 169, 59, 0) 45%),
    radial-gradient(circle at -20% 120%, rgba(255, 255, 255, .18) 0, rgba(255, 255, 255, 0) 40%),
    linear-gradient(145deg, var(--brand-dark), var(--brand) 55%, var(--brand-2));
  box-shadow: var(--shadow-lg);
}
.hero h1 { font-size: 1.9rem; line-height: 1.15; letter-spacing: -.02em; margin: 14px 0 10px; font-weight: 800; }
.hero .hl { color: #ffd27a; white-space: nowrap; }
.hero-sub { margin: 0 0 18px; color: rgba(255, 255, 255, .9); }
.hero-badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px 5px 8px; border-radius: 999px; background: rgba(255, 255, 255, .16); font-size: .85rem; font-weight: 600; }
.hero-badge .ic { width: 18px; height: 18px; }
.perks { list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 0; margin: 0 0 20px; }
.perks li { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 12px 6px; border-radius: 14px; background: rgba(255, 255, 255, .12); font-size: .82rem; font-weight: 600; line-height: 1.25; }
.perks .ic { width: 24px; height: 24px; color: #ffd27a; }
.hero .btn.zalo { background: #fff; color: var(--zalo); box-shadow: 0 10px 24px rgba(0, 0, 0, .18); }
.hero-note { margin: 12px 0 0; font-size: .8rem; text-align: center; color: rgba(255, 255, 255, .8); }
.hero-note a { color: #fff; }

.buy { padding: 0; overflow: hidden; }
.buy-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px; background: linear-gradient(120deg, var(--brand-soft), var(--card)); border-bottom: 1px solid var(--line); }
.buy-icon { display: inline-flex; width: 44px; height: 44px; border-radius: 14px; align-items: center; justify-content: center; color: #fff; background: linear-gradient(135deg, var(--brand), var(--brand-2)); box-shadow: 0 6px 14px rgba(15, 118, 92, .3); flex: none; }
.buy-title { font-size: 1.12rem; margin: 0; line-height: 1.3; }
.buy-sub { margin: 2px 0 0; font-size: .88rem; color: var(--muted); }
.buy #manualBox { margin: 0; padding: 18px 20px 6px; gap: 12px; }
.paste-field { position: relative; }
.paste-field .ic { position: absolute; left: 14px; top: 14px; color: var(--muted); pointer-events: none; }
.paste-field textarea { padding: 13px 14px 13px 46px; min-height: 92px; border-radius: 14px; border: 1.5px dashed var(--line); background: var(--bg); font-size: 1rem; }
.paste-field textarea:focus { border-style: solid; border-color: var(--brand); outline: 3px solid var(--brand-soft); outline-offset: 0; }
.btn.cta { background: linear-gradient(120deg, var(--brand), var(--brand-2)); border-radius: 14px; box-shadow: 0 10px 22px rgba(15, 118, 92, .28); font-weight: 800; letter-spacing: .01em; }
.flow { list-style: none; margin: 8px 20px 0; padding: 0; display: grid; gap: 2px; counter-reset: flow; }
.flow li { counter-increment: flow; display: flex; align-items: center; gap: 12px; padding: 9px 0; font-size: .92rem; border-top: 1px dashed var(--line); }
.flow li:first-child { border-top: 0; }
.flow-ic { position: relative; display: inline-flex; width: 34px; height: 34px; border-radius: 11px; align-items: center; justify-content: center; color: var(--brand); background: var(--brand-soft); flex: none; }
.flow-ic .ic { width: 19px; height: 19px; }
.flow-ic::after { content: counter(flow); position: absolute; top: -5px; right: -5px; width: 17px; height: 17px; border-radius: 50%; background: var(--accent); color: #3b2a00; font-size: .68rem; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.hint { display: flex; gap: 10px; align-items: flex-start; margin: 10px 20px 18px; padding: 10px 12px; border-radius: 12px; background: var(--accent-soft); font-size: .85rem; color: var(--text); }
.hint .ic { width: 19px; height: 19px; color: #b36b00; margin-top: 1px; }

.empty { text-align: center; padding: 10px 0 4px; }
.empty p { margin: 4px 0; }
.empty-ic { display: inline-flex; width: 52px; height: 52px; border-radius: 16px; align-items: center; justify-content: center; background: var(--brand-soft); color: var(--brand); margin-bottom: 6px; }
.empty-ic .ic { width: 26px; height: 26px; }
.h3.with-ic { display: flex; align-items: center; gap: 8px; }
.h3.with-ic .ic { color: var(--brand); width: 20px; height: 20px; }
.member { margin-top: 4px; }

.install { box-shadow: var(--shadow); border: 1px solid var(--line); background: var(--card); }
.notice { box-shadow: var(--shadow); }
.guide h1 { font-size: 1.5rem; }

/* ---- Chuông thông báo admin ---- */
.topbar-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.bell { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border: 0; border-radius: 12px; background: rgba(255, 255, 255, .16); color: #fff; cursor: pointer; flex: none; }
.bell .ic { width: 22px; height: 22px; }
.bell.alert { background: #fff; color: var(--brand-dark); box-shadow: 0 0 0 0 rgba(255, 210, 122, .9); animation: bellPulse 1.8s ease-out infinite; }
.bell.alert .ic { animation: bellRing 2.4s ease-in-out infinite; transform-origin: 50% 10%; }
.bell-badge { position: absolute; top: -5px; right: -5px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px; background: #e5383b; color: #fff; font-size: .72rem; font-weight: 800; line-height: 20px; text-align: center; box-shadow: 0 0 0 2px var(--brand); }
@keyframes bellPulse { 0% { box-shadow: 0 0 0 0 rgba(255, 210, 122, .85); } 70% { box-shadow: 0 0 0 10px rgba(255, 210, 122, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 210, 122, 0); } }
@keyframes bellRing { 0%, 70%, 100% { transform: rotate(0); } 75% { transform: rotate(14deg); } 80% { transform: rotate(-12deg); } 85% { transform: rotate(8deg); } 90% { transform: rotate(-5deg); } }
@media (prefers-reduced-motion: reduce) { .bell.alert, .bell.alert .ic { animation: none; } }
.bell-panel { position: fixed; z-index: 20; top: calc(62px + env(safe-area-inset-top, 0px)); right: 12px; width: min(380px, calc(100vw - 24px)); max-height: min(70vh, 560px); overflow: auto; background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 18px 48px rgba(10, 40, 30, .28); }
.bell-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); }
.bell-list { list-style: none; margin: 0; padding: 6px; }
.bell-item { border-radius: 12px; }
.bell-link { display: flex; gap: 10px; padding: 10px; color: inherit; text-decoration: none; border-radius: 12px; }
a.bell-link:hover { background: var(--bg); }
.bell-link .ic { margin-top: 2px; }
.bell-link strong { display: block; font-size: .95rem; line-height: 1.35; }
.bell-link p { margin: 2px 0 0; font-size: .84rem; color: var(--muted); }
.bell-item.action .ic { color: #e5383b; }
.bell-item.warn .ic { color: #b36b00; }
.bell-item.info .ic { color: var(--brand); }
.bell-item.action { background: var(--error-bg); margin-bottom: 4px; }
.bell-item.warn { background: var(--warn-bg); margin-bottom: 4px; }
.bell-item.fresh { background: var(--brand-soft); margin-bottom: 4px; }
.brand { white-space: nowrap; flex: none; }
.link-btn { white-space: nowrap; }
@media (max-width: 440px) { .topbar-right #userName { display: none; } }
.push-bar { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; padding: 10px 12px; border-radius: 14px; background: var(--accent-soft); border: 1px solid rgba(242, 169, 59, .35); }
.push-bar .ic { color: #b36b00; }
.push-bar p { flex: 1; margin: 0; font-size: .88rem; line-height: 1.35; }
.push-bar .btn.small { flex: none; }
.h3.sub { font-size: .95rem; margin: 18px 0 8px; color: var(--muted); }
.order-item { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.stage-pending { background: var(--bg); }
.chip { white-space: nowrap; }
.sheet-backdrop { position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-end; justify-content: center; background: rgba(10, 30, 24, .45); padding: 12px; }
.sheet { width: min(480px, 100%); background: var(--card); color: var(--text); border-radius: 22px; padding: 20px 18px calc(18px + env(safe-area-inset-bottom, 0px)); box-shadow: 0 -10px 40px rgba(0, 0, 0, .25); display: grid; gap: 10px; }
.sheet p { margin: 0; }
.sheet .h3 { margin: 0; }
.withdraw-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.withdraw-amount { display: block; font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; color: var(--brand); font-variant-numeric: tabular-nums; }
.withdraw .btn.cta { min-width: 130px; }
.withdraw #withdrawStatus { margin: 10px 0 0; }
.withdraw-history { list-style: none; margin: 8px 0 0; padding: 0; font-size: .85rem; color: var(--muted); }
.withdraw-history li { padding: 4px 0; border-top: 1px dashed var(--line); }
