:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --line: #e3e6ea;
  --text: #1c2024;
  --muted: #6b7480;
  --brand: #2f6fed;
  --brand-dark: #2557c4;
  --ok: #0f9d76;
  --warn: #c98a00;
  --danger: #d64545;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .06);

  /* 整體介面縮放倍率。字級、間距、圓角、圖片全部等比例放大，
     要再調整只改這一個數字即可（1 = 原始大小，1.2 = 放大 20%）。
     注意：改這裡的同時，檔案最下方 @media 的斷點數值也要一起乘上同樣倍率。 */
  --ui-scale: 1.2;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  zoom: var(--ui-scale);
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC",
    "PingFang TC", "Microsoft JhengHei", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* zoom 之後 100vh 會跟著被放大而多出捲軸，需要除回倍率 */
.fill-viewport { min-height: calc(100vh / var(--ui-scale)); }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 0 20px; }
.wrap-narrow { max-width: 720px; margin: 0 auto; padding: 0 20px; }

/* ---------- header ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.topbar-in {
  display: flex; align-items: center; gap: 20px;
  height: 60px;
}
.brand { font-weight: 700; font-size: 17px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand .dot { color: var(--brand); }
.topbar nav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.topbar nav a {
  padding: 7px 13px; border-radius: 8px; color: var(--muted);
  font-size: 14px; font-weight: 500;
}
.topbar nav a:hover { background: #eef1f5; text-decoration: none; color: var(--text); }
.topbar nav a.active { background: #e8effd; color: var(--brand); }
.topbar .who { font-size: 13px; color: var(--muted); }

/* ---------- cards & layout ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}
.card + .card { margin-top: 18px; }
.section-title { font-size: 20px; font-weight: 700; margin: 32px 0 14px; }
h1 { font-size: 26px; margin: 0 0 6px; line-height: 1.35; }
h2 { font-size: 18px; margin: 0 0 12px; }
.lead { color: var(--muted); margin: 0 0 20px; }
.grid { display: grid; gap: 16px; }
/* min() 讓欄位在窄畫面自動退回單欄，不會因為最小寬度而撐破版面 */
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.mt { margin-top: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- event cards ---------- */
.event-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); display: flex; flex-direction: column;
  transition: transform .12s ease, box-shadow .12s ease;
}
.event-card:hover { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(16,24,40,.12); }
.event-cover { height: 96px; background: var(--brand); position: relative; }
.event-cover .date {
  position: absolute; left: 16px; bottom: -18px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 6px 12px; text-align: center; box-shadow: var(--shadow);
}
/* 月份在上、日期在下，兩行同樣大小的粗體 */
.event-cover .date b,
.event-cover .date span {
  display: block; font-size: 18px; font-weight: 700;
  line-height: 1.2; color: var(--text);
}
.event-body { padding: 30px 18px 18px; flex: 1; display: flex; flex-direction: column; }
.event-body h3 { margin: 0 0 6px; font-size: 17px; }
.event-meta { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.event-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; }

