/* Material dark palette: tonal surfaces, semantic text and state roles.
   Based on MUI's #121212 dark background. Keep light mode untouched. */
:root[data-tmf-theme="dark"] {
  color-scheme: dark;
  --md-background: #0d1117;
  --md-surface-low: #171d26;
  --md-surface: #202732;
  --md-surface-container: #2b323e;
  --md-surface-high: #343d4a;
  --md-surface-highest: #3e4858;
  --md-sidebar: #1c2b40;
  --md-sidebar-selected: #3563bd;
  --md-sidebar-hover: #2d4665;
  --md-on-surface: #f2f4f7;
  --md-on-surface-variant: #c9d2df;
  --md-on-surface-muted: #b0bece;
  --md-outline: #8a97a8;
  --md-outline-variant: #3c4653;
  --md-primary: #aacaff;
  --md-on-primary: #17375f;
  --md-primary-container: #284666;
  --md-on-primary-container: #e1edff;
  --md-primary-button: #2c61b1;
  --md-focus: #acd0ff;
  --md-hover: rgba(255,255,255,.075);
  --md-selected: rgba(170,202,255,.16);
  --ink: var(--md-on-surface);
  --muted: var(--md-on-surface-variant);
  --line: var(--md-outline-variant);
  --pale: var(--md-surface-high);
  --blue: var(--md-primary);
  --deep: var(--md-on-primary-container);
  --green: #88d9a8;
  --amber: #ffce87;
  --red: #ffaaa8;
  --dm-canvas: var(--md-background);
  --dm-shell: var(--md-surface-low);
  --dm-main: var(--md-surface);
  --dm-raised: var(--md-surface-container);
  --dm-inset: var(--md-surface-high);
  --dm-fg: var(--md-on-surface);
  --dm-secondary: var(--md-on-surface-variant);
  --dm-muted: var(--md-on-surface-muted);
  --dm-accent: var(--md-primary);
  --dm-cta: var(--md-primary-button);
}

