:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --line: #dde1e7;
  --text: #1c2430;
  --muted: #5d6878;
  --brand: #1f5fa8;
  --brand-ink: #ffffff;
  --brand-soft: #e6eef8;
  --ok: #1f7a4a;
  --ok-soft: #e3f3ea;
  --warn: #9a6400;
  --warn-soft: #fbf0d9;
  --bad: #b3261e;
  --bad-soft: #fbe5e3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161c;
    --surface: #1b2129;
    --surface-2: #232a34;
    --line: #313a46;
    --text: #e6e9ee;
    --muted: #9aa5b4;
    --brand: #5b9be0;
    --brand-ink: #0d1520;
    --brand-soft: #1d2d42;
    --ok: #5cc48c;
    --ok-soft: #173326;
    --warn: #e2b04a;
    --warn-soft: #382c12;
    --bad: #f08a80;
    --bad-soft: #3d1c1a;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.3; margin: 0; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* 版面 */
.topbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 20px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.topbar .brand { font-weight: 700; font-size: 17px; margin-right: auto; display: flex; align-items: center; gap: 8px; }
.topbar .brand svg { width: 22px; height: 22px; color: var(--brand); }
.wrap { max-width: 1180px; margin: 0 auto; padding: 20px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1 1 auto; }
.stack > * + * { margin-top: 12px; }

/* 表單 */
label.field { display: block; font-size: 13px; color: var(--muted); }
label.field > span { display: block; margin-bottom: 4px; }
input[type="text"], input[type="password"], input[type="search"], input[type="email"], input[type="tel"],
input[type="datetime-local"], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px;
}
textarea { min-height: 160px; font-family: ui-monospace, Consolas, "Noto Sans TC", monospace; font-size: 13px; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 500; padding: 8px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); white-space: nowrap;
  text-decoration: none;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn.lg { padding: 12px 20px; font-size: 17px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 16px; height: 16px; }

/* 會議清單 */
.meeting-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.meeting-item { padding: 16px 18px; cursor: pointer; text-align: left; font: inherit; color: inherit; width: 100%; }
.meeting-item:hover { border-color: var(--brand); }
.meeting-item h3 { font-size: 16px; margin-bottom: 4px; }
.bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-top: 10px; }
.bar > i { display: block; height: 100%; background: var(--ok); }

/* 統計 */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat { padding: 14px 16px; }
.stat .k { font-size: 13px; color: var(--muted); }
.stat .v { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat.ok .v { color: var(--ok); }

/* 名單表 */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.toolbar input[type="search"] { max-width: 280px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { font: inherit; font-size: 13px; padding: 6px 12px; border: 0; background: var(--surface); color: var(--muted); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 13px; font-weight: 600; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
tbody tr:hover { background: var(--surface-2); }
td.actions { white-space: nowrap; text-align: right; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }

.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.no { background: var(--surface-2); color: var(--muted); }

/* 對話框 */
dialog { border: 1px solid var(--line); border-radius: 12px; padding: 0; background: var(--surface); color: var(--text); width: min(560px, calc(100vw - 32px)); box-shadow: 0 12px 40px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(10, 14, 20, .5); }
dialog header { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
dialog header h2 { font-size: 17px; flex: 1; }
dialog .body { padding: 18px 20px; }
dialog footer { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
dialog.wide { width: min(760px, calc(100vw - 32px)); }
.x { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 22px; line-height: 1; padding: 2px 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.qr-box { width: 240px; max-width: 100%; margin: 0 auto; background: #fff; padding: 6px; border-radius: 8px; }
.qr-box svg { display: block; width: 100%; height: auto; }
.copyline { display: flex; gap: 6px; }
.copyline input { font-size: 13px; }
.preview { max-height: 220px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; margin-top: 10px; }
.preview table { font-size: 13px; }
.note { font-size: 13px; color: var(--muted); background: var(--surface-2); border-radius: 8px; padding: 10px 12px; }

/* 提示 */
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: #1c2430; color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.25); transition: opacity .3s; }
.toast.bad { background: var(--bad); }
.toast.ok { background: var(--ok); }
.toast.out { opacity: 0; }

/* 名牌（mm 單位，編輯器與列印共用） */
.bd {
  position: relative; overflow: hidden; background: #fff; color: #111;
  font-family: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", sans-serif; line-height: 1.25;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.bd-bg { position: absolute; inset: 0; width: 100%; height: 100%; }
.bd-bg svg { display: block; width: 100%; height: 100%; }
img.bd-bg { object-fit: cover; }
.bd-el { position: absolute; }
.bd-text { white-space: pre-wrap; word-break: break-word; }
.bd-text[data-fit] { white-space: nowrap; overflow: hidden; }
.bd-qr { background: #fff; }
.bd-qr svg { display: block; width: 100%; height: 100%; }
.bd-logo img { display: block; width: 100%; height: 100%; object-fit: contain; }
.bd-logo.bd-ph { border: 1px dashed #9aa5b4; color: #8a94a3; display: flex; align-items: center; justify-content: center; font-size: 8pt; background: rgba(255,255,255,.6); }

/* 登入 */
.login { max-width: 380px; margin: 12vh auto; }

@media (max-width: 760px) {
  .wrap { padding: 16px; }
  .topbar { padding: 10px 16px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid2 { grid-template-columns: 1fr; }
  .toolbar input[type="search"] { max-width: none; flex: 1 1 100%; }
  .hide-sm { display: none; }
}
