/* ============================================================================
   Dark theme — activated by `body.dark-mode`.

   Server-rendered from the `rf_dark` cookie (riskflagsc/app.blade.php adds the
   class) and toggled live by js/rfsc/darkMode.js, so there is no flash.

   Three layers cooperate:
     1. AdminLTE ships its own `.dark-mode` CSS (navbar / sidebar / cards / tables
        / forms / dropdowns) — that gives us the chrome for free.
     2. We re-declare the SEMANTIC design tokens here, so the x-rf-* components and
        the tokenised rfsc.css palette flip with it — exactly as a tenant skin
        re-points tokens (see design-tokens.css). This is the bulk of the theme.
     3. A short, growing list of targeted patches for custom rfsc.css surfaces that
        still carry raw hex and so don't follow the tokens yet.

   Loads LAST in layouts/_siteStyles.blade.php.
   ========================================================================== */

body.dark-mode {
  /* -- Surfaces & lines: swap the roles to dark. Aligned with AdminLTE's dark
        card (#343a40) so x-rf-cards sit flush beside AdminLTE-chrome cards. ---- */
  --rf-surface:        #343a40;
  --rf-surface-muted:  #2b3036;
  --rf-surface-sunken: #23272c;
  --rf-border:         #4b545c;
  --rf-border-strong:  #5a636c;

  /* -- Text ---------------------------------------------------------------- */
  --rf-ink:            #e9ecef;
  --rf-ink-muted:      #adb5bd;
  --rf-ink-faint:      #7e8894;

  /* -- Component defaults -------------------------------------------------- */
  /* Page header: re-declared explicitly rather than left to the var() fallbacks
     in design-system.css, so a tenant skin that pins one of these on :root
     (babcock pins the title colour) still hands dark mode back. */
  --rf-page-header-bg:          var(--rf-surface);
  --rf-page-header-title-color: var(--rf-ink);
  --rf-page-header-icon-color:  var(--rf-ink-muted);
  --rf-card-shadow:    0 1px 3px rgba(0, 0, 0, .45);
  --rf-scrim:          rgba(0, 0, 0, .6);
  --rf-focus-ring:     0 0 0 .2rem rgba(255, 193, 7, .35); /* amber ring reads on dark */
  --rf-warning-ink:    var(--rf-warning);             /* plain amber reads on dark */
}

/* ---------------------------------------------------------------------------
   Patches: custom rfsc.css surfaces that still hold raw hex (so the token
   re-declaration above can't reach them). Keep this list minimal and add to it
   only for surfaces that actually read wrong in dark.
   ------------------------------------------------------------------------ */

/* The sub-claim "level colour" panel + its icon strip are baked light greys. */
body.dark-mode .SCL2-colour,
body.dark-mode .VertAlignerIcons,
body.dark-mode .VertAlignerIconsAA,
body.dark-mode .VertAlignerIconsEA {
  background: var(--rf-surface) !important;
  color: var(--rf-ink) !important;
}
body.dark-mode .SCL2-colour-opacity {
  background: var(--rf-surface-sunken) !important;
  color: var(--rf-ink) !important;
}

/* Context / argument / delivery-plan rows (pale hex fills). */
body.dark-mode .contextPair,
body.dark-mode .contextPairArg {
  background: var(--rf-surface-muted) !important;
  color: var(--rf-ink) !important;
}

/* The riskflagsc card body is a genuine surface. */
body.dark-mode .card-riskflagsc > .card-body {
  background: var(--rf-surface);
  color: var(--rf-ink);
}

/* The dashboard canvas is a full-bleed area, not a card — in dark it must inherit
   the content-wrapper, or its surface fill reads as a darker panel / band. */
body.dark-mode .dashboardfull {
  background: transparent !important;
}

/* Reference-number chips ("Context #1", "Argument #1", "Evidence 1.1"…) — a baked
   white pill; with the inherited light text it would be white-on-white. Give it a
   sunken dark fill + muted light text. (badge-light count pills stay light: a light
   highlight on dark reads fine.) */
body.dark-mode .ContextTitle {
  background-color: var(--rf-surface-sunken) !important;
  color: var(--rf-ink-muted) !important;
}

/* The "please wait" compile animation (pleaseWaitFeature.blade.php) is a baked
   opaque MP4 — dark-navy line art + a cyan accent on a WHITE ground — so it glares
   as a white box in the dark modal. It's monochrome line art, so recolour it live
   rather than ship a second asset: invert flips the white ground dark and the
   strokes light; hue-rotate(180deg) flips luminance while keeping hue, so the cyan
   accent stays blue (a plain invert turns it rust-orange); screen dissolves the
   now-black ground into the modal's own --rf-surface, so there's no black hole. */
