/* KruHub — สไตล์กลางตาม mockup (น้ำเงิน #3D58E8 / #5170FF · Anuphan + IBM Plex Sans Thai) */
:root {
  --bg: #F4F5FA; --surface: #FFFFFF; --ink: #161A33; --muted: #5A6079; --line: #E3E5EF; --line2: #EEF0F6;
  --accent: #3D58E8; --accent-deep: #2A41B8; --accent-soft: #E6EAFF; --accent-line: #C9D2FF;
  --ok: #157F3C; --ok-soft: #DCF3E3; --warn: #8A4309; --warn-soft: #FDF0E3; --bad: #B42318; --bad-soft: #FDE4E1;
  --font-display: 'Anuphan', 'IBM Plex Sans Thai', system-ui, sans-serif;
  --font-body: 'IBM Plex Sans Thai', system-ui, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font-body); }
a { color: var(--accent); text-decoration: none; } a:hover { color: var(--accent-deep); }
h1, h2, h3 { font-family: var(--font-display); margin: 0; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar .in { max-width: 1200px; margin: 0 auto; padding: 12px 24px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font: 700 18px var(--font-display); }
.logo { width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: #fff; display: grid; place-items: center; font: 700 18px var(--font-display); }
.who { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-deep); display: grid; place-items: center; font-weight: 600; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; font-size: 14px; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: var(--accent); color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--accent-deep); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.sm { min-height: 32px; padding: 4px 12px; font-size: 13px; }

main.page { max-width: 1200px; margin: 0 auto; padding: 36px 24px 56px; display: flex; flex-direction: column; gap: 32px; }
.muted { color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.section-title { font-size: 20px; font-weight: 600; margin-bottom: 14px; }

.apps { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr)); gap: 16px; }
.app-card { padding: 22px; display: flex; flex-direction: column; gap: 14px; color: var(--ink); }
.app-card:hover { border-color: var(--accent); color: var(--ink); box-shadow: 0 6px 20px rgba(40, 50, 100, .08); }
.app-card .ic { width: 44px; height: 44px; border-radius: 12px; background: var(--accent-soft); display: grid; place-items: center; }
.app-card b { font: 700 18px var(--font-display); }
.app-card .role { font-size: 12px; font-weight: 600; background: var(--bg); border: 1px solid var(--line); color: var(--muted); border-radius: 999px; padding: 2px 10px; align-self: flex-start; }

