/* =========================================================
   Reports Portal - Modern Dark Theme
   ========================================================= */

:root {
    --portal-bg: #0a0a0f;
    --portal-surface: #12121a;
    --portal-elevated: #1a1a2e;
    --portal-border: rgba(255,255,255,0.06);
    --portal-border-hover: rgba(255,255,255,0.12);
    --portal-text: #e0e0e8;
    --portal-text-muted: #8a8a9a;
    --portal-accent: #0db1e7;
    --portal-accent-dim: rgba(13,177,231,0.15);
    --portal-accent-glow: rgba(13,177,231,0.3);
    --portal-success: #2dd4a8;
    --portal-warning: #f0b429;
    --portal-danger: #ef4444;
    --portal-radius: 12px;
    --portal-radius-sm: 8px;
    --portal-transition: 0.2s ease;
}

/* --- Base --- */

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--portal-bg);
    color: var(--portal-text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    margin: 0;
}

a {
    color: var(--portal-accent);
    text-decoration: none;
    transition: color var(--portal-transition);
}

a:hover {
    color: #3ecbf5;
}

/* --- Navbar --- */

.portal-navbar {
    background: rgba(10, 10, 15, 0.82);
    backdrop-filter: blur(20px) saturate(1.2);
    -webkit-backdrop-filter: blur(20px) saturate(1.2);
    border-bottom: 1px solid var(--portal-border);
    padding: 0.5rem 0;
    z-index: 1030;
}

.portal-navbar .navbar-brand {
    color: var(--portal-text);
    gap: 0;
}

.portal-navbar .brand-separator {
    width: 1px;
    height: 20px;
    background: var(--portal-border-hover);
    margin: 0 0.75rem;
}

.portal-navbar .brand-text {
    color: var(--portal-accent);
    font-weight: 400;
    font-size: 0.85rem;
    letter-spacing: 0.12em;
    text-transform: lowercase !important;
}

.portal-navbar .nav-link {
    color: var(--portal-text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.4rem 0.65rem;
    border-radius: 6px;
    transition: all var(--portal-transition);
}

.portal-navbar .nav-link:hover,
.portal-navbar .nav-link.active {
    color: var(--portal-text);
    background: rgba(255,255,255,0.05);
}

.user-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--portal-elevated);
    color: var(--portal-text);
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.3rem 0.75rem;
    border-radius: 20px;
    border: 1px solid var(--portal-border);
}

.user-pill .company-label {
    color: var(--portal-text-muted);
    font-size: 0.72rem;
    padding-left: 0.5rem;
    border-left: 1px solid var(--portal-border);
}

/* --- Content Area --- */

.portal-content {
    padding-top: 72px;
    min-height: calc(100vh - 50px);
    max-width: 1280px;
    margin: 0 auto;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
    padding-bottom: 3rem;
}

/* --- Footer --- */

.portal-footer {
    border-top: 1px solid var(--portal-border);
    padding: 1.25rem 0;
    color: var(--portal-text-muted);
    font-size: 0.75rem;
}

/* --- Cards --- */

.portal-card {
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius);
    padding: 1.5rem;
    transition: border-color var(--portal-transition), box-shadow var(--portal-transition);
}

.portal-card:hover {
    border-color: var(--portal-border-hover);
}

.portal-card-elevated {
    background: var(--portal-elevated);
    backdrop-filter: blur(8px);
}

/* --- Page Headers --- */

.page-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--portal-border);
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.page-header .subtitle {
    color: var(--portal-text-muted);
    font-size: 0.9rem;
}

/* --- Tables --- */

.portal-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.portal-table thead th {
    background: var(--portal-elevated);
    color: var(--portal-text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--portal-border);
    white-space: nowrap;
}

.portal-table thead th:first-child {
    border-radius: var(--portal-radius-sm) 0 0 0;
}

.portal-table thead th:last-child {
    border-radius: 0 var(--portal-radius-sm) 0 0;
}

.portal-table tbody td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--portal-border);
    vertical-align: middle;
    font-size: 0.875rem;
}

