:root {
  --purple: #5b2a86;
  --purple-2: #7b3fb3;
  --gold: #f5b301;
  --bg: #f6f3fa;
  --card: #ffffff;
  --text: #1f1530;
  --muted: #6d6380;
  --ok: #1a9e55;
  --danger: #c0392b;
  --radius: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Noto Sans Thai", "Leelawadee UI", "Sarabun", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; width: 100%; max-width: 480px; margin: 0 auto; padding: 12px 14px 20px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--purple); color: #fff;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
}
.brand { font-weight: 700; font-size: 1.15rem; display: flex; align-items: center; gap: 8px; }
.logo {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: var(--gold); color: var(--purple); font-weight: 800;
}
.lang {
  background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.4);
  border-radius: 999px; padding: 6px 14px; font-weight: 700; font-size: .9rem;
}
.view { display: none; }
.view.active { display: block; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.card { background: var(--card); border-radius: var(--radius); padding: 22px 18px; box-shadow: 0 2px 10px rgba(60,20,90,.08); }

.spinner {
  width: 42px; height: 42px; margin: 60px auto 16px; border-radius: 50%;
  border: 4px solid #e2d6ef; border-top-color: var(--purple); animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.today {
  display: flex; justify-content: space-between; align-items: center;
  background: linear-gradient(135deg, var(--purple), var(--purple-2)); color: #fff;
  border-radius: var(--radius); padding: 14px 16px;
}
.today .muted { color: rgba(255,255,255,.8); }
.today-total { font-size: 1.6rem; font-weight: 800; }
.today-count { font-size: 1rem; opacity: .9; }

.display {
  margin: 14px 0 10px; background: var(--card); border-radius: var(--radius);
  padding: 18px 16px; text-align: right; font-size: 2.8rem; font-weight: 800;
  overflow-x: auto; white-space: nowrap; box-shadow: inset 0 0 0 2px #e7def2;
}
.display .pi { color: var(--gold); margin-right: 8px; }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.keypad button {
  font-size: 1.8rem; font-weight: 700; padding: 16px 0; border-radius: 14px; border: 0;
  background: var(--card); color: var(--text); box-shadow: 0 2px 0 #dcd0ea;
  touch-action: manipulation; user-select: none;
}
.keypad button:active { transform: translateY(2px); box-shadow: none; }
.keypad .alt { background: #ece4f6; }
.keypad .primary, .btn.primary { background: var(--gold); color: #2b1b00; }
.keypad .wide2 { grid-column: span 1; }
.keypad #chargeBtn { grid-column: span 2; font-size: 1.4rem; }

.btn {
  display: block; width: 100%; margin-top: 12px; padding: 15px; font-size: 1.1rem; font-weight: 700;
  border-radius: 14px; border: 0; background: var(--purple); color: #fff;
}
.btn.ghost { background: transparent; color: var(--danger); border: 2px solid #f0d5d2; }
.btn:disabled { opacity: .55; }

.big-amount { font-size: 2.6rem; font-weight: 800; margin: 6px 0 12px; color: var(--purple); }
.qr { display: grid; place-items: center; margin: 8px auto; }
.qr svg, .qr img { width: 230px; height: 230px; }
.status { font-weight: 600; min-height: 1.4em; }
.status.ok { color: var(--ok); }
.status.err { color: var(--danger); }
.check {
  width: 80px; height: 80px; margin: 4px auto 8px; border-radius: 50%; background: var(--ok);
  color: #fff; font-size: 3rem; display: grid; place-items: center;
}

.list-title { margin: 22px 4px 8px; font-size: 1.05rem; }
.sales { list-style: none; margin: 0; padding: 0; }
.sales li {
  background: var(--card); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.sales .amt { font-weight: 800; color: var(--purple); white-space: nowrap; }
.sales .meta { font-size: .85rem; color: var(--muted); }
.sales a { color: var(--purple-2); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(120px);
  background: #2a1f38; color: #fff; padding: 12px 18px; border-radius: 12px; max-width: 90vw;
  transition: transform .25s; z-index: 10; text-align: center;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.foot { text-align: center; padding: 10px 0 18px; }
.foot a { color: var(--muted); }
