/*
 * YENTUMI Gradebook Enterprise — Unified Dark Theme System
 * Release 2026.08.28.048 / Step 5.38
 *
 * Light remains the product default. These rules activate only after a user
 * explicitly chooses Dark. Staff, Parent/Learner and Platform Administration
 * share the same semantic surface, text, border, control and state language.
 */

/* --------------------------------------------------------------------------
   1. Platform-wide semantic dark tokens
   -------------------------------------------------------------------------- */
html[data-theme="dark"]{
  color-scheme:dark;
  --gb-dark-bg:#081522;
  --gb-dark-bg-deep:#06111d;
  --gb-dark-surface:#0f2033;
  --gb-dark-surface-raised:#14283e;
  --gb-dark-surface-soft:#192f47;
  --gb-dark-surface-hover:#1d3651;
  --gb-dark-border:#2b455f;
  --gb-dark-border-strong:#3b5b78;
  --gb-dark-text:#f3f7fb;
  --gb-dark-text-secondary:#cad6e3;
  --gb-dark-muted:#9fb0c2;
  --gb-dark-subtle:#8195aa;
  --gb-dark-placeholder:#7e91a6;
  --gb-dark-blue:#5f8ff7;
  --gb-dark-blue-strong:#83a8ff;
  --gb-dark-blue-soft:rgba(72,126,245,.18);
  --gb-dark-success:#56ca8a;
  --gb-dark-success-soft:rgba(48,181,111,.16);
  --gb-dark-warning:#f0b85f;
  --gb-dark-warning-soft:rgba(222,153,49,.17);
  --gb-dark-danger:#ff7b72;
  --gb-dark-danger-soft:rgba(239,68,68,.16);
  --gb-dark-info:#70b7ff;
  --gb-dark-info-soft:rgba(70,163,255,.16);
  --gb-dark-shadow:0 18px 44px rgba(0,0,0,.24);
  --gb-dark-shadow-soft:0 8px 24px rgba(0,0,0,.18);
  --gb-dark-focus:0 0 0 3px rgba(95,143,247,.28);
}