body.dark-mode #compilingModal video {
  filter: invert(1) hue-rotate(180deg);
  mix-blend-mode: screen;
}

/* --- Tables ---------------------------------------------------------------- */

/* Row hover: rfsc.css bakes a light-peach (#fff0e0) hover that, under the now-light
   text, is unreadable. Use a subtle light overlay — the conventional dark hover. */
body.dark-mode .table-hover tbody tr:hover td,
body.dark-mode .table-hover tbody tr:hover th {
  background-color: rgba(255, 255, 255, 0.055) !important;
}

/* Bootstrap's light table header keeps its pale fill under AdminLTE dark. */
body.dark-mode .thead-light th,
body.dark-mode .thead-light td {
  background-color: var(--rf-surface-sunken);
  color: var(--rf-ink);
  border-color: var(--rf-border);
}

/* Contextual highlight rows are light-tinted (they pop on dark) — keep the tint but
   restore dark text so the row stays legible. */
body.dark-mode .table-warning, body.dark-mode .table-warning > td, body.dark-mode .table-warning > th,
body.dark-mode .table-info,    body.dark-mode .table-info > td,    body.dark-mode .table-info > th,
body.dark-mode .table-success, body.dark-mode .table-success > td, body.dark-mode .table-success > th,
body.dark-mode .table-danger,  body.dark-mode .table-danger > td,  body.dark-mode .table-danger > th {
  color: #1f2d3d !important;
}

/* --- Bootstrap alert-light ------------------------------------------------- */
/* AdminLTE dark-modes the coloured alert variants but not `alert-light`, so it
   keeps its near-white fill + pale border (light-on-light). Used as a bordered
   note/panel in ~11 places — the assessment-register filter bar, guest task /
   file-request briefs, permissions placeholders, the compliance rule editor —
   whose own contents already read tokens or inherit the alert's colour. Map it
   onto the sunken surface so all of them flip together. */
body.dark-mode .alert-light {
  background: var(--rf-surface-sunken) !important;
  border-color: var(--rf-border) !important;
  color: var(--rf-ink) !important;
}

/* --- Un-tokenised pale one-off backgrounds (the "tail") -------------------- */
/* These custom surfaces bake a specific light hex (#e8f6fa, #EAEBED, …) that no
   token aliases, so they can't be flipped value-preservingly in the sweep. Map the
   panel-like ones onto the sunken dark surface; small status pills stay light chips
   with dark text; light hover states become a subtle overlay. */

body.dark-mode .resp-org-div,
body.dark-mode .SCL2Argument-colour,
body.dark-mode .DPelsewhere,
body.dark-mode .box.box-solid.SCL2form,
body.dark-mode .RowL4,
body.dark-mode #template > .TLC > .SCL1 > .SCL2 {
  background: var(--rf-surface-sunken) !important;
  color: var(--rf-ink) !important;
}

body.dark-mode #searchResults .search-result-item:hover,
body.dark-mode .widget-picker-item:hover,
body.dark-mode .widget-picker-group__toggle,
body.dark-mode .widget-position-cell:hover,
body.dark-mode .comment.wysiwyg > [contenteditable=true]:hover,
body.dark-mode .comment.wysiwyg > [contenteditable=true]:focus {
  background-color: rgba(255, 255, 255, 0.055) !important;
}

body.dark-mode span.EvidenceValidTo,
body.dark-mode span.EvidenceFromCaseSlot {
  color: #1f2d3d !important;
}

/* ==========================================================================
   Data-heavy pages — pale/near-white feature backgrounds that no token
   aliases (risk matrix, register, compliance, bow tie, and the feature
   stylesheets they share). Derived from a min(R,G,B) >= 200 scan of 56 feature
   stylesheets, then hand-reconciled. Saturated accents (risk-level cells, the
   engagement heat scale, brand navy, RAG status fills) and var(--rf-surface*)
   backgrounds are deliberately excluded: the accents are meant to stay, and the
   token-backed surfaces already flip via the re-declaration at the top.
   ========================================================================== */

/* ---- PANEL / SURFACE: pale card/panel/row/cell/header fills -> dark sunken --- */
/* riskmatrix */
body.dark-mode .context-filters-panel,
body.dark-mode .context-filter-locked .select2-container--default .select2-selection--multiple,
body.dark-mode .context-filter-input-label,
body.dark-mode .riskMatrixTitleCell,
body.dark-mode .riskMatrixTitleCellBanner,
body.dark-mode .riskMatrixTable th,
body.dark-mode .assessment-timeline-toggle,
body.dark-mode .assessmentPopover,
body.dark-mode .matrixIndexTab,
body.dark-mode .assessment-ripple-offer,
body.dark-mode .scl2ScoringUnassessed {
  background: var(--rf-surface-sunken) !important;
  color: var(--rf-ink) !important;
}

