/* The light design is unchanged. Dark colors are scoped to an explicit user choice. */
.theme-toggle{min-height:40px;padding:8px 11px;border:1px solid var(--line);border-radius:8px;background:var(--white,#fff);color:var(--text,var(--ink));font-size:12px;font-weight:650;white-space:nowrap;cursor:pointer}
.theme-toggle:focus-visible{outline:3px solid #68b7e3;outline-offset:2px}
.theme-setting{padding-top:20px;border-top:1px solid var(--line);margin-top:20px}
.theme-setting select{display:block;width:100%;max-width:260px;margin-top:7px;padding:10px;border:1px solid var(--line);border-radius:8px;background:var(--white,#fff);color:var(--text,var(--ink))}
.theme-setting p{font-size:12px;color:var(--muted);margin-top:8px}
html[data-theme=dark]{color-scheme:dark;--bg:#0e1823;--text:#e8eef5;--ink:#e8eef5;--muted:#b1bfcc;--line:#34485b;--white:#192938;--sky:#19384d;--navy:#172d42;--navy2:#101f2e;--blue:#78bced;--red:#f18b91;--amber:#f1bf72;--green:#8bceb0;--shadow:0 10px 28px #0004}
html[data-theme=dark] body{background:var(--bg);color:var(--text)}
html[data-theme=dark] .theme-toggle{background:#22384a;color:#f1f6fa;border-color:#4b6579}
html[data-theme=dark] .theme-setting select{background:#172736;color:var(--text)}

/* Main portal surfaces and controls. */
html[data-theme=dark] .portal-app .sidebar{background:linear-gradient(180deg,#0b1723,#142b3e)}
html[data-theme=dark] .portal-app .topbar,
html[data-theme=dark] .portal-app .dialog-actions,
html[data-theme=dark] .portal-app .report-row.header,
html[data-theme=dark] .portal-app .employee-table-head,
html[data-theme=dark] .portal-app .audit-head{background:#142332;color:var(--text)}
html[data-theme=dark] .portal-app .panel,
html[data-theme=dark] .portal-app .stats article,
html[data-theme=dark] .portal-app dialog,
html[data-theme=dark] .portal-app .insight,
html[data-theme=dark] .portal-app .shared-card,
html[data-theme=dark] .portal-app .health-summary>article,
html[data-theme=dark] .portal-app .executive-summary article,
html[data-theme=dark] .portal-app .case-next-step{background:#192938;color:var(--text);border-color:var(--line)}
html[data-theme=dark] .portal-app .search,
html[data-theme=dark] .portal-app .icon-btn,
html[data-theme=dark] .portal-app .chip,
html[data-theme=dark] .portal-app .back,
html[data-theme=dark] .portal-app .secondary,
html[data-theme=dark] .portal-app .close,
html[data-theme=dark] .portal-app .mobile-menu,
html[data-theme=dark] .portal-app .employee-actions select,
html[data-theme=dark] .portal-app .report-controls select,
html[data-theme=dark] .portal-app .direct-picker select,
html[data-theme=dark] .portal-app .shared-toolbar select,
html[data-theme=dark] .portal-app .collab-tabs button,
html[data-theme=dark] .portal-app .channel-button,
html[data-theme=dark] .portal-app .message-file,
html[data-theme=dark] .portal-app .initial-files input,
html[data-theme=dark] .portal-app .inline-crew-fields input,
html[data-theme=dark] .portal-app .inline-crew-fields textarea,
html[data-theme=dark] .portal-app .settings-form input,
html[data-theme=dark] .portal-app .form-grid input,
html[data-theme=dark] .portal-app .form-grid select,
html[data-theme=dark] .portal-app .form-grid textarea,
html[data-theme=dark] .portal-app input,
html[data-theme=dark] .portal-app select,
html[data-theme=dark] .portal-app textarea{background:#142332;color:var(--text);border-color:#476074}
html[data-theme=dark] .portal-app .search input{background:transparent;border:0}
html[data-theme=dark] .portal-app input::placeholder,
html[data-theme=dark] .portal-app textarea::placeholder{color:#9aabba}
html[data-theme=dark] .portal-app .request-row:hover,
html[data-theme=dark] .portal-app .employee-row:hover,
html[data-theme=dark] .portal-app .row-actions button:hover,
html[data-theme=dark] .portal-app .channel-button:hover,
html[data-theme=dark] .portal-app .channel-button.active{background:#263c4e}
html[data-theme=dark] .portal-app .request-row,
html[data-theme=dark] .portal-app .info-row,
html[data-theme=dark] .portal-app .employee-row{border-color:var(--line)}
html[data-theme=dark] .portal-app .report-row.attention,
html[data-theme=dark] .portal-app .insight.warning,
html[data-theme=dark] .portal-app .priority-warning,
html[data-theme=dark] .portal-app .close-work-notice,
html[data-theme=dark] .portal-app .executive-summary article.warning{background:#3a2e20;color:#f6dca9;border-color:#755a31}
html[data-theme=dark] .portal-app .insight.good,
html[data-theme=dark] .portal-app .operation-result span{background:#183d36;color:#b3ebd3;border-color:#356c5a}
html[data-theme=dark] .portal-app .close-request-error,
html[data-theme=dark] .portal-app .danger{background:#402b33;color:#ffb7ba;border-color:#87535b}
html[data-theme=dark] .portal-app .temporary-password,
html[data-theme=dark] .portal-app .portal-access-option,
html[data-theme=dark] .portal-app .case-type-options button,
html[data-theme=dark] .portal-app .priority-governance,
html[data-theme=dark] .portal-app .initial-files,
html[data-theme=dark] .portal-app .feedback-context,
html[data-theme=dark] .portal-app .feedback-item,
html[data-theme=dark] .portal-app .comparison-period,
html[data-theme=dark] .portal-app .attention-row,
html[data-theme=dark] .portal-app .chat-messages,
html[data-theme=dark] .portal-app .collab-message-list,
html[data-theme=dark] .portal-app .chat-bubble,
html[data-theme=dark] .portal-app .health-detail dl div,
html[data-theme=dark] .portal-app .case-next-step #crew-request-assignments{background:#203447;color:var(--text);border-color:var(--line)}
html[data-theme=dark] .portal-app .chat-message.mine .chat-bubble{background:#214759}
html[data-theme=dark] .portal-app .source-icon,
html[data-theme=dark] .portal-app .timeline-dot,
html[data-theme=dark] .portal-app .case-type-options span,
html[data-theme=dark] .portal-app .shared-icon,
html[data-theme=dark] .portal-app .attachment-thumb{background:#264b65;color:#c2e4fa}
html[data-theme=dark] .portal-app h1,
html[data-theme=dark] .portal-app .executive-summary strong,
html[data-theme=dark] .portal-app .comparison-row strong,
html[data-theme=dark] .portal-app .case-next-step h3,
html[data-theme=dark] .portal-app .activity-item strong{color:#f2f6fa}
html[data-theme=dark] .portal-app .case-next-step>p,
html[data-theme=dark] .portal-app .activity-item p,
html[data-theme=dark] .portal-app .request-main span,
html[data-theme=dark] .portal-app .timeline-copy p,
html[data-theme=dark] .portal-app .timeline-copy span,
html[data-theme=dark] .portal-app .settings-form label,
html[data-theme=dark] .portal-app .form-grid label,
html[data-theme=dark] .portal-app .report-controls label,
html[data-theme=dark] .portal-app .inline-crew-fields label,
html[data-theme=dark] .portal-app .inline-crew-note,
html[data-theme=dark] .portal-app .employee-person span,
html[data-theme=dark] .portal-app .employee-cell{color:#bac8d4}
html[data-theme=dark] .portal-app .text-btn,
html[data-theme=dark] .portal-app a,
html[data-theme=dark] .portal-app .case-next-step #crew-request-assignments button{color:#92d2ff}
html[data-theme=dark] .portal-app .primary{background:#367cab;color:#fff}
html[data-theme=dark] .portal-app .primary:hover{background:#4692c4}
html[data-theme=dark] .portal-app .status.new,
html[data-theme=dark] .portal-app .chip.active{background:#204660;color:#c6e7ff}
html[data-theme=dark] .portal-app .status.progress{background:#554125;color:#ffe1a3}
html[data-theme=dark] .portal-app .status.late{background:#532f36;color:#ffc1c5}
html[data-theme=dark] .portal-app .status.done{background:#1e4739;color:#b5ebca}
html[data-theme=dark] .portal-app .stats small,
html[data-theme=dark] .portal-app .meta-item span,
html[data-theme=dark] .portal-app .info-row span{color:#b0becc}
html[data-theme=dark] .portal-app .bar{background:#34495b}
/* Case history styles are injected after the page styles, so these selectors
   must override their hard-coded light colors as well. */
html[data-theme=dark] .portal-app .readable-history .history-event{background:#1b2e3f;color:#edf3f8;border-color:#40576a;border-left-color:#70b9df}
html[data-theme=dark] .portal-app .readable-history .history-title{color:#f3f7fa}
html[data-theme=dark] .portal-app .readable-history .history-event p{color:#e0eaf1!important}
html[data-theme=dark] .portal-app .readable-history .history-intro,
html[data-theme=dark] .portal-app .readable-history h4,
html[data-theme=dark] .portal-app .readable-history .history-meta,
html[data-theme=dark] .portal-app .readable-history .history-actor{color:#bbccda}
html[data-theme=dark] .portal-app .readable-history .history-event details{border-color:#40576a}
html[data-theme=dark] .portal-app .readable-history .history-event summary{color:#9bd4f6}
html[data-theme=dark] .portal-app .readable-history .history-event dt,
html[data-theme=dark] .portal-app .readable-history .history-event dd{color:#dce8ef}
html[data-theme=dark] .portal-app #crew-latest-activity{background:#203c3b!important;color:#d8f0e7!important}

/* The same preference follows the calendar and the task application. */
html[data-theme=dark] .crew-app header,
html[data-theme=dark] .tasks-app .bottom-nav{background:#192938;color:var(--text);border-color:var(--line)}
html[data-theme=dark] .crew-app .calendar,
html[data-theme=dark] .crew-app .detail,
html[data-theme=dark] .crew-app .open-work,
html[data-theme=dark] .crew-app #setup,
html[data-theme=dark] .crew-app .stat,
html[data-theme=dark] .crew-app dialog,
html[data-theme=dark] .tasks-app .overview>div,
html[data-theme=dark] .tasks-app .task-card,
html[data-theme=dark] .tasks-app .detail-card,
html[data-theme=dark] .tasks-app .quick-actions,
html[data-theme=dark] .tasks-app .login-card,
html[data-theme=dark] .tasks-app .task-close-dialog{background:#192938;color:var(--text);border-color:var(--line)}
html[data-theme=dark] .crew-app input,
html[data-theme=dark] .crew-app select,
html[data-theme=dark] .crew-app textarea,
html[data-theme=dark] .crew-app button:not(.primary):not(.theme-toggle),
html[data-theme=dark] .tasks-app input,
html[data-theme=dark] .tasks-app select,
html[data-theme=dark] .tasks-app textarea,
html[data-theme=dark] .tasks-app .tabs button,
html[data-theme=dark] .tasks-app .search,
html[data-theme=dark] .tasks-app .detail-head>button,
html[data-theme=dark] .tasks-app .section-head button,
html[data-theme=dark] .tasks-app .upload{background:#142332;color:var(--text);border-color:#476074}
html[data-theme=dark] .crew-app .days .planned,
html[data-theme=dark] .tasks-app .status{background:#21465e;color:#d1ecff}
html[data-theme=dark] .crew-app .days .recorded,
html[data-theme=dark] .tasks-app .status.done{background:#214736;color:#c2efcd}
html[data-theme=dark] .crew-app .days .missing,
html[data-theme=dark] .tasks-app .task-work-note{background:#4a3927;color:#ffe1a4}
html[data-theme=dark] .crew-app .primary{background:#236d58;color:#fff;border-color:#236d58}
html[data-theme=dark] .crew-app .primary:hover{background:#2b8068}
html[data-theme=dark] .crew-app .entry,
html[data-theme=dark] .crew-app .pilot-note,
html[data-theme=dark] .tasks-app .empty{background:#203c3c;color:var(--text)}
html[data-theme=dark] .crew-app .tag,
html[data-theme=dark] .crew-app #entry-mode{background:#4a3927;color:#ffe1a4}
html[data-theme=dark] .crew-app .team-table td,
html[data-theme=dark] .crew-app .team-table th{border-color:var(--line)}
html[data-theme=dark] .crew-app .team-table .selected-person{background:#25493e}
html[data-theme=dark] .tasks-app .task-card:hover{background:#263c4e}
html[data-theme=dark] .tasks-app .status.late,
html[data-theme=dark] .tasks-app .task-close-error{background:#512f36;color:#ffc5ca}
html[data-theme=dark] .tasks-app .quick-actions button{background:#2b4052;color:var(--text)}
html[data-theme=dark] .tasks-app .quick-actions .complete{background:#214736;color:#c2efcd}
html[data-theme=dark] .tasks-app .bottom-nav button{background:transparent;color:var(--text)}
html[data-theme=dark] .tasks-app .timeline-row>i{background:#315e76;color:#d1edff}
html[data-theme=dark] input::placeholder,
html[data-theme=dark] textarea::placeholder{color:#9aabba}
@media(max-width:720px){.portal-app .theme-toggle{width:40px;font-size:0;padding:7px}.portal-app .theme-toggle::first-letter{font-size:18px}.crew-app .theme-toggle,.tasks-app .theme-toggle{font-size:12px}}
/* Shared usability controls, in both themes. */
.role-home{padding:22px;margin-bottom:20px}
.role-home h2{margin:0 0 8px}.role-home p{color:var(--muted);font-size:15px}
.home-actions{display:grid;grid-template-columns:repeat(auto-fit,minmax(160px,1fr));gap:12px;margin-top:16px}
.home-actions button{display:flex;flex-direction:column;align-items:flex-start;gap:6px;padding:16px;min-height:88px;cursor:pointer}
.home-actions strong{font-size:28px}.home-actions span{font-size:14px}
.role-landing>.stats{display:none}
.schedule-switch{display:flex;gap:10px;flex-wrap:wrap;margin:20px 0}
.schedule-switch button{min-height:44px;padding:10px 18px}
.schedule-switch button[aria-pressed="true"]{background:#245d87!important;color:#fff!important;border-color:#245d87!important}
.crew-app .split[hidden],.crew-app #summary[hidden],.crew-app #daily-work[hidden],.role-home[hidden]{display:none!important}
#daily-jobs .job .actions{display:flex;gap:10px;flex-wrap:wrap;align-items:center}
#daily-jobs .job button,#daily-jobs .job a{min-height:44px;padding:10px 14px}
.work-filters{display:flex;flex-wrap:wrap;gap:8px;padding:16px 20px 0}
.work-filters button{min-height:44px}
.work-filters button[aria-pressed="true"]{background:#245d87;color:#fff;border:2px solid #245d87}
html[data-theme="dark"] .portal-app .work-filters button[aria-pressed="true"]{background:#286795;color:#fff;border-color:#8dbddd}
#work-filter-context{margin:10px 20px;font-size:14px}
.request-main small{display:block;margin-top:6px;color:var(--muted);font-size:13px}
.request-row:focus-visible{outline:3px solid #4295d0;outline-offset:-3px}
.history-event[hidden],.readable-history h4[hidden]{display:none!important}
.history-toggle{margin:12px 0;min-height:44px}
.portal-app .case-next-step #crew-request-assignments button{background:#245d87!important;color:#fff!important;border:1px solid #245d87!important;min-height:44px;padding:10px 16px;border-radius:8px;cursor:pointer}
html[data-theme="dark"] .portal-app .case-next-step #crew-request-assignments button{background:#286795!important;color:#fff!important;border-color:#8dbddd!important}
html[data-theme="dark"] .deadline-info strong{color:#ffd18a!important}
@media(max-width:720px){
 .portal-app .topbar{flex-wrap:wrap;gap:10px}
 .portal-app .top-actions{flex-wrap:wrap;width:100%}
 .portal-app .top-actions .search{display:flex!important;order:5;width:100%;flex:1 0 100%;min-width:0}
 .portal-app .top-actions .search input{width:100%;min-width:0}
 .crew-app .split .detail{order:-1}
}
