/* Define the IBM Plex Sans Regular font using @font-face */
@font-face {
    font-family: 'IBM Plex Sans';
    src: url('../fonts/IBMPlexSans-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
}

/* Define the IBM Plex Sans Bold font using @font-face */
@font-face {
    font-family: 'IBM Plex Sans';
    src: url('../fonts/IBMPlexSans-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
}
/* Define the Michroma Regular font using @font-face */
@font-face {
    font-family: 'Michroma';
    src: url('../fonts/Michroma-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

/* Define the KodeMono Regular font using @font-face */
@font-face {
    font-family: 'KodeMono';
    src: url('../fonts/KodeMono-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

/* Theme variables (Light default) */
:root {
    --bg-color: #f8f9fa;
    --text-color: #212529;
    --muted-text-color: #6c757d;
    --nav-bg: #ffffff;
    --nav-text: #212529;
    --nav-border: rgba(0,0,0,0.1);
    --footer-bg: #f8f9fa;
    --footer-text: #6c757d;
    --card-bg: #ffffff;
    --list-item-bg: #ffffff;
    --list-item-border: rgba(0,0,0,0.125);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #0f1113;
        --text-color: #e6e6e6;
        --muted-text-color: #a0a6ac;
        --nav-bg: #14171a;
        --nav-text: #e6e6e6;
        --nav-border: rgba(255,255,255,0.12);
        --footer-bg: #14171a;
        --footer-text: #a0a6ac;
        --card-bg: #1a1e21;
        --list-item-bg: #1a1e21;
        --list-item-border: rgba(255,255,255,0.1);
    }
}

/**** Forced themes via attribute ****/
[data-theme='light'] {
    --bg-color: #f8f9fa;
    --text-color: #212529;
    --muted-text-color: #6c757d;
    --nav-bg: #ffffff;
    --nav-text: #212529;
    --nav-border: rgba(0,0,0,0.1);
    --footer-bg: #f8f9fa;
    --footer-text: #6c757d;
    --card-bg: #ffffff;
    --list-item-bg: #ffffff;
    --list-item-border: rgba(0,0,0,0.125);
}
[data-theme='dark'] {
    --bg-color: #0f1113;
    --text-color: #e6e6e6;
    --muted-text-color: #a0a6ac;
    --nav-bg: #14171a;
    --nav-text: #e6e6e6;
    --nav-border: rgba(255,255,255,0.12);
    --footer-bg: #14171a;
    --footer-text: #a0a6ac;
    --card-bg: #1a1e21;
    --list-item-bg: #1a1e21;
    --list-item-border: rgba(255,255,255,0.1);
}

body {
    font-family: 'IBM Plex Sans', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
}


.progress-bar-animated {
    animation-duration: 3s;
    animation-fill-mode: both;
    animation-iteration-count: infinite;
}

.bg-dark {
    background-image: linear-gradient(45deg, rgba(63, 70, 74, 0.82) 25%, transparent 25%, transparent 50%, rgba(53, 58, 60, 0.82) 50%, rgba(52, 58, 64, 0.54) 75%, transparent 75%, transparent 100%);
    background-size: 10px 10px;
    background-color: #343a40 !important;
}

/* Air between the end of a page's content and the footer, on every page. */
main[role="main"] {
    padding-bottom: 3rem;
}

footer {
    position: static;
    width: 100%;
}

footer div {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
}

/* Responsive footer: hide extras on small screens to avoid overflow */
@media (max-width: 576px) {
    .theme-footer .footer-extra { display: none; }
    .theme-footer p { margin-bottom: 0; }
}

/* Theme helpers */
.theme-bg { background-color: var(--bg-color) !important; }
.theme-text { color: var(--text-color) !important; }
.theme-navbar {
    background-color: var(--nav-bg) !important;
    color: var(--nav-text) !important;
    border-bottom: 1px solid var(--nav-border);
}
.theme-navbar .navbar-brand,
.theme-navbar .nav-link,
.theme-navbar .navbar-text { color: var(--nav-text) !important; }
.theme-navbar .nav-link.disabled, .theme-navbar .navbar-text, .theme-navbar .nav-link .small { color: var(--muted-text-color) !important; }
.theme-navbar .btn-outline-secondary { color: var(--nav-text); border-color: var(--nav-border); }
.theme-navbar .btn-outline-secondary:hover { background-color: rgba(0,0,0,0.05); }
[data-theme='dark'] .theme-navbar .btn-outline-secondary:hover { background-color: rgba(255,255,255,0.08); }
.theme-navbar .navbar-toggler { border-color: var(--nav-border); }
/* custom hamburger icon to avoid navbar-light/dark dependency */
.theme-navbar .navbar-toggler-icon { background-image: none; position: relative; width: 1.5em; height: 1.5em; }
.theme-navbar .navbar-toggler-icon::before,
.theme-navbar .navbar-toggler-icon::after { content: ''; position: absolute; left: 0; right: 0; height: 2px; background-color: var(--nav-text); }
.theme-navbar .navbar-toggler-icon::before { top: 0.45em; }
.theme-navbar .navbar-toggler-icon::after { top: 0.95em; }

.theme-footer { background-color: var(--footer-bg) !important; color: var(--footer-text) !important; border-top: 1px solid var(--nav-border); }
.theme-card { background-color: var(--card-bg) !important; color: var(--text-color) !important; }

/* Bootstrap 4's .table puts `color: #212529` on the table element itself, which
   beats the colour inherited from .theme-card and leaves the bare <th scope="row">
   labels on /status near-black on the dark background. Re-assert the theme colour
   on the table; cells that carry .text-muted match directly and still win over it,
   so the muted response column keeps its intended tone. */
.theme-card .table { color: var(--text-color); }
/* The same fault outside cards: the expression method page and the admin
   tables sit on the page background, so every table takes the theme colour. */
.table { color: var(--text-color); }
.table th, .table td, .table thead th { border-color: var(--panel-rule, rgba(128, 128, 128, 0.3)); }
.theme-list-item { background-color: var(--list-item-bg) !important; color: var(--text-color) !important; border-color: var(--list-item-border) !important; }

.loading-percent {
    font-size: 1.5rem;
    font-weight: bold;
}

.permanent-underline {
    text-decoration: underline;
}

/* Styles for the loading overlay and fade-out effect */
.overlay {
    position: fixed;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    background-color: rgba(0, 0, 0, 0.8);
    /* Blur everything behind the overlay while loading */
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    z-index: 9999;
    transition: opacity 1s ease-in-out;
}

.overlay-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.overlay img {
    /* You can adjust the image size and other styles */
    max-width: 100%;
    height: auto;
}

.overlay p {
    color: white;
    margin-top: 10px;
}

@keyframes emphasise {
    0% {
        background-color: transparent;
    }
    50% {
        background-color: #9b9b9b;
    }
    100% {
        background-color: transparent;
    }
}

.emphasise-animation {
    animation: emphasise 0.7s infinite;
}

.separator-line {
    flex: 1;
    margin: 10px 0; /* Adjust margin for top and bottom */
    border: none; /* Remove the default hr border */

    /* Extra small devices (phones) */
    border-top: 1px solid #676767;

    /* Small devices (tablets) */
    @media (min-width: 576px) {
        border-top: none;
        border-bottom: 1px solid #676767;
    }
}

/* Dim the custom file label when the input is disabled (upload in progress) */
.custom-file-input:disabled ~ .custom-file-label,
.custom-file-label.disabled {
    background-color: #6c757d; /* bootstrap secondary */
    color: #dee2e6; /* light gray */
    cursor: not-allowed;
    opacity: 0.65;
}

/* Enhanced upload UI styles */
.dropzone {
    border: 2px dashed #6c757d;
    border-radius: 0.5rem;
    padding: 1.25rem;
    color: #adb5bd;
    background-image: linear-gradient(180deg, rgba(108,117,125,0.08), rgba(108,117,125,0.02));
    transition: box-shadow 0.25s ease, transform 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
    user-select: none;
    cursor: pointer;
}
.dropzone .dz-instructions {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
}
.dropzone .dz-instructions i {
    font-size: 1.25rem;
}
.dropzone:hover {
    border-color: #5bc0de; /* info */
    box-shadow: 0 0 0.75rem rgba(91,192,222,0.35);
    transform: translateY(-1px);
}
.dropzone.dragover {
    border-color: #17a2b8;
    background-color: rgba(23,162,184,0.08);
    box-shadow: 0 0 1rem rgba(23,162,184,0.5), inset 0 0 0.5rem rgba(23,162,184,0.25);
}
.dropzone.disabled {
    opacity: 0.6;
    cursor: not-allowed;
    box-shadow: none;
}
/* Smooth progress transitions */
.progress .progress-bar {
    transition: width 0.4s ease;
}
/* Custom file label subtle interaction */
.custom-file-label {
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
}
.custom-file-input:focus ~ .custom-file-label,
.custom-file-label:hover {
    transform: translateY(-1px);
}
/* List group contrast on dark bg */
.list-group-item {
    border-color: rgba(255,255,255,0.1);
}

/* About page improvements */
.page-hero {
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 0.5rem 1rem rgba(0,0,0,0.35);
    background-repeat: no-repeat;
}
.page-hero h1 {
    font-family: 'Michroma', 'IBM Plex Sans', Arial, sans-serif;
}
.page-hero .badge {
    letter-spacing: .02em;
}

/* Navbar */
.navbar {
    background-color: var(--nav-bg) !important;
    border-bottom: 1px solid var(--nav-border);
}
.navbar .navbar-brand, .navbar .nav-link {
    color: var(--nav-text) !important;
}
.navbar .nav-link:hover {
    text-decoration: underline;
}

/* Footer */
.footer {
    background-color: var(--footer-bg);
    color: var(--footer-text);
    border-top: 1px solid var(--nav-border);
}

/* Cards and lists */
.card { background-color: var(--card-bg); }
.theme-list-item { background-color: var(--list-item-bg); border-color: var(--list-item-border); }

/* Modern number input (spinbutton) */
.modern-number .form-control {
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.modern-number .btn {
    min-width: 44px; /* comfortable target size */
}
.modern-number .btn:focus {
    box-shadow: 0 0 0 .2rem rgba(108,117,125,.25);
}
/* Hide native number spinners for a cleaner look */
input[type=number].form-control::-webkit-outer-spin-button,
input[type=number].form-control::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type=number].form-control {
    -moz-appearance: textfield;
}
[data-theme='dark'] .modern-number .btn.btn-outline-secondary {
    color: #e6e6e6;
    border-color: #6c757d;
}
[data-theme='dark'] .modern-number .btn.btn-outline-secondary:hover {
    background-color: #6c757d;
    color: #fff;
}

/* Dropzone */
.dropzone {
    border: 2px dashed var(--list-item-border);
    padding: 24px;
    background: var(--card-bg);
    color: var(--muted-text-color);
    border-radius: .5rem;
    transition: border-color .2s, background-color .2s;
}
.dropzone.dragover {
    border-color: #17a2b8;
    background-color: rgba(23, 162, 184, 0.08);
}

.separator-line {
    border: 0;
    border-top: 1px solid var(--nav-border);
}

/* Overlay */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    /* Blur everything behind the overlay while loading */
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    transition: opacity .6s ease;
}
.overlay .overlay-container {
    background: var(--card-bg);
    border: 1px solid var(--nav-border);
    border-radius: 12px;
    padding: 24px 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: min(92vw, 520px);
    color: var(--text-color);
    text-align: center;
}
.overlay img { width: 80px; height: 80px; object-fit: contain; }
.overlay p { margin: 12px 0 4px; font-weight: 600; }
.overlay .loading-percent { font-variant-numeric: tabular-nums; }

/* Theme toggle button */
#theme-toggle-btn { white-space: nowrap; }
#theme-toggle-label { margin-left: .35rem; font-size: .9rem; color: var(--muted-text-color); }

/* Page hero (legacy) */
.page-hero {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: .75rem 0 1rem;
}
.page-hero h1 {
    font-family: 'Michroma', 'IBM Plex Sans', Arial, sans-serif;
}
.page-hero .badge {
    letter-spacing: .02em;
}

/* Homepage title: larger and organised */
.page-header { text-align: center; margin-top: .5rem; margin-bottom: 1rem; }
.page-title { color: var(--text-color); font-weight: 700; letter-spacing: .2px; }
.page-title-sm { color: var(--text-color); font-weight: 700; letter-spacing: .2px; }
@media (min-width: 768px) { .page-title { font-size: 2.25rem; } }
@media (max-width: 767.98px) { .page-title-sm { font-size: 1.5rem; } }

/* Layout: Sticky footer using flexbox */
html, body { height: 100%; }
body { min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1 0 auto; display: block; }

/* Ensure themed footer gets proper styling */
footer.theme-footer {
    background-color: var(--footer-bg);
    color: var(--footer-text);
    border-top: 1px solid var(--nav-border);
    width: 100%;
}
/* Center footer content */
footer.theme-footer > div {
    display: flex;
    justify-content: center;
    align-items: center;
}


/* --- Mobile responsiveness fixes (2025-09-17) --- */
/* Global box-sizing for predictable sizing */
html { box-sizing: border-box; }
*, *::before, *::after { box-sizing: inherit; }

/* Responsive media to avoid overflow on small screens */
img, video, canvas, svg { max-width: 100%; height: auto; }

/* Break long words/paths to prevent horizontal scroll */
.container, .container-fluid, .list-group-item { overflow-wrap: anywhere; word-break: break-word; }

/* Last-resort guard against inadvertent horizontal scrolling */
html, body { max-width: 100%; overflow-x: hidden; }


/* Seasonal: Santa hat on the NCQ brand during Christmas (Dec 1 – Jan 6) */
.navbar .navbar-brand.xmas-hat {
    position: relative; /* create containing block for the hat */
    display: inline-block;
}
.navbar .navbar-brand.xmas-hat::after {
    content: '';
    position: absolute;
    top: -0.40em;            /* lower the hat so it sits beside text instead of above */
    left: -0.45em;           /* move hat to the left of the NCQ brand */
    width: 1.15em;
    height: 1.15em;
    background-repeat: no-repeat;
    background-size: contain;
    /* Simple inline SVG Santa hat (red cap with white trim and pom-pom) with improved light-mode contrast */
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'><defs><filter id='shadow' x='-20%25' y='-20%25' width='140%25' height='140%25'><feDropShadow dx='0' dy='1' stdDeviation='1' flood-color='rgba(0,0,0,0.3)'/></filter></defs><g filter='url(%23shadow)'><path d='M56 36c0-8-10-18-24-22C18 10 10 18 6 26c8-2 20 2 24 6 6 6 10 8 26 4z' fill='%23d32f2f'/><path d='M4 42h48c2 0 4 2 4 4s-2 4-4 4H4c-2 0-4-2-4-4s2-4 4-4z' fill='%23f5f5f5' stroke='currentColor' stroke-opacity='.55' stroke-width='2' stroke-linejoin='round'/><circle cx='52' cy='20' r='8' fill='%23f5f5f5' stroke='currentColor' stroke-opacity='.55' stroke-width='2'/></g></svg>");
    transform: rotate(-18deg); /* tilt towards the text for a natural look on the left */
    pointer-events: none; /* decoration only */
}

/* Jumbotron vertical padding override (fix ugly top/bottom spacing) */
.jumbotron {
    padding-top: 20px;   /* numeric value for consistent spacing */
    padding-bottom: 20px;/* numeric value for consistent spacing */
}
/* Ensure fluid variant keeps horizontal behavior but respects new vertical paddings */
.jumbotron.jumbotron-fluid {
    padding-left: 0;
    padding-right: 0;
}
/* Page hero variants can be a touch larger without being excessive */
.page-hero.jumbotron {
    padding-top: 28px;
    padding-bottom: 28px;
}
@media (min-width: 768px) {
    .jumbotron { padding-top: 24px; padding-bottom: 24px; }
    .page-hero.jumbotron { padding-top: 36px; padding-bottom: 36px; }
}


/* Chart ramp (ADR-0002, WS7).

   Defined once, here, beside the rules that use it, rather than added to the
   theme blocks at the top of the file: the theme variables are declared in
   more than one place, and a copy in each is a copy to keep in step.
   Light is the default; dark is re-picked from the same hue rather than
   flipped, so "more included" reads as "more contrast" in both. */
:root {
    --chart-excluded: #5aa3b2;
    --chart-retained: #237d90;
    --chart-counted: #0d525f;
    --chart-neutral: #adb5bd;
    --chart-grid: rgba(0,0,0,0.18);
    --tile-bg: #ffffff;
    --tile-border: rgba(0,0,0,0.125);
    --panel-rule: rgba(0,0,0,0.08);
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme='light']) {
        --chart-excluded: #2b6f7c;
        --chart-retained: #45a8bd;
        --chart-counted: #8ad8e6;
        --chart-neutral: #6c757d;
        --chart-grid: rgba(255,255,255,0.22);
        --tile-bg: #1a1e21;
        --tile-border: rgba(255,255,255,0.1);
        --panel-rule: rgba(255,255,255,0.08);
    }
}
[data-theme='dark'] {
    --chart-excluded: #2b6f7c;
    --chart-retained: #45a8bd;
    --chart-counted: #8ad8e6;
    --chart-neutral: #6c757d;
    --chart-grid: rgba(255,255,255,0.22);
    --tile-bg: #1a1e21;
    --tile-border: rgba(255,255,255,0.1);
    --panel-rule: rgba(255,255,255,0.08);
}

/* ===================================================================
   Results panel (ADR-0002, WS7)

   The chart ramp is ordered, not categorical: an object is excluded,
   retained, or counted, and that is a sequence. So it is one hue,
   light to dark, with a neutral grey for rows that were never data.
   The steps are re-picked for dark mode rather than flipped, so that
   "more included" stays "more contrast against the page" in both.
   =================================================================== */

.results-panel {
    margin: 0 0 2rem;
}

/* --- Headline tiles --- */
.stat-grid {
    gap: 0;
}
.stat-tile {
    background: var(--tile-bg);
    border: 1px solid var(--tile-border);
    border-radius: .4rem;
    padding: .75rem .85rem;
    margin: .25rem;
}
.stat-label {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--muted-text-color);
    line-height: 1.25;
    min-height: 2.1em;
}
.stat-symbol {
    font-weight: 700;
    color: var(--chart-counted);
    /* The label above is uppercased, which turns the symbols this project
       actually uses -- alpha, beta, gamma -- into their capitals. They are
       specific characters, not styling. */
    text-transform: none;
}
.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
    margin-top: .15rem;
    font-variant-numeric: tabular-nums;
}
.stat-note {
    font-size: .75rem;
    color: var(--muted-text-color);
    min-height: 1.2em;
}

