/* Shared screen-only surfaces. Print/PDF documents keep their paper palette. */
@media screen {
  html[data-theme="dark"] {
    --surface:#162233;
    --ink:#fff;
    --text:#fff;
    --muted:#b8c8d8;
    --line:#35495d;
    --dark-header:#1b3042;
    --dark-table-header:#193b46;
    --dark-field:#102031;
    --dark-inset:#1b2b3d;
  }

  /* Screen surfaces share one palette, including nested forms and cards that
     older modules paint white. Do not target image/map/PDF contents or badges. */
  html[data-theme="dark"] :is(
    form,dialog,fieldset,article,.card,.panel,.surface-card,.content-card,.card-list,
    .patuh-dialog,.form-drawer,.form-section-card,.dialog-section,.record-modal-body,
    .record-status-summary,.simple-workflow,.stage-evidence,.sync-center,
    .operations-case-card,.operations-subcard,.operations-linked-list>article,
    .event-case-head,.event-case-grid>div,.event-narrative,.event-check-card,
    .event-wizard-page,.event-account-identity,.event-submit-summary,
    .event-review-evidence,.event-review-location,.event-declaration,.event-reference,
    .event-receipt-details>div,.event-status-card dl>div,.event-submit-summary dl>div,
    .event-status-timeline,.event-status-timeline li,.event-status-check-note,
    .source-facts>div,.source-text,.source-hazard,.source-link-grid>section,
    .source-audit li,.source-review-request-list,.record-facts>div,.hirarc-rating-note,
    .inspection-section,.inspection-item,.inspection-response-readonly,
    .inspection-question-support,.inspection-inline-support,.inspection-template-editor,
    .inspection-version-note,.inspection-criterion-editor-list>details,
    .jsa-authoring-details,.jsa-inline-editor,.jsa-step-description>div,.jsa-controls,
    .jsa-empty-state,.jsa-file-link,.jsa-location-link,.jsa-workflow-summary>div,
    .jsa-print-summary,.jsa-environment-links,.jsa-environment-review,
    .jsa-step-integrations,.jsa-step-integration-grid>section,.jsa-review-evidence-register,
    .jsa-gap-capa-card li,.operations-note,.readiness-check,
    .committee-detail-grid>div,.committee-record,.oshwa-cycle,.oshwa-criterion,
    .oshwa-transition-grid details,.oshwa-trend-plot,.oshwa-trend-summary>span,.sh-formula,
    .industry-details>div,.industry-history,.industry-control-flow>div,.industry-control-link,
    .manufacturing-details>div,.ogp-details>div,.logistics-details>div,.education-details>div,
    .hospitality-details>div,.healthcare-details>div,.retail-details>div,.energy-details>div,
    .water-details>div,.waste-details>div,.agriculture-details>div,
    .logistics-profile-grid>a,.education-profile-grid>a,.hospitality-profile-grid>a,
    .healthcare-profile-grid>a,.retail-profile-grid>a,.energy-profile-grid>a,
    .water-profile-grid>a,.waste-profile-grid>a,.agriculture-profile-grid>a,
    .hospitality-reading,.healthcare-reading,.retail-reading,.energy-reading,.water-reading,
    .waste-reading,.agriculture-reading,.hospitality-focus>a,.healthcare-focus>a,
    .retail-focus>a,.energy-focus>a,.water-focus>a,.waste-focus>a,.agriculture-focus>a,
    .fm-upcoming>a,.fm-period,.eq-access,.eq-workflow>span,.employee-shortcuts>a,
    .employee-record-list>button,.employee-workflow-history,.training-date,.training-certificate,
    .environment-kpis>a,.environment-record-grid>a,.environment-bar-chart,
    .hse-perf-total,.hse-perf-filters,.hse-perf-group>summary,.hse-perf-missing,
    .workspace-access-disabled,.profile-governed-fields,.admin-effective-access>summary,
    .guide-section,.guide-module,.guide-module>summary,.guide-activity-instructions,
    .guide-industry-note,.guide-related-links>a,.guide-category-cards>a,.guide-search-panel,
    .guide-role-banner,.guide-role-copy,.guide-module-click-guide,.guide-no-results,
    .guide-visual-grid figure,.guide-visual-grid figcaption,.guide-module-visuals figure,
    .guide-module-visuals figcaption,.turnstile-check,.package-branding,.pricing-value,
    .landing-card,.module-tile,.capability-card,.pricing-card,.login-demo-section,
    .login-demo-table,.demo-account,.general-enquiry-dialog,
    [class$="-card"],[class*="-card "],[class$="-panel"],[class*="-panel "]
  ):where(:not(.operations-print-sheet,.operations-print-sheet *)) {
    background:var(--surface)!important;
    color:var(--ink);
    border-color:var(--line);
  }

  /* Separators and input backgrounds make nested work areas distinguishable. */
  html[data-theme="dark"] :is(
    .event-case-grid>div,.record-facts>div,.source-facts>div,.operations-facts>article,
    .operations-mini-kpis>article,.committee-detail-grid>div,.jsa-step-description>div,
    .stage-evidence,.form-section-card,.dialog-section,.inspection-inline-support,
    .record-status-summary,.workspace-access-grid>article
  ) {background:var(--dark-inset)!important}
  html[data-theme="dark"] :is(.form-actions,.sticky-form-actions,.record-modal-header,.dialog-heading,.general-enquiry-heading,.event-status-check-header) {
    background:var(--dark-header)!important;
    color:#fff;
    border-color:var(--line);
  }
  html[data-theme="dark"] :is(.event-case-tabs,.operations-case-tabs,.case-tabs,.subnav,.industry-nav-panel,.workflow-journey,.workflow-tab-menu,.guide-category-nav) {
    background:var(--surface)!important;
    color:var(--ink);
    border-color:var(--line);
  }
  html[data-theme="dark"] :is(form,dialog,article,.panel,.card,[class$="-card"],[class*="-card "],[class$="-panel"],[class*="-panel "]) :where(h1,h2,h3,h4,h5,legend,label,dt,dd) {color:#fff}
  html[data-theme="dark"] :is(.form-note,.form-help,.hint,.control-note,.operations-note,.hirarc-rating-note,.source-text,.eq-access,.guide-role-copy) {color:#cbd8e5}
  html[data-theme="dark"] :is(form,dialog,article,.panel,.card,[class$="-card"],[class*="-card "],[class$="-panel"],[class*="-panel "]) :where(small,dt) {color:#b8c8d8}
  html[data-theme="dark"] :is(.operations-note,.source-text,.eq-access,.guide-role-copy) :where(b,strong) {color:#fff}
  html[data-theme="dark"] :is(.inspection-item-question>p,.inspection-item-meta,.guide-principles p,.guide-industry-card p,.guide-category-cards p,.guide-module-body p,.guide-module-body li,.guide-visual-grid figcaption span,.guide-module-visuals figcaption span) {color:#c4d2df}

  html[data-theme="dark"] :where(
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="hidden"]):not([type="submit"]):not([type="button"]):not([type="reset"]),
    textarea,select
  ) {
    background-color:var(--dark-field)!important;
    color:#fff!important;
    border-color:#506579!important;
    color-scheme:dark;
  }
  html[data-theme="dark"] :is(input,textarea)::placeholder {color:#aebfd0;opacity:1}
  html[data-theme="dark"] :is(input,textarea,select):disabled {
    background-color:#243242!important;color:#b8c8d8!important;opacity:1;
  }
  html[data-theme="dark"] :is(input,textarea)[readonly] {background-color:#1c2a3b!important}
  html[data-theme="dark"] select option {background:#102031;color:#fff}
  html[data-theme="dark"] input::file-selector-button {background:#294354;color:#fff;border:1px solid #60778c;border-radius:6px}
  html[data-theme="dark"] :is(.check,label:has(>input[type="checkbox"]),label:has(>input[type="radio"])) {background-color:var(--dark-inset);color:#fff}
  html[data-theme="dark"] :is(input,textarea,select):focus-visible {outline:2px solid #8ee4c3;outline-offset:2px}
  html[data-theme="dark"] :is(input,textarea,select)[aria-invalid="true"] {background-color:#361f2b!important;border-color:#ee929d!important}

  /* Dark status surfaces retain their operational meaning. */
  html[data-theme="dark"] :is(.event-readiness.ready,.readiness-check.green,.operations-check-list article.passed,.training-kpis article.passed,.qr-verification-panel.green,.guard-result.green) {background:#173c32!important;color:#d5ffea;border-color:#448e70}
  html[data-theme="dark"] :is(.event-readiness.blocking,.jsa-readiness-panel article.blocking,.jsa-control-card.jsa-status-gap,.training-kpis article.danger,.qr-verification-panel.red,.guard-result.red,.event-page-errors,.general-enquiry-errors,.form-error-summary,.event-status-check-error,.sh-message[data-error],.sh-form-feedback[data-error]) {background:#3e2430!important;color:#ffd9df;border-color:#b66779}
  html[data-theme="dark"] :is(.hospitality-reading.failed,.healthcare-reading.failed,.retail-reading.failed,.energy-reading.failed,.water-reading.failed,.waste-reading.failed,.agriculture-reading.failed) {background:#3e2430!important;color:#ffd9df;border-color:#b66779}
  html[data-theme="dark"] :is(.eq-warning,.industry-note,.industry-next-gate,.jsa-return-note,.jsa-source-review-alert,.jsa-gap-capa-panel,.jsa-environment-review.attention,.oshwa-legacy-note,.oshwa-guidance,.oshwa-capa-actions,.verified-gap-note,.p3-quality-warning,.workspace-access-disabled,.readiness-check.amber,.construction-kpi.attention,.training-kpis article.warning,.jkkp-summary-grid article.warning,.qr-verification-panel.amber,.guard-result.amber) {background:#3b3020!important;color:#ffe9b9;border-color:#a87932}

  html[data-theme="dark"] :is(.card-header,.card-heading,.panel-header,.panel-heading,.record-modal-header,.dialog-heading,.subscription-dialog-heading,.enquiry-dialog-heading,.general-enquiry-heading,.mobile-module-sheet__header) {
    background:var(--dark-header);
    color:#fff;
    border-color:var(--line);
  }
  html[data-theme="dark"] :is(.content-card,.panel,.surface-card,.module-tile,.pricing-card,.capability-card,.general-enquiry-dialog) :is(h1,h2,h3,h4),
  html[data-theme="dark"] :is(.section-heading,.industry-heading,.construction-heading,.fm-heading,.p3-panel-heading,.dialog-heading,.record-modal-header,.general-enquiry-heading) :is(h1,h2,h3,h4,strong) {color:#fff}
  html[data-theme="dark"] :is(.section-heading,.industry-heading,.construction-heading,.fm-heading,.p3-panel-heading,.dialog-heading) > p,
  html[data-theme="dark"] :is(.section-heading,.industry-heading,.construction-heading,.fm-heading) > div > p:not(.eyebrow) {color:var(--muted)}
  html[data-theme="dark"] :is(.card-header,.panel-header,.dialog-heading,.record-modal-header,.general-enquiry-heading) .eyebrow {color:#8ee4c3}

  html[data-theme="dark"] :is(.patuh-datatable,.table-wrap,.data-table-shell) {border-color:var(--line)}
  html[data-theme="dark"] :is(.datatable-toolbar,.datatable-footer,.table-tools) {
    background:#1b2b3c;
    color:#d7e3ef;
    border-color:var(--line);
  }
  html[data-theme="dark"] :is(.datatable-search,.table-search,.datatable-summary,.datatable-page-label) {color:#d7e3ef}
  html[data-theme="dark"] :is(.datatable-search,.table-search) input::placeholder {color:#aebfd0;opacity:1}
  html[data-theme="dark"] :is(.datatable-button,.datatable-pagination button) {border-color:#486075;color:#fff;background:#142435}
  html[data-theme="dark"] :is(.datatable-button,.datatable-pagination button):is(:hover,:focus-visible):not(:disabled) {background:#294454;color:#fff;border-color:#8ee4c3}

  /* Override module-specific table header palettes, including industry tables. */
  html[data-theme="dark"] table thead :is(th,td),
  html[data-theme="dark"] .responsive-table thead th,
  html[data-theme="dark"] [data-industry-tables] .table-wrap table thead th {
    background:var(--dark-table-header)!important;
    color:#fff!important;
    border-color:#456071!important;
  }
  html[data-theme="dark"] table thead :is(a,button,span,small) {color:inherit}
  html[data-theme="dark"] table thead [data-dt-sortable]::after {color:#d7f5ee;opacity:1}
  html[data-theme="dark"] table thead [data-dt-sortable]:focus-visible {outline:2px solid #8ee4c3;outline-offset:-3px}
  html[data-theme="dark"] :is(.responsive-table,.patuh-datatable table) :is(td,th) {border-color:var(--line)}
  html[data-theme="dark"] :is(.responsive-table,.patuh-datatable table) td::before {color:#b8c8d8}
  html[data-theme="dark"] :is(.responsive-table,.patuh-datatable table) tbody tr:hover {background:#203447}

  /* Keep status meanings while using readable text on dark badge surfaces. */
  html[data-theme="dark"] :is(.badge,.status,.status-pill,.readiness-badge,.eq-status,.enquiry-status,.enquiry-email,.role-decision,.risk-pill,.governance-pill,.reference-chip,.qr-live-badge,.live-server-badge,.package-demo-badge,.pricing-badge,.install-device-pill) {
    background:var(--badge-dark-bg,#293d52)!important;
    color:var(--badge-dark-text,#fff)!important;
    border-color:var(--badge-dark-border,#56718b)!important;
  }
  html[data-theme="dark"] :is(.badge,.status,.status-pill,.readiness-badge):is(.approved,.closed,.verified,.valid,.ready,.passed,.active,.succeeded,.sent,.green,.inside,.matched,.not_required,.waived,.status-approved,.status-closed,.status-verified,.jsa-status-approved,.jsa-status-reviewed),
  html[data-theme="dark"] :is(.governance-pill,.qr-live-badge,.live-server-badge,.package-demo-badge) {
    --badge-dark-bg:#174638;--badge-dark-text:#d5ffea;--badge-dark-border:#448e70;
  }
  html[data-theme="dark"] :is(.badge,.status,.status-pill,.readiness-badge):is(.pending,.pending_verification,.pending_approval,.expiring,.warning,.partial,.amber,.waitlisted,.low_accuracy,.boundary,.status-pending_verification,.status-pending_approval,.status-submitted,.status-returned,.jsa-status-returned,.jsa-status-gap),
  html[data-theme="dark"] .risk-pill {
    --badge-dark-bg:#503919;--badge-dark-text:#ffe9b9;--badge-dark-border:#a87932;
  }
  html[data-theme="dark"] :is(.badge,.status,.status-pill,.readiness-badge):is(.rejected,.failed,.expired,.revoked,.suspended,.missing,.blocked,.red,.outside,.scope_denied,.spoof_suspected,.cross_organization,.status_blocked,.status-rejected,.status-overdue,.status-reopened,.jsa-status-critical) {
    --badge-dark-bg:#542b36;--badge-dark-text:#ffd9df;--badge-dark-border:#b66779;
  }
  html[data-theme="dark"] :is(.badge,.status,.status-pill):is(.draft,.archived,.inactive,.superseded,.status-draft,.status-archived,.jsa-status-draft,.jsa-status-superseded) {
    --badge-dark-bg:#34354e;--badge-dark-text:#edeaff;--badge-dark-border:#73708e;
  }
  html[data-theme="dark"] :is(.eq-status.good,.role-decision.allow,.enquiry-status[data-stage="closed_deal"],.enquiry-email[data-email-status="sent"]) {
    --badge-dark-bg:#174638;--badge-dark-text:#d5ffea;--badge-dark-border:#448e70;
  }
  html[data-theme="dark"] :is(.eq-status.attention,.enquiry-status[data-stage="proposal_quoted"]) {
    --badge-dark-bg:#503919;--badge-dark-text:#ffe9b9;--badge-dark-border:#a87932;
  }
  html[data-theme="dark"] :is(.eq-status.danger,.enquiry-email[data-email-status="failed"]) {
    --badge-dark-bg:#542b36;--badge-dark-text:#ffd9df;--badge-dark-border:#b66779;
  }
  html[data-theme="dark"] :is(.enquiry-status[data-stage="demo_done"],.role-decision.prevent) {
    --badge-dark-bg:#34354e;--badge-dark-text:#edeaff;--badge-dark-border:#73708e;
  }
  html[data-theme="dark"] .construction-flow li {background:#1b3042;border-color:var(--line)}
  html[data-theme="dark"] .construction-flow a {color:#fff}

  /* Landing badges use plain spans rather than the shared .badge class. */
  html[data-theme="dark"] .landing-page :is(.governance-pills>span,.landing-domain-grid article>span,.landing-siti-visual>span) {
    background:#293d52;
    color:#fff;
    border-color:#56718b;
  }
  html[data-theme="dark"] .landing-page :is(.landing-domain-grid p,.landing-siti>div:last-child>p:last-of-type) {color:#c4d2df}

  /* White hover/focus surfaces need black labels, including nested button text. */
  html[data-theme="dark"] :is(button,.button,input[type="submit"],input[type="button"],input[type="reset"],.subnav a,.industry-nav-group>summary,.event-case-tabs a,.operations-case-tabs a,.case-tabs a,.committee-tabs a,.committee-nav a,.contractor-tabs a,.oshwa-workspace-nav a):is(:hover,:focus-visible):not(:disabled):not([aria-disabled="true"]) {
    background:#fff!important;
    color:#000!important;
    border-color:#fff!important;
  }
  html[data-theme="dark"] :is(button,.button,.subnav a,.industry-nav-group>summary,.event-case-tabs a,.operations-case-tabs a,.case-tabs a,.committee-tabs a,.committee-nav a,.contractor-tabs a,.oshwa-workspace-nav a):is(:hover,:focus-visible):not(:disabled):not([aria-disabled="true"]) :is(span,strong,b,small,i,svg) {
    color:inherit!important;
  }
}