.portal-table tbody tr {
    transition: background var(--portal-transition);
}

.portal-table tbody tr:hover {
    background: rgba(255,255,255,0.02);
}

.portal-table tbody tr:last-child td {
    border-bottom: none;
}

/* --- Badges / Pills --- */

.portal-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    letter-spacing: 0.03em;
}

.portal-badge-accent {
    background: var(--portal-accent-dim);
    color: var(--portal-accent);
}

.portal-badge-muted {
    background: rgba(255,255,255,0.06);
    color: var(--portal-text-muted);
}

/* --- Buttons --- */

.btn-portal {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: var(--portal-radius-sm);
    border: 1px solid var(--portal-border);
    background: var(--portal-elevated);
    color: var(--portal-text);
    transition: all var(--portal-transition);
    cursor: pointer;
    text-decoration: none;
}

.btn-portal:hover {
    background: rgba(255,255,255,0.08);
    border-color: var(--portal-border-hover);
    color: var(--portal-text);
}

.btn-portal-primary {
    background: var(--portal-accent);
    border-color: var(--portal-accent);
    color: #fff;
}

.btn-portal-primary:hover {
    background: #0ca0d3;
    border-color: #0ca0d3;
    color: #fff;
    box-shadow: 0 0 20px var(--portal-accent-glow);
}

/* --- Login Page --- */

.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--portal-bg);
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(13,177,231,0.04) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 20%, rgba(13,177,231,0.03) 0%, transparent 50%);
}

.login-card {
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    backdrop-filter: blur(12px);
}

.login-card .logo {
    display: block;
    max-height: 44px;
    margin: 0 auto 1rem;
}

.login-card h1 {
    font-size: 1.15rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 1.75rem;
    color: var(--portal-text);
}

.login-card h1 span {
    color: var(--portal-accent);
}

.login-card .form-control {
    background: var(--portal-bg);
    border: 1px solid var(--portal-border);
    color: var(--portal-text);
    border-radius: var(--portal-radius-sm);
    padding: 0.65rem 0.85rem;
    font-size: 0.875rem;
    transition: border-color var(--portal-transition), box-shadow var(--portal-transition);
}

.login-card .form-control:focus {
    background: var(--portal-bg);
    border-color: var(--portal-accent);
    box-shadow: 0 0 0 3px var(--portal-accent-dim);
    color: var(--portal-text);
}

.login-card .form-control::placeholder {
    color: var(--portal-text-muted);
}

.login-card .form-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--portal-text-muted);
    margin-bottom: 0.35rem;
}

/* --- Dashboard --- */

.portal-beta-notice {
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-left: 3px solid var(--portal-accent);
    border-radius: var(--portal-radius-sm);
    padding: 1rem 1.25rem;
    margin-bottom: 2rem;
    font-size: 0.85rem;
    color: var(--portal-text-muted);
    line-height: 1.6;
}

.portal-beta-notice strong {
    color: var(--portal-text);
}

.dash-section-title {
    color: var(--portal-text);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--portal-border);
}

.other-tests-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.75rem;
}

.other-test-card {
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius-sm);
    padding: 0.85rem 1rem;
    opacity: 0.7;
    transition: opacity var(--portal-transition);
}

.other-test-card:hover {
    opacity: 1;
}

.other-test-title {
    color: var(--portal-text);
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.35rem;
}

.other-test-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.72rem;
    color: var(--portal-text-muted);
}

.other-test-title a {
    color: var(--portal-text);
    text-decoration: none;
    transition: color var(--portal-transition);
}

.other-test-title a:hover {
    color: var(--portal-accent);
}

.other-test-title a .fa-external-link-alt {
    opacity: 0.4;
    transition: opacity var(--portal-transition);
}

.other-test-title a:hover .fa-external-link-alt {
    opacity: 1;
}

.other-test-meta span {
    background: var(--portal-elevated);
    padding: 1px 8px;
    border-radius: 4px;
}

.other-test-brand-tyres {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--portal-success);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}

