:root {
  --navy: #0b1d3a;
  --navy-2: #12284d;
  --navy-3: #1b3664;
  --line: #2a4677;
  --copper: #c8834f;
  --copper-2: #e3a06b;
  --text: #eef2f8;
  --muted: #9fb0cc;
  --ok: #2fbf71;
  --bad: #e5484d;
  --warn: #f0b429;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--navy);
  color: var(--text);
  font-family: 'IBM Plex Sans Thai', 'Noto Sans Thai', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--copper-2); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.15rem; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 16px; }
.narrow { max-width: 480px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; background: var(--navy-2); border-bottom: 2px solid var(--copper);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; letter-spacing: .3px; }
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: .8rem; }
.card {
  background: var(--navy-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px;
}
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.stat { background: var(--navy-3); border-radius: 12px; padding: 12px 14px; }
.stat .k { color: var(--muted); font-size: .85rem; }
.stat .v { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
label { display: block; font-size: .85rem; color: var(--muted); margin: 8px 0 4px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--navy); color: var(--text); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--copper); border-color: transparent; }
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--navy-3); color: var(--text); font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
button:disabled { opacity: .5; cursor: not-allowed; }
.primary { background: var(--copper); border-color: var(--copper); color: #1a1006; }
.primary:hover { background: var(--copper-2); }
.danger { background: transparent; border-color: var(--bad); color: #ff8a8d; }
select.menu { width: auto; padding: 8px 10px; font-weight: 600; background: var(--navy-3); cursor: pointer; }
.pill { white-space: nowrap; }
.ok-btn { background: rgba(47,191,113,.15); border-color: var(--ok); color: #7be3a8; }
.ghost { background: transparent; }
.big { padding: 16px 20px; font-size: 1.15rem; width: 100%; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 8px 16px; background: var(--navy-2); }
.tabs button { background: transparent; border-color: transparent; color: var(--muted); }
.tabs button.on { color: var(--text); border-color: var(--copper); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .82rem; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tablewrap { overflow-x: auto; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .78rem; font-weight: 600; }
.pill.customer { background: rgba(200,131,79,.2); color: var(--copper-2); }
.pill.general { background: rgba(120,160,230,.18); color: #a9c4ff; }
.pill.bad { background: rgba(229,72,77,.18); color: #ff8a8d; }
.pill.ok { background: rgba(47,191,113,.18); color: #7be3a8; }
.strike { text-decoration: line-through; opacity: .55; }
.hidden { display: none !important; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--navy-3); border: 1px solid var(--copper); padding: 12px 18px;
  border-radius: 12px; z-index: 100; max-width: 90vw; box-shadow: 0 8px 30px rgba(0,0,0,.4);
}
.err { color: #ff8a8d; }

/* scanner */
#reader { width: 100%; border-radius: var(--radius); overflow: hidden; background: #000; min-height: 260px; }
#reader video { object-fit: cover; }
.sheet {
  position: fixed; inset: 0; background: rgba(4,10,22,.86); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet .panel {
  width: 100%; max-width: 520px; background: var(--navy-2); border-top: 3px solid var(--copper);
  border-radius: 20px 20px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
}
.money { font-size: 2.6rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kv { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.result-ok { background: #0f3d27; border: 2px solid var(--ok); }
.result-bad { background: #43161a; border: 2px solid var(--bad); }

/* coupon page */
.qrbox {
  background: #fff; border-radius: 18px; padding: 16px; margin: 0 auto;
  width: min(84vw, 360px); aspect-ratio: 1 / 1;
}
.qrbox img { width: 100%; height: 100%; display: block; }
.code { font-family: ui-monospace, Menlo, monospace; letter-spacing: 3px; font-size: 1.2rem; }

@media print {
  .noprint { display: none !important; }
}