/* register */
body.dark-mode .register-page-header,
body.dark-mode .registerColumnGroupHeader,
body.dark-mode .registerColumnSubGroupHeader,
body.dark-mode .registerGutterColumn,
body.dark-mode .registerToolsGutterColumn,
body.dark-mode blockquote,
body.dark-mode .register-grid-header,
body.dark-mode .register-grid-gutter,
body.dark-mode .register-grid-tools,
body.dark-mode .register-sticky-xscroll,
body.dark-mode .register-sticky-gutter,
body.dark-mode .register-sticky-cell,
body.dark-mode .register-sticky-header,
body.dark-mode .register-grid-group-header,
body.dark-mode .register-grid-subgroup-header,
body.dark-mode .register-row.ui-sortable-helper,
body.dark-mode .register-row.ui-sortable-placeholder,
body.dark-mode .popover .popover-header,
body.dark-mode .register-group-header-cell,
body.dark-mode .file-upload-existing,
body.dark-mode .register-ripple-offer,
body.dark-mode .spv-preview-page,
body.dark-mode .spv-title-card,
body.dark-mode .spv-fields-card,
body.dark-mode .spv-matrix-unassessed,
body.dark-mode .spv-geotag-card,
body.dark-mode .spv-matrix-card,
body.dark-mode .spv-hover-table .spv-hover-step-side,
body.dark-mode .spv-group,
body.dark-mode .spv-group-label,
body.dark-mode .spv-group-vertical .spv-subgroup-boxed .spv-subgroup-fields,
body.dark-mode .spv-h-group,
body.dark-mode .spv-h-subgroup,
body.dark-mode.spv-mode .content-wrapper,
body.dark-mode .spv-page:fullscreen,
body.dark-mode .spv-page:-webkit-full-screen,
body.dark-mode .sortableSubGroups,
body.dark-mode .column-options-list .column-option-item,
body.dark-mode #columnOptionsModal .ui-sortable-placeholder,
body.dark-mode .ui-sortable-helper,
body.dark-mode .ui-sortable-helper tr,
body.dark-mode .ui-sortable-helper td,
body.dark-mode .ui-sortable-placeholder,
body.dark-mode .columnsGrid .gridHeader,
body.dark-mode .columnsGrid .groupHeaderCell,
body.dark-mode .columnsGrid .subGroupHeaderCell,
body.dark-mode .columnsGrid .subGroupContainer > .ui-sortable-placeholder,
body.dark-mode .grid-sort-helper,
body.dark-mode .grid-sort-placeholder,
body.dark-mode .evaluation-conditions-table .evaluation-row-disabled,
body.dark-mode .evaluation-row-has-issue td,
body.dark-mode .reviewColumnsGrid .gridHeader,
body.dark-mode .reviewColumnsGrid .ui-sortable-placeholder,
body.dark-mode .assessment-dots-container {
  background: var(--rf-surface-sunken) !important;
  color: var(--rf-ink) !important;
}

/* compliance */
body.dark-mode .cib-progress,
body.dark-mode .cib-details,
body.dark-mode .compliance-summary-thead th,
body.dark-mode .compliance-summary-table th.compliance-col-subgroup,
body.dark-mode .compliance-summary-table th.compliance-col-subgroup-empty,
body.dark-mode .compliance-summary-table th.compliance-col-group-empty,
body.dark-mode .compliance-group-header-row,
body.dark-mode .compliance-item-row--parent,
body.dark-mode .compliance-state-square,
body.dark-mode .compliance-state-empty,
body.dark-mode .compliance-section-header,
body.dark-mode .compliance-subsection-header,
body.dark-mode .compliance-item-ref,
body.dark-mode .compliance-checklist-item.compliance-row-review-locked,
body.dark-mode .compliance-checklist-item.compliance-row-review-failed,
body.dark-mode .compliance-checklist-item.compliance-row-invalid,
body.dark-mode .compliance-evidence-upload.compliance-evidence-invalid,
body.dark-mode .compliance-review-annotation-failed .compliance-review-note-block,
body.dark-mode .compliance-evidence-upload,
body.dark-mode .compliance-evidence-row,
body.dark-mode .compliance-file-thumb,
body.dark-mode .compliance-file-doc-link,
body.dark-mode .compliance-review-annotation,
body.dark-mode .compliance-review-column-value,
body.dark-mode .compliance-plan-header,
body.dark-mode .compliance-plan-container,
body.dark-mode .compliance-plan-label,
body.dark-mode .edit-tree-toggle,
body.dark-mode .edit-tree-body,
body.dark-mode .edit-tree-node.edit-tree-parent:not(.edit-tree-active),
body.dark-mode #assignmentTimelineContainer .vis-item.timeline-item-past.vis-range,
body.dark-mode #complianceShowTimeline .vis-item.timeline-item-projected.vis-range,
body.dark-mode .contractor-stat-card,
body.dark-mode .contractor-overall-progress .progress,
body.dark-mode .contractor-ub-row-active,
body.dark-mode .contractor-ub-progress,
body.dark-mode .contractor-ub-row-expanded,
body.dark-mode .contractor-ub-detail,
body.dark-mode .contractor-task-progress,
body.dark-mode .contractor-type-bar,
body.dark-mode .contractor-acting-as-bar,
body.dark-mode .compliance-case-header {
  background: var(--rf-surface-sunken) !important;
  color: var(--rf-ink) !important;
}