.other-test-brand-tyres span {
    background: rgba(45, 212, 168, 0.1);
    padding: 1px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.report-card {
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius);
    padding: 1.25rem 1.5rem;
    transition: all var(--portal-transition);
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.report-card:hover {
    border-color: var(--portal-accent);
    box-shadow: 0 0 24px rgba(13,177,231,0.06);
    transform: translateY(-1px);
}

.report-card .report-info {
    flex: 1;
    min-width: 0;
}

.report-card .report-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--portal-text);
}

.report-card .report-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    color: var(--portal-text-muted);
    font-size: 0.8rem;
}

.report-card .report-meta i {
    width: 14px;
    text-align: center;
    margin-right: 0.15rem;
}

.report-card .report-actions {
    flex-shrink: 0;
}

/* --- Profile Page --- */

.profile-field {
    display: flex;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--portal-border);
}

.profile-field:last-child {
    border-bottom: none;
}

.profile-field .field-label {
    width: 140px;
    flex-shrink: 0;
    color: var(--portal-text-muted);
    font-size: 0.82rem;
    font-weight: 500;
}

.profile-field .field-value {
    font-size: 0.9rem;
}

/* --- Breadcrumbs --- */

.portal-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--portal-text-muted);
    margin-bottom: 1.25rem;
}

.portal-breadcrumb a {
    color: var(--portal-text-muted);
}

.portal-breadcrumb a:hover {
    color: var(--portal-accent);
}

.portal-breadcrumb .sep {
    opacity: 0.4;
}

/* --- Error Page --- */

.error-code {
    font-size: 5rem;
    font-weight: 700;
    color: var(--portal-accent);
    line-height: 1;
    margin-bottom: 0.5rem;
    opacity: 0.7;
}

.error-message {
    font-size: 1.1rem;
    color: var(--portal-text-muted);
}

/* --- Alerts --- */

.portal-alert {
    padding: 0.75rem 1rem;
    border-radius: var(--portal-radius-sm);
    font-size: 0.85rem;
    margin-bottom: 1rem;
    border: 1px solid;
}

.portal-alert-danger {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

.portal-alert-success {
    background: rgba(45, 212, 168, 0.08);
    border-color: rgba(45, 212, 168, 0.2);
    color: #86efcb;
}

.portal-alert-info {
    background: var(--portal-accent-dim);
    border-color: rgba(13, 177, 231, 0.2);
    color: #7dd3f5;
}

/* --- Tyre selector (portal header, replaces in-report tyre navigation) --- */

.tyre-selector {
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius-sm);
    padding: 0.75rem 1rem;
    margin-bottom: 1.5rem;
}

.tyre-selector-label {
    font-size: 0.78rem;
    color: var(--portal-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 500;
}

.tyre-selector-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.tyre-selector-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.65rem;
    font-size: 0.78rem;
    color: var(--portal-text);
    background: var(--portal-elevated);
    border: 1px solid var(--portal-border);
    border-radius: 5px;
    text-decoration: none;
    transition: all var(--portal-transition);
    white-space: nowrap;
}

.tyre-selector-item:hover {
    background: var(--portal-accent-dim);
    border-color: var(--portal-accent);
    color: var(--portal-accent);
}

.tyre-selector-item.is-reference {
    border-color: rgba(240, 180, 41, 0.3);
}

.tyre-selector-pos {
    font-weight: 700;
    color: var(--portal-accent);
    font-size: 0.72rem;
}

.tyre-selector-ref {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--portal-warning);
    background: rgba(240, 180, 41, 0.15);
    padding: 1px 5px;
    border-radius: 3px;
}

/* --- Report Display Overrides ---
   Comprehensive styling for test report HTML from test_report_display.php.
   Must override Bootstrap defaults and inline styles from the report generator.
*/

.report-container {
    color: var(--portal-text);
}

/* --- Global text color resets --- */

.report-container .text-muted {
    color: var(--portal-text-muted) !important;
}

.report-container h1, .report-container h2, .report-container h3,
.report-container h4, .report-container h5, .report-container h6 {
    color: var(--portal-text);
}

.report-container strong {
    color: var(--portal-text);
}

.report-container a {
    color: var(--portal-accent);
}

