:root{--blue:#153c72;--blue2:#1b5795;--bg:#f5f7fa;--line:#dce3ec;--muted:#627184;--txt:#18283a;--good:#247c55;--warn:#ae631f;--red:#b43b3b}*{box-sizing:border-box}
body{font:15px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",Arial,sans-serif;margin:0;background:var(--bg);color:var(--txt)}
.top{background:white;border-bottom:1px solid var(--line);padding:13px clamp(16px,4vw,48px);display:flex;gap:20px;justify-content:space-between;align-items:center;min-height:79px}
.brand{display:flex;align-items:center;gap:12px}.brandmark{background:var(--blue);color:white;font-size:17px;font-weight:800;border-radius:12px;display:grid;place-items:center;width:45px;height:45px}.brand strong{display:block;font-size:17px;letter-spacing:.4px;color:#14345c}.brand small{font-size:11px;color:var(--muted);letter-spacing:.55px;font-weight:600}
.exam-controls{display:flex;align-items:center;gap:9px}.exam-controls label{font-weight:600;font-size:13px;color:var(--muted)}
.layout{max-width:1220px;margin:0 auto;padding:22px 22px 30px}.steps{display:flex;gap:8px;margin:0 0 25px}.steps button{border:1px solid var(--line);background:#fff;color:#52637b;cursor:pointer;flex:1;padding:13px 10px;border-radius:10px;display:flex;justify-content:center;align-items:center;gap:11px;font-weight:750;font-size:14px}.steps button b{border:1px solid #bfcedd;border-radius:50%;width:26px;height:26px;display:grid;place-items:center}.steps button.active{color:#fff;border-color:var(--blue);background:var(--blue)}.steps button.active b{border-color:#d2e9ff;background:rgba(255,255,255,.13)}.steps button:hover:not(.active){border-color:#8caacd;background:#f0f7fe}
.head{margin-bottom:17px}.head h1{font-size:25px;letter-spacing:-.4px;margin:0 0 2px}.head p{color:var(--muted);font-size:14px;margin:0}
.panel{background:#fff;border:1px solid var(--line);border-radius:12px;margin-bottom:15px;overflow:hidden}.panel-head{padding:16px 19px 12px;border-bottom:1px solid #edf1f5}.panel-head h2{font-size:17px;line-height:1.4;margin:0}.panel-head p{color:var(--muted);font-size:13px;margin:3px 0 0}.panel-body{padding:18px 19px}.panel-body.slim{padding:11px 18px}.toolbar{display:flex;flex-wrap:wrap;align-items:end;gap:12px}.field{min-width:125px;display:flex;flex-direction:column;gap:5px}.field.grow{flex:1;min-width:220px}.field label{font-size:12px;font-weight:750;color:#516078}.muted,.helper{color:var(--muted);font-size:13px}.helper{margin:12px 0 0}
input,select,textarea{font:inherit;background:white;color:var(--txt);border:1px solid #cbd6e2;border-radius:8px;padding:9px 10px;max-width:100%;min-height:40px}select{min-width:115px}input[type=file]{padding:7px 9px}input[type=checkbox]{min-height:auto;width:16px;height:16px;vertical-align:middle;accent-color:var(--blue)}input:focus,select:focus{outline:2px solid #96bff4;outline-offset:1px;border-color:#628ccc}
.btn{display:inline-flex;justify-content:center;align-items:center;gap:7px;background:white;border:1px solid #cbd6e2;color:#253b56;font-weight:700;font-size:13px;cursor:pointer;text-decoration:none;border-radius:8px;padding:10px 14px;white-space:nowrap;min-height:40px}.btn:hover{background:#f1f6fc}.btn.primary{background:var(--blue);border-color:var(--blue);color:white}.btn.primary:hover{background:#24588d}.btn.subtle{background:#f2f6fb}.btn:disabled{opacity:.5;cursor:not-allowed}.btn-row{display:flex;flex-wrap:wrap;gap:9px;margin:12px 0 0}.btn.large{padding:13px 20px;font-size:14px}
.table-wrap{max-width:100%;overflow:auto}.table{border-collapse:collapse;width:100%;font-size:13px;min-width:620px}.table th{position:sticky;top:0;background:#e9eff6;border-bottom:1px solid #c7d3df;color:#27435e;font-size:12px;text-align:left;padding:10px 11px;white-space:nowrap}.table td{padding:8px 11px;border-bottom:1px solid #e9eef3;vertical-align:middle}.table tr:hover td{background:#f8fafc}.num{text-align:right!important;font-variant-numeric:tabular-nums}.center{text-align:center!important}.mono{font-family:Consolas,monospace}.table .score-input{width:87px;min-height:34px;padding:5px 9px;font-weight:650;border-radius:5px}.table .phach-input{width:108px;min-height:34px;padding:5px 8px;border-radius:5px}.table select{min-width:110px;min-height:34px;padding:5px 7px}
.notice{background:#f0f6ff;border-left:3px solid #5885b6;border-radius:6px;padding:12px 14px;margin-top:12px;font-size:13px}.notice.warn{background:#fff6eb;border-color:#ce8a40}.notice.success{background:#eff9f3;border-color:#5baf86}.small-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px}.mini-card{padding:14px;border:1px solid var(--line);border-radius:10px;background:#fff}.mini-card strong{font-size:21px;display:block;color:var(--blue)}.mini-card small{color:var(--muted);font-size:12px}
details{border:1px solid #dce5f0;border-radius:9px;margin-top:14px;background:#fcfdff}summary{padding:12px 14px;cursor:pointer;color:#315a86;font-weight:680;font-size:13px}details .inside{padding:1px 14px 15px}.settings-row{display:grid;grid-template-columns:70px 1fr 1fr;gap:9px;align-items:center;max-width:460px;margin:8px 0}.checkline{display:inline-flex;gap:7px;align-items:center;font-size:13px}.choices{display:flex;flex-wrap:wrap;gap:9px}.select-link{border:1px solid #cad9eb;color:#234d79;border-radius:9px;padding:12px 16px;cursor:pointer;text-align:left;min-width:200px;background:white;font-weight:700}.select-link:hover{background:#f2f8ff;border-color:#6797c8}.select-link small{display:block;color:var(--muted);font-weight:400;margin-top:4px;white-space:normal}.empty{padding:24px;color:#687992;text-align:center}.divider{height:1px;background:#edf1f5;margin:16px 0}.tag{display:inline-block;border-radius:5px;padding:2px 7px;background:#f1f4f8;color:#51637a;font-size:11px;font-weight:700}.tag.good{background:#eaf7ef;color:#207b51}.tag.warn{background:#fff4e3;color:#9c631b}.tag.bad{background:#ffeded;color:#b43b3b}
.modal-back{position:fixed;inset:0;background:rgba(20,33,50,.53);display:flex;align-items:center;justify-content:center;padding:18px;z-index:100}.modal-back.hidden{display:none}.modal{background:white;border-radius:13px;padding:24px;width:min(700px,98vw);max-height:90vh;overflow:auto;box-shadow:0 10px 60px #13263744}.modal h2{margin:0 0 13px}.modal .table{min-width:500px}#toast{position:fixed;right:18px;bottom:17px;z-index:150;display:none;background:#204b7c;color:white;border-radius:8px;padding:11px 17px;box-shadow:0 10px 35px #0d294b44;font-size:13px}#toast.error{background:#a83838}footer{text-align:center;font-size:12px;color:#8a98a7;padding:23px 0}a{color:#14599a}h3{margin:0 0 10px;font-size:15px}
@media(max-width:850px){.top{flex-wrap:wrap;padding:12px 16px}.exam-controls{width:100%;flex-wrap:wrap}.exam-controls select{flex:1}.layout{padding:15px 12px}.steps button{font-size:12px;padding:9px 6px;gap:5px}.steps button b{width:23px;height:23px}.head h1{font-size:21px}.small-grid{grid-template-columns:repeat(2,1fr)}.panel-body{padding:14px}.toolbar>.field{flex:1;min-width:145px}.btn{white-space:normal}}

/* V1.3: compact single-entry grid. */
.entry-grid{min-width:max-content;border-collapse:separate;border-spacing:0;font-size:13px}
.entry-grid th{position:sticky;top:0;z-index:3;min-width:110px;white-space:normal;background:#eaf1fb}
.entry-grid th:first-child,.entry-grid th:nth-child(2){min-width:65px}
.entry-grid .studentname{min-width:170px;white-space:nowrap;font-weight:600}
.entry-grid td{padding:5px 7px!important;white-space:nowrap}
.entry-grid .edit-cell{padding:4px!important}
.entry-grid input.grid-input{width:105px;min-width:90px;border:1px solid #c7d5e5;border-radius:5px;padding:8px 6px;background:white;line-height:1.2;font-size:14px}
.entry-grid input.grid-input:focus{outline:2px solid #2464b7;outline-offset:1px;background:#f2f8ff}
.entry-grid .phach-view{min-width:110px;text-align:center;background:#f7faff}
.entry-grid .match-phach,.entry-grid .match-phach input{background:#fff2a1!important;color:#332700!important;font-weight:700}
.entry-grid input.saving{border-color:#c98c29!important;background:#fff8eb!important}
.entry-grid input.saved{border-color:#15803d!important;background:#f0fff1!important}
.entry-grid input.save-error{border:2px solid #c53030!important;background:#fff0ef!important}
@media(max-width:850px){.entry-grid{font-size:12px}.entry-grid .studentname{min-width:135px}.entry-grid input.grid-input{width:87px;min-width:80px}}

/* V1.6: Edit the selected exam name directly in the header. */
#examSelect{max-width:180px;min-width:135px}
#examNameEdit{width:clamp(220px,27vw,460px);min-width:190px;padding:9px 12px;border-radius:7px;border:1px solid #c8d5e6;background:#fff;color:#152d48;font:inherit;font-size:14px}
#examNameEdit:focus{outline:2px solid #2877c7;outline-offset:1px}
#examNameStatus{font-size:11px;min-width:56px;color:#52718f;white-space:nowrap}
#examNameStatus.pending{color:#8d6200}
#examNameStatus.error{color:#b42318}
@media(max-width:850px){#examNameEdit{flex:1;min-width:180px;max-width:100%}}

/* V1.7: one editable exam name, no visible operator or duplicate selector */
#examSelect{display:none!important}
.exam-controls #examNameEdit{width:clamp(280px,38vw,560px)}
.visually-hidden{position:absolute!important;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}

/* V1.7 – export choices grouped compactly for quick operation */
.export-lines{display:grid;gap:9px}.export-line{display:flex;align-items:center;gap:9px;flex-wrap:wrap;border:1px solid #e1e8f1;border-radius:10px;padding:11px 14px;background:#fbfcfe}.export-line>strong,.export-line .export-title{min-width:245px;flex:1}.export-title{display:flex;flex-direction:column;gap:3px}.export-title small{font-size:12px;color:#61718a}.export-line .btn{min-width:94px}

/* V1.9 – minimal speaking-score settings */
.gear-btn{font-size:24px;line-height:1;min-width:42px;min-height:41px;padding:5px 12px;margin-top:19px}
.class-tab-list{max-height:165px;overflow-y:auto;border:1px solid #e0e7ef;border-radius:10px;padding:9px;margin:10px 0 18px;background:#f8fafc}
.class-tab-group{display:flex;gap:5px;flex-wrap:wrap;align-items:center;margin:5px 0 9px}
.class-tab-caption{font-weight:700;min-width:55px;font-size:12px;color:#53657a}
.class-tab{border:1px solid #d0d9e7;border-radius:7px;padding:6px 9px;background:#fff;cursor:pointer;font-size:13px}
.class-tab.selected{border-color:#205293;background:#dfecfc;font-weight:bold}
.class-tab.no-speaking{color:#777;background:#eee}
.auto-rule-table input{width:100%;max-width:150px;min-width:60px;padding:8px 9px;border-radius:6px;border:1px solid #c9d5e5}
.auto-switch{padding:12px;background:#eaf5ed;border:1px solid #bce3c6;border-radius:8px;margin:12px 0}
.auto-switch input{width:18px;height:18px;vertical-align:middle;margin-right:6px}
.auto-score{font-weight:600;color:#236347;background:#eef9f2;text-align:center}
.auto-score small{display:block;color:#567d68;font-size:10px}
.project-actions{flex-wrap:wrap;gap:9px}
.project-actions input[type=file]{max-width:210px;font-size:12px}

.grade-only-tabs{display:flex;gap:8px;max-height:none;justify-content:flex-start;flex-wrap:wrap}
.grade-only-tabs .class-tab{min-width:85px;font-size:14px;padding:10px}

/* V1 – consistent, legible type scale and four one-click grade switches */
body{font-size:16px}
.brand strong,.panel-head h2{font-size:18px}
.brand small,.exam-controls label,.field label,.helper,.muted,.panel-head p,summary,.notice{font-size:14px}
.steps button,.btn,.table,.table th,.entry-grid,.entry-grid th,.entry-grid td{font-size:15px}
.entry-grid input.grid-input{font-size:16px}
.entry-grid .studentname{font-size:15px}
.entry-grid th{white-space:normal}
#examNameEdit{font-size:16px}
.auto-score small{display:none!important}
.speaking-grade-list{display:grid;gap:10px;margin:18px 0}
.speaking-grade-row{display:flex;justify-content:space-between;align-items:center;padding:15px 18px;border:1px solid #d5e2ee;border-radius:10px;cursor:pointer;background:#fff;gap:12px}
.speaking-grade-row strong{display:block;font-size:18px}
.speaking-grade-row small{display:block;font-size:14px;color:#627184}
.speaking-grade-row input{width:22px;height:22px;flex:none}
.speaking-grade-row.grade-active{background:#eaf6ee;border-color:#9fd1b4}
.speaking-grade-row.grade-disabled{background:#f2f4f7;color:#667085;cursor:default}
.speaking-grade-row.grade-disabled input{cursor:not-allowed}
.advanced-speaking{margin-top:15px}
.advanced-label{display:flex;align-items:center;gap:15px;padding:10px 0;font-weight:650}

/* V1 – compact, separate configuration screen; no new app-wide menus. */
.config-exams{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:10px}
.config-exam{text-align:left;cursor:pointer;border:1px solid #d2deeb;border-radius:10px;background:white;color:#284868;padding:13px 15px;min-height:75px;display:flex;flex-direction:column;gap:5px;font:inherit}
.config-exam b{font-size:15px;line-height:1.35}.config-exam small{color:#687c91;font-size:13px}
.config-exam.selected{border:2px solid #235b9e;background:#edf5ff}
.config-subjects{display:grid;gap:9px;max-width:610px}.config-line{display:grid;grid-template-columns:95px minmax(140px,1fr);align-items:center;gap:10px}.config-line label{font-weight:700}
.config-speaking-grid{display:grid;grid-template-columns:repeat(4,minmax(130px,1fr));gap:10px;margin-bottom:14px}
.config-speaking{display:flex;align-items:center;gap:10px;border:1px solid #d3dfeb;border-radius:10px;padding:14px;background:#fff;cursor:pointer;min-width:0}
.config-speaking.on{border-color:#94cfa8;background:#ecf7ef}.config-speaking input{width:21px;height:21px}.config-speaking b{display:block}.config-speaking small{display:block;font-size:12px;color:#607181;margin-top:2px}
.config-dates{display:flex;gap:22px;flex-wrap:wrap}.config-dates .field{min-width:230px}.config-dates input{font-size:16px}
.config-copy{display:block;margin:18px 0 10px;line-height:1.6}.config-copy input{width:18px;height:18px}
@media(max-width:850px){.config-speaking-grid{grid-template-columns:repeat(2,1fr)}.config-line{grid-template-columns:70px 1fr}}

/* V1: when no exam code was assigned, show SBD in the code column without storing a phach. */
.entry-grid .phach-view.sbd-fallback{color:#205381;background:#f0f6ff;font-weight:700;font-variant-numeric:tabular-nums}
.storage-location{display:flex;align-items:center;flex-wrap:wrap;gap:10px;border:1px solid #dbe5ef;border-radius:8px;background:#f5f9fe;padding:9px 12px;margin-top:7px}
.storage-location code{overflow-wrap:anywhere;flex:1;min-width:220px;color:#17466f;font-size:13px}

/* V1 - Speaking rules per grade, with one edit button for each grade. */
.config-speaking-grid{grid-template-columns:repeat(2,minmax(245px,1fr))}
.config-speaking{justify-content:space-between;flex-wrap:wrap;cursor:default}
.config-speaking label{display:flex;align-items:center;gap:10px;cursor:pointer;flex:1;min-width:150px}
.config-speaking .btn{min-height:35px;padding:7px 11px}
@media(max-width:680px){.config-speaking-grid{grid-template-columns:1fr}}
