/* v0.8.2: calm navy / blue interface with soft neutral surfaces and readable contrast. */
:root {
  color-scheme: light;
  --brand: #2463a5;
  --brand-strong: #1d4f86;
  --ink: #253449;
  --muted: #63748a;
  --line: #e1e8f0;
  --bg: #f5f7fb;
  --sidebar: #1c2d45;
  --card: #ffffff;
  --success: #247a57;
  --danger: #b54750;
  --shadow: 0 8px 24px rgba(31, 48, 72, .055);
}

html { background: var(--bg); }
body.portal-page { color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.5; }
.portal-page .sidebar { background: var(--sidebar); color: #e9eff7; }
.portal-page .sidebar-brand { border-bottom-color: rgba(231,239,249,.13); }
.portal-page .sidebar-section-label { color: #a8b7ca; letter-spacing: .13em; }
.portal-page .nav-item { color: #e4ebf5; font-size: 14px; border-radius: 10px; padding: 12px 13px; }
.portal-page .nav-item:hover { background: rgba(255,255,255,.075); }
.portal-page .nav-item.active { background: #2b659f; box-shadow: 0 4px 12px rgba(8,26,49,.2); color: #fff; }
.portal-page .nav-group-toggle { color: #e4ebf5; font-size: 14px; }
.portal-page .topbar { background: rgba(255,255,255,.97); border-bottom-color: var(--line); }
.portal-page .breadcrumbs strong { color: var(--brand); }
.portal-page .connection-chip { font-size:var(--type-secondary); color: var(--muted); }
.portal-page .content-wrap { padding-top: 28px; background: var(--bg); }
.portal-page .school-title-block h1 { color: var(--ink); font-size: clamp(22px, 2vw, 27px); letter-spacing: -.02em; }
.portal-page .school-title-block p, .portal-page .view-heading p { color: var(--muted); font-size: 14px; }
.portal-page .view-heading h2 { font-size: 22px; color: var(--ink); letter-spacing: -.015em; }
.portal-page .surface-card, .portal-page .stat-card { background: var(--card); border-color: var(--line); box-shadow: var(--shadow); }
.portal-page .section-card { border-radius: 14px; }
.portal-page .card-heading h3, .portal-page .section-toolbar h3, .portal-page .platform-next h3 { font-size: 16px; color: #2b3b52; }
.portal-page .card-heading p, .portal-page .section-toolbar p { font-size:var(--type-table); color: var(--muted); line-height: 1.55; }
.portal-page .stat-card { border-radius: 13px; padding: 19px; }
.portal-page .stat-top { color: #65778e; font-size: 13px; }
.portal-page .stat-card>strong { color: var(--ink); }
.portal-page .stat-card small { color: var(--muted); font-size:var(--type-secondary); }
.portal-page .primary-button { background: var(--brand); border-color: var(--brand); box-shadow: 0 3px 9px rgba(36,99,165,.13); border-radius: 9px; font-size: 14px; min-height: 40px; color: #fff; }
.portal-page .primary-button:hover { background: var(--brand-strong); border-color: var(--brand-strong); filter: none; }
.portal-page .outline-button { color: #40536b; border-color: #d6e0eb; border-radius: 9px; font-size: 14px; min-height: 40px; background: #fff; }
.portal-page .outline-button:hover { color: var(--brand-strong); border-color: #9db7d3; background: #f6f9fd; }
.portal-page input, .portal-page select, .portal-page textarea { color: #2b3b50; border-color: #d5dfeb; border-radius: 9px; background: #fff; }
.portal-page input:focus, .portal-page select:focus, .portal-page textarea:focus { border-color: #6d9dcc; box-shadow: 0 0 0 3px rgba(48,111,174,.13); outline: none; }
.portal-page .field-group label, .portal-page .student-filter-row label { color: #4d6078; font-size: 14px; }
.portal-page .field-hint, .portal-page .form-help { color: var(--muted); font-size:var(--type-secondary); line-height: 1.5; }
.portal-page .role-pill, .portal-page .mini-tag { color: #265d91; background: #eaf2fb; }
.portal-page table { white-space: nowrap; }
.portal-page th { color: #5d6f85; font-size:var(--type-table); letter-spacing: .02em; background: #f6f8fc; }
.portal-page td { color: #40536a; font-size:var(--type-table); }
.portal-page td, .portal-page th { padding: 12px 11px; border-bottom-color: #e7edf4; }
.portal-page .empty-cell { color: #74849a; font-size: 13px; }
.portal-page .status-tag { font-size:var(--type-secondary); }
.portal-page .account-status { font-size:var(--type-secondary); }
.portal-page .scope-note, .portal-page .attendance-summary-note { color: #53677f; background: #f0f5fb; border-color: #e0e8f2; font-size:var(--type-secondary); }
.portal-page .dashboard-scan-cta { border-color: #d9e5f2; background: linear-gradient(110deg,#edf4fb 0%,#f8fafd 72%,#eef4fa 100%); box-shadow: 0 5px 18px rgba(34,69,108,.05); }
.portal-page .dashboard-scan-kicker { color: var(--brand); }
.portal-page .dashboard-scan-cta-copy h2 { color: #28415f; }
.portal-page .dashboard-scan-cta-copy p { color: #5c7088; }
.portal-page .dashboard-open-scanner { background: var(--brand); box-shadow: 0 5px 14px rgba(36,99,165,.16); }
.portal-page .dashboard-open-scanner:hover { background: var(--brand-strong); box-shadow: 0 7px 17px rgba(36,99,165,.19); }
.portal-page .dashboard-add-student { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 48px; padding: 11px 18px; border: 1px solid #bfd1e4; border-radius: 10px; background: #fff; color: #285f96; font-weight: 700; font-size: 14px; cursor: pointer; }
.portal-page .dashboard-add-student:hover { background: #f4f8fd; border-color: #8eafd0; }
.portal-page .dashboard-quick-buttons { display: flex; align-items: center; justify-content: flex-end; gap: 12px; flex-wrap: wrap; }
.portal-page .admin-monitoring-card { margin: 18px 0; padding: 18px; }
.portal-page .monitor-date-filter { display: flex; align-items: center; gap: 9px; color: #60738a; font-size:var(--type-table); font-weight: 650; }
.portal-page .monitor-date-filter input { min-height: 40px; padding: 7px 10px; }
.portal-page .monitoring-table { min-width: 680px; }
.portal-page .table-subtext { display: block; color: #75859a; font-size:var(--type-table); margin-top: 3px; }
.portal-page .gate-scan-help { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; margin: 14px 0; padding: 14px; border: 1px solid #dce6f0; border-radius: 12px; background: #f7f9fc; }
.portal-page .gate-scan-help-item { display: grid; gap: 4px; padding: 12px; border-radius: 9px; background: #fff; border: 1px solid #e4eaf2; }
.portal-page .gate-scan-help-item strong { color: #354f6d; font-size: 14px; }
.portal-page .gate-scan-help-item span, .portal-page .gate-scan-help p { color: #687b91; font-size:var(--type-secondary); line-height: 1.5; }
.portal-page .gate-scan-help p { grid-column: 1 / -1; margin: 2px 2px 0; }
.portal-page .student-photo-thumb { width: 52px; height: 52px; object-fit: cover; border-radius: 50%; border: 1px solid #d9e2ed; background: #f0f4f9; display: block; }
.portal-page .student-photo-placeholder { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: #edf2f8; color: #8092a8; }
.portal-page .student-photo-placeholder.no-photo { border: 1px dashed #c6d2df; }
.portal-page .student-qr-preview img { width: 58px; height: 58px; object-fit: contain; display: block; }
.portal-page .student-qr-preview { border: 0; background: transparent; padding: 0; cursor: pointer; }
.portal-page .student-scan-verified-photo { display: block; width: 132px; height: 132px; margin: 12px auto; border: 4px solid #fff; border-radius: 18px; object-fit: cover; background: #edf2f8; box-shadow: 0 5px 17px rgba(35,55,84,.14); }
.portal-page #studentScanNoticePhoto { width: 154px; height: 154px; border-radius: 22px; }
.portal-page .student-scan-verified-photo[hidden] { display: none !important; }
.portal-page .student-scan-no-photo { display: grid; place-items: center; color: #9c5b4c; background: #fbf4ef; font-size: 13px; font-weight: 650; }
.portal-page .photo-flash { animation: photoConfirmPulse 1.05s ease-out 1; }
@keyframes photoConfirmPulse {
  0% { opacity: .55; transform: scale(.94); box-shadow: 0 0 0 0 rgba(36,99,165,.35); }
  45% { opacity: 1; transform: scale(1.025); box-shadow: 0 0 0 11px rgba(36,99,165,.11); }
  100% { opacity: 1; transform: scale(1); box-shadow: 0 5px 17px rgba(35,55,84,.14); }
}
.portal-page .gate-photo-verification { display: flex; align-items: flex-start; justify-content: center; gap: 9px; max-width: 460px; margin: 14px auto; padding: 12px 14px; border: 1px solid #dce6f0; border-radius: 10px; background: #f6f9fd; color: #405a78; font-size: 13px; line-height: 1.45; }
.portal-page .gate-photo-verification input { width: 18px; height: 18px; flex: 0 0 auto; margin: 0; }
.portal-page .gate-photo-warning { margin: 12px auto; padding: 12px; border-radius: 10px; color: #875c31; background: #fbf5e9; font-size: 13px; }
.portal-page .student-scan-notice-dialog { border-color: #b8cde1; }
.portal-page .student-scan-notice-dialog h3 { color: #2b405b; }
.portal-page .student-scan-success-icon { background: #e9f2fb; color: var(--brand); }
.portal-page .student-scan-success-kicker { color: var(--brand); }
.portal-page .student-scan-notice-copy, .portal-page .student-scan-notice-meta { color: #687a90; }
.portal-page .student-scan-notice-name { color: #2f4765; }
.portal-page button:focus-visible, .portal-page a:focus-visible, .portal-page summary:focus-visible { outline: 3px solid rgba(36,99,165,.34); outline-offset: 2px; }

body.login-page { background: #f5f7fb; color: var(--ink); }
.login-page .login-mode { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px; }
.login-page .mode-tab { min-width: 0; padding-inline: 5px; line-height: 1.25; }
.login-page .mode-tab:focus-visible { outline: 3px solid rgba(36,99,165,.34); outline-offset: 2px; position: relative; z-index: 1; }
.login-page .login-panel { background: #f5f7fb; }
.login-page .login-panel-inner { border-color: #e1e8f0; box-shadow: 0 8px 26px rgba(31,48,72,.06); }
.login-page .login-art { background: linear-gradient(145deg, #1c2d45 0%, #2f659b 100%); }
.login-page .primary-button { background: var(--brand); border-color: var(--brand); }
.login-page .primary-button:hover { background: var(--brand-strong); }
.login-page input, .login-page select { border-color: #d5dfeb; border-radius: 9px; }
.login-page input:focus, .login-page select:focus { border-color: #6d9dcc; box-shadow: 0 0 0 3px rgba(48,111,174,.13); outline: none; }
.login-page a:focus-visible, .login-page button:focus-visible { outline: 3px solid rgba(36,99,165,.34); outline-offset: 2px; }

body.attendance-desk { background: #f5f7fb; color: var(--ink); }
body.attendance-desk .topbar { background: #1c2d45; }
body.attendance-desk .summary article, body.attendance-desk .panel { border-color: var(--line); box-shadow: var(--shadow); }
body.attendance-desk .summary article { background: #fff; }
body.attendance-desk button, body.attendance-desk .entry-row button { background: var(--brand); }
body.attendance-desk .secondary, body.attendance-desk .tab { background: #eaf1f9; color: #315e8d; }
body.attendance-desk .tab.active { background: var(--brand); color: #fff; }
body.attendance-desk input, body.attendance-desk select { border-color: #d5dfeb; }
body.attendance-desk input:focus, body.attendance-desk select:focus { border-color: #6d9dcc; box-shadow: 0 0 0 3px rgba(48,111,174,.13); outline: none; }
body.attendance-desk .feedback { background: #eff4fa; color: #53677f !important; }

.portal-page .gate-scan-type { display: grid; gap: 6px; align-content: start; margin: 0; color: #4d6078; font-size: 13px; font-weight: 700; }
.portal-page .gate-scan-type select { min-height: 42px; background: #fff; }
.portal-page .gate-scan-help { align-items: stretch; }

@media (max-width: 760px) {
  .portal-page .dashboard-quick-buttons { display: grid; grid-template-columns: 1fr; width: 100%; }
  .portal-page .dashboard-add-student, .portal-page .dashboard-open-scanner { width: 100%; min-width: 0; }
  .portal-page .gate-scan-help { grid-template-columns: 1fr; }
  .portal-page .gate-scan-help p { grid-column: auto; }
  .portal-page .section-toolbar { align-items: flex-start; flex-direction: column; gap: 12px; }
  .portal-page .monitor-date-filter { width: 100%; justify-content: space-between; }
  .portal-page .monitor-date-filter input { flex: 1; min-width: 0; }
}
@media (max-width: 420px) {
  .login-page .login-mode { gap: 1px; padding: 3px; }
  .login-page .mode-tab { padding: 10px 3px; font-size:var(--type-table); }
}
@media (prefers-reduced-motion: reduce) {
  .portal-page .photo-flash { animation: none; }
  .portal-page *, .portal-page *::before, .portal-page *::after,
  .login-page *, .login-page *::before, .login-page *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}

/* Clear, readable photo states in learner tables. */
.portal-page .student-photo-placeholder.no-photo {
  width: 58px;
  min-height: 48px;
  height: auto;
  padding: 4px;
  box-sizing: border-box;
  border-radius: 10px;
  color: #667b94;
  background: #f2f5f9;
  font-size:var(--type-table);
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  overflow-wrap: anywhere;
}
.portal-page .student-photo-thumb { width: 58px; height: 58px; }
.portal-page .brand-mark img, .portal-page .school-emblem img { width:100%; height:100%; object-fit:contain; border-radius:inherit; }
.portal-page .school-logo-preview { width:112px; height:112px; display:grid; place-items:center; border:1px solid var(--line); border-radius:18px; background:#f1f5f9; color:var(--brand); font-size:36px; font-weight:800; overflow:hidden; }
.portal-page .school-logo-preview img { width:100%; height:100%; object-fit:contain; }
.portal-page .school-logo-field { align-items:start; }
.portal-page .school-logo-field input[type=file] { width:min(380px,100%); margin-top:8px; }
.portal-page .cloud-sync-enable-row { margin-top:6px; padding:13px 15px; border:1px solid var(--line); border-radius:10px; background:#f8fafc; }
.portal-page .checkbox-label { display:flex; align-items:center; gap:10px; font-weight:700; color:#344760; }
.portal-page .checkbox-label input { width:18px; height:18px; }
.portal-page .cloud-sync-metrics { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; margin-top:16px; }
.portal-page .cloud-sync-metrics article { display:grid; gap:5px; padding:14px; border:1px solid var(--line); border-radius:10px; background:#fff; }
.portal-page .cloud-sync-metrics span { color:var(--muted); font-size:var(--type-secondary); }
.portal-page .cloud-sync-metrics strong { color:var(--ink); font-size:15px; }
.account-profile-dialog { width:min(540px,calc(100vw - 28px)); max-height:min(90dvh,860px); overflow:auto; border:1px solid var(--line); border-radius:18px; padding:24px; color:var(--ink); box-shadow:0 24px 70px rgba(0,0,0,.24); }
.account-profile-dialog::backdrop { background:rgba(12,25,40,.62); }
.account-profile-dialog .dialog-header { display:flex; justify-content:space-between; align-items:flex-start; gap:16px; margin-bottom:20px; }
.account-profile-dialog h2 { margin:4px 0; font-size:24px; }
.account-profile-dialog h3 { margin:22px 0 12px; font-size:17px; }
.account-profile-dialog .dialog-close { width:38px; height:38px; border:0; border-radius:9px; background:#f1f5f9; font-size:24px; color:#475569; }
.account-profile-dialog .account-password-form { border-top:1px solid var(--line); margin-top:20px; padding-top:2px; }
.platform-school-form { grid-template-columns:repeat(2,minmax(0,1fr)); }
.platform-school-form .form-actions { grid-column:1 / -1; }
@media(max-width:640px){.portal-page .cloud-sync-metrics{grid-template-columns:1fr}.platform-school-form{grid-template-columns:1fr}.platform-school-form .form-actions{grid-column:auto}.account-profile-dialog{padding:18px}}

@media(max-width:700px){
 #studentRosterTable{display:block;width:100%}
 #studentRosterTable thead{display:none}
 #studentRosterTable tbody{display:block;width:100%}
 #studentRosterTable tr{display:block;width:100%;margin:0 0 12px;padding:8px;border:1px solid #e2e8f0;border-radius:12px;background:#fff;box-shadow:0 2px 8px rgba(15,23,42,.04)}
 #studentRosterTable td{display:flex;align-items:center;justify-content:space-between;gap:10px;width:100%;padding:8px 6px;border:0;border-bottom:1px solid #f1f5f9;text-align:right;white-space:normal}
 #studentRosterTable td:last-child{border-bottom:0}
 #studentRosterTable td::before{content:attr(data-label);flex:0 0 34%;color:#64748b;font-size:var(--type-table);font-weight:700;text-align:left}
 #studentRosterTable td.empty-cell{display:block;text-align:center}
 #studentRosterTable td.empty-cell::before{content:none}
 #studentRosterTable .student-row-actions{justify-content:flex-end;flex-wrap:wrap}
}
/* Bulk timetable assignment toolbar. */
#periodBulkToolbar{margin:12px 0}
#periodBulkToolbar select{min-width:220px}
@media(max-width:700px){#periodBulkToolbar{position:sticky;bottom:8px;z-index:5;background:#fff;padding:10px;border-radius:12px;box-shadow:0 4px 16px rgba(15,23,42,.12)}#periodBulkToolbar select{min-width:150px;max-width:100%}}
/* Student import preview and batch management dialogs. */
#studentImportModal .student-edit-dialog,#studentBatchModal .student-edit-dialog{width:min(980px,96vw);max-height:90vh;overflow:auto}
#studentImportPreviewRows td{vertical-align:top;white-space:normal;max-width:280px}
.student-bulk-actions{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.student-bulk-actions select{max-width:180px}
@media(max-width:700px){.student-bulk-actions{position:sticky;bottom:6px;z-index:6;background:#fff;padding:10px;border-radius:12px;box-shadow:0 4px 16px rgba(15,23,42,.12)}#studentImportModal .student-edit-dialog,#studentBatchModal .student-edit-dialog{width:100%;max-height:94dvh;padding:16px}}
/* Final navigation and clarity overrides (loaded after responsive styles). */
.sidebar{overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin}
.nav-group{min-width:0}.nav-group-toggle{min-height:44px}.nav-submenu .nav-item{min-height:44px;padding-left:17px}
.nav-item:focus-visible,.nav-group-toggle:focus-visible{outline:3px solid #7dd3fc;outline-offset:2px}
.sidebar-bottom{position:sticky;bottom:0;background:var(--sidebar);padding-top:8px}
.connection-chip.local-only{padding:7px 10px;border:1px solid #f3d7a4;border-radius:999px;background:#fff8e8;color:#80540a;font-size:var(--type-secondary);font-weight:700;gap:8px;white-space:nowrap}
.connection-chip.local-only i{background:#d97706;box-shadow:0 0 0 3px rgba(217,119,6,.12)}
.student-roster-tools .student-bulk-actions{position:sticky;bottom:8px;z-index:5;padding:12px;border:1px solid #d8e5ef;border-radius:12px;background:rgba(255,255,255,.96);box-shadow:0 8px 24px rgba(15,23,42,.09)}
@media(max-width:700px){
 .sidebar{position:fixed;z-index:100;left:0;top:0;width:min(300px,86vw);height:100dvh;transform:translateX(-105%);transition:transform .2s ease}
 .sidebar.open{transform:translateX(0)}.topbar{padding:0 14px}.content-wrap{padding:18px 14px}
 .connection-chip.local-only{font-size:0;padding:9px}.connection-chip.local-only span{font-size:var(--type-secondary)}
}

.connection-chip.sync-connected{border-color:#b7e4c7;background:#ecfdf3;color:#176b3a}
.connection-chip.sync-connected i{background:#16a34a;box-shadow:0 0 0 3px rgba(22,163,74,.12)}
.connection-chip.sync-disconnected{border-color:#f3d7a4;background:#fff8e8;color:#80540a}
.connection-chip.sync-disconnected i{background:#d97706;box-shadow:0 0 0 3px rgba(217,119,6,.12)}

#staffBulkDepartmentToolbar{margin:12px 0}
#staffBulkDepartmentToolbar select{min-width:220px}
@media(max-width:700px){#staffBulkDepartmentToolbar{position:sticky;bottom:8px;z-index:5;background:#fff;padding:10px;border-radius:12px;box-shadow:0 4px 16px rgba(15,23,42,.12)}#staffBulkDepartmentToolbar select{min-width:150px;max-width:100%}}

/* Shared, readable dashboard and modal language across every school role. */
.portal-page .stat-top{font-size:13px;line-height:1.4}
.portal-page .stat-card>strong{font-size:32px}
.portal-page .stat-card small{font-size:var(--type-secondary)}
.portal-page .card-heading h3,.portal-page .section-toolbar h3{font-size:15px;line-height:1.35}
.portal-page .card-heading p,.portal-page .section-toolbar p{font-size:var(--type-table);line-height:1.5;color:#718096}
.portal-page th{font-size:var(--type-table);letter-spacing:.02em}
.portal-page td{font-size:var(--type-table);line-height:1.45}
.portal-page .nav-label{font-size:var(--type-table)}
.portal-page .page-heading h2{font-size:24px;line-height:1.2}
.portal-page .page-heading p{font-size:13px;line-height:1.5;color:#718096}
.student-scan-setup-overlay,.student-scan-notice-overlay,.student-qr-preview-overlay{
 position:fixed;inset:0;z-index:1000;display:grid;place-items:center;padding:18px;
 background:rgba(15,23,42,.52);backdrop-filter:blur(3px)
}
.student-scan-setup-dialog,.student-scan-notice-dialog,.student-qr-preview-dialog{
 width:min(680px,100%);max-height:90dvh;overflow:auto;background:#fff;border:1px solid #e5ebf1;
 border-radius:16px;padding:22px;box-shadow:0 24px 70px rgba(15,23,42,.22)
}
.student-edit-overlay{background:rgba(15,23,42,.52);backdrop-filter:blur(3px);padding:18px}
.student-edit-dialog{border:1px solid #e5ebf1;border-radius:16px;box-shadow:0 24px 70px rgba(15,23,42,.22)}
.portal-page input:not([type=checkbox]):not([type=radio]),.portal-page select,.portal-page textarea{
 min-height:42px;border-radius:9px;font-size:var(--type-table)
}
.portal-page button{min-height:40px;border-radius:9px;font-size:var(--type-table);font-weight:650}
.portal-page .empty-cell{font-size:13px;padding:28px 12px}
@media(max-width:700px){
 .portal-page .page-heading h2{font-size:21px}
 .portal-page .stat-card{min-height:112px;padding:14px}
 .portal-page .stat-card>strong{font-size:27px}
 .portal-page .stat-top{font-size:var(--type-secondary)}
 .student-scan-setup-dialog,.student-scan-notice-dialog,.student-qr-preview-dialog{width:100%;max-height:94dvh;padding:16px;border-radius:14px}
}

@media(max-width:700px){
 .teacher-monitor-scroll{overflow:visible}
 #teacherMonitorTable,#staffAccountsTable{display:block;width:100%}
 #teacherMonitorTable thead,#staffAccountsTable thead{display:none}
 #teacherMonitorTable tbody,#staffAccountsTable tbody{display:block;width:100%}
 #teacherMonitorTable tr,#staffAccountsTable tr{display:block;width:100%;margin:0 0 12px;padding:8px;border:1px solid #e2e8f0;border-radius:12px;background:#fff}
 #teacherMonitorTable td,#staffAccountsTable td{display:flex;align-items:center;justify-content:space-between;gap:10px;width:100%;padding:8px 6px;border:0;border-bottom:1px solid #f1f5f9;text-align:right;white-space:normal}
 #teacherMonitorTable td::before,#staffAccountsTable td::before{content:attr(data-label);flex:0 0 34%;color:#64748b;font-size:var(--type-table);font-weight:700;text-align:left}
 #teacherMonitorTable td.empty-cell::before,#staffAccountsTable td.empty-cell::before{content:none}
 #teacherMonitorTable .teacher-scope-list{justify-content:flex-end}
}


/* Mobile teacher directory: reset the desktop table width before rendering
   each teacher as a readable two-column information card. */
@media (max-width: 700px) {
  #teachersView .teacher-monitor-scroll { overflow: visible; }
  #teachersView #teacherMonitorTable {
    display: block;
    width: 100%;
    min-width: 0 !important;
    table-layout: auto !important;
  }
  #teachersView #teacherMonitorTable thead { display: none; }
  #teachersView #teacherMonitorTable tbody { display: block; width: 100%; min-width: 0; }
  #teachersView #teacherMonitorTable tbody tr {
    display: block;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    margin: 0 0 12px;
    padding: 8px 12px;
    border: 1px solid #e0e8f1;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 3px 12px rgba(31,48,72,.045);
  }
  #teachersView #teacherMonitorTable tbody td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box;
    padding: 11px 2px;
    border: 0;
    border-bottom: 1px solid #edf1f5;
    text-align: left;
    white-space: normal !important;
    overflow-wrap: break-word;
    word-break: normal;
    line-height: 1.45;
  }
  #teachersView #teacherMonitorTable tbody td:last-child { border-bottom: 0; }
  #teachersView #teacherMonitorTable tbody td::before {
    content: attr(data-label);
    flex: 0 0 38%;
    max-width: 38%;
    color: #64748b;
    font-size:var(--type-table);
    font-weight: 700;
    line-height: 1.4;
    text-align: left;
    overflow-wrap: normal;
    word-break: normal;
  }
  #teachersView #teacherMonitorTable .teacher-cell-value {
    display: flex;
    flex: 1 1 62%;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    min-width: 0;
    max-width: 62%;
    text-align: right;
    overflow-wrap: break-word;
    word-break: normal;
  }
  #teachersView #teacherMonitorTable .teacher-identity strong {
    max-width: 100%;
    color: #243b53;
    font-size: 15px;
    line-height: 1.35;
    overflow-wrap: break-word;
    word-break: normal;
  }
  #teachersView #teacherMonitorTable .teacher-cell-value .table-subtext {
    max-width: 100%;
    margin: 0;
    color: #718296;
    font-size:var(--type-table);
    line-height: 1.35;
    overflow-wrap: break-word;
    word-break: normal;
  }
  #teachersView #teacherMonitorTable .teacher-scope-list,
  #teachersView #teacherMonitorTable .teacher-assignment-summary {
    justify-content: flex-end;
    max-width: 100%;
  }
  #teachersView #teacherMonitorTable .action-row {
    justify-content: flex-end;
    max-width: 100%;
  }
  #teachersView #teacherMonitorTable td.empty-cell {
    display: block;
    text-align: center;
  }
  #teachersView #teacherMonitorTable td.empty-cell::before { content: none; }
}

/* Scanner failures use a focused, accessible modal instead of a transient toast. */
.student-scan-error-overlay {
  position: fixed;
  inset: 0;
  z-index: 14000;
  display: grid;
  place-items: center;
  padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right))
    max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  background: rgba(15,23,42,.58);
  backdrop-filter: blur(4px);
}
.student-scan-error-overlay[hidden] { display: none !important; }
.student-scan-error-dialog {
  width: min(440px, 100%);
  box-sizing: border-box;
  padding: 25px;
  border: 1px solid #f0d5d7;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15,23,42,.28);
  text-align: center;
}
.student-scan-error-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: #fff0f0;
  color: #b42336;
  font-size: 27px;
  font-weight: 800;
}
.student-scan-error-kicker {
  margin: 0 0 6px;
  color: #b42336;
  font-size:var(--type-secondary);
  font-weight: 800;
  letter-spacing: .12em;
}
.student-scan-error-dialog h3 {
  margin: 0;
  color: #293b52;
  font-size: 20px;
  line-height: 1.3;
}
.student-scan-error-message {
  margin: 12px 0 20px;
  color: #63748a;
  font-size: 14px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.student-scan-error-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 9px;
}
.student-scan-error-actions button { min-height: 44px; }
@media (max-width: 480px) {
  .student-scan-error-dialog { padding: 21px 17px; border-radius: 15px; }
  .student-scan-error-actions { flex-direction: column-reverse; }
  .student-scan-error-actions button { width: 100%; }
}

/* Guided timetable editor and school identity navigation. */
.portal-page .nav-item.active { background: var(--nav-active, var(--brand-strong)); border-left-color: var(--brand); }
.portal-page .timetable-settings-grid { grid-template-columns: minmax(210px,1fr) minmax(320px,1.6fr); align-items:start; }
.portal-page #calendarExceptionForm { grid-column: 1 / -1; }
.template-block-row { display:grid; grid-template-columns:1fr 1fr; gap:12px; padding:14px; margin:0 0 14px; border:1px solid var(--line); border-radius:12px; background:var(--bg); min-width:0; }
.template-block-row legend { font-weight:700; padding:0 5px; color:var(--brand-strong); }
.template-block-row label { min-width:0; }
.template-block-row input,.template-block-row select { width:100%; min-height:44px; box-sizing:border-box; }
.template-block-row label:first-of-type { grid-column:1 / -1; }
.portal-page .weekly-timetable-board { grid-template-columns:repeat(var(--visible-days,5),minmax(210px,1fr)); overflow-x:auto; scroll-snap-type:x proximity; padding:8px 2px 18px; }
.portal-page .weekly-day-column { scroll-snap-align:start; background:var(--bg); min-height:200px; }
.portal-page .weekly-day-column>header { flex-direction:column; align-items:flex-start; gap:4px; padding:10px; border-bottom:3px solid var(--brand); }
.portal-page .weekly-day-column>header strong { font-size:16px; }
.portal-page .weekly-day-column>header span { font-size:var(--type-secondary); }
.portal-page .weekly-schedule-card { padding:14px; margin-bottom:12px; background:#fff; border-left:3px solid var(--brand); }
.portal-page .weekly-card-time { font-size:14px; font-weight:700; color:var(--brand-strong); }
.portal-page .weekly-schedule-card.is-unassigned { border-left-color:#b77913; }
@media(max-width:800px) { .portal-page .timetable-settings-grid { grid-template-columns:1fr; } .portal-page .weekly-timetable-board { grid-template-columns:repeat(var(--visible-days,5),minmax(260px,80vw)); } }