.list .row { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding: 16px 22px; border-bottom: 1px solid var(--line2); }
.list .row:last-child { border-bottom: 0; }
.tag { font-size: 12px; font-weight: 600; border-radius: 6px; padding: 4px 8px; background: var(--accent-soft); color: var(--accent-deep); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.gray { background: var(--line2); color: #3B4060; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 32px; }
.login { width: 100%; max-width: 420px; padding: 40px 36px; display: flex; flex-direction: column; gap: 28px; align-items: stretch; text-align: center; }
.login .logo { width: 56px; height: 56px; border-radius: 16px; font-size: 26px; margin: 0 auto; }
.login .gbtn { min-height: 52px; font-size: 16px; font-weight: 600; border-color: #C9CDDC; }
.alert { border-radius: 12px; padding: 12px 14px; font-size: 14px; text-align: left; }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }

/* tables / forms */
table.t { width: 100%; border-collapse: collapse; }
table.t th, table.t td { padding: 12px 14px; border-bottom: 1px solid var(--line2); text-align: left; font-size: 14px; vertical-align: middle; }
table.t th { font-size: 13px; font-weight: 500; color: var(--muted); background: #F7F8FC; }
table.t tr:last-child td { border-bottom: 0; }
.scroll { overflow-x: auto; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.field input, .field select, select.inline { border: 1px solid #C9CDDC; border-radius: 8px; padding: 8px 10px; background: var(--surface); color: var(--ink); min-height: 38px; font-size: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 12px 14px; align-items: end; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); }
.check input { width: 18px; height: 18px; }
.inline-form { display: inline; }
details.edit summary { cursor: pointer; color: var(--accent); font-size: 13px; list-style: none; }
details.edit[open] { background: #F7F8FC; border-radius: 10px; padding: 12px; margin-top: 8px; }

.soon { padding: 48px 24px; text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; }

/* ---------- ทั่วไป ---------- */
h1 { font-size: 26px; } h2 { font-size: 20px; } h3 { font-size: 16px; }
p { margin: 4px 0 0; }
.small { font-size: 13px; }
.grow { flex: 1 1 auto; min-width: 0; }
.nowrap { white-space: nowrap; }
.pad { padding: 18px 22px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row-between { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.row-gap { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.center { text-align: center; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
fieldset.plain { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.plain legend { padding: 0; margin-bottom: 6px; }
textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid #C9CDDC; border-radius: 8px; padding: 10px; width: 100%; }
tr.dim td { opacity: .55; }
.done { text-decoration: line-through; color: var(--muted); }
.edit-box summary { cursor: pointer; list-style: none; }
.edit-box summary::-webkit-details-marker { display: none; }
details.edit form { margin-top: 8px; }

/* แท็บวิชา */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.tabs a.on { color: var(--accent-deep); border-color: var(--accent); }
.dot { background: var(--warn); color: #fff; font-size: 11px; font-weight: 600; border-radius: 999px; padding: 0 7px; line-height: 18px; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; background: var(--line2); border-radius: 10px; padding: 4px; align-self: flex-start; }
.seg a { padding: 6px 14px; border-radius: 8px; color: var(--muted); font-size: 14px; font-weight: 500; }
.seg a.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* การ์ดรายวิชา */
.courses { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); gap: 16px; }
.course { padding: 20px; display: flex; flex-direction: column; gap: 10px; color: var(--ink); }
.course:hover { border-color: var(--accent); color: var(--ink); box-shadow: 0 6px 20px rgba(40,50,100,.08); }
.course b { font: 700 18px var(--font-display); }
.cname { font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; color: var(--muted); }
.bar { height: 6px; background: var(--line2); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }

/* ตัวเลขสรุป */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); gap: 12px; }
.stat { padding: 16px 18px; display: flex; flex-direction: column; gap: 2px; color: var(--ink); }
.stat span { color: var(--muted); font-size: 13px; }
.stat b { font: 700 26px var(--font-display); }
.stat small { color: var(--muted); font-size: 12px; }
a.stat:hover { border-color: var(--accent); color: var(--ink); }
.links { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 12px; }
.links a { word-break: break-all; }
.qr-sm svg { width: 140px; height: 140px; }

/* จอฉาย QR */

/* ---------- หน้านักศึกษา (มือถือ · ตามธีมเครื่อง) ---------- */
body.stu { color-scheme: light dark; }
.stu-wrap { max-width: 460px; margin: 0 auto; padding: 16px 16px 40px; display: flex; flex-direction: column; gap: 14px; }
.stu-head { display: flex; align-items: center; gap: 12px; padding: 4px 0; }
.stu-h { font-size: 22px; }
.stu-tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--line2); border-radius: 12px; padding: 4px; }
.stu-tabs a { text-align: center; padding: 10px; border-radius: 9px; color: var(--muted); font-weight: 600; }
.stu-tabs a.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.stu-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.stu-card.center { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding: 32px 18px; }
.stu-day { display: flex; gap: 12px; align-items: center; background: var(--accent-soft); border-radius: 12px; padding: 12px 14px; color: var(--ink); }
.w { font: 700 13px var(--font-display); background: var(--accent); color: #fff; border-radius: 8px; padding: 4px 8px; flex: none; }
.stu-me { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0; }
.stu-me b { font: 700 22px var(--font-display); }
.field.big input { min-height: 52px; font-size: 20px; text-align: center; letter-spacing: .04em; }
input.pin { font: 700 32px var(--font-display) !important; letter-spacing: .3em; }
.btn.block { width: 100%; min-height: 52px; font-size: 16px; }
.big-ic { font-size: 40px; line-height: 1; }
.big-ic.ok { width: 64px; height: 64px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); display: grid; place-items: center; font-size: 32px; font-weight: 700; }
.row-form { display: flex; gap: 10px; align-items: flex-end; }
.stu-sum { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.stu-sum div { border-radius: 12px; padding: 10px 4px; text-align: center; display: flex; flex-direction: column; }
.stu-sum b { font: 700 24px var(--font-display); }
.stu-sum span { font-size: 13px; }
.s-present { background: var(--ok-soft); color: var(--ok); }
.s-late { background: var(--warn-soft); color: var(--warn); }
.s-absent { background: var(--bad-soft); color: var(--bad); }
.s-leave { background: var(--accent-soft); color: var(--accent-deep); }
.list-plain { padding: 4px 18px; }
.stu-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line2); }
.stu-row:last-child { border-bottom: 0; }
.steps { display: flex; gap: 6px; } .steps i { flex: 1; height: 4px; border-radius: 9px; background: var(--line); } .steps i.on { background: var(--accent); }
.lbl { font-weight: 600; font-size: 14px; color: var(--ink); }
.pick { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 12px; padding: 12px; cursor: pointer; }
.pick:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.pick input { width: 20px; height: 20px; }
.seg-radio { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg-radio label { border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-align: center; cursor: pointer; font-weight: 500; }
.seg-radio label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-deep); }
.seg-radio input { position: absolute; opacity: 0; }

@media (prefers-color-scheme: dark) {
  body.stu {
    --bg: #0F1222; --surface: #181C30; --ink: #E8EAF6; --muted: #9AA0BD; --line: #2A2F4A; --line2: #222740;
    --accent: #5170FF; --accent-deep: #9DB0FF; --accent-soft: #232B55; --accent-line: #3A4680;
    --ok: #6DD58C; --ok-soft: #173826; --warn: #F5B86B; --warn-soft: #3A2A16; --bad: #FF8A80; --bad-soft: #3D1B1B;
  }
  body.stu .field input, body.stu textarea { background: var(--bg); border-color: var(--line); color: var(--ink); }
  body.stu .btn { background: var(--surface); border-color: var(--line); color: var(--ink); }
  body.stu .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
  body.stu .tag.gray { background: var(--line2); color: var(--muted); }
}
.danger-zone { border-color: #F3C9C4; }
.danger-zone h3 { color: var(--bad); }
.danger-zone .row-gap { align-items: flex-end; }

/* ---------- ตัวช่วยสร้างวิชา ---------- */
.wiz { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr)); gap: 10px; }
.wiz-step { display: flex; gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; color: var(--ink); }
a.wiz-step:hover { border-color: var(--accent); color: var(--ink); }
.wiz-step b { display: block; font-size: 14px; }
.wiz-step small { display: block; font-size: 12px; color: var(--muted); }
.wiz-n { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--line2); color: var(--muted); font-weight: 600; font-size: 13px; }
.wiz-step.on { border-color: var(--accent); background: var(--accent-soft); }
.wiz-step.on .wiz-n { background: var(--accent); color: #fff; }
.wiz-step.ok .wiz-n { background: var(--ok-soft); color: var(--ok); }
.wiz-foot { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.grid6 { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(170px, 100%), 1fr)); gap: 12px 14px; }
.grid6 .span2 { grid-column: span 2; }
@media (max-width: 560px) { .grid6 .span2 { grid-column: auto; } }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid4 { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(160px, 100%), 1fr)); gap: 14px; }
@media (max-width: 560px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
details.pop { position: relative; display: inline-block; }
details.pop > summary { list-style: none; cursor: pointer; }
details.pop > summary::-webkit-details-marker { display: none; }
.pop-body { position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; width: 300px; box-shadow: 0 12px 30px rgba(20,25,60,.14); }
.pop-body.wide { width: min(560px, 90vw); }
details.pop.right .pop-body { left: auto; right: 0; }
.dlg { border: 0; border-radius: 16px; padding: 0; width: min(1000px, 94vw); max-height: 90vh; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.dlg::backdrop { background: rgba(22,26,51,.45); }
.dlg form { display: flex; flex-direction: column; max-height: 90vh; }
.dlg-head, .dlg-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 20px; border-bottom: 1px solid var(--line2); }
.dlg-foot { border-top: 1px solid var(--line2); border-bottom: 0; justify-content: flex-end; }
.dlg-body { padding: 16px 20px; overflow: auto; }
.dlg table select { min-width: 140px; font-size: 13px; padding: 6px 8px; }
.choice { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { margin-top: 4px; }
.sched { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 32px; }
@media (max-width: 860px) { .sched { grid-template-columns: 1fr; } }
.days { display: flex; flex-wrap: wrap; gap: 8px; }
.daybtn input, .slotbtn input[type=radio] { position: absolute; opacity: 0; }
.daybtn span { display: grid; place-items: center; width: 52px; height: 44px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; font-weight: 500; }
.daybtn input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.daybtn input:focus-visible + span { outline: 2px solid var(--accent-deep); outline-offset: 2px; }
.slotbtn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; cursor: pointer; }
.slotbtn:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.prow { display: flex; gap: 14px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line2); }
.prow b { width: 34px; }
.prow.skip { color: var(--muted); }
.prow.skip .grow { text-decoration: line-through; }
.chip .x { border: 0; background: none; color: var(--muted); cursor: pointer; font: inherit; padding: 0 2px; }
.parts input, .parts select { width: 100%; }
.grades { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.grade { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; }
.grade input { width: 64px; text-align: center; padding: 6px; }
.grade .x { border: 1px solid var(--line); background: var(--surface); color: var(--bad); border-radius: 6px; cursor: pointer; width: 28px; height: 28px; margin-left: auto; }
fieldset.plain-card { border: 1px solid var(--line); margin: 0; min-width: 0; }
.page input:not([type=checkbox]):not([type=radio]):not([type=file]), .page select, .page textarea { border: 1px solid #C9CDDC; border-radius: 8px; padding: 8px 10px; background: var(--surface); color: var(--ink); font: inherit; font-size: 14px; min-height: 38px; }
.page input[readonly] { background: var(--line2); }
.parts td { vertical-align: top; }
.parts .pname { margin-top: 6px; }
.pexam { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; margin-top: 8px; }
.pexam label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.pexam input { width: 100px !important; }
.pexam .pex { flex-basis: 100%; }
.parts td:first-child { min-width: 230px; }

/* ---------- แท็บเช็คชื่อ ---------- */
.ok-t { color: var(--ok); } .bad-t { color: var(--bad); } .warn-t { color: var(--warn); } .ink { color: var(--ink); }
.linkbtn, .link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; }
.linkbtn:hover, .link:hover { color: var(--accent-deep); text-decoration: underline; }
.day { overflow: visible; }
.day.today { border-color: var(--accent); }
.day-h { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 12px 18px; background: #F7F8FC; border-bottom: 1px solid var(--line2); border-radius: 14px 14px 0 0; }
.day-h b { font-size: 15px; }
.slot { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 16px; padding: 12px 18px; border-bottom: 1px solid var(--line2); }
.slot:last-child { border-bottom: 0; }
.slot.live { background: #F5FBF7; box-shadow: inset 3px 0 0 var(--ok); }
.slot.dim { opacity: .6; }
.slot-n { width: 40px; align-self: center; font-size: 15px; }
.slot-f { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.slot-f label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.slot-f input[type=time] { width: 122px; }
.slot-f select { min-width: 96px; }
.slot-f .saved { align-self: center; min-width: 80px; }
.slot-a { flex: 1 1 260px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; align-self: center; }
details.past > summary { cursor: pointer; color: var(--accent); }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.mk { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 7px; border: 1px solid transparent; font: 600 13px inherit; padding: 0; cursor: pointer; vertical-align: middle; }
.legend .mk { width: 22px; height: 22px; font-size: 12px; cursor: default; }
.m-present { background: var(--ok-soft); color: var(--ok); }
.m-late { background: var(--warn-soft); color: var(--warn); }
.m-absent { background: var(--bad-soft); color: var(--bad); }
.m-leave { background: var(--accent-soft); color: var(--accent-deep); }
.m-none { background: var(--surface); border-color: var(--line); }
.mk.ed { border: 2px solid currentColor; }
.mk.nc { opacity: .55; }
.mk:disabled { cursor: default; }
.grid-wrap { max-height: 75vh; }
.att { border-collapse: separate; border-spacing: 0; }
.att th, .att td { white-space: nowrap; }
.att thead th { position: sticky; top: 0; z-index: 2; }
.att thead tr:nth-child(2) th { top: 44px; }
.att .sticky { position: sticky; left: 0; background: var(--surface); z-index: 1; }
.att thead .sticky { z-index: 3; background: #F7F8FC; }
.att .wk { text-align: center; border-left: 1px solid var(--line); }
.att .wk small { display: block; font-weight: 400; font-size: 11px; color: var(--muted); }
.att .wk.now { background: var(--accent-soft); color: var(--accent-deep); }
.att .sl { text-align: center; font-size: 12px; padding: 6px 4px; }
.att .sl.nc { color: var(--muted); font-style: italic; }
.att td.c { text-align: center; padding: 4px 3px; }
.att td.tot { text-align: center; font-weight: 600; }

/* ---------- หัววิชา + Dashboard ---------- */
.chip.acc { background: var(--accent-soft); border-color: var(--accent-soft); color: var(--accent-deep); font-weight: 500; }
.ov { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
@media (max-width: 960px) { .ov { grid-template-columns: 1fr; } }
.legend .lg { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-left: 6px; }
.s-p { background: #2E9E5B; } .s-l { background: #E9A23B; } .s-v { background: #9B6BD8; } .s-a { background: #D9483B; }
.bars { display: flex; gap: 10px; align-items: stretch; height: 280px; margin-top: 12px; overflow-x: auto; }
.bar-col { flex: 1 0 44px; display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; }
.bar-col b { font-size: 13px; margin-top: 6px; }
.bar-col small { font-size: 11px; color: var(--muted); }
.bar-v { flex: 1; width: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; }
.bar-pct { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.bar-stack { display: flex; flex-direction: column; border-radius: 6px 6px 0 0; overflow: hidden; min-height: 6px; }
.bar-stack i { display: block; min-height: 0; }
.bar-empty { height: 100%; border: 1px dashed var(--line); border-radius: 6px; }
.todo { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.todo li { display: flex; gap: 12px; font-size: 14px; }
.todo li b { min-width: 24px; color: var(--warn); }
.prog { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.brk { word-break: break-all; }
.smenu { position: absolute; z-index: 50; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 30px rgba(20,25,60,.16); padding: 6px; display: flex; flex-direction: column; min-width: 160px; }
.smenu button { display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 8px 10px; border-radius: 8px; font: inherit; font-size: 15px; cursor: pointer; text-align: left; color: var(--ink); }
.smenu button:hover, .smenu button:focus-visible { background: var(--line2); outline: none; }
.smenu .mk { width: 26px; height: 26px; border-radius: 50%; cursor: inherit; }
.m-clear { background: var(--line2); color: var(--muted); }

/* ---------- จอ QR (ตามแอปเดิม) ---------- */
.qr-screen { min-height: 100vh; display: flex; flex-direction: column; padding: 28px 40px; gap: 24px; background: var(--bg); }
.qr-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px; }
.qr-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px; }
.qr-title b { font: 700 clamp(24px, 3.2vw, 40px) var(--font-display); }
.qr-title .w { font-size: 16px; padding: 4px 10px; align-self: center; }
.qr-body { flex: 1; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: clamp(24px, 6vw, 80px); }
.qr-card { background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 24px; }
.qr-big { width: min(62vh, 44vw, 640px); aspect-ratio: 1; display: grid; place-items: center; }
.qr-big svg { width: 100%; height: 100%; }
.qr-side { flex: 1 1 360px; max-width: 680px; display: flex; flex-direction: column; gap: 14px; align-items: flex-start; }
.qr-hint { font-size: clamp(16px, 1.6vw, 22px); }
.qr-code { font: 800 clamp(96px, 14vw, 220px)/1 var(--font-display); letter-spacing: .1em; color: #111318; font-variant-numeric: tabular-nums; }
.qr-timer { width: 100%; height: 12px; background: var(--line); border-radius: 99px; overflow: hidden; }
.qr-timer i { display: block; height: 100%; background: var(--accent); transition: width .25s linear; }
.qr-host { font: 700 clamp(20px, 2.2vw, 32px) var(--font-display); color: #111318; }
.qr-count { font-size: 18px; }
.qr-count b { font: 700 32px var(--font-display); }
@media (max-width: 760px) { .qr-big { width: 82vw; } .qr-side { align-items: center; text-align: center; } }

/* ---------- ความเป็นระเบียบ: ปุ่ม/ป้าย/ช่องสูงเท่ากัน เส้นฐานตรงกัน ---------- */
.btn { font-family: inherit; line-height: 1.2; box-sizing: border-box; height: 40px; min-height: 40px; vertical-align: middle; text-decoration: none; }
.btn.sm { height: 34px; min-height: 34px; padding: 0 12px; font-size: 13px; font-weight: 500; }
.btn.sm.primary { font-weight: 600; }
.btn.block { height: 52px; }
.inline-form { display: inline-flex; margin: 0; vertical-align: middle; }
.tag { display: inline-flex; align-items: center; height: 26px; box-sizing: border-box; line-height: 1; white-space: nowrap; vertical-align: middle; }
.row-gap { align-items: center; }
.page input:not([type=checkbox]):not([type=radio]):not([type=file]), .page select { height: 40px; box-sizing: border-box; }
/* แถวรอบเรียน: ทุกอย่างวางบนเส้นเดียวกับช่องเวลา */
.slot { align-items: flex-end; }
.slot-n { align-self: flex-end; height: 40px; display: flex; align-items: center; }
.slot-f { align-items: flex-end; }
.slot-f input[type=time], .slot-f select { height: 40px; }
.slot-f .saved { align-self: flex-end; height: 40px; display: flex; align-items: center; }
.slot-a { align-self: flex-end; min-height: 40px; align-items: center; }
.slot-a .btn.sm { height: 34px; }
.day-h { min-height: 58px; box-sizing: border-box; }
.day-h .link, .day-h .linkbtn { height: 34px; display: inline-flex; align-items: center; }
details.pop > summary.link, details.pop > summary.small { display: inline-flex; align-items: center; height: 34px; }

/* ---------- แท็บคะแนน ---------- */
.sc th small { display: block; font-weight: 400; font-size: 11px; color: var(--muted); }
.sc .sc-in { width: 76px; height: 32px; min-height: 32px; padding: 0 6px; text-align: center; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.sc .sc-in:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.sc .sc-in.err { border-color: var(--bad); background: var(--bad-soft); }
.sc .sc-in.saving { opacity: .6; }
.sc .sc-in:disabled { background: transparent; border-color: transparent; color: var(--ink); }
.sc .sum { min-width: 52px; height: 32px; padding: 0 8px; border: 1px solid transparent; border-radius: 8px; background: var(--line2); font: inherit; font-weight: 600; cursor: pointer; color: var(--ink); }
.sc .sum:hover:not(:disabled) { border-color: var(--accent-line); }
.sc .sum.ovr { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.sc .sum.tot { background: var(--accent-soft); color: var(--accent-deep); }
.sc .sum.tot.ovr { background: var(--warn-soft); color: var(--warn); }
.sc .sum:disabled { cursor: default; }
.sc .ok-t { color: var(--ok); font-weight: 600; } .sc .bad-t { color: var(--bad); font-weight: 600; }
.linkbtn { border: 0; background: none; padding: 0; font: inherit; color: var(--accent); cursor: pointer; }
.linkbtn:hover { color: var(--accent-deep); text-decoration: underline; }
.sc-key { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; margin: 0 4px 0 8px; border: 1px solid transparent; }
.sc-key.calc { background: var(--line2); } .sc-key.ovr { background: var(--warn-soft); border-color: var(--warn); }
.scpop { gap: 8px; padding: 12px; min-width: 220px; }
.scpop label { display: flex; flex-direction: column; gap: 4px; }
.scpop input:not([type=checkbox]) { height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; }
.scpop label.row-gap { flex-direction: row; align-items: center; }
.stack-xs { display: flex; flex-direction: column; gap: 4px; }
