/* Deep Midnight TC02. All overrides are dark-only and preserve layout and artwork. */
html:root[data-theme="dark"] {
  --navy:#D5DEE8; --blue:#8CABC9; --ink:#D5DEE8; --muted:#A8B6C6;
  --soft:#1B2530; --white:#141B24;
  --bg-page:#0D1118; --bg-surface:#141B24; --bg-surface-elevated:#1B2530;
  --bg-elevated:#1B2530; --bg-input:#202B37; --bg-hover:#263544;
  --bg-interactive:#202B37; --bg-selected:#29415C; --bg-disabled:#18212C;
  --text-primary:#D5DEE8; --text-secondary:#A8B6C6; --text-muted:#9DADBE;
  --text-disabled:#8999AA; --text-link:#8CABC9; --text-inverse:#0D1118;
  --border-default:#344354; --border-strong:#536577; --border-selected:#7898B8;
  --accent-primary:#7898B8; --accent-hover:#8DA9C5;
  --dm-control-edge:#718498;
  --dm-success-bg:#20362F; --dm-success-text:#A6CABA; --dm-success-edge:#658D7B;
  --dm-warning-bg:#372D21; --dm-warning-text:#D8C298; --dm-warning-edge:#967E54;
  --dm-error-bg:#38262D; --dm-error-text:#E2B1BC; --dm-error-edge:#A37583;
  --overlay-bg:rgba(0,3,8,.78); --shadow-default:0 12px 34px #0006;
  color-scheme:dark;
}
html:root[data-theme="dark"] :is(body,#app,.app-shell,.page-view,.home-view,.auth-stage,.admin-layout,.home8-view) { background:var(--bg-page); color:var(--text-primary); }
html:root[data-theme="dark"] :is(.topbar,.auth-card,.profile-menu,.user-menu,.home8-card,.module-card,.table-card,.contract-card,.settings-card,.template-card,.account-card,.account-filter-card,.account-link-card,.complex-section,.my-work-panel,.my-work-card,.panel-item,.shared-link-section,.structure-modules,.structure-content) { background:var(--bg-surface); color:var(--text-primary); border-color:var(--border-default); }
html:root[data-theme="dark"] :is(.side-panel,.revision-side-panel,.create-dialog,.confirm-dialog,.revision-dialog,.conflict-dialog,.email-dialog,.board-dialog,.image-dialog,.eiom-detail-dialog,.sp-modal,.sp-panel) { background:var(--bg-surface-elevated); color:var(--text-primary); border-color:var(--border-default); }
html:root[data-theme="dark"] :is(input:not([type="checkbox"]):not([type="radio"]),textarea,select) { background-color:var(--bg-input); color:var(--text-primary); border-color:var(--border-default); }
html:root[data-theme="dark"] :is(input,textarea)::placeholder { color:var(--text-secondary); opacity:1; }
html:root[data-theme="dark"] :is(input,textarea,select):disabled { background:var(--bg-disabled); color:var(--text-disabled); }
html:root[data-theme="dark"] :is(h1,h2,h3,strong,b,.row-title,.fixed-id,.profile-detail,.account-card-values,.account-card-values dd) { color:var(--text-primary); }
html:root[data-theme="dark"] :is(small,.muted,.page-title p,.auth-copy p,.profile-copy,.profile-detail span,.account-card > header,.account-card-values dt) { color:var(--text-secondary); }
html:root[data-theme="dark"] :is(th,thead,.group-tabs,.account-list-tabs button,.account-card-edit,.document-switches,.summary-row button,.work-meta > span,.quarter-meta > span,.review-strip,.recipient-choice,.profile-security-section,.auth-reset-fallback,.auth-reset-flow-account) { background:var(--bg-input); color:var(--text-secondary); border-color:var(--border-default); }
html:root[data-theme="dark"] :is(table,th,td,.dialog-head,.panel-head,.account-system-head,.account-card,.account-list-grid,.work-meta,.quarter-meta) { border-color:var(--border-default); }
html:root[data-theme="dark"] :is(.ghost,.secondary,.detail-actions button,.complex-head button,.group-tabs button,.account-actions button,.revision-button,.dialog-cancel,.account-list-tabs button,.profile-theme button) { background:var(--bg-interactive); color:var(--text-primary); border-color:var(--border-default); }
html:root[data-theme="dark"] :is(.primary,button.primary,.revision-button.primary,.auth-submit,.profile-theme button.active) { background:var(--accent-primary); color:var(--text-inverse); border-color:var(--accent-primary); }
html:root[data-theme="dark"] :is(.primary,.revision-button.primary,.auth-submit):hover { background:var(--accent-hover); color:var(--text-inverse); }
html:root[data-theme="dark"] :is(.account-list-tabs button.active,.group-tabs button.active,.document-switches button.active) { background:var(--bg-selected); color:var(--text-primary); border-color:var(--accent-primary); }
html:root[data-theme="dark"] :is(button,a,input,textarea,select):focus-visible { outline-color:var(--accent-primary); }
html:root[data-theme="dark"] :is(.home8-view,.home8-view button,.home8-view a) { color:var(--text-primary); }
html:root[data-theme="dark"] .home8-header.topbar { background:var(--bg-surface); border-color:var(--border-default); }
html:root[data-theme="dark"] .home8-hero { background:linear-gradient(var(--bg-surface),var(--bg-page)); }
html:root[data-theme="dark"] .home8-hero::before,
html:root[data-theme="dark"] .home8-hero::after { background-image:linear-gradient(0deg,var(--bg-page),rgba(13,17,24,.86) 32%),url('/home8-assets/approved-hero-reference.png'); }
html:root[data-theme="dark"] :is(.home8-hero>p,.home8-hero h1,.home8-hero h2,.home8-header .brand-caption small,.home8-card h2,.home8-personal-row strong,.home8-system strong,.home8-sharepoint strong,.home8-launch strong) { color:var(--text-primary); }
html:root[data-theme="dark"] :is(.home8-hero h1 span,.home8-card h2>span,.home8-launch-arrow,.home8-card h2>button,.home8-personal-row i,.home8-system i) { color:var(--accent-primary); }
html:root[data-theme="dark"] :is(.home8-search,.home8-search-results,.home8-personal-row,.home8-system,.home8-system[data-external-system],.home8-sharepoint,.home8-radial .home8-launch,.home8-search-examples button,.home8-inboxes button,.home8-tabs button,.home8-completed,.home8-month-list,.home8-monthly h2>input) { background:var(--bg-input); color:var(--text-primary); border-color:var(--border-default); box-shadow:0 3px 12px #0003; }
html:root[data-theme="dark"] :is(.home8-radial .home8-launch:hover,.home8-personal-row:hover,.home8-system:hover,.home8-search-results button:hover,.home8-inboxes button:hover,.home8-search-examples button:hover) { background:var(--bg-hover); border-color:var(--accent-primary); color:var(--text-primary); }
html:root[data-theme="dark"] .home8-search>button { background:var(--accent-primary); color:var(--text-inverse); }
html:root[data-theme="dark"] :is(.home8-search kbd,.home8-search-results button,.home8-tabs button.active) { background:var(--bg-selected); color:var(--text-primary); }
html:root[data-theme="dark"] :is(.home8-personal-row small,.home8-system small,.home8-sharepoint small,.home8-search-results p,.home8-search-results button span,.home8-search-results small,.home8-search-examples small,.home8-chart-axis,.home8-bar-value,.home8-notice>span,.home8-announcements .home8-notice>span,.home8-build,.home8-divider) { color:var(--text-secondary); }
html:root[data-theme="dark"] .home8-view .home8-chart { background:var(--bg-surface); border-color:var(--border-default); }
html:root[data-theme="dark"] .home8-chart-grid { background:repeating-linear-gradient(to top,var(--border-default) 0 1px,transparent 1px var(--chart-step)); }
html:root[data-theme="dark"] .home8-bar-plot>i { background:linear-gradient(#6989A8,#47647F); }
html:root[data-theme="dark"] .home8-bar.selected .home8-bar-plot>i { background:linear-gradient(#89A4BF,#6388B2); }
html:root[data-theme="dark"] :is(.home8-notice,.home8-completed,.home8-divider:after) { border-color:var(--border-default); }
html:root[data-theme="dark"] .home8-divider:after { background:var(--border-default); }
html:root[data-theme="dark"] .home8-radial .home8-core { background:radial-gradient(circle at 28% 23%,#34516C,#283C51 42%,#1C2B3C 78%); border-color:#34495E; box-shadow:0 0 0 7px #1A2734,inset 0 3px 9px #86A3C319; }
html:root[data-theme="dark"] .home8-launch-icon .home-work-icon { mix-blend-mode:normal; }
html:root[data-theme="dark"] .home8-core :is(strong,span,i) { color:var(--text-primary); }
html:root[data-theme="dark"] :is(.home8-orbit,.home8-orbit:after,.home8-radial:before) { border-color:var(--border-default); background:none; box-shadow:none; }
html:root[data-theme="dark"] .home8-radial:after { background:linear-gradient(transparent,var(--bg-page)); }
html:root[data-theme="dark"] .home8-view .home8-eiom-badge { background:var(--bg-surface); }
html:root[data-theme="dark"] :is(.message.error,.danger-note,.error-message,.template-sync-message) { background:var(--dm-error-bg); color:var(--dm-error-text); border-color:var(--dm-error-edge); }
html:root[data-theme="dark"] :is(.message.success,.success-message) { background:var(--dm-success-bg); color:var(--dm-success-text); border-color:var(--dm-success-edge); }
html:root[data-theme="dark"] :is(.warning-note,.security-tip,.realtime-banner,.auth-reset-unavailable,.email-onboarding-guide,.email-onboarding-highlight) { background:var(--dm-warning-bg); color:var(--dm-warning-text); border-color:var(--dm-warning-edge); }
html:root[data-theme="dark"] .template-sync-dialog { --ts-heading:var(--text-primary); --ts-body:var(--text-secondary); --ts-card:var(--bg-surface); --ts-card-border:var(--border-default); --ts-before:var(--bg-input); --ts-after:var(--bg-selected); --ts-after-border:var(--accent-primary); --ts-rule:var(--border-default); background:var(--bg-surface-elevated); }
html:root[data-theme="dark"] .template-sync-dialog :is(.template-sync-card,.template-sync-value,.template-sync-count,.template-sync-close,.template-sync-card-icon) { background:var(--bg-input); color:var(--text-primary); border-color:var(--border-default); }
html:root[data-theme="dark"] .template-sync-dialog .template-sync-apply { background:var(--accent-primary); color:var(--text-inverse); }
html:root[data-theme="dark"] :is(.suggestion-drop-zone,.suggestion-upload-preview,.account-card-edit,.sp-folder-row,.sp-job-card) { background:var(--bg-input); color:var(--text-primary); border-color:var(--border-default); }
html:root[data-theme="dark"] * { scrollbar-color:var(--border-strong) var(--bg-page); }
html:root[data-theme="dark"] :is(.sp-dialog,.sp-admin-dialog) { background:var(--bg-surface-elevated); color:var(--text-primary); border-color:var(--border-default); }
html:root[data-theme="dark"] :is(.sp-head,.sp-card,.sp-tools-menu,.sp-history-panel,.sp-progress,.sp-queue,.sp-admin,.sp-selection-summary,.sp-command-row) { background:var(--bg-surface); color:var(--text-primary); border-color:var(--border-default); }
html:root[data-theme="dark"] :is(.sp-dialog button,.sp-admin button,.sp-tools>summary,.sp-sidebar-trigger,.sp-detect>span,.sp-folder-results button,.sp-decision,.sp-items li,.sp-phases li,.sp-info-row,.account-copy,.account-list-tabs button b) { background:var(--bg-input); color:var(--text-primary); border-color:var(--border-default); }
html:root[data-theme="dark"] :is(.sp-dialog button.sp-primary,.sp-admin button.sp-primary) { background:var(--accent-primary); color:var(--text-inverse); border-color:var(--accent-primary); }
html:root[data-theme="dark"] :is(.sp-dialog button,.sp-admin button):hover:not(:disabled) { background:var(--bg-hover); color:var(--text-primary); border-color:var(--accent-primary); }
html:root[data-theme="dark"] :is(.sp-head p,.sp-note,.sp-field-label,.sp-search-label,.sp-breadcrumb,.sp-target-details,.sp-progress-detail,.sp-sidebar-copy small,.sp-admin small) { color:var(--text-secondary); }
html:root[data-theme="dark"] :is(.sp-form>select,.sp-form>input,.sp-folder-tools input,.sp-admin input:not([type=checkbox]),.sp-admin textarea,.sp-target-details p) { background:var(--bg-input); color:var(--text-primary); border-color:var(--border-default); }
html:root[data-theme="dark"] .sp-overlay { background:var(--overlay-bg); }
html:root[data-theme="dark"] :is(.sp-connection-compact [data-state=error],.sp-connection-compact [data-state=incompatible],.sp-connection-compact [data-state=disconnected],.sp-phases li[data-state=error],.sp-phases li[data-state=cancelled],[data-sp-message][data-kind=error],.sp-decision [data-decision=cancel]) { background:var(--dm-error-bg); color:var(--dm-error-text); border-color:var(--dm-error-edge); }
html:root[data-theme="dark"] [data-sp-message][data-kind=ok] { color:var(--dm-success-text); }
html:root[data-theme="dark"] :is(.sp-note[data-kind=warning],.sp-selection-warning) { color:var(--dm-warning-text); }

/* Home accents and existing icon artwork. */
html:root[data-theme="dark"] .home8-radial .home8-launch:hover { box-shadow:0 3px 12px #0003; }
html:root[data-theme="dark"] .home8-core :is(span,i) { color:var(--text-secondary); }
html:root[data-theme="dark"] .home8-launch-icon .home-work-icon,
html:root[data-theme="dark"] .home8-view .sidebar-utility-icon { filter:saturate(.72) brightness(.88); }
html:root[data-theme="dark"] .home8-heading-icon svg { filter:none; }
html:root[data-theme="dark"] .home8-view :is(.home8-empty,.home8-notice time,.home8-alerts .notification-card>small) { color:var(--text-secondary); }
html:root[data-theme="dark"] .home8-notice b { background:var(--bg-selected); color:var(--text-link); }
html:root[data-theme="dark"] .home8-notice b.important { background:var(--dm-error-bg); color:var(--dm-error-text); }
html:root[data-theme="dark"] .home8-tabs button[aria-pressed="true"] { background:var(--bg-selected); color:var(--text-primary); }
html:root[data-theme="dark"] .home8-view .home8-count { background:var(--bg-selected); color:var(--text-primary); }
html:root[data-theme="dark"] .home8-personal-row[data-work-panel=review] .home8-count { background:var(--dm-warning-bg); color:var(--dm-warning-text); }

/* SharePoint upload, preparation, status and nested dialogs. */
html:root[data-theme="dark"] .sp-drop { background:var(--bg-surface-elevated); border-color:var(--dm-control-edge); }
html:root[data-theme="dark"] .sp-drop.drag-over { background:var(--bg-selected); border-color:var(--border-selected); }
html:root[data-theme="dark"] :is(.sp-drop>p,.sp-detect small,.sp-head small,.sp-progress-head,.sp-results,.sp-progress-detail .sp-note,.sp-queue article>small,.sp-collision-list small) { color:var(--text-secondary); }
html:root[data-theme="dark"] :is(.sp-dialog,.sp-admin-dialog,.sp-card) { box-shadow:var(--shadow-default); }
html:root[data-theme="dark"] .sp-admin { background:var(--overlay-bg); }
html:root[data-theme="dark"] :is(.sp-queue-detail,.sp-preparation,.sp-sidebar-icon,.sp-admin-grid article,.sp-release-active) { background:var(--bg-surface-elevated); color:var(--text-secondary); border-color:var(--border-default); }
html:root[data-theme="dark"] .sp-connection-compact [data-sp-status-chip] { background:var(--bg-input); color:var(--text-secondary); border-color:var(--dm-control-edge); }
html:root[data-theme="dark"] .sp-connection-compact [data-state=connected],
html:root[data-theme="dark"] .sp-phases li[data-state=done] { background:var(--dm-success-bg); color:var(--dm-success-text); border-color:var(--dm-success-edge); }
html:root[data-theme="dark"] .sp-connection-compact :is([data-state=error],[data-state=incompatible],[data-state=disconnected]) { background:var(--dm-error-bg); color:var(--dm-error-text); border-color:var(--dm-error-edge); }
html:root[data-theme="dark"] .sp-connection-actions>p { color:var(--dm-warning-text); }
html:root[data-theme="dark"] .sp-phases li:is([data-state=active],[data-active=true]),
html:root[data-theme="dark"] .sp-detect>span[aria-pressed=true],
html:root[data-theme="dark"] .sp-folder-row[data-folder-selected]>button,
html:root[data-theme="dark"] .sp-history-filters button[aria-pressed=true] { background:var(--bg-selected); color:var(--text-primary); border-color:var(--border-selected); }
html:root[data-theme="dark"] .sp-progress progress { background:var(--bg-input); accent-color:var(--accent-primary); }
html:root[data-theme="dark"] .sp-progress progress::-webkit-progress-bar { background:var(--bg-input); }
html:root[data-theme="dark"] .sp-progress progress::-webkit-progress-value { background:var(--accent-primary); }
html:root[data-theme="dark"] .sp-progress progress::-moz-progress-bar { background:var(--accent-primary); }
html:root[data-theme="dark"] .sp-progress progress:is([data-state=failed],[data-state=partial])::-webkit-progress-value { background:var(--dm-warning-edge); }
html:root[data-theme="dark"] .sp-progress progress:is([data-state=failed],[data-state=partial])::-moz-progress-bar { background:var(--dm-warning-edge); }
html:root[data-theme="dark"] .sp-preparation li[data-state=done] { color:var(--dm-success-text); }
html:root[data-theme="dark"] .sp-preparation li[data-state=active] { color:var(--text-link); }
html:root[data-theme="dark"] .sp-preparation li[data-state=error] { color:var(--dm-error-text); }
html:root[data-theme="dark"] .sp-decision [data-decision=overwrite] { background:var(--dm-warning-bg); color:var(--dm-warning-text); border-color:var(--dm-warning-edge); }
html:root[data-theme="dark"] .sp-decision [data-decision=cancel] { background:var(--dm-error-bg); color:var(--dm-error-text); border-color:var(--dm-error-edge); }
html:root[data-theme="dark"] :is(.sp-dialog,.sp-admin-dialog) button:disabled { background:var(--bg-disabled); color:var(--text-disabled); border-color:var(--border-default); opacity:1; }

/* PANEL, work drawers and profile. */
html:root[data-theme="dark"] :is(.panel-legacy-audit,.panel-contract-group .empty-panel,.my-work-panel .completed-empty>span) { background:var(--bg-input); color:var(--text-secondary); border-color:var(--border-default); }
html:root[data-theme="dark"] .panel-contract-group .contract-stats :is(span,i) { color:var(--text-secondary); }
html:root[data-theme="dark"] .panel-parent-card-wrap .contract-delete { background:var(--dm-error-bg); color:var(--dm-error-text); border-color:var(--dm-error-edge); }
html:root[data-theme="dark"] .my-work-panel>header button[data-work-panel-close] { background:var(--bg-interactive); color:var(--text-primary); border-color:var(--dm-control-edge); }
html:root[data-theme="dark"] .my-work-panel>header button[data-work-panel-close]:hover { background:var(--bg-selected); border-color:var(--border-selected); }
html:root[data-theme="dark"] .my-work-assigned-tabs button { background:var(--bg-interactive); color:var(--text-secondary); border-color:var(--dm-control-edge); }
html:root[data-theme="dark"] .my-work-assigned-tabs button.active,
html:root[data-theme="dark"] .side-panel .panel-tabs button.selected { background:var(--bg-selected); color:var(--text-primary); border-color:var(--border-selected); box-shadow:inset 0 -2px var(--border-selected); }
html:root[data-theme="dark"] .my-work-assigned-tabs em { background:var(--bg-surface); color:var(--text-secondary); }
html:root[data-theme="dark"] .side-panel :is(.panel-tabs button,.panel-item>span:not(.status)) { color:var(--text-secondary); }
html:root[data-theme="dark"] .profile-dialog .profile-detail span { border-color:var(--border-default); background:var(--bg-surface); }
html:root[data-theme="dark"] .profile-dialog :is(.profile-section-heading small,.profile-security-section>p,.profile-feature-unavailable,.compact-form label,.browser-assistant-profile-toggle small) { color:var(--text-secondary); }
html:root[data-theme="dark"] .browser-assistant-profile-toggle { background:var(--bg-input); border-color:var(--dm-control-edge); }
html:root[data-theme="dark"] .browser-assistant-profile-toggle:has(input:checked) { background:var(--bg-selected); border-color:var(--border-selected); }
html:root[data-theme="dark"] .browser-assistant-profile-toggle:has(input:disabled) { background:var(--bg-disabled); border-color:var(--border-default); cursor:not-allowed; }
html:root[data-theme="dark"] .browser-assistant-profile-toggle:has(input:disabled) :is(b,small) { color:var(--text-disabled); }
html:root[data-theme="dark"] .profile-recovery-status { background:var(--bg-input); color:var(--text-secondary); }
html:root[data-theme="dark"] .profile-recovery-status.verified { background:var(--dm-success-bg); color:var(--dm-success-text); }
html:root[data-theme="dark"] .profile-dialog .compact-form+.compact-form { border-top-color:var(--border-default); }
html:root[data-theme="dark"] .browser-assistant-pairing-warning { background:var(--dm-warning-bg); color:var(--dm-warning-text); border-color:var(--dm-warning-edge); }
html:root[data-theme="dark"] .assistant-visibility-toggle { color:var(--text-secondary); }
html:root[data-theme="dark"] .assistant-visibility-status { background:var(--bg-input); color:var(--text-secondary); }
html:root[data-theme="dark"] .assistant-visibility-status.enabled { background:var(--dm-success-bg); color:var(--dm-success-text); }

/* Functional control boundaries are stronger than decorative card borders. */
html:root[data-theme="dark"] :is(.sp-dialog,.sp-admin-dialog,.profile-dialog,.board-dialog) :is(button,input:not([type=checkbox]):not([type=radio]),textarea,select):not(:disabled) { border-color:var(--dm-control-edge); }
html:root[data-theme="dark"] :is(.sp-dialog,.sp-admin-dialog,.profile-dialog,.board-dialog) :is(.primary,.sp-primary):not(:disabled) { border-color:var(--accent-primary); }
html:root[data-theme="dark"] :is(.sp-dialog,.sp-admin-dialog,.profile-dialog,.board-dialog) :is(button,input,textarea,select):disabled { background-color:var(--bg-disabled); color:var(--text-disabled); border-color:var(--border-default); }
html:root[data-theme="dark"] .home8-view :is(.system-shortcut-icon,.home8-cloud-upload,.home8-heading-icon svg) { filter:saturate(.7) brightness(.82); }
html:root[data-theme="dark"] .home8-view .home8-bridge-chip { background:var(--bg-selected); color:var(--text-primary); }
html:root[data-theme="dark"] .home8-sharepoint--c .sidebar-footer-utility { border-color:var(--border-default); }
html:root[data-theme="dark"] .home8-sharepoint--c .sp-sidebar-trigger:before { color:var(--text-link); }
html:root[data-theme="dark"] .home8-sharepoint--c .sp-sidebar-trigger:after,
html:root[data-theme="dark"] .home8-sharepoint--c [data-sp-home-status] { color:var(--text-secondary); }
html:root[data-theme="dark"] .home8-sharepoint--c [data-sp-home-status]:is([data-state=failed],[data-state=partial]) { color:var(--dm-error-text); }
html:root[data-theme="dark"] .home8-sharepoint--c [data-sp-home-status][data-state^=needs-] { color:var(--dm-warning-text); }