/* --- Report header --- */

.report-container .report-header {
    background: var(--portal-surface);
    border-radius: var(--portal-radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.report-container .test-title {
    color: var(--portal-text) !important;
    font-weight: 700;
}

/* --- Section headers & numbering --- */

.report-container .section-header {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--portal-text) !important;
    margin-bottom: 1rem;
    margin-top: 2rem;
}

.report-container .section-number {
    display: inline-block;
    background: var(--portal-accent) !important;
    color: #000 !important;
    font-weight: 800;
    padding: 3px 12px;
    border-radius: 6px;
    margin-right: 10px;
    font-size: 1.2rem;
}

.report-container .subsection-header {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--portal-text) !important;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--portal-accent) !important;
}

.report-container .subsection-number {
    display: inline-block;
    background: var(--portal-accent) !important;
    color: #000 !important;
    font-weight: 800;
    padding: 2px 10px;
    border-radius: 6px;
    margin-right: 10px;
    font-size: 1.1rem;
}

.report-container .section-divider {
    border-color: var(--portal-border) !important;
    opacity: 0.5;
    margin: 2rem 0;
}

/* --- All tables (Bootstrap overrides) --- */

.report-container .table {
    --bs-table-bg: transparent !important;
    --bs-table-color: var(--portal-text) !important;
    --bs-table-border-color: var(--portal-border) !important;
    --bs-table-striped-bg: rgba(255,255,255,0.02) !important;
    --bs-table-hover-bg: rgba(255,255,255,0.03) !important;
    --bs-table-active-bg: rgba(255,255,255,0.04) !important;
    color: var(--portal-text) !important;
    border-color: var(--portal-border) !important;
    background: transparent !important;
    margin-bottom: 1rem;
}

.report-container .table-dark {
    --bs-table-bg: transparent !important;
    --bs-table-color: var(--portal-text) !important;
    --bs-table-border-color: var(--portal-border) !important;
    --bs-table-hover-bg: rgba(255,255,255,0.03) !important;
    --bs-table-striped-bg: rgba(255,255,255,0.02) !important;
    background: transparent !important;
}

.report-container .table > thead {
    border-bottom: 2px solid rgba(13, 177, 231, 0.3) !important;
}

.report-container .table > thead > tr > th,
.report-container .table-dark > thead > tr > th {
    background: var(--portal-elevated) !important;
    color: var(--portal-text-muted) !important;
    border-color: var(--portal-border) !important;
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.65rem 0.75rem;
    white-space: nowrap;
}

.report-container .table > tbody > tr > td,
.report-container .table-dark > tbody > tr > td {
    background: transparent !important;
    color: var(--portal-text) !important;
    border-color: var(--portal-border) !important;
    padding: 0.55rem 0.75rem;
    vertical-align: middle;
}

.report-container .table > tbody > tr:hover > td {
    background: rgba(255,255,255,0.02) !important;
}

/* Rounded corners on table wrappers */
.report-container .table-responsive {
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius-sm);
    overflow: hidden;
}

.report-container .table-responsive > .table {
    margin-bottom: 0;
}

/* report-table specific */
.report-container .report-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.85rem;
}

.report-container .report-table th {
    background: var(--portal-elevated) !important;
    color: var(--portal-text-muted) !important;
    border-color: var(--portal-border) !important;
}

.report-container .report-table td {
    border-color: var(--portal-border) !important;
    background: transparent !important;
}

/* Summary table (width: auto) */
.report-container .table[style*="width: auto"] {
    border-radius: var(--portal-radius-sm);
    overflow: hidden;
}

.report-container .table[style*="width: auto"] th {
    background: var(--portal-elevated) !important;
    color: var(--portal-text-muted) !important;
    padding: 0.5rem 1rem;
}

.report-container .table[style*="width: auto"] td {
    padding: 0.5rem 1rem;
}

/* --- Reference rows --- */

.report-container .reference-row td,
.report-container .reference-row > td {
    background: var(--portal-accent-dim) !important;
    font-weight: 600;
}

/* --- Mono values --- */

