/* Portal-specific report, account and submission surfaces. The light styles live with each view. */
html[data-theme="dark"] {
    --rb-report-blue: #71b7ee;
    --rb-report-indigo: #aa9bf5;
    --rb-report-pale-blue: #91dce2;
    --rb-report-orange: #ffb66d;
    --rb-report-red: #ff837d;
}

/* Keep the login photograph and Red Bull mark in their original colours. */
html[data-theme="dark"] #bg::before {
    background-color: rgb(8 16 30 / 40%);
    mix-blend-mode: normal;
}
html[data-theme="dark"] .glass {
    background: rgb(16 27 43 / 90%);
    color: var(--rb-text);
}
html[data-theme="dark"] .glass :is(h1, .lucide-circle-check-big-icon) {
    color: var(--rb-accent) !important;
}

/* The customer dashboard supplies a later, light-only card stylesheet in the view. */
html[data-theme="dark"] .container2 .card {
    background: var(--rb-surface) !important;
}
html[data-theme="dark"] .container2 :is(.card-header, .card-footer) {
    color: var(--rb-text) !important;
}
html[data-theme="dark"] .container2 :is(.card-header, .card-footer) .lucide-icon,
html[data-theme="dark"] .container2 :is(.footer-left, .footer-right) {
    color: var(--rb-muted) !important;
}
html[data-theme="dark"] :is(.user-info-card, .stat-item, .user-message-block, .submit-rate-block, #userMessage, .privacy-notice),
html[data-theme="dark"] :is(.market-share-card, .chart-container, .quick-stat, .anomaly-card, .anomaly-card-sparkline-container) {
    background: var(--rb-surface);
    border-color: var(--rb-border);
    color: var(--rb-text);
}
html[data-theme="dark"] :is(.user-detail, .user-info-compact, .stat-compact, .explanation-content, .anomaly-card-sparkline, .anomaly-card-severity-score) {
    background: var(--rb-surface-raised);
    border-color: var(--rb-border);
    color: var(--rb-text);
}
html[data-theme="dark"] :is(.user-detail-value, .user-name, .stat-value-compact, .stat-value, .anomaly-card-title, .anomaly-card-impact, .anomaly-card-description, .anomaly-card-stat-value, .explanation-content strong),
html[data-theme="dark"] :is(#userMessage, .submit-rate-block, .user-message-block) .alert,
html[data-theme="dark"] :is(.additional-filters, .filter-form) .form-label {
    color: var(--rb-text);
}
html[data-theme="dark"] :is(.user-detail-label, .user-email, .stat-label, .stat-icon-compact, .stat-label-compact, .stat-icon, .privacy-notice .privacy-text, .quick-stat-label, .helper-text, .loading-placeholder, .anomaly-card-subtitle, .anomaly-card-date, .anomaly-card-stats, .anomaly-card-stat-label, .anomaly-card-sparkline-header) {
    color: var(--rb-muted);
}
html[data-theme="dark"] :is(.privacy-notice a, .lucide-icon.blue) { color: var(--rb-link); }
html[data-theme="dark"] :is(.normal-value, .trend-up, .lucide-icon.green) { color: var(--rb-positive); }
html[data-theme="dark"] :is(.anomaly-flag, .trend-down, .lucide-icon.red) { color: var(--rb-negative); }
html[data-theme="dark"] .lucide-icon.orange { color: var(--rb-warning); }
html[data-theme="dark"] :is(.trend-neutral, .lucide-icon.grey) { color: var(--rb-muted); }
html[data-theme="dark"] :is(.trend-up, .trend-down, .trend-neutral) { opacity: 1; }
html[data-theme="dark"] :is(.additional-filters, .method-toggle, .anomaly-card-footer) { border-color: var(--rb-border); }
html[data-theme="dark"] :is(.quick-stat-number, .anomaly-card-analyze-link) { color: var(--rb-accent); }
html[data-theme="dark"] .anomaly-card-analyze-link { border-color: var(--rb-accent); }
html[data-theme="dark"] :is(.anomaly-card-analyze-link:hover, .method-toggle.active, .anomaly-card-ranking) {
    color: var(--rb-bg);
    background: var(--rb-accent);
    border-color: var(--rb-accent);
}
html[data-theme="dark"] .method-toggle:not(.active):hover { background: var(--rb-surface-raised); }
html[data-theme="dark"] .explanation-content { border-left-color: var(--rb-link); }
html[data-theme="dark"] .anomaly-card-method-badge {
    color: var(--rb-muted);
    background: var(--rb-surface-raised);
    border-color: var(--rb-border);
}
html[data-theme="dark"] .anomaly-card-method-badge.primary {
    color: var(--rb-link);
    border-color: var(--rb-link);
}
html[data-theme="dark"] :is(.severity-badge.low, .severity-badge.medium, .anomaly-card-severity.high, .anomaly-card-severity.medium, .anomaly-card-severity.low) {
    color: #101820;
}
html[data-theme="dark"] .heatmap-cell { border-color: var(--rb-border); }
html[data-theme="dark"] .heatmap-cell.normal { background: var(--rb-surface); }
html[data-theme="dark"] .heatmap-cell.anomaly-1 { background: #564324; }
html[data-theme="dark"] .heatmap-cell.anomaly-2 { background: #77512b; }
html[data-theme="dark"] .heatmap-cell.anomaly-3 { background: #a96139; color: #fff; }
html[data-theme="dark"] .heatmap-cell.anomaly-4 { background: #ca6c56; color: #101820; }
html[data-theme="dark"] .heatmap-cell.anomaly-5 { background: #ff877d; color: #101820; }
html[data-theme="dark"] :is(.loading-skeleton, .card.load .placeholder) {
    background-image: linear-gradient(90deg, var(--rb-surface) 25%, var(--rb-surface-raised) 50%, var(--rb-surface) 75%);
}
html[data-theme="dark"] .loader {
    border-color: var(--rb-border);
    border-top-color: var(--rb-warning);
}

/* Sticky headers stay opaque as report rows pass underneath them. */
html[data-theme="dark"] .table :is(thead, .pivot-total-row) th,
html[data-theme="dark"] .table .group-header td {
    color: var(--rb-text);
    border-color: var(--rb-border) !important;
    background: var(--rb-surface-raised) !important;
}
html[data-theme="dark"] .reach-message-group {
    --reach-surface: var(--rb-surface-raised);
    --reach-border: var(--rb-border);
    --reach-ink: var(--rb-muted);
}
html[data-theme="dark"] .reach-message-group[data-tone="success"] { --reach-ink: var(--rb-positive); }
html[data-theme="dark"] .reach-message-group[data-tone="info"] { --reach-ink: var(--rb-link); }
html[data-theme="dark"] .reach-message-group[data-tone="danger"] { --reach-ink: var(--rb-negative); }
html[data-theme="dark"] .reach-message-group[data-tone="warning"] { --reach-ink: var(--rb-warning); }
html[data-theme="dark"] .reach-message-group .progress { background-color: var(--rb-border) !important; }
html[data-theme="dark"] .reach-message-group .badge:not(.bg-light) {
    background-color: var(--reach-ink) !important;
    color: var(--rb-bg) !important;
}

html[data-theme="dark"] .submission-month-control.is-enhanced .form-control {
    background-color: var(--rb-surface);
}
html[data-theme="dark"] .submission-month-control.is-enhanced .submission-month-icon {
    color: var(--rb-muted);
}
html[data-theme="dark"] .submission-month-calendar.flatpickr-calendar {
    border-color: var(--rb-border);
}
html[data-theme="dark"] .submission-month-calendar :is(.flatpickr-prev-month:hover, .flatpickr-next-month:hover, .flatpickr-monthSelect-month:hover, .flatpickr-monthSelect-month:focus) {
    background: var(--rb-surface-raised);
    border-color: var(--rb-border);
}
html[data-theme="dark"] .submission-month-calendar .flatpickr-monthSelect-month.flatpickr-disabled {
    background: var(--rb-bg);
    color: var(--rb-muted);
    opacity: .6;
}
html[data-theme="dark"] .submission-month-calendar :focus-visible { outline-color: var(--rb-link); }

/* Highcharts emits SVG presentation attributes and inline text styles. CSS also
   updates charts already on screen, including their hover and hidden states. */
html[data-theme="dark"] .highcharts-background { fill: var(--rb-surface); }
html[data-theme="dark"] :is(.highcharts-title, .highcharts-legend-item text, .highcharts-data-label text, .highcharts-stack-labels text) {
    fill: var(--rb-text) !important;
}
html[data-theme="dark"] :is(.highcharts-axis-labels text, .highcharts-axis-title, .highcharts-subtitle, .highcharts-credits) {
    fill: var(--rb-muted) !important;
}
html[data-theme="dark"] .highcharts-legend-item-hidden text {
    fill: var(--rb-muted) !important;
    opacity: .65;
}
html[data-theme="dark"] .highcharts-text-outline { stroke: var(--rb-surface); }
html[data-theme="dark"] :is(.highcharts-grid-line, .highcharts-axis-line, .highcharts-tick) { stroke: var(--rb-grid); }
html[data-theme="dark"] :is(.highcharts-button-box, .highcharts-tooltip-box) {
    fill: var(--rb-surface-raised);
    stroke: var(--rb-border);
}
html[data-theme="dark"] .highcharts-button-symbol { stroke: var(--rb-muted); }
html[data-theme="dark"] .highcharts-contextmenu :is(.highcharts-menu, .highcharts-menu-item) {
    background: var(--rb-surface-raised) !important;
    color: var(--rb-text) !important;
    border-color: var(--rb-border) !important;
}
html[data-theme="dark"] .highcharts-contextmenu .highcharts-menu-item:hover { background: var(--rb-bg) !important; }
html[data-theme="dark"] .highcharts-tooltip text {
    fill: var(--rb-text) !important;
}
html[data-theme="dark"] .highcharts-pie-series .highcharts-point,
html[data-theme="dark"] .highcharts-heatmap-series .highcharts-point { stroke: var(--rb-surface); }
