:root {
  --ink: #17233b;
  --paper: #f7f8f5;
  --line: #cdd5d1;
  --blue: #135c92;
  --green: #087f5b;
  --green-soft: #d8f5e8;
  --amber: #a45b00;
  --amber-soft: #fff0cf;
  --red: #b4233c;
  --red-soft: #ffe0e5;
  --white: #fff;
  --shadow: 0 18px 50px rgba(23, 35, 59, .14);
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--paper); }
button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid #4aa9e9; outline-offset: 3px; }
.shell { width: min(100% - 32px, 560px); margin: 0 auto; padding: 28px 0 56px; }
.wide { width: min(100% - 32px, 1080px); }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; font-weight: 800; letter-spacing: .02em; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 48px; color: var(--white); background: var(--blue); clip-path: polygon(0 0, 100% 0, 100% 42%, 88% 50%, 100% 58%, 100% 100%, 0 100%, 0 58%, 12% 50%, 0 42%); font-size: 24px; }
h1 { margin: 0 0 10px; font-size: clamp(32px, 8vw, 52px); line-height: 1.06; letter-spacing: -.04em; }
h2 { margin: 0 0 18px; font-size: 22px; }
p { line-height: 1.7; }
.muted { color: #596579; }
.panel { padding: 24px; background: var(--white); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 8px 24px rgba(23,35,59,.06); }
.stack { display: grid; gap: 16px; }
.field { display: grid; gap: 7px; font-weight: 700; }
.field input { width: 100%; min-height: 50px; padding: 12px 14px; border: 1px solid #aeb8b4; border-radius: 10px; background: var(--white); color: var(--ink); }
.primary, .secondary, .danger { min-height: 50px; border: 0; border-radius: 10px; padding: 12px 18px; font-weight: 800; }
.primary { background: var(--blue); color: var(--white); }
.secondary { background: #e6edf1; color: var(--ink); }
.danger { background: var(--red); color: var(--white); }
.primary:disabled { opacity: .5; cursor: wait; }
.message { padding: 12px 14px; border-radius: 10px; background: var(--amber-soft); color: #6e3d00; line-height: 1.5; }
.hidden { display: none !important; }
.ticket { position: relative; overflow: hidden; padding: 28px; background: var(--ink); color: var(--white); border-radius: 22px; box-shadow: var(--shadow); }
.ticket::after { content: "4"; position: absolute; right: -15px; bottom: -58px; color: rgba(255,255,255,.07); font: 900 230px/1 Arial, sans-serif; }
.ticket-head { position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px dashed rgba(255,255,255,.36); padding-bottom: 18px; }
.member { position: relative; z-index: 1; display: flex; align-items: center; gap: 14px; margin: 22px 0; }
.avatar { width: 58px; height: 58px; border-radius: 50%; object-fit: cover; background: #dbe3e8; border: 2px solid var(--white); }
.avatar-fallback { display: grid; place-items: center; color: var(--ink); font-size: 24px; font-weight: 900; }
.member-name { font-size: 24px; font-weight: 900; }
.status-pill { display: inline-flex; padding: 6px 10px; border-radius: 999px; background: var(--green-soft); color: #045c42; font-weight: 800; font-size: 14px; }
.qr-wrap { position: relative; z-index: 1; display: grid; place-items: center; width: fit-content; min-width: 240px; min-height: 240px; margin: 18px auto 10px; padding: 16px; background: var(--white); border-radius: 12px; }
.qr-wrap img, .qr-wrap canvas { max-width: 208px; height: auto; }
.countdown { position: relative; z-index: 1; text-align: center; color: #cbd6e6; font-variant-numeric: tabular-nums; }
.ticket-meta { position: relative; z-index: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 20px; }
.ticket-meta small { display: block; color: #aebdd0; margin-bottom: 4px; }
.ticket-meta strong { display: block; }
.login-hero { padding: 30px 0 22px; }
.login-hero p { max-width: 42ch; }
.staff-body { background: #e9eeeb; }
.staff-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.staff-top h1 { font-size: 28px; margin: 0; }
.link-button { border: 0; background: transparent; color: var(--blue); font-weight: 800; padding: 8px; }
.scanner { position: relative; overflow: hidden; aspect-ratio: 4 / 5; max-height: 68vh; background: #09111d; border-radius: 22px; box-shadow: var(--shadow); }
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scan-frame { position: absolute; inset: 17% 10%; border: 4px solid rgba(255,255,255,.95); border-radius: 18px; box-shadow: 0 0 0 999px rgba(0,0,0,.36); }
.scan-frame::before, .scan-frame::after { content: ""; position: absolute; left: 8%; right: 8%; height: 2px; background: #63e6be; box-shadow: 0 0 14px #63e6be; }
.scan-frame::before { top: 50%; }
.scanner-note { position: absolute; left: 0; right: 0; bottom: 24px; color: var(--white); text-align: center; font-weight: 800; }
.result { display: grid; place-items: center; text-align: center; min-height: 62vh; padding: 34px 24px; border-radius: 24px; color: var(--ink); box-shadow: var(--shadow); }
.result.valid { background: var(--green-soft); color: #034d37; }
.result.used { background: var(--amber-soft); color: #633800; }
.result.uncertain { background: var(--amber-soft); color: #633800; }
.result.invalid { background: var(--red-soft); color: #751427; }
.result-symbol { font-size: 80px; line-height: 1; font-weight: 900; }
.result h2 { margin: 16px 0 6px; font-size: 38px; }
.result .avatar { width: 84px; height: 84px; margin-top: 18px; border-color: currentColor; }
.manual { display: flex; gap: 8px; margin-top: 14px; }
.manual input { min-width: 0; flex: 1; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.manual button { min-width: 92px; }
.admin-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 20px 0; }
.metric { padding: 18px; background: var(--ink); color: var(--white); border-radius: 14px; }
.metric strong { display: block; font-size: 32px; }
.metric span { color: #b8c5d5; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: #596579; }
.member-toolbar { display: grid; gap: 8px; margin-bottom: 14px; }
.member-search-actions { display: flex; gap: 8px; align-items: center; }
.member-search-actions input { min-width: 0; flex: 1; min-height: 50px; padding: 12px 14px; border: 1px solid #aeb8b4; border-radius: 10px; }
.member-pagination { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 16px; }
.member-pagination span { min-width: 130px; color: #596579; text-align: center; }
.member-pagination button { min-height: 42px; }
.code-list { padding: 16px; background: #edf2f5; border-radius: 10px; font: 700 15px/1.8 Consolas, monospace; white-space: pre-wrap; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.section-gap { margin-top: 16px; }
@media (max-width: 720px) {
  .admin-grid { grid-template-columns: 1fr 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .panel { padding: 18px; }
  .member-search-actions { flex-wrap: wrap; }
  .member-search-actions input { flex-basis: 100%; }
  .member-pagination { justify-content: space-between; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