:root[data-tmf-theme="dark"] body,
:root[data-tmf-theme="dark"] body:has(.app-frame) {
  background:var(--dm-canvas)!important;
  background-image:none!important;
  color:var(--dm-fg)!important;
}
/* The shell and page canvas are distinct levels, with no legacy white inset. */
:root[data-tmf-theme="dark"] body:has(.app-frame) .app-frame,
:root[data-tmf-theme="dark"] body:has(.app-frame) .app-frame.sidebar-collapsed {
  background:var(--dm-shell)!important;
  color:var(--dm-fg)!important;
  padding:0!important;
  border:0!important;
  outline:0!important;
  box-shadow:0 16px 48px rgba(0,0,0,.33)!important;
}
/* No separate fill for the main page canvas. Cards and panels retain their own surfaces. */
:root[data-tmf-theme="dark"] body:has(.app-frame) .main,
:root[data-tmf-theme="dark"] body:has(.app-frame) .page-footer {
  background:transparent!important;
  background-image:none!important;
  color:var(--dm-fg)!important;
}
:root[data-tmf-theme="dark"] body:has(.app-frame) .topbar {
  background:var(--dm-shell)!important;
  color:var(--dm-fg)!important;
  border:0!important;
  box-shadow:none!important;
  margin-left:0!important;
}
:root[data-tmf-theme="dark"] body:has(.app-frame) .sidebar {
  background:var(--md-sidebar)!important;
  color:var(--dm-fg)!important;
}
:root[data-tmf-theme="dark"] .sidebar .nav-item {color:#e1e4e9!important}
:root[data-tmf-theme="dark"] .sidebar .nav-item.active {
  background:var(--md-sidebar-selected)!important;color:#fff!important;
}
:root[data-tmf-theme="dark"] .sidebar .nav-item:hover {background:var(--md-sidebar-hover)!important;color:#fff!important}
:root[data-tmf-theme="dark"] .sidebar .sidebar-add {
  background:#e5e9f1!important;color:#174375!important;
}
:root[data-tmf-theme="dark"] .sidebar .sidebar-toggle {
  background:#242424!important;color:#e5e8ed!important;border-color:var(--md-outline)!important;
}
:root[data-tmf-theme="dark"] .sidebar .sidebar-toggle:hover {background:var(--md-surface-highest)!important}
:root[data-tmf-theme="dark"] .sidebar .nav-label,
:root[data-tmf-theme="dark"] .sidebar .sidebar-footer,
:root[data-tmf-theme="dark"] .sidebar .sidebar-summary-title,
:root[data-tmf-theme="dark"] .sidebar .sidebar-summary .small {
  color:#d0d4dd!important;opacity:1!important;
}
:root[data-tmf-theme="dark"] .sidebar .progress-track {background:#474d58!important}
:root[data-tmf-theme="dark"] .sidebar .progress-fill {background:#a6c9ff!important}
:root[data-tmf-theme="dark"] .brand-name {color:#bcd6ff!important}
:root[data-tmf-theme="dark"] .brand-sub,
:root[data-tmf-theme="dark"] .brand-place {color:#c4cbd7!important}
:root[data-tmf-theme="dark"] .brand-mark {background:#355e99!important;color:#fff!important}
:root[data-tmf-theme="dark"] .brand-version {
  color:#e6eaf2!important;background:#3f4653!important;
}
:root[data-tmf-theme="dark"] .top-tools .icon-button,
:root[data-tmf-theme="dark"] .user-menu {color:#d5d9e0!important}
:root[data-tmf-theme="dark"] .top-tools .icon-button:hover {
  color:#fff!important;background:#393e46!important;
}
:root[data-tmf-theme="dark"] .theme-toggle {background:var(--md-surface-highest)!important;color:#e9edf5!important}
:root[data-tmf-theme="dark"] .global-search .icon {color:#b5bdc9!important}
:root[data-tmf-theme="dark"] .global-search input {background:var(--md-surface-high)!important;color:#f4f5f6!important}
:root[data-tmf-theme="dark"] .user-meta span {color:#bbc2cf!important}

/* Surface roles: cards, nested panels and selected states have distinct elevation. */
:root[data-tmf-theme="dark"] :is(
 .panel,.stat-card,.target-panel,.chart-box,.school-goal,.school-goal-child,
 .school-goal-juz,.student-card,.family-switch,.family-card:not(.active),
 .task-panel,.task-row,.form-panel,.capaian-leaderboard,.capaian-rank-row,
 .tasmi-event-panel,.tasmi-event-row,.detail-summary .detail-metric,
 .followup-card,.followup-reply,.version-entry,.recap-card,
 .recap-metrics>div,.feedback-metrics>div,.feedback-ticket,.surah-tile,
 .halaqah-card:not(.featured),.recap-notes,.recap-review,
 .feedback-response,.feedback-execution,.info-box,.task-teacher-note,
 .school-goal-next,.school-goal-footer,.juz-auto-row,.juz-auto-status,
 .record-card,.success-box,.card-actions,.school-goal-juz.is-locked
) {
  background:var(--dm-raised)!important;
  border-color:var(--line)!important;
  color:var(--dm-fg)!important;
}
:root[data-tmf-theme="dark"] :is(
 .greeting,.preview-strip,.demo-banner,.detail-summary>div,
 .student-card-foot,.recap-marker,.capaian-rank-meta,
 .tasmi-invite-options,.school-goal-juz.is-active,.school-goal-juz.is-passed,
 .profile-preview,.empty-icon,.recap-review,.recap-notes,.feedback-response,
 .feedback-execution
) {
  border-color:var(--line)!important;
}
:root[data-tmf-theme="dark"] :is(
 .greeting,.preview-strip,.demo-banner,.school-goal-next,
 .recap-notes,.recap-review,.feedback-response,.feedback-execution,
 .detail-summary>div,.card-actions,.surah-tile.partial,.surah-tile.complete
) {
  background:var(--dm-inset)!important;
  color:var(--dm-fg)!important;
}
:root[data-tmf-theme="dark"] .school-goal-juz.is-active {background:var(--md-primary-container)!important}
:root[data-tmf-theme="dark"] .school-goal-juz.is-passed {background:#264338!important}
:root[data-tmf-theme="dark"] .school-goal-juz.is-locked {background:#292b30!important}
:root[data-tmf-theme="dark"] .halaqah-card.featured {
  background:var(--md-primary-container)!important;color:#fff!important;border-color:#416da8!important;
}
:root[data-tmf-theme="dark"] .halaqah-card.featured :is(h3,.tiny-label,.halaqah-bottom,.halaqah-bottom span) {
  color:#f0f5ff!important;
}
:root[data-tmf-theme="dark"] .halaqah-card:not(.featured) :is(h3,.tiny-label,.halaqah-bottom,.halaqah-bottom span) {
  color:#d7dce5!important;
}
:root[data-tmf-theme="dark"] .family-card.active {
  background:var(--md-primary-container)!important;color:#fff!important;border-color:#4c80bc!important;
}
:root[data-tmf-theme="dark"] .family-card.active :is(strong,small,.family-card-meta) {
  color:#f0f5ff!important;
}
/* Keep the existing cream task count chip legible on the selected child. */
:root[data-tmf-theme="dark"] .family-card.active .family-card-task {
  color:#704700!important;background:#ffedbb!important;
}
:root[data-tmf-theme="dark"] .recap-timeline:before {background:#4b5666!important}
:root[data-tmf-theme="dark"] .recap-marker {background:var(--md-primary-container)!important;color:#dbe7ff!important}
:root[data-tmf-theme="dark"] :is(.followup-reply,.version-entry,.feedback-ticket,.recap-card) {
  border-color:var(--line)!important;
}
:root[data-tmf-theme="dark"] :is(.panel,.capaian-leaderboard,.student-card,.family-card,.tasmi-event-panel) {
  box-shadow:none!important;
}

/* Text legibility. Explicit light-mode colors must not remain on dark surfaces. */
:root[data-tmf-theme="dark"] :is(h1,h2,h3,h4,h5,h6,
 .student-cell strong,.table-surah,.capaian-rank-info strong,
 .capaian-rank-meta strong,.recap-top h3,.recap-metrics strong,
 .feedback-metrics strong,.version-head h2,.version-head strong,
 .school-goal-juz-top strong,.school-goal-next strong,
 .feedback-response strong,.feedback-execution strong,
 .tasmi-event-info strong,.stat-value,.ring-center strong,
 .task-row strong,.detail-summary strong
) {color:var(--dm-fg)!important}
:root[data-tmf-theme="dark"] :is(
 .muted,.stat-label,.stat-foot,.stat-value span,
 .table-sub,.student-cell span:not(.avatar),.source-label,
 .list-notes,.notes-content,.notes-review,.chart-legend,.chart-foot,
 .panel-footer,.page-footer,.student-card-line,.ring-center span,
 .family-card-meta,.task-row p,.task-row small,
 .recap-text,.recap-notes,.recap-top p,.recap-type,
 .feedback-ticket-meta,.feedback-ticket-message,.feedback-entry small,
 .version-entry ul,.version-head small,.followup-title p,
 .school-goal-juz-note,.school-goal-footer,.school-goal-next,
 .capaian-rank-info span,.capaian-rank-meta span,.capaian-ranking-stats,
 .tasmi-event-info span,.tasmi-event-panel p,.feedback-history-details,
 .feedback-response p,.feedback-execution p,.school-goal p,
 .target-panel p,.recap-metrics span,.feedback-metrics span,
 .date-filters,.student-card-foot,.target-student .small
) {color:var(--dm-secondary)!important}
:root[data-tmf-theme="dark"] :is(
 .field label,.capaian-filters label,.attendance-toolbar label,
 .attendance-field,.checkbox-row label,.password-guide .rule
) {color:#e0e4ea!important}
:root[data-tmf-theme="dark"] .password-guide .rule.valid {color:#8fe8ae!important}
:root[data-tmf-theme="dark"] :is(.section-head p,.panel-header p,.capaian-leaderboard p,.preview-copy span,.brand-place) {
  color:var(--dm-secondary)!important;
}
:root[data-tmf-theme="dark"] .empty-state {color:var(--dm-secondary)!important}
:root[data-tmf-theme="dark"] .empty-state h3 {color:var(--dm-fg)!important}
:root[data-tmf-theme="dark"] .eyebrow,
:root[data-tmf-theme="dark"] :is(a,.button.link,.student-link:hover strong,.tab.active) {
  color:var(--dm-accent)!important;
}
:root[data-tmf-theme="dark"] :is(.count-pill,.recap-type) {
  color:#d3e6ff!important;
}
:root[data-tmf-theme="dark"] .count-pill {
  background:#394e69!important;
}
:root[data-tmf-theme="dark"] .notes-review {
  border-color:var(--line)!important;
}

/* Buttons and fields. All primary buttons have white text on a sufficiently dark blue. */
:root[data-tmf-theme="dark"] .button:not(.primary):not(.soft):not(.link):not(.danger) {
  background:var(--md-surface-high)!important;color:#edf0f4!important;border-color:var(--md-outline)!important;
}
:root[data-tmf-theme="dark"] .button.primary,
:root[data-tmf-theme="dark"] .attendance-launch .button.primary,
:root[data-tmf-theme="dark"] .attendance-manual .button.primary {
  background:var(--dm-cta)!important;color:#fff!important;border-color:#3b70c4!important;
  box-shadow:none!important;
}
:root[data-tmf-theme="dark"] .button.primary:hover {background:#326bc7!important}
:root[data-tmf-theme="dark"] .button.soft,
:root[data-tmf-theme="dark"] a.button.soft,
:root[data-tmf-theme="dark"] .chip.active {
  background:var(--md-primary-container)!important;color:#e5f0ff!important;border-color:#506a8f!important;
}
:root[data-tmf-theme="dark"] .button.soft:hover,
:root[data-tmf-theme="dark"] .chip.active:hover {background:#3b5170!important}
:root[data-tmf-theme="dark"] .button.danger {
  color:#ffbaba!important;background:#4b3037!important;border-color:#7c4652!important;
}
:root[data-tmf-theme="dark"] :is(.chip,.tab,.icon-button,.card-actions .icon-button) {
  color:#d0d6df!important;
}
:root[data-tmf-theme="dark"] .chip {
  background:var(--md-surface-high)!important;border-color:var(--md-outline)!important;
}
:root[data-tmf-theme="dark"] :is(.chip:hover,.icon-button:hover,.card-actions .icon-button:hover) {
  background:var(--md-surface-highest)!important;color:#fff!important;
}
:root[data-tmf-theme="dark"] :is(input:not([type="checkbox"]):not([type="radio"]),select,textarea) {
  background:var(--md-surface-high)!important;color:#f3f5f7!important;
  border-color:var(--md-outline)!important;
}
:root[data-tmf-theme="dark"] :is(input,textarea)::placeholder {color:#bdc5d0!important;opacity:1}
:root[data-tmf-theme="dark"] :is(input,select,textarea):focus-visible {
  outline:2px solid #9bc5ff!important;outline-offset:2px;
}
:root[data-tmf-theme="dark"] input:disabled,
:root[data-tmf-theme="dark"] button:disabled {opacity:.7}
:root[data-tmf-theme="dark"] .preview-role {
  background:var(--md-surface-container)!important;border-color:#4b515a!important;
}
:root[data-tmf-theme="dark"] .preview-role button {
  color:#e4e9f0!important;
}
:root[data-tmf-theme="dark"] .preview-role button.selected {
  background:#4a5e79!important;color:#fff!important;
}
:root[data-tmf-theme="dark"] .demo-exit {background:var(--md-surface-highest)!important;color:#f0f3f8!important;border-color:var(--md-outline)!important}
:root[data-tmf-theme="dark"] .greeting .button {
  background:var(--md-surface-highest)!important;color:#e9f1ff!important;border-color:#64748a!important;
}
:root[data-tmf-theme="dark"] :is(.progress-track,.ring-track) {background:#49505c!important}
:root[data-tmf-theme="dark"] .progress-fill {background:#91baff!important}

/* Statuses remain distinct without pale, low-contrast labels. */
:root[data-tmf-theme="dark"] .status {background:#234b37!important;color:#bbf1d0!important}
:root[data-tmf-theme="dark"] .status.amber {background:#503d24!important;color:#ffdaa0!important}
:root[data-tmf-theme="dark"] .status.blue {background:#2c4565!important;color:#daeaff!important}
:root[data-tmf-theme="dark"] .status.gray {background:#41444d!important;color:#e3e5eb!important}
:root[data-tmf-theme="dark"] .status.red {background:#5a3434!important;color:#ffd4d4!important}
:root[data-tmf-theme="dark"] .error-banner,
:root[data-tmf-theme="dark"] .form-error {background:#493032!important;color:#ffd0d0!important;border-color:#6c4145!important}
:root[data-tmf-theme="dark"] .success-box {background:#274436!important;color:#d1f5da!important;border-color:#497454!important}
:root[data-tmf-theme="dark"] .form-panel .rule-check {color:#abb6c6!important}

/* Avatar initials are dark enough to read on their intentionally light backgrounds. */
:root[data-tmf-theme="dark"] .avatar {color:#1d477e!important;background:#e4efff!important}
:root[data-tmf-theme="dark"] .avatar.rose {color:#922e48!important;background:#ffe4eb!important}
:root[data-tmf-theme="dark"] .avatar.green {color:#146143!important;background:#d8f8e8!important}
:root[data-tmf-theme="dark"] .avatar.gold {color:#75501e!important;background:#fff0cc!important}

/* Attendance component: inherit the neutral palette while retaining camera overlay. */
:root[data-tmf-theme="dark"] :is(
 .attendance-panel,.attendance-manual,.face-register-row,.attendance-summary-card
) {
  background:var(--dm-raised)!important;color:var(--dm-fg)!important;
  border-color:var(--line)!important;
}
:root[data-tmf-theme="dark"] :is(
 .attendance-panel>header h2,.face-register-person strong,
 .attendance-summary-card strong
) {color:var(--dm-fg)!important}
:root[data-tmf-theme="dark"] :is(
 .attendance-panel>header p,.face-register-person span,
 .attendance-summary-card span,.attendance-history-row span,
 .attendance-history-row small
) {color:var(--dm-secondary)!important}
:root[data-tmf-theme="dark"] .attendance-privacy {background:#443b2c!important;color:#ffe3b4!important}
:root[data-tmf-theme="dark"] .attendance-summary-card {background:#353940!important}
:root[data-tmf-theme="dark"] .attendance-note:not(:empty) {background:#234536!important;color:#cff5dd!important}
:root[data-tmf-theme="dark"] .attendance-note.error:not(:empty) {background:#513137!important;color:#ffe3e3!important}

/* Secondary content and exam components. The Qur'an paper remains cream with dark Arabic ink. */
:root[data-tmf-theme="dark"] :is(
 .tasmi-invite-options,.tasmi-event-panel,.tasmi-event-row,
 .capaian-rank-row,.capaian-leaderboard,.capaian-filters,
 .surah-tile,.school-goal-juz,.task-row
) {border-color:var(--line)!important}
:root[data-tmf-theme="dark"] .capaian-rank-number {color:#c5dcff!important}
:root[data-tmf-theme="dark"] .tasmi-event-icon {background:#354a65!important;color:#d6e7ff!important}
:root[data-tmf-theme="dark"] .tasmi-invite-options {background:#34373e!important}
:root[data-tmf-theme="dark"] :is(.tasmi-invitation,.quran-paper) {
  background:#fffdf4!important;color:#243044!important;
}
:root[data-tmf-theme="dark"] .tasmi-invitation :is(h1,h2,h3,p,strong,span,dt,dd) {
  color:#253c55!important;
}
:root[data-tmf-theme="dark"] .quran-paper .quran-arabic {color:#26362d!important}
:root[data-tmf-theme="dark"] :is(.quran-toolbar,.quran-footer) {background:#292b30!important;border-color:var(--line)!important}
:root[data-tmf-theme="dark"] .quran-sheet {background:#202124!important}
:root[data-tmf-theme="dark"] .quran-footer span {color:#e3e5eb!important}

/* General modal and login; exclude the full-screen face scanner. */
:root[data-tmf-theme="dark"] dialog:not(.tmf-camera-dialog),
:root[data-tmf-theme="dark"] :is(.dialog-body,.dialog-head,.login-card) {
  background:var(--dm-raised)!important;color:var(--dm-fg)!important;
  border-color:var(--line)!important;
}
:root[data-tmf-theme="dark"] .dialog-head .icon-button {color:#e9ebef!important}
:root[data-tmf-theme="dark"] dialog:not(.tmf-camera-dialog) :is(.field label,small,p) {
  color:var(--dm-secondary)!important;
}
:root[data-tmf-theme="dark"] .dialog-body .form-divider {border-color:var(--line)!important}
:root[data-tmf-theme="dark"] .tmf-camera-dialog,
:root[data-tmf-theme="dark"] .tmf-camera-dialog .tmf-camera-shell {
  background:#091726!important;color:#fff!important;
}
/* Notification and toast surfaces should use the same contrast treatment. */
:root[data-tmf-theme="dark"] :is(.notification-list,.notification-item,.toast,.loading-state) {
  color:var(--dm-fg)!important;
}
:root[data-tmf-theme="dark"] .toast {background:var(--md-surface-high)!important;border-color:var(--line)!important}

/* Full-width mobile navigation, unchanged geometry. */
@media (max-width:1024px){
  :root[data-tmf-theme="dark"] .mobile-nav {
    background:var(--md-surface-container)!important;
    border-color:var(--md-outline-variant)!important;
    box-shadow:0 14px 32px rgba(0,0,0,.32)!important;
  }
  :root[data-tmf-theme="dark"] .mobile-nav button {
    color:#eaedf1!important;
  }
  :root[data-tmf-theme="dark"] .mobile-nav button.active {
    background:var(--md-primary-container)!important;color:var(--md-on-primary-container)!important;
  }
}
@media print {
  :root[data-tmf-theme="dark"] body,
  :root[data-tmf-theme="dark"] body:has(.app-frame),
  :root[data-tmf-theme="dark"] body:has(.app-frame) .app-frame,
  :root[data-tmf-theme="dark"] body:has(.app-frame) .main {
    background:#fff!important;color:#111!important;
  }
  :root[data-tmf-theme="dark"] .print-header {color:#111!important}
}
/* Additional component-specific contrast rules. */
:root[data-tmf-theme="dark"] .backup-disclosure {
  background:var(--dm-raised)!important;border-color:var(--line)!important;
  color:var(--dm-fg)!important;
}
:root[data-tmf-theme="dark"] .backup-disclosure-body {
  background:var(--dm-inset)!important;border-color:var(--line)!important;
  color:var(--dm-fg)!important;
}
:root[data-tmf-theme="dark"] .backup-item-title strong,
:root[data-tmf-theme="dark"] .backup-inline-form label {color:var(--dm-fg)!important}
:root[data-tmf-theme="dark"] .backup-item-title small,
:root[data-tmf-theme="dark"] .backup-item-chevron {color:var(--dm-secondary)!important}
:root[data-tmf-theme="dark"] .backup-item-icon {
  background:#40506b!important;color:#e1ebff!important;
}
:root[data-tmf-theme="dark"] td {color:var(--dm-secondary)!important}
:root[data-tmf-theme="dark"] .halaqah-card.featured .avatar {
  background:#e4efff!important;color:#1d477e!important;
}
:root[data-tmf-theme="dark"] .halaqah-card.featured .avatar.rose {
  background:#ffe4eb!important;color:#922e48!important;
}

:root[data-tmf-theme="dark"] .halaqah-card.featured .halaqah-bottom .avatar,
:root[data-tmf-theme="dark"] .halaqah-card.featured .halaqah-bottom .avatar:not(.rose) {
  background:#e4efff!important;color:#1d477e!important;
}
:root[data-tmf-theme="dark"] .halaqah-card.featured .halaqah-bottom .avatar.rose {
  background:#ffe4eb!important;color:#922e48!important;
}

/* Expanded Excel biodata and student detail remain part of the dark modal. */
:root[data-tmf-theme="dark"] :is(
 .student-bio-editor,.student-bio-view,.biodata-table>div
) {
  background:var(--dm-inset)!important;
  color:var(--dm-fg)!important;
  border-color:var(--line)!important;
}
:root[data-tmf-theme="dark"] :is(.student-bio-editor>summary,.student-bio-view>summary) {
  color:#dbe9ff!important;
}
:root[data-tmf-theme="dark"] :is(.student-bio-editor>p,.biodata-table dt,.bio-edit-group .field label) {
  color:var(--dm-secondary)!important;
}
:root[data-tmf-theme="dark"] .bio-edit-group {border-color:var(--line)!important}
:root[data-tmf-theme="dark"] .biodata-table dd {color:var(--dm-fg)!important}
/* Avatars inside both featured and standard halaqah cards keep their dark initials. */
:root[data-tmf-theme="dark"] .app-frame .halaqah-card .halaqah-bottom .avatar {
  background:#e4efff!important;color:#1d477e!important;
}
:root[data-tmf-theme="dark"] .app-frame .halaqah-card .halaqah-bottom .avatar.rose {
  background:#ffe4eb!important;color:#922e48!important;
}

/* Dark mode for parent attendance and registered-face gallery. */
:root[data-tmf-theme="dark"] .attendance-report-row{border-color:#343434}
:root[data-tmf-theme="dark"] .attendance-report-row strong{color:#f1f3f5}
:root[data-tmf-theme="dark"] .attendance-report-row small,
:root[data-tmf-theme="dark"] .attendance-report-times{color:#c7cbd3}
:root[data-tmf-theme="dark"] .attendance-report-note{color:#e8c98d}
:root[data-tmf-theme="dark"] .attendance-registered-count{color:#bad6ff}
:root[data-tmf-theme="dark"] .attendance-report-filters label{color:#ecedf0}
:root[data-tmf-theme="dark"] .attendance-report-filters input,
:root[data-tmf-theme="dark"] .attendance-report-filters select{
  background:var(--md-surface-container);color:#f1f3f5;border-color:#525252}
:root[data-tmf-theme="dark"] .face-register-avatar{border-color:#53565c}


/* Component states share the palette, including legacy high-specificity styles
   from guardian-clean, management-layout and dashboard-surface. */
:root[data-tmf-theme="dark"] .app-frame :is(.preview-strip,.demo-banner) {
  background:var(--md-surface-container)!important;
  border:1px solid var(--md-outline-variant)!important;
}
:root[data-tmf-theme="dark"] .app-frame .preview-copy strong {color:var(--md-on-surface)!important}
:root[data-tmf-theme="dark"] .app-frame .preview-copy span {color:var(--md-on-surface-variant)!important}
:root[data-tmf-theme="dark"] .app-frame .preview-role {
  background:var(--md-surface-high)!important;
  border-color:var(--md-outline-variant)!important;
}
:root[data-tmf-theme="dark"] .app-frame .preview-role button.selected {
  background:var(--md-primary-container)!important;
  color:var(--md-on-primary-container)!important;
}
:root[data-tmf-theme="dark"] .app-frame .family-switch .family-card {
  background:var(--md-surface-high)!important;
  background-image:none!important;
  border-color:var(--md-outline-variant)!important;
  color:var(--md-on-surface)!important;
}
:root[data-tmf-theme="dark"] .app-frame .family-switch .family-card:is(.active,[aria-pressed="true"]) {
  background:var(--md-primary-container)!important;
  border-color:#6486af!important;
  color:var(--md-on-primary-container)!important;
}
:root[data-tmf-theme="dark"] .app-frame .family-switch .family-card:hover:not(.active):not([aria-pressed="true"]) {
  background:var(--md-surface-highest)!important;
}
:root[data-tmf-theme="dark"] .app-frame .family-switch .family-card:is(.active,[aria-pressed="true"]):hover {
  background:var(--md-primary-container)!important;
}
:root[data-tmf-theme="dark"] .app-frame .family-switch .family-card :is(.family-card-content,strong) {
  color:var(--md-on-surface)!important;
}
:root[data-tmf-theme="dark"] .app-frame .family-switch .family-card:is(.active,[aria-pressed="true"]) :is(strong,.family-card-content) {
  color:var(--md-on-primary-container)!important;
}
:root[data-tmf-theme="dark"] .app-frame .family-switch .family-card .family-card-meta {
  color:var(--md-on-surface-variant)!important;
}
:root[data-tmf-theme="dark"] .app-frame .family-switch .family-card:is(.active,[aria-pressed="true"]) .family-card-meta {
  color:#d1ddef!important;
}
:root[data-tmf-theme="dark"] .app-frame .family-switch .family-card .family-card-current,
:root[data-tmf-theme="dark"] .app-frame .family-switch .family-card .family-card-percentage {
  color:var(--md-primary)!important;
  background:transparent!important;
}
:root[data-tmf-theme="dark"] .app-frame .family-switch .family-card .family-card-task {
  color:#f6d09a!important;
  background:transparent!important;
}
:root[data-tmf-theme="dark"] .app-frame .family-switch .family-card>.family-card-arrow {
  color:var(--md-primary)!important;
}
:root[data-tmf-theme="dark"] .app-frame .task-panel .task-row {
  background:var(--md-surface-high)!important;
  border:1px solid var(--md-outline-variant)!important;
}
:root[data-tmf-theme="dark"] .app-frame .task-panel .task-row .task-teacher-note {
  background:transparent!important;
  color:inherit!important;
  border:0!important;
}
:root[data-tmf-theme="dark"] .app-frame .task-panel .task-row .task-teacher-note strong,
:root[data-tmf-theme="dark"] .app-frame .family-switch .family-card.active .family-card-current {
  color:var(--md-primary)!important;
}
:root[data-tmf-theme="dark"] .app-frame .task-panel .task-row .task-teacher-note p {
  color:var(--md-on-surface-variant)!important;
}
:root[data-tmf-theme="dark"] .app-frame .tmf-section-help {
  background:var(--md-surface-high)!important;
  border-color:var(--md-outline-variant)!important;
  color:var(--md-on-surface-variant)!important;
}
:root[data-tmf-theme="dark"] .app-frame .tmf-section-help :is(summary,.tmf-help-toggle,.tmf-help-body,.tmf-help-body strong) {
  color:var(--md-on-surface)!important;
}
:root[data-tmf-theme="dark"] .app-frame .chart-tooltip {
  background:var(--md-surface-highest)!important;
  border-color:var(--md-outline)!important;
  color:var(--md-on-surface-variant)!important;
}
:root[data-tmf-theme="dark"] .app-frame .chart-tooltip strong {color:var(--md-primary)!important}
:root[data-tmf-theme="dark"] .app-frame .chart-point-dot {
  background:var(--md-surface-container)!important;
  box-shadow:0 0 0 2px var(--md-surface-container)!important;
  border-color:var(--md-primary)!important;
}
:root[data-tmf-theme="dark"] .app-frame .global-search input {
  background:var(--md-surface-high)!important;
  border:1px solid var(--md-outline-variant)!important;
  color:var(--md-on-surface)!important;
}
:root[data-tmf-theme="dark"] .app-frame :is(.theme-toggle,.global-search input,.chip,.button,.nav-item,select,textarea):focus-visible {
  outline:2px solid var(--md-focus)!important;
  outline-offset:2px!important;
}
:root[data-tmf-theme="dark"] .app-frame .sidebar .nav-item.active {
  background:var(--md-sidebar-selected)!important;
  color:var(--md-on-surface)!important;
}
:root[data-tmf-theme="dark"] .app-frame .sidebar .nav-item:hover {
  background:var(--md-sidebar-hover)!important;
}
:root[data-tmf-theme="dark"] .app-frame .sidebar .sidebar-add {
  background:var(--md-primary)!important;
  color:var(--md-on-primary)!important;
}
:root[data-tmf-theme="dark"] ::selection {
  background:var(--md-primary-container);
  color:var(--md-on-primary-container);
}


/* Shared nested surface levels, table dividers and labels across every role/page. */
:root[data-tmf-theme="dark"] .app-frame :is(
  .panel .table-wrap,.panel .panel-header,.panel .panel-footer,
  .form-panel .form-grid,.task-panel .task-list,.school-goal .school-goal-header
) {background:transparent!important}
:root[data-tmf-theme="dark"] .app-frame :is(
  .school-goal .school-goal-child,
  .school-goal .school-goal-juz:not(.is-active):not(.is-passed):not(.is-locked),
  .form-panel .info-box,.form-panel .profile-preview,
  .panel .recap-card,.panel .followup-reply,
  .detail-summary>div,.student-card .student-card-foot,
  .tmf-data-layout .tmf-user-table tbody tr
) {
  background:var(--md-surface-high)!important;
  border-color:var(--md-outline-variant)!important;
}
:root[data-tmf-theme="dark"] .app-frame :is(
  th,td,.mobile-cards tr,.panel-footer,.student-card-foot,
  .form-divider,.target-line,.tabs,.dialog-head,.card-actions,
  .attendance-report-row,.attendance-history-row
) {border-color:var(--md-outline-variant)!important}
:root[data-tmf-theme="dark"] .app-frame th,
:root[data-tmf-theme="dark"] .app-frame .tmf-data-layout .tmf-user-table td::before {
  color:var(--md-on-surface-variant)!important;
}
@media screen and (max-width:800px) {
  :root[data-tmf-theme="dark"] body:has(.app-frame) .app-frame,
  :root[data-tmf-theme="dark"] body:has(.app-frame) .app-frame.sidebar-collapsed {
    box-shadow:none!important;
  }
}
