/*
 * TOTS YARD THEME SYSTEM
 * Change colours only in this token table. Components below consume tokens;
 * they must not introduce page-specific dark colours.
 */
:root{
  --theme-bg:#fbf8f5;
  --theme-sidebar:#ffffff;
  --theme-surface:#ffffff;
  --theme-surface-raised:#ffffff;
  --theme-surface-soft:#f5f1f3;
  --theme-section-header-bg:#ffffff;
  --theme-workspace-bg:#ffffff;
  --theme-selected-bg:#f6f2f4;
  --theme-window-bar-bg:#ffffff;
  --theme-control:#ffffff;
  --theme-control-hover:#f6f2f4;
  --theme-border:#b9aab5;
  --theme-border-strong:#8f7c8b;
  --theme-text:#302733;
  --theme-text-muted:#786d74;
  --theme-text-faint:#9d9299;
  --theme-primary-bg:#3f2948;
  --theme-primary-text:#ffffff;
  --theme-overlay:rgba(28,20,31,.48);
  --theme-success-bg:#e3f0e9;
  --theme-success-border:#78a48f;
  --theme-success-text:#34704b;
  --theme-warning-bg:#fff0d8;
  --theme-warning-border:#c89a58;
  --theme-warning-text:#8b612c;
  --theme-danger-bg:#fae4df;
  --theme-danger-border:#bd756a;
  --theme-danger-text:#9f463d;
  --theme-message-bg:#f5f1f3;
  --theme-message-border:#b9aab5;
  --theme-message-text:#302733;
  --theme-info-bg:#edf3f5;
  --theme-info-border:#91a7ae;
  --theme-info-text:#425d65;
  --theme-panel-bg:#ffffff;
  --theme-table-head-bg:#f5f1f3;
  --theme-table-row-bg:#ffffff;
  --theme-filter-bg:#ffffff;
  --theme-action-bg:#3f2948;
  --theme-action-text:#ffffff;
  --theme-shadow:0 14px 36px rgba(49,32,53,.12);
}

html body.dark-mode{
  --theme-bg:#020303;
  --theme-sidebar:#000000;
  --theme-surface:#020303;
  --theme-surface-raised:#0d0f10;
  --theme-surface-soft:#151718;
  --theme-section-header-bg:#020303;
  --theme-workspace-bg:#020303;
  --theme-selected-bg:#191b1c;
  --theme-window-bar-bg:#0d0f10;
  --theme-control:#111314;
  --theme-control-hover:#191b1c;
  --theme-border:#303436;
  --theme-border-strong:#565b5e;
  --theme-text:#f1f1f1;
  --theme-text-muted:#a5a8aa;
  --theme-text-faint:#73787a;
  --theme-primary-bg:#f4f4f4;
  --theme-primary-text:#111111;
  --theme-overlay:rgba(0,0,0,.72);
  --theme-success-bg:#14251d;
  --theme-success-border:#315c45;
  --theme-success-text:#83c7a2;
  --theme-warning-bg:#292113;
  --theme-warning-border:#604b24;
  --theme-warning-text:#d5b270;
  --theme-danger-bg:#291817;
  --theme-danger-border:#6c3531;
  --theme-danger-text:#e09a93;
  --theme-message-bg:#111314;
  --theme-message-border:#303436;
  --theme-message-text:#f1f1f1;
  --theme-info-bg:#111719;
  --theme-info-border:#344147;
  --theme-info-text:#c5d0d3;
  --theme-panel-bg:#020303;
  --theme-table-head-bg:#151718;
  --theme-table-row-bg:#020303;
  --theme-filter-bg:#111314;
  --theme-action-bg:#f4f4f4;
  --theme-action-text:#111111;
  --theme-shadow:0 20px 60px rgba(0,0,0,.52);
  /* Compatibility aliases: legacy components now inherit the token system. */
  --cream:var(--theme-bg);
  --white:var(--theme-surface);
  --surface:var(--theme-surface);
  --card-surface:var(--theme-surface);
  --soft:var(--theme-surface-soft);
  --mint:var(--theme-surface-soft);
  --line:var(--theme-border);
  --card-border:var(--theme-border);
  --ink:var(--theme-text);
  --muted:var(--theme-text-muted);
  --forest:var(--theme-primary-bg);
  --forest-2:var(--theme-primary-bg);
  --accent:var(--theme-primary-bg);
  color-scheme:dark;
}

