:root {
  --accent: #C0622D;
  --accent-soft: #fbeee6;
  --ok: #2e7d4f;
  --ok-soft: #e7f4ec;
  --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;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}
button { font: inherit; color: inherit; }
input[type=radio], input[type=checkbox] { accent-color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* header */
.top { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 12px 16px 8px; border-bottom: 1px solid var(--line); }
.top-row { display: flex; align-items: center; justify-content: space-between; }
.top h1 { font-size: 20px; margin: 0; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.icon-btn { border: 1px solid var(--line); background: var(--card); border-radius: 999px; width: 36px; height: 36px; font-size: 18px; cursor: pointer; }
.link-btn { border: 0; background: none; color: var(--muted); padding: 8px; cursor: pointer; white-space: nowrap; }
.sessions { display: flex; gap: 8px; overflow-x: auto; margin: 10px -16px 0; padding: 0 16px 2px; scrollbar-width: none; }
.sessions::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 14px; cursor: pointer; }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.summary { margin-top: 10px; font-size: 14px; color: #444; }
.summary .ok { color: var(--ok); font-weight: 600; white-space: nowrap; }
.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; }

/* list */
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; }
.card.done { border-color: #b9dcc6; background: #fbfefc; }
.card.flagged { opacity: .55; }
.card-main { display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 14px; }
.card-info { flex: 1; min-width: 0; text-align: left; border: 0; background: none; padding: 0; cursor: pointer; }
.name { font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; align-items: center; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #f0eeec; color: #555; }
.badge.leader { background: #e8eefc; color: #2f4fa8; }
.badge.follower { background: #fce8f0; color: #a8325f; }
.badge.src { background: var(--accent-soft); color: var(--accent); }
.badge.flag { background: #eee; color: #888; }
.badge.date { background: #333; color: #fff; }
.att { font-size: 12px; }
.att.yes { color: var(--ok); }
.att.no { color: #b23b3b; }
.checkin-btn { flex: none; min-width: 84px; height: 44px; border-radius: 12px; border: 1.5px solid var(--accent); background: #fff; color: var(--accent); font-weight: 700; cursor: pointer; }
.checkin-btn.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.checkin-btn:disabled { opacity: .5; }
.details { margin: 0; padding: 4px 14px 14px; display: grid; grid-template-columns: 72px 1fr; gap: 4px 10px; font-size: 14px; border-top: 1px dashed var(--line); }
.details dt { color: var(--muted); padding-top: 6px; }
.details dd { margin: 0; padding-top: 6px; overflow-wrap: anywhere; }
.tel { color: var(--accent); }
.empty { text-align: center; color: var(--muted); margin-top: 40px; }

/* floating walk-in button */
.fab-bar { position: fixed; left: 0; right: 0; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 6;
  display: flex; justify-content: center; gap: 10px; pointer-events: none; }
.fab { pointer-events: auto; border: 0; border-radius: 999px; padding: 14px 22px; background: var(--accent); color: #fff; font-weight: 700; font-size: 16px;
  box-shadow: 0 6px 18px rgba(192, 98, 45, .35); cursor: pointer; white-space: nowrap; }
.fab-secondary { background: #fff; color: var(--accent); border: 1.5px solid var(--accent); box-shadow: 0 6px 18px rgba(0, 0, 0, .12); }

/* dialog */
dialog { border: 0; border-radius: 16px; padding: 20px; width: min(92vw, 420px); }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog h2 { margin: 0 0 4px; font-size: 18px; }
dialog label { display: block; margin-top: 12px; font-size: 14px; color: #444; }
dialog input[type=text], #walkinName, #walkinSessionSelect { display: block; width: 100%; margin-top: 6px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 16px; }
.seg { border: 0; padding: 0; margin: 14px 0 0; }
.seg legend { font-size: 14px; color: #444; padding: 0; margin-bottom: 6px; }
.seg label { display: inline-flex; align-items: center; gap: 4px; margin: 0 14px 0 0; font-size: 15px; color: var(--text); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.primary { border: 0; border-radius: 10px; padding: 10px 18px; background: var(--accent); color: #fff; font-weight: 700; cursor: pointer; }
.primary:disabled { opacity: .6; }

/* toast */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 10;
  background: #222; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: 90vw; }
.toast.error { background: #b23b3b; }

/* login */
body.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 28px 24px; text-align: center; width: min(100%, 380px); }
.login-card h1 { font-size: 20px; margin: 0 0 6px; }
#gbtn { display: flex; justify-content: center; margin-top: 18px; min-height: 44px; }
.msg { margin-top: 14px; color: #b23b3b; font-size: 14px; }

.who { font-size: 12px; color: var(--muted); margin-top: 2px; }
.checkin-status { flex: none; font-size: 14px; font-weight: 600; color: var(--muted); padding: 6px 10px; border-radius: 10px; background: #f3f1ef; }
.checkin-status.on { color: #fff; background: var(--ok); }
.fab[hidden] { display: none; }

a.link-btn { text-decoration: none; }
.link-btn[hidden] { display: none; }
.link-btn.danger { color: #b23b3b; flex: none; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 14px; }
.panel h2 { font-size: 16px; margin: 0 0 10px; }
.add-form { display: flex; flex-wrap: wrap; gap: 8px; }
.add-form input { flex: 1 1 220px; min-width: 0; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 16px; }
.add-form select { border: 1px solid var(--line); border-radius: 10px; padding: 10px; font-size: 15px; background: #fff; }

.role-select { border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; font-size: 14px; background: #fff; }
.meta .muted.small { flex-basis: 100%; }

.inapp { margin-top: 16px; }
.inapp p { margin: 6px 0; }
.inapp .primary { display: inline-block; margin-top: 12px; text-decoration: none; }
.inapp [hidden] { display: none; }
#gbtn[hidden] { display: none; }

.qr-dialog { text-align: center; }
.qr-dialog img { display: block; width: min(72vw, 280px); height: auto; margin: 14px auto 6px; image-rendering: pixelated; }
.qr-note { font-weight: 700; color: var(--accent); margin: 6px 0 2px; }
.qr-dialog .primary { margin-top: 12px; width: 100%; }
.top-row > div:first-child { min-width: 0; }
.who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-actions { flex: none; }
@media (max-width: 360px) {
  .top h1 { font-size: 18px; }
  .top-actions { gap: 2px; }
  .top-actions .link-btn { padding: 6px 4px; font-size: 14px; }
  .icon-btn { width: 32px; height: 32px; font-size: 16px; }
  .fab { padding: 12px 16px; font-size: 15px; }
}