/* bowtie — the diagram canvas + mini-map + floating toolbars go dark */
body.dark-mode #container,
body.dark-mode .toolbarPopup,
body.dark-mode #containerMini,
body.dark-mode #miniMap,
body.dark-mode .bt-card-white-header .card-header {
  background: var(--rf-surface-sunken) !important;
  color: var(--rf-ink) !important;
}

/* rfsc — document rows, clone bars, tinymce variable button, asset placer */
body.dark-mode .toolbar-top,
body.dark-mode .bg-kbi,
body.dark-mode .bg-btMetaTypes,
body.dark-mode .connectionExistingRow.kbiEntity,
body.dark-mode .ComponentisedDocumentRow,
body.dark-mode .ComponentisedDocumentRow.notTemplateControlledRow,
body.dark-mode .ComponentisedDocumentRow > .ComponentisedDocumentDisplayName,
body.dark-mode .documentationIndex .ComponentisedDocumentRow > .ComponentisedDocumentContent,
body.dark-mode #progressInfo>.progressInfoText,
body.dark-mode .SafetyCaseCloneConnections,
body.dark-mode .engagement-day,
body.dark-mode .pdf-main,
body.dark-mode .pdf-sidebar,
body.dark-mode .pdf-page-canvas,
body.dark-mode .placed-asset,
body.dark-mode .placed-already,
body.dark-mode .caseImageThumb__preview,
body.dark-mode .trigger-data-container,
body.dark-mode .context-container,
body.dark-mode .matrix-container {
  background: var(--rf-surface-sunken) !important;
  color: var(--rf-ink) !important;
}

/* geotag */
body.dark-mode .sc-icon-picker-panel,
body.dark-mode .sc-icon-picker-search-wrap,
body.dark-mode .sc-geotag-popup__assessment-step,
body.dark-mode .sc-geotag-legend__toggle,
body.dark-mode .sc-geotag-legend__body,
body.dark-mode #osmmapcontainer.sc-geotag-fullscreen {
  background: var(--rf-surface-sunken) !important;
  color: var(--rf-ink) !important;
}

/* ai import */
body.dark-mode .AiImportOverlayViewer,
body.dark-mode .AiPdfPage {
  background: var(--rf-surface-sunken) !important;
  color: var(--rf-ink) !important;
}

/* goldenthread timeline */
body.dark-mode #goldenThreadContent:fullscreen,
body.dark-mode #goldenThreadContent:-webkit-full-screen,
body.dark-mode #goldenThreadTimeline .gt-canvas,
body.dark-mode #goldenThreadTimeline .gt-tick-label,
body.dark-mode #goldenThreadTimeline .gt-axis-line {
  background: var(--rf-surface-sunken) !important;
  color: var(--rf-ink) !important;
}

/* file-slots matrix */
body.dark-mode .fileSlotCell.not-required,
body.dark-mode td:has(> .fileSlotCell.not-required),
body.dark-mode .fileSlotCell .editThing .file-supersede-history-btn,
body.dark-mode .fileSlotsMatrix__stickyCol,
body.dark-mode .fileSlotsMatrix thead th,
body.dark-mode .fileSlotEvidenceBox {
  background: var(--rf-surface-sunken) !important;
  color: var(--rf-ink) !important;
}

/* file-supersede */
body.dark-mode .file-supersede-trash-popover,
body.dark-mode .file-supersede-compare-pane,
body.dark-mode .file-supersede-mapping-row.is-unresolved,
body.dark-mode .file-supersede-pdf-cover {
  background: var(--rf-surface-sunken) !important;
  color: var(--rf-ink) !important;
}