/* Application canvas and navigation */
html body.dark-mode,
html body.dark-mode :is(.app-shell,.main,.workspace,.content,.page,.page-content,#nurseryDetailPage,.detail-view,.main-content,.detail-layout){background:var(--theme-bg)!important;color:var(--theme-text)!important}
html body.dark-mode :is(.sidebar,.detail-sidebar,.report-sidebar,.detail-tabs){background:var(--theme-sidebar)!important;border-color:var(--theme-border)!important;color:var(--theme-text)!important;box-shadow:none!important}
html body.dark-mode :is(.topbar,.detail-topbar,.page-header){background:var(--theme-surface-raised)!important;border-color:var(--theme-border)!important;color:var(--theme-text)!important;box-shadow:none!important}

/* Typography */
html body.dark-mode :is(h1,h2,h3,h4,h5,h6,strong,b,legend,label,th){color:var(--theme-text)!important}
html body.dark-mode :is(p,small,dt,.muted,.subtitle,.helper-text,.field-hint){color:var(--theme-text-muted)!important}
html body.dark-mode :is(.eyebrow,.section-kicker){color:var(--theme-text-faint)!important}

/* Surfaces: every ordinary card, panel and window shares one source. */
html body.dark-mode :is(.panel,.stat-card,.today-stat-card,.overview-group,.management-card,.nursery-card,.academic-year-row,.year-comparison-card,.finance-setting-card,.collection-summary-card,.collection-step,.billing-list-panel,.family-detail,.family-list-item,.linked-children article,.staff-data-row,.app-user-row,.permission-group,.checkbox-field,.theme-preference-card,.receipt-search-panel,.report-subject-search>div,.registration-history-sheet,.inline-report-document,.empty-structure,.future-billing,.contact-us-panel){background:var(--theme-surface)!important;border-color:var(--theme-border)!important;color:var(--theme-text)!important;box-shadow:none!important}
html body.dark-mode #nurseryDetailPage :is(.panel,.stat-card,.today-stat-card,.overview-group,.management-card,.nursery-card,.academic-year-row,.year-comparison-card,.finance-setting-card,.collection-summary-card,.collection-step,.billing-list-panel,.family-detail,.family-list-item,.linked-children article,.staff-data-row,.app-user-row,.permission-group,.checkbox-field,.theme-preference-card,.receipt-search-panel,.report-subject-search>div,.registration-history-sheet,.inline-report-document,.empty-structure,.future-billing,.contact-us-panel){background:var(--theme-surface)!important;border-color:var(--theme-border)!important;color:var(--theme-text)!important;box-shadow:none!important}
html body.dark-mode :is(.parent-contact-strip,.bill-contact,.serial-examples,.attendance-report-cards article,.cashbox-movement-summary article,.fee-load-result-grid>div,.summary-receipts>div,.payment-balance,.finance-rule-note,.family-detail-empty,.copy-classes-summary,.year-result-help){background:var(--theme-surface-soft)!important;border-color:var(--theme-border)!important;color:var(--theme-text)!important}

/* Section headings share one neutral token across the application. */
html body.dark-mode :is(.module-heading,.children-heading),
html body.dark-mode #nurseryDetailPage :is(.module-heading,.children-heading){
  background:var(--theme-section-header-bg)!important;
  border-color:var(--theme-border)!important;
  color:var(--theme-text)!important;
  box-shadow:none!important;
}

