:root {
  --brand: #2f4a3a; --brand-2: #3f6b51; --brand-soft: #e7efe9;
  --bg: #f4f5f2; --card: #ffffff; --text: #1d2420; --muted: #66706a; --line: #dde2dd;
  --ok: #1f8a4c; --ok-soft: #e3f4ea; --warn: #b7791f; --warn-soft: #fdf3e1;
  --bad: #c0392b; --bad-soft: #fbe9e7; --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'IBM Plex Sans Thai', system-ui, sans-serif; background: var(--bg); color: var(--text);
  font-size: 16px; line-height: 1.5; -webkit-tap-highlight-color: transparent;
}
.top { background: var(--brand); color: #fff; padding: 14px 16px; position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px; }
.top h1 { font-size: 18px; margin: 0; font-weight: 600; flex: 1; }
.top .sub { font-size: 13px; opacity: .8; }
.top a, .top button.link { color: #fff; font-size: 14px; text-decoration: none; background: none; border: 0; cursor: pointer; font-family: inherit; }
.wrap { max-width: 560px; margin: 0 auto; padding: 16px; }
.wrap.wide { max-width: 1100px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.card h2 { font-size: 16px; margin: 0 0 12px; }
label { display: block; font-size: 14px; color: var(--muted); margin: 12px 0 6px; }
label .req { color: var(--bad); }
input, select, textarea {
  width: 100%; font: inherit; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-2); border-color: transparent; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.seg button, .chip-btn {
  font: inherit; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: #fafbf9; cursor: pointer; color: var(--text);
}
.seg button.on, .chip-btn.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.sizes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.btn {
  display: block; width: 100%; font: inherit; font-weight: 600; padding: 14px; border-radius: 12px; border: 0;
  background: var(--brand); color: #fff; cursor: pointer; margin-top: 16px; font-size: 17px;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--brand); border: 1px solid var(--brand); }
.btn.ok { background: var(--ok); } .btn.bad { background: var(--bad); } .btn.small { padding: 10px; font-size: 15px; margin-top: 8px; }
.row { display: flex; gap: 8px; } .row > * { flex: 1; }
.muted { color: var(--muted); font-size: 14px; }
.hidden { display: none !important; }
.note { border-radius: 10px; padding: 12px 14px; font-size: 14px; margin-top: 12px; }
.note.ok { background: var(--ok-soft); color: #145c33; } .note.warn { background: var(--warn-soft); color: #7a4f10; }
.note.bad { background: var(--bad-soft); color: #8a2318; } .note.info { background: var(--brand-soft); color: var(--brand); }
.event-opt { display: block; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-top: 8px; cursor: pointer; background: #fff; }
.event-opt.on { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand) inset; background: var(--brand-soft); }
.event-opt .t { font-weight: 600; } .event-opt .d { font-size: 14px; color: var(--muted); }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; font-size: 15px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 500; }
.ticket { text-align: center; }
.ticket .qr { display: inline-block; padding: 14px; background: #fff; border-radius: 12px; border: 1px solid var(--line); margin: 8px 0; }
.ticket .code { font-family: ui-monospace, monospace; font-size: 26px; letter-spacing: 4px; font-weight: 700; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 13px; font-weight: 600; margin: 2px; }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.wait { background: #eef0ee; color: var(--muted); }
.badge.warn { background: var(--warn-soft); color: var(--warn); } .badge.bad { background: var(--bad-soft); color: var(--bad); }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; z-index: 50; }
.modal .sheet { background: #fff; width: 100%; max-width: 560px; border-radius: 18px 18px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); max-height: 92vh; overflow: auto; }
@media (min-width: 700px) { .modal { align-items: center; } .modal .sheet { border-radius: 18px; } }
.spinner { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin 1s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 22px; } .stat span { font-size: 12px; color: var(--muted); }
.list-item { padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.list-item:last-child { border-bottom: 0; }
.result { border-radius: var(--radius); padding: 18px; color: #fff; text-align: center; }
.result.ok { background: var(--ok); } .result.warn { background: var(--warn); } .result.bad { background: var(--bad); }
.result .big { font-size: 22px; font-weight: 700; } .result .size { font-size: 64px; font-weight: 800; line-height: 1.1; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; overflow-x: auto; }
.tabs button { font: inherit; padding: 10px 16px; border-radius: 99px; border: 1px solid var(--line); background: #fff; cursor: pointer; white-space: nowrap; }
.tabs button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
#reader { width: 100%; border-radius: 12px; overflow: hidden; background: #000; }
#reader video { border-radius: 12px; }