.report-container .mono-value {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.82rem;
}

/* --- Stats card (raw data sections) --- */

.report-container .stats-card {
    background: var(--portal-surface) !important;
    border: 1px solid var(--portal-border) !important;
    border-radius: var(--portal-radius) !important;
    padding: 1.25rem !important;
    margin-bottom: 1.25rem !important;
}

.report-container .stats-card hr {
    border-color: var(--portal-border) !important;
    opacity: 0.5;
}

/* --- Session header rows --- */

.report-container .session-header-row td {
    background: var(--portal-elevated) !important;
    border-top: 2px solid var(--portal-accent) !important;
    padding: 8px 12px !important;
    color: var(--portal-text) !important;
}

/* --- Value cells (individual measurements) --- */

.report-container .value-cell {
    border-color: var(--portal-border) !important;
    background: transparent !important;
    color: var(--portal-text) !important;
}

.report-container .value-cell.outlier {
    background-color: rgba(220, 53, 69, 0.15) !important;
}

/* --- Control run styling --- */

.report-container .control-run-value {
    background-color: rgba(13, 177, 231, 0.15) !important;
    border-radius: 3px;
    padding: 2px 6px;
}

/* --- Evolution badge --- */

.report-container .evolution-badge {
    background-color: var(--portal-success) !important;
    color: #000 !important;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.85em;
}

/* --- Cards (Bootstrap overrides) --- */

.report-container .card {
    background: var(--portal-surface) !important;
    border: 1px solid var(--portal-border) !important;
    border-radius: var(--portal-radius-sm) !important;
    color: var(--portal-text) !important;
}

.report-container .card-header {
    border-bottom: 1px solid var(--portal-border) !important;
    padding: 0.75rem 1rem;
}

.report-container .card-header.bg-success {
    background: rgba(45, 212, 168, 0.15) !important;
    color: var(--portal-success) !important;
    border-bottom-color: rgba(45, 212, 168, 0.2) !important;
}

.report-container .card-header.bg-secondary {
    background: var(--portal-elevated) !important;
    color: var(--portal-text-muted) !important;
}

.report-container .card-header.bg-danger {
    background: rgba(239, 68, 68, 0.15) !important;
    color: var(--portal-danger) !important;
    border-bottom-color: rgba(239, 68, 68, 0.2) !important;
}

.report-container .card-body {
    background: transparent !important;
    color: var(--portal-text) !important;
    padding: 1rem;
}

.report-container .card-title {
    color: var(--portal-text) !important;
}

.report-container .card .text-success {
    color: var(--portal-success) !important;
}

.report-container .card .text-danger {
    color: var(--portal-danger) !important;
}

/* Card variant for borders */
.report-container .card.border-success {
    border-color: rgba(45, 212, 168, 0.3) !important;
}

.report-container .card.border-danger {
    border-color: rgba(239, 68, 68, 0.3) !important;
}

/* --- Test parameters box --- */

.report-container .test-parameters {
    background: var(--portal-surface) !important;
    border: 1px solid var(--portal-border) !important;
    border-radius: var(--portal-radius-sm) !important;
}

.report-container .test-parameters .table {
    color: var(--portal-text) !important;
}

.report-container .test-parameters .table td {
    border: none !important;
    padding: 0.35rem 0.5rem;
    background: transparent !important;
}

/* --- Table of contents --- */

.report-container .report-toc {
    background: var(--portal-surface) !important;
    border: 1px solid var(--portal-border) !important;
    border-radius: var(--portal-radius-sm) !important;
}

.report-container .report-toc a {
    color: var(--portal-text-muted) !important;
    transition: color var(--portal-transition);
}

.report-container .report-toc a:hover {
    color: var(--portal-accent) !important;
}

/* --- Badges --- */

.report-container .badge {
    font-weight: 500;
}

.report-container .badge.bg-primary {
    background: var(--portal-accent) !important;
    color: #000 !important;
}

.report-container .badge.bg-secondary {
    background: var(--portal-elevated) !important;
    color: var(--portal-text-muted) !important;
}