/* Workspaces and record panes use neutral surfaces throughout the app. */
html body.dark-mode :is(.family-workspace,.billing-workspace,.academic-workspace,.settings-workspace),
html body.dark-mode #nurseryDetailPage :is(.family-workspace,.billing-workspace,.academic-workspace,.settings-workspace){
  background:var(--theme-workspace-bg)!important;
  border-color:var(--theme-border)!important;
  color:var(--theme-text)!important;
  box-shadow:none!important;
}
html body.dark-mode :is(.family-detail,.bill-detail,.family-profile-head,.parent-contact-strip,.linked-children,.linked-children article,.family-list,.family-list-item),
html body.dark-mode #nurseryDetailPage :is(.family-detail,.bill-detail,.family-profile-head,.parent-contact-strip,.linked-children,.linked-children article,.family-list,.family-list-item){
  background:var(--theme-surface)!important;
  border-color:var(--theme-border)!important;
  color:var(--theme-text)!important;
  box-shadow:none!important;
}
html body.dark-mode :is(.family-list-item.active,.billing-row.active,.internal-message-item.active,.staff-summary article.active),
html body.dark-mode #nurseryDetailPage :is(.family-list-item.active,.billing-row.active,.internal-message-item.active,.staff-summary article.active){
  background:var(--theme-selected-bg)!important;
  border-color:var(--theme-border-strong)!important;
  color:var(--theme-text)!important;
  box-shadow:inset 3px 0 var(--theme-text)!important;
}

/* Forms and controls */
html body.dark-mode :is(input,select,textarea,.list-search,.family-search,.academic-search,.search,.search input,.signed-in-user-chip,.header-theme-button,.account-tools-button,.secondary-button,.icon-button){background:var(--theme-control)!important;border-color:var(--theme-border)!important;color:var(--theme-text)!important;box-shadow:none!important}
html body.dark-mode #nurseryDetailPage :is(input,select,textarea,.list-search,.family-search,.academic-search,.search,.search input,.signed-in-user-chip,.header-theme-button,.account-tools-button,.secondary-button,.icon-button,.fee-row-actions button){background:var(--theme-control)!important;border-color:var(--theme-border)!important;color:var(--theme-text)!important;box-shadow:none!important}
html body.dark-mode :is(input,select,textarea)::placeholder{color:var(--theme-text-faint)!important}
html body.dark-mode :is(input,select,textarea,.secondary-button,.icon-button):hover{background:var(--theme-control-hover)!important;border-color:var(--theme-border-strong)!important;color:var(--theme-text)!important}
html body.dark-mode :is(input,select,textarea):focus{border-color:var(--theme-border-strong)!important;box-shadow:0 0 0 3px rgba(255,255,255,.07)!important;outline:none!important}

/* Buttons */
html body.dark-mode :is(.primary-button,.collection-submit,button.primary-action){background:var(--theme-primary-bg)!important;border-color:var(--theme-primary-bg)!important;color:var(--theme-primary-text)!important;box-shadow:none!important}
html body.dark-mode :is(.primary-button,.collection-submit,button.primary-action):hover{filter:brightness(1.06);transform:none!important}

/* Tables and repeated rows */
html body.dark-mode :is(.fees-head,.discount-head,.staff-data-head,.attendance-head,.attendance-data-head,.academic-data-head,.registration-history-head,.report-preview-columns,.finance-ledger-head,.billing-list-head,.cashbox-method-head,.promotion-student-head,.app-user-head,.annual-result-head,.promotion-map-header){background:var(--theme-surface-soft)!important;border-color:var(--theme-border)!important;color:var(--theme-text-muted)!important}
html body.dark-mode #nurseryDetailPage :is(.fees-head,.discount-head,.staff-data-head,.attendance-head,.attendance-data-head,.academic-data-head,.registration-history-head,.report-preview-columns,.finance-ledger-head,.billing-list-head,.cashbox-method-head,.promotion-student-head,.app-user-head,.annual-result-head,.promotion-map-header){background:var(--theme-surface-soft)!important;border-color:var(--theme-border)!important;color:var(--theme-text-muted)!important}
html body.dark-mode :is(table,tr,td,th,.fees-row,.discount-row,.finance-ledger-row,.registration-history-row,.promotion-student-row,.annual-result-row,.promotion-map-row,.report-preview-row){border-color:var(--theme-border)!important}
html body.dark-mode :is(tr:hover td,.clickable-report-row:hover){background:var(--theme-control-hover)!important}

