:root {
  --accent: #C0622D;
  --accent-soft: #fbeee6;
  --ok: #2e7d4f;
  --ok-soft: #e7f4ec;
  --warn: #b5541c;
  --text: #1f1f1f;
  --muted: #777;
  --line: #e6e2de;
  --bg: #faf8f6;
  --card: #fff;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Segoe UI", sans-serif;
  font-size: 16px; line-height: 1.45;
}
button, input, select { font: inherit; color: inherit; }
input[type=checkbox] { accent-color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
[hidden] { display: none !important; }
.btn-primary {
  border: 0; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 600;
  padding: 13px 20px; font-size: 17px; cursor: pointer; width: 100%;
}
.btn-primary:active { filter: brightness(.92); }

/* ---------- guest entry ---------- */
.entry-body { background: #1d1410; color: #fff; min-height: 100vh; }
.entry {
  min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
}
.state { width: 100%; max-width: 380px; text-align: center; }
.spinner { width: 44px; height: 44px; margin: 0 auto 16px; border-radius: 50%; border: 4px solid rgba(255,255,255,.2); border-top-color: #fff; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.ticket { background: #fff; color: var(--text); border-radius: 22px; overflow: hidden; box-shadow: 0 18px 50px rgba(0,0,0,.4); }
.ticket-top { background: var(--ok); color: #fff; padding: 26px 20px 22px; }
.check { width: 64px; height: 64px; margin: 0 auto 10px; border-radius: 50%; background: #fff; color: var(--ok); font-size: 38px; font-weight: 700; line-height: 64px; animation: pop .45s cubic-bezier(.2,1.6,.4,1) both; }
.check.wait { background: #fff4e0; font-size: 30px; }
.check.bad { background: #fff2ea; color: var(--warn); }
@keyframes pop { from { transform: scale(.3); opacity: 0; } }
.ticket-top h1, .state > h1 { margin: 0; font-size: 26px; letter-spacing: .02em; }
.sub { margin: 4px 0 0; opacity: .85; }
.ticket-person { padding: 22px 20px 16px; border-bottom: 2px dashed var(--line); }
.avatar { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; display: block; margin: 0 auto 10px; border: 3px solid var(--ok-soft); }
.guest-name { font-size: 26px; font-weight: 700; overflow-wrap: anywhere; }
.entry-time { margin-top: 4px; color: var(--muted); }
.entry-time span { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.ticket-live { padding: 14px; display: flex; align-items: center; justify-content: center; gap: 8px; font-variant-numeric: tabular-nums; font-size: 20px; font-weight: 600; }
.live-dot { width: 10px; height: 10px; border-radius: 50%; background: #2fbf6b; animation: blink 1s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .2; } }
.hint { margin-top: 20px; line-height: 1.6; }
.entry-body .muted { color: rgba(255,255,255,.6); }
#error .btn-primary, #closed .btn-primary { margin-top: 22px; }

/* ---------- staff sign-in ---------- */
.signin { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.signin-card { width: 100%; max-width: 360px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 24px 20px; display: flex; flex-direction: column; gap: 14px; }
.signin-card h1 { margin: 0; font-size: 24px; }
.signin-card p { margin: 0; }
.signin-card label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: #444; }
.signin-card input { border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; font-size: 16px; background: #fff; }
.error-text { color: #b23b3b; font-size: 14px; }

/* ---------- staff list ---------- */
#app { padding-bottom: calc(90px + env(safe-area-inset-bottom)); }
.top { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 12px 16px 8px; border-bottom: 1px solid var(--line); }
.top > * { max-width: 720px; margin-left: auto; margin-right: auto; }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.top h1 { font-size: 20px; margin: 0; }
.who { font-size: 13px; color: var(--muted); }
.top-actions { display: flex; gap: 4px; align-items: center; }
.day-select { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 10px; font-size: 14px; max-width: 140px; }
.link-btn { border: 0; background: none; color: var(--muted); padding: 8px; cursor: pointer; white-space: nowrap; }
.gate { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: #f0eeec; border: 1px solid var(--line); }
.gate.open { background: var(--ok-soft); border-color: #b9dcc6; }
.gate-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: #aaa; }
.gate.open .gate-dot { background: #2fbf6b; animation: blink 1.2s ease-in-out infinite; }
.gate-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.gate-text b { font-size: 15px; }
.gate.open .gate-text b { color: var(--ok); }
.gate-text span { color: var(--muted); }
.gate-btn { flex: none; border: 0; border-radius: 10px; padding: 9px 14px; font-weight: 700; cursor: pointer; background: var(--ok); color: #fff; }
.gate.open .gate-btn { background: #fff; color: #b23b3b; border: 1px solid #e5c4c4; }
.gate-btn:disabled { opacity: .6; }
.stats { display: grid; grid-template-columns: 1fr 1fr 1.6fr; gap: 8px; margin-top: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; display: flex; flex-direction: column; min-width: 0; }
.stat b { font-size: 22px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat.warn b { color: var(--warn); }
.stat.ok b { color: var(--ok); }
.stat.ok span { white-space: normal; overflow: visible; line-height: 1.3; }
.tools { display: flex; gap: 10px; align-items: center; margin-top: 10px; }
.tools input[type=search] { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; font-size: 16px; background: var(--card); }
.toggle { font-size: 13px; color: var(--muted); white-space: nowrap; display: flex; align-items: center; gap: 4px; }
.status { min-height: 18px; margin-top: 6px; }

main { padding: 12px 16px; max-width: 720px; margin: 0 auto; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; transition: background .4s, border-color .4s; }
.card.done { border-color: #b9dcc6; background: #fbfefc; }
.card.fresh { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.new-tag { font-size: 11px; font-weight: 700; color: #fff; background: var(--accent); border-radius: 6px; padding: 1px 6px; margin-left: 6px; vertical-align: 2px; }
.card-main { display: flex; align-items: center; gap: 12px; padding: 12px; }
.avatar-sm { flex: none; width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: #eee; }
.avatar-sm.ph { display: flex; align-items: center; justify-content: center; font-weight: 700; color: #888; }
.card-info { flex: 1; min-width: 0; }
.name { font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 3px; align-items: center; font-size: 13px; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #f0eeec; color: #555; font-variant-numeric: tabular-nums; }
.paid { color: var(--ok); font-weight: 600; }
.unpaid { color: var(--warn); font-weight: 600; }
.amts { flex: none; display: flex; gap: 6px; }
.amt {
  min-width: 54px; height: 46px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff;
  font-size: 17px; font-weight: 700; cursor: pointer; font-variant-numeric: tabular-nums;
}
.amt.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.amt.vip { color: #8a6a12; font-size: 15px; letter-spacing: .02em; }
.amt.vip.on { background: #b8901f; border-color: #b8901f; color: #fff; }
.paid.vip { color: #8a6a12; }
.amt:disabled { opacity: .55; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

.fab-bar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 60%, rgba(250,248,246,0)); }
.fab { display: inline-block; text-decoration: none; text-align: center; border-radius: 999px; padding: 12px 26px; font-weight: 600; background: var(--accent); color: #fff; }
.fab-secondary { background: #fff; color: var(--accent); border: 1.5px solid var(--accent); }

@media (max-width: 380px) {
  .amt { min-width: 46px; height: 44px; font-size: 15px; padding: 0 4px; }
  .amt.vip { font-size: 13px; }
  .amts { gap: 4px; }
  .avatar-sm { width: 36px; height: 36px; }
  .card-main { gap: 8px; padding: 10px; }
}

/* ---------- QR poster ---------- */
.qr-body { background: #fff; }
.qr-poster { max-width: 520px; margin: 0 auto; padding: 32px 16px; text-align: center; }
.qr-poster h1 { font-size: 40px; margin: 0; }
.qr-en { margin: 2px 0 16px; color: var(--muted); font-size: 18px; }
.qr-img { width: 100%; max-width: 420px; height: auto; display: block; margin: 0 auto; }
.qr-steps { text-align: left; display: inline-block; margin: 16px auto 24px; font-size: 18px; line-height: 1.8; }
.join-page { max-width: 380px; padding-top: 18vh; }
.join-page.desktop { padding-top: 40px; }
.join-qr .qr-img { max-width: 280px; margin-top: 8px; }
.join-qr-hint { margin: 6px 0 0; color: #444; }
.join-or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; margin: 22px 0 6px; }
.join-or::before, .join-or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.join-btn { display: block; text-decoration: none; text-align: center; margin-top: 12px; }
.join-hint { margin: 10px 0 0; font-size: 14px; }
@media print { .no-print { display: none; } .qr-poster { padding-top: 60px; } }
