:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --line: #e6e8eb;
  --text: #16181b;
  --muted: #7a8089;
  --soft: #f0f1f3;
  --dark: #16181b;
  --green: #1f8a4c;
  --red: #c8372d;
  --radius: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: 'IBM Plex Sans Thai', system-ui, -apple-system, sans-serif;
  font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 480px; margin: 0 auto; padding: 16px 16px 48px; }
.wrap.wide { max-width: 1040px; }
.hidden { display: none !important; }

.top { display: flex; align-items: center; justify-content: space-between; padding: 8px 2px 18px; }
.brand { font-weight: 700; letter-spacing: .22em; font-size: 20px; }
.sub { color: var(--muted); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.center { text-align: center; }
h3 { font-size: 13px; color: var(--muted); font-weight: 600; letter-spacing: .06em; margin: 22px 4px 10px; text-transform: uppercase; }

label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--soft);
  border: 1px solid transparent; border-radius: 12px; padding: 12px 14px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: #c5c9cf; background: #fff; }
input.big { font-size: 26px; font-weight: 600; text-align: center; letter-spacing: .08em; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; border: 1px solid var(--line); background: #fff; color: var(--text);
  border-radius: 12px; padding: 11px 16px; cursor: pointer; transition: .15s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--dark); color: #fff; border-color: var(--dark); }
.btn.ghost { background: var(--soft); border-color: transparent; }
.btn.danger { color: var(--red); }
.btn.block { width: 100%; margin-top: 16px; padding: 14px; }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 10px; }
.btn-text { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: 6px; }
.btns { display: flex; gap: 10px; margin-top: 16px; }
.btns .btn { flex: 1; }