/* Navigation states */
html body.dark-mode #nurseryDetailPage .detail-tabs button{background:transparent!important;border-color:var(--theme-border)!important;color:var(--theme-text)!important;box-shadow:none!important}
html body.dark-mode #nurseryDetailPage .detail-tabs button:hover{background:var(--theme-control-hover)!important;border-color:var(--theme-border-strong)!important;color:var(--theme-text)!important}
html body.dark-mode #nurseryDetailPage .detail-tabs button.active,
html body.dark-mode #nurseryDetailPage .menu-subgroup:not(.collapsed)>.menu-group-toggle{background:var(--theme-control-hover)!important;border-color:var(--theme-border-strong)!important;color:var(--theme-text)!important}
html body.dark-mode :is(.detail-tab-icon,.overview-card-icon,.today-stat-icon,.family-avatar,.child-avatar,.summary-icon,.management-icon,.notification-summary i){background:var(--theme-surface-soft)!important;border-color:var(--theme-border)!important;color:var(--theme-text-muted)!important}

/* Dialogs, popovers and messages */
html body.dark-mode :is(.parent-modal-backdrop,.modal-backdrop,.profile-drawer-backdrop,.setup-wizard-backdrop){background:var(--theme-overlay)!important}
html body.dark-mode :is(.parent-modal,.modal,.modal-card,.profile-drawer,.selection-modal,.internal-messages-modal,.setup-wizard,.login-card,.shortcut-picker){background:var(--theme-surface-raised)!important;border-color:var(--theme-border)!important;color:var(--theme-text)!important;box-shadow:var(--theme-shadow)!important}
html body.dark-mode :is(.parent-modal-header,.parent-modal-footer,.modal-heading,.profile-section,.student-drawer-actions,.form-actions,.shortcut-picker>footer){background:var(--theme-surface-raised)!important;border-color:var(--theme-border)!important}
html body.dark-mode .shortcut-picker>b,
html body.dark-mode .shortcut-picker>footer,
html body.dark-mode .shortcut-picker .shortcut-picker-list{background:var(--theme-window-bar-bg)!important;border-color:var(--theme-border)!important;color:var(--theme-text)!important}
html body.dark-mode :is(.account-tools-menu,.collection-parent-results,.discount-account-results,.global-search-results){background:var(--theme-surface-raised)!important;border-color:var(--theme-border)!important;box-shadow:var(--theme-shadow)!important}

/* One continuous window surface. This replaces the legacy #262027 pane fill. */
html body.dark-mode :is(.parent-modal-backdrop,.modal-backdrop,.profile-drawer-backdrop,.setup-wizard-backdrop) > :is(.parent-modal,.modal,.modal-card,.profile-drawer,.selection-modal,.internal-messages-modal,.setup-wizard),
html body.dark-mode :is(.parent-modal,.modal,.modal-card,.profile-drawer,.selection-modal,.internal-messages-modal,.setup-wizard) > :is(.parent-modal-header,.parent-modal-footer,.modal-heading,.form-actions),
html body.dark-mode :is(.parent-modal,.modal,.modal-card,.profile-drawer,.selection-modal,.internal-messages-modal,.setup-wizard) :is(.parent-pane,.parent-pane.active,.parent-fields,.secondary-fields,.modal-body,.test-reset-body,.student-photo-crop-body,.discount-details-grid,.setup-wizard-scroll){
  background:var(--theme-surface-raised)!important;
  color:var(--theme-text)!important;
  border-color:var(--theme-border)!important;
}
html body.dark-mode :is(.parent-modal,.modal,.modal-card,.profile-drawer,.selection-modal,.internal-messages-modal,.setup-wizard) :is(.primary-button,.collection-submit,button.primary-action){background:var(--theme-primary-bg)!important;border-color:var(--theme-primary-bg)!important;color:var(--theme-primary-text)!important}
html body.dark-mode :is(.parent-modal,.modal,.modal-card,.profile-drawer,.selection-modal,.internal-messages-modal,.setup-wizard) :is(.secondary-button,.icon-button,input,select,textarea){background:var(--theme-control)!important;border-color:var(--theme-border)!important;color:var(--theme-text)!important}

