:root {
  --primary: #333; --primary-ink: #fff; --accent: #999; --bg: #f6f6f6; --surface: #fff; --ink: #222; --muted: #666; --line: #e5e5e5;
  --hero: #333; --ok: #16a34a; --ok-bg: #dcfce7; --bad: #dc2626; --bad-bg: #fee2e2; --wait: #b45309; --wait-bg: #fef3c7; --busy: #1d4ed8; --busy-bg: #dbeafe;
  --radius: 14px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);
}
:root[data-dark="1"] { --ok-bg: rgba(22,163,74,.18); --bad-bg: rgba(220,38,38,.18); --wait-bg: rgba(180,83,9,.22); --busy-bg: rgba(29,78,216,.25); --ok: #4ade80; --bad: #f87171; --wait: #fbbf24; --busy: #93c5fd; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25); }
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: "IBM Plex Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); }
:root[data-dark="1"] a { color: var(--accent); }
h1, h2, h3 { line-height: 1.3; margin: 0 0 10px; }
h2 { font-size: 21px; } h3 { font-size: 16px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .center { text-align: center; }
.mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; letter-spacing: .02em; }
code { font-family: ui-monospace, Consolas, monospace; font-size: 12px; padding: 1px 6px; border-radius: 6px; background: color-mix(in srgb, var(--ink) 8%, transparent); }
.boot { padding: 80px 16px; text-align: center; color: var(--muted); }

/* header */
.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1080px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 20px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: var(--ink) !important; text-decoration: none; white-space: nowrap; }
.brand-emoji { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; background: var(--hero); font-size: 19px; }
.top nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.top nav a { padding: 7px 12px; border-radius: 9px; color: var(--muted) !important; text-decoration: none; font-weight: 500; white-space: nowrap; }
.top nav a:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.top nav a.active { color: var(--primary) !important; background: color-mix(in srgb, var(--primary) 12%, transparent); }
:root[data-dark="1"] .top nav a.active { color: var(--ink) !important; background: color-mix(in srgb, var(--primary) 45%, transparent); }
.top-right { display: flex; align-items: center; gap: 8px; }
.wallet-chip { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; padding: 5px 12px; border-radius: 10px; border: 1px solid var(--line); text-decoration: none; color: var(--ink) !important; }
.wallet-chip span { font-size: 11px; color: var(--muted); } .wallet-chip strong { font-size: 15px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--primary); color: var(--primary-ink) !important; font-weight: 700; text-decoration: none; }

.page { max-width: 1080px; margin: 0 auto; padding: 24px 16px 40px; min-height: calc(100vh - 140px); }
.foot { max-width: 1080px; margin: 0 auto; padding: 18px 16px 28px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); }
.foot a { color: var(--muted); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 18px; border-radius: 10px; border: 1px solid transparent; background: var(--primary); color: var(--primary-ink) !important; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; transition: filter .12s, transform .06s; white-space: nowrap; }
.btn:hover { filter: brightness(1.08); } .btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--ink) !important; border-color: var(--line); }
.btn.ghost:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.btn.light { background: #fff; color: #111 !important; }
.btn.outline-light { background: transparent; color: #fff !important; border-color: rgba(255,255,255,.6); }
.btn.danger-ghost { background: transparent; color: var(--bad) !important; border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.center { justify-content: center; }
.spacer { flex: 1; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); margin-bottom: 18px; min-width: 0; }
.card.soft { background: color-mix(in srgb, var(--surface) 70%, var(--bg)); box-shadow: none; }
.card.narrow { max-width: 460px; margin-left: auto; margin-right: auto; }
.card.narrow.wide-ish { max-width: 640px; }
.card.attention { border-color: color-mix(in srgb, var(--wait) 50%, transparent); background: color-mix(in srgb, var(--wait-bg) 45%, var(--surface)); }
.two-col { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.two-col > .card { margin-bottom: 0; }
@media (max-width: 800px) { .two-col { grid-template-columns: 1fr; } }
.big-emoji { font-size: 40px; line-height: 1; margin-bottom: 8px; }
.section-title { margin: 28px 0 14px; }

/* hero */
.hero { background: var(--hero); color: #fff; border-radius: 18px; padding: 26px 26px; display: flex; justify-content: space-between; align-items: center; gap: 18px; flex-wrap: wrap; box-shadow: var(--shadow); }
.hero-label { opacity: .85; font-size: 14px; }
.hero-amount { font-size: 36px; font-weight: 700; letter-spacing: -.01em; }
.hero-title { font-size: 26px; font-weight: 700; }
.hero-sub { opacity: .9; }

/* products */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.product { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow); transition: transform .12s; }
.product:hover { transform: translateY(-2px); }
.cover { aspect-ratio: 4 / 3; display: grid; place-items: center; font-size: 56px; }
.p-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.p-body h3 { font-size: 15px; margin: 0; }
.p-foot { margin-top: auto; padding-top: 12px; display: flex; justify-content: space-between; align-items: center; }
.price { font-size: 17px; }

/* forms */
.form { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; font-size: 14px; }
input, select { font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); width: 100%; min-width: 0; }
input:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 1px; border-color: var(--primary); }
input::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
.hint { font-weight: 400; font-size: 13px; color: var(--muted); }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin-top: 6px; }
.divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.money-input { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding-left: 14px; }
.money-input span { font-size: 20px; color: var(--muted); }
.money-input input { border: 0; font-size: 22px; font-weight: 600; padding: 10px 12px 10px 8px; background: transparent; }
.money-input:focus-within { border-color: var(--primary); outline: 2px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 1px; }
.money-input input:focus { outline: none; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font: inherit; font-size: 14px; padding: 6px 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.chip:hover { border-color: var(--primary); color: var(--primary); }

/* status */
.err { background: var(--bad-bg); color: var(--bad); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin: 6px 0; }
.err code { background: transparent; border: 1px solid currentColor; opacity: .8; }
.err-detail { font-size: 12px; opacity: .8; margin-top: 4px; }
.banner { border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; font-size: 14px; }
.banner.warn { background: var(--wait-bg); color: var(--wait); }
.banner.bad { background: var(--bad-bg); color: var(--bad); }
.banner.info { background: var(--busy-bg); color: var(--busy); }
.banner .fix { margin-top: 6px; color: var(--ink); }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.wait { background: var(--wait-bg); color: var(--wait); } .pill.busy { background: var(--busy-bg); color: var(--busy); }
.pill.mute { background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--muted); }
.bank-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: 0; }