/* ---------- badges ---------- */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; line-height: 1.6;
  background: #eef1f5; color: var(--muted);
}
.badge.green { background: #e3f5ee; color: #0b7a5c; }
.badge.blue  { background: #e8effd; color: var(--brand-dark); }
.badge.amber { background: #fdf3dd; color: #96690a; }
.badge.red   { background: #fdeaea; color: #b53434; }
.badge.gray  { background: #eef1f5; color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 9px; border: 1px solid transparent;
  background: var(--brand); color: #fff; font-size: 14px; font-weight: 600;
  cursor: pointer; font-family: inherit; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--text); }
.btn.ghost:hover { background: #f2f4f7; color: var(--text); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #b53434; }
.btn.ok { background: var(--ok); }
.btn.ok:hover { background: #0b7a5c; }
.btn.sm { padding: 5px 11px; font-size: 13px; border-radius: 7px; }
.btn.lg { padding: 13px 24px; font-size: 16px; }
.btn.block { width: 100%; }

/* ---------- forms ---------- */
.field { margin-bottom: 16px; }
.field > label {
  display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px;
}
.field .req { color: var(--danger); margin-left: 3px; }
.field .hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=password], input[type=email], input[type=tel],
input[type=number], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 9px; font-size: 15px; font-family: inherit; background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47,111,237,.14);
}
textarea { min-height: 92px; resize: vertical; }
.choices { display: flex; flex-direction: column; gap: 7px; }
.choices label { display: flex; align-items: flex-start; gap: 8px; font-size: 14.5px; cursor: pointer; }
.choices input { margin-top: 4px; }
.inline-check { display: flex; align-items: center; gap: 8px; font-size: 14.5px; cursor: pointer; }

/* ---------- color picker ---------- */
.color-field { display: flex; gap: 10px; align-items: center; }
.color-field input[type=color] {
  flex: none; width: 46px; height: 40px; padding: 0; cursor: pointer;
  border: 1px solid var(--line); border-radius: 9px; background: #fff;
}
.color-field input[type=color]::-webkit-color-swatch-wrapper { padding: 4px; }
.color-field input[type=color]::-webkit-color-swatch { border: 0; border-radius: 6px; }
.color-field input[type=color]::-moz-color-swatch { border: 0; border-radius: 6px; }
.color-field input[type=text] {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-transform: lowercase;
}
.swatches { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.swatches button {
  width: 26px; height: 26px; padding: 0; font-size: 0; cursor: pointer;
  border: 1px solid rgba(16, 24, 40, .14); border-radius: 7px;
  transition: transform .1s ease;
}
.swatches button:hover { transform: scale(1.15); }
.swatches button.on { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--brand); }

/* ---------- alerts ---------- */
.alert {
  padding: 11px 14px; border-radius: 9px; font-size: 14px; margin-bottom: 16px;
  border: 1px solid transparent;
}
.alert.error { background: #fdeaea; border-color: #f6c9c9; color: #a32c2c; }
.alert.ok { background: #e3f5ee; border-color: #b7e5d5; color: #0b7a5c; }
.alert.info { background: #eef3fd; border-color: #cddcfa; color: #2557c4; }
.alert.warn { background: #fdf3dd; border-color: #f2dfae; color: #96690a; }
.hidden { display: none !important; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; top: 0; left: 0; z-index: 100;
  /* body 有 zoom，fixed 元素也會被放大，寬高要除回倍率才不會超出視窗 */
  width: calc(100vw / var(--ui-scale));
  height: calc(100vh / var(--ui-scale));
  background: rgba(16, 24, 40, .45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; overflow-y: auto;
}
.modal {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: 0 16px 48px rgba(16, 24, 40, .28);
  width: 100%; max-width: 460px; max-height: 100%;
  display: flex; flex-direction: column; overflow: hidden;
}
.modal-head {
  padding: 16px 20px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
}
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-close {
  margin-left: auto; background: none; border: 0; cursor: pointer;
  font-size: 20px; line-height: 1; color: var(--muted);
  padding: 4px 8px; border-radius: 7px; font-family: inherit;
}
.modal-close:hover { background: #eef1f5; color: var(--text); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot {
  padding: 14px 20px; border-top: 1px solid var(--line); background: #fafbfc;
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: #fafbfc; font-weight: 600; font-size: 13px; color: var(--muted); position: sticky; top: 0; }
tbody tr:hover { background: #fafbfc; }
tbody tr:last-child td { border-bottom: none; }
td.wrap-cell { white-space: normal; min-width: 180px; }

/* 卡片內的資訊表格（活動資訊、報名資料）：可換行，標題欄不套資料表的樣式 */
.info-table { font-size: 14px; }
.info-table th, .info-table td { white-space: normal; vertical-align: top; }
.info-table th {
  background: none; position: static; width: 96px;
  padding-left: 0; color: var(--muted); font-weight: 400;
}
.info-table td { padding-right: 0; }
.info-table td.wrap-cell { min-width: 0; }

/* ---------- stats ---------- */
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.stat .n { font-size: 30px; font-weight: 700; line-height: 1.15; }
.stat .l { font-size: 13px; color: var(--muted); }
.stat.brand .n { color: var(--brand); }
.stat.ok .n { color: var(--ok); }
.stat.warn .n { color: var(--warn); }

/* ---------- progress ---------- */
.bar { height: 8px; background: #eef1f5; border-radius: 99px; overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 99px; transition: width .3s; }
.bar > i.ok { background: var(--ok); }

/* ---------- ticket ---------- */
.ticket {
  background: #fff; border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow); overflow: hidden; text-align: center;
}
.ticket-head { padding: 20px; border-bottom: 1px dashed var(--line); }
.ticket-qr { padding: 24px 20px; }
.ticket-qr img { width: 240px; max-width: calc(70vw / var(--ui-scale)); height: auto; }
.ticket-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 24px; font-weight: 700; letter-spacing: 2px; margin-top: 8px;
}

/* ---------- checkin console ---------- */
.scan-box { background: #12161c; border-radius: var(--radius); overflow: hidden; position: relative; }
.scan-box video, .scan-box canvas { width: 100%; display: block; }
#reader { width: 100%; }
.result-panel { border-radius: var(--radius); padding: 20px; text-align: center; border: 2px solid; }
.result-panel.ok { background: #e3f5ee; border-color: var(--ok); }
.result-panel.dup { background: #fdf3dd; border-color: var(--warn); }
.result-panel.err { background: #fdeaea; border-color: var(--danger); }
.result-panel .icon { font-size: 40px; line-height: 1; }
.result-panel .who { font-size: 24px; font-weight: 700; margin: 6px 0 2px; }

.list-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; margin-bottom: 8px;
}
.list-item .name { font-weight: 600; }

/* 斷點 = 原始斷點 × --ui-scale（640 × 1.2 = 768）。
   媒體查詢量的是實際視窗寬度，不受 zoom 影響，所以要自己乘上倍率。 */
@media (max-width: 768px) {
  .card { padding: 18px; }
  h1 { font-size: 22px; }
  /* 左右內距要保留 .wrap 的 20px，否則標題會貼齊螢幕邊緣 */
  .topbar-in { height: auto; padding: 10px 20px; flex-wrap: wrap; gap: 10px; }
  th, td { padding: 8px 10px; }
}

@media print {
  .topbar, .no-print { display: none !important; }
  body { background: #fff; zoom: 1; }  /* 列印維持原尺寸，避免憑證超出紙張 */
  .ticket { box-shadow: none; }
}