/* Authenticated school + platform portals consume the same semantic tokens. */
html[data-theme="dark"] body.enterprise-shell-v3{
  --gb-bg:var(--gb-dark-bg)!important;
  --gb-surface:var(--gb-dark-surface)!important;
  --gb-surface-raised:var(--gb-dark-surface-raised)!important;
  --gb-surface-soft:var(--gb-dark-surface-soft)!important;
  --gb-line:var(--gb-dark-border)!important;
  --gb-line-strong:var(--gb-dark-border-strong)!important;
  --gb-text:var(--gb-dark-text)!important;
  --gb-muted:var(--gb-dark-muted)!important;
  --gb-subtle:var(--gb-dark-subtle)!important;
  --gb-brand-soft:color-mix(in srgb,var(--school-accent,#2563eb) 17%,var(--gb-dark-surface))!important;
  --gb-brand-border:color-mix(in srgb,var(--school-accent,#2563eb) 38%,var(--gb-dark-border))!important;
  --gb-brand-wash:color-mix(in srgb,var(--school-accent,#2563eb) 9%,var(--gb-dark-bg))!important;
  --gb-brand-strong:color-mix(in srgb,var(--school-accent,#2563eb) 70%,#fff)!important;
  --gb-shadow-sm:var(--gb-dark-shadow-soft)!important;
  --gb-shadow-md:var(--gb-dark-shadow)!important;
  --gb-shadow-hover:0 20px 48px rgba(0,0,0,.30)!important;
  background:var(--gb-dark-bg)!important;
  color:var(--gb-dark-text)!important;
}

/* Parent portal receives the same hierarchy while retaining family blue. */
html[data-theme="dark"] body.parent-family-app{
  --pf-bg:var(--gb-dark-bg)!important;
  --pf-surface:var(--gb-dark-surface)!important;
  --pf-soft:var(--gb-dark-surface-raised)!important;
  --pf-border:var(--gb-dark-border)!important;
  --pf-text:var(--gb-dark-text)!important;
  --pf-muted:var(--gb-dark-muted)!important;
  --pf-blue:var(--gb-dark-blue)!important;
  --pf-blue-soft:var(--gb-dark-blue-soft)!important;
  --pf-green:var(--gb-dark-success)!important;
  --pf-green-soft:var(--gb-dark-success-soft)!important;
  --pf-amber:var(--gb-dark-warning)!important;
  --pf-amber-soft:var(--gb-dark-warning-soft)!important;
  --pf-shadow:var(--gb-dark-shadow-soft)!important;
  background:linear-gradient(180deg,var(--gb-dark-bg) 0%,var(--gb-dark-bg-deep) 100%)!important;
  color:var(--gb-dark-text)!important;
}

/* --------------------------------------------------------------------------
   2. Universal portal shell, typography and navigation
   -------------------------------------------------------------------------- */
html[data-theme="dark"] body.enterprise-shell-v3 :where(.shell,.page-content,.dashboard-main,.app-main),
html[data-theme="dark"] body.pwa-auth-page{
  color:var(--gb-dark-text);
}
html[data-theme="dark"] body.enterprise-shell-v3 .app-header{
  background:rgba(10,25,41,.98)!important;
  border-bottom:1px solid var(--gb-dark-border)!important;
  box-shadow:0 8px 26px rgba(0,0,0,.16)!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 .app-sidebar{
  border-right-color:color-mix(in srgb,var(--school-accent,#2563eb) 18%,#243d56)!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 :where(.enterprise-user-summary,.mobile-sidebar-toggle,.pwa-refresh-control){
  color:var(--gb-dark-text)!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 :where(.enterprise-user-summary:hover,.enterprise-user-menu[open]>.enterprise-user-summary){
  background:var(--gb-dark-surface-raised)!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 :where(.enterprise-user-avatar,.enterprise-school-mark,.pwa-refresh-control){
  border-color:var(--gb-dark-border)!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 .enterprise-user-popover{
  background:var(--gb-dark-surface)!important;
  border-color:var(--gb-dark-border)!important;
  box-shadow:0 24px 64px rgba(0,0,0,.42)!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 .enterprise-user-action{
  color:var(--gb-dark-text)!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 .enterprise-user-action:hover{
  background:var(--gb-dark-surface-hover)!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 .enterprise-user-action small{
  color:var(--gb-dark-muted)!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 :where(h1,h2,h3,h4,h5,strong,b,legend):not(.premium-report *):not(.report-document *){color:var(--gb-dark-text)}
html[data-theme="dark"] body.enterprise-shell-v3 :where(.muted,.hint,small,.page-head p,.section-heading p):not(.premium-report *):not(.report-document *){color:var(--gb-dark-muted)}

/* Installed bottom navigation: identical treatment for staff and platform admin. */
html[data-theme="dark"].gradebook-installed-app.gradebook-phone-app .pwa-app-dock{
  background:rgba(11,27,44,.97)!important;
  border-color:var(--gb-dark-border)!important;
  box-shadow:0 -10px 30px rgba(0,0,0,.26)!important;
}
html[data-theme="dark"].gradebook-installed-app.gradebook-phone-app .pwa-dock-item{color:var(--gb-dark-muted)!important}
html[data-theme="dark"].gradebook-installed-app.gradebook-phone-app .pwa-dock-item.active,
html[data-theme="dark"].gradebook-installed-app.gradebook-phone-app .pwa-dock-item:hover{
  background:var(--gb-dark-blue-soft)!important;
  color:#b8ceff!important;
}

/* --------------------------------------------------------------------------
   3. Common cards / panels / tables / tabs
   -------------------------------------------------------------------------- */
html[data-theme="dark"] body.enterprise-shell-v3 :where(
  .panel,.confirm-card,.stats article,.settings-card,.teacher-list-card,
  .teacher-assignment-summary,.assignment-overview-filters,.enterprise-access-health,
  .enterprise-access-summary article,.enterprise-role-list article,
  .enterprise-permission-picker section,.enterprise-permission-catalogue>section,
  .enterprise-activity-list article,.account-profile-card,.profile-save-bar,
  .gradebook-mobile-sheet,.result-context-panel,.result-entry-panel,.result-import-panel
){
  background:var(--gb-dark-surface)!important;
  border-color:var(--gb-dark-border)!important;
  color:var(--gb-dark-text)!important;
  box-shadow:var(--gb-dark-shadow-soft)!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 :where(
  .teacher-mobile-kpis article,.teacher-mobile-actions>a,.teacher-today-list article,
  .teacher-day-card,.teacher-notification-state,.mobile-lesson-progress,
  .lesson-development-editor tr,.mobile-lesson-step-actions,.academic-day-banner,
  .cc-card,.cc-kpi,.cc-search-shell,.student360-tabs,.academic-ops-tabs
){
  background:var(--gb-dark-surface)!important;
  border-color:var(--gb-dark-border)!important;
  color:var(--gb-dark-text)!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 table:not(.premium-report *):not(.report-document *){color:var(--gb-dark-text)!important}
html[data-theme="dark"] body.enterprise-shell-v3 th:not(.premium-report *):not(.report-document *){
  background:var(--gb-dark-surface-raised)!important;
  color:var(--gb-dark-text-secondary)!important;
  border-color:var(--gb-dark-border)!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 td:not(.premium-report *):not(.report-document *){border-color:var(--gb-dark-border)!important}
html[data-theme="dark"] body.enterprise-shell-v3 table:not(.premium-report *):not(.report-document *) tbody tr:hover{background:var(--gb-dark-surface-raised)!important}
html[data-theme="dark"] body.enterprise-shell-v3 :where(.result-mode-tabs,.result-tabs,.settings-subnav,.student360-tabs,.academic-ops-tabs,.enterprise-access-tabs,.enterprise-platform-tabs){
  background:var(--gb-dark-bg-deep)!important;
  border-color:var(--gb-dark-border)!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 :where(.result-mode-tabs a,.result-tabs a,.settings-subnav a,.student360-tabs a,.academic-ops-tabs a,.enterprise-access-tabs a,.enterprise-platform-tabs a){
  color:var(--gb-dark-muted)!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 :where(.result-mode-tabs a.active,.result-tabs a.active,.settings-subnav a.active,.student360-tabs a.active,.academic-ops-tabs a.active,.enterprise-access-tabs a.active,.enterprise-platform-tabs a.active){
  background:var(--gb-dark-surface-raised)!important;
  color:color-mix(in srgb,var(--school-accent,#5f8ff7) 65%,#fff)!important;
  border-color:var(--gb-brand-border)!important;
  box-shadow:inset 0 0 0 1px var(--gb-brand-border)!important;
}

/* --------------------------------------------------------------------------
   4. Forms: no white islands, readable placeholders and disabled controls
   -------------------------------------------------------------------------- */
html[data-theme="dark"] body.enterprise-shell-v3 :where(input:not([type="checkbox"]):not([type="radio"]),select,textarea),
html[data-theme="dark"] body.parent-family-app :where(input:not([type="checkbox"]):not([type="radio"]),select,textarea),
html[data-theme="dark"] body.pwa-auth-page :where(input:not([type="checkbox"]):not([type="radio"]),select,textarea){
  background:var(--gb-dark-surface-raised)!important;
  color:var(--gb-dark-text)!important;
  border-color:var(--gb-dark-border-strong)!important;
  caret-color:var(--gb-dark-blue-strong)!important;
  box-shadow:none!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 :where(input,select,textarea):focus,
html[data-theme="dark"] body.parent-family-app :where(input,select,textarea):focus,
html[data-theme="dark"] body.pwa-auth-page :where(input,select,textarea):focus{
  border-color:var(--gb-dark-blue)!important;
  box-shadow:var(--gb-dark-focus)!important;
  outline:none!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 :where(input,textarea)::placeholder,
html[data-theme="dark"] body.parent-family-app :where(input,textarea)::placeholder,
html[data-theme="dark"] body.pwa-auth-page :where(input,textarea)::placeholder{
  color:var(--gb-dark-placeholder)!important;
  opacity:1!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 :where(input,select,textarea):disabled,
html[data-theme="dark"] body.enterprise-shell-v3 :where(input,select,textarea)[readonly],
html[data-theme="dark"] body.parent-family-app :where(input,select,textarea):disabled{
  background:#122338!important;
  color:#98aabd!important;
  border-color:#294158!important;
  opacity:1!important;
  -webkit-text-fill-color:#98aabd!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 label,
html[data-theme="dark"] body.parent-family-app label{color:var(--gb-dark-text-secondary)!important}

/* Native mobile select trigger follows exactly the same control language. */
html[data-theme="dark"] body.enterprise-shell-v3 :where(.gb-mobile-select-trigger,.gradebook-mobile-select-trigger){
  background:var(--gb-dark-surface-raised)!important;
  color:var(--gb-dark-text)!important;
  border-color:var(--gb-dark-border-strong)!important;
}

/* --------------------------------------------------------------------------
   5. Buttons and semantic states
   -------------------------------------------------------------------------- */
html[data-theme="dark"] body.enterprise-shell-v3 :where(button,.button):not(.danger):not(.secondary):not(.ghost),
html[data-theme="dark"] body.parent-family-app :where(button,.button).primary{
  color:#fff!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 .secondary{
  background:var(--gb-dark-surface-raised)!important;
  color:var(--gb-dark-text)!important;
  border:1px solid var(--gb-dark-border-strong)!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 .ghost{
  background:var(--gb-dark-blue-soft)!important;
  color:#b7ceff!important;
  border-color:color-mix(in srgb,var(--school-accent,#5f8ff7) 35%,var(--gb-dark-border))!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 :where(button,.button):disabled,
html[data-theme="dark"] body.enterprise-shell-v3 .button.disabled{
  background:#203247!important;
  border-color:#2b435b!important;
  color:#8799ac!important;
  opacity:1!important;
  box-shadow:none!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 .danger,
html[data-theme="dark"] body.enterprise-shell-v3 button.danger{
  background:#c9342d!important;
  border-color:#dc5149!important;
  color:#fff!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 :where(.alert.success,.badge.active,.badge.approved){background:var(--gb-dark-success-soft)!important;color:#8ee2b3!important;border-color:rgba(86,202,138,.35)!important}
html[data-theme="dark"] body.enterprise-shell-v3 :where(.alert.warning,.badge.warning,.badge.pending){background:var(--gb-dark-warning-soft)!important;color:#ffd392!important;border-color:rgba(240,184,95,.36)!important}
html[data-theme="dark"] body.enterprise-shell-v3 :where(.alert.danger,.badge.danger,.badge.rejected,.badge.inactive){background:var(--gb-dark-danger-soft)!important;color:#ffaaa4!important;border-color:rgba(255,123,114,.35)!important}
html[data-theme="dark"] body.enterprise-shell-v3 :where(.alert.info,.hint,.info-card){border-color:var(--gb-dark-border)!important}

/* --------------------------------------------------------------------------
   6. Teacher results — direct correction of the screenshots' mixed surfaces
   -------------------------------------------------------------------------- */
html[data-theme="dark"] body.enterprise-shell-v3 .result-context-head h2,
html[data-theme="dark"] body.enterprise-shell-v3 .result-entry-intro h2{color:var(--gb-dark-text)!important}
html[data-theme="dark"] body.enterprise-shell-v3 :where(.result-context-head p,.result-entry-intro p,.result-submission-status>span:first-child){color:var(--gb-dark-muted)!important}
html[data-theme="dark"] body.enterprise-shell-v3 .result-lock-notice{
  background:var(--gb-dark-warning-soft)!important;
  color:#ffd392!important;
  border-color:#b67b25!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 .result-formula span,
html[data-theme="dark"] body.enterprise-shell-v3 .result-mobile-toolbar{
  background:var(--gb-dark-surface-raised)!important;
  border-color:var(--gb-dark-border)!important;
  color:var(--gb-dark-muted)!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 .result-formula b,
html[data-theme="dark"] body.enterprise-shell-v3 .result-progress>strong{color:var(--gb-dark-text)!important}
html[data-theme="dark"] body.enterprise-shell-v3 .score-search input{background:var(--gb-dark-bg-deep)!important}
html[data-theme="dark"] body.enterprise-shell-v3 table.result-score-table.mobile-card-table tr.score-learner-row{
  background:var(--gb-dark-surface)!important;
  border-color:var(--gb-dark-border)!important;
  box-shadow:0 8px 24px rgba(0,0,0,.14)!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 table.result-score-table.mobile-card-table tr.score-complete{
  border-color:color-mix(in srgb,var(--school-accent,#5f8ff7) 36%,var(--gb-dark-border))!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 table.result-score-table.mobile-card-table tr.score-absent{
  background:#24191d!important;
  border-color:#75404a!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 table.result-score-table.mobile-card-table .score-learner-cell{
  border-bottom-color:var(--gb-dark-border)!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 .score-row-number{
  background:var(--gb-dark-surface-soft)!important;
  color:var(--gb-dark-text-secondary)!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 .score-learner-avatar{
  background:var(--gb-dark-blue-soft)!important;
  color:#a9c5ff!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 table.result-score-table.mobile-card-table td::before{
  color:var(--gb-dark-muted)!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 table.result-score-table.mobile-card-table :where(input[type="number"],.remark-input){
  background:#12263c!important;
  border-color:var(--gb-dark-border-strong)!important;
  color:var(--gb-dark-text)!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 table.result-score-table.mobile-card-table :where(input[type="number"],.remark-input):disabled{
  background:#102136!important;
  color:#93a5b8!important;
  -webkit-text-fill-color:#93a5b8!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 table.result-score-table.mobile-card-table .calculated-score,
html[data-theme="dark"] body.enterprise-shell-v3 table.result-score-table.mobile-card-table .score-total-cell{
  background:var(--gb-dark-surface-raised)!important;
  border-color:var(--gb-dark-border)!important;
  color:#8eb1ff!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 .score-absent-toggle{
  background:var(--gb-dark-surface-raised)!important;
  border-color:var(--gb-dark-border)!important;
  color:var(--gb-dark-text)!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 .score-absent-toggle input:not(:checked){
  background:#243a50!important;
  border-color:#48627c!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 .score-absent-toggle input::after{background:#eef4fa!important}
html[data-theme="dark"] body.enterprise-shell-v3 .result-score-actions{
  background:rgba(15,32,51,.96)!important;
  border-color:var(--gb-dark-border)!important;
  box-shadow:0 16px 42px rgba(0,0,0,.34)!important;
}

/* --------------------------------------------------------------------------
   7. Teacher/lesson workflow surfaces
   -------------------------------------------------------------------------- */
html[data-theme="dark"] body.enterprise-shell-v3 :where(.teacher-home-hero,.teacher-timetable-hero,.lesson-note-banner){
  background:linear-gradient(135deg,var(--gb-dark-surface),color-mix(in srgb,var(--school-accent,#2563eb) 11%,var(--gb-dark-surface)))!important;
  border-color:var(--gb-brand-border)!important;
  color:var(--gb-dark-text)!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 :where(.teacher-home-hero p,.teacher-timetable-hero p,.lesson-note-banner p){color:var(--gb-dark-muted)!important}
html[data-theme="dark"] body.enterprise-shell-v3 .teacher-day-card>header{background:var(--gb-dark-surface-raised)!important;border-color:var(--gb-dark-border)!important}
html[data-theme="dark"] body.enterprise-shell-v3 .lesson-development-editor tr{background:var(--gb-dark-surface-raised)!important}
html[data-theme="dark"] body.enterprise-shell-v3 .lesson-development-editor :where(th,td){color:var(--gb-dark-text)!important}
html[data-theme="dark"] body.enterprise-shell-v3 .mobile-choice-chip{
  background:var(--gb-dark-surface-raised)!important;
  border-color:var(--gb-dark-border)!important;
  color:var(--gb-dark-text-secondary)!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 .mobile-choice-chip[aria-pressed="true"]{
  background:var(--gb-dark-blue-soft)!important;
  color:#b8ceff!important;
  border-color:var(--gb-brand-border)!important;
}

/* Printable lesson/report documents remain paper-white on screen and print. */
html[data-theme="dark"] body.enterprise-shell-v3 :where(.lesson-print,.report-document,.report-sheet,.report-page,.pdf-page){
  color-scheme:light;
}

/* --------------------------------------------------------------------------
   8. Parent & Learner portal
   -------------------------------------------------------------------------- */
html[data-theme="dark"] body.parent-family-app .parent-app-header{
  background:rgba(8,21,34,.96)!important;
  border-bottom:1px solid rgba(43,69,95,.65)!important;
}
html[data-theme="dark"] body.parent-family-app :where(
  .parent-welcome-card,.parent-updates-card,.parent-callout,.parent-child-card,
  .portal-modal-sheet,.parent-feature-card,.parent-family-overview article,
  .record-hero-average,.status-box,.child-metrics>div,.parent-update-preview,
  .login-option-card,.parent-account-summary,.parent-appearance-card,
  .portal-message-card,.assignment-item,.record-summary-grid article,
  .record-period-preview a,.record-period-list>article,.subject-history-list>article,
  .academic-trend,.child-detail-grid>div
){
  background:var(--gb-dark-surface)!important;
  border-color:var(--gb-dark-border)!important;
  color:var(--gb-dark-text)!important;
  box-shadow:var(--gb-dark-shadow-soft)!important;
}
html[data-theme="dark"] body.parent-family-app .parent-welcome-card{
  background:linear-gradient(135deg,var(--gb-dark-surface),var(--gb-dark-surface-raised))!important;
}
html[data-theme="dark"] body.parent-family-app :where(h1,h2,h3,h4,strong,b):not(.premium-report *):not(.report-document *){color:var(--gb-dark-text)!important}
html[data-theme="dark"] body.parent-family-app :where(p,small,.muted,.child-card-title small,.portal-modal-head p):not(.premium-report *):not(.report-document *){color:var(--gb-dark-muted)!important}
html[data-theme="dark"] body.parent-family-app :where(.parent-header-button,.parent-avatar-button,.parent-family-meta span,.parent-child-action,.parent-theme-toggle,.record-back,.record-print){
  background:var(--gb-dark-surface-raised)!important;
  border-color:var(--gb-dark-border)!important;
  color:var(--gb-dark-text)!important;
}
html[data-theme="dark"] body.parent-family-app :where(.parent-child-action.primary,.child-primary-actions a.primary){
  background:var(--gb-dark-blue)!important;
  border-color:var(--gb-dark-blue)!important;
  color:#fff!important;
}
html[data-theme="dark"] body.parent-family-app .parent-mobile-dock{
  background:rgba(12,29,47,.97)!important;
  border-color:var(--gb-dark-border)!important;
  box-shadow:0 18px 50px rgba(0,0,0,.34)!important;
}
html[data-theme="dark"] body.parent-family-app .parent-mobile-dock :where(a,button){color:var(--gb-dark-muted)!important}
html[data-theme="dark"] body.parent-family-app .parent-mobile-dock [data-parent-nav].is-active,
html[data-theme="dark"] body.parent-family-app .parent-mobile-dock>a:first-child{
  background:var(--gb-dark-blue-soft)!important;
  color:#b8ceff!important;
}
html[data-theme="dark"] body.parent-family-app .portal-modal-backdrop{background:rgba(2,8,15,.72)!important}
html[data-theme="dark"] body.parent-family-app .portal-modal-head{border-bottom-color:var(--gb-dark-border)!important}

/* --------------------------------------------------------------------------
   9. Unified staff/family login and authentication
   -------------------------------------------------------------------------- */
html[data-theme="dark"] body.pwa-auth-page{
  background:linear-gradient(135deg,#081522 0%,#0b1c2e 52%,#07131f 100%)!important;
  color:var(--gb-dark-text)!important;
}
html[data-theme="dark"] body.pwa-auth-page :where(.auth-card,.unified-login-card,.gradebook-login-card,.login-card){
  background:var(--gb-dark-surface)!important;
  border-color:var(--gb-dark-border)!important;
  color:var(--gb-dark-text)!important;
  box-shadow:0 28px 80px rgba(0,0,0,.38)!important;
}
html[data-theme="dark"] body.pwa-auth-page :where(h1,h2,h3,strong,b){color:var(--gb-dark-text)!important}
html[data-theme="dark"] body.pwa-auth-page :where(p,small,.muted){color:var(--gb-dark-muted)!important}
html[data-theme="dark"] body.pwa-auth-page :where(.login-audience-tabs,.login-method-tabs,.auth-segmented,.portal-login-tabs){
  background:var(--gb-dark-bg-deep)!important;
  border-color:var(--gb-dark-border)!important;
}
html[data-theme="dark"] body.pwa-auth-page :where(.login-audience-tabs button,.login-method-tabs button,.auth-segmented button,.portal-login-tab){color:var(--gb-dark-muted)!important}
html[data-theme="dark"] body.pwa-auth-page :where(.login-audience-tabs button.active,.login-method-tabs button.active,.auth-segmented button.active,.portal-login-tab.active){
  background:var(--gb-dark-surface-raised)!important;
  color:var(--gb-dark-text)!important;
  border-color:var(--gb-dark-border-strong)!important;
}

/* --------------------------------------------------------------------------
   10. Main/Super Admin platform pages — previously outside school token scope
   -------------------------------------------------------------------------- */
html[data-theme="dark"] body.enterprise-shell-platform :where(
  .panel,.stats article,.admin-card,.platform-card,.platform-health-card,
  .settings-card,.enterprise-platform-card,.revenue-card,.message-card,
  .audit-card,.registration-card,.school-card
){
  background:var(--gb-dark-surface)!important;
  border-color:var(--gb-dark-border)!important;
  color:var(--gb-dark-text)!important;
  box-shadow:var(--gb-dark-shadow-soft)!important;
}
html[data-theme="dark"] body.enterprise-shell-platform :where(.page-head h1,.page-head h2,h1,h2,h3,strong,b){color:var(--gb-dark-text)!important}
html[data-theme="dark"] body.enterprise-shell-platform :where(.muted,p small,.section-heading p){color:var(--gb-dark-muted)!important}
html[data-theme="dark"] body.enterprise-shell-platform :where(table,thead,tbody,tr,td,th){border-color:var(--gb-dark-border)!important}
html[data-theme="dark"] body.enterprise-shell-platform th{background:var(--gb-dark-surface-raised)!important;color:var(--gb-dark-text-secondary)!important}
html[data-theme="dark"] body.enterprise-shell-platform tbody tr:hover{background:var(--gb-dark-surface-raised)!important}

/* --------------------------------------------------------------------------
   11. Accessibility, scrollbar and reduced-motion consistency
   -------------------------------------------------------------------------- */
html[data-theme="dark"] body :where(a,button,input,select,textarea,summary,[tabindex]):focus-visible{
  outline:3px solid rgba(95,143,247,.32)!important;
  outline-offset:2px!important;
}
html[data-theme="dark"] body{scrollbar-color:#4a6178 #0b1a2b}
html[data-theme="dark"] body ::-webkit-scrollbar{width:10px;height:10px}
html[data-theme="dark"] body ::-webkit-scrollbar-track{background:#0b1a2b}
html[data-theme="dark"] body ::-webkit-scrollbar-thumb{background:#405972;border:2px solid #0b1a2b;border-radius:999px}
@media(max-width:800px){
  html[data-theme="dark"] body.enterprise-shell-v3 .panel{box-shadow:none!important}
  html[data-theme="dark"] body.enterprise-shell-v3 :where(input,select,textarea){font-size:16px!important}
}
@media(prefers-reduced-motion:reduce){
  html[data-theme="dark"] body *,html[data-theme="dark"] body *::before,html[data-theme="dark"] body *::after{transition-duration:.01ms!important;animation-duration:.01ms!important}
}
@media print{
  html[data-theme="dark"],html[data-theme="dark"] body{color-scheme:light!important}
  html[data-theme="dark"] body :where(.lesson-print,.report-document,.report-sheet,.report-page,.pdf-page){background:#fff!important;color:#111!important}
}


/* --------------------------------------------------------------------------
   12.1 Completion fixes from live dark-mode QA (Step 5.35)
   -------------------------------------------------------------------------- */
/* Staff / teacher pages that still exposed light islands. */
html[data-theme="dark"] body.enterprise-shell-v3 :where(
  .assignment-period,.assignment-workspace-stats article,.assignment-overview-panel,
  .assignment-overview-filters,.assignment-overview-filters .filters,
  .assignment-monitoring-card,.assignment-summary-card,.assignment-code-card,
  .assignment-code-list article,.assignment-empty-state,.assignment-access-card,
  .enrollment-onboarding,.enrollment-downloads>a,.enrollment-code-note,
  .teacher-editor, .teacher-editor fieldset,.teacher-list-card,.teacher-assignment-summary,
  .subject-assignment-row,.teacher-assignment-summary p,.teacher-assignment-summary div,
  .student360-tab-panel,.student360-panel,.student360-summary-card,.student-guardian-list article,
  .student-document-list article,.student-report-list article,.student360-secondary-panel,
  .student360-administrative-panel,.student360-profile-panel
){
  background:var(--gb-dark-surface)!important;
  border-color:var(--gb-dark-border)!important;
  color:var(--gb-dark-text)!important;
  box-shadow:var(--gb-dark-shadow-soft)!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 :where(
  .assignment-period b,.assignment-overview-heading h2,.enrollment-onboarding h2,
  .teacher-list-card h3,.teacher-editor h2,.teacher-editor legend,
  .student360-tab-panel h2,.student360-panel h2,.student360-panel h3,
  .student360-administrative-panel h2,.student360-profile-panel h2
){color:var(--gb-dark-text)!important}
html[data-theme="dark"] body.enterprise-shell-v3 :where(
  .assignment-overview-heading p,.assignment-overview-filters p,.enrollment-onboarding p,
  .enrollment-code-note span,.teacher-list-card p,.teacher-list-card small,
  .teacher-editor p,.teacher-editor small,.teacher-editor label,
  .student360-panel p,.student360-panel small,.student360-panel label
){color:var(--gb-dark-muted)!important}
html[data-theme="dark"] body.enterprise-shell-v3 :where(fieldset,.teacher-editor fieldset){
  background:var(--gb-dark-surface)!important;
  border-color:var(--gb-dark-border)!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 :where(.enrollment-downloads>a.secondary,.teacher-list-card .ghost){
  background:var(--gb-dark-surface-raised)!important;
  color:#b8ceff!important;
  border-color:var(--gb-dark-border-strong)!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 :where(.enrollment-code-note b,.assignment-code-card b,.assignment-code-list b){
  color:#b8ceff!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 :where(.subject-assignment-row .danger,.remove-assignment){
  background:#c9342d!important;
  border-color:#dc5149!important;
  color:#fff!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 :where(input[type="file"]){
  background:var(--gb-dark-surface-raised)!important;
  color:var(--gb-dark-text)!important;
  border-color:var(--gb-dark-border-strong)!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 :where(input[type="file"])::file-selector-button{
  margin-right:12px!important;
  border:0!important;
  border-right:1px solid var(--gb-dark-border)!important;
  background:var(--gb-dark-bg-deep)!important;
  color:var(--gb-dark-text)!important;
  padding:11px 14px!important;
  font:inherit!important;
  font-weight:700!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 option,
html[data-theme="dark"] body.parent-family-app option,
html[data-theme="dark"] body.pwa-auth-page option{
  background:#13263a!important;
  color:var(--gb-dark-text)!important;
}

/* Parent / family portal completion fixes. */
html[data-theme="dark"] body.parent-family-app :where(
  .parent-empty-state,.record-subject-chips b,.record-subject-pill,
  .record-period-preview,.record-card,.record-child-card,.assignment-empty-state,
  .parent-child-record,.parent-child-assignment,.parent-message-empty,
  .parent-record-preview,.portal-empty-state
){
  background:var(--gb-dark-surface)!important;
  border-color:var(--gb-dark-border)!important;
  color:var(--gb-dark-text)!important;
}
html[data-theme="dark"] body.parent-family-app .parent-empty-state{
  border-style:dashed!important;
  background:color-mix(in srgb,var(--gb-dark-surface) 82%,#f7fbf9)!important;
}
html[data-theme="dark"] body.parent-family-app .parent-empty-state>span{
  background:var(--gb-dark-success-soft)!important;
  color:#8ee2b3!important;
}
html[data-theme="dark"] body.parent-family-app :where(.record-subject-chips b,.record-subject-pill){
  background:var(--gb-dark-surface-raised)!important;
  color:var(--gb-dark-text-secondary)!important;
  border:1px solid var(--gb-dark-border)!important;
  border-radius:999px!important;
}
html[data-theme="dark"] body.parent-family-app :where(.parent-count-pill,.status-box.good,.status-box.pending,.status-box.warning){
  border-color:transparent!important;
}
html[data-theme="dark"] body.parent-family-app .status-box.good,
html[data-theme="dark"] body.parent-family-app .parent-count-pill{
  background:var(--gb-dark-success-soft)!important;
  color:#8ee2b3!important;
}
html[data-theme="dark"] body.parent-family-app .status-box.pending{
  background:var(--gb-dark-blue-soft)!important;
  color:#b8ceff!important;
}
html[data-theme="dark"] body.parent-family-app .status-box.warning{
  background:var(--gb-dark-warning-soft)!important;
  color:#ffd392!important;
}
html[data-theme="dark"] body.parent-family-app :where(.academic-trend svg text,.academic-trend .chart-label,.academic-trend .chart-value){
  fill:var(--gb-dark-muted)!important;
  color:var(--gb-dark-muted)!important;
}
html[data-theme="dark"] body.parent-family-app :where(.academic-trend svg path,.academic-trend svg line){
  stroke:color-mix(in srgb,var(--gb-dark-blue) 60%,#30465f)!important;
}
html[data-theme="dark"] body.parent-family-app :where(.academic-trend svg circle){
  fill:#b8ceff!important;
  stroke:#4f83ff!important;
}

/* Report viewer: dark shell around the intentionally white printable page. */
html[data-theme="dark"] body.enterprise-shell-v3 :where(.report-viewer-shell,.report-viewer-toolbar),
html[data-theme="dark"] body.parent-family-app :where(.report-viewer-shell,.report-viewer-toolbar){
  color:var(--gb-dark-text)!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 .report-viewer-toolbar,
html[data-theme="dark"] body.parent-family-app .report-viewer-toolbar{
  background:var(--gb-dark-surface)!important;
  border-color:var(--gb-dark-border)!important;
  box-shadow:var(--gb-dark-shadow-soft)!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 .report-viewer-toolbar label,
html[data-theme="dark"] body.parent-family-app .report-viewer-toolbar label{
  color:var(--gb-dark-text-secondary)!important;
}

html[data-theme="dark"] body.enterprise-shell-v3 .report-action-set .button,
html[data-theme="dark"] body.enterprise-shell-v3 .report-action-set button,
html[data-theme="dark"] body.parent-family-app .report-action-set .button,
html[data-theme="dark"] body.parent-family-app .report-action-set button{
  background:var(--gb-dark-surface-raised)!important;
  border:1px solid var(--gb-dark-border)!important;
  color:var(--gb-dark-text)!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 .report-action-set .report-download-primary,
html[data-theme="dark"] body.enterprise-shell-v3 .report-action-set button.report-download-primary,
html[data-theme="dark"] body.parent-family-app .report-action-set .report-download-primary,
html[data-theme="dark"] body.parent-family-app .report-action-set button.report-download-primary{
  background:var(--gb-dark-blue)!important;
  border-color:var(--gb-dark-blue)!important;
  color:#fff!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 .report-preview-viewport,
html[data-theme="dark"] body.parent-family-app .report-preview-viewport{
  background:linear-gradient(180deg,#0d1c2d,#11263b)!important;
  border-color:var(--gb-dark-border)!important;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.04)!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 .report-preview-stage>.premium-report,
html[data-theme="dark"] body.parent-family-app .report-preview-stage>.premium-report{
  background:#fff!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 .report-action-status,
html[data-theme="dark"] body.parent-family-app .report-action-status{
  background:var(--gb-dark-surface-raised)!important;
  color:var(--gb-dark-muted)!important;
  border:1px solid var(--gb-dark-border)!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 .report-action-status[data-state="working"],
html[data-theme="dark"] body.parent-family-app .report-action-status[data-state="working"]{
  background:var(--gb-dark-blue-soft)!important;
  color:#b8ceff!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 .report-action-status[data-state="success"],
html[data-theme="dark"] body.parent-family-app .report-action-status[data-state="success"]{
  background:var(--gb-dark-success-soft)!important;
  color:#8ee2b3!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 .report-action-status[data-state="error"],
html[data-theme="dark"] body.parent-family-app .report-action-status[data-state="error"]{
  background:var(--gb-dark-danger-soft)!important;
  color:#ffaaa4!important;
}

/* Mobile safe areas and bottom docks. */
@media(max-width:820px){
  html[data-theme="dark"] body.parent-family-app .parent-mobile-dock,
  html[data-theme="dark"].gradebook-installed-app.gradebook-phone-app .pwa-app-dock{
    backdrop-filter:blur(14px);
  }
  html[data-theme="dark"] body.parent-family-app .report-viewer-shell{
    padding-bottom:118px!important;
  }
}



/* --------------------------------------------------------------------------
   13. Full legacy-surface audit — Step 5.35
   The unified stylesheet loads last so older module CSS cannot reintroduce
   white cards, pale text or light dialogs inside an explicitly dark portal.
   -------------------------------------------------------------------------- */

/* Paper isolation: dark application shell, original paper/report palette. */
html[data-theme="dark"] body :where(.premium-report,.report-document,.report-sheet,.report-page,.pdf-page){
  color-scheme:light!important;
  background:#fff!important;
}
html[data-theme="dark"] body :where(.premium-report,.report-document) :where(input,select,textarea){color-scheme:light!important}

/* Staff/admin generic legacy surfaces. */
html[data-theme="dark"] body.enterprise-shell-v3 :where(
  .card,.empty-state,.empty-message-state,.empty-card,.empty-panel,.notice-card,.hint-card,
  .info-panel,.summary-card,.detail-card,.metric-card,.kpi-card,.form-card,.filter-card,
  .inline-upload,.filters,.filter-bar,.toolbar,.form-toolbar,.import-toolbar,
  .import-panel,.import-stats article,.import-errors,.import-preview,.review-panel,
  .assignment-code-card,.assignment-access-card,.assignment-family-access,.assignment-empty-state,
  .assignment-monitoring-card,.assignment-list-card,.assignment-detail-card,
  .teacher-password-note,.temporary-password-note,.password-help,.credential-note,.credential-help,
  .student360-card,.student360-section,.student360-secondary-panel,.student360-administrative-panel,
  .student360-profile-panel,.student360-tab-panel,.student360-panel,
  .report-preview-modal,.modal-card,.modal-panel,.modal-sheet
):not(.premium-report *):not(.report-document *){
  background:var(--gb-dark-surface)!important;
  border-color:var(--gb-dark-border)!important;
  color:var(--gb-dark-text)!important;
  box-shadow:var(--gb-dark-shadow-soft)!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 :where(
  .empty-state p,.empty-message-state p,.empty-card p,.notice-card p,.hint-card p,
  .info-panel p,.summary-card p,.detail-card p,.credential-note p,.credential-help p,
  .teacher-password-note p,.temporary-password-note p,.student360-card p,.student360-section p
):not(.premium-report *):not(.report-document *){color:var(--gb-dark-muted)!important}

/* Enrollment: preserve primary blue CTA; remove white centre/upload islands. */
html[data-theme="dark"] body.enterprise-shell-v3 .enrollment-downloads>a:not(.secondary){
  background:var(--school-accent,var(--gb-dark-blue))!important;
  border-color:var(--school-accent,var(--gb-dark-blue))!important;
  color:#fff!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 :where(
  .enrollment-import-controls,.enrollment-import-bar,.enrollment-import-workspace,
  .enrollment-import-form,.enrollment-upload-panel,.enrollment-filter-panel,
  .inline-upload
){background:var(--gb-dark-surface)!important;border-color:var(--gb-dark-border)!important;color:var(--gb-dark-text)!important}
html[data-theme="dark"] body.enterprise-shell-v3 :where(.enrollment-import-controls,.enrollment-import-bar,.inline-upload) label{color:var(--gb-dark-text-secondary)!important}

/* Teachers: every fieldset/help/assignment row belongs to the same dark family. */
html[data-theme="dark"] body.enterprise-shell-v3 .teacher-editor :where(fieldset,.role-checks,.subject-assignment-row,.teacher-password-note,.temporary-password-note,.password-help,.credential-note){
  background:var(--gb-dark-surface)!important;
  border-color:var(--gb-dark-border)!important;
  color:var(--gb-dark-text)!important;
}
html[data-theme="dark"] body.enterprise-shell-v3 .teacher-editor :where(.teacher-password-note,.temporary-password-note,.password-help,.credential-note) :where(p,small,span){color:var(--gb-dark-muted)!important}
html[data-theme="dark"] body.enterprise-shell-v3 .teacher-list-card .teacher-assignment-summary{background:var(--gb-dark-surface-raised)!important;border-color:var(--gb-dark-border)!important}

/* Student 360 values: live QA showed dark text on dark cards. */
html[data-theme="dark"] body.enterprise-shell-v3 :where(
  .student360-dl dt,.student360-summary-row span,.student360-hero-summary span,
  .student360-meta small,.student360-section .eyebrow
){color:var(--gb-dark-muted)!important}
html[data-theme="dark"] body.enterprise-shell-v3 :where(
  .student360-dl dd,.student360-dl p,.student360-dl strong,
  .student360-summary-row strong,.student360-hero-summary strong,
  .student360-profile-value,.student360-value
){color:var(--gb-dark-text)!important;-webkit-text-fill-color:var(--gb-dark-text)!important}

/* Academic Operations legacy surfaces and dialogs. */
html[data-theme="dark"] body.enterprise-shell-v3 :where(
  .academic-ops-page-head>div:last-child,.academic-ops-tabs,.academic-ops-hero,
  .academic-ops-metrics article,.academic-readiness-list>a,.academic-period-list article,
  .academic-curriculum-list article,.academic-code-list article,.academic-event-list>a,
  .academic-day-banner,.academic-override,.academic-empty-state,.academic-dialog-shell,
  .academic-dialog-actions,.academic-form-section,.academic-optional-section,
  .academic-period-strip>div,.academic-timetable thead th,.academic-timetable tbody th,
  .academic-timetable-entry,.academic-break
){background:var(--gb-dark-surface)!important;border-color:var(--gb-dark-border)!important;color:var(--gb-dark-text)!important}
html[data-theme="dark"] body.enterprise-shell-v3 :where(.academic-ops-period,.academic-flow span,.academic-week-range,.academic-code-badge){
  background:var(--gb-dark-blue-soft)!important;border-color:var(--gb-brand-border)!important;color:#b8ceff!important
}
html[data-theme="dark"] body.enterprise-shell-v3 .academic-dialog-close{background:var(--gb-dark-surface-raised)!important;color:var(--gb-dark-text)!important;border-color:var(--gb-dark-border)!important}

/* Interface settings / preview controls. */
html[data-theme="dark"] body.enterprise-shell-v3 :where(.interface-palette-option,.interface-choice,.interface-preview-note,.interface-mini-grid i){
  background:var(--gb-dark-surface)!important;border-color:var(--gb-dark-border)!important;color:var(--gb-dark-text)!important
}
html[data-theme="dark"] body.enterprise-shell-v3 .interface-mini-shell{background:var(--gb-dark-bg-deep)!important;border-color:var(--gb-dark-border)!important}

/* Mobile/native pickers and dialogs. */
html[data-theme="dark"] body.enterprise-shell-v3 :where(.gradebook-mobile-sheet,.gb-select-sheet,.gb-temporal-sheet,.mobile-choice-picker){
  background:var(--gb-dark-surface)!important;border-color:var(--gb-dark-border)!important;color:var(--gb-dark-text)!important
}
html[data-theme="dark"] body.enterprise-shell-v3 :where(.gradebook-mobile-sheet-head,.gb-select-sheet-head,.gb-temporal-sheet-head){border-color:var(--gb-dark-border)!important}
html[data-theme="dark"] body.enterprise-shell-v3 :where(.gradebook-mobile-sheet-head>button,.gb-select-sheet-close,.gb-temporal-sheet-close){
  background:var(--gb-dark-surface-raised)!important;color:var(--gb-dark-text)!important;border-color:var(--gb-dark-border)!important
}
html[data-theme="dark"] body.enterprise-shell-v3 :where(.gb-select-sheet-option,.gb-temporal-sheet-option){color:var(--gb-dark-text-secondary)!important}
html[data-theme="dark"] body.enterprise-shell-v3 :where(.gb-select-sheet-option:hover,.gb-select-sheet-option:focus-visible,.gb-temporal-sheet-option:hover,.gb-temporal-sheet-option:focus-visible){background:var(--gb-dark-surface-hover)!important}

/* PWA install dialog can be opened from every portal. */
html[data-theme="dark"] body :where(.pwa-install-dialog){background:var(--gb-dark-surface)!important;border-color:var(--gb-dark-border)!important;color:var(--gb-dark-text)!important}
html[data-theme="dark"] body .pwa-install-dialog :where(.pwa-install-device-grid article,.pwa-install-help){background:var(--gb-dark-surface-raised)!important;border-color:var(--gb-dark-border)!important;color:var(--gb-dark-text-secondary)!important}
html[data-theme="dark"] body .pwa-install-dialog-head button{background:var(--gb-dark-surface-raised)!important;color:var(--gb-dark-text)!important}
html[data-theme="dark"] body .pwa-install-dialog .ghost{background:var(--gb-dark-surface-raised)!important;color:var(--gb-dark-text)!important;border-color:var(--gb-dark-border)!important}

/* Parent/family legacy components from portal.css + parent-mobile-app.css. */
html[data-theme="dark"] body.parent-family-app :where(
  .message-preview,.message-preview.empty,.attention-tag,.status-box,.child-metrics div,
  .action-button,.action-button.subtle,.action-button.disabled,.portal-modal-sheet,
  .portal-modal-close,.filter-chip,.filter-chip span,.portal-message-card,
  .tiny-button,.empty-message-state,.login-mode-card,.login-option-card,
  .login-option-form input,.login-option-inline .ghost,.parent-quick-action,
  .parent-logout-link,.parent-logout-action,.assignment-feedback
):not(.premium-report *):not(.report-document *){
  background:var(--gb-dark-surface)!important;
  border-color:var(--gb-dark-border)!important;
  color:var(--gb-dark-text)!important;
}
html[data-theme="dark"] body.parent-family-app :where(.message-preview p,.portal-message-card p,.empty-message-state,.login-mode-card small,.login-option-card p,.assignment-feedback){color:var(--gb-dark-muted)!important}
html[data-theme="dark"] body.parent-family-app .filter-chip.active{background:var(--gb-dark-blue)!important;border-color:var(--gb-dark-blue)!important;color:#fff!important}
html[data-theme="dark"] body.parent-family-app .filter-chip.active span{background:rgba(255,255,255,.14)!important;color:#fff!important}
html[data-theme="dark"] body.parent-family-app .attention-tag{background:var(--gb-dark-warning-soft)!important;color:#ffd392!important}
html[data-theme="dark"] body.parent-family-app .action-button.primary{background:var(--gb-dark-blue)!important;border-color:var(--gb-dark-blue)!important;color:#fff!important}
html[data-theme="dark"] body.parent-family-app .action-button.disabled{background:#203247!important;color:#8799ac!important}

/* Platform/Super Admin: catch legacy generic cards, dialogs and empty states. */
html[data-theme="dark"] body.enterprise-shell-platform :where(
  .card,.empty-state,.empty-message-state,.modal-card,.modal-panel,.modal-sheet,
  .filter-card,.toolbar,.inline-upload,.stats article,.confirm-card,dialog:not(.premium-report *)
){background:var(--gb-dark-surface)!important;border-color:var(--gb-dark-border)!important;color:var(--gb-dark-text)!important;box-shadow:var(--gb-dark-shadow-soft)!important}
html[data-theme="dark"] body.enterprise-shell-platform :where(input:not([type="checkbox"]):not([type="radio"]),select,textarea){background:var(--gb-dark-surface-raised)!important;color:var(--gb-dark-text)!important;border-color:var(--gb-dark-border-strong)!important}

/* Browser-generated form states. */
html[data-theme="dark"] body :where(input,textarea):-webkit-autofill,
html[data-theme="dark"] body :where(input,textarea):-webkit-autofill:hover,
html[data-theme="dark"] body :where(input,textarea):-webkit-autofill:focus{
  -webkit-text-fill-color:var(--gb-dark-text)!important;
  -webkit-box-shadow:0 0 0 1000px var(--gb-dark-surface-raised) inset!important;
  caret-color:var(--gb-dark-text)!important;
}
html[data-theme="dark"] body :where(input[type="date"],input[type="time"],input[type="datetime-local"])::-webkit-calendar-picker-indicator{filter:invert(.85);opacity:.82}
html[data-theme="dark"] body :where(input[type="checkbox"],input[type="radio"]){accent-color:var(--school-accent,var(--gb-dark-blue))}

/* Dark-mode media/table containment should never leak into paper reports. */
@media screen{
  html[data-theme="dark"] body :where(.premium-report,.report-document,.report-sheet,.report-page,.pdf-page){isolation:isolate}
}

/* --------------------------------------------------------------------------
   16. Step 5.36 — mobile account / profile / settings stabilisation
   Fixes scattered teacher mobile account menu, settings and signature panels.
   -------------------------------------------------------------------------- */
@media (max-width:800px){
  html[data-theme="dark"] body.enterprise-shell-v3 .enterprise-user-popover,
  body.enterprise-shell-v3 .enterprise-user-popover{
    display:grid!important;
    gap:10px!important;
    align-content:start!important;
    overscroll-behavior:contain!important;
  }

  /* Buttons and links inside the account sheet must share the same layout. */
  html[data-theme="dark"] body.enterprise-shell-v3 .enterprise-user-popover :is(a.enterprise-user-action,button.enterprise-user-action),
  body.enterprise-shell-v3 .enterprise-user-popover :is(a.enterprise-user-action,button.enterprise-user-action){
    appearance:none!important;
    -webkit-appearance:none!important;
    display:grid!important;
    grid-template-columns:44px minmax(0,1fr) auto!important;
    align-items:center!important;
    gap:12px!important;
    width:100%!important;
    min-height:72px!important;
    margin:0!important;
    padding:13px 14px!important;
    border:1px solid transparent!important;
    border-radius:16px!important;
    background:transparent!important;
    color:inherit!important;
    text-align:left!important;
    text-decoration:none!important;
    box-shadow:none!important;
    overflow:hidden!important;
  }
  html[data-theme="dark"] body.enterprise-shell-v3 .enterprise-user-popover :is(a.enterprise-user-action,button.enterprise-user-action){
    border-color:rgba(59,91,120,.55)!important;
    background:rgba(20,40,62,.38)!important;
  }
  html[data-theme="dark"] body.enterprise-shell-v3 .enterprise-user-popover :is(a.enterprise-user-action,button.enterprise-user-action):hover,
  html[data-theme="dark"] body.enterprise-shell-v3 .enterprise-user-popover :is(a.enterprise-user-action,button.enterprise-user-action):focus-visible,
  body.enterprise-shell-v3 .enterprise-user-popover :is(a.enterprise-user-action,button.enterprise-user-action):hover,
  body.enterprise-shell-v3 .enterprise-user-popover :is(a.enterprise-user-action,button.enterprise-user-action):focus-visible{
    background:var(--gb-dark-surface-hover,var(--gb-surface-raised,#eef4ff))!important;
    border-color:var(--gb-brand-border,var(--gb-dark-border-strong,#c9d8ec))!important;
  }

  body.enterprise-shell-v3 .enterprise-user-popover .enterprise-user-action>span,
  body.enterprise-shell-v3 .enterprise-user-popover .enterprise-theme-menu-action>[data-theme-menu-icon],
  html[data-theme="dark"] body.enterprise-shell-v3 .enterprise-user-popover .enterprise-user-action>span,
  html[data-theme="dark"] body.enterprise-shell-v3 .enterprise-user-popover .enterprise-theme-menu-action>[data-theme-menu-icon]{
    width:44px!important;
    height:44px!important;
    min-width:44px!important;
    min-height:44px!important;
    flex:0 0 44px!important;
    display:grid!important;
    place-items:center!important;
    align-self:center!important;
    justify-self:start!important;
    overflow:hidden!important;
    border-radius:14px!important;
    border:1px solid var(--gb-brand-border,var(--gb-dark-border,#dce6f2))!important;
    background:var(--gb-brand-soft,var(--gb-dark-blue-soft,#eff6ff))!important;
    color:var(--gb-brand-strong,var(--gb-dark-blue-strong,#1d4ed8))!important;
  }
  body.enterprise-shell-v3 .enterprise-user-popover .enterprise-user-action svg,
  body.enterprise-shell-v3 .enterprise-user-popover .enterprise-theme-menu-action [data-theme-menu-icon] svg,
  html[data-theme="dark"] body.enterprise-shell-v3 .enterprise-user-popover .enterprise-user-action svg,
  html[data-theme="dark"] body.enterprise-shell-v3 .enterprise-user-popover .enterprise-theme-menu-action [data-theme-menu-icon] svg{
    width:20px!important;
    height:20px!important;
    min-width:20px!important;
    min-height:20px!important;
    display:block!important;
    flex:none!important;
    stroke:currentColor!important;
    fill:none!important;
    overflow:visible!important;
  }

  body.enterprise-shell-v3 .enterprise-user-popover .enterprise-user-action>div,
  html[data-theme="dark"] body.enterprise-shell-v3 .enterprise-user-popover .enterprise-user-action>div{
    min-width:0!important;
    display:grid!important;
    gap:3px!important;
    align-content:center!important;
  }
  body.enterprise-shell-v3 .enterprise-user-popover .enterprise-user-action b,
  html[data-theme="dark"] body.enterprise-shell-v3 .enterprise-user-popover .enterprise-user-action b{
    margin:0!important;
    font-size:17px!important;
    line-height:1.18!important;
    letter-spacing:-.01em!important;
    white-space:normal!important;
  }
  body.enterprise-shell-v3 .enterprise-user-popover .enterprise-user-action small,
  html[data-theme="dark"] body.enterprise-shell-v3 .enterprise-user-popover .enterprise-user-action small{
    margin:0!important;
    font-size:13px!important;
    line-height:1.45!important;
    white-space:normal!important;
    color:var(--gb-dark-muted,var(--gb-muted,#6b7e93))!important;
  }

  body.enterprise-shell-v3 .enterprise-user-popover .enterprise-theme-menu-action,
  html[data-theme="dark"] body.enterprise-shell-v3 .enterprise-user-popover .enterprise-theme-menu-action{
    grid-template-columns:44px minmax(0,1fr) 52px!important;
  }
  body.enterprise-shell-v3 .enterprise-user-popover .enterprise-theme-switch,
  html[data-theme="dark"] body.enterprise-shell-v3 .enterprise-user-popover .enterprise-theme-switch{
    width:46px!important;
    height:28px!important;
    justify-self:end!important;
    margin-left:0!important;
  }
  body.enterprise-shell-v3 .enterprise-user-popover .enterprise-theme-switch i,
  html[data-theme="dark"] body.enterprise-shell-v3 .enterprise-user-popover .enterprise-theme-switch i{
    width:22px!important;
    height:22px!important;
  }
  html[data-theme="dark"] body.enterprise-shell-v3 .enterprise-user-popover .enterprise-theme-switch i{
    transform:translateX(18px)!important;
  }

  /* Refresh action is a button; force button reset parity with links. */
  body.enterprise-shell-v3 .enterprise-user-popover .pwa-refresh-menu,
  html[data-theme="dark"] body.enterprise-shell-v3 .enterprise-user-popover .pwa-refresh-menu{
    border-style:solid!important;
  }

  /* Sign-out should read as destructive but still polished, not a giant red bar. */
  body.enterprise-shell-v3 .enterprise-user-popover .enterprise-user-action.danger,
  html[data-theme="dark"] body.enterprise-shell-v3 .enterprise-user-popover .enterprise-user-action.danger{
    border-top:0!important;
    margin-top:0!important;
    padding-top:13px!important;
    border-color:color-mix(in srgb,var(--gb-dark-danger,#ef4444) 34%,var(--gb-dark-border,#30455e))!important;
    background:var(--gb-dark-danger-soft,rgba(239,68,68,.12))!important;
    color:#ffd0cb!important;
  }
  body.enterprise-shell-v3 .enterprise-user-popover .enterprise-user-action.danger:hover,
  html[data-theme="dark"] body.enterprise-shell-v3 .enterprise-user-popover .enterprise-user-action.danger:hover{
    background:rgba(239,68,68,.18)!important;
    border-color:rgba(255,123,114,.55)!important;
  }
  body.enterprise-shell-v3 .enterprise-user-popover .enterprise-user-action.danger>span,
  html[data-theme="dark"] body.enterprise-shell-v3 .enterprise-user-popover .enterprise-user-action.danger>span{
    background:rgba(239,68,68,.18)!important;
    border-color:rgba(255,123,114,.46)!important;
    color:#ffb4ad!important;
  }

  /* Mobile settings/profile pages themselves. */
  html[data-theme="dark"] body.enterprise-shell-v3 :is(.account-settings-layout,.signature-page),
  body.enterprise-shell-v3 :is(.account-settings-layout,.signature-page){
    display:grid!important;
    grid-template-columns:1fr!important;
    gap:14px!important;
    align-items:start!important;
  }
  html[data-theme="dark"] body.enterprise-shell-v3 :is(.account-profile-card,.signature-status-card),
  body.enterprise-shell-v3 :is(.account-profile-card,.signature-status-card){
    display:grid!important;
    grid-template-columns:72px minmax(0,1fr)!important;
    gap:14px!important;
    align-items:center!important;
  }
  body.enterprise-shell-v3 :is(.account-avatar-preview,.signature-status-icon),
  html[data-theme="dark"] body.enterprise-shell-v3 :is(.account-avatar-preview,.signature-status-icon){
    width:72px!important;
    height:72px!important;
    min-width:72px!important;
    min-height:72px!important;
    display:grid!important;
    place-items:center!important;
    border-radius:22px!important;
    overflow:hidden!important;
    font-size:28px!important;
    line-height:1!important;
  }
  body.enterprise-shell-v3 .account-avatar-preview img,
  body.enterprise-shell-v3 .signature-preview img{
    width:100%!important;
    height:100%!important;
    object-fit:cover!important;
  }
  body.enterprise-shell-v3 .signature-preview{
    max-width:100%!important;
    min-height:140px!important;
    display:grid!important;
    place-items:center!important;
    padding:12px!important;
    border:1px dashed var(--gb-dark-border,#30455e)!important;
    border-radius:16px!important;
    background:rgba(255,255,255,.02)!important;
  }
  body.enterprise-shell-v3 .signature-preview img{
    height:auto!important;
    max-height:150px!important;
    object-fit:contain!important;
  }
  body.enterprise-shell-v3 .signature-empty,
  body.enterprise-shell-v3 .account-settings-form fieldset,
  html[data-theme="dark"] body.enterprise-shell-v3 .signature-empty,
  html[data-theme="dark"] body.enterprise-shell-v3 .account-settings-form fieldset{
    border:1px solid var(--gb-dark-border,#30455e)!important;
    border-radius:16px!important;
    padding:14px!important;
    background:rgba(255,255,255,.02)!important;
  }
  body.enterprise-shell-v3 .account-settings-form fieldset,
  body.enterprise-shell-v3 .signature-manager form{
    display:grid!important;
    gap:12px!important;
  }
}

@media (max-width:420px){
  body.enterprise-shell-v3 .enterprise-user-popover,
  html[data-theme="dark"] body.enterprise-shell-v3 .enterprise-user-popover{
    left:8px!important;
    right:8px!important;
    top:calc(70px + env(safe-area-inset-top))!important;
    padding:8px!important;
    border-radius:18px!important;
  }
  body.enterprise-shell-v3 .enterprise-user-popover :is(a.enterprise-user-action,button.enterprise-user-action),
  html[data-theme="dark"] body.enterprise-shell-v3 .enterprise-user-popover :is(a.enterprise-user-action,button.enterprise-user-action){
    grid-template-columns:40px minmax(0,1fr) auto!important;
    min-height:68px!important;
    padding:12px!important;
    gap:10px!important;
  }
  body.enterprise-shell-v3 .enterprise-user-popover .enterprise-user-action>span,
  body.enterprise-shell-v3 .enterprise-user-popover .enterprise-theme-menu-action>[data-theme-menu-icon],
  html[data-theme="dark"] body.enterprise-shell-v3 .enterprise-user-popover .enterprise-user-action>span,
  html[data-theme="dark"] body.enterprise-shell-v3 .enterprise-user-popover .enterprise-theme-menu-action>[data-theme-menu-icon]{
    width:40px!important;height:40px!important;min-width:40px!important;min-height:40px!important;border-radius:13px!important;
  }
  body.enterprise-shell-v3 .enterprise-user-popover .enterprise-user-action b,
  html[data-theme="dark"] body.enterprise-shell-v3 .enterprise-user-popover .enterprise-user-action b{font-size:16px!important}
  body.enterprise-shell-v3 .enterprise-user-popover .enterprise-user-action small,
  html[data-theme="dark"] body.enterprise-shell-v3 .enterprise-user-popover .enterprise-user-action small{font-size:12px!important}
  body.enterprise-shell-v3 :is(.account-profile-card,.signature-status-card),
  html[data-theme="dark"] body.enterprise-shell-v3 :is(.account-profile-card,.signature-status-card){grid-template-columns:64px minmax(0,1fr)!important;gap:12px!important}
  body.enterprise-shell-v3 :is(.account-avatar-preview,.signature-status-icon),
  html[data-theme="dark"] body.enterprise-shell-v3 :is(.account-avatar-preview,.signature-status-icon){width:64px!important;height:64px!important;min-width:64px!important;min-height:64px!important;font-size:24px!important;border-radius:18px!important}
}

/* --------------------------------------------------------------------------
   17. Step 5.37 — Staff mobile account behaviour + installed app correctness
   -------------------------------------------------------------------------- */
/* Hidden means hidden, even when an account action has a forced grid display. */
[data-pwa-install-item][hidden],
[data-pwa-install][hidden],
html.gradebook-installed-app [data-pwa-install-item],
html.gradebook-installed-app [data-pwa-install],
html[data-pwa-installed="1"] [data-pwa-install-item],
html[data-pwa-installed="1"] [data-pwa-install]{
  display:none!important;
}

@media(max-width:800px){
  /* Treat the open account menu as a real app sheet with a quiet backdrop. */
  body.enterprise-shell-v3 .enterprise-user-menu[open]::before{
    content:"";
    position:fixed;
    inset:64px 0 0;
    z-index:78;
    background:rgba(2,9,17,.48);
    backdrop-filter:blur(2px);
    -webkit-backdrop-filter:blur(2px);
    pointer-events:none;
  }
  body.enterprise-shell-v3 .enterprise-user-popover{
    z-index:90!important;
    max-height:calc(100dvh - 154px - env(safe-area-inset-top) - env(safe-area-inset-bottom))!important;
    padding:8px!important;
    gap:8px!important;
    border-radius:18px!important;
  }

  /* More compact, native-settings density. */
  body.enterprise-shell-v3 .enterprise-user-popover :is(a.enterprise-user-action,button.enterprise-user-action),
  html[data-theme="dark"] body.enterprise-shell-v3 .enterprise-user-popover :is(a.enterprise-user-action,button.enterprise-user-action){
    grid-template-columns:38px minmax(0,1fr) auto!important;
    min-height:60px!important;
    padding:10px 12px!important;
    gap:10px!important;
    border-radius:14px!important;
  }
  body.enterprise-shell-v3 .enterprise-user-popover .enterprise-user-action>span,
  body.enterprise-shell-v3 .enterprise-user-popover .enterprise-theme-menu-action>[data-theme-menu-icon],
  html[data-theme="dark"] body.enterprise-shell-v3 .enterprise-user-popover .enterprise-user-action>span,
  html[data-theme="dark"] body.enterprise-shell-v3 .enterprise-user-popover .enterprise-theme-menu-action>[data-theme-menu-icon]{
    width:38px!important;height:38px!important;min-width:38px!important;min-height:38px!important;
    border-radius:12px!important;
  }
  body.enterprise-shell-v3 .enterprise-user-popover .enterprise-user-action svg,
  body.enterprise-shell-v3 .enterprise-user-popover .enterprise-theme-menu-action [data-theme-menu-icon] svg{
    width:18px!important;height:18px!important;min-width:18px!important;min-height:18px!important;
  }
  body.enterprise-shell-v3 .enterprise-user-popover .enterprise-user-action b,
  html[data-theme="dark"] body.enterprise-shell-v3 .enterprise-user-popover .enterprise-user-action b{
    font-size:15px!important;
    line-height:1.2!important;
  }
  body.enterprise-shell-v3 .enterprise-user-popover .enterprise-user-action small,
  html[data-theme="dark"] body.enterprise-shell-v3 .enterprise-user-popover .enterprise-user-action small{
    font-size:11.5px!important;
    line-height:1.35!important;
  }

  /* A true two-state appearance switch. */
  body.enterprise-shell-v3 .enterprise-user-popover .enterprise-theme-menu-action{
    grid-template-columns:38px minmax(0,1fr) 48px!important;
  }
  body.enterprise-shell-v3 .enterprise-theme-switch,
  html[data-theme="dark"] body.enterprise-shell-v3 .enterprise-theme-switch{
    box-sizing:border-box!important;
    width:46px!important;
    min-width:46px!important;
    height:28px!important;
    padding:3px!important;
    margin:0!important;
    overflow:hidden!important;
    border:1px solid var(--gb-line-strong,#9aabba)!important;
    border-radius:999px!important;
    display:flex!important;
    align-items:center!important;
    justify-content:flex-start!important;
    background:#718196!important;
  }
  body.enterprise-shell-v3 .enterprise-theme-switch i,
  html[data-theme="dark"] body.enterprise-shell-v3 .enterprise-theme-switch i{
    width:20px!important;height:20px!important;min-width:20px!important;min-height:20px!important;
    border-radius:50%!important;
    background:#fff!important;
    transform:translateX(0)!important;
    transition:transform .18s ease!important;
  }
  html[data-theme="dark"] body.enterprise-shell-v3 .enterprise-theme-switch,
  body.enterprise-shell-v3 #themeMenuToggle.is-dark .enterprise-theme-switch{
    background:var(--school-accent,#2563eb)!important;
    border-color:color-mix(in srgb,var(--school-accent,#2563eb) 70%,#fff)!important;
  }
  html[data-theme="dark"] body.enterprise-shell-v3 .enterprise-theme-switch i,
  body.enterprise-shell-v3 #themeMenuToggle.is-dark .enterprise-theme-switch i{
    transform:translateX(18px)!important;
  }

  /* Make the account sheet's destructive action calm and consistent. */
  body.enterprise-shell-v3 .enterprise-user-popover .enterprise-user-action.danger,
  html[data-theme="dark"] body.enterprise-shell-v3 .enterprise-user-popover .enterprise-user-action.danger{
    min-height:60px!important;
  }
}

@media(max-width:390px){
  body.enterprise-shell-v3 .enterprise-user-popover{
    left:7px!important;right:7px!important;
    top:calc(68px + env(safe-area-inset-top))!important;
    max-height:calc(100dvh - 148px - env(safe-area-inset-top) - env(safe-area-inset-bottom))!important;
  }
}
