:root {
  --navy: #12263a;
  --navy-2: #1d3a56;
  --gold: #e3b04b;
  --gold-soft: #fbf3e2;
  --bg: #f5f3ef;
  --card: #ffffff;
  --ink: #1b1f24;
  --muted: #6b7280;
  --line: #e5e1d8;
  --ok: #1f8a5b;
  --bad: #c2410c;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: 'IBM Plex Sans Thai', system-ui, sans-serif; font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
#app { max-width: 520px; margin: 0 auto; min-height: 100vh; padding-bottom: 88px; }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.3; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; padding: 48px 20px; }
.page { padding: 16px; }
.hidden { display: none !important; }

/* หัวหน้า */
.hero { background: linear-gradient(160deg, var(--navy) 0%, var(--navy-2) 100%); color: #fff; padding: 24px 20px 56px; }
.hero .brand { font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); font-weight: 600; }
.hero h1 { font-size: 22px; margin-top: 4px; }
.hero p { margin: 4px 0 0; color: #c9d4df; font-size: 14px; }

/* บัตรสมาชิก */
.member-card { margin: -40px 16px 16px; background: var(--card); border-radius: 18px; box-shadow: 0 6px 24px rgba(18,38,58,.12); padding: 20px; text-align: center; }
.points { font-size: 44px; font-weight: 700; color: var(--navy); line-height: 1.1; }
.points-label { color: var(--muted); font-size: 14px; }
.qr-box { margin: 16px auto 4px; width: 220px; height: 220px; border-radius: 12px; border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; background: #fff; }
.qr-box img { width: 204px; height: 204px; }
.pill { display: inline-block; background: var(--gold-soft); color: #8a6414; border-radius: 999px; padding: 2px 10px; font-size: 13px; font-weight: 600; }

.card { background: var(--card); border-radius: var(--radius); border: 1px solid var(--line); padding: 16px; margin-bottom: 12px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.list-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: none; }

/* ฟอร์ม */
label { display: block; font-size: 14px; font-weight: 500; margin: 12px 0 4px; }
input, select, textarea { width: 100%; font: inherit; padding: 12px; border: 1px solid #d4cfc4; border-radius: 10px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); border-color: transparent; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; margin-top: 16px; }
.check input { width: 20px; height: 20px; margin-top: 2px; flex: none; }

button, .btn { font: inherit; font-weight: 600; border: none; border-radius: 12px; padding: 12px 16px; cursor: pointer; background: var(--navy); color: #fff; display: inline-block; text-align: center; text-decoration: none; }
button:disabled { opacity: .45; cursor: not-allowed; }
.btn-block { display: block; width: 100%; margin-top: 16px; }
.btn-gold { background: var(--gold); color: var(--navy); }
.btn-ghost { background: transparent; color: var(--navy); border: 1px solid #cfc8b8; }
.btn-sm { padding: 6px 12px; font-size: 14px; border-radius: 9px; }
.btn-danger { background: var(--bad); }
.big-actions { display: grid; gap: 12px; margin-top: 8px; }
.big-actions button { padding: 22px 16px; font-size: 18px; border-radius: 16px; }

/* แถบเมนูล่าง */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line); display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.tabbar .inner { display: flex; width: 100%; max-width: 520px; }
.tabbar button { flex: 1; background: none; color: var(--muted); border-radius: 0; padding: 12px 4px; font-size: 13px; font-weight: 500; }
.tabbar button.active { color: var(--navy); font-weight: 700; box-shadow: inset 0 3px 0 var(--gold); }

.subtabs { display: flex; gap: 6px; overflow-x: auto; padding: 12px 16px 0; }
.subtabs button { background: #fff; color: var(--ink); border: 1px solid var(--line); padding: 8px 14px; border-radius: 999px; font-size: 14px; white-space: nowrap; font-weight: 500; }
.subtabs button.active { background: var(--navy); color: #fff; border-color: var(--navy); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.stat .v { font-size: 24px; font-weight: 700; color: var(--navy); }
.stat .l { font-size: 13px; color: var(--muted); }

.plus { color: var(--ok); font-weight: 600; }
.minus { color: var(--bad); font-weight: 600; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #eef2f6; color: var(--navy-2); font-weight: 600; }
.badge.ok { background: #e3f4ec; color: var(--ok); }
.badge.warn { background: #fdf0e3; color: var(--bad); }

.coupon { text-align: center; }
.coupon img { width: 180px; height: 180px; }
.coupon .code { font-family: ui-monospace, monospace; font-size: 20px; letter-spacing: .15em; font-weight: 700; }
.done { opacity: .55; }

.result { text-align: center; padding: 24px 8px; }
.result .icon { font-size: 52px; line-height: 1; }

/* modal + toast */
.modal { position: fixed; inset: 0; background: rgba(10,20,30,.5); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.modal .sheet { background: #fff; width: 100%; max-width: 520px; border-radius: 18px 18px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
.modal .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 30; max-width: 90%; text-align: center; }
.toast.bad { background: var(--bad); }
.url { font-family: ui-monospace, monospace; font-size: 13px; word-break: break-all; background: #f3f1ec; padding: 8px; border-radius: 8px; }
