/* Appearance affects application chrome only. No filters or colour inversion:
   brand assets, uploaded images, document pages and exported content stay intact. */
:root { --hub-theme-bg:#f4f5f1; --hub-theme-panel:#fffefb; --hub-theme-raised:#eef1e9; --hub-theme-ink:#111a19; --hub-theme-muted:#5c6b60; --hub-theme-line:#cbd5c5; --hub-theme-accent:#284239; }
.hub-appearance { border:0; padding:0; margin:0 0 24px; min-width:0; }
.hub-appearance legend { font-size:15px; font-weight:700; margin-bottom:8px; color:var(--hub-theme-ink); }
.hub-appearance p { font-size:13px; line-height:1.6; color:var(--hub-theme-muted); max-width:64ch; margin:0 0 12px; }
.hub-appearance>div { display:flex; gap:6px; padding:4px; background:var(--hub-theme-raised); border:1px solid var(--hub-theme-line); border-radius:10px; width:fit-content; max-width:100%; }
.hub-appearance>div>button { display:flex; align-items:center; justify-content:center; gap:7px; padding:9px 12px; margin:0; min-width:0; min-height:38px; border:1px solid transparent; border-radius:7px; background:transparent; color:var(--hub-theme-muted); font:600 13px/1.3 Inter,sans-serif; cursor:pointer; }
.hub-appearance>div>button[aria-pressed="true"] { background:var(--hub-theme-panel); color:var(--hub-theme-ink); border-color:var(--hub-theme-line); box-shadow:0 2px 3px #111a190a; }
.hub-appearance>div>button:focus-visible { outline:2px solid #809076; outline-offset:2px; }
.hub-appearance.is-compact { margin:8px 0 14px; }
.ws-location-settings>.hub-appearance { grid-column:1/-1; width:100%; padding-bottom:22px; margin:0 0 4px; border-bottom:1px solid var(--hub-theme-line); }
.hub-appearance.is-compact>div { width:100%; }.hub-appearance.is-compact>div>button { flex:1; padding:8px; flex-direction:column; gap:4px; font-size:12px; }
.welcome-mark .welcome-logo-dark-mode { display:none; }
@media screen {
  /* Canvas → section → nested card → control. Green is an accent, not a wash. */
  html[data-theme="dark"] { color-scheme:dark; --hub-theme-bg:#111a19; --hub-theme-panel:#252a29; --hub-theme-card:#303634; --hub-theme-raised:#3b423f; --hub-theme-inset:#1a201e; --hub-theme-ink:#f0f3ef; --hub-theme-muted:#b8c3bc; --hub-theme-line:#56615b; --hub-theme-accent:#b4cca4; --hub-theme-primary:#809b75; --hub-theme-primary-hover:#94ae89; --hub-theme-primary-ink:#111a19; --hub-theme-focus:#91c9ed; --hub-theme-shadow:0 4px 16px #0003,0 1px 0 #ffffff06 inset; --bg:var(--hub-theme-bg); --panel:var(--hub-theme-panel); --ink:var(--hub-theme-ink); --muted:var(--hub-theme-muted); --line:var(--hub-theme-line); --soft:var(--hub-theme-raised); }
  html[data-theme="light"] { color-scheme:light; }
  html[data-theme="dark"] body { background:var(--hub-theme-bg); color:var(--hub-theme-ink); }
  /* Native controls, never the print canvas or template editor. */
  html[data-theme="dark"] :is(button,input,select,textarea,summary):not(.personal-document-page-stack *, .pdf-preview-frame *, .visual-editor-page *, .template-editor-page *) { color:var(--hub-theme-ink)!important; border-color:var(--hub-theme-line)!important; background-color:var(--hub-theme-raised)!important; }
  html[data-theme="dark"] :is(input,select,textarea):not([type="checkbox"],[type="radio"],[type="range"],[type="color"],.personal-document-page-stack *, .pdf-preview-frame *) { background-color:var(--hub-theme-inset)!important; }
  html[data-theme="dark"] ::placeholder { color:var(--hub-theme-muted)!important; opacity:1; }
  html[data-theme="dark"] :is(input[type="checkbox"],input[type="radio"]) { accent-color:#aec29b; }
  html[data-theme="dark"] :is(button,a):focus-visible { outline:2px solid #c1d5ab!important; outline-offset:2px; }
  html[data-theme="dark"] :is(h1,h2,h3,h4,label,legend):not(.personal-document-page-stack *, .pdf-preview-frame *, .visual-editor-page *, .template-editor-page *) { color:var(--hub-theme-ink)!important; }
  html[data-theme="dark"] :is(button.active,button[aria-current],button[aria-pressed="true"],button.primary,button.tk-primary,.ws-nav-button.active):not(.saved-bid, .personal-document-page-stack *, .pdf-preview-frame *) { background-color:#38503b!important; color:#f1f6e9!important; border-color:#7e976c!important; }
  html[data-theme="dark"] button:hover:not(:disabled):not(.personal-document-page-stack *, .pdf-preview-frame *) { background-color:#343d38!important; }
  /* Hub, Home and access management. */
  html[data-theme="dark"] :is(.ws-shell,.ws-main,.ws-content,.ws-app-workspace,.ws-admin-page,.ws-applications-page) { background:var(--hub-theme-bg)!important; color:var(--hub-theme-ink); }
  html:root[data-theme="dark"] :is(.ws-sidebar,.ws-brand) { background:var(--hub-theme-bg)!important; border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] :is(.hub-home-hero,.hub-studio-time-rule>span) { background:var(--hub-theme-panel)!important; border-color:var(--hub-theme-line)!important; }
  html[data-theme="dark"] :is(.ws-topbar,.ws-tabbar,.ws-profile-menu,.ws-notifications-panel,.ws-people-list,.ws-permission-panel,.ws-access-guide,.ws-location-settings,.ws-view-as-control,.ws-group-card,.ws-group-editor,.hub-attention,.hub-today-calendar,.hub-quick-list,.ws-app-card,.ws-card) { background:var(--hub-theme-panel)!important; color:var(--hub-theme-ink)!important; border-color:var(--hub-theme-line)!important; }
  html[data-theme="dark"] :is(.ws-control-nav,.ws-person-nav,.ws-access-save,.ws-guide-grid article,.ws-permission-head,.ws-permission-row,.ws-regional-settings-preview) { background:var(--hub-theme-raised)!important; color:var(--hub-theme-ink)!important; border-color:var(--hub-theme-line)!important; }
  html[data-theme="dark"] :is(.ws-workspace-title strong,.ws-profile strong,.hub-attention strong,.hub-quick-list strong,.ws-permission-row strong,.ws-access-definitions dt,.ws-people-list strong) { color:var(--hub-theme-ink)!important; }
  html[data-theme="dark"] :is(.ws-workspace-title>span,.ws-admin-page p,.ws-admin-page small,.ws-admin-page dd,.ws-access-help,.hub-today-calendar p,.hub-attention p,.hub-attention small,.hub-quick-list small,.ws-app-card p) { color:var(--hub-theme-muted)!important; }
  /* Applications uses launch articles and sidebar editors, not .ws-app-card. */
  html:root[data-theme="dark"] :is(.hub-app-launch-grid>article,.hub-app-sidebar-editor,.hub-app-available-editor) { background:var(--hub-theme-panel)!important; color:var(--hub-theme-ink)!important; border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] :is(.hub-app-sidebar-list article,.hub-app-available-editor article) { background:var(--hub-theme-inset)!important; border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] .hub-app-launch-grid>article:is(:hover,:focus-visible) { background:var(--hub-theme-raised)!important; border-color:#809076!important; }
  html:root[data-theme="dark"] .hub-app-launch-grid>article:focus-visible { outline:2px solid var(--hub-theme-accent); outline-offset:3px; }
  html:root[data-theme="dark"] :is(.hub-app-sidebar-editor,.hub-app-available-editor)>header { border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] :is(.hub-app-launch-grid i,.hub-app-sidebar-list i,.hub-app-available-editor article>i,.hub-app-sidebar-editor header>strong) { background:var(--hub-theme-raised)!important; color:var(--hub-theme-accent)!important; }
  html:root[data-theme="dark"] .ws-applications-page :is(p,small,header span,.hub-app-launch-grid div>span,.hub-app-empty-sidebar) { color:var(--hub-theme-muted)!important; }
  html:root[data-theme="dark"] .ws-applications-page .hub-app-launch-grid div>.ws-wip-label { color:#edca8a!important; }
  html:root[data-theme="dark"] .hub-app-sidebar-list article>b { color:var(--hub-theme-accent)!important; }
  html:root[data-theme="dark"] .hub-app-sidebar-list article>button.remove { color:#efb5a9!important; }
  /* Settings: nested menus must follow the theme as well as the outer page. */
  html:root[data-theme="dark"] :is(.ws-google-settings,.ws-backup-status,.ws-bidding-settings,.ws-bidding-settings-heading,.ws-online-panel,.ws-audit-panel,.ws-attention-assignments) { background:var(--hub-theme-panel)!important; color:var(--hub-theme-ink)!important; border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] :is(.ws-group-members>label,.ws-attention-scope-grid>label,.ws-assignment-picker,.ws-google-account,.ws-backup-facts>div,.ws-audit-date) { background:var(--hub-theme-inset)!important; color:var(--hub-theme-ink)!important; border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] .ws-group-members>label:has(input:checked) { background:#29362d!important; border-color:#809076!important; }
  html:root[data-theme="dark"] :is(.ws-assignment-chips>span,.ws-attention-assignments>header b,.ws-google-settings-heading>strong,.ws-backup-status-heading>strong,.ws-audit-counts b,.ws-audit-toolbar,.ws-audit-list article header span) { background:var(--hub-theme-raised)!important; color:var(--hub-theme-ink)!important; border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] .ws-admin-page :is(.ws-people-list form,.ws-permission-panel>header,.ws-bidding-settings-heading,.ws-online-panel>header,.ws-audit-panel>header,.ws-online-list>div,.ws-group-editor footer) { border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] .ws-audit-list>article { border-bottom-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] .ws-admin-page :is(.ws-person-title span,.ws-view-as-control>div>span,.ws-location-settings>div>span,.ws-regional-settings-grid label>span,.ws-regional-preview>span,.ws-groups-kicker,.ws-bidding-settings-heading span,.ws-google-settings-heading span,.ws-online-panel header span,.ws-audit-panel header span,.ws-audit-date span,.ws-attention-assignments>header span) { color:var(--hub-theme-muted)!important; }
  html:root[data-theme="dark"] :is(.ws-group-members strong,.ws-assignment-picker strong,.ws-attention-scope-grid strong,.ws-regional-preview strong,.ws-google-account strong,.ws-backup-facts strong) { color:var(--hub-theme-ink)!important; }
  html:root[data-theme="dark"] :is(.ws-google-actions a,.ws-audit-download) { background:var(--hub-theme-raised)!important; color:var(--hub-theme-ink)!important; border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] :is(.ws-google-actions a,.ws-audit-download):hover { background:#343d38!important; }
  html:root[data-theme="dark"] :is(.ws-group-members,.ws-section-permission-grid) input:focus-visible+span { outline:2px solid var(--hub-theme-accent); outline-offset:3px; }
  html:root[data-theme="dark"] .ws-section-permission-grid label>span { background:var(--hub-theme-inset)!important; border-color:#6b7a70!important; color:transparent!important; }
  html:root[data-theme="dark"] .ws-section-permission-grid input:checked+span { background:#38503b!important; border-color:#809076!important; color:var(--hub-theme-ink)!important; }
  html:root[data-theme="dark"] :is(.ws-google-settings-heading>strong.is-connected,.ws-backup-status.is-healthy .ws-backup-status-heading>strong,.ws-groups-notice) { background:#243b2b!important; color:#c4dfb8!important; border-color:#506e49!important; }
  html:root[data-theme="dark"] .ws-backup-status:is(.is-warning,.is-stale,.is-missing) .ws-backup-status-heading>strong { background:#3c3625!important; color:#ead1a0!important; border-color:#716342!important; }
  html:root[data-theme="dark"] .ws-admin-page .ws-backup-warning { color:#ead1a0!important; }
  html:root[data-theme="dark"] .ws-admin-page :is(.ws-google-error,.ws-groups-error) { color:#f2b6a4!important; }
  html:root[data-theme="dark"] .ws-groups-error { background:#432c26!important; border-color:#76534a!important; }
  /* Bidding settings is embedded separately from the bid editor. */
  html:root[data-theme="dark"] #dataPage :is(.panel,.archive-row) { background:var(--hub-theme-panel)!important; color:var(--hub-theme-ink)!important; border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] #dataPage .database-empty { background:var(--hub-theme-inset)!important; color:var(--hub-theme-muted)!important; border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] #dataPage :is(p,small,.empty-state) { color:var(--hub-theme-muted)!important; }
  /* God Mode — retain signal colours and its dark analytical console. */
  html[data-theme="dark"] .god-workspace { --god-ink:var(--hub-theme-ink); --god-muted:var(--hub-theme-muted); --god-line:var(--hub-theme-line); --god-green:#b4cca4; --god-blue:#9dbdc9; --god-amber:#e4bc7a; --god-red:#efa899; background:var(--hub-theme-bg)!important; }
  html[data-theme="dark"] :is(.god-card,.god-kpi,.god-source,.god-queue-columns>section) { background:var(--hub-theme-panel)!important; }
  html:root[data-theme="dark"] .god-section-nav { background:var(--hub-theme-panel)!important; border-color:var(--hub-theme-line)!important; }
  html[data-theme="dark"] :is(.god-alert,.god-alert>i,.god-card>header>b,.god-table th,.god-empty,.god-queue-stat,.god-disclosure) { background:var(--hub-theme-raised)!important; color:var(--hub-theme-ink)!important; }
  html[data-theme="dark"] :is(.god-alert.is-critical,.god-kpi.is-danger) { background:#3c2924!important; }
  html[data-theme="dark"] :is(.god-alert.is-watch,.god-kpi.is-warning) { background:#363225!important; }
  html[data-theme="dark"] .god-alert.is-good { background:#243b2b!important; }
  /* Finance — charcoal ledger sheets within the off-black workspace. */
  html[data-theme="dark"] :is(.finance-app,.finance-main,.finance-workspace) { background:var(--hub-theme-bg)!important; color:var(--hub-theme-ink); }
  html[data-theme="dark"] :is(.finance-sidebar,.finance-toolbar,.finance-table-wrap,.finance-card,.finance-panel,.finance-modal,.finance-modal header,.finance-modal footer) { background:var(--hub-theme-panel)!important; color:var(--hub-theme-ink)!important; border-color:var(--hub-theme-line)!important; }
  html[data-theme="dark"] .finance-table :is(th,td) { background:transparent!important; color:var(--hub-theme-ink)!important; border-color:var(--hub-theme-line)!important; }
  html[data-theme="dark"] :is(.finance-table thead,.finance-summary-strip) { background:var(--hub-theme-raised)!important; }
  html[data-theme="dark"] .finance-table tbody tr:hover { background:var(--hub-theme-raised)!important; }
  html:root[data-theme="dark"] .finance-table tbody tr.is-deep-linked { background:var(--hub-theme-card)!important; box-shadow:inset 4px 0 var(--hub-theme-focus); }
  html:root[data-theme="dark"] .finance-table tbody tr.is-deep-linked:hover { background:var(--hub-theme-raised)!important; }
  html:root[data-theme="dark"] .finance-status:is(.void,.voided,.deleted,.written-off) { background:var(--hub-theme-raised)!important; color:var(--hub-theme-muted)!important; }
  html:root[data-theme="dark"] .finance-muted { color:var(--hub-theme-muted)!important; }
  html[data-theme="dark"] :is(.finance-table td strong,.finance-summary-strip strong) { color:#e9eee0!important; }
  html[data-theme="dark"] :is(.finance-table td small,.finance-page-header p,.finance-toolbar label,.finance-sidebar small) { color:#b4bca9!important; }
  html:root[data-theme="dark"] .finance-status:is(.not-in-xero,.ready) { background:var(--hub-theme-raised)!important; color:var(--hub-theme-muted)!important; }
  /* Detail, reconciliation and confirmation views are separate from the ledger. */
  html:root[data-theme="dark"] :is(.finance-drawer,.finance-xero-dialog,.ws-action-modal>form) { background:var(--hub-theme-panel)!important; color:var(--hub-theme-ink)!important; border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] :is(.finance-costs,.finance-invoice-allocation-row,.finance-invoice-lines,.finance-invoice-reconciliation,.finance-xero-confirm-summary,.finance-xero-recipient-plan,.finance-document-link,.finance-document-card,.finance-overview-flow) { background:var(--hub-theme-bg)!important; color:var(--hub-theme-ink)!important; border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] :is(.finance-invoice-allocation-summary>div,.finance-detail-reconcile,.finance-detail-xero,.finance-xero-status-check,.finance-invoice-xero-match,.finance-invoice-document-link,.finance-invoice-lines-heading,.finance-invoice-review-modal>form>footer,.finance-client-combined-option,.finance-xero-recipient-chips>span) { background:var(--hub-theme-raised)!important; color:var(--hub-theme-ink)!important; border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] :is(.finance-drawer,.finance-xero-dialog,.ws-action-modal>form) :is(header,footer,section,dl,.finance-costs>div,.finance-reconciliation-row,.finance-reconciliation-total,.finance-invoice-line,.finance-invoice-line-header) { border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] :is(.finance-drawer,.finance-xero-dialog,.ws-action-modal>form,.finance-overview-flow,.finance-queue-card) :is(p,small,dt,header>div>span,footer,.finance-drawer-total>div>span,.finance-invoice-allocation-summary span,.finance-detail-form>label>span,.finance-reconciliation-header,.finance-reconciliation-row>span,.finance-reconciliation-total) { color:var(--hub-theme-muted)!important; }
  html:root[data-theme="dark"] :is(.finance-drawer,.finance-xero-dialog,.ws-action-modal>form) :is(strong,dd,b,.finance-xero-recipient-field>span) { color:var(--hub-theme-ink)!important; }
  html:root[data-theme="dark"] :is(.finance-client-draft-copy>strong,.finance-queue-card>b,.finance-inline-link,.finance-detail-reconcile-message,.finance-client-draft-rule) { color:var(--hub-theme-accent)!important; }
  html:root[data-theme="dark"] .finance-xero-divider { border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] .finance-xero-divider span { background:var(--hub-theme-panel)!important; color:var(--hub-theme-muted)!important; }
  html:root[data-theme="dark"] :is(.finance-note,.finance-inline-message,.finance-data-gap,.finance-xero-flow-note,.finance-xero-sync-notice,.finance-reconciliation-total.mismatch,.finance-reconciliation-flags span) { background:#3c3625!important; color:#ead1a0!important; border-color:#716342!important; }
  html:root[data-theme="dark"] :is(.finance-xero-dialog-error,.finance-xero-toast,.finance-xero-bill-warning,.finance-xero-sync-notice.error,.finance-overview-xero.error) { background:#432c26!important; color:#f2b6a4!important; border-color:#76534a!important; }
  html:root[data-theme="dark"] :is(.finance-xero-flow-note.is-ready,.finance-xero-attachment-note,.finance-xero-sync-notice.success,.finance-overview-xero,.finance-supplier-xero-toast.success) { background:#243b2b!important; color:#c4dfb8!important; border-color:#506e49!important; }
  html:root[data-theme="dark"] :is(.finance-xero-recipient-copy-error,.finance-client-draft-warning,.finance-client-draft-rule.warning) { color:#f2b6a4!important; }
  html:root[data-theme="dark"] :is(.finance-document-link,.finance-document-card):hover { background:var(--hub-theme-raised)!important; }
  html:root[data-theme="dark"] .finance-file-chips a { background:var(--hub-theme-raised)!important; color:var(--hub-theme-ink)!important; border-color:var(--hub-theme-line)!important; }
  /* Documents: only the writing studio, not the letterhead or editor contents. */
  html[data-theme="dark"] :is(.documents-shell,.documents-main,.personal-documents-workspace,.personal-document-canvas) { background:var(--hub-theme-bg)!important; color:var(--hub-theme-ink); }
  html[data-theme="dark"] :is(.documents-sidebar,.documents-toolbar,.documents-card,.documents-panel,.personal-document-library,.personal-document-library>header,.personal-document-toolbar,.personal-document-ribbon,.personal-document-ribbon-row,.personal-document-statusbar,.personal-document-signatures,.personal-document-share,.personal-document-actions) { background:var(--hub-theme-panel)!important; color:var(--hub-theme-ink)!important; border-color:var(--hub-theme-line)!important; }
  html[data-theme="dark"] :is(.personal-document-library small,.personal-document-library p,.personal-document-statusbar,.documents-toolbar p,.documents-card p) { color:var(--hub-theme-muted)!important; }
  html[data-theme="dark"] .personal-document-page-stack { color-scheme:light; --ink:#111a19; --muted:#5f6c65; --panel:#fff; --bg:#fff; }
  html[data-theme="dark"] .personal-document-page { background:#fff!important; color:#111a19; }
  html[data-theme="dark"] .personal-document-editor { color:#111a19; }
  html[data-theme="dark"] :is(.personal-signature-saved,.personal-signature-create,.personal-signature-saved article) { background:var(--hub-theme-panel)!important; color:var(--hub-theme-ink)!important; border-color:var(--hub-theme-line)!important; }
  html[data-theme="dark"] .personal-signature-saved strong { color:var(--hub-theme-ink)!important; }
  html[data-theme="dark"] .personal-signature-saved :is(small,p) { color:var(--hub-theme-muted)!important; }
  /* Signature ink stays dark on a light drawing/thumbnail surface; do not invert the saved image. */
  html[data-theme="dark"] .personal-signature-saved article img { background:#fff; border-radius:3px; }
  /* Onboarding — softer category tiles and a guided form. */
  html[data-theme="dark"] :is(.onboarding-shell,.onboarding-main,.onboarding-sidebar) { background:var(--hub-theme-bg)!important; color:var(--hub-theme-ink); }
  html[data-theme="dark"] :is(.onboarding-card,.onboarding-top-nav,.onboarding-side>section,.onboarding-review,.onboarding-option-list,.onboarding-checks,.onboarding-fields fieldset,.onboarding-fields label.onboarding-switch) { background:var(--hub-theme-panel)!important; border-color:var(--hub-theme-line)!important; color:var(--hub-theme-ink)!important; }
  html[data-theme="dark"] :is(.onboarding-actions,.onboarding-review>footer,.onboarding-review-note) { background:var(--hub-theme-raised)!important; border-color:var(--hub-theme-line)!important; color:var(--hub-theme-ink)!important; }
  html[data-theme="dark"] :is(.onboarding-main p,.onboarding-main small,.onboarding-side p,.onboarding-main dt) { color:#b8c5af!important; }
  /* Bidding — estimating cards, no changes to client preview colours. */
  html[data-theme="dark"] :is(.app-shell,.workspace,.bid-editor,.bid-editor .topbar,.bid-global-section,.bid-overview-grid,.bid-workspace,.bid-settings) { background:var(--hub-theme-bg)!important; color:var(--hub-theme-ink)!important; }
  html[data-theme="dark"] :is(.bid-editor .card,.bid-editor .panel,.bid-global-section,.bid-overview-section,.bid-totals,.bid-contents-card,.bid-type-card,.table-wrap,.bid-status-menu,.bid-filter-menu,.bid-filter-panel,dialog,.modal-content) { background:var(--hub-theme-panel)!important; color:var(--hub-theme-ink)!important; border-color:var(--hub-theme-line)!important; }
  html[data-theme="dark"] .bid-editor :is(th,td) { background:var(--hub-theme-panel)!important; color:var(--hub-theme-ink)!important; border-color:var(--hub-theme-line)!important; }
  html[data-theme="dark"] .bid-editor :is(p,small,.muted,.section-header span) { color:var(--hub-theme-muted)!important; }
  html:root[data-theme="dark"] .bid-editor :is(.mode-strip,.table-scroll) { background:var(--hub-theme-panel)!important; border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] .bid-editor .client-status-pill.is-pending { background:var(--hub-theme-raised)!important; color:var(--hub-theme-muted)!important; }
  /* PD cards used translucent white fills, including alternating suppliers. */
  html:root[data-theme="dark"] .bid-editor .dept-day-field { background:var(--hub-theme-inset)!important; border-color:var(--hub-theme-line)!important; border-left-color:#809076!important; color:var(--hub-theme-ink)!important; box-shadow:0 2px 5px #0002; }
  html:root[data-theme="dark"] .bid-editor .dept-day-field :is(.dept-name,strong) { color:var(--hub-theme-ink)!important; }
  html:root[data-theme="dark"] .bid-editor .dept-day-field :is(.dept-card-field>span:first-child,.fixed-cost-placeholder) { color:var(--hub-theme-muted)!important; }
  html:root[data-theme="dark"] .bid-editor .dept-day-field :is(strong,.fixed-cost-placeholder) { background:var(--hub-theme-panel)!important; border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] .bid-editor .dept-day-field input.client-rate-input.is-rate-override { background:#393226!important; color:#f0d6a7!important; border-color:#b68e53!important; }
  html:root[data-theme="dark"] .bid-editor .dept-day-field input.client-rate-input.is-rate-missing { background:#362724!important; color:#efb5a9!important; border-color:#b8796c!important; }
  html:root[data-theme="dark"] .bid-editor .dept-day-field .missing-client-rate { color:#efb5a9!important; }
  html[data-theme="dark"] .pdf-preview-frame { color-scheme:light; --bg:#eaece9; --panel:#f8f9f6; --ink:#111a19; --muted:#5f6c65; --line:#cbd1c8; --soft:#dfe4dd; color:#111a19!important; background:#fff!important; }
  /* Database — directory rows keep separators and teal selection accents. */
  html[data-theme="dark"] :is(.directory-panel,.directory-toolbar,.people-list,.combined-list,.people-row,.combined-row,.record-dialog,.editor-dialog,.relationship-section,.field-summary,.panel,.toolbar,.modal-header,.modal-body,.modal-footer) { background:var(--hub-theme-panel)!important; color:var(--hub-theme-ink)!important; border-color:var(--hub-theme-line)!important; }
  html[data-theme="dark"] :is(.people-row,.combined-row):hover { background:var(--hub-theme-raised)!important; box-shadow:inset 4px 0 #8bbdb1; }
  html[data-theme="dark"] :is(.people-row,.combined-row,.directory-panel,.field-summary) strong { color:var(--hub-theme-ink)!important; }
  html[data-theme="dark"] :is(.people-row,.combined-row,.directory-panel,.field-summary) :is(small,p) { color:var(--hub-theme-muted)!important; }
  html[data-theme="dark"] .nav-icon img { filter:brightness(0) saturate(100%) invert(85%); }
  /* Tickets — readable urgency and ownership, including modal details. */
  html[data-theme="dark"] .tk-app { --tk-border:var(--hub-theme-line); --tk-green:#b4cca4; }
  html[data-theme="dark"] :is(.tk-workspace,.tk-queue,.tk-modal,.tk-row,.tk-metrics>button) { background:var(--hub-theme-panel)!important; color:var(--hub-theme-ink)!important; border-color:var(--hub-theme-line)!important; }
  html[data-theme="dark"] :is(.tk-filters,.tk-facts,.tk-modal>header,.tk-modal>footer,.tk-editor footer,.tk-activity .comment>div,.tk-mail-status,.tk-type,.tk-handoff-sections .next) { background:var(--hub-theme-raised)!important; color:var(--hub-theme-ink)!important; }
  html[data-theme="dark"] :is(.tk-row-owner strong,.tk-metrics strong,.tk-ticket-title) { color:var(--hub-theme-ink)!important; }
  html[data-theme="dark"] :is(.tk-row-main>span,.tk-row-owner>span,.tk-metrics>button>span,.tk-list-meta,.tk-footer-note,.tk-eyebrow,.tk-activity time,.tk-detail-id,.tk-facts dt,.tk-help) { color:var(--hub-theme-muted)!important; }
  html[data-theme="dark"] :is(.tk-overdue,.tk-priority.critical) { color:#f0ac9a!important; }
  html[data-theme="dark"] .tk-badge { background:#34473b; color:#d4e5c9; }
  html[data-theme="dark"] :is(.tk-badge.blocked,.tk-error) { background:#432c26; color:#f2b6a4; }
  html[data-theme="dark"] :is(.tk-badge.pending,.tk-handoff-callout) { background:#3c3625; color:#ead1a0; }
  /* Shared app navigation; each app keeps its own corners and active treatment. */
  html[data-theme="dark"] :is(.ws-app-workspace.is-hub-embedded .finance-sidebar,.ws-app-workspace.is-hub-embedded .documents-sidebar,[data-surface="hub"] .sidebar) { background:var(--hub-theme-panel)!important; border-color:var(--hub-theme-line)!important; }
  html[data-theme="dark"][data-surface="hub"] .sidebar { background:var(--hub-theme-panel)!important; border-color:var(--hub-theme-line)!important; }
  /* App-specific chrome with legacy fixed colours. */
  html[data-theme="dark"] :is(.hub-quick-launch,.finance-ledger,.finance-search,.personal-document-stage,.personal-document-welcome,.personal-document-search,.personal-document-formatbar,.personal-document-sharing,.people-filter-bar,.saved-filter-menu,.saved-filter-status-grid,.saved-filter-options,.bid-lifecycle-control,.bid-approved-version-control) { background:var(--hub-theme-panel)!important; color:var(--hub-theme-ink)!important; border-color:var(--hub-theme-line)!important; }
  html[data-theme="dark"] :is(.finance-ledger,.personal-document-welcome,.personal-document-empty,.onboarding-side,.onboarding-main) :is(strong,p,small,dt) { color:var(--hub-theme-muted)!important; }
  html[data-theme="dark"] :is(.finance-ledger,.personal-document-welcome,.personal-document-empty,.onboarding-side) strong { color:var(--hub-theme-ink)!important; }
  html[data-theme="dark"] :is(.onboarding-fields label>span,.onboarding-card-heading>div>span,.onboarding-side>section>span,.bid-section-header>span,.bid-type-section-header>span,.saved-filter-menu label,.saved-filter-menu strong,.saved-filter-menu>span,.bid-lifecycle-control>span,.bid-approved-version-control>span) { color:var(--hub-theme-muted)!important; }
  html[data-theme="dark"] :is(.role-pill,.role-pill.muted,.god-private,.onboarding-card-heading>b,.onboarding-checks label,.onboarding-option-list label,.onboarding-side li>b,.onboarding-side li>span:first-child) { background:#314532!important; color:#d7e7cc!important; border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] :is(.onboarding-checks,.onboarding-option-list) label { background:var(--hub-theme-raised)!important; color:var(--hub-theme-ink)!important; }
  html:root[data-theme="dark"] :is(.onboarding-checks,.onboarding-option-list) label:has(input:checked) { background:#29362d!important; border-color:#809076!important; }
  html[data-theme="dark"] :is(.ws-nav-item,.ws-nav-item-extra,.ws-brand) { background:transparent!important; }
  html[data-theme="dark"] .ws-nav-item.active { background:#2e4432!important; }
  html[data-theme="dark"] :is(.documents-sidebar,.finance-sidebar,.onboarding-top-nav) button small { color:#b3c2ae!important; }
  html[data-theme="dark"][data-surface="hub"] .sidebar .nav-button { color:#c4d7bd!important; background:transparent!important; }
  html[data-theme="dark"][data-surface="hub"] .sidebar .nav-button.active { color:#eff6e9!important; background:#314c3d!important; }
  html[data-theme="dark"] :is(.person-row,.combined-row) { background:var(--hub-theme-panel)!important; }
  html[data-theme="dark"] .person-row:hover { background:var(--hub-theme-raised)!important; }
  html[data-theme="dark"] .saved-search { background:var(--hub-theme-inset)!important; border-color:var(--hub-theme-line)!important; }
  html[data-theme="dark"] .saved-search-icon { stroke:#bdcdb3!important; }
  html[data-theme="dark"][data-surface="hub"] .sidebar .saved-search { background:var(--hub-theme-inset)!important; border-color:var(--hub-theme-line)!important; }
  html[data-theme="dark"][data-surface="hub"] .sidebar .saved-search input { color:#e9eee6!important; background:transparent!important; }
  html[data-theme="dark"][data-surface="hub"] .sidebar .saved-search input::placeholder { color:#afbdad!important; opacity:1; }
  html[data-theme="dark"] :is(button.danger,button.tk-danger):not(.personal-document-page-stack *, .pdf-preview-frame *) { color:#ffc7ba!important; background:#472c28!important; border-color:#805149!important; }
  html[data-theme="dark"] :is(button.danger,button.tk-danger):hover:not(:disabled):not(.personal-document-page-stack *, .pdf-preview-frame *) { background:#60382e!important; }
  html[data-theme="dark"] .welcome-screen { background:radial-gradient(circle at 50% 34%,var(--hub-theme-panel),var(--hub-theme-bg) 70%)!important; }
  html[data-theme="dark"] .welcome-mark .welcome-logo-light-mode { display:none; }
  html[data-theme="dark"] .welcome-mark .welcome-logo-dark-mode { display:block; }
  html[data-theme="dark"] :is(.welcome-copy h1 span,.welcome-copy>span) { color:#cfddc6!important; }
  /* Other in-Hub tools inherit the same preference while their redesign is WIP. */
  html[data-theme="dark"] :is(.clients-main,.clients-workspace,.io-main,.io-workspace,.media-shuttle-main,.media-shuttle-workspace) { background:var(--hub-theme-bg)!important; color:var(--hub-theme-ink)!important; }
  html[data-theme="dark"] :is(.clients-panel,.clients-form,.clients-stat,.clients-top-nav,.io-panel,.io-card,.io-plan-summary>div,.ms-panel,.ms-card,.ms-stat) { background:var(--hub-theme-panel)!important; color:var(--hub-theme-ink)!important; border-color:var(--hub-theme-line)!important; }
  html[data-theme="dark"] :is([class~="bg-white"],[class~="bg-gray-50"],[class~="bg-slate-50"]) { background:var(--hub-theme-panel)!important; color:var(--hub-theme-ink)!important; }
  html:root[data-theme="dark"] .tk-app>.sidebar .nav-button { background:transparent!important; color:#bdcfb5!important; }
  html:root[data-theme="dark"] .tk-app>.sidebar .nav-button.active { background:#314c37!important; color:#f1f6e9!important; border-color:#93ad81!important; }
  html:root[data-theme="dark"] .tk-app :is(.tk-filters>.tk-field>span,.tk-search svg,.tk-metrics svg,.tk-activity .change .tk-prose,.tk-handoff-callout p) { color:#bac9b2!important; }
  html:root[data-theme="dark"] :is(.finance-sidebar nav button,.documents-sidebar nav button):not(.active) { background:transparent!important; }
  html:root[data-theme="dark"] .god-section-nav button:not([aria-current]) { background:transparent!important; border-color:transparent!important; }
  html:root[data-theme="dark"] .ws-nav-item:not(.active),html:root[data-theme="dark"] .ws-nav-item-extra { background:transparent!important; }
  html:root[data-theme="dark"] .ms-workspace { --ms-ink:var(--hub-theme-ink); --ms-forest:#aac49c; --ms-paper:var(--hub-theme-bg); --ms-white:var(--hub-theme-panel); --ms-line:var(--hub-theme-line); --ms-muted:var(--hub-theme-muted); }
  html:root[data-theme="dark"] .clients-workspace { --clients-ink:var(--hub-theme-ink); --clients-forest:#aac49c; --clients-paper:var(--hub-theme-bg); --clients-white:var(--hub-theme-panel); --clients-line:var(--hub-theme-line); --clients-muted:var(--hub-theme-muted); }
  html:root[data-theme="dark"] .io-workspace { --surface:var(--hub-theme-bg); --foreground:var(--hub-theme-ink); --muted:var(--hub-theme-muted); --border:var(--hub-theme-line); }
  html:root[data-theme="dark"] :is(.ms-main,.ms-top-nav,.ms-modal,.ms-modal>header,.ms-portal-card,.ms-storage-card,.ms-members,.ms-member-list>div,.clients-top-nav,.io-embedded-nav) { background:var(--hub-theme-panel)!important; color:var(--hub-theme-ink)!important; border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] :is(.ws-location-settings-controls,.ws-weather-location-picker) :is(strong,span) { color:var(--hub-theme-muted)!important; }
  html:root[data-theme="dark"] :is(.form-field-group,.form-field-group-grid,.combined-record-section,.company-contact-section,.contact-type-picker,.company-contact-add,.connection-picker,.data-health-map article) { background:var(--hub-theme-panel)!important; color:var(--hub-theme-ink)!important; border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] :is(.kicker,.form-section-heading span,.onboarding-header>div>span) { color:#a8c1ad!important; }
  html:root[data-theme="dark"] :is(.company-role-picker,.company-contact-editor-heading,.assignment-access-options,.connection-checkbox-list,.connection-checkbox-picker,.metric,.nudge-card,.compact-row,.table-head,.table-row,.draft-box,.search-box) { background:var(--hub-theme-panel)!important; color:var(--hub-theme-ink)!important; border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] :is(.finance-empty,.personal-document-empty) { color:var(--hub-theme-muted)!important; }
  html:root[data-theme="dark"] .bid-editor :is(.bid-section-kicker,.pd-title,.bid-contents-card>strong,.bid-authorship-card>strong,.bid-csv-card>strong,.bid-content-counts strong,#grandTotalOut,#averageShotCostOut) { color:var(--hub-theme-ink)!important; }
  html:root[data-theme="dark"] .bid-editor :is(.totals .grand,.total-row,.grand-total,.bid-content-counts>div,.prepared-by-display) { background:var(--hub-theme-raised)!important; color:var(--hub-theme-ink)!important; }
  html:root[data-theme="dark"] .win-likelihood { --win-likelihood-color:#b3cda1; background:var(--hub-theme-inset)!important; border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] .win-likelihood[data-band="medium"] { --win-likelihood-color:#edca8a; }
  html:root[data-theme="dark"] .win-likelihood[data-band="low"] { --win-likelihood-color:#f0aa9b; }
  html:root[data-theme="dark"] .win-likelihood-heading>span { color:#e6edde!important; }
  html:root[data-theme="dark"] .win-likelihood-heading small { background:var(--hub-theme-raised)!important; color:var(--hub-theme-muted)!important; }
  html:root[data-theme="dark"] .win-likelihood-track { background:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] :is(.cc-options,.discipline-options,.line-grid-discipline-options,.company-role-picker,.company-contact-editor-heading,.saved-filter-option) { background:var(--hub-theme-panel)!important; color:var(--hub-theme-ink)!important; border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] .bid-editor .total { color:var(--hub-theme-ink)!important; }
  html:root[data-theme="dark"] :is(.button-link,a.primary,.ms-button) { background:var(--hub-theme-raised)!important; color:var(--hub-theme-ink)!important; border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] button:disabled { opacity:.65; }
  html:root[data-theme="dark"] .ws-brand>span { color:#abc198!important; }
  html:root[data-theme="dark"] .ws-nav-app-label { color:#aab7a3!important; }
  html:root[data-theme="dark"] :is(.finance-toolbar>div>span,.finance-ledger-head>div>span,.finance-save-state,.finance-app label>span,.finance-client-draft-builder>div>span) { color:#b3c0ad!important; }
  html:root[data-theme="dark"] :is(.finance-shell,.finance-segmented,.finance-client-draft-builder,.finance-import-panel,.finance-upload-form) { background:var(--hub-theme-panel)!important; color:var(--hub-theme-ink)!important; border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] :is(.finance-ledger,.finance-ledger-head,.finance-summary-strip,.finance-summary-strip>div,.finance-table-wrap) { border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] .god-queue-columns article { background:var(--hub-theme-inset)!important; }
  html:root[data-theme="dark"] .god-queue-columns p { color:var(--god-muted)!important; }
  html:root[data-theme="dark"] .god-queue-columns .needs-attention dd { color:#f0ac9a!important; }
  html:root[data-theme="dark"] :is(.god-pattern,.god-loading,.god-rank-row,.god-detail-row) { background:var(--hub-theme-panel)!important; color:var(--hub-theme-ink)!important; }
  html:root[data-theme="dark"] .god-workspace small { color:var(--god-muted)!important; }
  html:root[data-theme="dark"] .onboarding-advanced-fields { background:var(--hub-theme-inset)!important; border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] .onboarding-fields :is(label,legend) b { color:#ebc88b!important; }
  html:root[data-theme="dark"] :is(.checkbox-menu,.send-progress-card) { background:var(--hub-theme-panel)!important; color:var(--hub-theme-ink)!important; border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] :is(.company-card-stats,.data-health-map span,.send-progress-card p) { color:var(--hub-theme-muted)!important; }
  html:root[data-theme="dark"] .data-health-list b { background:#3d3525!important; color:#edd5a3!important; }
  html:root[data-theme="dark"] :is(.data-table th,.table-wrap th) { background:var(--hub-theme-raised)!important; color:var(--hub-theme-ink)!important; border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] .record-list { background:var(--hub-theme-panel)!important; }
  html:root[data-theme="dark"] .record-list :is(th,td) { background:var(--hub-theme-panel)!important; color:var(--hub-theme-ink)!important; border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] .bid-type-section { background:var(--hub-theme-panel)!important; border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] :is(.ws-groups,.ws-hub-access,.ws-access-banner,.ws-section-permission-grid) { background:var(--hub-theme-panel)!important; color:var(--hub-theme-ink)!important; border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] :is(.ws-groups-edit-label,.ws-access-save span,.ws-list-label,.ws-permission-head>div>span) { color:var(--hub-theme-muted)!important; }
  html:root[data-theme="dark"] .ws-access-audit { background:#3c3625!important; border-color:#716342!important; }
  html:root[data-theme="dark"] .ws-access-audit strong { color:#ead1a0!important; }
  html:root[data-theme="dark"] .ws-people-list button>b { background:#4d4636!important; color:#f3e2bc!important; }
  html:root[data-theme="dark"] :is(.ws-regional-preview,.ws-google-capabilities>div,.ws-backup-empty) { background:var(--hub-theme-raised)!important; color:var(--hub-theme-ink)!important; border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] :is(.ws-guide-grid article>span,.ws-google-capabilities span) { color:var(--hub-theme-muted)!important; }
  html:root[data-theme="dark"] :is(.ws-notification-menu,.ws-notification-empty) { background:var(--hub-theme-panel)!important; color:var(--hub-theme-ink)!important; border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] :is(.ws-notification-menu span,.ws-profile-menu>header span) { color:var(--hub-theme-muted)!important; }
  html:root[data-theme="dark"] :is(.hub-studio-time-list .is-personal,.hub-attention) :is(small,strong,span) { color:var(--hub-theme-ink)!important; }
  html:root[data-theme="dark"] :is(.eyebrow,.ms-kicker,.ms-workspace small,.clients-panel-heading>div>span,.clients-workspace small,.io-panel>header span,.io-status-card span) { color:var(--hub-theme-muted)!important; }
  html:root[data-theme="dark"] :is(.clients-metrics article,.io-status-card,.ms-metric,.ms-overview-portal-card,.ms-portal-health span) { background:var(--hub-theme-panel)!important; color:var(--hub-theme-ink)!important; border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] .clients-avatar { background:#38503b!important; color:#f1f6e9!important; }
  html:root[data-theme="dark"] .ms-preview-banner { background:#3c3625!important; color:#ead1a0!important; border-color:#716342!important; }
  html:root[data-theme="dark"] :is(.ms-health-flags>span,.ms-search,.ms-portal-card dl,.ms-directory-control,.ms-transfer-history,.ms-branding-card dl div,.ms-setup-card li,.ms-permission-toggle,.ms-default-note,.ms-locked-field,.ms-locked-field b,.ms-form .ms-check,.ms-standard-summary,.ms-create-member-list>div,.ms-read-only-note) { background:var(--hub-theme-raised)!important; color:var(--hub-theme-ink)!important; border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] :is(.ms-info-note,.ms-settings-confirm) { background:#3c3625!important; color:#ead1a0!important; border-color:#716342!important; }
  html:root[data-theme="dark"] :is(.ms-alert,.ms-form-error,.ms-inline-confirm) { background:#432c26!important; color:#f2b6a4!important; border-color:#76534a!important; }
  html:root[data-theme="dark"] :is(.documents-editor,.documents-process-panel,.documents-history,.rate-card-location,.rate-card-location-head,.rate-card-rate,.documents-history-head) { background:var(--hub-theme-panel)!important; color:var(--hub-theme-ink)!important; border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] :is(.documents-toolbar>div>span,.documents-toolbar-state,.documents-editor header span,.documents-editor header small,.documents-process-title>span,.documents-history>header span,.documents-empty-state,.personal-document-library>header span,.personal-document-ribbon-row small) { color:var(--hub-theme-muted)!important; }
  html:root[data-theme="dark"] :is(.documents-editor label>span,.documents-editor small,.documents-process-panel p,.documents-process-panel small,.rate-card-rate b,.ws-permission-head span) { color:var(--hub-theme-muted)!important; }
  html:root[data-theme="dark"] .rate-card-rate span { color:var(--hub-theme-ink)!important; }
  html:root[data-theme="dark"] .documents-process-status { background:var(--hub-theme-raised)!important; color:var(--hub-theme-ink)!important; border-color:var(--hub-theme-line)!important; }

  /* Deliberate surface hierarchy across owned apps. Nested cards are a step
     lighter than their section; form inputs stay recessed. No document-paper selectors. */
  html:root[data-theme="dark"] :is(.hub-attention,.hub-today-calendar,.hub-quick-list,.hub-app-launch-grid>article,.ws-permission-panel,.ws-access-guide,.finance-ledger,.finance-card,.god-card,.god-kpi,.onboarding-card,.documents-panel,.personal-document-library,.directory-panel,.tk-queue,.bid-global-section,.bid-type-section) { box-shadow:var(--hub-theme-shadow); }
  html:root[data-theme="dark"] :is(
    .ws-group-card,.ws-group-editor,.ws-guide-grid article,.ws-google-capabilities>div,.ws-backup-facts>div,.ws-group-members>label,.ws-attention-scope-grid>label,
    .hub-app-sidebar-list article,.hub-app-available-editor article,
    .finance-costs,.finance-invoice-allocation-row,.finance-invoice-lines,.finance-invoice-reconciliation,.finance-xero-confirm-summary,.finance-xero-recipient-plan,.finance-document-card,
    .god-queue-columns article,.god-pattern,.god-rank-row,.god-detail-row,
    .onboarding-checks,.onboarding-option-list,.onboarding-fields fieldset,.onboarding-fields label.onboarding-switch,
    .personal-signature-saved article,.personal-document-sharing,.documents-process-panel,.rate-card-rate,
    .form-field-group,.combined-record-section,.company-contact-section,.relationship-section,.field-summary,.data-health-map article,.person-row,.company-card,.combined-record-row,
    .opportunity-card,.nudge-card,.draft-box,.compact-row,
    .tk-row,.tk-facts,.tk-activity .comment>div,
    .clients-panel .clients-form,.clients-metrics article,.io-panel .io-card,.io-plan-summary>div,.ms-panel .ms-card,.ms-branding-card dl div,.ms-setup-card li
  ) { background:var(--hub-theme-card)!important; border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] :is(.ws-topbar,.ws-tabbar,.finance-toolbar,.finance-ledger-head,.documents-toolbar,.personal-document-toolbar,.personal-document-ribbon,.personal-document-library>header,.directory-toolbar,.tk-filters,.onboarding-card-heading) { background:var(--hub-theme-card)!important; border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] :is(.ws-profile-menu,.ws-notifications-panel,.ws-notification-menu,.saved-filter-menu,.cc-options,.discipline-options,.line-grid-discipline-options,.hub-section-panel) { background:var(--hub-theme-card)!important; border-color:var(--hub-theme-line)!important; box-shadow:0 16px 40px #0007,0 0 0 1px #ffffff08; }
  html:root[data-theme="dark"] :is(.saved-filter-status-grid,.saved-filter-options,.form-field-group-grid) { background:transparent!important; }
  html:root[data-theme="dark"] :is(.saved-filter-option,.company-contact-editor-heading,.contact-type-picker,.onboarding-checks label,.onboarding-option-list label) { background:var(--hub-theme-raised)!important; }
  html:root[data-theme="dark"] :is(.ws-group-members>label,.ws-attention-scope-grid>label,.onboarding-checks label,.onboarding-option-list label):has(input:checked) { background:#354a39!important; border-color:#809b75!important; }
  html:root[data-theme="dark"] :is(.people-row,.person-row,.company-card,.combined-record-row,.combined-row,.tk-row,.god-rank-row):is(:hover,:focus-within) { background:var(--hub-theme-raised)!important; }
  html:root[data-theme="dark"] .tk-workspace { background:var(--hub-theme-bg)!important; }

  /* Subtle app-specific accents on section edges, rather than large colour washes. */
  html:root[data-theme="dark"] .god-card>header { border-bottom-color:#547583!important; }
  html:root[data-theme="dark"] .finance-ledger-head { border-bottom-color:#82765b!important; }
  html:root[data-theme="dark"] .personal-document-library>header { border-bottom-color:#84798f!important; }
  html:root[data-theme="dark"] .directory-toolbar { border-bottom-color:#528578!important; }
  html:root[data-theme="dark"] .tk-filters { border-bottom-color:#638294!important; }
  html:root[data-theme="dark"] .onboarding-card-heading { border-bottom-color:#738c65!important; }

  /* Bidding has a section shell, inset cards, and recessed editable fields. */
  html:root[data-theme="dark"] .bid-editor .bid-global-section { background:var(--hub-theme-panel)!important; }
  html:root[data-theme="dark"] .bid-editor :is(.bid-overview-grid,.bid-global-tools,.topbar .toolbar) { background:transparent!important; }
  html:root[data-theme="dark"] .bid-editor :is(.panel,.card,.bid-contents-card,.bid-authorship-card,.bid-csv-card) { background:var(--hub-theme-card)!important; border-color:var(--hub-theme-line)!important; box-shadow:0 1px 0 #ffffff07 inset; }
  html:root[data-theme="dark"] .bid-editor :is(.bid-section-header,.bid-type-section-header) { border-bottom-color:#738c65!important; }
  html:root[data-theme="dark"] .bid-editor .totals-panel :is(.total-line,.average-total) { border-bottom-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] .bid-editor .totals-panel .grand-total { background:var(--hub-theme-raised)!important; border-color:#809b75!important; }

  /* Disclosure content must keep its surface when opened or collapsed.
     Target the actual summary tiles as well as the surrounding section. */
  html:root[data-theme="dark"] .bid-overview-summary>:is(div,label) { background:var(--hub-theme-card)!important; border-color:var(--hub-theme-line)!important; color:var(--hub-theme-ink)!important; }
  html:root[data-theme="dark"] .bid-overview-summary :is(strong,.overview-action button) { color:var(--hub-theme-ink)!important; }
  html:root[data-theme="dark"] .bid-overview-summary span { color:var(--hub-theme-muted)!important; }
  html:root[data-theme="dark"] .sales-commission-badge { background:var(--hub-theme-raised)!important; color:var(--hub-theme-accent)!important; }
  html:root[data-theme="dark"] :is(.modification-entry,.archive-row,.finance-commission-rule-person,.finance-bizdev-plan,.finance-commission-sheet-recovery) { background:var(--hub-theme-card)!important; color:var(--hub-theme-ink)!important; border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] :is(.finance-commission-rule-person>header,.finance-bizdev-plan-body>footer) { background:var(--hub-theme-raised)!important; color:var(--hub-theme-ink)!important; border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] :is(.finance-commission-rule-list,.finance-commission-rule-list article,.finance-bizdev-plan-body,.finance-bizdev-plan-section) { border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] .finance-commission-rule-list article.selected { background:var(--hub-theme-inset)!important; }
  html:root[data-theme="dark"] :is(.finance-commission-rule-person>header strong,.finance-bizdev-plan strong) { color:var(--hub-theme-ink)!important; }
  html:root[data-theme="dark"] :is(.finance-commission-rule-list small,.finance-commission-rule-person>header b,.finance-bizdev-plan small,.finance-bizdev-plan-body>footer span,.finance-commission-sheet-action small,.onboarding-advanced-toggle small) { color:var(--hub-theme-muted)!important; }
  html:root[data-theme="dark"] :is(.finance-commission-rule-person>header em,.finance-commission-message) { background:#243b2b!important; color:#c4dfb8!important; border-color:#506e49!important; }
  html:root[data-theme="dark"] .finance-commission-error { background:#432c26!important; color:#f2b6a4!important; border-color:#76534a!important; }
  html:root[data-theme="dark"] .finance-commission-sheet-action small.synced { color:#c4dfb8!important; }
  html:root[data-theme="dark"] .finance-commission-sheet-action small.error { color:#f2b6a4!important; }
  html:root[data-theme="dark"] :is(.finance-commission-sheet-action a,.finance-commission-rule-person-actions a) { background:var(--hub-theme-raised)!important; color:var(--hub-theme-ink)!important; border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] .form-field-group>summary::after { background:var(--hub-theme-inset)!important; color:var(--hub-theme-accent)!important; }
  html:root[data-theme="dark"] .checkbox-option:has(input:checked) { background:#354a39!important; }
  html:root[data-theme="dark"] .checkbox-option:is(:hover,:focus-within) { background:var(--hub-theme-raised)!important; }
  html:root[data-theme="dark"] .tk-link-picker label { background:var(--hub-theme-card)!important; border-color:var(--hub-theme-line)!important; }
  html:root[data-theme="dark"] .tk-link-picker label:has(input:checked) { background:#354a39!important; }
  /* Image controls are editor chrome, not document content. The underlying
     paper and exported images retain their original colours. */
  html:root[data-theme="dark"] .personal-document-image-menu { background:var(--hub-theme-card)!important; border-color:var(--hub-theme-line)!important; color:var(--hub-theme-ink)!important; }
  html:root[data-theme="dark"] .personal-document-image-tools :is(button,label,output) { background:var(--hub-theme-raised)!important; border-color:var(--hub-theme-line)!important; color:var(--hub-theme-ink)!important; }
  html:root[data-theme="dark"] .personal-document-image-tools button.danger { color:#f2b6a4!important; }

  /* Selecting or hovering a bid must never change its business status colour. */
  html:root[data-theme="dark"] .sidebar button.saved-bid { --bid-status-bg:#303634; --bid-status-line:#aeb5b1; background:var(--bid-status-bg)!important; border-color:var(--bid-status-line)!important; color:var(--hub-theme-ink)!important; box-shadow:inset 4px 0 var(--bid-status-line); }
  html:root[data-theme="dark"] .sidebar button.saved-bid.status-submitted { --bid-status-bg:#433c27; --bid-status-line:#d9bd6b; }
  html:root[data-theme="dark"] .sidebar button.saved-bid.status-won { --bid-status-bg:#294333; --bid-status-line:#85bc8b; }
  html:root[data-theme="dark"] .sidebar button.saved-bid:is(.status-lost,.status-canceled) { --bid-status-bg:#4a302d; --bid-status-line:#e19689; }
  html:root[data-theme="dark"] .sidebar button.saved-bid.status-hold { --bid-status-bg:#493a2c; --bid-status-line:#dba775; }
  html:root[data-theme="dark"] .sidebar button.saved-bid:is(.active,:focus-visible) { outline:2px solid var(--hub-theme-focus)!important; outline-offset:-2px; }
  html:root[data-theme="dark"] .sidebar button.saved-bid:hover:not(:disabled) { background:color-mix(in srgb,var(--bid-status-bg) 90%,white)!important; }
  html:root[data-theme="dark"] .sidebar button.saved-bid :is(strong,.saved-bid-client,.saved-bid-total,.saved-bid-version-state) { color:var(--hub-theme-ink)!important; }
  html:root[data-theme="dark"] .sidebar button.saved-bid .saved-bid-loss-reason { color:#f5c6bd!important; }
  html:root[data-theme="dark"] .sidebar button.saved-bid .current-bid-badge { color:#111a19!important; }

  /* Primary actions get a readable sage fill; selection and secondary actions do not. */
  html:root[data-theme="dark"] :is(button.primary,button.primary-action,button.tk-primary,a.primary,.hub-section-new-bid,#newBidBtn,#sendClientBtn):not(.personal-document-page-stack *, .pdf-preview-frame *, .visual-editor-page *, .template-editor-page *) { background:var(--hub-theme-primary)!important; color:var(--hub-theme-primary-ink)!important; border-color:#a8bf9e!important; box-shadow:0 2px 8px #0003; }
  html:root[data-theme="dark"] :is(button.primary,button.primary-action,button.tk-primary,a.primary,.hub-section-new-bid,#newBidBtn,#sendClientBtn):hover:not(:disabled):not(.personal-document-page-stack *, .pdf-preview-frame *, .visual-editor-page *, .template-editor-page *) { background:var(--hub-theme-primary-hover)!important; }
  html:root[data-theme="dark"] #sendClientBtn:focus-visible { outline-color:var(--hub-theme-focus)!important; }
  html:root[data-theme="dark"] #newBidBtn .nav-icon img { filter:brightness(0) saturate(100%)!important; }
}