.seg { display: flex; background: var(--soft); border-radius: 12px; padding: 4px; margin-bottom: 4px; }
.seg button { flex: 1; border: 0; background: none; font: inherit; padding: 9px; border-radius: 9px; color: var(--muted); cursor: pointer; }
.seg button.active { background: #fff; color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.06); }

.hero .hello { color: var(--muted); font-size: 14px; }
.hero .name { font-size: 20px; font-weight: 600; }
.points { font-size: 56px; font-weight: 700; line-height: 1.05; margin-top: 14px; letter-spacing: -.02em; }
.points small { font-size: 16px; font-weight: 500; color: var(--muted); margin-left: 6px; letter-spacing: 0; }
.progress { height: 6px; background: var(--soft); border-radius: 6px; overflow: hidden; margin: 14px 0 8px; }
.progress div { height: 100%; background: var(--dark); border-radius: 6px; transition: width .4s; }
.hint { color: var(--muted); font-size: 13px; }

#qr { display: inline-block; padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: 14px; margin: 6px 0 10px; }
#qr img, #qr canvas { display: block; }
.phone { font-weight: 600; letter-spacing: .1em; }

.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .t { font-weight: 600; }
.row .s { color: var(--muted); font-size: 12.5px; }
.row .pts { font-weight: 700; white-space: nowrap; }
.pts.pos { color: var(--green); }
.pts.neg { color: var(--text); }
.row.voided .t, .row.voided .pts { text-decoration: line-through; opacity: .45; }
.row.click { cursor: pointer; }
.row.click:hover { background: #fafbfc; }
.empty { padding: 26px; text-align: center; color: var(--muted); }

.pill { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--soft); color: var(--muted); vertical-align: middle; }
.pill.ok { background: #e7f4ec; color: var(--green); }
.pill.red { background: #fbeceb; color: var(--red); }

.reward-cost { font-weight: 700; white-space: nowrap; text-align: right; }
.reward-cost small { display: block; font-weight: 500; color: var(--muted); font-size: 11.5px; }

.modal { position: fixed; inset: 0; background: rgba(15,17,20,.45); display: none; align-items: flex-end; justify-content: center; z-index: 50; padding: 16px; }
.modal.show { display: flex; }
.modal .sheet { background: #fff; width: 100%; max-width: 460px; border-radius: 20px; padding: 22px; max-height: 88vh; overflow: auto; animation: up .2s ease; }
.modal .sheet.wide { max-width: 720px; }
.modal h2 { margin: 0 0 6px; font-size: 18px; }
@media (min-width: 640px) { .modal { align-items: center; } }
@keyframes up { from { transform: translateY(20px); opacity: 0; } }
.confirm-msg { font-size: 16px; margin: 4px 0 0; }

#toast { position: fixed; top: 14px; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 99; pointer-events: none; padding: 0 16px; }
.toast { background: var(--dark); color: #fff; padding: 11px 18px; border-radius: 12px; font-weight: 500; box-shadow: 0 6px 20px rgba(0,0,0,.18); transition: .3s; max-width: 440px; }
.toast.ok { background: var(--green); }
.toast.err { background: var(--red); }
.toast.out { opacity: 0; transform: translateY(-8px); }

/* staff */
.shift-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.member-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.member-head .pts-now { font-size: 32px; font-weight: 700; }
#reader { width: 100%; border-radius: 14px; overflow: hidden; background: #000; }
#reader video { border-radius: 14px; }
.calc { text-align: center; color: var(--muted); margin-top: 8px; min-height: 22px; }
.calc b { color: var(--text); font-size: 18px; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.quick .btn { flex: 1 1 22%; padding: 9px 4px; }

/* admin */
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 16px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; border: 1px solid var(--line); background: #fff; font: inherit; padding: 8px 14px; border-radius: 99px; color: var(--muted); cursor: pointer; }
.tabs button.active { background: var(--dark); color: #fff; border-color: var(--dark); }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.stat .k { color: var(--muted); font-size: 12.5px; }
.stat .v { font-size: 26px; font-weight: 700; margin-top: 2px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input { flex: 1; min-width: 160px; }
.toolbar input[type=date] { flex: 0 1 170px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 14px; color: var(--text); font-size: 14px; }
.check input { width: auto; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 0 0 12px; }
.section-title h2 { margin: 0; font-size: 17px; }

/* coupons */
.coupon { display: flex; align-items: stretch; background: #fff; border: 1px solid var(--line); border-radius: 14px; margin-bottom: 10px; overflow: hidden; }
.coupon.dim { opacity: .5; }
.cbadge { flex: none; width: 78px; display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--dark); color: #fff; position: relative; padding: 10px 4px; }
.cbadge::after { content: ''; position: absolute; right: -1px; top: 6px; bottom: 6px; border-right: 2px dashed #fff; opacity: .9; }
.cbadge b { font-size: 20px; line-height: 1.1; letter-spacing: -.01em; }
.cbadge span { font-size: 10.5px; letter-spacing: .14em; opacity: .75; }
.cbody { flex: 1; min-width: 0; padding: 12px 14px; }
.cbody .t { font-weight: 600; }
.cbody .s { color: var(--muted); font-size: 12.5px; }
.cright { display: flex; align-items: center; padding: 0 12px 0 0; }
.stepper { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 10px 0 4px; }
.stepper button { width: 56px; height: 56px; border-radius: 50%; font-size: 26px; padding: 0; }
.stepper .num { font-size: 54px; font-weight: 700; min-width: 80px; text-align: center; line-height: 1; }
.cups-row { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-bottom: 4px; }
.cup { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); }
.cup.on { background: var(--dark); border-color: var(--dark); }
.home-link { color: inherit; text-decoration: none; display: block; }

/* บัตรสมาชิก */
.mcard {
  position: relative; overflow: hidden; color: #fff; border-radius: 22px; padding: 22px 22px 18px; margin-bottom: 14px;
  background: radial-gradient(120% 90% at 100% 0%, #3a3d43 0%, #1b1d21 55%, #121316 100%);
  box-shadow: 0 14px 30px rgba(18,19,22,.22);
}
.mcard::after { content: ''; position: absolute; right: -60px; bottom: -80px; width: 220px; height: 220px; border-radius: 50%; border: 1px solid rgba(255,255,255,.07); }
.mc-top { display: flex; justify-content: space-between; align-items: center; }
.mc-brand { font-weight: 700; letter-spacing: .28em; font-size: 15px; }
.mc-tier { font-size: 10.5px; letter-spacing: .2em; padding: 3px 10px; border: 1px solid rgba(255,255,255,.3); border-radius: 99px; opacity: .85; }
.mc-name { margin-top: 22px; font-size: 15px; opacity: .8; }
.mc-pts { font-size: 54px; font-weight: 700; line-height: 1.05; letter-spacing: -.02em; }
.mc-pts small { font-size: 15px; font-weight: 500; opacity: .6; margin-left: 6px; letter-spacing: 0; }
.mc-cups { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 16px; }
.mc-cups span { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid rgba(255,255,255,.35); }
.mc-cups span.on { background: #fff; border-color: #fff; }
.mc-bar { height: 6px; background: rgba(255,255,255,.15); border-radius: 6px; overflow: hidden; margin-top: 16px; }
.mc-bar div { height: 100%; background: #fff; border-radius: 6px; }
.mc-goal { font-size: 12.5px; opacity: .7; margin-top: 8px; }
.mc-foot { display: flex; justify-content: space-between; margin-top: 20px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.12); position: relative; z-index: 1; }
.mc-k { font-size: 10.5px; letter-spacing: .1em; opacity: .55; text-transform: uppercase; }
.mc-v { font-weight: 600; letter-spacing: .06em; font-size: 14px; }
.qr-card { cursor: pointer; padding-bottom: 14px; }
.qr-card #qr { margin-top: 0; }
#qrBig { display: inline-block; padding: 14px; border: 1px solid var(--line); border-radius: 16px; }
#qrBig img, #qrBig canvas { display: block; }
.modal.qr-full { align-items: center; }

/* หน้าบัตรแบบกระชับ: บัตร + QR อยู่ในจอเดียวบนมือถือ */
#viewMain { padding-top: 4px; }
.mcard { padding: 16px 18px 14px; border-radius: 20px; margin-bottom: 10px; }
.mc-name { margin-top: 12px; font-size: 14px; }
.mc-pts { font-size: 42px; }
.mc-pts small { font-size: 14px; }
.mc-cups { gap: 6px; margin-top: 10px; }
.mc-cups span { width: 15px; height: 15px; }
.mc-bar { margin-top: 10px; }
.mc-goal { margin-top: 6px; font-size: 12px; }
.mc-foot { margin-top: 12px; padding-top: 10px; }
.mc-v { font-size: 13.5px; }
.qr-card { padding: 12px 12px 10px; margin-bottom: 10px; }
.qr-card #qr { padding: 8px; margin: 0 0 6px; border-radius: 12px; }
.qr-card .hint { font-size: 12px; }
