/* One dark palette for all portal modules. Reference: charcoal, warm text,
   muted blue actions. Explicit states preserve error/success semantics. */
#portal .profile-account{display:flex;align-items:center;gap:9px}
#bsh-theme-toggle{display:inline-grid;place-items:center;flex:0 0 46px;width:46px;height:46px;padding:0;border:1px solid #dce6f1;border-radius:15px;background:#fff;color:#496783;cursor:pointer}
#bsh-theme-toggle svg{width:22px;height:22px;stroke:currentColor;fill:none;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
#bsh-theme-toggle:focus-visible{outline:2px solid #94b4d5;outline-offset:4px}
html[data-theme="dark"]{
  color-scheme:dark;
  --ink:#eee9de;--muted:#b4babc;--blue:#94b4d5;--blue-dark:#abc5df;
  --line:#3a4247;--soft:#30373b;--white:#272d30;--danger:#e6abab;
  --dark-bg:#171c1f;--dark-shell:#1e2427;--dark-surface:#272d30;
  --dark-raised:#30373b;--dark-action:#365475;--dark-hover:#426385;
  --surface-border:1px solid #343c40;--surface-shadow:0 8px 24px #0000001c;
  background:var(--dark-bg);color:var(--ink)
}
html[data-theme="dark"] body{background:var(--dark-bg)!important;color:var(--ink)}
html[data-theme="dark"] body::before,html[data-theme="dark"] body::after{display:none!important}
html[data-theme="dark"] :is(.topbar,.sidebar,#main-content,.portal-footer){background:var(--dark-shell)!important;color:var(--ink);border-color:#343c40!important;box-shadow:var(--surface-shadow)!important;backdrop-filter:none}
html[data-theme="dark"] :is(.identity-text,.profile-toggle,.profile-menu,.panel,.file-panel,.upload-panel,.file-search-panel,.storage-card,.folder-card,.stat-card,.home-stat-card,.home-upcoming,.tasks-stat,.task-person,.waqf-panel,.waqf-stat,.waqf-unit-card,.waqf-list-item,.waqf-note,.corr-stat-card,.corr-detail-card,.corr-meta,.corr-route-recipient,.corr-current-holder,.corr-dispatch-card,.corr-attachment,.corr-more-menu-popover,.corr-attachments,.task-return-box,.task-submit-box,.task-attachment,.user-folder-access,.user-folder-mode,#user-folder-options,.notice,dialog,.permission-group,.login-fields){background:var(--dark-surface)!important;color:var(--ink)!important;border-color:var(--line)!important;box-shadow:none}
html[data-theme="dark"] :is(.nav-item,.tasks-tab,.waqf-tab,.corr-tabs button,.corr-more-menu>summary){background:var(--dark-surface)!important;color:var(--ink)!important;border-color:transparent!important;box-shadow:none!important}
html[data-theme="dark"] :is(.sidebar .nav-item.active,.tasks-tab.active,.waqf-tab.active,.corr-tabs button.active,.folder-card.selected){background:#303e49!important;border-color:#586c7c!important;color:#c9daea!important;box-shadow:inset 3px 0 #94b4d5!important}
html[data-theme="dark"] :is(.sidebar .nav-item:hover,.tasks-tab:hover,.waqf-tab:hover,.corr-tabs button:hover,.profile-toggle:hover,.profile-menu>button:hover,.corr-more-menu>summary:hover,.corr-more-menu-popover button:hover,.user-folder-tree-row:hover){background:var(--dark-raised)!important;color:#f5f1e8!important}
html[data-theme="dark"] :is(h1,h2,h3,h4,h5,h6,strong,label,legend,.folder-open,.file-card-name,.waqf-report-value){color:var(--ink)!important}
html[data-theme="dark"] :is(.muted,.nav-label,.field-hint,.step-label,.home-stat-card span,.commitment-label,.task-person small,.tasks-stat span,.waqf-stat span,.waqf-unit-meta span,.corr-meta span,.corr-dispatch-card span,.corr-route-note,.profile-menu-heading span,.profile-menu-heading small,.login-footer){color:var(--muted)!important}
html[data-theme="dark"] :is(.stat-card strong,.home-stat-card strong,.tasks-stat strong,.corr-stat-card strong,.waqf-stat strong,.eyebrow){color:#aac1d7!important}
html[data-theme="dark"] :is(input:not([type="checkbox"]):not([type="radio"]):not([type="button"]):not([type="submit"]),select,textarea,[contenteditable="true"]){background:#1d2326!important;border-color:#48545b!important;color:var(--ink)!important;box-shadow:none!important}
html[data-theme="dark"] :is(input,textarea)::placeholder{color:#a4aeb2!important}
html[data-theme="dark"] :is(input,select,textarea):focus-visible{outline:2px solid #94b4d5;outline-offset:2px}
html[data-theme="dark"] :is(input[readonly],input:disabled,select:disabled,textarea:disabled){background:#252b2f!important;color:#9fa8ad!important}
html[data-theme="dark"] :is(input[type="checkbox"],input[type="radio"]){accent-color:#94b4d5}
html[data-theme="dark"] :is(button,.button,.btn,[role="button"],input[type="button"],input[type="submit"]){background:var(--dark-raised)!important;border:1px solid #4a565e!important;color:var(--ink)!important;box-shadow:none!important}
html[data-theme="dark"] :is(button,.button,.btn,[role="button"]):hover{background:#39434a!important;border-color:#71808a!important}
html[data-theme="dark"] :is(button.primary,.btn-primary,.button-primary){background:var(--dark-action)!important;border-color:#5b7896!important;color:#fffaf0!important}
html[data-theme="dark"] :is(button.primary,.btn-primary,.button-primary):hover{background:var(--dark-hover)!important;border-color:#94b4d5!important}
html[data-theme="dark"] :is(button.text-button,.text-button,.icon-button){background:transparent!important;border-color:transparent!important;color:#b9cfe1!important}
html[data-theme="dark"] :is(button.danger,.danger,.corr-more-delete,.waqf-danger-link){background:#463034!important;color:#f1b6b6!important;border-color:#735056!important}
html[data-theme="dark"] :is(button:disabled,button[disabled],input[type="submit"]:disabled){background:#303639!important;color:#9ba4aa!important;border-color:#434d53!important;opacity:1;cursor:not-allowed}
html[data-theme="dark"] #bsh-theme-toggle{background:#303639!important;color:#d8c48d!important;border-color:#434b50!important}
html[data-theme="dark"] :is(table,.waqf-table,.corr-table){background:var(--dark-surface)!important;color:var(--ink)!important}
html[data-theme="dark"] :is(th,.waqf-table th,.corr-table th,.file-toolbar,.permission-group>summary,.profile-menu-heading){background:#30373b!important;color:#d8dcd9!important;border-color:var(--line)!important}
html[data-theme="dark"] :is(td,.waqf-table td,.corr-table td,#files-body tr){border-color:var(--line)!important;color:var(--ink)!important}
html[data-theme="dark"] #files-body tr{background:var(--dark-surface)!important}
html[data-theme="dark"] :is(tbody tr:hover,.corr-unread-row,.corr-table tr.corr-unread-row){background:#303c44!important}
html[data-theme="dark"] :is(.file-type-icon,#files-body .file-mark,.home-task-status,.task-pill,.corr-badge,.waqf-badge){background:#35414a!important;border-color:#596b79!important;color:#d2dfeb!important}
html[data-theme="dark"] :is(.error,.form-message.error,.task-inline-error,.upload-file-result[data-state="error"]){color:#edb0b0!important}
html[data-theme="dark"] :is(.success,.upload-file-result[data-state="success"]){color:#a9d2bf!important}
html[data-theme="dark"] :is(.status-on,.task-status.completed){color:#a9d2bf!important}
html[data-theme="dark"] :is(.status-off,.task-status.overdue,.task-pill.overdue){color:#edb0b0!important}
html[data-theme="dark"] :is(.item-menu,.waqf-tabs,.task-detail-meta>div){background:var(--dark-surface)!important;border-color:var(--line)!important;color:var(--ink)!important;box-shadow:none}
html[data-theme="dark"] :is(.item-menu .menu-danger,.menu-danger){color:#edb0b0!important}
html[data-theme="dark"] :is(.task-status.new,.role-badge){background:#35414a!important;color:#c5d8e9!important}
html[data-theme="dark"] :is(.task-status.in_progress,.waqf-badge.warn){background:#433c2c!important;color:#e5d3a6!important}
html[data-theme="dark"] .task-status.pending_approval{background:#3b3548!important;color:#d4c4e4!important}
html[data-theme="dark"] :is(.task-status.completed,.waqf-badge.ok){background:#2d4038!important;color:#a9d2bf!important}
html[data-theme="dark"] .waqf-badge.danger{background:#463034!important;color:#f1b6b6!important}
html[data-theme="dark"] .profile-avatar{background:#3c596e!important;border-color:#637d91!important;color:#f5f1e8!important}
html[data-theme="dark"] .notice.error{background:#422d31!important;border-color:#735056!important}
html[data-theme="dark"] .notice.warning{background:#3b362b!important;color:#e5d3a6!important;border-color:#6c624b!important}
html[data-theme="dark"] .user-folder-mode:has(input:checked){background:#303e49!important}
html[data-theme="dark"] .permission-group .check-grid{background:var(--dark-surface)!important;border-color:var(--line)!important}
html[data-theme="dark"] .gauge-track{stroke:#4b555c}
html[data-theme="dark"] dialog::backdrop{background:#0c1013b8;backdrop-filter:blur(3px)}
html[data-theme="dark"] ::selection{background:#486985;color:#fff}
html[data-theme="dark"] .welcome-screen::before{background:var(--dark-bg)!important}
html[data-theme="dark"] .welcome-copy{color:var(--ink)!important}
html[data-theme="dark"] .welcome-copy strong{color:#aac1d7!important}
html[data-theme="dark"] body.entry-running #login-screen{background:var(--dark-bg)!important}
@media(max-width:600px){#bsh-theme-toggle{flex-basis:40px;width:40px;height:40px;border-radius:13px}#portal .profile-account{gap:6px}}
