:root {
  --bg: #eef0ea;
  --ink: #1c2230;
  --muted: #5b6372;
  --line: #d3d7cd;
  --card: #23345c;
  --card-ink: #f3f5f8;
  --verde: #a8c256;
  --ok: #1f7a4d;
  --bad: #b42318;
  --wait: #6b7280;
  --radius-field: 10px;
  --font: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  --font-name: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 16px; line-height: 1.6;
  padding: env(safe-area-inset-top, 0) 0 env(safe-area-inset-bottom, 0);
}
main { max-width: 34rem; margin: 0 auto; padding: 2.5rem 1.25rem 4rem; }
.org { display: flex; align-items: baseline; gap: .6rem; margin-bottom: 2rem; }
.org b { font-size: 1.05rem; letter-spacing: .02em; }
.org span { color: var(--muted); font-size: .9rem; }
h1 { font-size: 1.75rem; line-height: 1.25; margin: 0 0 .5rem; font-weight: 700; }
p.lead { color: var(--muted); margin: 0 0 1.75rem; }
label { display: block; font-weight: 500; margin: 1.1rem 0 .35rem; }
label small { color: var(--muted); font-weight: 400; margin-left: .35rem; }
input {
  width: 100%; font: inherit; padding: .75rem .85rem; border: 1.5px solid var(--line);
  border-radius: var(--radius-field); background: #fff; color: var(--ink);
}
input:focus { outline: none; border-color: var(--card); box-shadow: 0 0 0 3px rgba(35, 52, 92, .18); }
button {
  font: inherit; font-weight: 700; cursor: pointer; border: 0; border-radius: var(--radius-field);
  background: var(--card); color: #fff; padding: .8rem 1.2rem; margin-top: 1.4rem; width: 100%;
}
button.secondary { background: transparent; color: var(--card); border: 1.5px solid var(--card); }
button:disabled { opacity: .55; cursor: progress; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--verde); outline-offset: 2px; }
.error { color: var(--bad); margin-top: 1rem; font-weight: 500; }
.hint { color: var(--muted); font-size: .9rem; margin-top: 2rem; }
a { color: var(--card); }

