:root {
    --ink: #17312e;
    --muted: #667672;
    --paper: #f5f3ec;
    --surface: #ffffff;
    --surface-soft: #eef3f0;
    --line: #dfe6e2;
    --brand: #174c45;
    --brand-deep: #113a35;
    --brand-soft: #dfece8;
    --accent: #e6ad2f;
    --accent-soft: #fff2cf;
    --danger: #b9463f;
    --danger-soft: #fae6e3;
    --success: #2e7b57;
    --success-soft: #e1f1e8;
    --shadow: 0 10px 30px rgba(22, 49, 45, .08);
    --radius: 16px;
}

html[data-theme="ocean"] {
    --ink: #18343e; --muted: #667b83; --paper: #f1f5f6; --surface-soft: #eaf2f5; --line: #d9e4e8;
    --brand: #155a75; --brand-deep: #10475d; --brand-soft: #dcecf2; --accent: #e4a72e; --accent-soft: #fff1cc;
}
html[data-theme="indigo"] {
    --ink: #272f4a; --muted: #70758a; --paper: #f4f3f7; --surface-soft: #eeedf5; --line: #e0dfea;
    --brand: #3f4b82; --brand-deep: #303a68; --brand-soft: #e2e5f2; --accent: #d9a62c; --accent-soft: #fff1cd;
}
html[data-theme="burgundy"] {
    --ink: #442b33; --muted: #806e73; --paper: #f7f2f2; --surface-soft: #f3e9ec; --line: #eadcdf;
    --brand: #7a3346; --brand-deep: #5d2736; --brand-soft: #f0dfe4; --accent: #d6a138; --accent-soft: #fff0cf;
}
html[data-theme="graphite"] {
    --ink: #283238; --muted: #707b80; --paper: #f2f3f2; --surface-soft: #ecefee; --line: #dce1df;
    --brand: #38434a; --brand-deep: #293238; --brand-soft: #e1e6e5; --accent: #d3a129; --accent-soft: #fff0c9;
}

* { box-sizing: border-box; }

html { max-width: 100%; overflow-x: hidden; font-family: "Noto Sans Thai", Tahoma, sans-serif; color: var(--ink); background: var(--paper); }
body { margin: 0; min-height: 100vh; max-width: 100%; overflow-x: hidden; font-size: 15px; line-height: 1.55; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin-top: 0; }

