/* Shared dark theme. Preserve navigation geometry and risk values; paired light fixes follow below. */
html.dark-style {
  color-scheme: dark;
  --rq-canvas: #0b1018;
  --rq-surface: #141c28;
  --rq-surface-2: #1d2939;
  --rq-border: #38485d;
  --rq-text: #edf2f8;
  --rq-muted: #b3c0d2;
  --rq-action: #75dfd1;
  --rq-action-hover: #a3eee3;
  --rq-action-text: #092c2a;
  --rq-action-soft: #163b3b;
  --rq-focus: #75dfd1;
  --rq-ai: #d7c1ff;
  --rq-ai-soft: #35294b;
  --rq-shadow: 0 4px 20px #00000020;
  --rq-dark-text: var(--rq-text);
  --rq-dark-muted: var(--rq-muted);
  --rq-dark-surface: var(--rq-surface);
  --rq-dark-raised: var(--rq-surface-2);
  --rq-dark-border: var(--rq-border);
  --rq-control-border: #73869f;
  /* Older assessment and verification components share these aliases. */
  --am-page: var(--rq-canvas); --am-card: var(--rq-surface);
  --am-elevated: var(--rq-surface-2); --am-inset: #101925;
  --am-hairline: var(--rq-border); --am-hairline-strong: var(--rq-control-border);
  --am-text: var(--rq-text); --am-heading: var(--rq-text); --am-muted: var(--rq-muted);
  --am-accent: #187b71; --am-accent-soft: var(--rq-action-soft);
  --am-accent-text: var(--rq-action); --am-accent-ring: #75dfd155;
  --bs-body-bg: var(--rq-canvas);
  --bs-body-color: var(--rq-text);
  --bs-heading-color: var(--rq-text);
  --bs-secondary-color: var(--rq-muted);
  --bs-secondary-bg: var(--rq-surface-2);
  --bs-tertiary-bg: var(--rq-surface-2);
  --bs-border-color: var(--rq-border);
  --bs-link-color: var(--rq-action);
  --bs-link-hover-color: var(--rq-action-hover);
}
html.dark-style body { background: var(--rq-canvas); color: var(--rq-text); }
html.dark-style :is(.rq-shell,.authentication-wrapper) {
  color: var(--rq-text);
  --bs-card-color: var(--rq-text);
  --bs-card-bg: var(--rq-surface);
  --bs-card-border-color: var(--rq-border);
}
html.dark-style :is(.rq-shell,.authentication-wrapper) :is(h1,h2,h3,h4,h5,h6,.h1,.h2,.h3,.h4,.h5,.h6,.card-title,.text-heading,.text-body,.text-dark,.form-label,.col-form-label,.form-check-label) { color: var(--rq-text) !important; }
html.dark-style :is(.rq-shell,.authentication-wrapper) :is(.text-muted,.text-secondary,.form-text,.text-body-secondary,.breadcrumb-item,.breadcrumb-item.active,.dataTables_info,.stat-label,.info-label,.scan-card-status) { color: var(--rq-muted) !important; }
html.dark-style :is(.rq-shell,.authentication-wrapper) :is(.card,.modern-card,.stats-grid,.admin-widget,.metric-card,.vendor-client,.list-group-item,.accordion-item) { background: var(--rq-surface); color: var(--rq-text); border-color: var(--rq-border); box-shadow: var(--rq-shadow); }
html.dark-style :is(.rq-shell,.authentication-wrapper) :is(.card-header,.card-footer,.modern-card-header) { background: transparent; color: var(--rq-text); border-color: var(--rq-border); }
html.dark-style .rq-shell .card { border: 1px solid var(--rq-border); }
html.dark-style :is(.rq-shell,.authentication-wrapper) :is(.bg-white,.bg-light,.bg-light-subtle,.bg-body,.info-box,.domain-badge,.domain-count-badge,.no-domains-state,.mfa-secret-box) { background: var(--rq-surface-2) !important; color: var(--rq-text); border-color: var(--rq-border); }
html.dark-style :is(.rq-shell,.authentication-wrapper) :is(.stat-number,.info-value,.modern-card h6,.stat-item) { color: var(--rq-text); }
html.dark-style .rq-shell .layout-menu { background: #0e1722 !important; border-inline-end-color: var(--rq-border) !important; }
html.dark-style .rq-shell .menu-vertical .menu-inner .menu-item.active > .menu-link { background: var(--rq-action-soft) !important; box-shadow: inset 3px 0 0 var(--rq-action); }
html.dark-style .rq-shell .menu-vertical .menu-inner .menu-item.active > .menu-link :is(div,i),
html.dark-style .rq-shell .menu-vertical .menu-inner .menu-item.active > .menu-link { color: var(--rq-action) !important; }
html.dark-style .rq-shell .menu-header-text { color: var(--rq-muted) !important; }
html.dark-style :is(.rq-shell,.authentication-wrapper) a:not(.btn):not(.badge):not(.menu-link):not(.dropdown-item):not(.page-link):not(.nav-link):not(.rq-stat-link):not(.rq-metric) { color: var(--rq-action); }
html.dark-style :is(.rq-shell,.authentication-wrapper) .text-primary { color: var(--rq-action) !important; }

/* Input boundaries, placeholders, selected/disabled states and validation. */
html.dark-style :is(.form-control,.form-select,.input-group-text,.modern-input,.select2-container--default .select2-selection,.select2-container--bootstrap-5 .select2-selection,.tagify) {
  background-color: #101925 !important; color: var(--rq-text) !important; border-color: var(--rq-control-border) !important;
  --tag-bg: var(--rq-surface-2); --tag-text-color: var(--rq-text); --tags-border-color: var(--rq-control-border);
}
html.dark-style :is(.form-control,.form-select,.modern-input):focus { border-color: var(--rq-action) !important; box-shadow: 0 0 0 3px #75dfd12e; }
html.dark-style :is(input,textarea)::placeholder { color: var(--rq-muted) !important; opacity: 1; }
html.dark-style :is(input,select,textarea):disabled,
html.dark-style :is(.form-control,.modern-input)[readonly] { color: #bec9d8 !important; background: #202c3b !important; opacity: 1; }
html.dark-style :is(input,textarea):autofill { box-shadow: 0 0 0 1000px #101925 inset !important; -webkit-text-fill-color: var(--rq-text); caret-color: var(--rq-text); }
html.dark-style .form-check-input { background-color: #101925; border-color: var(--rq-control-border); }
html.dark-style .form-check-input:checked { background-color: #187b71; border-color: var(--rq-action); }
html.dark-style :is(.invalid-feedback,.text-danger) { color: #ffb3bf !important; }
html.dark-style .is-invalid { border-color: #ffb3bf !important; }
html.dark-style :is(.valid-feedback,.text-success) { color: #9ae5bd !important; }
html.dark-style .text-warning { color: #ffdb93 !important; }
html.dark-style .text-info { color: #a9d4ff !important; }
html.dark-style :is(a,button,input,select,textarea,summary,[tabindex]):focus-visible { outline: 3px solid var(--rq-focus) !important; outline-offset: 3px; }
html.dark-style :is(.rq-shell,.authentication-wrapper) .btn-primary,
html.dark-style .swal2-confirm:not(.btn-danger):not(.modern-logout-confirm) { background: var(--rq-action) !important; color: var(--rq-action-text) !important; border-color: var(--rq-action) !important; box-shadow: none; }
html.dark-style :is(.rq-shell,.authentication-wrapper) .btn-primary:hover { background: var(--rq-action-hover) !important; border-color: var(--rq-action-hover) !important; }
html.dark-style :is(.btn-outline-primary,.btn-outline-secondary,.btn-label-secondary,.btn-secondary,.swal2-cancel) { background: var(--rq-surface-2) !important; color: var(--rq-text) !important; border-color: var(--rq-control-border) !important; }
html.dark-style :is(.btn-outline-primary,.btn-outline-secondary,.btn-label-secondary,.btn-secondary):hover { background: #304157 !important; }
html.dark-style .btn-outline-danger { color: #ffb3bf !important; border-color: #dc7183 !important; }
html.dark-style :is(.btn-danger,.btn-outline-danger:hover,.modern-logout-confirm) { background: #a82c46 !important; color: #fff !important; border-color: #dc7183 !important; }
html.dark-style :is(.btn-success,.btn-warning,.btn-info) { color: #071d22 !important; }
html.dark-style .btn-success { background: #9ae5bd !important; border-color: #9ae5bd !important; }
html.dark-style .btn-warning { background: #ffdb93 !important; border-color: #ffdb93 !important; }
html.dark-style .btn-info { background: #a9d4ff !important; border-color: #a9d4ff !important; }
html.dark-style .btn:disabled { opacity: .65; }

/* Tables: stripes, sticky cells, filtering, paging and empty states. */
html.dark-style .table {
  --bs-table-bg: var(--rq-surface); --bs-table-color: var(--rq-text);
  --bs-table-striped-bg: #1a2534; --bs-table-striped-color: var(--rq-text);
  --bs-table-active-bg: #244143; --bs-table-active-color: var(--rq-text);
  --bs-table-hover-bg: #243448; --bs-table-hover-color: var(--rq-text);
  --bs-table-border-color: var(--rq-border); color: var(--rq-text) !important;
}
html.dark-style .table > :not(caption) > * > * { color: var(--rq-text); border-color: var(--rq-border) !important; }
html.dark-style .table thead th { background: var(--rq-surface-2) !important; color: #d2ddea !important; }
html.dark-style .table :is(.bg-white,.dtfc-fixed-left,.dtfc-fixed-right) { background: var(--rq-surface) !important; }
html.dark-style :is(.dataTables_wrapper,.dt-container) :is(label,.dataTables_info,.dt-info,.dataTables_empty) { color: var(--rq-muted); }
html.dark-style :is(.pagination .page-link,.dt-paging-button) { background: var(--rq-surface-2); color: var(--rq-text); border-color: var(--rq-border); }
html.dark-style .page-item.active .page-link { background: var(--rq-action); color: var(--rq-action-text); border-color: var(--rq-action); }
html.dark-style .page-item.disabled .page-link { background: var(--rq-surface); color: var(--rq-muted); }

/* Feedback and severity retain both labels and distinct color families. */
html.dark-style :is(.alert,.badge,.risk-pill) { border-color: var(--rq-border); }
html.dark-style :is(.alert-primary,.alert-info,.bg-label-primary,.bg-label-info,.bg-info-subtle) { background: #193748 !important; color: #b8dcff !important; }
html.dark-style :is(.alert-success,.bg-label-success,.bg-success-subtle) { background: #183c30 !important; color: #a6ecc8 !important; }
html.dark-style :is(.alert-warning,.bg-label-warning,.bg-warning-subtle) { background: #40331c !important; color: #ffe0a3 !important; }
html.dark-style :is(.alert-danger,.bg-label-danger,.bg-danger-subtle) { background: #452736 !important; color: #ffc2cc !important; }
html.dark-style :is(.alert-secondary,.bg-label-secondary) { background: #283548 !important; color: #d3deed !important; }
html.dark-style .badge:is(.bg-primary,.bg-info,.bg-warning,.bg-success,.bg-danger,.bg-secondary) { color: #0b1420 !important; }
html.dark-style .badge.bg-primary { background: #75dfd1 !important; }
html.dark-style .badge.bg-info { background: #a9d4ff !important; }
html.dark-style .badge.bg-warning { background: #ffdb93 !important; }
html.dark-style .badge.bg-success { background: #9ae5bd !important; }
html.dark-style .badge.bg-danger { background: #ffb3bf !important; }
html.dark-style .badge.bg-secondary { background: #bac9dc !important; }
html.dark-style .risk-critical { --risk-color: #ffb3bf; --risk-rgb: 255,179,191; }
html.dark-style .risk-high { --risk-color: #ffc28d; --risk-rgb: 255,194,141; }
html.dark-style .risk-medium { --risk-color: #ffdf91; --risk-rgb: 255,223,145; }
html.dark-style .risk-low { --risk-color: #9ae5bd; --risk-rgb: 154,229,189; }
html.dark-style :is(.risk-info,.risk-informational) { --risk-color: #a9d4ff; --risk-rgb: 169,212,255; }
html.dark-style .risk-unknown { --risk-color: #c2cede; --risk-rgb: 194,206,222; }
html.dark-style :is(.badge,.risk-pill,.severity-badge,.risk-badge)[class*="risk-"] { color: var(--risk-color) !important; background: rgba(var(--risk-rgb),.12) !important; border: 1px solid rgba(var(--risk-rgb),.35); }
html.dark-style :is(.rq-ai-label,.analysis-source-ai) { color: var(--rq-ai) !important; background: var(--rq-ai-soft) !important; }

/* Floating layers also appear outside the dashboard wrapper. */
html.dark-style :is(.modal-content,.offcanvas,.dropdown-menu,.select2-dropdown,.flatpickr-calendar,.daterangepicker,.swal2-popup,.popover,.tt-menu,.tagify__dropdown) { background: var(--rq-surface) !important; color: var(--rq-text) !important; border: 1px solid var(--rq-border); box-shadow: 0 16px 48px #0007; }
html.dark-style :is(.modal-header,.modal-footer,.offcanvas-header,.dropdown-divider,.popover-header) { border-color: var(--rq-border); }
html.dark-style :is(.modal-title,.swal2-title,.swal2-html-container,.modern-logout-title,.modern-logout-content,.popover-body) { color: var(--rq-text) !important; }
html.dark-style :is(.dropdown-item,.select2-results__option,.select2-selection__rendered,.select2-selection__placeholder,.select2-search__field,.flatpickr-day,.flatpickr-current-month,.flatpickr-weekday,.daterangepicker td,.daterangepicker th) { color: var(--rq-text) !important; }
html.dark-style :is(.dropdown-item:hover,.dropdown-item:focus,.select2-results__option--highlighted,.flatpickr-day:hover) { background: var(--rq-surface-2) !important; color: var(--rq-text) !important; }
html.dark-style :is(.dropdown-item.active,.select2-results__option[aria-selected=true],.flatpickr-day.selected,.daterangepicker td.active) { background: var(--rq-action-soft) !important; color: var(--rq-action) !important; }
html.dark-style :is(.daterangepicker .calendar-table,.daterangepicker td.off,.flatpickr-months .flatpickr-month) { background: var(--rq-surface) !important; }
html.dark-style :is(.nav-tabs,.accordion-button,.accordion-body) { border-color: var(--rq-border); }
html.dark-style .accordion-button { background: var(--rq-surface); color: var(--rq-text); }
html.dark-style .accordion-button:not(.collapsed) { background: var(--rq-surface-2); color: var(--rq-action); }
html.dark-style .nav-tabs .nav-link { color: var(--rq-muted); }
html.dark-style .nav-tabs .nav-link.active { background: var(--rq-surface-2); color: var(--rq-action); border-color: var(--rq-border); }

/* Findings, raw evidence and charts: legible support text without changing evidence. */
html.dark-style :is(pre,code,kbd,.code-snippet,.scan-detail-evidence,.raw-output,.evidence-panel) { color: #d6e8f8; background-color: #101925; border-color: var(--rq-border); }
html.dark-style pre { padding: 1rem; border-radius: 8px; }
html.dark-style :is(.summary-section-body,.scan-list-summary-teaser,.scan-detail-hud__meta,.scan-detail-evidence__note,.threat-lens-muted,.threat-lens-footnote,.threat-lens-panel-module,.module-stat-metric__label,.module-stat-group__label,.scan-card-primary__label) { color: var(--rq-muted) !important; }
html.dark-style :is(.scan-card,.scan-detail-hud,.scan-detail-evidence,.threat-lens-panel,.threat-lens-section,.rq-overview-card) { background: var(--rq-surface); color: var(--rq-text); border-color: var(--rq-border); }
html.dark-style :is(.module-stat-chip,.module-stat-hero,.module-stat-metric,.module-stat-group,.scan-icon-box,.scan-detail-evidence__header) { background: var(--rq-surface-2); border-color: var(--rq-border); }
html.dark-style :is(.apexcharts-tooltip,.apexcharts-menu,.apexcharts-xaxistooltip,.apexcharts-yaxistooltip) { background: var(--rq-surface) !important; color: var(--rq-text) !important; border-color: var(--rq-border) !important; }
html.dark-style .apexcharts-tooltip-title { background: var(--rq-surface-2) !important; color: var(--rq-text); border-color: var(--rq-border) !important; }
html.dark-style .apexcharts-legend-text { color: var(--rq-muted) !important; }
html.dark-style :is(.apexcharts-xaxis-texts-g,.apexcharts-yaxis-texts-g,.apexcharts-yaxis-title,.apexcharts-xaxis-title) text { fill: var(--rq-muted) !important; }
html.dark-style .apexcharts-gridline { stroke: var(--rq-border); }

/* Authentication keeps original logos and scannable, white QR backing. */
html.dark-style .authentication-wrapper .card { border: 1px solid var(--rq-border); box-shadow: 0 20px 60px #0003; }
html.dark-style .authentication-wrapper .rq-auth__logo { background: #fff; border-radius: 10px; padding: 10px; box-sizing: content-box; max-width: calc(100% - 20px); }
html.dark-style :is(.mfa-qr-frame,.vendor-mfa-qr) { background: #fff !important; color: #111 !important; }
html.dark-style .mfa-step-text { color: var(--rq-muted); }
html.dark-style .mfa-step-num { background: var(--rq-action); color: var(--rq-action-text); }
html.dark-style ::selection { background: #28625d; color: #fff; }
@media (forced-colors: active) {
  html.dark-style :is(.card,.btn,.form-control,.form-select,.badge) { border: 1px solid CanvasText !important; }
  html.dark-style :focus-visible { outline-color: Highlight !important; }
}
/* Older scanner modules use their own cards and terminal chrome. */
html.dark-style :is(.nmap-card,.nmap-advice-card,.ssl-details-section,.dns-details-section,.cl-repo-card,.dw-source-chip,.dr-stat-card) { background: var(--rq-surface) !important; color: var(--rq-text); border-color: var(--rq-border); }
html.dark-style :is(.nmap-terminal-header,.dns-terminal-header,.cl-terminal-header,.dw-breach-banner,.dw-risk-box,.cl-risk-box,.dr-verdict-banner,.dr-stat-card.suspicious) { background: var(--rq-surface-2) !important; color: var(--rq-text); border-color: var(--rq-border); }
html.dark-style :is(.nmap-dt-label,.ssl-dt-label,.dns-dt-label,.cl-dt-label,.dw-dt-label,.dr-dt-label) { color: var(--rq-muted); background: var(--rq-surface-2); }
html.dark-style .nmap-vuln-badge.vuln-high { color: #ffc28d; background: #453121; }
/* Activity history uses an ID selector and is shared by three admin modules. */
html.dark-style #activity-table thead th { background: var(--rq-surface-2) !important; color: #d2ddea !important; }
html.dark-style #activity-table tbody tr:hover td { background: #243448; }
html.dark-style #activity-table :is(.avatar-initial,.col-label,.change-arrow) { background-color: var(--rq-surface-2); color: var(--rq-muted); }
html.dark-style #activity-table .prev-val { color: #ffb3bf; }
html.dark-style #activity-table .new-val { color: #9ae5bd; }

/* Light-mode contrast corrections found during the paired theme audit. */
html.light-style :is(.rq-shell,.authentication-wrapper) .text-muted,
html.light-style :is(.threat-lens-muted,.threat-lens-driver-module,.cl-section-title,.cl-repo-label,.cl-detail-label,.cl-url-label,.dw-section-label,.dw-details-table th,.dr-verdict-label,.dr-section-title,.dr-stat-sub,.dr-vendor-empty,.nmap-section-label) { color: #4d6076 !important; }
html.light-style :is(.badge.bg-success,.btn-success) { background: #147a46 !important; color: #fff !important; }
html.light-style :is(.badge.bg-secondary,.btn-secondary) { background: #566479 !important; color: #fff !important; }
html.light-style .badge.bg-primary { background: #6350ce !important; color: #fff !important; }
html.light-style :is(.btn-warning,.badge.bg-warning) { color: #3d2605 !important; }
html.light-style :is(.rq-shell,.authentication-wrapper) .btn-link { color: #096b83 !important; }
html.light-style .text-warning { color: #86520b !important; }
html.light-style :is(.badge,.risk-pill).risk-high { background: #98440d !important; color: #fff !important; }
html.light-style :is(.dr-verdict-text,.dr-stat-card.harmless .dr-stat-label) { color: #147a46; }
html.light-style .dr-stat-card.suspicious .dr-stat-label { color: #9a4210; }
html.light-style .dr-stat-card.malicious .dr-stat-label { color: #b92f3b; }
html.light-style .dw-table th { color: #4d6076 !important; }
html.light-style .dr-verdict-label { opacity: 1; }
html.light-style .assessment-tab-btn.active { color: #096b83 !important; }
html.light-style body .rq-shell .content-wrapper .text-muted { color: #4d6076 !important; }
html.light-style body .rq-shell .content-wrapper .text-warning { color: #86520b !important; }
/* Assessment-specific tokens must also follow the shared dark palette. */
html.dark-style .rq-shell .assessment-details-page {
  --ad-navy: var(--rq-text); --ad-blue: var(--rq-action); --ad-muted: var(--rq-muted);
  --ad-surface: var(--rq-surface); --ad-border: var(--rq-border);
}
html.dark-style .rq-shell :is(.assessment-hero,.assessment-tabs-shell,.ad-panel) { background: var(--rq-surface) !important; }
html.dark-style .rq-shell :is(.assessment-stat-tile,.assessment-hero-meter-panel,.assessment-hero-sev-cell,.assessment-tab-nav,.ad-panel-intro) { background: var(--rq-surface-2) !important; }
html.dark-style .rq-shell :is(.assessment-stat-tile-label,.assessment-stat-tile-hint,.assessment-tab-btn,.assessment-hero-eyebrow,.assessment-meta-pill) { color: var(--rq-muted) !important; }
html.dark-style .rq-shell .assessment-tab-btn.active { color: var(--rq-action) !important; background: var(--rq-action-soft) !important; }
html.light-style .rq-shell .assessment-tab-btn.active { color: #096b83 !important; }
/* Step-up verification uses an independent dialog, outside Bootstrap controls. */
html.dark-style #mfaModal .dw-input { background: #101925 !important; color: var(--rq-text) !important; border-color: var(--rq-control-border) !important; }
html.dark-style #mfaModal .dw-input:focus { border-color: var(--rq-action) !important; }
html.dark-style #mfaModal .dw-error { color: #ffb3bf !important; }
html.dark-style #mfaModal .dw-btn-confirm { background: var(--rq-action) !important; color: var(--rq-action-text) !important; }
html.dark-style #mfaModal .dw-btn-cancel:hover { background: #304157 !important; }
html.dark-style .modern-logout-confirm:hover { background: #92223b !important; }
html.dark-style .modern-logout-cancel { background: var(--rq-surface-2) !important; color: var(--rq-text) !important; border: 1px solid var(--rq-control-border) !important; }

html.dark-style :is(#mfaModal,.dw-modal) .dw-btn-confirm { background: var(--rq-action) !important; color: var(--rq-action-text) !important; }
html.dark-style :is(#mfaModal,.dw-modal) .dw-btn-confirm:hover { background: var(--rq-action-hover) !important; }
html.light-style #mfaModal .dw-input::placeholder { color: #4d6076; opacity: 1; }
html.light-style .btn-label-secondary { color: #46576d !important; background: #e9eef4 !important; }