/* --- Quality checks --- */
.check-row {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    padding: .7rem .9rem;
    border: 1px solid var(--tile-border);
    border-left-width: 4px;
    border-radius: .3rem;
    background: var(--tile-bg);
    margin-bottom: .5rem;
}
.check-warn { border-left-color: #d39e00; }
.check-info { border-left-color: var(--chart-retained); }
.check-warn .check-icon { color: #d39e00; }
.check-info .check-icon { color: var(--chart-retained); }
.check-icon { font-size: 1.1rem; line-height: 1.4; }
.check-title { font-weight: 700; }
.check-badge {
    font-weight: 400;
    font-size: .68rem;
    background: transparent;
    border: 1px solid var(--tile-border);
    color: var(--muted-text-color);
    vertical-align: middle;
}
.check-message { font-size: .9rem; }
.check-guidance { font-size: .82rem; color: var(--muted-text-color); margin-top: .15rem; }

/* --- Accounting bar --- */
.account-bar {
    display: flex;
    width: 100%;
    height: 22px;
    border-radius: .25rem;
    overflow: hidden;
    background: var(--tile-border);
}
.account-seg { display: block; height: 100%; }
/* A 2px page-coloured gap so adjacent segments never read as one block. */
.account-seg + .account-seg { box-shadow: inset 2px 0 0 var(--card-bg); }

.seg-blank_rows       { background: var(--chart-neutral); }
.seg-debris_count     { background: var(--chart-excluded); }
.seg-unclustered_count{ background: var(--chart-retained); }
.seg-cluster_count    { background: var(--chart-counted); }

.swatch {
    display: inline-block;
    width: .7rem;
    height: .7rem;
    border-radius: .15rem;
    margin-right: .4rem;
    vertical-align: baseline;
}
.swatch.hist-debris      { background: var(--chart-excluded); }
.swatch.hist-unclustered { background: var(--chart-retained); }
.swatch.hist-clustered   { background: var(--chart-counted); }

/* --- Volume histogram --- */
.histogram {
    display: block;
    width: 100%;
    height: 220px;
    overflow: visible;
}
.hist-bar { shape-rendering: crispEdges; }
.hist-debris      { fill: var(--chart-excluded); }
.hist-unclustered { fill: var(--chart-retained); }
.hist-clustered   { fill: var(--chart-counted); }
.hist-edge {
    stroke: var(--chart-grid);
    stroke-width: 1;
    stroke-dasharray: 3 3;
    vector-effect: non-scaling-stroke;
}
.hist-axis {
    position: relative;
    height: 1.2rem;
    font-size: .72rem;
    color: var(--muted-text-color);
    border-top: 1px solid var(--panel-rule);
    margin-top: .2rem;
}
.hist-axis span {
    position: absolute;
    transform: translateX(-50%);
    top: .15rem;
}
.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: .8rem;
    color: var(--muted-text-color);
}
.legend-item { display: inline-flex; align-items: center; }

/* --- Distribution bars --- */
.results-table th, .results-table td { border-top-color: var(--panel-rule); }
/* Counts and percentages are read down the column, so they must not wrap:
   "2,121" broken across two lines reads as two numbers. */
.results-table td.text-right,
.results-table th.text-right { white-space: nowrap; }
.results-table td.text-right { font-variant-numeric: tabular-nums; }

/* --- The metric catalogue on the method page ---
   Label, definition and why, side by side, with the label column pinned wide
   enough that the symbols line up down the page. */
.metrics-table th[scope="row"] {
    width: 16rem;
    font-weight: 400;
}
/* On a phone that pinned column swallowed the row: 256px of a 318px table left
   the two prose columns about 30px each, so every definition rendered one or
   two characters wide and ran for over a thousand pixels. Below md the row
   stops being a row and becomes a block -- label, then definition, then why. */
@media (max-width: 767.98px) {
    .metrics-table,
    .metrics-table tbody,
    .metrics-table tr,
    .metrics-table th,
    .metrics-table td {
        display: block;
        width: auto;
    }
    .metrics-table th,
    .metrics-table td {
        border-top: 0;
        padding: 0;
    }
    .metrics-table tr {
        padding: .55rem 0;
        border-top: 1px solid var(--panel-rule);
    }
    .metrics-table tbody tr:first-child { border-top: 0; padding-top: 0; }
    /* Overrides the pinned label column above: the attribute selector there
       outweighs the display:block group, so the width is reset by name. */
    .metrics-table th[scope="row"] {
        width: auto;
        font-weight: 600;
        margin-bottom: .15rem;
    }
    /* The "why" column, which is muted and secondary, sits under the
       definition rather than beside it. */
    .metrics-table td + td { margin-top: .2rem; }
    /* An empty cell in the stacked layout would add a blank gap. */
    .metrics-table td:empty { display: none; }
}
.dist-bar-col { width: 34%; min-width: 90px; }
.dist-bar {
    display: block;
    height: 12px;
    min-width: 2px;
    border-radius: 0 3px 3px 0;
    background: var(--chart-counted);
}
.sens-current > * { font-weight: 700; }

/* --- Actions --- */
.results-actions {
    border-top: 1px solid var(--panel-rule);
    padding-top: 1rem;
}
.run-promise {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem 1.1rem;
    margin: 1rem .25rem 0;
    padding-top: .75rem;
    border-top: 1px solid var(--panel-rule);
}

@media (max-width: 575.98px) {
    .stat-value { font-size: 1.25rem; }
    .histogram { height: 160px; }
}

/* Server-drawn charts (differential-expression tool). They carry their own
   white background so they read the same in either theme and as saved files. */
.xp-chart {
    overflow-x: auto;
    background: #ffffff;
    border-radius: 4px;
}
.xp-chart svg {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
}

/* Compact settings column beside the live charts. */
.xp-settings {
    position: sticky;
    top: 0.75rem;
    max-height: calc(100vh - 1.5rem);
    overflow-y: auto;
}
.xp-settings .xp-group {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--footer-text, #6c757d);
    margin: 1rem 0 0.4rem;
}
.xp-settings .xp-group:first-of-type { margin-top: 0; }
@media (max-width: 991.98px) {
    .xp-settings { position: static; max-height: none; }
}

/* Idle prompt for the expression tool. */
.xp-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.xp-modal {
    max-width: 460px;
    width: 100%;
}

/* Admin tabs: Bootstrap paints the active tab white, a bright box in dark mode. */
.nav-tabs { border-bottom-color: var(--panel-rule, rgba(128, 128, 128, 0.3)); }
.nav-tabs .nav-link.active {
    background-color: var(--card-bg);
    color: var(--text-color);
    border-color: var(--panel-rule, rgba(128, 128, 128, 0.3)) var(--panel-rule, rgba(128, 128, 128, 0.3)) var(--card-bg);
}

/* 2FA enrolment QR: the generated SVG has a fixed ~38mm size; scale it to a
   comfortable scanning size and let it shrink on narrow screens. */
.twofa-qr svg { display: block; width: min(260px, 70vw); height: auto; }

/* Recovery codes: a centred two-column block that is easy to copy down. */
.recovery-codes { display: grid; grid-template-columns: repeat(2, max-content);
  gap: .5rem 2rem; justify-content: center; margin: 1rem 0 1.5rem; }
.recovery-codes code { font-size: 1.05rem; }
