:root{font-family:Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;color:#172033;background:#f3f6fa;--blue:#0f3b70;--blue2:#1b5e9f;--line:#dfe6ee;--muted:#687588}*{box-sizing:border-box}body{margin:0}.topbar{height:72px;position:sticky;top:0;z-index:30;display:flex;align-items:center;gap:20px;padding:10px 28px;background:#fff;border-bottom:1px solid var(--line);box-shadow:0 2px 12px #0000000d}.brand{display:flex;align-items:center;gap:10px}.brand img{width:48px;height:48px;object-fit:contain}.brand strong{display:block;color:var(--blue);font-size:17px}.brand span{display:block;font-size:10px;letter-spacing:1px;color:#667}.teacher-chip{margin-left:auto;background:#edf4fc;color:var(--blue);padding:7px 11px;border-radius:999px;font-size:12px;font-weight:800}.menu-btn{display:none;margin-left:auto;border:0;background:#edf4fc;color:var(--blue);border-radius:9px;padding:8px 11px;font-size:22px}.layout{display:grid;grid-template-columns:245px 1fr;min-height:calc(100vh - 72px)}aside{background:#0b315c;color:#fff;padding:20px 12px}.portal-label{padding:8px 12px 16px;font-size:11px;letter-spacing:1.4px;opacity:.7;font-weight:800}nav{display:flex;flex-direction:column;gap:5px}nav button{border:0;background:transparent;color:#eaf2fb;padding:11px 12px;border-radius:9px;text-align:left;cursor:pointer;font-weight:700}nav button.active,nav button:hover{background:#ffffff1f;color:#fff}main{padding:24px clamp(16px,3vw,38px) 48px;min-width:0}.identity{display:grid;grid-template-columns:1.25fr .75fr;gap:20px;padding:24px;border-radius:17px;background:linear-gradient(135deg,var(--blue),var(--blue2));color:#fff}.identity h1{margin:3px 0 6px;font-size:clamp(30px,4vw,46px)}.identity p{margin:0}.eyebrow{font-size:11px;font-weight:800;letter-spacing:1.2px}.identity-box{align-self:center;background:#ffffff18;border:1px solid #ffffff40;padding:14px;border-radius:12px}.identity-box label{display:block;font-size:12px;font-weight:800;margin-bottom:6px}.identity-box select,.control select,.control input,.control textarea{width:100%;padding:10px;border:1px solid #cfd9e5;border-radius:8px;background:#fff;color:#26384d}.identity-box small{display:block;margin-top:7px;opacity:.8}.status{margin:14px 0;padding:10px 13px;border:1px solid var(--line);background:#fff;border-radius:9px;color:#596779}.status.ok{display:none}.status.error{display:block;background:#fff3f3;border-color:#edcaca;color:#922}.welcome{margin:20px 0 12px}.welcome h2{margin:0;color:var(--blue)}.welcome p{color:var(--muted);margin:5px 0}.cards{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:12px}.metric,.panel{background:#fff;border:1px solid #e0e7ef;border-radius:14px;box-shadow:0 5px 18px #1622330d}.metric{padding:16px}.metric span{font-size:12px;color:#6a7585}.metric strong{display:block;color:var(--blue);font-size:26px;margin-top:4px}.panel{padding:17px;margin-top:14px}.panel h3{color:var(--blue);margin:0 0 12px}.pills{display:flex;flex-wrap:wrap;gap:7px}.pill{background:#edf4fc;color:var(--blue);padding:6px 9px;border-radius:999px;font-size:12px;font-weight:800}.filters{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px}.control label{display:block;font-size:12px;font-weight:800;color:#4d5b6d;margin-bottom:5px}.actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:12px}.btn{border:0;border-radius:8px;padding:9px 13px;cursor:pointer;font-weight:800}.btn.primary{background:var(--blue);color:#fff}.btn.secondary{background:#e9eff6;color:#31465e}.btn.danger{background:#fff0f0;color:#a32626}.table-wrap{overflow:auto;border:1px solid #e3e9f0;border-radius:10px}table{width:100%;border-collapse:collapse;min-width:760px}th,td{padding:10px;border-bottom:1px solid #e6ebf1;text-align:left;font-size:13px}th{background:#eef4fb;color:var(--blue);position:sticky;top:0}.student-photo{width:42px;height:42px;border-radius:50%;object-fit:cover;background:#eef2f6}.photo-placeholder{width:42px;height:42px;border-radius:50%;display:grid;place-items:center;background:#eef2f6}.score{width:76px;padding:7px;border:1px solid #ccd7e3;border-radius:7px}.check{width:20px;height:20px}.empty{padding:32px;text-align:center;border:1px dashed #c9d4e0;border-radius:11px;color:var(--muted);background:#fff}.notice{padding:11px 13px;background:#f7f9fc;border-left:4px solid var(--blue);border-radius:8px;color:#536176}.post-grid{display:grid;grid-template-columns:1fr 1fr;gap:14px}.post-card{border:1px solid #e2e8ef;border-radius:11px;padding:13px}.post-card h4{margin:0 0 6px;color:var(--blue)}.post-card small{color:#788493}.summary{display:flex;gap:12px;flex-wrap:wrap}.summary span{background:#f0f5fa;padding:7px 10px;border-radius:8px;font-weight:700}.money{text-align:right;font-variant-numeric:tabular-nums}footer{text-align:center;padding:20px;color:#728096;background:#fff;border-top:1px solid var(--line)}
@media(max-width:1050px){.cards{grid-template-columns:repeat(3,1fr)}.filters{grid-template-columns:repeat(2,1fr)}}@media(max-width:800px){.topbar{padding:10px 14px}.teacher-chip{display:none}.menu-btn{display:block}.layout{display:block}aside{position:fixed;left:-270px;top:72px;bottom:0;width:245px;z-index:25;transition:left .2s;box-shadow:10px 0 25px #0002}.sidebar-open aside{left:0}main{padding:16px}.identity{grid-template-columns:1fr}.cards{grid-template-columns:repeat(2,1fr)}.post-grid{grid-template-columns:1fr}}@media(max-width:560px){.brand strong{font-size:14px}.brand img{width:42px;height:42px}.cards,.filters{grid-template-columns:1fr}.identity{padding:19px}.table-wrap table{min-width:680px}.table-wrap{max-width:100%;overflow-x:auto}.actions .btn{flex:1}}

/* Teacher Results & Marks — scoped upgrade */
.result-student-card{display:flex;gap:20px;align-items:center}
.result-student-photo .student-photo,.result-student-photo .photo-placeholder{width:110px;height:110px;border-radius:12px;object-fit:cover}
.result-student-info{flex:1}.result-student-info h3{margin:0 0 10px}
.student-facts{display:flex;flex-wrap:wrap;gap:8px 18px}.student-facts span{min-width:145px}
.result-entry-grid{display:grid;grid-template-columns:repeat(5,minmax(130px,1fr));gap:12px;align-items:end}
.result-entry-grid .result-remarks{grid-column:span 2}
@media(max-width:900px){.result-entry-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.result-entry-grid .result-remarks{grid-column:span 2}}
@media(max-width:600px){.result-student-card{align-items:flex-start}.result-entry-grid{grid-template-columns:1fr}.result-entry-grid .result-remarks{grid-column:span 1}.student-facts{display:grid;grid-template-columns:1fr 1fr}}

.report-student-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;margin-top:14px}.report-student-check{display:flex;gap:8px;align-items:center;padding:10px;border:1px solid var(--line);border-radius:9px;background:#f9fbfd}.report-student-check input{width:18px;height:18px}.report-student-check span{display:flex;flex-direction:column}.report-student-check small{color:var(--muted);margin-top:2px}@media(max-width:800px){.report-student-grid{grid-template-columns:1fr 1fr}}@media(max-width:560px){.report-student-grid{grid-template-columns:1fr}}

/* Teacher Attendance — scoped passport-photo rendering fix */
.attendance-student-photo{width:55px!important;height:65px!important;max-width:55px!important;max-height:65px!important;min-width:55px!important;min-height:65px!important;object-fit:cover!important;object-position:center top!important;display:block!important;margin:0 auto!important;border-radius:6px!important;background:#eef2f6!important}
.attendance-photo-placeholder{width:55px!important;height:65px!important;max-width:55px!important;max-height:65px!important;min-width:55px!important;min-height:65px!important;margin:0 auto!important;border-radius:6px!important}
@media(max-width:560px){.attendance-student-photo,.attendance-photo-placeholder{width:48px!important;height:58px!important;max-width:48px!important;max-height:58px!important;min-width:48px!important;min-height:58px!important}}
@media print{.attendance-student-photo{width:55px!important;height:65px!important;max-width:55px!important;max-height:65px!important;min-width:55px!important;min-height:65px!important;object-fit:cover!important;display:block!important;margin:0 auto!important}}

.teacher-promotion-panel{margin-top:18px}
.teacher-promotion-next{align-self:end;padding:10px 12px;border:1px solid var(--line);border-radius:9px;background:#f8fafc;min-height:42px}
.teacher-promotion-summary{display:flex;flex-direction:column;gap:5px;padding:12px 14px;margin:12px 0;border:1px solid var(--line);border-radius:10px;background:#f8fafc}
.teacher-promotion-counts{margin:12px 0;padding:10px 12px;border-radius:8px;background:#eef4fb}
.teacher-promotion-list{display:grid;gap:8px;margin:12px 0}
.teacher-promotion-student{display:flex;align-items:center;gap:10px;padding:9px 10px;border:1px solid var(--line);border-radius:10px;background:#fff}
.teacher-promotion-student>input{width:18px;height:18px;flex:0 0 auto}
.teacher-promotion-photo{width:48px;height:56px;display:flex;align-items:center;justify-content:center;overflow:hidden;border-radius:6px;background:#f2f4f7;flex:0 0 48px}
.teacher-promotion-photo .student-photo,.teacher-promotion-photo .photo-placeholder{width:48px!important;height:56px!important;max-width:48px!important;max-height:56px!important;object-fit:cover!important;margin:0!important}
.teacher-promotion-details{display:flex;flex-direction:column;min-width:0}
.teacher-promotion-details small{color:var(--muted);margin-top:3px}
@media(max-width:600px){.teacher-promotion-student{align-items:flex-start}.teacher-promotion-details small{line-height:1.35}}

/* Teacher Personal Profile — scoped surgical upgrade */
.teacher-profile-panel{margin-top:20px}.teacher-profile-heading{display:flex;justify-content:space-between;gap:14px;align-items:center}.teacher-profile-heading h3{font-size:24px;margin:4px 0 0}.teacher-profile-grid{display:grid;grid-template-columns:220px 1fr;gap:22px;margin-top:16px}.teacher-profile-photo-col{display:flex;flex-direction:column;align-items:center;gap:10px}.teacher-profile-photo{width:180px;height:210px;object-fit:cover;object-position:center top;border-radius:14px;border:1px solid var(--line);background:#eef2f6}.teacher-profile-photo-empty{display:grid;place-items:center;font-size:54px}.teacher-profile-details{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}.teacher-profile-details>div{padding:10px 12px;border:1px solid var(--line);border-radius:9px;background:#f9fbfd}.teacher-profile-details b,.teacher-profile-details span{display:block}.teacher-profile-details b{font-size:11px;color:var(--muted);margin-bottom:4px}.teacher-profile-modal{position:fixed;inset:0;z-index:1000;background:#0008;display:grid;place-items:center;padding:18px;overflow:auto}.teacher-profile-dialog{width:min(960px,100%);max-height:92vh;overflow:auto;background:#fff;border-radius:16px;padding:20px}.teacher-profile-dialog-head{display:flex;justify-content:space-between;gap:12px;align-items:center;position:sticky;top:-20px;background:#fff;padding:8px 0 12px;z-index:2}.teacher-profile-dialog h2,.teacher-profile-dialog h3{color:var(--blue)}.profile-form-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.profile-form-grid label{font-size:12px;font-weight:800;color:#4d5b6d}.profile-form-grid input,.profile-form-grid select{width:100%;padding:10px;margin-top:5px;border:1px solid #cfd9e5;border-radius:8px;background:#fff}.profile-form-grid input[readonly]{background:#eef2f6;color:#667}.teacher-photo-dialog{max-width:520px}.teacher-photo-preview{text-align:center;margin:14px 0}.teacher-photo-preview p{font-weight:800;color:var(--blue)}
@media(max-width:700px){.teacher-profile-heading{align-items:flex-start;flex-direction:column}.teacher-profile-grid{grid-template-columns:1fr}.teacher-profile-details,.profile-form-grid{grid-template-columns:1fr}.teacher-profile-photo{width:150px;height:180px}}
\n/* Teacher Fees & Textbooks — read-only synchronized view */
.teacher-fee-warning{margin-bottom:14px}.teacher-fee-loading{padding:10px 12px;margin:10px 0;border:1px solid var(--line);border-radius:8px;background:#f8fafc;font-weight:700}.teacher-fee-loading.error{color:#a51d1d}.teacher-fee-summary{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:10px}.teacher-fee-summary>div,.teacher-fee-account-summary span{padding:12px;border:1px solid var(--line);border-radius:9px;background:#f8fafc}.teacher-fee-summary span,.teacher-fee-summary b,.teacher-fee-account-summary span,.teacher-fee-account-summary b{display:block}.teacher-fee-summary span{font-size:11px;color:var(--muted);font-weight:800}.teacher-fee-summary b{margin-top:4px}.teacher-fee-student{display:flex;align-items:center;gap:8px;min-width:190px}.teacher-fee-student .student-photo,.teacher-fee-student .photo-placeholder{width:42px!important;height:50px!important;max-width:42px!important;max-height:50px!important;object-fit:cover!important;border-radius:6px;margin:0!important}.teacher-fee-student span{display:flex;flex-direction:column}.teacher-fee-student small{color:var(--muted)}.teacher-fee-status{font-weight:800}.teacher-fee-status.paid{color:#137333}.teacher-fee-status.partial{color:#9a6700}.teacher-fee-status.due{color:#b3261e}.teacher-fee-account-head{display:flex;align-items:center;gap:14px}.teacher-fee-account-head .student-photo,.teacher-fee-account-head .photo-placeholder{width:78px!important;height:92px!important;max-width:78px!important;max-height:92px!important;object-fit:cover!important;border-radius:8px}.teacher-fee-account-summary{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;margin-top:14px}.teacher-fee-account-summary b{margin-top:4px}.afisap-fee-save-status{margin-top:10px;font-weight:800}@media(max-width:800px){.teacher-fee-summary{grid-template-columns:repeat(2,minmax(0,1fr))}.teacher-fee-account-summary{grid-template-columns:1fr}}\n
/* Teacher Portal security */
.identity-box input{width:100%;padding:10px;border:1px solid #cfd9e5;border-radius:8px;background:#fff;color:#26384d;margin-bottom:8px}
.identity-box form{display:grid;gap:6px}.identity-box .btn{margin-top:4px}
#teacherSignedInBox{display:flex;gap:10px;align-items:center;justify-content:space-between;flex-wrap:wrap}
.teacher-auth-modal{position:fixed;inset:0;z-index:1200;background:#0008;display:grid;place-items:center;padding:18px}
.teacher-auth-dialog{width:min(520px,100%);background:#fff;color:#172033;border-radius:16px;padding:20px}
.teacher-auth-dialog h2{color:var(--blue);margin-top:0}.teacher-auth-dialog label{display:block;font-size:12px;font-weight:800;margin-top:10px}
.teacher-auth-dialog input{width:100%;padding:10px;border:1px solid #cfd9e5;border-radius:8px;margin-top:5px}

/* Clean authenticated / logged-out Teacher Portal transition */
.teacher-login-screen{min-height:100vh;position:relative;overflow:hidden;display:grid;place-items:center;padding:24px;background:#062f55}.teacher-login-backdrop{position:absolute;inset:-7%;background-image:linear-gradient(rgba(1,35,67,.18),rgba(1,35,67,.38)),url("afisap_teacher_login_wallpaper.png");background-size:cover;background-position:center;transform:scale(1.08);animation:afisapTeacherLoginWallpaperMove 18s ease-in-out infinite alternate;will-change:transform,background-position}.teacher-login-content{position:relative;z-index:1;width:min(460px,100%)}
.teacher-login-card{width:min(420px,100%);margin:0 auto;background:rgba(255,255,255,.97);border:1px solid #ffffff66;border-radius:18px;box-shadow:0 22px 65px #001a3566;padding:28px;backdrop-filter:blur(5px)}
.teacher-login-logo{display:block;width:78px;height:78px;object-fit:contain;margin:0 auto 10px}.teacher-login-school,.teacher-login-motto{display:block;text-align:center}.teacher-login-school{color:var(--blue);font-size:18px}.teacher-login-motto{font-size:10px;letter-spacing:1.5px;color:var(--muted);margin-top:3px}.teacher-login-card h1{text-align:center;color:var(--blue);font-size:26px;margin:18px 0}.teacher-login-card label{display:block;font-size:12px;font-weight:800;color:#4d5b6d;margin:10px 0 5px}.teacher-login-card input{width:100%;padding:12px;border:1px solid #cfd9e5;border-radius:9px;background:#fff;color:#26384d}.teacher-password-row{display:flex;gap:7px;align-items:stretch}.teacher-password-row input{flex:1;min-width:0}.password-toggle{border:1px solid #cfd9e5;background:#eef4fb;color:var(--blue);border-radius:9px;padding:0 12px;font-weight:800;cursor:pointer}.teacher-signin{width:100%;padding:12px;margin-top:16px}.teacher-forgot{text-align:center;color:var(--muted);font-size:12px;margin:15px 0 0}.teacher-login-status{min-height:20px;margin-top:10px;text-align:center;font-size:13px;font-weight:700;color:#922}.teacher-auth-progress{margin-top:14px}.teacher-auth-progress-label{display:flex;justify-content:space-between;gap:12px;font-size:12px;color:#536176;margin-bottom:6px}.teacher-auth-progress-track{height:9px;border-radius:999px;background:#e5ebf2;overflow:hidden}.teacher-auth-progress-track span{display:block;height:100%;width:0;background:var(--blue);border-radius:inherit;transition:width .28s ease}.teacher-transition-overlay{position:fixed;inset:0;z-index:2000;background:#f3f6faf2;display:grid;place-items:center;padding:20px}.teacher-transition-card{width:min(390px,100%);background:#fff;border:1px solid var(--line);border-radius:16px;box-shadow:0 18px 50px #0f3b7020;padding:24px}.teacher-transition-card>strong{display:block;text-align:center;color:var(--blue);margin-bottom:14px}.teacher-logged-out #teacherProtectedShell{display:none!important}.teacher-authenticated #teacherLoginScreen{display:none!important}.teacher-authenticated #teacherProtectedShell{display:block!important}
@media(max-width:560px){.teacher-login-screen{padding:16px}.teacher-login-card{padding:22px}.teacher-login-logo{width:68px;height:68px}.teacher-login-card h1{font-size:23px}}


/* Critical Teacher Portal visibility rule: hidden must always win. */
.teacher-transition-overlay[hidden],
.teacher-auth-progress[hidden],
#teacherLoginScreen[hidden],
#teacherProtectedShell[hidden]{
  display:none!important;
}

/* AFISAP Fees synchronization indicator */
.teacher-fee-loading-logo{
  display:inline-flex;
  width:28px;
  height:28px;
  margin-right:8px;
  vertical-align:middle;
  align-items:center;
  justify-content:center;
  animation:afisapFeeLogoPulse 1.1s ease-in-out infinite;
}
.teacher-fee-loading-logo img{width:28px;height:28px;object-fit:contain}
@keyframes afisapFeeLogoPulse{0%,100%{transform:scale(.9);opacity:.65}50%{transform:scale(1);opacity:1}}


/* AFISAP Teacher Fees print preparation overlay — surgical UI-only addition */
.teacher-fee-print-loader{position:fixed;inset:0;z-index:2600;background:rgba(241,245,249,.94);display:grid;place-items:center;padding:20px;backdrop-filter:blur(2px)}
.teacher-fee-print-loader-card{width:min(430px,100%);background:#fff;border:1px solid var(--line);border-radius:18px;box-shadow:0 20px 60px #0f3b7028;padding:28px;text-align:center}
.teacher-fee-print-loader-logo{width:92px;height:92px;margin:0 auto 14px;display:grid;place-items:center;animation:afisapFeePrintLogoBreathe 1.05s ease-in-out infinite}
.teacher-fee-print-loader-logo img{width:86px;height:86px;object-fit:contain}
.teacher-fee-print-loader-card>strong{display:block;color:var(--blue);font-size:17px;margin-bottom:16px}
.teacher-fee-print-progress-track{height:12px;border-radius:999px;background:#e6edf5;overflow:hidden;border:1px solid #d8e1eb}
.teacher-fee-print-progress-track span{display:block;height:100%;width:10%;background:var(--blue);border-radius:inherit;transition:width .35s ease}
.teacher-fee-print-progress-text{font-size:22px;font-weight:900;color:var(--blue);margin-top:10px;font-variant-numeric:tabular-nums}
.teacher-fee-print-loader-card small{display:block;color:var(--muted);margin-top:7px;line-height:1.4}
@keyframes afisapFeePrintLogoBreathe{0%,100%{transform:scale(.82);opacity:.45}50%{transform:scale(1.08);opacity:1}}
@media(max-width:560px){.teacher-fee-print-loader-card{padding:22px}.teacher-fee-print-loader-logo{width:78px;height:78px}.teacher-fee-print-loader-logo img{width:72px;height:72px}}

/* Surgical refresh-session restoration: never flash the login screen for a saved teacher session. */
.teacher-session-restore-overlay{display:none;position:fixed;inset:0;z-index:3100;background:rgba(241,245,249,.97);place-items:center;padding:20px}
.teacher-session-restore-card{width:min(390px,100%);background:#fff;border:1px solid var(--line);border-radius:18px;box-shadow:0 20px 60px #0f3b7028;padding:28px;text-align:center}
.teacher-session-restore-card img{display:block;width:88px;height:88px;object-fit:contain;margin:0 auto 14px;animation:afisapFeePrintLogoBreathe 1.05s ease-in-out infinite}
.teacher-session-restore-card strong{display:block;color:var(--blue);font-size:17px;margin-bottom:7px}
.teacher-session-restore-card small{display:block;color:var(--muted)}
.teacher-has-saved-session #teacherLoginScreen{display:none!important}
.teacher-has-saved-session body:not(.teacher-authenticated) .teacher-session-restore-overlay{display:grid}
.teacher-authenticated .teacher-session-restore-overlay,.teacher-logged-out .teacher-session-restore-overlay{display:none}

/* Surgical Results actions + animated Teacher login wallpaper/credit */
.result-edit-btn,.result-delete-btn{white-space:nowrap;padding:7px 11px}
.teacher-login-credit{margin:15px auto 0;width:min(420px,100%);text-align:center;color:#f4f8fd;font-size:13px;line-height:1.65;text-shadow:0 1px 3px #001c35;background:rgba(0,27,54,.35);border:1px solid #ffffff24;border-radius:12px;padding:10px 12px;backdrop-filter:blur(3px)}
.teacher-login-credit a{color:#fff;font-weight:800;text-decoration:none;border-bottom:1px solid #ffffff80}.teacher-login-credit a:hover,.teacher-login-credit a:focus{text-decoration:underline}
@keyframes afisapTeacherLoginWallpaperMove{0%{transform:scale(1.08) translate3d(-1.5%,-1%,0);background-position:42% 50%}50%{transform:scale(1.13) translate3d(1%,.5%,0);background-position:55% 47%}100%{transform:scale(1.09) translate3d(1.8%,-.5%,0);background-position:48% 55%}}
@media (prefers-reduced-motion:reduce){.teacher-login-backdrop{animation:none}}
@media(max-width:560px){.teacher-login-screen{padding:16px}.teacher-login-credit{font-size:12px}.teacher-login-content{width:100%}}
