/* SBM ONE screen palette. Values are paired by purpose: a component must use
   its surface and foreground together. Dark values exist ONLY on screen;
   existing light/print values remain the fallback in component styles.
   Never apply filters/inversion to documents, logos, photographs or maps. */
@media screen {
  html[data-sbm-theme="dark"] {
    --sbm-canvas: #0b1118;
    --sbm-surface: #111a23;
    --sbm-surface-soft: #192633;
    --sbm-heading: #f1f6fa;
    --sbm-text: #e7eef5;
    --sbm-muted: #becbd7;
    --sbm-link: #91d2ff;
    --sbm-line: #4e6578;
    --sbm-control-surface: #0b141e;
    --sbm-control-border: #859bae;
    --sbm-control-hover: #253e52;
    --sbm-selected-surface: #234863;
    --sbm-selected-text: #ffffff;
    --sbm-info-surface: #152e42;
    --sbm-info-text: #c8e8ff;
    --sbm-success-surface: #133527;
    --sbm-success-text: #a4edbe;
    --sbm-warning-surface: #362b14;
    --sbm-warning-text: #ffe09a;
    --sbm-danger-surface: #3a2027;
    --sbm-danger-text: #ffc2c7;
    --sbm-violet-surface: #302442;
    --sbm-violet-text: #e1c9ff;
    --sbm-action-surface: #215574;
    --sbm-action-text: #ffffff;
    --sbm-positive-action: #226044;
    --sbm-panel-gradient: linear-gradient(180deg,#192633,#111a23);
  }

  /* Shared components: do not reuse a heading-color variable for a button's
     background. These components appear across filing, training and records. */
  html[data-sbm-theme="dark"] :is(.steps b,.step b,.step-number,.training-guide>div>strong,.item-no) {
    background:var(--sbm-selected-surface)!important;
    color:var(--sbm-selected-text)!important;
  }
  html[data-sbm-theme="dark"] :is(.field-title,.folder-label) {color:var(--sbm-muted)!important}
  html[data-sbm-theme="dark"] :is(.training-guide>div,.steps>span,.step,.service-type-box,.employee-matches,.request-reply) {
    background:var(--sbm-surface-soft)!important;color:var(--sbm-text)!important;border-color:var(--sbm-line)!important;
  }
  html[data-sbm-theme="dark"] .employee-matches button {background:var(--sbm-surface)!important;color:var(--sbm-text)!important}
  html[data-sbm-theme="dark"] .employee-matches button:is(:hover,:focus-visible) {background:var(--sbm-control-hover)!important;color:#fff!important}

  /* Equipment component foregrounds: containers now consume the paired tokens
     in their own source CSS, including cards created after initial load. */
  html[data-sbm-theme="dark"][data-sbm-page="equipment"] :is(.kpi-hint,.boat-hour-card>span,.fleet-next-due-label,.inspection-date-line,.inspection-notes,.general-notes-status,.history-count,.live-inv-save-state,.compliance-missing-docs) {color:var(--sbm-muted)!important}
  html[data-sbm-theme="dark"][data-sbm-page="equipment"] .kpi.info .value {color:var(--sbm-link)!important}
  html[data-sbm-theme="dark"][data-sbm-page="equipment"] :is(.asset-view-tab,.maintenance-view-toggle,.record-view-toggle) {background:var(--sbm-surface-soft)!important;color:var(--sbm-text)!important;border-color:var(--sbm-line)!important}
  html[data-sbm-theme="dark"][data-sbm-page="equipment"] .asset-view-tab strong {background:var(--sbm-selected-surface)!important;color:var(--sbm-selected-text)!important}
  html[data-sbm-theme="dark"][data-sbm-page="equipment"] :is(.asset-view-tab,.quick-status-btn,.asset-tab,.record-view-toggle button,.maintenance-view-toggle button):is(.active,[aria-pressed="true"]) {background:var(--sbm-selected-surface)!important;color:var(--sbm-selected-text)!important;border-color:var(--sbm-control-border)!important}
  html[data-sbm-theme="dark"][data-sbm-page="equipment"] :is(.complete-btn,.inspection-actions .complete-btn) {background:var(--sbm-positive-action)!important;color:var(--sbm-action-text)!important}
  html[data-sbm-theme="dark"][data-sbm-page="equipment"] :is(.vendor-card,.boat-documents-section,.boat-document-group,.boat-document-file,.attachment-tile,.action-card,.inspection-card,.general-notes-body,.live-inv-top-note) {border-color:var(--sbm-line)!important}
  html[data-sbm-theme="dark"][data-sbm-page="equipment"] :is(.secondary,.icon-btn,.asset-view-tab,.asset-tab,.record-view-toggle button,.maintenance-view-toggle button,.quick-status-btn):hover {background:var(--sbm-control-hover)!important;color:var(--sbm-selected-text)!important}

  /* Statuses remain distinguishable by their text as well as their color. */
  html[data-sbm-theme="dark"] :is(.status.current,.status.completed,.status.ok,.status.good,.status.success,.badge.current,.badge.done) {background:var(--sbm-success-surface)!important;color:var(--sbm-success-text)!important}
  html[data-sbm-theme="dark"] :is(.status.expired,.status.error,.status.bad,.badge.overdue) {background:var(--sbm-danger-surface)!important;color:var(--sbm-danger-text)!important}
  html[data-sbm-theme="dark"] :is(.status.due30,.status.due90,.status.warn,.status.warning) {background:var(--sbm-warning-surface)!important;color:var(--sbm-warning-text)!important}

  /* Form-specific fixed light remnants found by the rendered-page checks. */
  html[data-sbm-theme="dark"] #fuelTicketStatus {color:var(--sbm-muted)!important}
  html[data-sbm-theme="dark"][data-sbm-page="tankerman"] .simple-meta {background:var(--sbm-surface)!important;color:var(--sbm-text)!important}
  html[data-sbm-theme="dark"][data-sbm-page="employees"] .corporate-letterhead span {color:var(--sbm-muted)!important}
  /* Work surfaces and state controls must have both a foreground and a
     background. Export-to-canvas copies explicitly retain the paper theme. */
  html[data-sbm-theme="dark"][data-sbm-page="boat-log"] body:not(.pdf-export) :is(.access-card,.page2-confirm-title) {
    background:var(--sbm-surface-soft)!important;color:var(--sbm-text)!important;border-color:var(--sbm-line)!important;
  }
  html[data-sbm-theme="dark"][data-sbm-page="boat-log"] body:not(.pdf-export) :is(#sharedLogWindow,#emailStatus,#deliveryDescription) {color:var(--sbm-muted)!important}
  html[data-sbm-theme="dark"][data-sbm-page="engine-room"] body:not(.pdf-export) .gauge-reading-title {color:var(--sbm-warning-text)!important}
  html[data-sbm-theme="dark"][data-sbm-page="engine-room"] body:not(.pdf-export) .condition-card .hint {background:var(--sbm-info-surface)!important;color:var(--sbm-info-text)!important;border-color:var(--sbm-control-border)!important}
  html[data-sbm-theme="dark"][data-sbm-page="engine-room"] body:not(.pdf-export) .flag-btn {background:var(--sbm-surface-soft)!important;color:var(--sbm-text)!important;border-color:var(--sbm-control-border)!important}
  html[data-sbm-theme="dark"][data-sbm-page="engine-room"] body:not(.pdf-export) .flag-btn.active {background:var(--sbm-danger-surface)!important;color:var(--sbm-danger-text)!important;border-color:#e57d8c!important}
  html[data-sbm-theme="dark"][data-sbm-page="tankerman"] :is(.choice-row label,.condition) {background:var(--sbm-surface-soft)!important;color:var(--sbm-text)!important;border-color:var(--sbm-control-border)!important}
  html[data-sbm-theme="dark"][data-sbm-page="tankerman"] .choice-row label:has(input:checked) {background:var(--sbm-selected-surface)!important;color:var(--sbm-selected-text)!important}
  html[data-sbm-theme="dark"][data-sbm-page="tankerman"] .choice-row label.selected-ok {background:var(--sbm-success-surface)!important;color:var(--sbm-success-text)!important}
  html[data-sbm-theme="dark"][data-sbm-page="tankerman"] .choice-row :is(label.selected-attn,label.selected-restock) {background:var(--sbm-danger-surface)!important;color:var(--sbm-danger-text)!important}
  html[data-sbm-theme="dark"][data-sbm-page="tankerman"] .optional-transfer-controls>span {color:var(--sbm-warning-text)!important}
  html[data-sbm-theme="dark"][data-sbm-page="employees"] .paperwork-callout {background:var(--sbm-violet-surface)!important;border-color:var(--sbm-line)!important}
  html[data-sbm-theme="dark"][data-sbm-page="employees"] .paperwork-callout :is(strong,span,b) {color:var(--sbm-violet-text)!important}
  html[data-sbm-theme="dark"][data-sbm-page="backup"] .readiness-list label {background:var(--sbm-surface-soft)!important;color:var(--sbm-text)!important;border-color:var(--sbm-line)!important}
  html[data-sbm-theme="dark"][data-sbm-page="backup"] .readiness-list label:has(input:checked) {background:var(--sbm-success-surface)!important;color:var(--sbm-success-text)!important}
  html[data-theme="dark"] body.archive-viewer:not(.pdf-export) .page2-confirm-title {background:var(--sbm-surface-soft,#192633)!important;color:var(--sbm-text,#e7eef5)!important;border-color:var(--sbm-line,#4e6578)!important}
  html[data-sbm-theme="dark"][data-sbm-page="employees"] :is(.status-badge.none,.status-badge.former) {background:var(--sbm-surface-soft)!important;color:var(--sbm-muted)!important;border:1px solid var(--sbm-line)}
  html[data-sbm-theme="dark"][data-sbm-page="employees"] .group-count {background:var(--sbm-selected-surface)!important;color:var(--sbm-selected-text)!important;border-color:var(--sbm-control-border)!important}
  html[data-sbm-theme="dark"][data-sbm-page="employees"] .employee-view-hero p {color:var(--sbm-muted)!important}
  html[data-sbm-theme="dark"][data-sbm-page="employees"] .eyebrow {color:var(--sbm-warning-text)!important}
  html[data-sbm-theme="dark"][data-sbm-page="employees"] :is(.crew-master-missing,.crew-test-part.alert,.annual-test-missing) {background:var(--sbm-danger-surface)!important;color:var(--sbm-danger-text)!important;border-color:#c57782!important}
  html[data-sbm-theme="dark"][data-sbm-page="employees"] .annual-test-note {background:var(--sbm-info-surface)!important;color:var(--sbm-info-text)!important;border-color:var(--sbm-line)!important}
  html.sbm-one-embedded[data-sbm-theme="dark"][data-sbm-page="employees"] .panel-header {background:var(--sbm-surface-soft)!important;color:var(--sbm-text)!important;border-color:var(--sbm-line)!important}
  html[data-sbm-theme="dark"][data-sbm-page="engine-room"] body:not(.pdf-export) .watch-picker-title {color:var(--sbm-muted)!important}

  /* v214: findings from the complete navigation and form-template review.
     Keep these changes on screen; exported and printed records keep their ink. */
  html[data-sbm-theme="light"] {--h-muted:#526674}
  html[data-sbm-theme="light"] :is(.section-dashboard-controls label,.training-back-row span,#periodLabel) {color:#526674!important}
  html[data-sbm-theme="light"] .temporary-none {color:#526674!important}
  html[data-sbm-theme="light"] body.dashboard-v181 .task-copy .sub {color:#526674!important}
  html[data-sbm-theme="dark"] body.dashboard-v181 :is(.tile,.btn:not(.primary):not(.green):not(.danger)) {background:#192633!important;color:#e7eef5!important;border-color:#5e7282!important}
  html[data-sbm-theme="dark"] body.dashboard-v181 .tile :is(h3,.big) {color:#f1f6fa!important}
  html[data-sbm-theme="dark"] body.dashboard-v181 .tile p {color:#becbd7!important}
  html[data-sbm-theme="dark"] body.dashboard-v181 :is(.tile,.btn):is(:hover,:focus-visible) {background:#253e52!important}

  html[data-sbm-theme="light"][data-sbm-page="employees"] {--muted:#526674;--sbm-muted:#526674}
  html[data-sbm-theme="light"][data-sbm-page="employees"] :is(.stat-label,.stat-note,.alert-desc,.review-empty,.subline,.email-empty,.panel-header p) {color:#526674!important}
  html[data-sbm-theme="light"][data-sbm-page="employees"] .page-label {color:#795500!important}
  html[data-sbm-theme="light"][data-sbm-page="employees"] .status-badge.none {background:#edf2f6!important;color:#526674!important}

  html[data-sbm-theme="light"][data-sbm-page="equipment"] body[data-equipment-page="dashboard"] .panel-head :is(.panel-subtext,.count) {color:#dcecf7!important}
  html[data-sbm-theme="light"][data-sbm-page="equipment"] .fleet-list-summary-card small {color:#526674!important}
  html[data-sbm-page="equipment"] :is(.inspection-card.closed,.inspection-row.closed) {opacity:1}

  html[data-sbm-theme="light"][data-sbm-page="boat-log"] body:not(.pdf-export) :is(.document-title,.payroll-company,.voyage-subtitle) {color:#805800!important}
  html[data-sbm-theme="dark"][data-sbm-page="boat-log"] body:not(.pdf-export) :is(#accessSignOutBtn,.payroll-output-hint,.archive-picker,.sop-number,.safety-form-footer,.safety-form-footer span,.voyage-form-code,.voyage-footer,.voyage-footer span) {color:#becbd7!important}
  html[data-sbm-theme="dark"][data-sbm-page="boat-log"] body:not(.pdf-export) .voyage-subtitle {color:#ffe09a!important}
  html[data-sbm-theme="light"][data-sbm-page="boat-log"] body:not(.pdf-export) .unsat-head {color:#111!important}
  html[data-sbm-theme="dark"][data-sbm-page="boat-log"] body:not(.pdf-export) li.important {color:#ffc2c7!important}
  html[data-sbm-theme="dark"][data-sbm-page="boat-log"] body:not(.pdf-export) .sign-required-note {background:#362b14!important;color:#ffe09a!important;border-color:#b28c38!important}
  html[data-sbm-theme="dark"][data-sbm-page="boat-log"] body:not(.pdf-export) .sign-required-note :is(strong,span) {color:#ffe09a!important}
  html[data-sbm-theme="dark"][data-sbm-page="boat-log"] body:not(.pdf-export) .shared-conflict-panel {background:#3a2027!important;color:#ffc2c7!important;border-color:#c57782!important}
  html[data-sbm-theme="dark"][data-sbm-page="boat-log"] body:not(.pdf-export) .shared-conflict-panel :is(strong,span) {color:#ffc2c7!important}
  html[data-sbm-theme="dark"][data-sbm-page="boat-log"] body:not(.pdf-export) :is(.history-edit-panel,.history-edit-copy,.correction-audit-summary) {background:#152e42!important;color:#c8e8ff!important;border-color:#4e6578!important}
  html[data-sbm-theme="dark"][data-sbm-page="boat-log"] body:not(.pdf-export) .history-edit-copy :is(strong,span) {color:#c8e8ff!important}

  html[data-sbm-theme="light"][data-sbm-page="engine-room"] body:not(.pdf-export) :is(.inv-equipment-sub,.inv-help,.inv-sub,.inv-cell label) {color:#526674!important}
  html[data-sbm-theme="dark"][data-sbm-page="engine-room"] body:not(.pdf-export) :is(.inv-stat,.inv-equipment-head,.inv-history-item,.inv-empty) {background:#192633!important;color:#e7eef5!important;border-color:#4e6578!important}
  html[data-sbm-theme="dark"][data-sbm-page="engine-room"] body:not(.pdf-export) :is(.inv-stat b,.inv-equipment-title,.inv-history-item b,.inv-history-details summary) {color:#f1f6fa!important}
  html[data-sbm-theme="dark"][data-sbm-page="engine-room"] body:not(.pdf-export) :is(.inv-stat span,.inv-equipment-sub,.inv-sub,.inv-cell label,.inv-help,.inv-number.muted,.archive-count,.archive-empty) {color:#becbd7!important}
  html[data-sbm-theme="dark"][data-sbm-page="engine-room"] body:not(.pdf-export) .inv-row {background:#111a23!important;color:#e7eef5!important;border-color:#4e6578!important}
  html[data-sbm-theme="dark"][data-sbm-page="engine-room"] body:not(.pdf-export) .inv-row.out {background:#3a2027!important;border-left-color:#e57d8c!important}
  html[data-sbm-theme="dark"][data-sbm-page="engine-room"] body:not(.pdf-export) .inv-row.low {background:#362b14!important;border-left-color:#d6ad4b!important}
  html[data-sbm-theme="dark"][data-sbm-page="engine-room"] body:not(.pdf-export) .inv-row.ok {background:#133527!important;border-left-color:#70b48a!important}
  html[data-sbm-theme="dark"][data-sbm-page="engine-room"] body:not(.pdf-export) .inv-part {color:#f1f6fa!important}
  html[data-sbm-theme="dark"][data-sbm-page="engine-room"] body:not(.pdf-export) .inv-text-btn {color:#91d2ff!important}
  html[data-sbm-theme="dark"][data-sbm-page="engine-room"] body:not(.pdf-export) .inv-text-btn.danger {color:#ffc2c7!important}
  html[data-sbm-theme="dark"][data-sbm-page="engine-room"] body:not(.pdf-export) .inv-note {background:#152e42!important;color:#c8e8ff!important;border-color:#4e6578!important}

  html[data-sbm-theme="light"][data-sbm-page="tankerman"] body:not(.pdf-export) :is(.statusline,.job-key-label) {color:#526674!important}
  html[data-sbm-theme="light"][data-sbm-page="tankerman"] body:not(.pdf-export) .statusline.good {color:#155938!important}
  html[data-sbm-theme="light"][data-sbm-page="tankerman"] body:not(.pdf-export) .statusline.warn {color:#6b4b08!important}
  html[data-sbm-theme="light"][data-sbm-page="tankerman"] body:not(.pdf-export) .statusline.bad {color:#892e35!important}
  html[data-sbm-theme="dark"][data-sbm-page="tankerman"] body:not(.pdf-export) :is(.sbm-job-subtitle,.job-user-item,.job-activity,.k,.revision,.statusline,.job-key-label) {color:#becbd7!important}
  html[data-sbm-theme="dark"][data-sbm-page="tankerman"] body:not(.pdf-export) :is(.session-name,.notes-title,.job-user-item b) {color:#f1f6fa!important}
  html[data-sbm-theme="dark"][data-sbm-page="tankerman"] body:not(.pdf-export) .instruction .v {color:#ffe09a!important}
  html[data-sbm-theme="dark"][data-sbm-page="tankerman"] body:not(.pdf-export) :is(.qty,.sbm-job-empty) {background:#192633!important;color:#e7eef5!important;border-color:#859bae!important}
  html[data-sbm-theme="dark"][data-sbm-page="tankerman"] body:not(.pdf-export) .gmail-summary-status {background:#192633!important;color:#becbd7!important}
  html[data-sbm-theme="dark"][data-sbm-page="tankerman"] body:not(.pdf-export) :is(.gmail-summary-status.good,.draft-status) {background:#133527!important;color:#a4edbe!important;border-color:#70b48a!important}
  html[data-sbm-theme="dark"][data-sbm-page="tankerman"] body:not(.pdf-export) .gmail-summary-status.warn {background:#362b14!important;color:#ffe09a!important}
  html[data-sbm-theme="dark"][data-sbm-page="tankerman"] body:not(.pdf-export) .gmail-summary-status.bad {background:#3a2027!important;color:#ffc2c7!important}
  html[data-sbm-theme="dark"][data-sbm-page="tankerman"] body:not(.pdf-export) .statusline.good {color:#a4edbe!important}
  html[data-sbm-theme="dark"][data-sbm-page="tankerman"] body:not(.pdf-export) .statusline.warn {color:#ffe09a!important}
  html[data-sbm-theme="dark"][data-sbm-page="tankerman"] body:not(.pdf-export) .statusline.bad {color:#ffc2c7!important}
  html[data-sbm-theme="dark"][data-sbm-page="tankerman"] body:not(.pdf-export) .current-order-card>summary {background:#152e42!important;color:#c8e8ff!important}
  html[data-sbm-theme="dark"][data-sbm-page="tankerman"] body:not(.pdf-export) .current-order-card>summary span {color:#c8e8ff!important}
  html[data-sbm-theme="dark"][data-sbm-page="tankerman"] body:not(.pdf-export) .current-order-card .collapse-action {background:#234863!important;color:#c8e8ff!important;border-color:#859bae!important}

  /* Preserved records have their own page roots rather than editable forms. */
  html:root[data-sbm-theme="dark"] body.archive-viewer:not(.pdf-export) :is(.sop-number,.safety-form-footer,.safety-form-footer span,#archivePickerText) {color:#c4d3e2!important;-webkit-text-fill-color:#c4d3e2!important}
  html:root[data-sbm-theme="dark"] body.completed-log-view:not(.pdf-export) .gauge-reading-banner {background:#152e42!important;color:#c8e8ff!important;border-color:#4e6578!important}
  html:root[data-sbm-theme="dark"] body.completed-log-view:not(.pdf-export) .condition-head {color:#becbd7!important}
  html:root[data-sbm-theme="dark"] body.completed-log-view:not(.pdf-export) .def-toggle {background:#192633!important;color:#e7eef5!important;border-color:#4e6578!important}
  html:root[data-sbm-theme="dark"] body.completed-log-view:not(.pdf-export) .def-toggle.active {background:#3a2027!important;color:#ffc2c7!important;border-color:#c57782!important}
  html:root[data-sbm-theme="dark"] body.completed-log-view:not(.pdf-export) .def-toggle b {color:inherit!important}
}