.report-container .badge.bg-info {
    background: rgba(13, 177, 231, 0.2) !important;
    color: var(--portal-accent) !important;
}

.report-container .badge.bg-dark {
    background: var(--portal-elevated) !important;
    color: var(--portal-text-muted) !important;
}

.report-container .badge.bg-warning {
    background: rgba(240, 180, 41, 0.2) !important;
    color: var(--portal-warning) !important;
}

/* --- Buttons --- */

.report-container .btn-outline-primary {
    color: var(--portal-accent) !important;
    border-color: var(--portal-accent) !important;
    background: transparent !important;
}

.report-container .btn-outline-primary:hover {
    background: var(--portal-accent-dim) !important;
}

.report-container .btn-outline-secondary {
    color: var(--portal-text-muted) !important;
    border-color: var(--portal-border) !important;
    background: transparent !important;
}

.report-container .btn-outline-secondary:hover {
    background: var(--portal-elevated) !important;
    color: var(--portal-text) !important;
}

.report-container .btn-warning {
    background: rgba(240, 180, 41, 0.15) !important;
    border-color: rgba(240, 180, 41, 0.3) !important;
    color: var(--portal-warning) !important;
}

/* --- Stat cards --- */

.report-container .stat-card {
    background: var(--portal-surface) !important;
    border: 1px solid var(--portal-border) !important;
    border-radius: var(--portal-radius-sm) !important;
}

.report-container .stat-value {
    color: var(--portal-accent) !important;
}

.report-container .stat-label {
    color: var(--portal-text-muted) !important;
}

/* --- Metadata cards --- */

.report-container .metadata-card,
.report-container [style*="background: #2b3035"],
.report-container [style*="background:#2b3035"],
.report-container [style*="background-color: #2b3035"],
.report-container [style*="background-color:#2b3035"] {
    background: var(--portal-surface) !important;
    border-color: var(--portal-border) !important;
    border-radius: var(--portal-radius-sm) !important;
}

/* --- AI analysis box --- */

.report-container [style*="background: #1e2226"],
.report-container [style*="background:#1e2226"] {
    background: var(--portal-surface) !important;
    border-color: var(--portal-border) !important;
    border-radius: var(--portal-radius-sm) !important;
}

/* --- Test parameters + TOC inline backgrounds --- */

.report-container [style*="background: #1a1d20"],
.report-container [style*="background:#1a1d20"],
.report-container [style*="background-color: #1a1d20"],
.report-container [style*="background-color:#1a1d20"] {
    background: var(--portal-surface) !important;
    border-color: var(--portal-border) !important;
}

/* --- Tyre info card (single tyre view) --- */

.report-container .tyre-info-card .card {
    background: var(--portal-surface) !important;
    border: 1px solid var(--portal-border) !important;
    border-radius: var(--portal-radius) !important;
    padding: 0.5rem;
}

.report-container .tyre-info-card h2 {
    color: var(--portal-text) !important;
    font-size: 1.4rem;
}

.report-container .tyre-details strong {
    color: var(--portal-text-muted);
    font-weight: 500;
}

/* --- Drift analysis cards --- */

.report-container .drift-analysis-cards .card {
    background: var(--portal-surface) !important;
    border: 1px solid var(--portal-border) !important;
}

.report-container .drift-analysis-cards .card-body {
    padding: 0.75rem !important;
}

/* --- Image gallery cards --- */

.report-container .image-gallery .card {
    background: var(--portal-surface) !important;
    overflow: hidden;
}

.report-container .image-gallery .card-body {
    background: var(--portal-surface) !important;
}

.report-container .image-gallery .card-text {
    color: var(--portal-text-muted) !important;
}

/* --- Voice notes --- */

.report-container [style*="background: rgba(13, 177, 231"] {
    background: rgba(13, 177, 231, 0.06) !important;
    border-radius: 4px;
}

/* --- Subjective scoring --- */

.report-container .subjective-scoring-inline {
    border-top-color: var(--portal-border) !important;
}

/* --- Performance summary cards (single tyre) --- */

.report-container .performance-summary .card {
    background: var(--portal-surface) !important;
}