/* 會員卡 */
.member-card {
  margin-top: 2rem; background: var(--card); color: var(--card-ink);
  border-radius: 20px; padding: 1.5rem 1.5rem 1.25rem; position: relative; overflow: hidden;
}
.member-card::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 6px; background: var(--verde);
}
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.card-top .chapter { font-size: .85rem; opacity: .8; }
.card-name { font-family: var(--font-name); font-size: 1.9rem; font-weight: 700; line-height: 1.2; margin: .9rem 0 .1rem; }
.card-en { opacity: .85; }
.card-id { font-size: 2.6rem; font-weight: 700; letter-spacing: .04em; font-variant-numeric: tabular-nums; margin-top: 1rem; line-height: 1; }
.qr-box { background: #fff; border-radius: 14px; padding: 14px; margin: 1.25rem auto .75rem; width: fit-content; }
.qr-box canvas { display: block; width: 220px; height: 220px; image-rendering: pixelated; }
.card-meta { display: grid; grid-template-columns: auto 1fr; gap: .15rem 1rem; font-size: .92rem; margin-top: .5rem; }
.card-meta dt { opacity: .7; }
.card-meta dd { margin: 0; }
.pill { display: inline-block; border-radius: 999px; padding: .15rem .7rem; font-size: .85rem; font-weight: 700; white-space: nowrap; }
.pill.active { background: var(--verde); color: #1b2a0a; }
.pill.expired { background: #f6d5d1; color: var(--bad); }
.pill.unknown { background: #e3e5e8; color: var(--wait); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.actions button { margin-top: 1rem; }

/* 工作人員頁 */
.tabs { display: flex; gap: .5rem; margin-bottom: 1.25rem; }
.tabs button { margin: 0; width: auto; flex: 1; background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.tabs button[aria-selected="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
#reader { border-radius: 14px; overflow: hidden; background: #000; min-height: 240px; }
.verdict { margin-top: 1rem; border-radius: 16px; padding: 1.25rem 1.25rem 1rem; color: #fff; }
.verdict.ok { background: var(--ok); }
.verdict.bad { background: var(--bad); }
.verdict.warn { background: #8a5a00; }
.verdict .big { font-size: 1.6rem; font-weight: 700; line-height: 1.2; }
.verdict .who { font-size: 1.15rem; margin-top: .4rem; }
.verdict .sub { opacity: .9; font-size: .92rem; }
.results { list-style: none; padding: 0; margin: 1rem 0 0; }
.results li { border-top: 1px solid var(--line); padding: .75rem 0; display: flex; justify-content: space-between; gap: 1rem; align-items: center; }
.results .rid { font-weight: 700; font-variant-numeric: tabular-nums; }
.results .rsub { color: var(--muted); font-size: .88rem; word-break: break-all; }
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; color: var(--muted); font-size: .9rem; }
.toolbar button { width: auto; margin: 0; padding: .35rem .8rem; font-weight: 500; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: no-preference) {
  .member-card { animation: rise .35s ease-out; }
  @keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
}
@media print {
  body { background: #fff; }
  form, .actions, .hint, .lead, .org { display: none !important; }
}

/* 會員清單頁 */
main.wide { max-width: 72rem; }
.nav { display: flex; gap: 1rem; font-size: .92rem; }
.stats { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 1.25rem; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: .55rem .9rem; min-width: 6.5rem; }
.stat b { display: block; font-size: 1.4rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: .82rem; }
.filters { display: grid; grid-template-columns: 1fr auto auto; gap: .6rem; margin-bottom: .75rem; }
.filters input, .filters select {
  font: inherit; padding: .6rem .75rem; border: 1.5px solid var(--line); border-radius: var(--radius-field); background: #fff; color: var(--ink);
}
.count { color: var(--muted); font-size: .9rem; margin-bottom: .5rem; }
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 14px; }
table.members { border-collapse: collapse; width: 100%; font-size: .92rem; }
table.members th, table.members td { text-align: left; padding: .6rem .75rem; border-bottom: 1px solid #e6e8e2; vertical-align: top; }
table.members th { position: sticky; top: 0; background: #f6f7f3; font-weight: 700; white-space: nowrap; }
table.members th button {
  all: unset; cursor: pointer; display: inline-flex; gap: .25rem; align-items: center;
}
table.members th button:focus-visible { outline: 3px solid var(--verde); outline-offset: 2px; }
table.members th[aria-sort="ascending"] button::after { content: "▲"; font-size: .65rem; }
table.members th[aria-sort="descending"] button::after { content: "▼"; font-size: .65rem; }
table.members td.id { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.members td.nowrap { white-space: nowrap; font-variant-numeric: tabular-nums; }
table.members td .en { color: var(--muted); font-size: .85rem; }
table.members td.email { overflow-wrap: anywhere; min-width: 12rem; }
table.members td.tight { white-space: nowrap; }
table.members tr:last-child td { border-bottom: 0; }
@media (max-width: 720px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .filters input { grid-column: 1 / -1; }
  .table-wrap { background: transparent; border: 0; overflow: visible; }
  table.members thead { display: none; }
  table.members, table.members tbody, table.members tr, table.members td { display: block; width: 100%; }
  table.members tr { background: #fff; border: 1px solid var(--line); border-radius: 12px; margin-bottom: .6rem; padding: .5rem .25rem; position: relative; }
  table.members td { border: 0; padding: .15rem .75rem; }
  table.members td[data-label]::before { content: attr(data-label) "　"; color: var(--muted); font-size: .82rem; }
  table.members td.status-cell { position: absolute; top: .55rem; right: .5rem; width: auto; padding: 0; }
  table.members td.status-cell::before { content: none; }
}

/* 雙語：英文副行 */
.en { display: block; font-size: .82em; font-weight: 400; color: var(--muted); line-height: 1.45; margin-top: .15em; letter-spacing: 0; }
.en-inline { font-size: .85em; font-weight: 400; margin-left: .4em; opacity: .75; }
.org { flex-wrap: wrap; row-gap: .1rem; }
.org > span .en { font-size: .8rem; }
h1 .en { font-size: 1rem; font-weight: 500; margin-top: .3rem; }
p.lead .en { margin-top: .35rem; font-size: .92em; }
label small span[lang="en"] { white-space: normal; }
button .en { color: inherit; opacity: .8; font-weight: 500; font-size: .78em; margin-top: .05rem; }
.error .en { color: inherit; opacity: .85; }
.hint .en { margin-top: .3rem; }
.member-card .en { color: inherit; opacity: .7; }
.card-meta dt .en { font-size: .75em; margin-top: 0; }
.card-meta { row-gap: .45rem; align-items: baseline; }
label small { display: block; margin: .1rem 0 0; font-size: .82rem; }
.card-top .chapter { line-height: 1.35; }
.tabs button .en { margin-top: .1rem; }
.verdict .en { color: inherit; opacity: .85; }
.verdict .big .en { font-size: .6em; font-weight: 500; }
.stat > span .en { font-size: .78rem; margin-top: 0; }
table.members th .en { font-size: .72rem; font-weight: 500; margin-top: 0; }
table.members th button { flex-direction: column; align-items: flex-start; gap: 0; }
table.members th[aria-sort] button { position: relative; padding-right: .9rem; }
table.members th[aria-sort="ascending"] button::after, table.members th[aria-sort="descending"] button::after { position: absolute; right: 0; top: .2rem; }
table.members td .en { font-size: .78rem; margin-top: 0; }
table.members td.tight { white-space: normal; min-width: 5.5rem; }
.toolbar button span[lang="en"], .nav span[lang="en"] { font-size: .85em; opacity: .8; }
.toolbar { gap: .75rem; flex-wrap: wrap; }
.nav { flex-wrap: wrap; gap: .25rem .9rem; }
.toolbar button { white-space: nowrap; }
.filters input, .filters select { min-width: 0; width: 100%; text-overflow: ellipsis; }
@media (max-width: 720px) {
  .filters { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
@media (max-width: 720px) {
  .filters select { padding-left: .55rem; padding-right: .3rem; font-size: .92rem; }
}

/* 品牌 logo 與官網連結 */
.org { align-items: center; gap: .5rem 1rem; }
.brand { display: inline-block; line-height: 0; border-radius: 6px; }
.brand img { height: 52px; width: auto; display: block; }
.org > span { border-left: 1px solid var(--line); padding-left: 1rem; }
.site-foot { margin-top: 2.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line); font-size: .9rem; }
.site-foot a { color: var(--ink); text-decoration-color: var(--line); }
.site-foot a:hover { color: var(--card); }
@media (max-width: 480px) {
  .brand img { height: 44px; }
  .org > span { border-left: 0; padding-left: 0; flex-basis: 100%; }
}