/* Window bars, steps and actions are controlled here, never by page colours. */
html body.dark-mode :is(.parent-modal,.payment-modal,.modal,.modal-card,.selection-modal,.internal-messages-modal,.setup-wizard) :is(.parent-modal-header,.parent-modal-footer,.modal-heading,.form-actions){
  background:var(--theme-window-bar-bg)!important;
  border-color:var(--theme-border)!important;
  color:var(--theme-text)!important;
}
html body.dark-mode :is(.parent-tabs,.parent-pane,.parent-fields,.secondary-fields){
  background:var(--theme-surface-raised)!important;
  border-color:var(--theme-border)!important;
  color:var(--theme-text)!important;
}
html body.dark-mode .parent-tabs button{
  background:var(--theme-control)!important;
  border-color:var(--theme-border)!important;
  color:var(--theme-text-muted)!important;
  box-shadow:none!important;
}
html body.dark-mode .parent-tabs button.active{
  background:var(--theme-selected-bg)!important;
  border-color:var(--theme-border-strong)!important;
  color:var(--theme-text)!important;
  box-shadow:0 0 0 2px var(--theme-text)!important;
}
html body.dark-mode .parent-tabs button :is(span,b),
html body.dark-mode :is(.secondary-toggle>span,.parent-modal-footer i){
  background:var(--theme-surface-soft)!important;
  border-color:var(--theme-border)!important;
  color:var(--theme-text)!important;
}
html body.dark-mode #nurseryDetailPage .primary-button,
html body.dark-mode :is(.parent-modal,.payment-modal,.modal,.modal-card,.selection-modal,.internal-messages-modal,.setup-wizard) .primary-button{
  background:var(--theme-primary-bg)!important;
  border-color:var(--theme-primary-bg)!important;
  color:var(--theme-primary-text)!important;
  box-shadow:none!important;
}