/* pdf-picker */
body.dark-mode .pdf-picker-container,
body.dark-mode .pdf-picker-page,
body.dark-mode .pdf-picker-loading-toast,
body.dark-mode .pdf-picker-progress {
  background: var(--rf-surface-sunken) !important;
  color: var(--rf-ink) !important;
}

/* api-docs */
body.dark-mode .api-header__logo,
body.dark-mode .api-btn--primary,
body.dark-mode .api-toc__input,
body.dark-mode .api-toc__count,
body.dark-mode .api-card,
body.dark-mode .api-op,
body.dark-mode .api-schema {
  background: var(--rf-surface-sunken) !important;
  color: var(--rf-ink) !important;
}

/* help-snapshot (editor chrome) */
body.dark-mode .snapshot-toolbar,
body.dark-mode .snapshot-toolbar-separator,
body.dark-mode .snapshot-annotate-wrap,
body.dark-mode .snapshot-annotate-toolbar,
body.dark-mode .snapshot-annotate-canvas-wrap,
body.dark-mode .snapshot-tool-btn,
body.dark-mode .snapshot-steps-panel,
body.dark-mode .snapshot-steps-panel-header,
body.dark-mode .snapshot-status-bar,
body.dark-mode .snapshot-brand-progress-bar,
body.dark-mode #snapshotCarousel .carousel-item img,
body.dark-mode .snapshot-regen-panel,
body.dark-mode .snapshot-regen-gif-prompt,
body.dark-mode .snapshot-regen-gif-desc,
body.dark-mode .callout-editor-canvas,
body.dark-mode .callout-editor-hotspot-handle,
body.dark-mode .brand-review-panel,
body.dark-mode .brand-review-hotspot-handle,
body.dark-mode .brand-review-hotspot-redraw {
  background: var(--rf-surface-sunken) !important;
  color: var(--rf-ink) !important;
}

/* variable-chips */
body.dark-mode .rf-var,
body.dark-mode .variable-picker-panel,
body.dark-mode .variable-values-bulk-bar,
body.dark-mode .variable-picker-per-case,
body.dark-mode .rfLocationSuggestions {
  background: var(--rf-surface-sunken) !important;
  color: var(--rf-ink) !important;
}

/* manual (help) — search + image galleries */
body.dark-mode .manual-welcome-search .input-group-text,
body.dark-mode .manual-welcome-results.has-results,
body.dark-mode .manual-toc,
body.dark-mode .manual-single-image,
body.dark-mode .manual-stack-card,
body.dark-mode #manualCarousel .carousel-item img {
  background: var(--rf-surface-sunken) !important;
  color: var(--rf-ink) !important;
}

/* mcp studio + guide */
body.dark-mode .mcp-var,
body.dark-mode .mcp-guide code,
body.dark-mode .mcp-guide blockquote,
body.dark-mode .mcp-guide th {
  background: var(--rf-surface-sunken) !important;
  color: var(--rf-ink) !important;
}

/* logviewer footer (bare .box left alone — too generic for a global override) */
body.dark-mode .main-footer {
  background: var(--rf-surface-sunken) !important;
  color: var(--rf-ink) !important;
}

/* document viewer */
body.dark-mode .documentViewerBody,
body.dark-mode .documentViewerSidebar,
body.dark-mode .documentViewerCard .card-header {
  background: var(--rf-surface-sunken) !important;
  color: var(--rf-ink) !important;
}

/* rfscadmin — compliance-event catalogue save-state rows */
body.dark-mode .compliance-event-row.is-dirty,
body.dark-mode .compliance-event-row.is-saving,
body.dark-mode .compliance-event-row.is-saved,
body.dark-mode .compliance-event-row.is-error {
  background: var(--rf-surface-sunken) !important;
  color: var(--rf-ink) !important;
}

/* report templates */
body.dark-mode .ReportTemplateRow__defaultLabel {
  background: var(--rf-surface-sunken) !important;
  color: var(--rf-ink) !important;
}

/* ---- HOVER / FOCUS: pale hover fills -> subtle light overlay ---------------- */
/* riskmatrix */
body.dark-mode .assessment-timeline-toggle:hover,
body.dark-mode .assessment-timeline-toggle:focus {
  background-color: rgba(255, 255, 255, 0.055) !important;
}

/* register */
body.dark-mode .register-row:hover,
body.dark-mode .register-row:hover .register-grid-gutter,
body.dark-mode .register-grid-cell:not(.register-grid-header):hover,
body.dark-mode .richTextCell .richTextPreview:hover,
body.dark-mode .geoTagCellClickable:hover {
  background-color: rgba(255, 255, 255, 0.055) !important;
}

