:root {
  --bg: #f6f7f9; --surface: #ffffff; --surface-2: #f0f2f5; --text: #1c2430; --muted: #5d6878;
  --border: #dde2e8; --primary: #0f766e; --primary-ink: #ffffff; --primary-soft: #e0f2f1;
  --ok: #16a34a; --ok-soft: #dcfce7; --warn: #b45309; --warn-soft: #fef3c7;
  --bad: #dc2626; --bad-soft: #fee2e2; --info: #2563eb; --info-soft: #dbeafe;
  --radius: 10px; --shadow: 0 1px 3px rgba(16, 24, 40, .08);
  --font: 'Sarabun', 'Noto Sans Thai', system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151a; --surface: #1a2028; --surface-2: #222a34; --text: #e6eaef; --muted: #9aa5b3;
    --border: #2e3846; --primary: #2dd4bf; --primary-ink: #04201d; --primary-soft: #133a37;
    --ok: #4ade80; --ok-soft: #12321f; --warn: #fbbf24; --warn-soft: #3a2c0b;
    --bad: #f87171; --bad-soft: #3b1515; --info: #60a5fa; --info-soft: #132a4a;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 16px/1.55 var(--font); }
a { color: var(--primary); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 16px; }
.narrow { max-width: 520px; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar .wrap { display: flex; align-items: center; gap: 12px; padding-top: 10px; padding-bottom: 10px; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 14px;
  border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); font-weight: 600; }
.btn.danger { color: var(--bad); }
.btn.big { min-height: 52px; font-size: 1.1rem; padding: 10px 20px; }
.btn.sm { min-height: 32px; padding: 4px 10px; font-size: .875rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { width: 100%; min-height: 40px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; }
input[type=checkbox] { width: auto; min-height: 0; }
.field { margin-bottom: 12px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .85rem; color: var(--muted); font-weight: 600; }
.scroll { overflow-x: auto; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .8rem; background: var(--surface-2); color: var(--muted); }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); } .badge.info { background: var(--info-soft); color: var(--info); }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs a { padding: 8px 12px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a.on { color: var(--text); border-color: var(--primary); font-weight: 600; }
.notice { padding: 12px; border-radius: 8px; background: var(--info-soft); color: var(--text); margin-bottom: 12px; }
.notice.warn { background: var(--warn-soft); } .notice.bad { background: var(--bad-soft); } .notice.ok { background: var(--ok-soft); }
#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 50; display: grid; gap: 8px; width: min(92vw, 420px); }
#toast div { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.2); }
dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 0; width: min(94vw, 560px); }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog .dlg-body { padding: 16px; max-height: 75vh; overflow: auto; }
dialog .dlg-foot { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }
.cell { min-width: 34px; text-align: center; cursor: pointer; border-radius: 6px; font-weight: 600; }
.cell:hover { outline: 2px solid var(--primary); }
.sticky-col { position: sticky; left: 0; background: var(--surface); z-index: 1; }
/* จอ QR หน้าห้อง */
.projector { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 16px; background: #fff; color: #111; }
.projector .qr svg { width: min(78vmin, 640px); height: auto; display: block; }
.projector .bar { height: 6px; background: #0f766e; border-radius: 3px; transition: width .25s linear; }
.projector .big-count { font-size: clamp(1.5rem, 4vw, 2.5rem); font-weight: 700; }
/* หน้าผลเช็คชื่อนักศึกษา */
.result { text-align: center; padding: 24px 16px; border-radius: var(--radius); }
.result .icon { font-size: 3rem; line-height: 1; }
.result.ok { background: var(--ok-soft); } .result.warn { background: var(--warn-soft); } .result.bad { background: var(--bad-soft); }
.hide { display: none !important; }
@media (max-width: 600px) { .wrap { padding: 12px 16px; } h1 { font-size: 1.3rem; } }
