:root{color-scheme:light;--theme-canvas:#f5f7fb;--theme-surface:#fff;--theme-surface-2:#f1f4f8;--theme-text:#172033;--theme-muted:#637087;--theme-border:#dce2ec;--theme-link:#173b9b;--theme-icon:#4d5c72;--theme-shadow:0 12px 35px rgba(0,55,139,.08)}
html[data-theme="dark"]{color-scheme:dark;--theme-canvas:#0b1020;--theme-surface:#151c2f;--theme-surface-2:#202940;--theme-text:#f1f5ff;--theme-muted:#b6c0d4;--theme-border:#35415c;--theme-link:#9db8ff;--theme-icon:#d6def0;--theme-shadow:0 14px 38px rgba(0,0,0,.34);--canvas:#0b1020;--surface:#151c2f;--ink:#f1f5ff;--muted:#b6c0d4;--line:#35415c;--main-bg:#0b1020;--outline:#35415c;--surface-variant:#202940;--task-bg:#0b1020;--task-ink:#f1f5ff;--task-muted:#b6c0d4;--task-line:#35415c;--task-blue:#9db8ff}
body{transition:background-color .2s ease,color .2s ease}.theme-toggle{position:fixed;inset-block-start:16px;inset-inline-end:16px;z-index:1090;width:42px;height:42px;display:grid;place-items:center;border:1px solid var(--theme-border);border-radius:12px;color:var(--theme-icon);background:var(--theme-surface);box-shadow:var(--theme-shadow);cursor:pointer}.topbar .theme-toggle,.top-app-bar .theme-toggle{position:static;inset:auto;z-index:auto;flex:0 0 40px;width:40px;height:40px;box-shadow:none}.theme-toggle:hover{color:var(--theme-link);background:var(--theme-surface-2)}.theme-toggle:focus-visible{outline:3px solid #7698f5;outline-offset:2px}.theme-toggle svg{width:21px;height:21px;fill:none;stroke:currentColor;stroke-width:1.8}.theme-toggle .theme-moon,html[data-theme="dark"] .theme-toggle .theme-sun{display:none}html[data-theme="dark"] .theme-toggle .theme-moon{display:block}
html[data-theme="dark"] body{background:var(--theme-canvas)!important;color:var(--theme-text)!important}html[data-theme="dark"] .app-shell,html[data-theme="dark"] .main-content{color:var(--theme-text)}html[data-theme="dark"] .topbar,html[data-theme="dark"] .top-app-bar,html[data-theme="dark"] .bottom-nav,html[data-theme="dark"] .mobile-nav{background-color:rgba(21,28,47,.97)!important;border-color:var(--theme-border)!important}html[data-theme="dark"] .card,html[data-theme="dark"] .module-card,html[data-theme="dark"] .special-card,html[data-theme="dark"] .modal-content,html[data-theme="dark"] .offcanvas,html[data-theme="dark"] .dropdown-menu,html[data-theme="dark"] .list-group-item,html[data-theme="dark"] .table,html[data-theme="dark"] .accordion-item{background:var(--theme-surface)!important;color:var(--theme-text)!important;border-color:var(--theme-border)!important}html[data-theme="dark"] .bg-white,html[data-theme="dark"] .bg-light{background-color:var(--theme-surface)!important}html[data-theme="dark"] .text-dark,html[data-theme="dark"] .dropdown-item,html[data-theme="dark"] .form-label,html[data-theme="dark"] label{color:var(--theme-text)!important}html[data-theme="dark"] .text-secondary,html[data-theme="dark"] .text-muted,html[data-theme="dark"] .desc-text,html[data-theme="dark"] .profile-name small,html[data-theme="dark"] .page-context span{color:var(--theme-muted)!important}html[data-theme="dark"] a:not(.btn):not(.side-link):not(.brand){color:var(--theme-link)}html[data-theme="dark"] .icon-btn,html[data-theme="dark"] .profile-btn:hover{background:var(--theme-surface-2);color:var(--theme-icon)}html[data-theme="dark"] .form-control,html[data-theme="dark"] .form-select,html[data-theme="dark"] textarea,html[data-theme="dark"] input{background-color:#10182a!important;color:var(--theme-text)!important;border-color:var(--theme-border)!important}html[data-theme="dark"] .form-control::placeholder,html[data-theme="dark"] input::placeholder,html[data-theme="dark"] textarea::placeholder{color:#95a1b8!important;opacity:1}html[data-theme="dark"] .dropdown-item:hover,html[data-theme="dark"] .dropdown-item:focus{background:var(--theme-surface-2);color:var(--theme-text)!important}html[data-theme="dark"] .btn-light{background:var(--theme-surface-2);border-color:var(--theme-border);color:var(--theme-text)}html[data-theme="dark"] .border,html[data-theme="dark"] .border-top,html[data-theme="dark"] .border-bottom{border-color:var(--theme-border)!important}html[data-theme="dark"] .table{--bs-table-bg:var(--theme-surface);--bs-table-color:var(--theme-text);--bs-table-border-color:var(--theme-border)}html[data-theme="dark"] .btn-close{filter:invert(1) grayscale(1) brightness(1.8)}

/* Custom portal surfaces which do not use Bootstrap's card class. */
html[data-theme="dark"] :is(.stat-card,.module-card-new,.task-filter,.task-item,.task-empty,.task-form-card,.detail-card,.task-notification-trigger,.task-notification-panel,.jalali-day,.module-choice label,.entity-head,.chat-balloon,.detail-facts>div,.task-form-header>a){background:var(--theme-surface)!important;color:var(--theme-text)!important;border-color:var(--theme-border)!important}
html[data-theme="dark"] :is(.task-item__main,.task-notification-item>a,.task-reminder a,.detail-description,.task-empty h3,.module-card-new,.stat-card){color:var(--theme-text)!important}
html[data-theme="dark"] :is(.task-open,.task-tabs a.active,.module-icon,.module-choice label>i:first-child,.detail-facts>div){background-color:var(--theme-surface-2)!important}
html[data-theme="dark"] .jalali-day:nth-child(7n){background:#211a2a!important}
html[data-theme="dark"] .task-reminders{background:#342d16!important;border-color:#776526!important}html[data-theme="dark"] .task-reminders__title{color:#ffe18a}
html[data-theme="dark"] .accordion-button{background:var(--theme-surface)!important;color:var(--theme-text)!important}html[data-theme="dark"] .accordion-button::after{filter:invert(1) brightness(1.8)}
html[data-theme="dark"] .alert-light{background:var(--theme-surface-2);color:var(--theme-text);border-color:var(--theme-border)}

/* Guard against accidental light text on explicitly light utility surfaces. */
html:not([data-theme="dark"]) :is(.bg-white,.bg-light).text-white,
html:not([data-theme="dark"]) :is(.bg-white,.bg-light)>.text-white:not(.bg-primary):not(.bg-secondary):not(.bg-danger):not(.bg-success){color:var(--theme-text)!important}
html:not([data-theme="dark"]) :is(.bg-white,.bg-light) a:not(.btn){color:var(--theme-link)}

/* Badges with data-driven backgrounds keep readable lettering and edge contrast. */
.badge[style*="background"]{color:#fff!important;text-shadow:0 1px 2px rgba(0,0,0,.85);font-weight:700}
@media(max-width:991.98px){.theme-toggle{inset-block-start:13px;inset-inline-end:58px;width:38px;height:38px;box-shadow:none}.topbar .theme-toggle,.top-app-bar .theme-toggle{inset:auto;flex-basis:36px;width:36px;height:36px}}@media(prefers-reduced-motion:reduce){body{transition:none}}