/* compliance (.compliance-row-pending:hover left out — it is a tinted row) */
body.dark-mode .cib-header:hover,
body.dark-mode .compliance-item-row:hover,
body.dark-mode .compliance-checklist-item:hover,
body.dark-mode .compliance-na-toggle:hover,
body.dark-mode .compliance-file-doc-link:hover,
body.dark-mode .compliance-plan-header:hover,
body.dark-mode .compliance-plan-header-disabled:hover,
body.dark-mode .edit-tree-toggle:hover,
body.dark-mode .edit-tree-node:hover,
body.dark-mode .contractor-ub-row:hover,
body.dark-mode .compliance-case-header:hover {
  background-color: rgba(255, 255, 255, 0.055) !important;
}

/* …except the Yes/No group's middle N/A button, which sits between two solid
   buttons: the shared 5.5% wash reads as no response at all there. Needs
   !important only because the rule above has it. */
body.dark-mode .compliance-yesno-toggle .compliance-na-toggle:hover {
  background-color: rgba(255, 255, 255, 0.22) !important;
}

/* bowtie */
body.dark-mode .toolbarButton:hover {
  background-color: rgba(255, 255, 255, 0.055) !important;
}

/* rfsc */
body.dark-mode .exportBtn:hover,
body.dark-mode .exportBtn:focus,
body.dark-mode .menu>li>a:hover,
body.dark-mode .dashboard-widget-remove:hover,
body.dark-mode .fsa-case-remove:hover,
body.dark-mode .placed-asset:hover,
body.dark-mode #deliveryPlansTable tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.055) !important;
}

/* geotag */
body.dark-mode .sc-icon-picker-clear:hover,
body.dark-mode .sc-icon-picker-item:hover {
  background-color: rgba(255, 255, 255, 0.055) !important;
}

/* file-slots matrix */
body.dark-mode .fileSlotCell .editThing .file-supersede-history-btn:hover {
  background-color: rgba(255, 255, 255, 0.055) !important;
}

/* pdf-picker */
body.dark-mode .pdf-picker-bookmark-item:hover,
body.dark-mode .pdf-picker-page-item:hover {
  background-color: rgba(255, 255, 255, 0.055) !important;
}

/* api-docs */
body.dark-mode .api-btn--primary:hover,
body.dark-mode .api-toc__link:hover,
body.dark-mode .api-op__toggle:hover {
  background-color: rgba(255, 255, 255, 0.055) !important;
}

/* help-snapshot */
body.dark-mode .snapshot-tool-btn:hover,
body.dark-mode .snapshot-regen-toggle:hover {
  background-color: rgba(255, 255, 255, 0.055) !important;
}

/* ---- STATUS TINTS / PILLS / CHIPS: keep the light tint, restore dark text --- */
/* riskmatrix — incl. both white "pre" step pills (dashed border needs a light bg) */
body.dark-mode .step-title-badge.step-badge-pre,
body.dark-mode .matrix-step-badge.step-badge-pre,
body.dark-mode .assessmentBadge {
  color: #1f2d3d !important;
}

/* register */
body.dark-mode .registerAssessmentBadge,
body.dark-mode .spv-chip-pre,
body.dark-mode .condition-badge-pass,
body.dark-mode .condition-badge-fail,
body.dark-mode .condition-badge-critical {
  color: #1f2d3d !important;
}

/* compliance */
body.dark-mode .compliance-row-complete td,
body.dark-mode .compliance-row-pending td,
body.dark-mode .compliance-review-section-header,
body.dark-mode .compliance-row-deep-linked > td,
body.dark-mode #complianceShowTimeline .vis-custom-time .vis-custom-time-marker,
body.dark-mode .contractor-ub-team-badge,
body.dark-mode .contractor-ub-via-team-badge {
  color: #1f2d3d !important;
}

/* rfsc (DocumentRow alert rows handled separately below) */
body.dark-mode .connectionSearchResult.kbiEntity,
body.dark-mode .connectionExistingRow.bowtieSearchResult,
body.dark-mode .connectionSearchResult.bowtieSearchResult,
body.dark-mode .wb-KbiTemplateEntity .wb-indent,
body.dark-mode .wb-BowTie .wb-indent,
body.dark-mode .fr-match-highlight,
body.dark-mode .fr-replace-highlight,
body.dark-mode .activity-log-interval-current-pill,
body.dark-mode .fr-var-chip,
body.dark-mode .fr-var-chip-empty {
  color: #1f2d3d !important;
}

