/* Loaded after all workspace modules. Light mode keeps each module's original palette. */
html[data-theme='dark'],
html[data-theme='dark'][data-dark-palette='navy'] {
  --text: #dfe8f8;
  --muted: #a3b3c9;
  --bg: #050810;
  --surface: #0f1624;
  --surface-soft: #131c2d;
  --surface-elevated: #172136;
  --subtle: #151f30;
  --line: #2f4157;
  --control-border: #60748f;
  --input-bg: #111a2a;
  --input-text: #e8efff;
  --blue: #81b8ff;
  --blue-hover: #accfff;
  --blue-soft: #1a2f50;
  --green: #69dba7;
  --green-soft: #16392e;
  --red: #ff91a6;
  --calendar-weekend: var(--red);
  --red-soft: #3b2130;
  --amber: #edc377;
  --amber-soft: #392f1f;
  --purple: #bba5ff;
  --purple-soft: #2e2647;
  --action-bg: #2864ce;
  --action-hover: #245aba;
  --on-action: #ffffff;
  --danger-action: #bd3150;
  --brand-gradient: linear-gradient(115deg, #2864ce, #126d82 55%, #0b7655);
  color-scheme: dark;
}

/* Preserve the published neutral night palette independently of navy overrides. */
html[data-theme='dark'][data-dark-palette='black'] {
  --text: #f2f2f5;
  --muted: #b4b4c2;
  --bg: #09090b;
  --surface: #18181c;
  --surface-soft: #111115;
  --surface-elevated: #23232a;
  --subtle: #1b1b20;
  --line: #41414b;
  --control-border: #77778b;
  --input-bg: #111115;
  --input-text: #f2f2f5;
}

/* Shared surfaces, navigation and record cards. */
html[data-theme='dark'] :is(
  .nav-footer, .rail-person-label, .company-modal-card, .company-contacts-dialog .modal-head,
  .company-note-editor, .portal-messenger, .messenger-heading, .messenger-dialog,
  .emoji-picker, .message-menu, .radio-popover, .radio-cover,
  .ep-dialog.modal.wide, .ep-dialog .modal-head, .ep-tabs, .ep-panel,
  .ep-mail-card, .ep-add, .ep-quick button, .ep-demo-warning, .org-person.ep-org-person,
  .record-side-dialog.modal, .record-side-dialog > .modal-body, .record-side-panel,
  .record-side-head, .record-tabs, .record-side-close
) { background: var(--surface); color: var(--text); border-color: var(--line); }

html[data-theme='dark'] :is(
  .demo-pill, .segment, .deal-view-switch, .tab-strip:where(:not(.cc-tabs)), .board-col, .board-count,
  .pane-count, .soft-stat, .doc-content, .dial-key, .crm-submenu-count, .tab b,
  .company-detail-dialog > .modal-body, .company-meta div, .company-products > span,
  .company-note-switch, .department-children, .integration-note, .field code,
  .search-summary, .search-group > h2 > span, .notification-filters,
  .attachment-chip, .message-image, .chat-image-viewer, .ep-preview-note,
  .ep-total, .ep-mail-filters, .ep-mail-filters b, .ep-channel, .ep-login,
  .ep-empty, .ep-loading, .ep-add-form, .ep-confirm, .radio-tabs, .radio-station-mark,
  .record-client-card, .record-info-icon, .record-feed
) { background: var(--subtle); color: var(--muted); border-color: var(--line); }

html[data-theme='dark'] :is(
  .nav-item, .icon-btn, .quick-action, .useful-link, .field, .check-field,
  .settings-tab, .tab, .mail-folder, .section-heading p, .eyebrow,
  .activity-time, .mini-kpi small, .workspace-footer, .board-sum, .board-empty,
  .board-empty span, .kanplan-summary-head p, .kanplan-summary-head h2 .icon,
  .kanplan-count-note, .kanplan-list-head p, .kanplan-list-tools > span,
  .kanplan-list-tools .text-btn.muted, .kanplan-table .table-sub,
  .company-contact-group header, .integration-card p, .integration-card footer small,
  .brand-gradient-sample span, .notification-button small, .employee-picker small,
  .help-copy, .boot-screen, .auth-brand span, .auth-card > p, .auth-note, .auth-footer,
  .security-account small, .portal-today, .search-summary > span, .search-group > h2,
  .search-empty, .messenger-list-title, .conversation small, .messenger-empty,
  .notification-overview p, .notification-feed-label, .notification-feed-label > span,
  .notification-meta, .notification-copy > small, .notification-filters h3,
  .notification-filters button, .notification-empty, .compose-tool,
  .emoji-picker > strong, .attachment-chip small, .attachment-chip button,
  .file-progress, .message-file small, .ep-photo-remove, .chat-compose-footer,
  .chat-send-mode select, .chat-day, .message-meta, .message-meta .icon,
  .chat-compose > small, .message-actions summary, .message-receipt,
  .message-forwarded, .message-quick button, .message-status,
  .ep-dialog .modal-head h2, .ep-position, .ep-department, .ep-edit, .ep-you,
  .ep-tabs button, .ep-panel-heading p, .ep-mail-filters button,
  .ep-group-heading h4 > span, .ep-group-heading p, .ep-mail-tags, .ep-mail-tags svg,
  .ep-more, .ep-channel p, .ep-footnote, .ep-info-card dt, .ep-quick small,
  .ep-quick button > svg, .ep-security-note p, .ep-empty-inline, .ep-empty > svg,
  .ep-add-form > p, .ep-confirm > p, .ep-org-main small,
  .radio-status, .radio-controls > button, .radio-volume > button,
  .radio-search > button, .radio-tabs button, .radio-station small,
  .radio-station > .icon, .radio-footer, .record-title-block small,
  .record-tab, .record-info small, .record-details dt, .record-note,
  .record-comment-button, .record-activity time, .record-activity small
) { color: var(--muted); }

html[data-theme='dark'] :is(
  .empty-state strong, .company-modal-card h3, .org-metrics b, .org-person strong,
  .urgent-copy strong, .help-copy h3, .messenger-brand, .conversation strong,
  .ep-address, .ep-info-card dd, .ep-login b, .ep-empty h3, .radio-station strong,
  .record-title-block h2, .record-info strong, .record-column > h3,
  .record-section h3, .record-client-card strong, .record-activity strong,
  .record-activity p, .record-details dd
) { color: var(--text); }
/* This legacy utility already uses !important. Keep its theme override equally scoped. */
html[data-theme='dark'] .small-note { color: var(--muted) !important; }

html[data-theme='dark'] :is(
  .card, .board-card, .task-row, .deal-row, .data-table td, .kanplan-table td, .kanplan-table-footer,
  .company-meta div, .company-quick-contact, .company-contact-row,
  .company-contact-group header, .company-note-switch, .department-card > header,
  .integration-card footer, .integration-icon, .brand-gradient-sample, .employee-credentials,
  .search-group + .search-group, .messenger-heading, .messenger-conversations,
  .messenger-dialog .chat-head, .messenger-dialog .chat-compose,
  .notification-overview, .notification-card, .notification-filters,
  .notification-filters .notification-config, .message-file + .message-file,
  .ep-tabs, .ep-mail-card, .ep-info-card, .ep-info-card dl > div, .ep-group-heading h4 > span,
  .ep-empty-inline, .ep-security-note, .ep-state, .responsive-records tbody tr,
  .record-side-head, .record-tabs, .record-meta-grid, .record-column,
  .record-client-card, .record-section, .record-comment-button, .record-activity
) { border-color: var(--line); }
html[data-theme='dark'] .funnel-col:not(:last-child)::after,
html[data-theme='dark'] .event-item:not(:last-child)::after,
html[data-theme='dark'] .org-connector span { border-color: var(--line); }
html[data-theme='dark'] .activity-row:not(:last-child)::after,
html[data-theme='dark'] .compose-resizer span { background: var(--line); }
html[data-theme='dark'] .chart-grid { stroke: var(--line); }
html[data-theme='dark'] .chart-label { fill: var(--muted); }
html[data-theme='dark'] .chart-dot:hover { stroke: var(--surface); }
html[data-theme='dark'] .funnel-bar { color: var(--surface); }
html[data-theme='dark'] .calendar-cell.today .day-number { background: var(--action-bg); color: var(--on-action); }
html[data-theme='dark'] .calendar-cell.today.weekend .day-number { background: var(--danger-action); color: var(--on-action); }
html[data-theme='dark'] :is(.badge, .presence, .ep-avatar, .ep-photo-camera) { border-color: var(--surface); }
html[data-theme='dark'] :is(.modal, .chat-window, .crm-menu, .portal-messenger, .radio-popover) { border-color: var(--line); box-shadow: var(--shadow); }
html[data-theme='dark'] :is(.modal, .ep-dialog)::backdrop { background: #020712bb; }
html[data-theme='dark'] .record-side-dialog.modal::backdrop { background: #02071288; }

/* Inputs use their own stronger boundary; hover and focus never flash white. */
html[data-theme='dark'] :is(.field input, .field select, .field textarea, input, select, textarea):where(:not([type='checkbox']):not([type='radio']):not([type='range']):not([type='color'])) {
  background-color: var(--input-bg); color: var(--input-text); border-color: var(--control-border);
}
html[data-theme='dark'] :is(.global-search input, .radio-search input, .support-search input) { background: transparent; }
html[data-theme='dark'] :is(input, textarea)::placeholder { color: var(--muted); opacity: 1; }
html[data-theme='dark'] :is(input[readonly], textarea[readonly]) { background: var(--subtle); color: var(--muted); }
html[data-theme='dark'] :is(input, select, textarea):focus { border-color: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 22%, transparent); }
html[data-theme='dark'] :is(button, a, input, select, textarea):focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
html[data-theme='dark'] .search-active .global-search { background: var(--input-bg); border-color: var(--blue); }
html[data-theme='dark'] :is(.data-table th, .kanplan-table th) { background: var(--subtle); color: var(--muted); }

html[data-theme='dark'] .urgent-trigger { background: var(--action-bg); color: var(--on-action); }
html[data-theme='dark'] .urgent-trigger.is-overdue { background: var(--danger-action); }
html[data-theme='dark'] .urgent-trigger b { background: transparent; }

html[data-theme='dark'] :is(.button:not(.secondary):not(.danger):not(.green-button):not(.ep-write):not(.text-btn), .chat-send, .radio-controls > .radio-play) {
  background: var(--action-bg); color: var(--on-action);
}
html[data-theme='dark'] :is(.button:not(.secondary):not(.danger):not(.green-button):not(.ep-write):not(.text-btn), .chat-send, .radio-controls > .radio-play):hover {
  background: var(--action-hover); color: var(--on-action);
}
html[data-theme='dark'] .button.secondary { background: var(--surface-soft); color: var(--text); border-color: var(--control-border); }
html[data-theme='dark'] .button.secondary:hover { background: var(--surface-elevated); border-color: var(--blue); }
html[data-theme='dark'] .button.danger { background: var(--red-soft); color: var(--red); border-color: var(--red); }
html[data-theme='dark'] .button.danger:hover { background: color-mix(in srgb, var(--red) 10%, var(--red-soft)); }
html[data-theme='dark'] :is(.skip-link, .segment.active .count, .conversation b, .ep-photo-camera) { background: var(--action-bg); color: var(--on-action); }
html[data-theme='dark'] :is(.badge, .segment .count.danger) { background: var(--danger-action); color: var(--on-action); }
html[data-theme='dark'] .task-check { background: var(--input-bg); border-color: var(--control-border); }
html[data-theme='dark'] .task-check.done { background: var(--green); border-color: var(--green); color: var(--surface); }
html[data-theme='dark'] .switch { background: var(--control-border); }
html[data-theme='dark'] .switch:checked { background: var(--green); }

html[data-theme='dark'] :is(
  .nav-item.active, .messenger-trigger.active, .portal-date, .segment.active,
  .settings-tab.active, .crm-submenu-item.active .crm-submenu-count,
  .mail-folder.active, .calendar-cell.selected, .calendar-note,
  .notification-filters button.active, .compose-tool[aria-expanded='true'],
  .ep-tabs button.active, .ep-mail-filters button.active, .ep-mail-filters button.active b,
  .radio-tabs button[aria-pressed='true'], .radio-station[aria-pressed='true'],
  .header-tools > :is(.header-calendar, .header-support)[aria-current='page']
) { color: var(--blue); background: var(--blue-soft); border-color: var(--line); }
/* Underlined company/contact tabs retain their own scoped active treatment. */
html[data-theme='dark'] .tab.active:where(:not(.company-tabs .tab, .cc-tabs .tab)) { color: var(--blue); background: var(--blue-soft); border-color: var(--line); }
html[data-theme='dark'] :is(.deal-view-switch .segment.active, .company-note-switch .segment.active) { background: var(--surface-elevated); color: var(--blue); }
html[data-theme='dark'] :is(
  .icon-btn:hover, .segment:hover, .deal-view-switch .segment:hover, .quick-action:hover,
  .calendar-cell:hover, .mail-row:hover, .dial-key:hover, .org-person:hover,
  .notification-button:hover, .notification-card:hover, .notification-filters button:hover,
  .compose-tool:hover, .conversation:hover, .radio-station:hover,
  .emoji-picker button:hover, .emoji-picker button:focus-visible,
  .attachment-chip button:hover, .message-actions summary:hover,
  .message-actions[open] summary, .message-quick button:hover, .message-quick button:focus-visible
) { background: var(--surface-elevated); color: var(--blue); }
html[data-theme='dark'] :is(.data-table tbody tr[data-action]:hover, .kanplan-table tbody tr:hover) { background: var(--surface-elevated); }
html[data-theme='dark'] :is(.calendar-cell.blank, .board-card) { background: var(--surface-soft); }
html[data-theme='dark'] :is(.board-card:hover, .quick-action:hover, .notification-card:hover, .segment.active) { border-color: var(--blue); }
html[data-theme='dark'] .board-col.drag-over { background: var(--blue-soft); outline-color: var(--blue); }
html[data-theme='dark'] .segment .count { background: var(--surface-elevated); color: var(--text); }
html[data-theme='dark'] .segment.active .count { background: var(--action-bg); color: var(--on-action); }
html[data-theme='dark'] .segment .count.danger { background: var(--danger-action); color: var(--on-action); }

/* KPI, status and stage colors retain meaning on dark surfaces. */
html[data-theme='dark'] :is(.kpi.kpi-blue, .mini-kpi, .entity-icon, .initials, .company-logo, .company-contact-avatar, .company-count, .activity-marker,
  .ep-avatar, .ep-mail-icon, .ep-kind, .ep-mini-icon, .ep-org-chat, .integration-icon, .notification-symbol) { background: var(--blue-soft); color: var(--blue); }
html[data-theme='dark'] :is(.kpi.kpi-green, .mini-kpi:nth-child(1), .entity-icon.green, .integration-icon.green,
  .ep-state, .ep-mail-icon.shared, .ep-kind.shared, .ep-mini-icon.green, .ep-policy,
  .notification-symbol.messages, .radio-heading small) { background: var(--green-soft); color: var(--green); }
html[data-theme='dark'] .kpi.kpi-amber { background: var(--amber-soft); color: var(--amber); }
html[data-theme='dark'] :is(.kpi.kpi-red, .notification-symbol.tasks) { background: var(--red-soft); color: var(--red); }
html[data-theme='dark'] :is(.entity-icon.violet, .notification-symbol.events) { background: var(--purple-soft); color: var(--purple); }
html[data-theme='dark'] .kpi .kpi-value { color: var(--text); }
html[data-theme='dark'] .kpi .kpi-label { color: inherit; }
html[data-theme='dark'] .kpi .kpi-hint { color: var(--muted); }
html[data-theme='dark'] .status-tag.blue { background: var(--blue-soft); color: var(--blue); }
html[data-theme='dark'] .status-tag.green { background: var(--green-soft); color: var(--green); }
html[data-theme='dark'] .status-tag.amber { background: var(--amber-soft); color: var(--amber); }
html[data-theme='dark'] .status-tag.red { background: var(--red-soft); color: var(--red); }
html[data-theme='dark'] :is(.status-tag.gray, .status-tag.neutral, .ep-state.inactive) { background: var(--subtle); color: var(--muted); }
html[data-theme='dark'] :is(.deal-stage-tag, .kanplan-stage, select.inline-stage) {
  background: color-mix(in srgb, var(--stage-accent) 16%, var(--surface));
  color: color-mix(in srgb, var(--stage-accent) 40%, var(--text));
}
html[data-theme='dark'] .record-stage:not(.active) { background: var(--surface-elevated); color: var(--muted); }
html[data-theme='dark'] .record-activity { background: color-mix(in srgb, var(--green) 10%, var(--surface)); border-color: color-mix(in srgb, var(--green) 35%, var(--line)); }
html[data-theme='dark'] .record-activity-icon { background: var(--green-soft); color: var(--green); }
html[data-theme='dark'] .stage-tile-check { background: var(--surface); color: var(--text); }
html[data-theme='dark'] .task-board-col {
  background: linear-gradient(180deg,color-mix(in srgb,var(--task-status-accent) 16%,var(--surface)),var(--surface));
  border-color: color-mix(in srgb,var(--task-status-accent) 36%,var(--line));
  border-top-color: var(--task-status-accent);
}
html[data-theme='dark'] .task-board-col header span {
  background: color-mix(in srgb,var(--task-status-accent) 22%,var(--surface-elevated));
  color: color-mix(in srgb,var(--task-status-accent) 52%,var(--text));
}
html[data-theme='dark'] .task-stages .kanplan-stage {
  background: color-mix(in srgb,var(--task-status-accent) 18%,var(--surface));
  color: color-mix(in srgb,var(--task-status-accent) 44%,var(--text));
  border-color: color-mix(in srgb,var(--task-status-accent) 35%,var(--line));
  border-top-color: var(--task-status-accent);
}
html[data-theme='dark'] .task-stages .stage-tile-check {
  background: var(--task-status-accent);
  color: #fff;
}
html[data-theme='dark'] .department-icon { background: color-mix(in srgb, var(--department-color) 15%, var(--surface)); color: color-mix(in srgb, var(--department-color) 40%, var(--text)); }
html[data-theme='dark'] :is(.support-stage-new, .client-stage-new) { --stage-color: #81b8ff; }
html[data-theme='dark'] :is(.support-stage-accepted, .client-stage-accepted) { --stage-color: #67d3e1; }
html[data-theme='dark'] :is(.support-stage-waiting, .client-stage-waiting) { --stage-color: #edc377; }
html[data-theme='dark'] :is(.support-stage-answered, .client-stage-answered) { --stage-color: #ffac89; }
html[data-theme='dark'] :is(.support-stage-done, .client-stage-done) { --stage-color: #69dba7; }
html[data-theme='dark'] :is(.support-stage-closed, .client-stage-closed, .client-stage-unknown) { --stage-color: var(--muted); }
html[data-theme='dark'] .support-metric-new { --metric-color: #67d3e1; }
html[data-theme='dark'] .support-metric-answered { --metric-color: #ffac89; }

/* Explanatory panels, employee profile and communications. */
html[data-theme='dark'] :is(.demo-notice, .call-status, .brand-gradient-sample, .security-account,
  .org-metrics, .urgent-row, .notification-overview, .ep-hero, .ep-security-note, .radio-now) {
  background: linear-gradient(115deg, var(--surface-elevated), var(--surface-soft)); color: var(--text); border-color: var(--line);
}
html[data-theme='dark'] :is(.demo-notice strong, .urgent-time, .push-diagnostics, .integration-note > .icon,
  .employee-picker .icon, .portal-today:hover, .messenger-brand > .icon,
  .notification-detail-category, .ep-photo-caption, .ep-tabs button:hover,
  .radio-footer a, .message-file, .message-file:hover) { color: var(--blue); }
html[data-theme='dark'] :is(.error-message, .urgent-row.is-overdue, .attention-group.is-overdue .attention-heading b, .ep-more:hover) {
  background: var(--red-soft); color: var(--red); border-color: var(--red);
}
html[data-theme='dark'] :is(.attention-group.is-overdue .attention-heading, .urgent-row.is-overdue .urgent-time,
  .password-feedback.is-error, .message-status.failed, .radio-status.is-error, .ep-photo-remove:hover) { color: var(--red); }
html[data-theme='dark'] :is(.password-feedback, .ep-info-card [data-security-result], .message-receipt.read) { color: var(--green); }
html[data-theme='dark'] .ep-unverified { color: var(--amber); }
html[data-theme='dark'] .attention-heading b { background: var(--blue-soft); color: var(--blue); }
html[data-theme='dark'] .company-note-editor::-webkit-scrollbar-thumb { background: var(--control-border); }
html[data-theme='dark'] .department-add { background: var(--subtle); color: var(--blue); }
html[data-theme='dark'] .notification-card.unread { background: var(--blue-soft); border-color: var(--line); }
html[data-theme='dark'] .notification-filters button > b { background: var(--surface-elevated); }
html[data-theme='dark'] .messenger-dialog .chat-messages { background: var(--bg); }
html[data-theme='dark'] :is(.messenger-dialog .chat-demo, .chat-demo, .messenger-conversations) { background: var(--subtle); color: var(--muted); }
html[data-theme='dark'] :is(.chat-input-row, .messenger-dialog .chat-input-row) { background: var(--input-bg); }
html[data-theme='dark'] .message { background: var(--surface-elevated); color: var(--text); }
html[data-theme='dark'] .message.mine { background: var(--blue-soft); }
html[data-theme='dark'] .message-menu button { color: var(--text); }
html[data-theme='dark'] .message-quote { background: var(--surface-soft); color: var(--muted); border-color: var(--blue); }
html[data-theme='dark'] .message-quote strong { color: var(--blue); }
html[data-theme='dark'] .message-like { color: var(--muted); border-color: var(--control-border); }
html[data-theme='dark'] :is(.message-like.active, .message-quick .active) { background: var(--green-soft); color: var(--green); border-color: var(--green); }
html[data-theme='dark'] .message-like.active .icon { fill: var(--green); }
html[data-theme='dark'] .message-image span { color: var(--muted); }
html[data-theme='dark'] #messenger-unread-total { background: var(--blue-soft); color: var(--blue); }
html[data-theme='dark'] #messenger-panel .conversation.selected { background: var(--blue-soft); }
html[data-theme='dark'] #messenger-panel .communication-tabs button[aria-pressed='true'] { background: var(--blue-soft); color: var(--blue); }
html[data-theme='dark'] .radio-trigger.is-playing { background: var(--blue-soft); }
html[data-theme='dark'] .radio-cover { border-color: var(--line); }
html[data-theme='dark'] .radio-station[aria-pressed='true'] strong { color: var(--blue); }

/* Project catalog, operating workspace and entity editors share the night palette. */
html[data-theme='dark'] .projects-page-v2,
html[data-theme='dark'] .project-tab-content,
html[data-theme='dark'] .project-passport-view,
html[data-theme='dark'] .project-passport-body,
html[data-theme='dark'] .project-entity-form,
html[data-theme='dark'] .project-entity-dialog > .modal-body,
html[data-theme='dark'] .project-idea-columns > main,
html[data-theme='dark'] .project-chat-messages,
html[data-theme='dark'] .project-idea-chat-list { background: var(--bg); color: var(--text); }
html[data-theme='dark'] .modal.project-entity-dialog { background: var(--bg); }
html[data-theme='dark'] .projects-sidebar,
html[data-theme='dark'] .project-workspace,
html[data-theme='dark'] .project-panel,
html[data-theme='dark'] .project-channels,
html[data-theme='dark'] .project-chat,
html[data-theme='dark'] .project-entity-head,
html[data-theme='dark'] .project-form-section,
html[data-theme='dark'] .project-entity-actions,
html[data-theme='dark'] .project-passport-toolbar,
html[data-theme='dark'] .project-member-block,
html[data-theme='dark'] .project-member-picker,
html[data-theme='dark'] .project-member-picker > label,
html[data-theme='dark'] .project-member-options,
html[data-theme='dark'] .project-iteration-idea,
html[data-theme='dark'] .project-iteration-task-card,
html[data-theme='dark'] .project-iteration-comment-list p,
html[data-theme='dark'] .project-chat-messages p,
html[data-theme='dark'] .project-iteration-dock,
html[data-theme='dark'] .project-iteration-dock > button:first-child,
html[data-theme='dark'] .project-readiness,
html[data-theme='dark'] .project-idea-head,
html[data-theme='dark'] .project-idea-chat,
html[data-theme='dark'] .project-idea-chat > header,
html[data-theme='dark'] .project-idea-chat form,
html[data-theme='dark'] .project-idea-chat-list p,
html[data-theme='dark'] .project-idea-moderators [data-search],
html[data-theme='dark'] .projects-catalog-toolbar .project-search,
html[data-theme='dark'] .project-tiles > .project-empty,
html[data-theme='dark'] .project-tile,
html[data-theme='dark'] .project-idea-reader-list,
html[data-theme='dark'] .project-idea-compose-tools > label,
html[data-theme='dark'] .project-idea-compose-tools > button,
html[data-theme='dark'] .project-idea-mention-picker,
html[data-theme='dark'] .project-idea-mention-picker button { background: var(--surface); color: var(--text); border-color: var(--line); }
html[data-theme='dark'] .project-type-filter,
html[data-theme='dark'] .project-finance article,
html[data-theme='dark'] .project-three-columns div,
html[data-theme='dark'] .project-ideas li,
html[data-theme='dark'] .project-analytics article,
html[data-theme='dark'] .project-access-switch,
html[data-theme='dark'] .project-member-row,
html[data-theme='dark'] .project-member-selected,
html[data-theme='dark'] .project-iteration-section,
html[data-theme='dark'] .project-iteration-tasks > button,
html[data-theme='dark'] .project-iteration-tabs,
html[data-theme='dark'] .project-iteration-column,
html[data-theme='dark'] .project-iteration-task-card > footer,
html[data-theme='dark'] .project-iteration-subtasks,
html[data-theme='dark'] .project-iteration-dock-close,
html[data-theme='dark'] .project-idea-popup dl > div,
html[data-theme='dark'] .project-readiness > ol > li,
html[data-theme='dark'] .project-idea-votes > article,
html[data-theme='dark'] .project-idea-moderators,
html[data-theme='dark'] .project-type-switch,
html[data-theme='dark'] .project-idea-message-quote { background: var(--surface-soft); color: var(--text); border-color: var(--line); }
html[data-theme='dark'] .project-tabs span,
html[data-theme='dark'] .project-pill,
html[data-theme='dark'] .project-chain-link,
html[data-theme='dark'] .project-iteration-tabs span,
html[data-theme='dark'] .project-iteration-column > header span,
html[data-theme='dark'] .project-type-switch b { background: var(--subtle); color: var(--muted); }
html[data-theme='dark'] .project-search,
html[data-theme='dark'] .project-tabs,
html[data-theme='dark'] .project-facts div,
html[data-theme='dark'] .project-row,
html[data-theme='dark'] .project-task,
html[data-theme='dark'] .project-chat > header,
html[data-theme='dark'] .project-chat form,
html[data-theme='dark'] .project-iterations > article,
html[data-theme='dark'] .project-ideas > article,
html[data-theme='dark'] .project-team section,
html[data-theme='dark'] .project-team article,
html[data-theme='dark'] .project-member-editor label,
html[data-theme='dark'] .project-table-wrap,
html[data-theme='dark'] .project-table th,
html[data-theme='dark'] .project-table td,
html[data-theme='dark'] .project-channel-members,
html[data-theme='dark'] .project-idea-files button,
html[data-theme='dark'] .project-view-facts > div,
html[data-theme='dark'] .project-view-facts > div:nth-last-child(-n+2),
html[data-theme='dark'] .project-view-links > a,
html[data-theme='dark'] .project-view-team article,
html[data-theme='dark'] .project-iteration-overview,
html[data-theme='dark'] .project-iteration-subtasks li > span,
html[data-theme='dark'] .project-iteration-task-card > footer button,
html[data-theme='dark'] .project-idea-popup section,
html[data-theme='dark'] .project-readiness-check,
html[data-theme='dark'] .project-tile > footer,
html[data-theme='dark'] .project-workspace-nav { border-color: var(--line); }
html[data-theme='dark'] .project-list-item small,
html[data-theme='dark'] .project-tabs button,
html[data-theme='dark'] .project-type-filter button,
html[data-theme='dark'] .project-panel-head p,
html[data-theme='dark'] .project-facts dt,
html[data-theme='dark'] .project-finance span,
html[data-theme='dark'] .project-row small,
html[data-theme='dark'] .project-empty,
html[data-theme='dark'] .project-task small,
html[data-theme='dark'] .project-channels small,
html[data-theme='dark'] .project-channels > button span,
html[data-theme='dark'] .project-chat header p,
html[data-theme='dark'] .project-chat-messages small,
html[data-theme='dark'] .project-iterations header p,
html[data-theme='dark'] .project-three-columns span,
html[data-theme='dark'] .project-iterations footer,
html[data-theme='dark'] .project-ideas > article > p,
html[data-theme='dark'] .project-ideas footer,
html[data-theme='dark'] .project-team h4,
html[data-theme='dark'] .project-team p,
html[data-theme='dark'] .project-releases time,
html[data-theme='dark'] .project-releases h3 small,
html[data-theme='dark'] .project-releases p,
html[data-theme='dark'] .project-releases footer,
html[data-theme='dark'] .project-form .field > span,
html[data-theme='dark'] .modal-description,
html[data-theme='dark'] .project-sync-note small,
html[data-theme='dark'] .project-analytics span,
html[data-theme='dark'] .project-table td small,
html[data-theme='dark'] .project-channel-members legend,
html[data-theme='dark'] .project-channel-members small,
html[data-theme='dark'] .project-entity-head p,
html[data-theme='dark'] .project-form-section > header p,
html[data-theme='dark'] .project-access-switch small,
html[data-theme='dark'] .project-member-row small,
html[data-theme='dark'] .project-release-readonly span,
html[data-theme='dark'] .project-release-readonly small,
html[data-theme='dark'] .project-view-facts dt,
html[data-theme='dark'] .project-view-description,
html[data-theme='dark'] .project-view-links > a small,
html[data-theme='dark'] .project-view-team p,
html[data-theme='dark'] .project-member-picker > label .icon,
html[data-theme='dark'] .project-member-options small,
html[data-theme='dark'] .project-iteration-overview p,
html[data-theme='dark'] .project-iteration-meta,
html[data-theme='dark'] .project-iteration-section > header p,
html[data-theme='dark'] .project-iteration-idea header p,
html[data-theme='dark'] .project-iteration-tasks small,
html[data-theme='dark'] .project-iteration-tasks > button > .icon,
html[data-theme='dark'] .project-iteration-comment-list time,
html[data-theme='dark'] .project-iteration-tabs button,
html[data-theme='dark'] .project-iteration-task-card small,
html[data-theme='dark'] .project-iteration-task-card > footer > span,
html[data-theme='dark'] .project-iteration-subtasks li,
html[data-theme='dark'] .project-iteration-subtasks li.is-done,
html[data-theme='dark'] .project-iteration-dock small,
html[data-theme='dark'] .project-idea-popup header p,
html[data-theme='dark'] .project-idea-popup section p,
html[data-theme='dark'] .project-idea-popup dt,
html[data-theme='dark'] .project-idea-popup ol,
html[data-theme='dark'] .project-readiness header p,
html[data-theme='dark'] .project-readiness button small,
html[data-theme='dark'] .project-readiness ul li,
html[data-theme='dark'] .project-readiness ul li.is-done,
html[data-theme='dark'] .project-idea-head > div > span:not(.project-pill),
html[data-theme='dark'] .project-idea-chat header small,
html[data-theme='dark'] .project-idea-moderators > p,
html[data-theme='dark'] .project-notification-toggle,
html[data-theme='dark'] .project-idea-chat-list time,
html[data-theme='dark'] .project-idea-votes article small,
html[data-theme='dark'] .project-idea-moderators [data-search] small,
html[data-theme='dark'] .project-type-switch button,
html[data-theme='dark'] .projects-catalog-toolbar p,
html[data-theme='dark'] .project-tile > p,
html[data-theme='dark'] .project-tile footer small,
html[data-theme='dark'] .project-idea-message-actions > button,
html[data-theme='dark'] .project-idea-read-state,
html[data-theme='dark'] .project-idea-reader-list small,
html[data-theme='dark'] .project-idea-composer-context small,
html[data-theme='dark'] .project-idea-mention-picker small { color: var(--muted); }
html[data-theme='dark'] .project-form-section h3,
html[data-theme='dark'] .project-access-switch strong,
html[data-theme='dark'] .project-analytics strong,
html[data-theme='dark'] .project-view-facts dd,
html[data-theme='dark'] .project-iteration-dock strong,
html[data-theme='dark'] .project-tile footer strong { color: var(--text); }
html[data-theme='dark'] .project-eyebrow,
html[data-theme='dark'] .project-tabs button:hover,
html[data-theme='dark'] .project-facts a,
html[data-theme='dark'] .project-team small,
html[data-theme='dark'] .project-auto-version strong,
html[data-theme='dark'] .project-release-readonly strong,
html[data-theme='dark'] .project-view-team small,
html[data-theme='dark'] .project-member-options > button > .icon,
html[data-theme='dark'] .project-iteration-dock span,
html[data-theme='dark'] .project-readiness header strong,
html[data-theme='dark'] .project-idea-message-quote small,
html[data-theme='dark'] .project-type-switch button:hover,
html[data-theme='dark'] .project-tile footer i,
html[data-theme='dark'] .project-idea-read-state > button { color: var(--blue); }
html[data-theme='dark'] .project-avatar,
html[data-theme='dark'] .project-owned,
html[data-theme='dark'] .project-form-section > header > span,
html[data-theme='dark'] .project-chat-messages article > span,
html[data-theme='dark'] .project-team article > span,
html[data-theme='dark'] .project-view-team article > span,
html[data-theme='dark'] .project-member-avatar,
html[data-theme='dark'] .project-iteration-section > header > span,
html[data-theme='dark'] .project-task-order,
html[data-theme='dark'] .project-iteration-comment-list > article > span,
html[data-theme='dark'] .project-idea-chat-list > article > span,
html[data-theme='dark'] .project-person-avatar,
html[data-theme='dark'] .project-idea-checklist li > span,
html[data-theme='dark'] .project-idea-reader-list b { background: var(--blue-soft); color: var(--blue); }
html[data-theme='dark'] .project-vendor,
html[data-theme='dark'] .project-pilot { background: var(--purple-soft); color: var(--purple); }
html[data-theme='dark'] .project-paused,
html[data-theme='dark'] .project-closed { background: var(--subtle); color: var(--muted); }
html[data-theme='dark'] .project-development,
html[data-theme='dark'] .project-new,
html[data-theme='dark'] .project-planned,
html[data-theme='dark'] .project-planning { background: var(--blue-soft); color: var(--blue); }
html[data-theme='dark'] .project-good,
html[data-theme='dark'] .project-active,
html[data-theme='dark'] .project-released,
html[data-theme='dark'] .project-completed,
html[data-theme='dark'] .project-converted,
html[data-theme='dark'] .project-done { background: var(--green-soft); color: var(--green); }
html[data-theme='dark'] .project-attention,
html[data-theme='dark'] .project-testing,
html[data-theme='dark'] .project-approved,
html[data-theme='dark'] .project-review,
html[data-theme='dark'] .project-running { background: var(--amber-soft); color: var(--amber); }
html[data-theme='dark'] .project-risk,
html[data-theme='dark'] .project-rejected,
html[data-theme='dark'] .project-alert,
html[data-theme='dark'] .project-delete-warning { background: var(--red-soft); color: var(--red); border-color: var(--red); }
html[data-theme='dark'] .project-link-editor .icon-btn,
html[data-theme='dark'] .project-member-row > .icon-btn { color: var(--red); }
html[data-theme='dark'] .project-sync-note,
html[data-theme='dark'] .project-auto-version,
html[data-theme='dark'] .project-release-readonly,
html[data-theme='dark'] .project-idea-composer-context {
  background: var(--blue-soft); color: var(--text); border-color: var(--blue);
}
html[data-theme='dark'] .project-type-filter .is-active,
html[data-theme='dark'] .project-type-switch button.is-active,
html[data-theme='dark'] .project-iteration-tabs button.is-active {
  background: var(--surface-elevated); color: var(--blue); box-shadow: none;
}
html[data-theme='dark'] .project-list-item.is-active,
html[data-theme='dark'] .project-type-switch .is-active b {
  background: var(--blue-soft); color: var(--blue); border-color: var(--blue);
}
html[data-theme='dark'] .project-tabs button.is-active { color: var(--blue); border-color: var(--blue); }
html[data-theme='dark'] .project-list-item:hover,
html[data-theme='dark'] .project-task:hover,
html[data-theme='dark'] .project-member-options > button:hover,
html[data-theme='dark'] .project-iteration-tasks > button:hover,
html[data-theme='dark'] .project-idea-message-actions > button:hover,
html[data-theme='dark'] .project-idea-mention-picker button:hover,
html[data-theme='dark'] .project-view-links > a:hover { background: var(--surface-elevated); color: var(--blue); border-color: var(--blue); }
html[data-theme='dark'] .project-channels > button:not(.button):hover,
html[data-theme='dark'] .project-channels > button.is-active {
  background: var(--blue-soft); color: var(--blue);
}
html[data-theme='dark'] .project-tile:hover { border-color: var(--blue); box-shadow: var(--shadow); }
html[data-theme='dark'] .project-view-links > a,
html[data-theme='dark'] .project-idea-files button { background: var(--surface-soft); color: var(--blue); }
html[data-theme='dark'] .project-readiness-check,
html[data-theme='dark'] .project-iteration-subtasks li > span,
html[data-theme='dark'] .project-iteration-task-card > footer button {
  background: var(--surface); color: var(--blue);
}
html[data-theme='dark'] .project-readiness .is-done > .project-readiness-check,
html[data-theme='dark'] .project-readiness > ol > li.is-done .project-readiness-check,
html[data-theme='dark'] .project-iteration-subtasks li.is-done > span { background: var(--green-soft); color: var(--green); border-color: var(--green); }
html[data-theme='dark'] .project-readiness ul .icon { color: var(--green); }
html[data-theme='dark'] .project-task-state { border-color: var(--blue); }
html[data-theme='dark'] .project-iteration-planned { border-top-color: var(--blue); }
html[data-theme='dark'] .project-iteration-working { border-top-color: var(--amber); }
html[data-theme='dark'] .project-iteration-completed { border-top-color: var(--green); }
html[data-theme='dark'] .project-releases:before { background: var(--line); }
html[data-theme='dark'] .project-release-dot { background: var(--blue); border-color: var(--surface); box-shadow: 0 0 0 1px var(--blue); }
html[data-theme='dark'] .project-table th { background: var(--subtle); color: var(--muted); }
html[data-theme='dark'] .project-search input { background: transparent; }
html[data-theme='dark'] .project-access-switch input,
html[data-theme='dark'] .project-member-row > input[type='checkbox'] { accent-color: var(--blue); }
html[data-theme='dark'] .project-idea-chat-list > .muted { background: var(--surface-soft); color: var(--muted); }
html[data-theme='dark'] .project-idea-chat-list > article.is-mine > div > p { background: var(--blue-soft); }
html[data-theme='dark'] .project-idea-message-quote { border-color: var(--blue); }
/* The source quote color is important; keep this exception confined to that quote. */
html[data-theme='dark'] .project-idea-message-quote p { color: var(--muted) !important; }
html[data-theme='dark'] .project-idea-message-files .attachment-chip,
html[data-theme='dark'] .project-idea-comment-files .attachment-chip { background: var(--surface-soft); }
html[data-theme='dark'] .project-idea-compose-tools > label,
html[data-theme='dark'] .project-idea-compose-tools > button { color: var(--blue); }
html[data-theme='dark'] .project-iteration-dock,
html[data-theme='dark'] .project-idea-reader-list,
html[data-theme='dark'] .project-idea-mention-picker { box-shadow: var(--shadow); }

/* Drive chrome and access dialogs; file images and document content keep their colors. */
html[data-theme='dark'] .drive-shell,
html[data-theme='dark'] .drive-form,
html[data-theme='dark'] .drive-sharing,
html[data-theme='dark'] .drive-heading h2,
html[data-theme='dark'] .drive-name-link,
html[data-theme='dark'] .drive-breadcrumbs [aria-current],
html[data-theme='dark'] .drive-sharing h3,
html[data-theme='dark'] .drive-empty h3 { color: var(--text); }
html[data-theme='dark'] .drive-panel,
html[data-theme='dark'] .drive-limit,
html[data-theme='dark'] .drive-server-note { background: var(--surface); border-color: var(--line); }
html[data-theme='dark'] .drive-tabs,
html[data-theme='dark'] .drive-public { background: var(--surface-soft); border-color: var(--line); }
html[data-theme='dark'] .drive-eyebrow,
html[data-theme='dark'] .drive-heading p,
html[data-theme='dark'] .drive-limit,
html[data-theme='dark'] .drive-tabs button,
html[data-theme='dark'] .drive-breadcrumbs,
html[data-theme='dark'] .drive-context,
html[data-theme='dark'] .drive-action,
html[data-theme='dark'] .drive-table td,
html[data-theme='dark'] .drive-file-name small,
html[data-theme='dark'] .drive-empty > .icon,
html[data-theme='dark'] .drive-empty p,
html[data-theme='dark'] .drive-footer,
html[data-theme='dark'] .drive-muted,
html[data-theme='dark'] .drive-field,
html[data-theme='dark'] .drive-form-hint,
html[data-theme='dark'] .drive-share-heading p,
html[data-theme='dark'] .drive-sharing h3 .icon,
html[data-theme='dark'] .drive-public-off { color: var(--muted); }
html[data-theme='dark'] .drive-breadcrumbs button,
html[data-theme='dark'] .drive-tabs button:hover,
html[data-theme='dark'] .drive-name-link:is(a,button):hover { color: var(--blue); }
html[data-theme='dark'] .drive-tabs button.is-active { background: var(--surface-elevated); color: var(--blue); box-shadow: none; }
html[data-theme='dark'] .drive-table th,
html[data-theme='dark'] .drive-access-badge { background: var(--subtle); color: var(--muted); border-color: var(--line); }
html[data-theme='dark'] .drive-table tbody tr:hover { background: var(--surface-elevated); }
html[data-theme='dark'] .drive-toolbar,
html[data-theme='dark'] .drive-table td,
html[data-theme='dark'] .drive-footer,
html[data-theme='dark'] .drive-share-heading,
html[data-theme='dark'] .drive-members,
html[data-theme='dark'] .drive-member { border-color: var(--line); }
html[data-theme='dark'] .drive-file-icon,
html[data-theme='dark'] .drive-avatar,
html[data-theme='dark'] .drive-progress,
html[data-theme='dark'] .drive-access-badge.is-edit { background: var(--blue-soft); color: var(--blue); border-color: var(--line); }
html[data-theme='dark'] .drive-file-icon.is-folder { background: var(--amber-soft); color: var(--amber); }
html[data-theme='dark'] .drive-action:hover { background: var(--surface-elevated); color: var(--blue); border-color: var(--blue); }
html[data-theme='dark'] .drive-action.is-danger:hover,
html[data-theme='dark'] .drive-form-error { background: var(--red-soft); color: var(--red); border-color: var(--red); }
html[data-theme='dark'] .drive-empty p.drive-error,
html[data-theme='dark'] .drive-error,
html[data-theme='dark'] .drive-text-danger { color: var(--red); }
html[data-theme='dark'] .drive-public-warning { color: var(--amber); }
html[data-theme='dark'] .drive-field input[readonly] { background: var(--subtle); color: var(--muted); }
html[data-theme='dark'] .drive-spinner { border-color: var(--line); border-top-color: var(--blue); }
html[data-theme='dark'] .drive-upload:focus-within { outline-color: var(--blue); }
html[data-theme='dark'] .drive-shell :is(button,a,input,select):focus-visible,
html[data-theme='dark'] .drive-sharing :is(button,a,input,select):focus-visible,
html[data-theme='dark'] .drive-form :is(button,a,input,select):focus-visible { outline-color: var(--blue); }

/* Remaining workspace surfaces introduced after the original appearance layer. */
html[data-theme='dark'] .record-edit-column { background: var(--surface-soft); }
html[data-theme='dark'] .record-edit-actions {
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface-soft) 85%, transparent), var(--surface-soft) 35%);
}
html[data-theme='dark'] .header-tools>.header-notes { background: var(--surface); color: var(--text); border-color: var(--line); box-shadow: var(--shadow); }
html[data-theme='dark'] .header-tools>.header-notes:hover { background: var(--surface-elevated); color: var(--blue); }
html[data-theme='dark'] .header-tools>.header-notes[aria-current='page'] { background: var(--blue-soft); color: var(--blue); box-shadow: inset 0 0 0 1px var(--blue); }
html[data-theme='dark'] .header-tools>:is(.header-calendar,.header-support,.header-notes,.header-telephony):focus-visible { outline-color: var(--blue); }
html[data-theme='dark'] .notes-preview-workspace { background: var(--bg); border-color: var(--line); }
html[data-theme='dark'] .approved-mail-review-note { background: var(--blue-soft); color: var(--muted); }
html[data-theme='dark'] .approved-mail-frame { background: var(--surface); }
html[data-theme='dark'] .open-line-card { background: var(--surface); border-color: var(--line); }
html[data-theme='dark'] .open-line-operators { border-color: var(--line); }
html[data-theme='dark'] .support-project-state,
html[data-theme='dark'] .support-unread-badge { background: var(--amber-soft); color: var(--amber); border-color: var(--amber); }
html[data-theme='dark'] .support-project-state.active { background: var(--green-soft); color: var(--green); }
html[data-theme='dark'] .support-unidentified { color: var(--amber); }
html[data-theme='dark'] .support-unread-badge:before { background: var(--amber); }

/* Password changes and device sign-in use the chosen palette, including black. */
html[data-theme='dark'] .auth-layout,
html[data-theme='dark'] .friendly-auth { background: var(--bg); }
html[data-theme='dark'] .auth-card,
html[data-theme='dark'] .friendly-auth-card { background: var(--surface); color: var(--text); border-color: var(--line); box-shadow: var(--shadow); }
html[data-theme='dark'] .friendly-auth-card h1,
html[data-theme='dark'] .friendly-auth-card .field,
html[data-theme='dark'] .device-remember strong,
html[data-theme='dark'] .device-comparison { color: var(--text); }
html[data-theme='dark'] .friendly-auth-card > p,
html[data-theme='dark'] .friendly-auth-card .eyebrow,
html[data-theme='dark'] .friendly-auth-card .device-help,
html[data-theme='dark'] .device-remember small,
html[data-theme='dark'] .device-qr-panel,
html[data-theme='dark'] .device-login-tabs button { color: var(--muted); }
html[data-theme='dark'] .device-login-tabs { background: var(--surface-soft); }
html[data-theme='dark'] .device-login-tabs button[aria-pressed='true'] { background: var(--surface-elevated); color: var(--blue); box-shadow: none; }
html[data-theme='dark'] .friendly-auth-card input:not([type='checkbox']) { background: var(--input-bg); color: var(--input-text); border-color: var(--control-border); }
html[data-theme='dark'] .friendly-auth-card input:not([type='checkbox']):focus { border-color: var(--blue); }
html[data-theme='dark'] .device-info,
html[data-theme='dark'] .auth-welcome-mark { background: var(--blue-soft); color: var(--blue); }
html[data-theme='dark'] .auth-welcome-mark span { color: var(--green); }
html[data-theme='dark'] .device-pin-option { border-color: var(--line); }
html[data-theme='dark'] .device-remember input[type='checkbox'] { accent-color: var(--blue); }
html[data-theme='dark'] .friendly-auth-card :focus-visible { outline-color: var(--blue); }
html[data-theme='dark'] .workspace-login-banner {
  --team-ink: var(--text);
  --team-accent: var(--green);
  --team-muted: var(--muted);
  background: linear-gradient(145deg, var(--surface-elevated), var(--surface-soft));
  border-color: var(--line);
}
html[data-theme='dark'] .workspace-login-banner::after {
  border-color: var(--line);
  box-shadow: 0 0 0 42px color-mix(in srgb, var(--green) 3%, transparent), 0 0 0 84px color-mix(in srgb, var(--green) 2%, transparent);
}
html[data-theme='dark'] .workspace-login-banner-dots button > span { background: var(--muted); }
html[data-theme='dark'] .workspace-login-banner-dots button[aria-pressed='true'] > span { background: var(--green); }
html[data-theme='dark'] .workspace-login-banner-dots button:focus-visible { outline-color: var(--blue); }
