/* CSS เฉพาะโปรแกรมตรวจกระดาษคำตอบ (ใช้ตัวแปรธีม --ac ...) */
.app-content { max-width: none; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.grid-side { display: grid; grid-template-columns: minmax(300px, 420px) minmax(0, 1fr); gap: 18px; align-items: start; }
.grid-side-r { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 440px); gap: 18px; align-items: start; }
@media (max-width: 1199px) { .grid-side, .grid-side-r { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 991px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }
.stack > * + * { margin-top: 14px; }
.lbl { display: block; font-weight: 800; font-size: .86rem; margin: 0 0 5px; color: var(--ink, #0f172a); }
.fld { margin-bottom: 12px; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.muted { color: #64748b; font-size: .85rem; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px; background: var(--ac-soft); color: var(--ac-ink); font-weight: 800; font-size: .8rem; border: 1px solid var(--ac-line); }

/* ตัวเลือกการสอบ */
.exam-pick { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; padding: 10px 14px; border-radius: 16px; background: #fff; border: 1px solid var(--ac-line); box-shadow: 0 6px 18px rgba(15, 23, 42, .05); }
.exam-pick select { max-width: 520px; flex: 1 1 260px; font-weight: 700; }

/* ตัวอย่างกระดาษคำตอบ */
.sheet-preview { background: repeating-linear-gradient(45deg, #eef3f6 0 12px, #f6f9fb 12px 24px); border-radius: 16px; padding: 16px; display: flex; justify-content: center; }
.sheet-preview svg { width: 100%; max-width: 640px; height: auto; background: #fff; box-shadow: 0 14px 34px rgba(15, 23, 42, .18); border-radius: 4px; }
.sheet-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.sheet-card { border: 2px solid #e2e8f0; border-radius: 16px; padding: 10px; background: #fff; cursor: pointer; text-align: left; transition: border-color .15s, transform .15s; }
.sheet-card:hover { transform: translateY(-2px); }
.sheet-card.active { border-color: var(--ac); box-shadow: 0 0 0 4px var(--ac-soft); }
.sheet-card svg { width: 100%; height: auto; display: block; border-radius: 6px; border: 1px solid #e5e7eb; }
.sheet-card b { display: block; margin-top: 6px; font-size: .9rem; }
.sheet-card small { color: #64748b; }

/* ปุ่มฝนเฉลย */
.key-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 4px 18px; }
.key-row { display: flex; align-items: center; gap: 5px; padding: 3px 6px; border-radius: 10px; }
.key-row:nth-child(even) { background: #f8fafc; }
.key-row .qn { width: 30px; text-align: right; font-weight: 800; color: #475569; font-size: .85rem; }
.bub { width: 32px; height: 32px; border-radius: 50%; border: 2px solid #94a3b8; background: #fff; font-weight: 800; font-size: .82rem; color: #475569; display: inline-flex; align-items: center; justify-content: center; padding: 0; transition: transform .1s; }
.bub:hover { transform: scale(1.08); }
.bub.on { background: var(--ac); border-color: var(--ac); color: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, .18); }
.bub.ok { background: #16a34a; border-color: #16a34a; color: #fff; }
.bub.bad { background: #e11d48; border-color: #e11d48; color: #fff; }
.bub.key { box-shadow: 0 0 0 3px #86efac; border-color: #16a34a; }
.bub.multi { background: #f59e0b; border-color: #f59e0b; color: #fff; }
.bub.all { width: auto; padding: 0 8px; border-radius: 999px; font-size: .72rem; }
.key-row.is-wrong { background: #fff1f2 !important; }
.key-row.is-flag { background: #fffbeb !important; }
@media (pointer: coarse) { .bub { width: 38px; height: 38px; } }

/* สแกน */
.cam-stage { position: relative; background: #0b1f24; border-radius: 18px; overflow: hidden; aspect-ratio: 3 / 4; max-height: 70vh; margin: 0 auto; display: flex; align-items: center; justify-content: center; }
.cam-stage video, .cam-stage canvas.cam-img { width: 100%; height: 100%; object-fit: contain; }
.cam-stage canvas.cam-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.cam-stage .cam-msg { position: absolute; left: 12px; right: 12px; bottom: 12px; padding: 9px 12px; border-radius: 12px; background: rgba(15, 23, 42, .72); color: #fff; font-weight: 700; font-size: .88rem; text-align: center; }
.cam-stage .cam-msg.ok { background: rgba(22, 163, 74, .85); }
.cam-stage .cam-idle { color: #cbd5e1; text-align: center; padding: 30px; }
.cam-stage .cam-idle i { font-size: 3rem; color: var(--ac-2); margin-bottom: 10px; display: block; }
.cam-guide { position: absolute; inset: 6%; border: 3px dashed rgba(255, 255, 255, .45); border-radius: 10px; pointer-events: none; }
.cam-guide::before, .cam-guide::after { content: ''; position: absolute; width: 26px; height: 26px; background: rgba(255, 255, 255, .55); }
.cam-guide::before { left: -3px; top: -3px; } .cam-guide::after { right: -3px; bottom: -3px; }
.scan-list { display: flex; flex-direction: column; gap: 10px; }
.scan-item { display: grid; grid-template-columns: 74px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px; border-radius: 16px; border: 1px solid #e2e8f0; background: #fff; }
.scan-item img, .scan-item .noimg { width: 74px; height: 96px; object-fit: cover; border-radius: 8px; border: 1px solid #e2e8f0; background: #f1f5f9; display: flex; align-items: center; justify-content: center; color: #94a3b8; }
.scan-item .sc { font-size: 1.6rem; font-weight: 800; color: var(--ac-ink); line-height: 1; text-align: right; }
.scan-item .sc small { display: block; font-size: .75rem; color: #64748b; font-weight: 700; }
.scan-item.is-err { border-color: #fecdd3; background: #fff1f2; }
.tips { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.tip { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border-radius: 14px; background: #fff; border: 1px solid #e2e8f0; font-size: .86rem; }
.tip b { display: block; }

/* ผลรายแผ่น */
.res-list { max-height: 72vh; overflow: auto; display: flex; flex-direction: column; gap: 6px; }
.res-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; border: 1px solid #e2e8f0; background: #fff; text-align: left; width: 100%; }
.res-item.active { border-color: var(--ac); background: var(--ac-soft); }
.res-item .nm { flex: 1; min-width: 0; line-height: 1.25; }
.res-item .nm small { color: #64748b; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-item .scb { font-weight: 800; color: var(--ac-ink); }
.res-img { position: relative; background: #0b1f24; border-radius: 14px; overflow: hidden; }
.res-img canvas, .res-img svg { width: 100%; height: auto; display: block; }
.score-big { display: flex; align-items: baseline; gap: 6px; font-weight: 800; }
.score-big b { font-size: 2.6rem; color: var(--ac-ink); line-height: 1; }

/* ตาราง/สถิติ */
.dt td.num, .dt th.num { text-align: center; }
.dt tr.is-fail td { background: #fff7f7; }
.chart-box { position: relative; height: 280px; }
.dist-bar { display: inline-flex; gap: 2px; align-items: flex-end; height: 26px; }
.dist-bar span { width: 9px; background: #cbd5e1; border-radius: 2px 2px 0 0; }
.dist-bar span.k { background: #16a34a; }

/* รายงาน */
.doc-preview { background: #e9eef2; border-radius: 16px; padding: 18px; overflow: auto; max-height: 82vh; }
.doc-preview .gov-page { transform-origin: top center; }
@media (max-width: 860px) { .doc-preview .gov-page { zoom: .44; } }
.omr-signs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6mm; margin-top: 12mm; text-align: center; }
.omr-signs .gov-sign { margin: 0; }
.gov-sign-right { margin-left: 65mm; }
.gov-2 { display: flex; gap: 20mm; } .gov-2 span { flex: 1; }
.gov-sub { text-align: center; } .gov-note { margin-top: 3mm !important; font-size: 14pt; }
.gov-memo-head .gov-garuda { height: 15mm; }
.tpl-pick { display: flex; flex-direction: column; gap: 6px; }
.tpl-opt { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border: 1px solid #e2e8f0; border-radius: 12px; background: #fff; cursor: pointer; font-size: .86rem; }
.tpl-opt.active { border-color: var(--ac); background: var(--ac-soft); }

/* พิมพ์กระดาษคำตอบ */
.omr-page { width: 210mm; height: 297mm; background: #fff; overflow: hidden; break-after: page; page-break-after: always; }
.omr-page:last-child { break-after: auto; page-break-after: auto; }
.omr-page svg { width: 210mm; height: 297mm; display: block; }
#print-root { display: none; }

.workflow { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.wf { display: flex; gap: 12px; align-items: center; padding: 14px; border-radius: 18px; background: #fff; border: 1px solid #e2e8f0; box-shadow: 0 8px 20px rgba(15, 23, 42, .05); color: inherit; text-decoration: none; }
.wf:hover { border-color: var(--ac-line); color: inherit; }
.wf b { display: block; } .wf small { color: #64748b; }
@media (max-width: 1100px) { .workflow { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .workflow { grid-template-columns: minmax(0, 1fr); } .dash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
textarea.form-control { min-height: 84px; }

.seg.wrap { flex-wrap: wrap; max-width: 100%; }
.exam-pick > * { min-width: 0; }
@media (max-width: 560px) { .seg.wrap > button { flex: 1 1 auto; justify-content: center; } }
.res-item, .res-item:hover { text-decoration: none; color: inherit; }
@media (max-width: 560px) { .tb-term { display: none !important; } }