/* rfsc — document-list rows in dark mode. The neutral (untemplated) rows took
   --rf-surface-sunken (near-black), and their title (.DocumentDisplayName) is pinned
   to a dark `darkslategray` (rfsc.css:3642), so they read as unreadable dark-on-dark
   blocks ("Other org-level components" looked too dark). Render them as a light card
   with dark text — the SAME treatment the RAG rows below already use (light tint +
   #1f2d3d text), just neutral grey — so the dark title reads correctly, exactly as it
   does on the green/red rows. */
body.dark-mode .DocumentRow,
body.dark-mode .DocumentRow.alert-secondary,
body.dark-mode .DocumentRow.notTemplateControlledRow {
  background: #b8bdc2 !important;
  color: #1f2d3d !important;
}
body.dark-mode .DocumentRow.alert-success {
  background: #d4edda !important;
  color: #1f2d3d !important;
}
body.dark-mode .DocumentRow.alert-danger {
  background: #f8d7da !important;
  color: #1f2d3d !important;
}

/* orgadmin */
body.dark-mode .action-type-badge,
body.dark-mode .tag-swatch--light {
  color: #1f2d3d !important;
}

/* geotag */
body.dark-mode .sc-geotag-popup__assessment-link .assessmentBadge {
  color: #1f2d3d !important;
}

/* goldenthread event chips */
body.dark-mode #goldenThreadTimeline .gt-chip,
body.dark-mode #goldenThreadTimeline .gt-chip.gt-file-upload,
body.dark-mode #goldenThreadTimeline .gt-chip.gt-report-generated,
body.dark-mode #goldenThreadTimeline .gt-chip.gt-report-submitted,
body.dark-mode #goldenThreadTimeline .gt-chip.gt-key-event,
body.dark-mode #goldenThreadTimeline .gt-chip.gt-review {
  color: #1f2d3d !important;
}

/* file-slots matrix — overdue review cue */
body.dark-mode .fileSlotCell.review-overdue,
body.dark-mode td:has(> .fileSlotCell.review-overdue) {
  color: #1f2d3d !important;
}

/* pdf-picker */
body.dark-mode .pdf-picker-selection-tag {
  color: #1f2d3d !important;
}

/* help-snapshot */
body.dark-mode .brand-review-status-adjusted,
body.dark-mode .brand-review-status-ok {
  color: #1f2d3d !important;
}

/* manual-search + logviewer */
body.dark-mode #searchResults .manual-search-snippet mark,
body.dark-mode .badge.empty {
  color: #1f2d3d !important;
}

/* ---- SELECTION / ACTIVE highlights: keep the light selection tint, dark text - */
body.dark-mode .edit-tree-node.edit-tree-active,
body.dark-mode .api-toc__link--group.is-active,
body.dark-mode .api-toc__link--group.is-active .api-toc__count,
body.dark-mode .api-toc__link.is-active,
body.dark-mode .pdf-picker-bookmark-item.active,
body.dark-mode .pdf-picker-page-item.active,
body.dark-mode .pdf-picker-bookmark-item.selected,
body.dark-mode .pdf-picker-page-item.selected,
body.dark-mode .widget-picker-item.widget-picker-selected,
body.dark-mode #deliveryPlansTable tbody tr.selected {
  color: #1f2d3d !important;
}

/* ---- SEARCH / WARNING highlights (#fff3cd): keep tint, dark text ------------- */
body.dark-mode .snapshot-brand-progress,
body.dark-mode .manual-search-snippet mark,
body.dark-mode .snapshot-mode-banner,
body.dark-mode .rf-var-empty {
  color: #1f2d3d !important;
}

/* ---- VEILS: translucent WHITE loading/empty scrims -> dark scrim ------------- */
/* A white veil over now-dark content flashes bright; flip it to the dark scrim. */
body.dark-mode .sc-geotag-empty,
body.dark-mode .register-field-review,
body.dark-mode .register-presence-bar {
  background: var(--rf-scrim) !important;
  color: var(--rf-ink) !important;
}

/* ---- CLONE dialog tree panels (#ffffff8a wash over a coloured parent) -------- */
/* Keep the see-through wash, but dark, so the parent's colour still reads under it. */
body.dark-mode .SCL2Entities,
body.dark-mode .SafetyCaseCloneSCL2Evs,
body.dark-mode .SafetyCaseCloneConnection,
body.dark-mode .SafetyCaseCloneDocument,
body.dark-mode .SafetyCaseCloneCategory,
body.dark-mode .SafetyCaseCloneSCL1,
body.dark-mode .SafetyCaseCloneSCL2,
body.dark-mode .SafetyCaseCloneSCL2Arg,
body.dark-mode .SafetyCaseCloneSCL2Ev,
body.dark-mode .SafetyCaseCloneSCL2Context,
body.dark-mode .SafetyCaseCloneSCL2DP,
body.dark-mode .SafetyCaseCloneSCL2Mit,
body.dark-mode .SafetyCaseCloneRegister,
body.dark-mode .SafetyCaseCloneRegisterItem,
body.dark-mode .evidenceCloneOrLink {
  background-color: rgba(0, 0, 0, 0.22) !important;
  color: var(--rf-ink) !important;
}