/* top-up detail */
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.detail-head h2 { margin-bottom: 2px; }
.stepper { list-style: none; display: flex; padding: 0; margin: 18px 0 22px; counter-reset: s; }
.stepper li { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); position: relative; text-align: center; }
.stepper li::before { content: ""; position: absolute; top: 14px; left: -50%; width: 100%; height: 2px; background: var(--line); z-index: 0; }
.stepper li:first-child::before { display: none; }
.stepper li span { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 2px solid var(--line); font-weight: 700; position: relative; z-index: 1; }
.stepper li.done span { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.stepper li.done::before, .stepper li.now::before { background: var(--primary); }
.stepper li.now span { border-color: var(--primary); color: var(--primary); }
.stepper li.now { color: var(--ink); font-weight: 600; }
.stepper.failed li.now span { border-color: var(--bad); color: var(--bad); }
.transfer { border: 1px solid var(--line); border-radius: 14px; padding: 18px; background: color-mix(in srgb, var(--primary) 4%, var(--surface)); }
.transfer-head { display: flex; justify-content: space-between; align-items: center; font-weight: 600; margin-bottom: 12px; }
.timer { font-variant-numeric: tabular-nums; font-size: 14px; padding: 3px 10px; border-radius: 99px; background: var(--wait-bg); color: var(--wait); }
.acct { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.acct-bank { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.acct-no { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 24px; font-weight: 700; margin: 6px 0 2px; }
.acct-name { color: var(--muted); }
.exact { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 12px 0 8px; padding: 12px 16px; border-radius: 12px; background: var(--surface); border: 1px dashed color-mix(in srgb, var(--primary) 50%, var(--line)); }
.exact-amt { font-size: 26px; font-weight: 700; color: var(--primary); }
:root[data-dark="1"] .exact-amt { color: var(--accent); }
.copy { font: inherit; font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.copy:hover { border-color: var(--primary); }
.slip-box { margin-top: 20px; }
.drop { display: block; border: 2px dashed var(--line); border-radius: 14px; padding: 22px; text-align: center; cursor: pointer; margin: 8px 0 12px; transition: border-color .12s; }
.drop:hover { border-color: var(--primary); }
.slip-preview { max-height: 220px; max-width: 100%; border-radius: 8px; margin-bottom: 6px; }
.status-block { text-align: center; padding: 20px 8px 8px; }
.status-block.ok h3 { color: var(--ok); } .status-block.bad h3 { color: var(--bad); }
.spinner { width: 36px; height: 36px; margin: 8px auto 14px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--primary); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.steps-list { padding-left: 20px; margin: 0 0 16px; } .steps-list li { margin-bottom: 6px; }
.mini-list { list-style: none; padding: 0; margin: 0; } .mini-list li { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }

/* history */
.tx-list { list-style: none; padding: 0; margin: 0; }
.tx-list li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); justify-content: space-between; }
.tx-list li:last-child { border-bottom: 0; }
.tx-icon { width: 34px; height: 34px; flex: none; border-radius: 10px; display: grid; place-items: center; background: color-mix(in srgb, var(--ink) 6%, transparent); }
.tx-main { flex: 1; min-width: 0; }
.plus { color: var(--ok); } .minus { color: var(--ink); }
.big-num { font-size: 22px; }
.balance-line { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 14px; border-radius: 12px; background: color-mix(in srgb, var(--primary) 8%, var(--surface)); margin: 10px 0; }
.balance-line strong { font-size: 24px; }

/* admin */
.admin-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted) !important; text-decoration: none; font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.active { color: var(--ink) !important; border-bottom-color: var(--primary); }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat-v { font-size: 22px; font-weight: 700; margin-top: 2px; }
.kv { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 8px 12px; margin: 0; }
.kv dt { color: var(--muted); font-size: 14px; } .kv dd { margin: 0; overflow-wrap: anywhere; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.toolbar select { width: auto; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.num { text-align: right; white-space: nowrap; }
td.actions { white-space: nowrap; text-align: right; } td.actions .btn { margin-left: 6px; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; padding: 11px 18px; border-radius: 12px; background: #1f2937; color: #fff; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.2); transition: all .2s; max-width: calc(100% - 32px); z-index: 50; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { background: #b91c1c; } #toast.warn { background: #b45309; }

@media (max-width: 640px) {
  .top-in { flex-wrap: wrap; gap: 10px; }
  .top nav { order: 3; flex-basis: 100%; }
  .top-right { margin-left: auto; }
  .hero { padding: 20px; } .hero-amount { font-size: 30px; }
  .card { padding: 18px; }
  .acct-no { font-size: 20px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .cover { font-size: 44px; }
}