/* High-specificity endpoints for legacy ID rules and generated modal forms. */
html body.dark-mode .parent-modal-backdrop .parent-modal form .parent-modal-footer > div > button.primary-button,
html body.dark-mode .parent-modal-backdrop .parent-modal form button[type="submit"].primary-button{
  background:var(--theme-primary-bg,#f4f4f4)!important;
  border-color:var(--theme-primary-bg,#f4f4f4)!important;
  color:var(--theme-primary-text,#111111)!important;
  box-shadow:none!important;
}
html body.dark-mode #nurseryDetailPage :is(.hero-tools,.quick-actions,.primary-shortcuts){
  background:var(--theme-surface-raised,#0d0f10)!important;
  border-color:var(--theme-border,#303436)!important;
  color:var(--theme-text,#f1f1f1)!important;
  box-shadow:none!important;
}
html body.dark-mode .topbar{
  background:var(--theme-surface-raised,#0d0f10)!important;
  border-color:var(--theme-border,#303436)!important;
  color:var(--theme-text,#f1f1f1)!important;
}

/* Semantic colours are intentionally the only non-neutral colours. */
html body.dark-mode :is(.status.active,.bill-status.paid,.app-user-row em.active,.promotion-result-pill.passed){background:var(--theme-success-bg)!important;border-color:var(--theme-success-border)!important;color:var(--theme-success-text)!important}
html body.dark-mode :is(.warning,.bill-status.due,.promotion-result-pill.repeat){background:var(--theme-warning-bg)!important;border-color:var(--theme-warning-border)!important;color:var(--theme-warning-text)!important}
html body.dark-mode :is(.bill-status.overdue,.promotion-result-pill.pending,.form-error,.profile-alert){background:var(--theme-danger-bg)!important;border-color:var(--theme-danger-border)!important;color:var(--theme-danger-text)!important}

/* Message system: future themes change these categories only in the table. */
html body.dark-mode :is(.empty-parent-note,.family-detail-empty,.report-menu-empty,.empty-structure,.collection-browser-empty,.empty-report,.report-empty,.no-results-message){
  background:var(--theme-message-bg)!important;
  border-color:var(--theme-message-border)!important;
  color:var(--theme-message-text)!important;
  box-shadow:none!important;
}
html body.dark-mode :is(.empty-parent-note,.family-detail-empty,.report-menu-empty,.empty-structure,.collection-browser-empty,.empty-report,.report-empty,.no-results-message) :is(strong,h3,span,p,small){
  color:inherit!important;
}
html body.dark-mode :is(.full-access-explanation,.programme-confirm-message,.year-result-help,.copy-classes-summary){
  background:var(--theme-info-bg)!important;
  border-color:var(--theme-info-border)!important;
  color:var(--theme-info-text)!important;
}
html body.dark-mode :is(.finance-rule-note,.promotion-run-notice.warning,.payment-balance:not(.balanced)){
  background:var(--theme-warning-bg)!important;
  border-color:var(--theme-warning-border)!important;
  color:var(--theme-warning-text)!important;
}
html body.dark-mode :is(.approval-success,.promotion-run-notice.ready,.payment-balance.balanced){
  background:var(--theme-success-bg)!important;
  border-color:var(--theme-success-border)!important;
  color:var(--theme-success-text)!important;
}
html body.dark-mode :is(.app-user-validation-banner,.promotion-run-notice.blocked,.structure-delete-content){
  background:var(--theme-danger-bg)!important;
  border-color:var(--theme-danger-border)!important;
  color:var(--theme-danger-text)!important;
}

/* Printing remains paper-white regardless of screen theme. */
@media print{html body.dark-mode .a4-statement{background:#fff!important;color:#1c1c1c!important}html body.dark-mode .a4-statement *{color:#1c1c1c!important;border-color:#bbb!important}}

/* Final component map: real screen containers, loaded last so retired palette
   selectors cannot leak through. */
#nurseryDetailPage .detail-tabs .contact-us-menu-item .detail-tab-label{
  white-space:nowrap!important;
  word-break:keep-all!important;
  overflow-wrap:normal!important;
  letter-spacing:.65px!important;
  font-size:12px!important;
}

/* Standalone navigation tabs: the arrow must not affect the true centre. */
#nurseryDetailPage .detail-tabs :is(.overview-menu-item,.contact-us-menu-item){
  position:relative!important;
  display:grid!important;
  grid-template-columns:1fr!important;
  place-items:center!important;
  padding-inline:38px!important;
  text-align:center!important;
}
#nurseryDetailPage .detail-tabs :is(.overview-menu-item,.contact-us-menu-item) .detail-tab-label{
  grid-column:1!important;
  width:max-content!important;
  max-width:none!important;
  white-space:nowrap!important;
  word-break:keep-all!important;
  overflow-wrap:normal!important;
  text-align:center!important;
  letter-spacing:.55px!important;
  font-size:11.5px!important;
  line-height:1!important;
}
#nurseryDetailPage .detail-tabs :is(.overview-menu-item,.contact-us-menu-item)>b{
  position:absolute!important;
  inset-inline-end:16px!important;
  top:50%!important;
  transform:translateY(-50%)!important;
  margin:0!important;
}

html body.dark-mode #nurseryDetailPage #detailAnnualResultsView :is(.annual-results-toolbar,.annual-results-table),
html body.dark-mode #nurseryDetailPage #detailAnnualPromotionView :is(.promotion-run-years,.promotion-run-toolbar,.promotion-run-table,.promotion-run-history),
html body.dark-mode #nurseryDetailPage #detailStaffView :is(.staff-list,.staff-summary article),
html body.dark-mode #nurseryDetailPage #detailAttendanceView :is(.attendance-register,.attendance-summary article){
  background:var(--theme-panel-bg)!important;
  color:var(--theme-text)!important;
  border-color:var(--theme-border)!important;
  box-shadow:none!important;
}

html body.dark-mode #nurseryDetailPage #detailAnnualResultsView :is(.annual-result-head),
html body.dark-mode #nurseryDetailPage #detailAnnualPromotionView :is(.promotion-student-head),
html body.dark-mode #nurseryDetailPage #detailStaffView :is(.staff-head,.staff-data-table>.staff-data-row:first-child),
html body.dark-mode #nurseryDetailPage #detailAttendanceView :is(.attendance-head,.attendance-data-head){
  background:var(--theme-table-head-bg)!important;
  color:var(--theme-text-muted)!important;
  border-color:var(--theme-border)!important;
}

html body.dark-mode #nurseryDetailPage #detailAnnualResultsView .annual-result-row:not(.annual-result-head),
html body.dark-mode #nurseryDetailPage #detailAnnualPromotionView .promotion-student-row:not(.promotion-student-head),
html body.dark-mode #nurseryDetailPage #detailStaffView .staff-data-row,
html body.dark-mode #nurseryDetailPage #detailAttendanceView .attendance-row:not(.attendance-head){
  background:var(--theme-table-row-bg)!important;
  color:var(--theme-text)!important;
  border-color:var(--theme-border)!important;
  box-shadow:none!important;
}

html body.dark-mode #nurseryDetailPage #detailAnnualPromotionView .promotion-run-years>span{
  background:var(--theme-info-bg)!important;
  color:var(--theme-info-text)!important;
  border:1px solid var(--theme-info-border)!important;
}

html body.dark-mode #nurseryDetailPage :is(#saveAnnualResults,#saveAttendanceButton,.add-staff-button,#approveAnnualPromotion),
html body.dark-mode #nurseryDetailPage :is(#detailAnnualResultsView,#detailAnnualPromotionView,#detailStaffView,#detailAttendanceView) .primary-button{
  background:var(--theme-action-bg)!important;
  background-image:none!important;
  color:var(--theme-action-text)!important;
  border-color:var(--theme-action-bg)!important;
  box-shadow:none!important;
}

html body.dark-mode #nurseryDetailPage #detailStaffView .staff-person>i,
html body.dark-mode #nurseryDetailPage #detailAttendanceView .attendance-row .student-avatar{
  background:var(--theme-surface-soft)!important;
  color:var(--theme-text-muted)!important;
  border-color:var(--theme-border)!important;
}