/* ---- Wunderbaum grid/tree (vendor skin) ------------------------------------ */
/* Wunderbaum ships its own CSS (a frontend_lib, so it is outside the feature-CSS
   sweep): a white grid body, a #dedede header and pale active/selected cells that
   all stay light in dark mode. It renders the registers, the assessment-register
   entity tree, the bow tie index and the evidence-connection pickers, so theme it
   here. Rows are transparent by default (the grid body shows through), so only the
   body, header, cell text/borders and the active/selected/hover states need it. */
body.dark-mode .wunderbaum,
body.dark-mode div.wb-grid {
  background-color: var(--rf-surface) !important;
  color: var(--rf-ink) !important;
}
body.dark-mode .wb-header,
body.dark-mode .wb-header .wb-col {
  background-color: var(--rf-surface-sunken) !important;
  color: var(--rf-ink) !important;
  border-color: var(--rf-border) !important;
}
/* Wunderbaum's own skin zebra-stripes data rows a light grey (#f7f7f7). On a
   dark grid with light row text that reads as light-on-light. Drop the row fill
   so the dark grid surface shows through; hover/selected re-add their overlay
   below (higher specificity, so they still win). */
body.dark-mode .wb-row {
  background-color: transparent !important;
}
body.dark-mode .wb-row .wb-col {
  color: var(--rf-ink) !important;
  border-color: var(--rf-border) !important;
}
body.dark-mode .wb-row:hover,
body.dark-mode .wb-col.wb-active,
body.dark-mode .wb-row.wb-active .wb-col.wb-active {
  background-color: rgba(255, 255, 255, 0.06) !important;
}
body.dark-mode .wb-row.wb-selected {
  background-color: rgba(255, 255, 255, 0.04) !important;
}

/* ---- Top navbar ------------------------------------------------------------- */
/* The app sets `navbar-white navbar-light` (config('adminlte.classes_topnav')),
   which AdminLTE dark leaves light, so the header bar stays white in dark mode.
   Flip the bar and its controls here — keyed on body.dark-mode so it follows the
   live toggle too (a Blade/config class swap would only take effect on the next
   page load, lagging the toggle). The custom navbar icons carry explicit
   text-dark / text-secondary / text-default utilities for the white bar, so let
   them inherit the (now light) nav-link colour rather than enumerating each. */
body.dark-mode .main-header.navbar {
  background-color: var(--rf-surface) !important;
  border-bottom: 1px solid var(--rf-border) !important;
}
body.dark-mode .main-header.navbar .nav-link,
body.dark-mode .main-header.navbar .navbar-nav > .nav-item > .nav-link {
  color: var(--rf-ink-muted) !important;
}
body.dark-mode .main-header.navbar .nav-link:hover,
body.dark-mode .main-header.navbar .nav-link:focus {
  color: var(--rf-ink) !important;
}
body.dark-mode .main-header.navbar .nav-link i {
  color: inherit !important;
}

/* Deliberately NOT patched here (documented, low-impact): ::-webkit-scrollbar
   tracks/thumbs and slider/toggle knob pseudo-elements; the .splitDimensionMissing
   hatch + .fsa-dial conic-gauge gradients (data-viz); @keyframes pulse/flash steps
   (transient); and tenant-skin / public-login backgrounds (body.dark-mode never
   applies to those — a fix belongs in the skin). Full inventory:
   scratchpad findings.json / table_final.txt from the 2026-08-31 dark-gap scan. */

/* .btn-outline-brand (the inactive half of a brand segmented control) is navy
   text on a transparent ground, and the brand navy is not re-declared for dark
   mode — so on the dark surface the label vanished. Ink on the surface instead;
   hover / .active fill to brand exactly as in light mode. */
body.dark-mode .btn-outline-brand {
  color: var(--rf-ink);
  border-color: var(--rf-border-strong);
}

body.dark-mode .btn-outline-brand:hover,
body.dark-mode .btn-outline-brand.active {
  color: var(--rf-on-primary);
  background-color: var(--rf-primary);
  border-color: var(--rf-brand-border);
}