/* SweetAlert2 uses the same visual language as the rest of the application. */
.app-swal-popup { width: min(430px, calc(100vw - 32px)); padding: 28px; border: 1px solid var(--line); border-radius: 20px; color: var(--ink); box-shadow: 0 24px 70px rgba(17,58,53,.2); font-family: "Noto Sans Thai", Tahoma, sans-serif; }
.app-swal-title { padding: 0; color: var(--ink); font-size: 22px; line-height: 1.35; }
.app-swal-message { margin-top: 10px; padding: 0; color: var(--muted); font-size: 14px; line-height: 1.7; }
.app-swal-actions { gap: 10px; margin-top: 24px; }
.app-swal-confirm, .app-swal-cancel { min-width: 104px; min-height: 42px; padding: 9px 18px; border: 1px solid transparent; border-radius: 10px; font-family: inherit; font-weight: 600; cursor: pointer; }
.app-swal-confirm { color: #fff; background: var(--brand); box-shadow: 0 6px 16px rgba(23,76,69,.18); }
.app-swal-confirm:hover { background: var(--brand-deep); }
.app-swal-cancel { border-color: var(--line); color: var(--ink); background: var(--surface); }
.app-swal-cancel:hover { background: var(--surface-soft); }
.app-swal-toast { border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); font-family: "Noto Sans Thai", Tahoma, sans-serif; }
.app-swal-toast-title { color: var(--ink); font-size: 14px; font-weight: 600; line-height: 1.55; }
.swal2-container { z-index: 10000; }
.swal2-icon { margin-top: 2px; transform: scale(.88); }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 264px minmax(0, 1fr); }
.sidebar { position: fixed; z-index: 30; inset: 0 auto 0 0; width: 264px; padding: 24px 18px; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; display: flex; flex-direction: column; background: var(--brand-deep); color: #fff; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 26px; border-bottom: 1px solid rgba(255,255,255,.11); }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 12px; color: var(--brand-deep); background: var(--accent); font-weight: 800; letter-spacing: -.04em; }
.brand-logo { width: 42px; height: 42px; padding: 2px; display: block; flex: 0 0 auto; border-radius: 12px; background: rgba(255,255,255,.92); object-fit: contain; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; line-height: 1.35; }
.brand small { margin-top: 2px; max-width: 160px; color: rgba(255,255,255,.58); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-nav { display: flex; flex-direction: column; gap: 5px; padding-top: 24px; }
.nav-caption { padding: 0 12px 8px; color: rgba(255,255,255,.42); font-size: 11px; font-weight: 700; letter-spacing: .08em; }
.nav-item { min-height: 44px; padding: 10px 12px; display: flex; align-items: center; gap: 12px; border-radius: 10px; color: rgba(255,255,255,.73); font-size: 14px; font-weight: 500; transition: background .18s, color .18s, transform .18s; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.07); transform: translateX(2px); }
.nav-item.active { color: #fff; background: rgba(255,255,255,.13); }
.nav-item.active::after { content: ""; width: 4px; height: 18px; margin-left: auto; border-radius: 8px; background: var(--accent); }
.nav-icon { width: 22px; text-align: center; opacity: .9; font-size: 17px; }
.nav-icon[data-icon="grid"]::before { content: "▦"; }
.nav-icon[data-icon="users"]::before { content: "◉"; }
.nav-icon[data-icon="book"]::before { content: "▤"; }
.nav-icon[data-icon="clipboard"]::before { content: "☑"; }
.nav-icon[data-icon="tasks"]::before { content: "▥"; }
.nav-icon[data-icon="file"]::before { content: "▧"; }
.nav-icon[data-icon="scan"]::before { content: "⌗"; }
.nav-icon[data-icon="history"]::before { content: "◷"; }
.nav-icon[data-icon="chart"]::before { content: "◟"; }
.nav-icon[data-icon="settings"]::before { content: "⚙"; }
.nav-icon[data-icon="mobile"]::before { content: "▯"; }
.sidebar-help { margin-top: auto; padding: 16px; border-radius: 12px; background: rgba(255,255,255,.075); }
.sidebar-help strong, .sidebar-help span { display: block; }
.sidebar-help strong { font-size: 13px; }
.sidebar-help span { margin-top: 4px; color: rgba(255,255,255,.58); font-size: 11px; line-height: 1.6; }
.main-column { grid-column: 2; min-width: 0; display: flex; min-height: 100vh; flex-direction: column; }
.topbar { position: sticky; z-index: 20; top: 0; min-height: 74px; padding: 12px 32px; display: flex; align-items: center; gap: 18px; border-bottom: 1px solid var(--line); background: var(--paper); background: color-mix(in srgb, var(--paper) 94%, transparent); backdrop-filter: blur(10px); }
.topbar-identity { min-width: 0; display: flex; align-items: center; gap: 10px; }
.topbar-brand-icon { width: 36px; height: 36px; padding: 2px; display: block; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); object-fit: contain; }
.topbar-title { min-width: 0; display: flex; flex-direction: column; }
.topbar-title .eyebrow { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .06em; }
.topbar-title strong { max-width: min(480px, 42vw); overflow: hidden; font-size: 16px; white-space: nowrap; text-overflow: ellipsis; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-chip strong, .user-chip small { display: block; }
.user-chip strong { max-width: 190px; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip small { color: var(--muted); font-size: 11px; }
.avatar { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; color: var(--brand); background: var(--brand-soft); font-weight: 700; }
.icon-button { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: var(--surface); cursor: pointer; }
.icon-button:hover { border-color: #b9c9c3; background: var(--surface-soft); }
.menu-button { display: none; padding: 9px; }
.menu-button span { display: block; width: 18px; height: 2px; margin: 2px 0; background: currentColor; }
.logout-button { transform: rotate(90deg); }
.content { width: min(1440px, 100%); margin: 0 auto; padding: 34px; flex: 1; }
.app-footer { width: min(1440px, 100%); margin: 0 auto; padding: 16px 34px 28px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 18px; color: var(--muted); font-size: 11px; }
.sidebar-backdrop { display: none; }

@media (max-height: 760px) and (min-width: 861px) {
    .sidebar { padding: 14px 14px; }
    .brand { padding: 0 8px 13px; }
    .brand-mark, .brand-logo { width: 38px; height: 38px; border-radius: 10px; }
    .side-nav { padding-top: 12px; gap: 2px; }
    .nav-caption { padding-bottom: 4px; }
    .nav-item { min-height: 38px; padding: 7px 10px; }
    .sidebar-help { display: none; }
}

.page-heading { margin-bottom: 26px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.page-heading h1 { margin-bottom: 5px; font-size: clamp(24px, 3vw, 32px); line-height: 1.25; letter-spacing: -.025em; }
.page-heading p { margin-bottom: 0; color: var(--muted); }
.heading-actions { display: flex; gap: 10px; }
.section-heading { margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.section-heading h2 { margin: 0; font-size: 18px; }
.section-heading p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.btn { min-height: 42px; padding: 9px 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 10px; background: transparent; font-weight: 600; cursor: pointer; transition: .18s ease; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { color: #fff; background: var(--brand); box-shadow: 0 6px 16px rgba(23,76,69,.16); }
.btn-primary:hover { background: var(--brand-deep); }
.btn-accent { color: #2b261b; background: var(--accent); }
.btn-outline { border-color: var(--line); color: var(--ink); background: var(--surface); }
.btn-outline:hover { border-color: #b9c9c3; }
.btn-danger { color: var(--danger); border-color: #efcbc7; background: #fff8f7; }
.btn-sm { min-height: 34px; padding: 6px 11px; border-radius: 8px; font-size: 12px; }
.btn-block { width: 100%; }
.btn[disabled], button[disabled] { opacity: .5; cursor: not-allowed; transform: none; }

.stats-grid { margin-bottom: 24px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.admin-stats-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.stat-card { min-height: 142px; padding: 20px; position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.stat-card::after { content: ""; position: absolute; right: -18px; bottom: -24px; width: 84px; height: 84px; border-radius: 50%; background: var(--surface-soft); }
.stat-card.accent { border-color: #ead49d; background: var(--accent-soft); }
.stat-card.success { border-color: #bddbc9; background: var(--success-soft); }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 600; }
.stat-value { margin: 12px 0 1px; display: block; font-size: 32px; font-weight: 700; line-height: 1; letter-spacing: -.04em; }
.stat-meta { color: var(--muted); font-size: 11px; }
.progress { height: 7px; overflow: hidden; border-radius: 20px; background: #e5e9e7; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--brand); }
.progress.accent > span { background: var(--accent); }

.workflow-panel { width: 100%; }
.workflow-steps { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 11px; }
.workflow-step { min-width: 0; min-height: 112px; padding: 15px; display: flex; align-items: flex-start; gap: 10px; border: 1px solid var(--line); border-radius: 12px; background: color-mix(in srgb, var(--brand-soft) 42%, var(--surface)); }
.workflow-step > span { width: 30px; height: 30px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 9px; color: #fff; background: var(--brand); font-size: 12px; font-weight: 800; box-shadow: 0 5px 12px rgba(23,76,69,.16); }
.workflow-step strong, .workflow-step small { display: block; }
.workflow-step strong { color: var(--ink); font-size: 13px; line-height: 1.45; }
.workflow-step small { margin-top: 4px; color: var(--muted); font-size: 10px; line-height: 1.55; }

.student-conditions-panel, .student-subjects-panel { width: 100%; }
.student-condition-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.student-condition-item { min-width: 0; min-height: 118px; padding: 16px; display: flex; align-items: flex-start; gap: 11px; border: 1px solid var(--line); border-radius: 12px; background: color-mix(in srgb, var(--accent-soft) 52%, var(--surface)); }
.student-condition-item > span { width: 31px; height: 31px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 9px; color: var(--brand-deep); background: var(--accent); font-size: 12px; font-weight: 800; box-shadow: 0 5px 12px rgba(205,151,24,.17); }
.student-condition-item strong, .student-condition-item small { display: block; }
.student-condition-item strong { color: var(--ink); font-size: 13px; line-height: 1.5; }
.student-condition-item small { margin-top: 5px; color: var(--muted); font-size: 10px; line-height: 1.65; }

.milestone-summary-panel { width: 100%; }
.milestone-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.milestone-card { min-width: 0; min-height: 210px; padding: 16px; position: relative; overflow: hidden; display: grid; grid-template-rows: auto auto auto 1fr auto; align-content: stretch; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.milestone-card::after { content: ""; position: absolute; right: -17px; bottom: -25px; width: 72px; height: 72px; border-radius: 50%; background: rgba(255,255,255,.52); }
.milestone-card span, .milestone-card strong, .milestone-card small, .milestone-card p, .milestone-card .milestone-report-button { position: relative; z-index: 1; display: block; }
.milestone-card span { color: var(--muted); font-size: 11px; font-weight: 700; }
.milestone-card strong { margin-top: 8px; color: var(--ink); font-size: 30px; line-height: 1; }
.milestone-card small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.milestone-card p { margin: 10px 0 12px; color: var(--muted); font-size: 10px; line-height: 1.55; }
.milestone-card .milestone-report-button { width: 100%; align-self: end; text-align: center; }
.milestone-card.is-selected { outline: 3px solid color-mix(in srgb, var(--brand) 32%, transparent); border-color: var(--brand); }
.milestone-card.waiting { border-color: #ead49d; background: var(--accent-soft); }
.milestone-card.submitted { border-color: #bed5e3; background: #e4f0f8; }
.milestone-card.work-passed { border-color: #bfd5ce; background: var(--brand-soft); }
.milestone-card.exam-passed { border-color: #bddbc9; background: var(--success-soft); }
.milestone-card.inactive { border-color: #d7ddda; background: #eef1ef; }
.report-narrative-panel { border-left: 5px solid var(--brand); }
.report-narrative-text { display: grid; gap: 10px; }
.report-narrative-text p { margin: 0; color: var(--ink); font-size: 13px; line-height: 1.85; text-align: justify; }
.status-report-text-list { display: grid; gap: 0; }
.status-report-text-list article { padding: 14px 0; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--line); }
.status-report-text-list article:first-child { padding-top: 0; }
.status-report-text-list article:last-child { padding-bottom: 0; border-bottom: 0; }
.status-report-text-list article.is-selected { margin: 0 -10px; padding-right: 10px; padding-left: 10px; border-radius: 9px; background: var(--brand-soft); }
.status-report-text-list h3 { margin: 0 0 3px; font-size: 14px; }
.status-report-text-list p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.stage-pill { padding: 4px 9px; display: inline-flex; border-radius: 999px; color: var(--muted); background: var(--surface-soft); font-size: 10px; font-weight: 700; white-space: nowrap; }
.stage-waiting_exam { color: #725514; background: var(--accent-soft); }
.stage-submitted_work { color: #315f80; background: #e4f0f8; }
.stage-passed_work { color: var(--brand); background: var(--brand-soft); }
.stage-passed_exam { color: #226a48; background: var(--success-soft); }
.stage-inactive { color: #68726f; background: #ecefed; }

.panel { margin-bottom: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.panel-header { padding: 19px 22px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); }
.panel-header h2, .panel-header h3 { margin: 0; font-size: 17px; }
.panel-header p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.panel-body { padding: 22px; }
.panel-body.flush { padding: 0; }
.two-column { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(280px, .75fr); gap: 20px; align-items: start; }
.split-even { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }

.table-wrap { width: 100%; overflow-x: auto; }
.filter-toolbar { margin-bottom: 12px; padding: 12px; display: flex; align-items: center; flex-wrap: wrap; gap: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: 0 5px 18px rgba(22,49,45,.05); }
.panel-body.flush > .filter-toolbar { margin: 0; padding: 13px 18px; border-width: 0 0 1px; border-radius: 0; box-shadow: none; background: color-mix(in srgb, var(--surface-soft) 48%, var(--surface)); }
.filter-controls { min-width: 0; display: flex; align-items: center; flex: 1 1 620px; flex-wrap: wrap; gap: 8px; }
.filter-search { position: relative; min-width: 200px; max-width: none; flex: 1 1 240px; }
.filter-search > span { position: absolute; z-index: 1; left: 12px; top: 50%; transform: translateY(-52%); color: var(--muted); font-size: 19px; pointer-events: none; }
.filter-search .input { min-height: 38px; padding: 7px 11px 7px 36px; }
.filter-selects { min-width: 0; display: flex; align-items: center; flex: 1 1 340px; flex-wrap: wrap; gap: 8px; }
.filter-select { width: auto; min-width: 110px; max-width: 190px; min-height: 38px; padding-top: 6px; padding-bottom: 6px; flex: 1 1 110px; font-size: 12px; }
.filter-summary { margin-left: 0; color: var(--muted); font-size: 11px; white-space: nowrap; }
.filter-reset { flex: 0 0 auto; }
.filter-empty { padding: 34px 18px; border: 1px dashed var(--line); border-radius: 12px; color: var(--muted); background: var(--surface-soft); text-align: center; }
.panel-body.flush > .filter-empty { margin: 18px; }
.filter-empty strong, .filter-empty small { display: block; }
.filter-empty strong { color: var(--ink); font-size: 14px; }
.filter-empty small { margin-top: 3px; font-size: 11px; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 14px 18px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.data-table th { color: var(--muted); background: #fbfcfb; font-size: 11px; font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
.data-table td { font-size: 13px; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fbfcfb; }
.cell-title strong, .cell-title small { display: block; }
.cell-title small { margin-top: 1px; color: var(--muted); font-size: 11px; }
.number-cell { font-variant-numeric: tabular-nums; }
.actions-cell { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.management-table { table-layout: fixed; }
.management-table th, .management-table td { padding: 10px 9px; overflow-wrap: anywhere; }
.management-table th { font-size: 9px; font-weight: 600; white-space: normal; }
.management-table td { font-size: 11px; font-weight: 400; }
.management-table th:last-child { width: 218px; }
.management-actions { flex-wrap: wrap; gap: 5px; white-space: normal; }
.management-actions form { display: inline-flex; }
.management-actions .btn { min-height: 31px; padding: 6px 8px; font-size: 9px; font-weight: 500; }
.management-row-inactive { opacity: .7; background: #f6f8f7; }
.enrollment-table-wrap { overflow-x: hidden; }
.enrollment-table { min-width: 0; table-layout: fixed; }
.enrollment-table th, .enrollment-table td { padding: 8px 7px; }
.enrollment-table th { font-size: 9px; font-weight: 500; line-height: 1.35; white-space: normal; }
.enrollment-table td { min-width: 0; overflow: hidden; font-size: 11px; font-weight: 400; line-height: 1.45; }
.enrollment-table th:nth-child(1) { width: 17%; }
.enrollment-table th:nth-child(2) { width: 19%; }
.enrollment-table th:nth-child(3) { width: 17%; }
.enrollment-table th:nth-child(4) { width: 12%; }
.enrollment-table th:nth-child(5) { width: 18%; }
.enrollment-table th:nth-child(6) { width: 17%; }
.enrollment-student-cell strong, .enrollment-subject-cell strong { overflow: visible; font-size: 11px; font-weight: 400; line-height: 1.5; overflow-wrap: anywhere; text-overflow: clip; white-space: normal; }
.enrollment-student-cell small, .enrollment-subject-cell small { margin-top: 2px; font-size: 9px; font-weight: 400; line-height: 1.35; white-space: normal; }
.enrollment-detail-lines { display: grid; gap: 5px; }
.enrollment-detail-lines > span { min-width: 0; display: grid; grid-template-columns: 34px minmax(0, 1fr); align-items: center; gap: 3px; }
.enrollment-detail-lines small { color: var(--muted); font-size: 8px; font-weight: 400; line-height: 1.3; }
.enrollment-detail-lines strong, .enrollment-detail-lines .file-link { min-width: 0; font-size: 10px; font-weight: 400; line-height: 1.35; overflow-wrap: anywhere; white-space: normal; }
.enrollment-detail-lines .badge { width: max-content; max-width: 100%; padding: 3px 5px; font-size: 8px; font-weight: 400; line-height: 1.25; text-align: center; white-space: normal; }
.detail-success { color: var(--success); }
.detail-warning { color: #996b10; }
.enrollment-result-cell .badge { max-width: 100%; padding: 4px 6px; font-size: 9px; font-weight: 400; line-height: 1.25; text-align: center; white-space: normal; }
.enrollment-result-cell small { display: block; margin-top: 4px; color: var(--muted); font-size: 8px; font-weight: 400; line-height: 1.35; white-space: normal; }
.enrollment-actions { flex-wrap: wrap; gap: 5px; white-space: normal; }
.enrollment-actions form { min-width: 0; max-width: 100%; display: inline-flex; }
.enrollment-actions .btn { min-height: 29px; max-width: 100%; padding: 5px 7px; font-size: 9px; font-weight: 400; line-height: 1.25; white-space: normal; }
.badge { padding: 4px 9px; display: inline-flex; align-items: center; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge-registered, .badge-draft { color: #725514; background: var(--accent-soft); }
.badge-in_progress, .badge-submitted { color: #315f80; background: #e4f0f8; }
.badge-passed, .badge-published, .badge-graduated, .badge-active { color: #226a48; background: var(--success-soft); }
.badge-failed, .badge-suspended, .badge-revision_required { color: #9b3933; background: var(--danger-soft); }
.badge-inactive { color: #5f6d69; background: #e8edeb; }
.badge-pending { color: #725514; background: var(--accent-soft); }
.badge-archived { color: #68726f; background: #ecefed; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label { color: #3f524e; font-size: 12px; font-weight: 700; }
.field .hint { color: var(--muted); font-size: 11px; }
.image-compression-status { padding: 7px 9px; border-radius: 8px; color: var(--muted); background: var(--surface-soft); font-size: 11px; }
.image-compression-status.processing { color: var(--brand); }
.image-compression-status.success { color: var(--success); background: var(--success-soft); font-weight: 600; }
.input, .select, .textarea { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #cfdad6; border-radius: 9px; outline: none; color: var(--ink); background: #fff; transition: border-color .15s, box-shadow .15s; }
.textarea { min-height: 108px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(23,76,69,.11); }
.input::placeholder, .textarea::placeholder { color: #9aa6a2; }
.date-picker-control { position: relative; width: 100%; }
.date-picker-display { width: 100%; min-height: 44px; padding: 10px 50px 10px 12px; border: 1px solid #cfdad6; border-radius: 9px; outline: none; color: var(--ink); background: #fff; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.date-picker-display:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(23,76,69,.11); }
.date-picker-button { position: absolute; right: 7px; top: 50%; width: 34px; height: 34px; padding: 0; transform: translateY(-50%); border: 0; border-radius: 8px; color: var(--brand); background: var(--brand-soft); cursor: pointer; }
.date-picker-button:hover { background: #d1e4de; }
.date-picker-button::before { content: ""; position: absolute; left: 9px; top: 9px; width: 14px; height: 14px; border: 2px solid currentColor; border-radius: 3px; }
.date-picker-button::after { content: ""; position: absolute; left: 9px; top: 13px; width: 14px; height: 2px; background: currentColor; box-shadow: 3px 4px 0 -1px currentColor, 7px 4px 0 -1px currentColor, 3px 8px 0 -1px currentColor, 7px 8px 0 -1px currentColor; }

.flatpickr-calendar { width: 340px; overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: 0 20px 60px rgba(17,58,53,.2); font-family: "Noto Sans Thai", Tahoma, sans-serif; }
.flatpickr-calendar.open { z-index: 1000; }
.flatpickr-calendar::before, .flatpickr-calendar::after { display: none; }
.flatpickr-months { min-height: 58px; padding: 8px 8px 0; align-items: center; background: var(--surface); }
.flatpickr-months .flatpickr-month { height: 48px; color: var(--ink); }
.flatpickr-current-month { height: 48px; padding-top: 9px; font-size: 16px; font-weight: 700; }
.flatpickr-current-month .flatpickr-monthDropdown-months { padding: 4px 26px 4px 8px; border-radius: 8px; color: var(--ink); background: var(--surface-soft); font-weight: 700; }
.flatpickr-current-month input.cur-year { padding: 4px 0 4px 7px; border-radius: 8px; color: var(--ink); font-weight: 700; }
.flatpickr-current-month .numInputWrapper { width: 76px; }
.flatpickr-months .flatpickr-prev-month, .flatpickr-months .flatpickr-next-month { top: 11px; width: 38px; height: 38px; padding: 3px; display: grid; place-items: center; border-radius: 10px; color: var(--brand); background: var(--brand-soft); font-size: 30px; line-height: 1; }
.flatpickr-months .flatpickr-prev-month:hover, .flatpickr-months .flatpickr-next-month:hover { color: #fff; background: var(--brand); }
.flatpickr-weekdays { height: 38px; padding: 0 10px; border-top: 1px solid var(--line); background: #fbfcfb; }
span.flatpickr-weekday { color: var(--muted); font-size: 12px; font-weight: 700; }
.flatpickr-innerContainer { padding: 7px 10px 8px; }
.flatpickr-rContainer, .flatpickr-days, .dayContainer { width: 318px; max-width: 318px; min-width: 318px; }
.flatpickr-day { max-width: 42px; height: 42px; border-radius: 11px; color: var(--ink); line-height: 40px; font-size: 13px; font-weight: 500; }
.flatpickr-day:hover, .flatpickr-day:focus { border-color: var(--brand-soft); background: var(--brand-soft); }
.flatpickr-day.today { border-color: var(--accent); color: #795814; background: var(--accent-soft); font-weight: 800; }
.flatpickr-day.today:hover { border-color: var(--accent); color: #2b261b; background: var(--accent); }
.flatpickr-day.selected, .flatpickr-day.selected:hover, .flatpickr-day.selected:focus { border-color: var(--brand); color: #fff; background: var(--brand); box-shadow: 0 5px 12px rgba(23,76,69,.2); }
.flatpickr-day.prevMonthDay, .flatpickr-day.nextMonthDay { color: #aab4b1; }
.flatpickr-time { border-top: 1px solid var(--line); }
.flatpickr-time input, .flatpickr-time .flatpickr-am-pm { color: var(--ink); font-family: inherit; }
.date-picker-footer { min-height: 50px; padding: 8px 14px; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); background: #fbfcfb; }
.date-picker-footer button { padding: 7px 10px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; }
.date-picker-footer button:hover { color: var(--brand); background: var(--brand-soft); }
.date-picker-footer .date-picker-today { margin-left: auto; color: #fff; background: var(--brand); }
.date-picker-footer .date-picker-today:hover { color: #fff; background: var(--brand-deep); }
.form-actions { margin-top: 20px; padding-top: 18px; display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--line); }
.settings-toggle { min-height: 76px; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); cursor: pointer; }
.settings-toggle-copy { min-width: 0; }
.settings-toggle-copy strong, .settings-toggle-copy small { display: block; }
.settings-toggle-copy strong { color: var(--ink); font-size: 13px; }
.settings-toggle-copy small { margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.55; }
.switch-control { position: relative; width: 48px; height: 28px; flex: 0 0 auto; }
.switch-control input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.switch-track { position: absolute; inset: 0; border-radius: 999px; background: #cbd5d1; transition: background .18s ease, box-shadow .18s ease; }
.switch-track::after { content: ''; position: absolute; top: 4px; left: 4px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(21,47,43,.2); transition: transform .18s ease; }
.switch-control input:checked + .switch-track { background: var(--brand); }
.switch-control input:checked + .switch-track::after { transform: translateX(20px); }
.switch-control input:focus-visible + .switch-track { box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }
.search-row { display: flex; gap: 10px; }
.search-row .input { min-width: 240px; }
.inline-form { display: inline; }

.modal[hidden] { display: none; }
.modal { position: fixed; z-index: 100; inset: 0; padding: 24px; display: grid; place-items: center; }
.modal-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: rgba(10, 31, 28, .58); cursor: default; animation: modal-fade .16s ease-out; }
.modal-dialog { position: relative; width: min(680px, 100%); max-height: calc(100vh - 48px); overflow: hidden; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: 0 28px 80px rgba(10,31,28,.25); animation: modal-rise .2s ease-out; }
.modal-dialog-sm { width: min(520px, 100%); }
.modal-dialog > form { min-height: 0; overflow: hidden; display: flex; flex: 1 1 auto; flex-direction: column; }
.modal-header { padding: 20px 22px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0; font-size: 20px; }
.modal-header p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.modal-close { width: 36px; height: 36px; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); background: var(--surface); font-size: 24px; line-height: 1; cursor: pointer; }
.modal-close:hover { color: var(--ink); background: var(--surface-soft); }
.modal-header, .modal-footer { flex: 0 0 auto; }
.modal-body { min-height: 0; padding: 22px; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.modal-dialog > form .modal-body { flex: 1 1 auto; }
.modal-footer { padding: 16px 22px; display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--line); background: #fbfcfb; }
body.modal-open { overflow: hidden; }
.subject-check-grid { max-height: 250px; padding: 8px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); }
.subject-check-option { min-width: 0; padding: 9px 10px; display: flex; align-items: flex-start; gap: 8px; border: 1px solid transparent; border-radius: 8px; background: var(--surface); cursor: pointer; }
.subject-check-option:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.subject-check-option input { margin-top: 3px; accent-color: var(--brand); }
.subject-check-option span { min-width: 0; }
.subject-check-option strong, .subject-check-option small { display: block; }
.subject-check-option strong { font-size: 11px; }
.subject-check-option small { margin-top: 1px; color: var(--muted); font-size: 9px; line-height: 1.35; }
.enrollment-bulk-dialog { width: min(900px, 100%); }
.enrollment-picker-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.enrollment-picker-heading label, .enrollment-picker-heading small { display: block; }
.enrollment-picker-heading small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.enrollment-picker-heading > strong { padding: 6px 10px; flex: 0 0 auto; border-radius: 999px; color: var(--brand); background: var(--brand-soft); font-size: 11px; }
.enrollment-picker-tools { margin-top: 10px; display: grid; grid-template-columns: minmax(240px, 1fr) 140px auto auto; gap: 8px; }
.enrollment-subject-search { position: relative; }
.enrollment-subject-search > span { position: absolute; z-index: 1; left: 12px; top: 50%; color: var(--muted); font-size: 20px; line-height: 1; pointer-events: none; transform: translateY(-52%); }
.enrollment-subject-search .input { padding-left: 38px; }
.enrollment-level-filter { min-width: 0; }
.enrollment-subject-options { max-height: 360px; margin-top: 10px; overflow-y: auto; overscroll-behavior: contain; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); scrollbar-width: thin; }
.enrollment-subject-list-head, .enrollment-subject-option { min-width: 0; display: grid; grid-template-columns: 28px 112px minmax(0, 1fr) 76px; gap: 10px; align-items: center; }
.enrollment-subject-list-head { min-height: 38px; padding: 8px 14px; position: sticky; z-index: 2; top: 0; color: #fff; background: var(--brand-deep); font-size: 10px; font-weight: 700; }
.enrollment-subject-option { min-height: 54px; padding: 9px 14px; border-bottom: 1px solid var(--line); border-left: 4px solid transparent; color: var(--ink); background: #fff; cursor: pointer; transition: border-color .16s ease, background .16s ease, box-shadow .16s ease; }
.enrollment-subject-option:nth-of-type(even) { background: color-mix(in srgb, var(--brand-soft) 24%, #fff); }
.enrollment-subject-option:last-child { border-bottom: 0; }
.enrollment-subject-option:hover { border-left-color: color-mix(in srgb, var(--brand) 55%, transparent); background: color-mix(in srgb, var(--brand-soft) 48%, #fff); }
.enrollment-subject-option:has(input:focus-visible) { outline: 3px solid color-mix(in srgb, var(--brand) 22%, transparent); outline-offset: -3px; }
.enrollment-subject-option:has(input:checked), .enrollment-subject-option.is-selected { border-left-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 24%, transparent); }
.enrollment-subject-option input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.enrollment-subject-check { width: 22px; height: 22px; display: grid; place-items: center; border: 1px solid #b9c8c4; border-radius: 6px; color: transparent; background: #fff; font-size: 13px; font-weight: 800; }
.enrollment-subject-option:has(input:checked) .enrollment-subject-check, .enrollment-subject-option.is-selected .enrollment-subject-check { border-color: var(--brand); color: #fff; background: var(--brand); }
.enrollment-subject-code, .enrollment-subject-name { min-width: 0; overflow-wrap: anywhere; }
.enrollment-subject-code { color: var(--brand-deep); font-size: 11px; }
.enrollment-subject-name { font-size: 12px; line-height: 1.45; }
.enrollment-subject-level { padding: 5px 7px; justify-self: start; border-radius: 999px; color: #315f57; background: #e5f0ed; font-size: 9px; font-weight: 700; text-align: center; white-space: nowrap; }
.enrollment-subject-option[data-level="ม.1"] .enrollment-subject-level, .enrollment-subject-option[data-level="ม.1-3"] .enrollment-subject-level { color: #15577a; background: #e0f1fa; }
.enrollment-subject-option[data-level="ม.2"] .enrollment-subject-level { color: #31578a; background: #e8effa; }
.enrollment-subject-option[data-level="ม.3"] .enrollment-subject-level { color: #51458b; background: #ece9fb; }
.enrollment-subject-option[data-level="ม.4"] .enrollment-subject-level, .enrollment-subject-option[data-level="ม.4-6"] .enrollment-subject-level { color: #7a4d1d; background: #fbefd9; }
.enrollment-subject-option[data-level="ม.5"] .enrollment-subject-level { color: #7d3f57; background: #f8e7ed; }
.enrollment-subject-option[data-level="ม.6"] .enrollment-subject-level, .enrollment-subject-option[data-level="ม.1-6"] .enrollment-subject-level { color: #2f6651; background: #e1f2e9; }
.enrollment-list-summary { margin-top: 8px; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 10px; }
.enrollment-list-summary > span { color: var(--brand); font-weight: 700; }
.enrollment-picker-empty { margin: 10px 0 0; padding: 18px; border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); background: var(--surface-soft); font-size: 12px; text-align: center; }
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-rise { from { opacity: 0; transform: translateY(12px) scale(.985); } to { opacity: 1; transform: translateY(0) scale(1); } }

@media (max-height: 700px) {
    .modal { padding: 12px; }
    .modal-dialog { max-height: calc(100vh - 24px); }
    .modal-header { padding: 16px 20px; }
    .modal-body { padding: 18px 20px; }
    .modal-footer { padding: 12px 20px; }
}

.alert { margin-bottom: 18px; padding: 12px 15px; display: flex; align-items: center; gap: 10px; border: 1px solid; border-radius: 10px; font-size: 13px; }
.alert span { width: 23px; height: 23px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; font-weight: 800; }
.alert-success { color: #235c42; border-color: #bcdcc8; background: var(--success-soft); }
.alert-success span { color: white; background: var(--success); }
.alert-error { color: #913a34; border-color: #efc5c1; background: var(--danger-soft); }
.alert-error span { color: white; background: var(--danger); }
.notice { padding: 14px 16px; border-left: 4px solid var(--accent); border-radius: 8px; color: #69511e; background: var(--accent-soft); font-size: 13px; }
.notice strong { display: block; }

.empty-state { padding: 48px 24px; text-align: center; }
.empty-state .empty-icon { margin: 0 auto 14px; width: 58px; height: 58px; display: grid; place-items: center; border-radius: 50%; color: var(--brand); background: var(--brand-soft); font-weight: 800; letter-spacing: 2px; }
.empty-state h3 { margin-bottom: 4px; font-size: 17px; }
.empty-state p { margin: 0; color: var(--muted); font-size: 13px; }

.subject-list { display: grid; gap: 12px; }
.subject-card { padding: 16px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.subject-card h3 { margin: 0 0 2px; font-size: 15px; }
.subject-card p { margin: 0; color: var(--muted); font-size: 12px; }
.subject-card .subject-status { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.work-list { display: grid; gap: 16px; }
.work-card { overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.work-card-header { padding: 17px 19px; display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); background: #fbfcfb; }
.work-card-header h2, .work-card-header h3 { margin: 0 0 3px; font-size: 17px; }
.work-card-header p { margin: 0; color: var(--muted); font-size: 12px; }
.work-card-body { padding: 19px; }
.work-instructions { margin-bottom: 16px; padding: 14px 16px; border-radius: 10px; background: var(--surface-soft); white-space: pre-wrap; }
.work-feedback { margin: 14px 0; padding: 13px 15px; border-left: 4px solid var(--danger); border-radius: 8px; color: #7d3631; background: var(--danger-soft); }
.work-feedback.passed { border-left-color: var(--success); color: #235c42; background: var(--success-soft); }
.work-meta { display: flex; flex-wrap: wrap; gap: 8px 16px; color: var(--muted); font-size: 12px; }
.work-submission { margin-top: 15px; padding-top: 15px; border-top: 1px solid var(--line); }
.work-submission p { white-space: pre-wrap; }
.work-history { margin-top: 16px; border-top: 1px solid var(--line); }
.work-history summary { padding: 14px 0 0; color: var(--brand); font-weight: 700; cursor: pointer; }
.review-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.review-option { padding: 13px; display: flex; align-items: center; gap: 9px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.review-option:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.file-link { color: var(--brand); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.score-ring { width: 54px; height: 54px; display: grid; place-items: center; border: 5px solid var(--brand-soft); border-top-color: var(--brand); border-radius: 50%; font-size: 13px; font-weight: 700; }
.timeline { display: grid; }
.timeline-item { position: relative; padding: 0 0 20px 28px; }
.timeline-item::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: -4px; width: 1px; background: var(--line); }
.timeline-item:last-child::before { display: none; }
.timeline-item::after { content: ""; position: absolute; left: 2px; top: 5px; width: 11px; height: 11px; border: 3px solid white; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.timeline-item strong, .timeline-item small { display: block; }
.timeline-item strong { font-size: 13px; }
.timeline-item small { color: var(--muted); font-size: 11px; }

.question-editor-toolbar { margin-bottom: 12px; padding: 11px 13px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
.question-editor-toolbar > div:first-child { min-width: 0; }
.question-editor-toolbar strong, .question-editor-toolbar small { display: block; }
.question-editor-toolbar strong { font-size: 12px; }
.question-editor-toolbar small { margin-top: 2px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.question-editor-tools { display: flex; align-items: center; flex: 0 0 auto; gap: 7px; }
.question-editor-tools label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10px; font-weight: 700; }
.question-editor-tools .select { width: 96px; min-height: 34px; padding: 4px 8px; font-size: 11px; }
.question-editor { display: grid; gap: 10px; }
.question-card { overflow: hidden; padding: 0; scroll-margin-top: 92px; border: 1px solid var(--line); border-radius: 12px; background: #fff; transition: border-color .15s, box-shadow .15s; }
.question-card:focus-within { border-color: #a9c7bd; box-shadow: 0 0 0 3px rgba(21, 86, 76, .07); }
.question-card.is-collapsed { background: #fcfdfc; }
.question-card-header { padding: 10px 12px; display: grid; grid-template-columns: 32px minmax(160px, 1fr) auto auto; align-items: center; gap: 10px; }
.question-number { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; color: white; background: var(--brand); font-size: 12px; font-weight: 700; }
.question-card-summary { min-width: 0; }
.question-card-summary strong, .question-card-summary small { display: block; }
.question-card-summary strong { font-size: 11px; line-height: 1.35; }
.question-card-summary small { margin-top: 2px; overflow: hidden; color: var(--muted); font-size: 10px; line-height: 1.45; text-overflow: ellipsis; white-space: nowrap; }
.question-card-config { display: flex; align-items: center; justify-content: flex-end; gap: 9px; }
.question-card.is-collapsed .question-card-config { display: none; }
.question-card-toggle { min-width: 70px; min-height: 32px; padding: 4px 8px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line); border-radius: 8px; color: var(--brand); background: #fff; font: inherit; font-size: 10px; font-weight: 700; cursor: pointer; }
.question-card-toggle:hover { border-color: var(--brand); background: var(--brand-soft); }
.question-card-toggle b { font-size: 15px; line-height: 1; }
.question-card-body { padding: 13px 14px 15px; border-top: 1px solid var(--line); }
.question-card-body[hidden] { display: none; }
.question-card .input, .question-card .select, .question-card .textarea { min-height: 38px; font-size: 12px; }
.question-card .textarea { line-height: 1.65; }
.question-prompt-field { display: block; }
.question-prompt-field > span { display: block; margin-bottom: 5px; color: var(--ink); font-size: 10px; font-weight: 700; }
.question-prompt-field .textarea { min-height: 88px; resize: vertical; }
.question-type-select { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10px; }
.question-type-select .select { width: 144px; min-height: 34px; padding: 4px 8px; }
.question-media-editor { margin-top: 9px; padding: 10px; display: grid; grid-template-columns: minmax(135px, .4fr) minmax(0, 1fr); gap: 8px; border: 1px dashed var(--line); border-radius: 9px; background: var(--surface-soft); }
.question-media-editor label, .choice-media-editor { min-width: 0; }
.question-media-editor span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 9px; font-weight: 700; }
.question-choice-editor { margin-top: 10px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.choice-editor-row { padding: 8px; display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 0; border: 1px solid var(--line); border-radius: 9px; background: #fbfcfb; }
.choice-editor-row > .choice-label { height: 38px; border-radius: 8px 0 0 8px; font-size: 11px; }
.choice-editor-main { min-width: 0; display: grid; gap: 6px; }
.choice-editor-main > .input:first-child { border-radius: 0 9px 9px 0; }
.choice-media-editor { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 6px; }
.match-answer-input { border-color: #b8d3ca; background: var(--brand-soft); }
.answer-key-editor { margin-top: 10px; padding: 11px; border: 1px solid #c8d9d3; border-radius: 9px; background: var(--brand-soft); }
.answer-key-editor label { color: var(--ink); font-size: 10px; font-weight: 700; }
.answer-key-editor .textarea { margin-top: 5px; min-height: 88px; background: #fff; }
.answer-key-editor small { display: block; margin-top: 5px; color: var(--muted); font-size: 9px; line-height: 1.55; }
.choice-grid { margin-top: 11px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.choice-field { display: grid; grid-template-columns: 32px minmax(0, 1fr); align-items: center; }
.choice-label { height: 42px; display: grid; place-items: center; border: 1px solid #cfdad6; border-right: 0; border-radius: 9px 0 0 9px; color: var(--brand); background: var(--surface-soft); font-weight: 700; }
.choice-field .input { border-radius: 0 9px 9px 0; }
.correct-choice { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10px; }
.correct-choice .select { min-height: 34px; width: 106px; padding: 4px 8px; }
.question-sticky-bar { position: sticky; z-index: 10; bottom: 14px; margin: 20px 0 0; padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid #bed0ca; border-radius: 12px; background: rgba(255,255,255,.96); box-shadow: 0 8px 30px rgba(17,58,53,.14); }
.question-count { font-weight: 700; }
.question-count small { display: block; color: var(--muted); font-size: 11px; font-weight: 500; }

.scan-layout { display: grid; grid-template-columns: minmax(300px, .8fr) minmax(0, 1.4fr); gap: 20px; align-items: start; }
.drop-zone { padding: 34px 20px; display: block; border: 2px dashed #afc2bc; border-radius: 13px; background: #f7faf8; text-align: center; cursor: pointer; }
.drop-zone.dragging { border-color: var(--brand); background: var(--brand-soft); }
.drop-zone input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
.drop-icon { width: 58px; height: 58px; margin: 0 auto 14px; display: grid; place-items: center; border-radius: 50%; color: var(--brand); background: var(--brand-soft); font-size: 25px; }
.drop-zone strong, .drop-zone small { display: block; }
.drop-zone small { margin-top: 4px; color: var(--muted); }
.scan-progress { display: none; margin-top: 15px; }
.scan-progress.visible { display: block; }
.scan-progress p { margin: 6px 0 0; color: var(--muted); font-size: 11px; }
.ocr-raw { min-height: 240px; font-family: Consolas, monospace; font-size: 12px; }
.ocr-toolbar { margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ocr-toolbar .badge { font-size: 12px; }

.exam-intro { padding: 24px; border-radius: var(--radius); color: #fff; background: var(--brand-deep); }
.exam-intro h1 { margin-bottom: 6px; font-size: 27px; }
.exam-intro p { margin-bottom: 17px; color: rgba(255,255,255,.68); }
.exam-meta { display: flex; flex-wrap: wrap; gap: 10px; }
.exam-meta span { padding: 6px 11px; border: 1px solid rgba(255,255,255,.15); border-radius: 999px; background: rgba(255,255,255,.08); font-size: 12px; }
.exam-question { margin-top: 16px; padding: 20px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.exam-question-heading { margin-bottom: 14px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.exam-question h3 { margin-bottom: 14px; font-size: 15px; line-height: 1.65; }
.exam-question-heading h3 { margin-bottom: 0; }
.exam-question h3 span { margin-right: 7px; color: var(--brand); }
.question-type-badge { flex: 0 0 auto; padding: 4px 9px; border-radius: 999px; color: var(--brand); background: var(--brand-soft); font-size: 10px; font-weight: 700; }
.exam-media { margin: 12px 0; }
.exam-media-image img { display: block; width: auto; max-width: min(100%, 720px); max-height: 480px; border: 1px solid var(--line); border-radius: 11px; object-fit: contain; }
.exam-media-video { width: min(100%, 720px); aspect-ratio: 16 / 9; overflow: hidden; border-radius: 11px; background: #0d1715; }
.exam-media-video iframe, .exam-media-video video { width: 100%; height: 100%; border: 0; object-fit: contain; }
.exam-media-link { margin: 10px 0; display: inline-flex; align-items: center; gap: 6px; color: var(--brand); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.answer-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.answer-option { padding: 11px 12px; display: flex; align-items: flex-start; gap: 9px; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; transition: .15s; }
.answer-option:hover, .answer-option:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.answer-option input { margin-top: 5px; accent-color: var(--brand); }
.answer-option b { color: var(--brand); }
.answer-option > span { min-width: 0; flex: 1; }
.answer-option .exam-media { margin: 8px 0 0; }
.answer-option .exam-media-video { width: 100%; }
.text-answer-field { display: grid; gap: 7px; color: var(--ink); font-weight: 700; }
.structured-answer-list { display: grid; gap: 9px; }
.structured-answer-list article { padding: 12px 14px; display: grid; grid-template-columns: minmax(0, 1fr) 160px; align-items: center; gap: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); }
.structured-answer-list article label { color: var(--muted); font-size: 11px; font-weight: 700; }
.structured-answer-list article .select { margin-top: 4px; }
.matching-answer-bank { margin-bottom: 12px; padding: 12px 14px; display: grid; gap: 6px; border-left: 4px solid var(--accent); border-radius: 8px; background: var(--accent-soft); }
.matching-answer-bank > strong { margin-bottom: 2px; }
.matching-answer-bank span { font-size: 12px; }
.exam-submit { position: sticky; bottom: 15px; margin-top: 20px; padding: 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid #b8cbc5; border-radius: 12px; background: rgba(255,255,255,.96); box-shadow: 0 10px 28px rgba(17,58,53,.15); }
.exam-submit p { margin: 0; color: var(--muted); font-size: 12px; }

.result-card { max-width: 680px; margin: 40px auto; padding: 36px; border: 1px solid var(--line); border-radius: 22px; background: #fff; box-shadow: var(--shadow); text-align: center; }
.result-symbol { width: 82px; height: 82px; margin: 0 auto 18px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--success); font-size: 36px; font-weight: 800; }
.result-symbol.failed { background: var(--danger); }
.result-card h1 { margin-bottom: 4px; font-size: 28px; }
.result-score { margin: 22px auto; padding: 18px; max-width: 260px; border-radius: 14px; background: var(--surface-soft); }
.result-score strong { display: block; font-size: 42px; line-height: 1.1; }
.result-score span { color: var(--muted); font-size: 12px; }
.result-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 9px; }

.guest-body { display: grid; min-height: 100vh; place-items: center; padding: 28px; background: var(--paper); }
.login-shell { width: min(1080px, 100%); min-height: 660px; display: grid; grid-template-columns: 1.05fr .95fr; overflow: hidden; border-radius: 24px; background: #fff; box-shadow: 0 24px 70px rgba(17,58,53,.16); }
.login-story { padding: 56px; display: flex; flex-direction: column; justify-content: space-between; color: #fff; background: var(--brand-deep); }
.login-brand { display: flex; align-items: center; gap: 12px; }
.login-brand .brand-mark { background: var(--accent); }
.login-brand .brand-logo { width: 46px; height: 46px; }
.login-copy { max-width: 390px; }
.login-kicker { color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: .08em; }
.login-copy h1 { margin: 12px 0; font-size: clamp(32px, 5vw, 46px); line-height: 1.16; letter-spacing: -.035em; }
.login-copy p { color: rgba(255,255,255,.66); }
.login-points { margin: 28px 0 0; padding: 0; display: grid; gap: 13px; list-style: none; }
.login-points li { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.login-points li::before { content: "✓"; width: 23px; height: 23px; display: grid; place-items: center; border-radius: 50%; color: var(--brand-deep); background: var(--accent); font-weight: 800; }
.login-footnote { color: rgba(255,255,255,.42); font-size: 11px; }
.login-form-side { padding: 38px 48px; display: flex; flex-direction: column; justify-content: center; }
.login-form-side h2 { margin-bottom: 4px; font-size: 25px; }
.login-form-side > p { margin-bottom: 24px; color: var(--muted); }
.login-form-side .field { margin-bottom: 15px; }
.login-form-side .btn { margin-top: 8px; min-height: 47px; }
.demo-accounts { margin-top: 22px; padding: 14px; border-radius: 10px; background: var(--surface-soft); }
.demo-accounts strong { display: block; margin-bottom: 6px; font-size: 11px; }
.demo-accounts span { display: block; color: var(--muted); font-size: 11px; }
.login-mobile-access { margin-top: 14px; padding: 13px; display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 14px; align-items: center; border: 1px solid var(--line); border-radius: 13px; background: linear-gradient(135deg, #fff, var(--brand-soft)); }
.login-mobile-qr { width: 130px; height: 130px; padding: 7px; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 11px; background: #fff; box-shadow: 0 7px 18px rgba(17,58,53,.08); }
.login-mobile-qr canvas, .login-mobile-qr img { width: 116px !important; height: 116px !important; display: block; }
.login-mobile-details { min-width: 0; }
.login-mobile-details > strong { display: block; margin: 2px 0 4px; font-size: 15px; }
.login-mobile-kicker { color: var(--brand); font-size: 9px; font-weight: 700; letter-spacing: .04em; }
.login-mobile-details p { margin: 0 0 6px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.login-mobile-url { display: block; overflow-wrap: anywhere; color: var(--brand); font-size: 9px; line-height: 1.35; text-decoration: underline; text-underline-offset: 2px; }
.login-mobile-copy { margin-top: 7px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px; color: var(--brand); background: #fff; font: inherit; font-size: 10px; font-weight: 600; cursor: pointer; }
.login-mobile-copy:hover { border-color: var(--brand); background: var(--brand-soft); }
.login-mobile-access.has-network-warning { border-color: #e7c76d; background: #fff8df; }
.login-mobile-access.is-unavailable .login-mobile-qr::before { content: "QR ไม่พร้อมใช้งาน"; color: var(--muted); font-size: 10px; text-align: center; }

.settings-section { margin-bottom: 20px; }
.logo-settings { margin-bottom: 22px; padding: 16px; display: grid; grid-template-columns: minmax(220px, 1fr) auto; gap: 14px 20px; align-items: center; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-soft); }
.logo-settings > p { grid-column: 1 / -1; margin: -2px 0 0; color: var(--muted); font-size: 11px; }
.logo-current { min-width: 0; display: flex; align-items: center; gap: 13px; }
.logo-current img { width: 66px; height: 66px; padding: 4px; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); object-fit: contain; box-shadow: 0 5px 16px rgba(22,49,45,.08); }
.logo-current strong, .logo-current small { display: block; }
.logo-current strong { font-size: 14px; }
.logo-current small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.logo-actions, .logo-actions form { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.logo-file-button { position: relative; overflow: hidden; }
.logo-file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.settings-grid .settings-section { height: 100%; }
.panel-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.theme-picker { display: grid; grid-template-columns: repeat(5, minmax(120px, 1fr)); gap: 10px; }
.theme-option { --theme-card-brand: #174c45; --theme-card-deep: #113a35; --theme-card-soft: #dfece8; position: relative; min-width: 0; padding: 13px; display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; transition: border-color .18s, box-shadow .18s, transform .18s; }
.theme-option:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(22,49,45,.08); }
.theme-option:has(input:checked) { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.theme-option input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.theme-option > span:not(.theme-preview) { min-width: 0; }
.theme-option strong, .theme-option small { display: block; }
.theme-option strong { font-size: 12px; }
.theme-option small { color: var(--muted); font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.theme-option > b { width: 20px; height: 20px; margin-left: auto; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; color: transparent; background: var(--surface-soft); font-size: 11px; }
.theme-option:has(input:checked) > b { color: #fff; background: var(--brand); }
.theme-preview { width: 40px; height: 40px; padding: 6px; display: grid; grid-template-columns: 9px 1fr; grid-template-rows: 8px 1fr; gap: 3px; flex: 0 0 auto; overflow: hidden; border-radius: 9px; background: #fff; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.theme-preview i:first-child { grid-row: 1 / -1; border-radius: 3px; background: var(--theme-card-deep); }
.theme-preview i:nth-child(2) { border-radius: 3px; background: var(--theme-card-brand); }
.theme-preview i:nth-child(3) { border-radius: 3px; background: var(--theme-card-soft); }
.theme-ocean { --theme-card-brand: #155a75; --theme-card-deep: #10475d; --theme-card-soft: #dcecf2; }
.theme-indigo { --theme-card-brand: #3f4b82; --theme-card-deep: #303a68; --theme-card-soft: #e2e5f2; }
.theme-burgundy { --theme-card-brand: #7a3346; --theme-card-deep: #5d2736; --theme-card-soft: #f0dfe4; }
.theme-graphite { --theme-card-brand: #38434a; --theme-card-deep: #293238; --theme-card-soft: #e1e6e5; }
.student-account-fields { margin-top: 17px; }
.user-password-field { margin-top: 17px; }
[hidden] { display: none !important; }
.import-drop { min-height: 146px; padding: 22px; display: grid; place-items: center; align-content: center; border: 2px dashed #b8c8c3; border-radius: 13px; background: color-mix(in srgb, var(--brand-soft) 35%, var(--surface)); text-align: center; cursor: pointer; transition: border-color .18s, background .18s; }
.import-drop:hover, .import-drop.dragging { border-color: var(--brand); background: var(--brand-soft); }
.import-drop input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
.import-drop strong, .import-drop small { display: block; }
.import-drop small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.import-icon { width: 42px; height: 42px; margin-bottom: 8px; display: grid; place-items: center; border-radius: 12px; color: var(--brand); background: var(--brand-soft); font-size: 21px; font-weight: 700; }
.import-columns { margin: 13px 0 7px; color: var(--muted); font-size: 11px; }
.import-columns strong { color: var(--ink); }
.import-status { padding: 10px 12px; border-radius: 9px; color: var(--muted); background: var(--surface-soft); font-size: 12px; }
.import-status.ready { color: var(--success); background: var(--success-soft); font-weight: 600; }
.import-preview { margin-top: 12px; overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.import-preview table { width: 100%; border-collapse: collapse; font-size: 10px; white-space: nowrap; }
.import-preview th, .import-preview td { max-width: 150px; padding: 7px 9px; overflow: hidden; border-bottom: 1px solid var(--line); text-align: left; text-overflow: ellipsis; }
.import-preview th { color: var(--muted); background: var(--surface-soft); font-weight: 700; }
.import-preview tr:last-child td { border-bottom: 0; }
.subject-import-layout { display: grid; grid-template-columns: minmax(260px, .75fr) minmax(0, 1.25fr); gap: 18px; align-items: start; }

.record-count { padding: 5px 10px; border-radius: 999px; color: var(--brand); background: var(--brand-soft); font-size: 11px; font-weight: 700; white-space: nowrap; }
.evidence-record { overflow: hidden; }
.evidence-hero { padding: 24px 26px; display: flex; align-items: center; justify-content: space-between; gap: 22px; border-bottom: 1px solid var(--line); background: linear-gradient(135deg, var(--surface), var(--brand-soft)); }
.evidence-hero h2 { margin: 4px 0 2px; font-size: clamp(21px, 3vw, 30px); letter-spacing: -.02em; }
.evidence-hero p { margin: 0; color: var(--muted); font-size: 12px; }
.evidence-score { display: flex; flex: 0 0 auto; align-items: center; gap: 12px; }
.evidence-score > strong { color: var(--brand); font-size: 30px; }
.evidence-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); overflow: hidden; border: 1px solid var(--line); border-radius: 13px; }
.evidence-grid > div { min-width: 0; padding: 16px; border-right: 1px solid var(--line); background: var(--surface); }
.evidence-grid > div:last-child { border-right: 0; }
.evidence-grid span, .evidence-grid strong, .evidence-grid small { display: block; }
.evidence-grid span { margin-bottom: 5px; color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.evidence-grid strong { font-size: 13px; overflow-wrap: anywhere; }
.evidence-grid small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.evidence-section { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.evidence-section h3 { margin: 0 0 12px; font-size: 17px; }
.evidence-content { padding: 15px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); line-height: 1.7; overflow-wrap: anywhere; }
.evidence-approval { margin-top: 20px; }
.evidence-signature { margin-top: 24px; padding: 15px 16px; display: grid; gap: 5px; border: 1px dashed #afc4bd; border-radius: 11px; background: color-mix(in srgb, var(--brand-soft) 35%, var(--surface)); }
.evidence-signature span { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .04em; }
.evidence-signature code { padding: 7px 9px; overflow-wrap: anywhere; border-radius: 7px; color: var(--brand-deep); background: var(--surface); font-size: 10px; }
.evidence-signature small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.answer-evidence-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.answer-evidence-card { padding: 15px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
.answer-evidence-card.correct { border-left: 4px solid var(--success); }
.answer-evidence-card.incorrect { border-left: 4px solid var(--danger); }
.answer-evidence-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.answer-evidence-head strong { color: var(--brand); }
.answer-evidence-head span { padding: 3px 8px; border-radius: 999px; color: var(--muted); background: var(--surface-soft); font-size: 10px; font-weight: 700; }
.answer-evidence-card.correct .answer-evidence-head span { color: var(--success); background: var(--success-soft); }
.answer-evidence-card.incorrect .answer-evidence-head span { color: var(--danger); background: var(--danger-soft); }
.answer-evidence-card > p { min-height: 42px; margin: 10px 0 12px; color: var(--ink); font-size: 12px; line-height: 1.6; }
.answer-evidence-choice { padding: 9px 10px; border-radius: 8px; background: var(--surface-soft); }
.answer-evidence-choice + .answer-evidence-choice { margin-top: 7px; }
.answer-evidence-choice span, .answer-evidence-choice strong { display: block; }
.answer-evidence-choice span { color: var(--muted); font-size: 9px; }
.answer-evidence-choice strong { margin-top: 2px; font-size: 11px; }
.answer-evidence-choice.key { color: #235c42; background: var(--success-soft); }
.official-print-header, .official-print-certification { display: none; }

@media (max-width: 1280px) {
    .theme-picker { grid-template-columns: repeat(3, minmax(130px, 1fr)); }
    .workflow-steps { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .milestone-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1120px) {
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .scan-layout { grid-template-columns: 1fr; }
    .settings-grid { grid-template-columns: 1fr; }
    .student-condition-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .milestone-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .evidence-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .evidence-grid > div:nth-child(2) { border-right: 0; }
    .evidence-grid > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
    .question-choice-editor { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
    .app-shell { display: block; }
    .main-column { min-height: 100vh; }
    .sidebar { transform: translateX(-105%); transition: transform .22s ease; box-shadow: 15px 0 40px rgba(0,0,0,.17); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop { position: fixed; z-index: 25; inset: 0; border: 0; background: rgba(10,31,28,.44); }
    .sidebar-backdrop.open { display: block; }
    .menu-button { display: block; }
    .content { padding: 25px 20px; }
    .topbar { padding: 11px 20px; }
    .two-column, .split-even { grid-template-columns: 1fr; }
    .subject-import-layout { grid-template-columns: 1fr; }
    .logo-settings { grid-template-columns: 1fr; }
    .logo-actions, .logo-actions form { justify-content: flex-start; }
    .filter-toolbar { align-items: stretch; flex-wrap: wrap; }
    .filter-controls { width: 100%; flex-wrap: wrap; }
    .filter-search { max-width: none; flex-basis: 100%; }
    .filter-selects { min-width: 0; flex: 1; overflow-x: auto; }
    .filter-summary { margin-left: 0; align-self: center; }
    .question-editor-toolbar { align-items: stretch; flex-direction: column; }
    .question-editor-tools { justify-content: flex-end; }
    .login-shell { grid-template-columns: 1fr; max-width: 580px; }
    .login-story { min-height: 300px; padding: 34px; }
    .login-footnote, .login-points { display: none; }
    .login-form-side { padding: 36px; }
}

@media (max-width: 620px) {
    body { font-size: 14px; }
    .user-chip > span:not(.avatar), .topbar-title .eyebrow { display: none; }
    .topbar-title strong { max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .topbar-brand-icon { width: 34px; height: 34px; }
    .content { padding: 22px 14px; }
    .page-heading { flex-direction: column; }
    .heading-actions, .heading-actions .btn { width: 100%; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .workflow-steps { grid-template-columns: 1fr; }
    .student-condition-grid { grid-template-columns: 1fr; }
    .milestone-grid { grid-template-columns: 1fr; }
    .stat-card { min-height: 124px; padding: 16px; }
    .stat-value { font-size: 27px; }
    .panel-header, .panel-body { padding: 16px; }
    .panel-header { align-items: flex-start; flex-wrap: wrap; }
    .question-editor-toolbar { padding: 10px; }
    .question-editor-tools { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .question-editor-tools label { grid-column: 1 / -1; justify-content: space-between; }
    .question-editor-tools .select { width: min(210px, 65%); }
    .question-editor-tools .btn { width: 100%; }
    .question-card-body { padding: 11px; }
    .form-grid, .form-grid.three, .choice-grid, .answer-options, .review-options { grid-template-columns: 1fr; }
    .question-card-header { grid-template-columns: 32px minmax(0, 1fr) auto; }
    .question-card-config { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .question-card.is-collapsed .question-card-config { display: none; }
    .question-type-select, .correct-choice { width: 100%; justify-content: space-between; }
    .question-type-select .select, .correct-choice .select { width: min(210px, 65%); }
    .question-card-toggle { min-width: 64px; }
    .question-media-editor, .choice-media-editor { grid-template-columns: 1fr; }
    .structured-answer-list article { grid-template-columns: 1fr; }
    .exam-question-heading { flex-direction: column; }
    .search-row { flex-direction: column; }
    .search-row .input { min-width: 0; }
    .question-sticky-bar, .exam-submit { align-items: stretch; flex-direction: column; }
    .question-sticky-bar .btn, .exam-submit .btn { width: 100%; }
    .login-story { min-height: 250px; }
    .login-copy h1 { font-size: 31px; }
    .login-form-side { padding: 28px 22px; }
    .guest-body { padding: 12px; }
    .subject-check-grid { grid-template-columns: 1fr; }
    .enrollment-picker-heading { align-items: flex-start; flex-direction: column; gap: 8px; }
    .enrollment-picker-tools { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .enrollment-subject-search { grid-column: 1 / -1; }
    .enrollment-level-filter { grid-column: 1 / -1; width: 100%; }
    .enrollment-picker-tools .btn { min-height: 40px; padding: 8px; font-size: 10px; }
    .enrollment-subject-options { max-height: 330px; }
    .enrollment-subject-list-head, .enrollment-subject-option { grid-template-columns: 24px 76px minmax(0, 1fr) 52px; gap: 7px; }
    .enrollment-subject-list-head { padding: 8px 10px; }
    .enrollment-subject-option { min-height: 58px; padding: 9px 10px; }
    .enrollment-subject-code { font-size: 10px; }
    .enrollment-subject-name { font-size: 11px; }
    .enrollment-subject-level { padding: 4px 5px; font-size: 8px; }
    .enrollment-list-summary { align-items: flex-start; flex-direction: column; gap: 3px; }
    .login-mobile-access { grid-template-columns: 108px minmax(0, 1fr); gap: 11px; }
    .login-mobile-qr { width: 108px; height: 108px; padding: 6px; }
    .login-mobile-qr canvas, .login-mobile-qr img { width: 94px !important; height: 94px !important; }
    .modal { padding: 0; align-items: end; }
    .modal-dialog { width: 100%; max-height: 94vh; border-radius: 18px 18px 0 0; }
    .modal-header, .modal-body { padding: 18px; }
    .modal-footer { padding: 14px 18px; }
    .modal-footer .btn { flex: 1; }
    .flatpickr-calendar { width: min(340px, calc(100vw - 20px)); }
    .flatpickr-rContainer, .flatpickr-days, .dayContainer { width: min(318px, calc(100vw - 42px)); min-width: min(318px, calc(100vw - 42px)); max-width: min(318px, calc(100vw - 42px)); }
    .flatpickr-day { max-width: 14.2857%; }
    .theme-picker { grid-template-columns: 1fr; }
    .theme-option small { white-space: normal; }
    .app-footer { padding: 14px 18px 22px; flex-direction: column; text-align: center; }
    .logo-actions, .logo-actions form, .logo-actions .btn { width: 100%; }
    .status-report-text-list article { align-items: stretch; flex-direction: column; }
    .status-report-text-list article .btn { width: 100%; }
    .filter-toolbar, .panel-body.flush > .filter-toolbar { padding: 12px; }
    .filter-controls, .filter-selects { align-items: stretch; flex-direction: column; }
    .filter-selects, .filter-select { width: 100%; max-width: none; }
    .filter-summary { flex: 1; }
    .management-table { display: block; table-layout: auto; }
    .management-table thead { display: none; }
    .management-table tbody { padding: 12px; display: grid; gap: 12px; }
    .management-table tr { padding: 4px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); box-shadow: 0 6px 18px rgba(22,49,45,.06); }
    .management-table tbody tr:hover { background: var(--surface); }
    .management-table td { min-width: 0; padding: 11px 12px; display: block; border: 0; overflow: visible; color: var(--ink); font-size: 13px; line-height: 1.45; overflow-wrap: normal; word-break: normal; }
    .management-table td::before { content: attr(data-label); margin-bottom: 4px; display: block; color: var(--muted); font-size: 10px; font-weight: 600; line-height: 1.25; }
    .management-table td:nth-child(1), .management-table td:nth-child(2) { background: color-mix(in srgb, var(--brand-soft) 38%, var(--surface)); }
    .management-table td:nth-child(2) { border-radius: 0 9px 9px 0; }
    .management-table td:first-child { border-radius: 9px 0 0 9px; }
    .management-table td:last-child { grid-column: 1 / -1; padding-top: 12px; border-top: 1px solid var(--line); }
    .management-table .cell-title strong, .management-table .cell-title small { overflow-wrap: normal; word-break: normal; }
    .management-actions { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .management-actions > .btn, .management-actions > form, .management-actions > form .btn { width: 100%; }
    .management-actions .btn { min-height: 42px; padding: 9px 10px; font-size: 11px; }
    .evidence-hero { padding: 19px; align-items: flex-start; flex-direction: column; }
    .evidence-grid, .answer-evidence-grid { grid-template-columns: 1fr; }
    .evidence-grid > div { border-right: 0; border-bottom: 1px solid var(--line); }
    .evidence-grid > div:last-child { border-bottom: 0; }
    .evidence-score { width: 100%; justify-content: space-between; }
}

.install-guide-backdrop { min-height: 68vh; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; opacity: .55; }
.install-guide-backdrop-card { min-height: 190px; border: 1px solid var(--line); border-radius: 22px; background: var(--surface); box-shadow: var(--shadow); }
.install-guide-backdrop-card-wide { min-height: 280px; grid-column: 1 / -1; }
.install-guide-overlay { position: fixed; z-index: 200; inset: 0; padding: 24px; display: grid; place-items: center; background: rgba(8, 24, 22, .76); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.install-guide-dialog { width: min(640px, 100%); max-height: min(92dvh, 900px); overflow: hidden; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; border: 1px solid rgba(255,255,255,.7); border-radius: 24px; background: #fff; box-shadow: 0 30px 90px rgba(0,0,0,.34); }
.install-guide-header { min-height: 82px; padding: 20px 28px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-bottom: 1px solid #e4e9e7; background: #fff; }
.install-guide-header h1 { margin: 0; display: flex; align-items: center; gap: 10px; color: #152a28; font-size: 25px; line-height: 1.25; }
.install-guide-header h1 > span { font-size: 28px; }
.install-guide-close { width: 44px; height: 44px; flex: 0 0 44px; display: grid; place-items: center; border: 1px solid #dce3e1; border-radius: 13px; color: #73817f; background: #fff; font-size: 32px; font-weight: 300; line-height: 1; text-decoration: none; transition: border-color .18s ease, color .18s ease, background .18s ease; }
.install-guide-close:hover, .install-guide-close:focus-visible { border-color: #b7c4c1; color: #263d3a; background: #f4f7f6; }
.install-guide-body { min-height: 0; padding: 26px 32px 28px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.install-guide-illustration { width: 92px; height: 92px; margin: 0 auto 10px; padding: 12px; display: grid; place-items: center; border-radius: 22px; background: linear-gradient(145deg, #5144eb, #6938e9); box-shadow: 0 14px 30px rgba(85,61,232,.28); }
.install-guide-illustration img { width: 66px; height: 66px; border-radius: 14px; object-fit: contain; background: #fff; }
.install-guide-intro { margin-bottom: 20px; text-align: center; }
.install-guide-intro h2 { margin: 0; color: #152a28; font-size: clamp(24px, 4vw, 30px); line-height: 1.35; }
.install-guide-intro p { margin: 7px auto 0; color: #697976; font-size: 14px; line-height: 1.6; }
.install-guide-status { margin-top: 8px; color: #82908e; font-size: 12px; }
.install-guide-install-button { width: 100%; min-height: 60px; margin-top: 16px; padding: 12px 22px; border: 0; border-radius: 13px; color: #fff; background: linear-gradient(135deg, #4e46ec, #563aea); box-shadow: 0 10px 24px rgba(80,65,235,.24); font: inherit; font-size: 19px; font-weight: 700; cursor: pointer; transition: transform .18s ease, box-shadow .18s ease, filter .18s ease; }
.install-guide-install-button:hover, .install-guide-install-button:focus-visible { filter: brightness(1.05); transform: translateY(-1px); box-shadow: 0 13px 28px rgba(80,65,235,.3); }
.install-guide-install-button > span { margin-right: 5px; font-size: 27px; line-height: 0; vertical-align: -2px; }
.install-guide-installed { margin-top: 12px; padding: 8px 12px; display: inline-block; border-radius: 999px; color: #146337; background: #e4f5e9; font-size: 13px; font-weight: 700; }
.install-guide-platform { margin-top: 14px; padding: 20px 24px; border: 1px solid transparent; border-radius: 18px; transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease; }
.install-guide-platform.is-recommended { border-color: currentColor; box-shadow: 0 12px 28px rgba(26,75,70,.12); transform: translateY(-1px); }
.install-guide-platform.is-recommended::after { content: "เหมาะสำหรับอุปกรณ์นี้"; margin-top: 12px; display: block; font-size: 11px; font-weight: 700; text-align: right; }
.install-guide-platform h3 { margin: 0 0 9px; display: flex; align-items: center; gap: 10px; font-size: 18px; line-height: 1.35; }
.install-guide-platform-icon { font-size: 22px; line-height: 1; }
.install-guide-platform ol { margin: 0; padding-left: 27px; color: #334744; font-size: 15px; line-height: 1.75; }
.install-guide-platform li { padding-left: 3px; }
.install-guide-platform strong { color: inherit; }
.install-guide-ios { color: #1756ad; background: #eef5ff; border-color: #d8e7fb; }
.install-guide-ios ol { color: #314b6f; }
.install-guide-android { color: #23784b; background: #eefaf1; border-color: #d7eddd; }
.install-guide-android ol { color: #355d45; }
.install-guide-share { font-size: 22px; }
.install-guide-browser-note { margin: 16px 4px 0; color: #778582; font-size: 12px; line-height: 1.55; text-align: center; }
.install-guide-footer { padding: 18px 28px 22px; border-top: 1px solid #e4e9e7; background: #fff; }
.install-guide-understood { width: 100%; min-height: 56px; padding: 12px 20px; display: flex; align-items: center; justify-content: center; border-radius: 13px; color: #fff; background: #d93b36; box-shadow: 0 10px 24px rgba(217,59,54,.22); font-size: 18px; font-weight: 700; text-decoration: none; transition: background .18s ease, transform .18s ease; }
.install-guide-understood:hover, .install-guide-understood:focus-visible { color: #fff; background: #c8312d; transform: translateY(-1px); }

.audit-filter-toolbar { display: grid; gap: 12px; }
.audit-date-filters { align-items: end; }
.audit-date-filters .field { min-width: 180px; margin: 0; }
.audit-date-filters .field > span { margin-bottom: 5px; display: block; color: var(--muted); font-size: 12px; font-weight: 600; }
.audit-log-table td { vertical-align: top; }
.audit-log-table td:nth-child(4) { min-width: 220px; }
.audit-log-table td:last-child small { max-width: 260px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-permission-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.role-permission-grid article { padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: color-mix(in srgb, var(--brand-soft) 24%, var(--surface)); }
.role-permission-grid h3 { margin: 12px 0 5px; font-size: 16px; }
.role-permission-grid p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.65; }
@media (max-width: 900px) {
    .role-permission-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
    .role-permission-grid { grid-template-columns: 1fr; }
    .audit-date-filters { align-items: stretch; flex-direction: column; }
    .audit-date-filters .field { width: 100%; min-width: 0; }
    .audit-date-filters .btn { width: 100%; }
    .install-guide-overlay { padding: 12px; }
    .install-guide-dialog { max-height: calc(100dvh - 24px); border-radius: 22px; }
    .install-guide-header { min-height: 68px; padding: 14px 18px; }
    .install-guide-header h1 { gap: 7px; font-size: 20px; }
    .install-guide-header h1 > span { font-size: 23px; }
    .install-guide-close { width: 40px; height: 40px; flex-basis: 40px; border-radius: 12px; font-size: 29px; }
    .install-guide-body { padding: 19px 18px 22px; }
    .install-guide-illustration { width: 82px; height: 82px; padding: 10px; border-radius: 20px; }
    .install-guide-illustration img { width: 60px; height: 60px; }
    .install-guide-intro { margin-bottom: 15px; }
    .install-guide-intro h2 { font-size: 22px; }
    .install-guide-intro p { font-size: 12px; }
    .install-guide-install-button { min-height: 56px; padding: 10px 14px; font-size: 17px; }
    .install-guide-platform { margin-top: 12px; padding: 17px 18px; border-radius: 16px; }
    .install-guide-platform h3 { font-size: 16px; }
    .install-guide-platform ol { padding-left: 23px; font-size: 14px; line-height: 1.7; }
    .install-guide-footer { padding: 14px 18px 17px; }
    .install-guide-understood { min-height: 52px; font-size: 17px; }
}

@media print {
    @page { size: A4; margin: 12mm; }
    html, body, .content, .panel, .stat-card, .milestone-card, .data-table, .evidence-record, .official-print-header, .official-print-certification { font-family: "TH SarabunPSK", "TH Sarabun New", "Sarabun", sans-serif !important; }
    body { color: #000; background: #fff; font-size: 16pt; line-height: 1.35; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .sidebar, .topbar, .app-footer, .heading-actions, .btn, .form-actions, .filter-toolbar, .filter-empty { display: none !important; }
    .app-shell, .main-column { display: block; }
    .content { padding: 0; }
    .table-wrap { overflow: visible; }
    .page-heading { display: none !important; }
    .official-print-header { display: block !important; margin-bottom: 16pt; padding-bottom: 12pt; border-bottom: 2px solid #000; }
    .official-print-brand { display: flex; align-items: center; justify-content: center; gap: 12pt; text-align: left; }
    .official-print-brand img { width: 54pt; height: 54pt; object-fit: contain; }
    .official-print-brand strong, .official-print-brand span { display: block; }
    .official-print-brand strong { font-size: 24pt; line-height: 1.1; }
    .official-print-brand span { margin-top: 2pt; font-size: 15pt; }
    .official-print-kicker { margin: 10pt 0 0; text-align: center; font-size: 14pt; font-weight: 700; }
    .official-print-header h1 { margin: 2pt 0 8pt; text-align: center; font-size: 22pt; line-height: 1.15; }
    .official-print-metadata { display: grid; grid-template-columns: 1fr 1fr; gap: 2pt 14pt; padding: 6pt 8pt; border: 1px solid #777; font-size: 12pt; }
    .official-print-metadata span:last-child { grid-column: 1 / -1; }
    .official-print-address { margin-top: 10pt; }
    .official-print-address p { margin: 3pt 0; font-size: 14pt; text-align: justify; }
    .official-print-address p:last-child { text-indent: 36pt; }
    .page-heading p, .panel-header p, .stat-meta, .cell-title small { font-size: 12pt; }
    .panel-header h2, .panel-header h3 { font-size: 18pt; }
    .panel { border: 1px solid #777; border-radius: 0; }
    .panel-header { padding: 8pt 10pt; border-color: #777; }
    .panel-body { padding: 8pt 10pt; }
    .data-table { width: 100%; border-collapse: collapse; }
    .data-table thead { display: table-header-group; }
    .data-table th, .data-table td { padding: 5pt 6pt; border: 1px solid #777; color: #000; font-size: 12pt; vertical-align: top; }
    .data-table tr { break-inside: avoid; }
    .document-roster[hidden] { display: block !important; }
    .document-roster tr[hidden] { display: table-row !important; }
    .official-roster-table th, .official-roster-table td { padding: 4pt; font-size: 10.5pt; }
    .official-detail-section { break-before: page; }
    .official-detail-table th, .official-detail-table td { padding: 3pt; font-size: 9.5pt; line-height: 1.2; }
    .official-detail-table small { font-size: 8.5pt; }
    .badge, .stage-pill { font-size: 11pt; }
    .milestone-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6pt; }
    .milestone-card { min-height: 108pt; padding: 8pt; box-shadow: none; }
    .milestone-card span, .milestone-card small { font-size: 11pt; }
    .milestone-card strong { font-size: 24pt; }
    .milestone-card p { margin: 5pt 0 0; font-size: 9.5pt; line-height: 1.25; }
    .panel, .stat-card { box-shadow: none; break-inside: avoid; }
    .document-section { break-inside: auto; }
    .milestone-summary-panel { break-inside: avoid; }
    .report-narrative-panel { break-inside: avoid; }
    .report-narrative-text p { font-size: 14pt; line-height: 1.55; }
    .status-report-navigation { display: none !important; }
    .answer-evidence-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .answer-evidence-card { break-inside: avoid; }
    .official-print-certification { display: block !important; margin-top: 24pt; break-inside: avoid; }
    .official-print-closing { margin: 0 0 26pt; text-indent: 36pt; font-size: 14pt; }
    .official-signature-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12pt; text-align: center; }
    .official-signature-grid span, .official-signature-grid strong, .official-signature-grid small { display: block; }
    .official-signature-grid span { font-size: 11pt; white-space: nowrap; }
    .official-signature-grid strong { margin-top: 8pt; font-size: 12pt; font-weight: 400; }
    .official-signature-grid small { margin-top: 2pt; font-size: 10pt; }
    .official-print-footnote { margin: 22pt 0 0; padding-top: 5pt; border-top: 1px solid #999; font-size: 9pt; text-align: center; }
}