/* Dark detail-screen contract.
   This is deliberately the final layer: legacy page CSS may describe layout,
   but every detail screen gets its colour from the theme table above. */
html body.dark-mode #nurseryDetailPage .detail-view,
html body.dark-mode #nurseryDetailPage .detail-view.active{
  background:var(--theme-bg)!important;
  color:var(--theme-text)!important;
}

html body.dark-mode #nurseryDetailPage .detail-view.active :is(
  .panel,.academic-years-layout,.academic-year-list,.academic-year-list-panel,
  .academic-data-table,.fees-table,.discount-table,.staff-list,.staff-data-table,
  .attendance-register,.attendance-table,.annual-results-table,.promotion-run-table,
  .promotion-run-history,.promotion-map-table,.app-users-table,.registration-history-sheet,
  .report-preview,.report-preview-table,.finance-ledger,.billing-list-panel,
  .cashbox-methods,.family-workspace,.family-detail,.family-list,.collection-step,
  .collection-form-card,.collection-summary-card,.finance-setting-card,.contact-us-panel
){
  background:var(--theme-panel-bg)!important;
  background-image:none!important;
  border-color:var(--theme-border)!important;
  color:var(--theme-text)!important;
  box-shadow:none!important;
}

html body.dark-mode #nurseryDetailPage .detail-view.active :is(
  .academic-year-row,.academic-data-row,.fees-row,.catalogue-row,.discount-row,
  .staff-data-row,.attendance-row,.annual-result-row,.promotion-student-row,
  .promotion-map-row,.app-user-row,.registration-history-row,.report-preview-row,
  .finance-ledger-row,.billing-row,.cashbox-row,.payment-method-row
){
  background:var(--theme-table-row-bg)!important;
  background-image:none!important;
  border-color:var(--theme-border)!important;
  color:var(--theme-text)!important;
  box-shadow:none!important;
}