/* --- Inline style overrides for text colours --- */

.report-container [style*="color: #ccc"],
.report-container [style*="color:#ccc"] {
    color: var(--portal-text) !important;
}

.report-container [style*="color: #888"],
.report-container [style*="color:#888"] {
    color: var(--portal-text-muted) !important;
}

.report-container [style*="color: #adb5bd"] {
    color: var(--portal-text-muted) !important;
}

.report-container [style*="color: #c8c8c8"] {
    color: var(--portal-text) !important;
}

/* --- Border overrides --- */

.report-container [style*="border: 1px solid #495057"],
.report-container [style*="border:1px solid #495057"] {
    border-color: var(--portal-border) !important;
}

.report-container [style*="border-bottom: 3px solid #0db1e7"] {
    border-bottom-color: var(--portal-accent) !important;
}

.report-container hr {
    border-color: var(--portal-border);
    opacity: 0.5;
}

/* --- Control run evolution (inline in table) --- */

.report-container td[style*="background: #1e2226"] {
    background: var(--portal-surface) !important;
}

.report-container [style*="background-color: #1a1d20"] {
    background: var(--portal-elevated) !important;
}

/* --- Rounded corner helper for standalone tables --- */

.report-container .table-bordered {
    border: none !important;
}

.report-container .table-bordered > thead > tr:first-child > th:first-child {
    border-top-left-radius: var(--portal-radius-sm);
}

.report-container .table-bordered > thead > tr:first-child > th:last-child {
    border-top-right-radius: var(--portal-radius-sm);
}

.report-container .table-bordered > tbody > tr:last-child > td:first-child {
    border-bottom-left-radius: var(--portal-radius-sm);
}

.report-container .table-bordered > tbody > tr:last-child > td:last-child {
    border-bottom-right-radius: var(--portal-radius-sm);
}

/* --- Canvas charts (ensure visible on dark bg) --- */

.report-container canvas {
    border-radius: 4px;
}

/* Brand tyre highlight in dashboard */
.brand-tyre-highlight {
    border-left: 3px solid var(--portal-accent);
    padding-left: 0.75rem;
    margin-top: 0.5rem;
}

/* --- Responsive --- */

@media (max-width: 768px) {
    .portal-content {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .login-card {
        margin: 1rem;
        padding: 1.75rem;
    }

    .report-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .report-card .report-actions {
        width: 100%;
    }

    .report-card .report-actions .btn-portal {
        width: 100%;
        justify-content: center;
    }

    .profile-field {
        flex-direction: column;
        gap: 0.25rem;
    }

    .profile-field .field-label {
        width: auto;
    }

    .user-pill .company-label {
        display: none;
    }
}

/* --- Print --- */

@media print {
    .portal-navbar,
    .portal-footer,
    .portal-breadcrumb,
    .no-print {
        display: none !important;
    }

    .portal-content {
        padding-top: 0;
        max-width: 100%;
    }

    body {
        background: #fff;
        color: #111;
    }

    .report-container,
    .report-container .table,
    .report-container .table-dark,
    .report-container .card,
    .report-container .stats-card,
    .report-container .card-body {
        background: #fff !important;
        color: #111 !important;
    }

    .report-container .table > thead > tr > th,
    .report-container .table-dark > thead > tr > th {
        background: #f0f0f0 !important;
        color: #333 !important;
        border-color: #ccc !important;
    }

    .report-container .table > tbody > tr > td,
    .report-container .table-dark > tbody > tr > td {
        color: #111 !important;
        border-color: #ddd !important;
        background: #fff !important;
    }

    .report-container .section-number,
    .report-container .subsection-number {
        background: #333 !important;
        color: #fff !important;
    }

    .report-container .card-header {
        background: #f0f0f0 !important;
        color: #333 !important;
    }

    .report-container .table-responsive {
        border-color: #ddd !important;
    }

    .report-container .reference-row td {
        background: #e8f4fd !important;
    }

    .report-container .badge {
        border: 1px solid #ccc !important;
        background: #f5f5f5 !important;
        color: #333 !important;
    }
}