html body.dark-mode #nurseryDetailPage .detail-view.active :is(
  .academic-year-head,.academic-data-head,.fees-head,.catalogue-head,.discount-head,
  .staff-head,.staff-data-head,.attendance-head,.attendance-data-head,.annual-result-head,
  .promotion-student-head,.promotion-map-header,.app-user-head,.registration-history-head,
  .report-preview-columns,.finance-ledger-head,.billing-list-head,.cashbox-method-head
){
  background:var(--theme-table-head-bg)!important;
  background-image:none!important;
  border-color:var(--theme-border)!important;
  color:var(--theme-text-muted)!important;
  box-shadow:none!important;
}

html body.dark-mode #nurseryDetailPage .detail-view.active :is(
  input,select,textarea,.filters,.toolbar,.academic-year-form-card,
  .annual-results-toolbar,.promotion-run-years,.promotion-run-toolbar,
  .cashbox-movement-filters,.receipt-search-panel,.report-subject-search>div
){
  background:var(--theme-control)!important;
  background-image:none!important;
  border-color:var(--theme-border)!important;
  color:var(--theme-text)!important;
  box-shadow:none!important;
}

html body.dark-mode #nurseryDetailPage .detail-view.active :is(
  .primary-button,button.primary-action,.collection-submit,.add-academic-year-button,
  .add-grade-button,.add-class-button,.add-fee-button,.add-discount-button,.add-staff-button
){
  background:var(--theme-action-bg)!important;
  background-image:none!important;
  border-color:var(--theme-action-bg)!important;
  color:var(--theme-action-text)!important;
  box-shadow:none!important;
}

html body.dark-mode #nurseryDetailPage .detail-view.active :is(.academic-year-row,.academic-data-row) button:not(.primary-button):not(.danger-action-button){
  background:transparent!important;
  color:var(--theme-text)!important;
  border-color:transparent!important;
}

/* Keep meaning-based colours as the only exceptions to the neutral dark theme. */
html body.dark-mode #nurseryDetailPage .detail-view.active :is(.status.active,.current-year-badge,.promotion-result-pill.passed){
  background:var(--theme-success-bg)!important;
  border-color:var(--theme-success-border)!important;
  color:var(--theme-success-text)!important;
}
html body.dark-mode #nurseryDetailPage .detail-view.active :is(.danger-action-button,.year-delete,.fee-delete-button){
  color:var(--theme-danger-text)!important;
}

/* Grade and class cards are generated at runtime and have a legacy
   .management-card fill. Anchor them to the theme contract explicitly. */
html body.dark-mode #nurseryDetailPage #detailGradesView.detail-view.active .grade-management-grid > .management-card,
html body.dark-mode #nurseryDetailPage #detailRoomsView.detail-view.active .room-management-grid > .management-card{
  background:var(--theme-panel-bg)!important;
  background-color:var(--theme-panel-bg)!important;
  background-image:none!important;
  border-color:var(--theme-border)!important;
  color:var(--theme-text)!important;
  box-shadow:none!important;
}

html body.dark-mode #nurseryDetailPage :is(#detailGradesView,#detailRoomsView).detail-view.active .management-card :is(.management-card-top,.management-copy,dl,dl>div){
  background:transparent!important;
  background-image:none!important;
  border-color:var(--theme-border)!important;
  color:var(--theme-text)!important;
}

html body.dark-mode #nurseryDetailPage :is(#detailGradesView,#detailRoomsView).detail-view.active .management-card :is(.secondary-button,.card-manage-button){
  background:var(--theme-control)!important;
  border-color:var(--theme-border)!important;
  color:var(--theme-text)!important;
  box-shadow:none!important;
}
