* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #1a1a2e;
    color: #e0e0e0;
    min-height: 100vh;
}

header {
    background: #16213e;
    padding: 1rem 2rem;
    border-bottom: 2px solid #0f3460;
    display: flex;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
}

header h1 {
    color: #e94560;
    font-size: 1.4rem;
    white-space: nowrap;
}

.version-tag {
    font-size: 0.55em;
    font-weight: 400;
    color: #888;
    vertical-align: middle;
    text-decoration: none;
}

.version-tag:hover {
    color: #5bc0de;
}

nav { display: flex; gap: 0.5rem; }

.nav-btn {
    background: #0f3460;
    color: #e0e0e0;
    border: 1px solid #1a1a2e;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s;
}
.nav-btn:hover { background: #533483; }
.nav-btn.active { background: #e94560; color: #fff; }

main { padding: 1.5rem 2rem; }

.view { display: none; }
.view.active { display: block; }

.controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.controls label { font-weight: 600; color: #aaa; }

.controls select {
    background: #16213e;
    color: #e0e0e0;
    border: 1px solid #0f3460;
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    font-size: 0.9rem;
}

.nominated-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    font-weight: 600;
    color: #aaa;
    font-size: 0.9rem;
    margin-left: 0.5rem;
}
.nominated-toggle input[type="checkbox"] {
    accent-color: #e94560;
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Stage tabs */
.stage-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1rem;
    overflow-x: auto;
    padding-bottom: 0.25rem;
    scrollbar-width: thin;
    scrollbar-color: #0f3460 #1a1a2e;
}
.stage-tabs:empty { display: none; }
.stage-tab {
    background: #0f3460;
    color: #e0e0e0;
    border: 1px solid #1a1a2e;
    padding: 0.35rem 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    white-space: nowrap;
    transition: background 0.2s;
}
.stage-tab:hover { background: #533483; }
.stage-tab.active { background: #e94560; color: #fff; }

/* Leg-based stage tab colors */
.stage-tab[data-leg="1"] { background: #1a4a6e; }
.stage-tab[data-leg="1"]:hover { background: #2a6a9e; }
.stage-tab[data-leg="1"].active { background: #e94560; }
.stage-tab[data-leg="2"] { background: #1a5e3a; }
.stage-tab[data-leg="2"]:hover { background: #2a8e5a; }
.stage-tab[data-leg="2"].active { background: #e94560; }
.stage-tab[data-leg="3"] { background: #5e4a1a; }
.stage-tab[data-leg="3"]:hover { background: #8e7a2a; }
.stage-tab[data-leg="3"].active { background: #e94560; }

.stage-tab .stage-tab-name {
    display: block;
    font-size: 0.7rem;
    color: #aaa;
    margin-top: 1px;
}
.stage-tab.active .stage-tab-name { color: #ddd; }

/* Service/ceremony separators between stage tabs */
.stage-separator {
    display: flex;
    align-items: center;
    font-size: 0.7rem;
    color: #888;
    padding: 0 0.15rem;
    white-space: nowrap;
}
.stage-separator.service { color: #f0ad4e; }
.stage-separator.ceremony { color: #5bc0de; font-style: italic; }

/* Nominations grid */
.nominations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin-top: 0.5rem;
}

.nom-card {
    background: #16213e;
    border: 1px solid #0f3460;
    border-radius: 8px;
    padding: 1rem;
}
.nom-card-header {
    font-weight: 700;
    font-size: 1rem;
    color: #e94560;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid #0f3460;
    padding-bottom: 0.5rem;
}
.nom-class-group {
    margin-bottom: 0.6rem;
}
.nom-class-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #aaa;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.nom-driver {
    padding: 0.2rem 0 0.2rem 0.5rem;
    font-size: 0.9rem;
    color: #e0e0e0;
}
.nom-driver-type {
    font-size: 0.75rem;
    color: #666;
    margin-left: 0.3rem;
}
.nom-empty {
    color: #555;
    text-align: center;
    padding: 2rem;
    font-size: 0.95rem;
}

/* Split-screen stage view */
.stage-split { display: flex; gap: 1rem; }
.stage-split-left, .stage-split-right { flex: 1; min-width: 0; overflow-x: auto; position: relative; }
.split-heading {
    color: #e94560;
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}
.stage-split-left .dataTables_wrapper,
.stage-split-right .dataTables_wrapper {
    position: relative;
}
.stage-split-left .dataTables_filter,
.stage-split-right .dataTables_filter {
    position: absolute;
    top: -1.7rem;
    right: 0;
}

/* Position change indicators */
.pos-up { color: #4caf50; font-weight: 600; font-size: 0.85em; }
.pos-down { color: #f44336; font-weight: 600; font-size: 0.85em; }
.pos-same { color: #888; font-size: 0.85em; }

/* Compact table font */
table.compact-table { font-size: 12.5px; }
table.compact-table th:first-child,
table.compact-table td:first-child { width: 25px; text-align: center; }
#results-table th:nth-child(4),
#results-table td:nth-child(4) { min-width: 220px; }

/* DataTables dark theme overrides */
table.dataTable { border-collapse: collapse; width: 100%; }
table.dataTable thead th {
    background: #16213e;
    color: #e94560;
    border-bottom: 2px solid #0f3460;
    padding: 6px 8px;
    text-align: left;
    font-size: 12.5px;
}
table.dataTable tbody td {
    padding: 5px 8px;
    border-bottom: 1px solid #222;
}
table.dataTable tbody tr:nth-child(odd) { background: #1a1a2e; }
table.dataTable tbody tr:nth-child(even) { background: #16213e; }
table.dataTable tbody tr:hover { background: #0f3460; }

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    background: #16213e;
    color: #e0e0e0;
    border: 1px solid #0f3460;
    border-radius: 4px;
    padding: 4px 8px;
}
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_length label,
.dataTables_wrapper .dataTables_filter label {
    color: #aaa;
}
.dataTables_wrapper .dataTables_paginate .paginate_button {
    color: #e0e0e0 !important;
    background: #0f3460;
    border: 1px solid #1a1a2e;
    border-radius: 3px;
    margin: 0 2px;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: #e94560 !important;
    color: #fff !important;
    border-color: #e94560;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: #533483 !important;
    color: #fff !important;
}

/* Admin panel */
.admin-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
}
.admin-card {
    background: #16213e;
    border: 1px solid #0f3460;
    border-radius: 8px;
    padding: 1.5rem;
}
.admin-card h3 { color: #e94560; margin-bottom: 0.5rem; }
.admin-card p { color: #aaa; margin-bottom: 1rem; font-size: 0.9rem; }
.admin-card label {
    display: block;
    color: #aaa;
    font-size: 0.85rem;
    margin-top: 0.75rem;
    margin-bottom: 0.25rem;
}
.admin-card input[type="file"] {
    width: 100%;
    background: #1a1a2e;
    color: #e0e0e0;
    border: 1px solid #0f3460;
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.9rem;
}
.admin-card input[type="text"],
.admin-card input[type="number"] {
    width: 100%;
    background: #1a1a2e;
    color: #e0e0e0;
    border: 1px solid #0f3460;
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.9rem;
}
.admin-card textarea {
    width: 100%;
    background: #1a1a2e;
    color: #e0e0e0;
    border: 1px solid #0f3460;
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.9rem;
    font-family: monospace;
    resize: vertical;
}
.admin-card select {
    width: 100%;
    background: #1a1a2e;
    color: #e0e0e0;
    border: 1px solid #0f3460;
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.9rem;
}
.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
    width: auto;
    accent-color: #e94560;
}

.btn {
    display: inline-block;
    margin-top: 1rem;
    background: #e94560;
    color: #fff;
    border: none;
    padding: 0.6rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s;
}
.btn:hover { background: #c73e54; }
.btn:disabled { background: #555; cursor: not-allowed; }

.status {
    margin-top: 0.75rem;
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
    min-height: 1.5em;
}
.status.success { background: #1b4332; color: #95d5b2; }
.status.error { background: #3d0000; color: #ff6b6b; }
.status.loading { background: #1a1a2e; color: #aaa; }

/* Comment icon in results table */
.comment-cell {
    text-align: center;
    position: relative;
}
.comment-icon {
    cursor: pointer;
    font-size: 1rem;
    opacity: 0.7;
    transition: opacity 0.15s;
    position: relative;
}
.comment-icon:hover {
    opacity: 1;
}
.comment-icon:hover::after {
    content: attr(data-comment);
    position: absolute;
    bottom: 130%;
    right: 0;
    background: #0f3460;
    color: #e0e0e0;
    border: 1px solid #e94560;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    white-space: pre-wrap;
    max-width: 300px;
    min-width: 120px;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    pointer-events: none;
}

/* Standings rally grid */
.rally-col-header {
    font-size: 0.8rem;
    white-space: nowrap;
}

.rally-cell {
    text-align: center;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.15s;
}
.rally-cell:hover {
    background: #533483 !important;
    color: #fff;
}
.rally-cell.no-data {
    color: #555;
    cursor: default;
}
.rally-cell.no-data:hover {
    background: inherit !important;
    color: #555;
}

.total-cell {
    text-align: center;
    font-weight: 700;
    color: #e94560;
}

/* Driver detail popup */
.driver-popup {
    position: absolute;
    z-index: 1000;
    background: #16213e;
    border: 1px solid #e94560;
    border-radius: 8px;
    padding: 0;
    min-width: 320px;
    max-width: 480px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}
.driver-popup.hidden { display: none; }

.driver-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 1rem;
    background: #0f3460;
    border-radius: 8px 8px 0 0;
    font-weight: 600;
    font-size: 0.9rem;
    color: #e94560;
}

.popup-close-btn {
    background: none;
    border: none;
    color: #aaa;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 0.3rem;
    line-height: 1;
}
.popup-close-btn:hover { color: #e94560; }

#popup-body { padding: 0.5rem 0.75rem 0.75rem; }

.popup-drivers-table {
    width: 100%;
    font-size: 0.85rem;
    border-collapse: collapse;
}
.popup-drivers-table th {
    color: #aaa;
    font-weight: 600;
    padding: 4px 8px;
    text-align: left;
    border-bottom: 1px solid #0f3460;
}
.popup-drivers-table td {
    padding: 4px 8px;
    border: none;
}
.popup-drivers-table tr.excluded-driver {
    color: #666;
    text-decoration: line-through;
}

/* ── Driver Stats Modal ──────────────────────────────────────────────── */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-overlay.hidden { display: none; }

.driver-stats-modal {
    background: #16213e;
    border: 1px solid #0f3460;
    border-radius: 8px;
    max-width: 95vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    min-width: 600px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #0f3460;
}
.modal-header h2 {
    color: #e94560;
    font-size: 1.2rem;
    margin-bottom: 0.2rem;
}
.modal-subtitle {
    color: #888;
    font-size: 0.9rem;
}
.profile-link {
    color: #5bc0de;
    font-size: 0.85rem;
    text-decoration: none;
    display: inline-block;
    margin-top: 0.3rem;
}
.profile-link:hover { text-decoration: underline; }

.modal-body {
    padding: 1rem 1.5rem;
    overflow: auto;
}
.modal-body h3 {
    color: #e94560;
    font-size: 1rem;
    margin: 1rem 0 0.5rem;
}
.modal-body h3:first-child { margin-top: 0; }

.stats-table-wrapper {
    overflow-x: auto;
    margin-bottom: 0.5rem;
}

.stats-matrix {
    border-collapse: collapse;
    font-size: 0.8rem;
    white-space: nowrap;
    width: auto;
}
.stats-matrix th,
.stats-matrix td {
    border: 1px solid #0f3460;
    padding: 3px 8px;
    text-align: center;
}
.stats-matrix th {
    background: #0f3460;
    color: #e0e0e0;
    font-weight: 600;
}
.stats-matrix td {
    color: #ccc;
}
.stats-matrix .row-label {
    text-align: left;
    background: #1a1a2e;
    color: #aaa;
    font-weight: 500;
    position: sticky;
    left: 0;
    z-index: 1;
}

.stats-matrix td.sr-cell {
    background: rgba(233, 69, 96, 0.25);
}
.stats-matrix td.pos-gold { background: rgba(255, 215, 0, 0.25); }
.stats-matrix td.pos-silver { background: rgba(192, 192, 192, 0.3); }
.stats-matrix td.pos-bronze { background: rgba(205, 127, 50, 0.25); }

/* ── Compare Controls ────────────────────────────────────────────── */

.compare-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
    margin-right: 1rem;
}
.compare-controls label {
    color: #aaa;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}
.compare-controls select {
    background: #1a1a2e;
    color: #e0e0e0;
    border: 1px solid #0f3460;
    padding: 0.35rem 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
    max-width: 260px;
}
.compare-controls .btn-icon {
    background: none;
    border: none;
    color: #888;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 0.3rem;
    line-height: 1;
}
.compare-controls .btn-icon:hover {
    color: #e94560;
}

/* ── Comparison Table ────────────────────────────────────────────── */

.compare-section-header td {
    font-weight: 700;
    font-size: 0.85rem;
    padding: 6px 8px !important;
    text-align: left !important;
    border-top: 2px solid #0f3460;
}
.compare-driver-label {
    background: #1a1a2e !important;
    color: #5bc0de !important;
}
.compare-delta-label {
    background: #1a1a2e !important;
    color: #e94560 !important;
}

.delta-faster {
    color: #4caf50 !important;
    font-weight: 600;
}
.delta-slower {
    color: #f44336 !important;
    font-weight: 600;
}
.delta-neutral {
    color: #888 !important;
}

/* Penalty time (red text below stage time) */
.penalty-time {
    color: #f44336;
    font-size: 0.8em;
}

.driver-name-link {
    color: #5bc0de;
    cursor: pointer;
}
.driver-name-link:hover {
    text-decoration: underline;
}

/* ── Scrape Queue ──────────────────────────────────────────────────── */

.admin-card-wide {
    grid-column: 1 / -1;
}

.scrape-form-row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    flex-wrap: wrap;
}
.scrape-form-field { display: flex; flex-direction: column; }
.scrape-form-field label { margin-top: 0; }
.scrape-form-url { flex: 1; min-width: 250px; }
.scrape-form-number { width: 70px; }
.scrape-form-btn { align-self: flex-end; }
.scrape-form-btn .btn { margin-top: 0; }

#scrape-queue-panel {
    margin-top: 1rem;
}

.scrape-section:not(:empty) {
    margin-bottom: 0.75rem;
}

.scrape-queue-label {
    font-size: 0.8rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.35rem;
    font-weight: 600;
}

.scrape-current-job {
    background: #1a2a4e;
    border: 1px solid #0f3460;
    border-left: 3px solid #e94560;
    border-radius: 4px;
    padding: 0.6rem 0.8rem;
    font-size: 0.9rem;
}
.scrape-progress {
    color: #aaa;
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

.scrape-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid #555;
    border-top-color: #e94560;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 0.4rem;
    vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

.scrape-queue-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #16213e;
    border: 1px solid #0f3460;
    border-radius: 4px;
    padding: 0.4rem 0.8rem;
    margin-bottom: 0.3rem;
    font-size: 0.85rem;
}
.scrape-queue-item-name {
    color: #ccc;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 0.5rem;
}

.btn-remove-job {
    background: none;
    border: 1px solid #555;
    color: #aaa;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.8rem;
    white-space: nowrap;
}
.btn-remove-job:hover {
    border-color: #e94560;
    color: #e94560;
}

.scrape-history-item {
    font-size: 0.85rem;
    padding: 0.2rem 0;
    color: #aaa;
}
.scrape-history-done .scrape-history-icon { color: #4caf50; }
.scrape-history-error .scrape-history-icon { color: #f44336; }

/* ── Itinerary Editor ─────────────────────────────────────────────── */

.itin-table-wrap {
    overflow-x: auto;
    margin-top: 0.5rem;
}
.itin-edit-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.itin-edit-table th {
    text-align: left;
    color: #aaa;
    font-weight: 600;
    padding: 0.4rem 0.3rem;
    border-bottom: 1px solid #0f3460;
    white-space: nowrap;
}
.itin-edit-table td {
    padding: 0.25rem 0.3rem;
}
.itin-input {
    width: 100%;
    background: #1a1a2e;
    color: #e0e0e0;
    border: 1px solid #0f3460;
    padding: 0.35rem 0.4rem;
    border-radius: 3px;
    font-size: 0.85rem;
    box-sizing: border-box;
}
.itin-input:focus {
    border-color: #e94560;
    outline: none;
}
.itin-narrow {
    width: 70px;
}
select.itin-input {
    appearance: auto;
}
.btn-icon {
    background: none;
    border: 1px solid #555;
    color: #aaa;
    border-radius: 3px;
    cursor: pointer;
    padding: 0.2rem 0.5rem;
    font-size: 0.8rem;
    transition: all 0.15s;
}
.btn-icon:hover {
    border-color: #e94560;
    color: #e94560;
}
.btn-small {
    padding: 0.35rem 0.8rem;
    font-size: 0.8rem;
    margin-top: 0.5rem;
}
.btn-secondary {
    background: #0f3460;
}
.btn-secondary:hover {
    background: #1a4a7a;
}

/* ── Live Rallies Banner ─────────────────────────────────────────── */

#live-rallies-banner:empty { display: none; }

#live-rallies-banner {
    margin-bottom: 1rem;
}

.live-rally-card {
    background: #16213e;
    border: 1px solid #0f3460;
    border-left: 3px solid #e94560;
    border-radius: 6px;
    padding: 0.6rem 1rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    cursor: pointer;
    transition: background 0.15s;
}
.live-rally-card:hover {
    background: #1a2a4e;
}

.live-rally-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}

.live-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #e94560;
    border-radius: 50%;
    animation: live-pulse 1.5s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes live-pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 4px #e94560; }
    50% { opacity: 0.4; box-shadow: 0 0 0 #e94560; }
}

.live-label {
    color: #e94560;
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.live-rally-name {
    color: #e0e0e0;
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.live-rally-meta {
    color: #888;
    font-size: 0.8rem;
    white-space: nowrap;
}

.live-rally-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.btn-live-scrape {
    background: #e94560;
    color: #fff;
    border: none;
    padding: 0.35rem 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: background 0.2s;
    white-space: nowrap;
}
.btn-live-scrape:hover { background: #c73e54; }
.btn-live-scrape:disabled {
    background: #333;
    color: #888;
    cursor: not-allowed;
}

.live-scrape-progress {
    color: #aaa;
    font-size: 0.8rem;
}

.live-cooldown {
    color: #888;
    font-size: 0.8rem;
}

/* Admin live rallies list */
.live-admin-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0;
    border-bottom: 1px solid #0f3460;
    font-size: 0.85rem;
}
.live-admin-item:last-child { border-bottom: none; }
.live-admin-name { color: #e0e0e0; }
.live-admin-date { color: #888; font-size: 0.8rem; margin-left: 0.5rem; }
.btn-remove-live {
    background: none;
    border: 1px solid #555;
    color: #aaa;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.8rem;
}
.btn-remove-live:hover {
    border-color: #e94560;
    color: #e94560;
}

/* ── Qualifying ────────────────────────────────────────────────── */

.qual-top-bar {
    margin-bottom: 1rem;
}

.qual-session-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.qual-session-controls label {
    color: #aaa;
    font-size: 0.9rem;
}

.qual-session-controls select {
    background: #16213e;
    color: #e0e0e0;
    border: 1px solid #0f3460;
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    min-width: 200px;
}

.btn-danger {
    background: #5a1a1a !important;
    border-color: #8b2020 !important;
    color: #e94560 !important;
}
.btn-danger:hover {
    background: #7a2020 !important;
}

.qual-rally-section {
    background: #16213e;
    border: 1px solid #0f3460;
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.qual-rally-section h3 {
    color: #e94560;
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
}

.qual-rally-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    min-height: 1.5rem;
}

.qual-rally-chip {
    background: #0f3460;
    color: #e0e0e0;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.qual-chip-ago {
    font-size: 0.7rem;
    color: #888;
    margin-left: 0.1rem;
}
.qual-chip-ago.scraping {
    color: #e9a345;
}

.qual-chip-rescrape {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0 0.15rem;
}
.qual-chip-rescrape:hover {
    color: #5b9bd5;
}
.qual-chip-rescrape:disabled {
    color: #555;
    cursor: not-allowed;
}

.qual-chip-remove {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0 0.15rem;
}
.qual-chip-remove:hover {
    color: #e94560;
}

.qual-add-rally-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.qual-add-rally-row input[type="text"] {
    background: #1a1a2e;
    color: #e0e0e0;
    border: 1px solid #0f3460;
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    flex: 1;
    min-width: 250px;
}

.qual-add-rally-row select {
    background: #1a1a2e;
    color: #e0e0e0;
    border: 1px solid #0f3460;
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    min-width: 180px;
}

.qual-or {
    color: #666;
    font-size: 0.85rem;
}

.qual-empty {
    color: #666;
    font-size: 0.85rem;
    font-style: italic;
}

.qual-class-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1rem;
}

.qual-class-tab {
    background: #16213e;
    color: #aaa;
    border: 1px solid #0f3460;
    padding: 0.4rem 1rem;
    cursor: pointer;
    border-radius: 4px 4px 0 0;
    font-size: 0.85rem;
    transition: background 0.2s, color 0.2s;
}

.qual-class-tab:hover {
    background: #1a2a4e;
    color: #e0e0e0;
}

.qual-class-tab.active {
    background: #e94560;
    color: #fff;
    border-color: #e94560;
}

#qual-leaderboard {
    width: 100%;
}

.qual-stage-col {
    font-size: 0.75rem;
    text-align: center;
    min-width: 70px;
}

.qual-stage-name {
    font-size: 0.65rem;
    color: #888;
    font-weight: normal;
}
.qual-set-time {
    color: #5b9bd5 !important;
    cursor: pointer;
    font-style: italic;
    font-size: 0.75rem;
}
.qual-set-time:hover {
    color: #7cb8e8 !important;
    text-decoration: underline;
}

.qual-time {
    text-align: center;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
}

.qual-dnf {
    color: #e94560;
}

.qual-total {
    font-variant-numeric: tabular-nums;
}

.qual-driver-row {
    cursor: pointer;
}

.qual-driver-row:hover td {
    background: #1a2a4e !important;
}

.qual-expanded td {
    background: #1a2a4e !important;
}

.qual-driver-name {
    white-space: nowrap;
}

.qual-detail-row {
    background: #0d1b30 !important;
}

.qual-detail-row td {
    padding: 0.75rem 1rem !important;
    background: #0d1b30 !important;
}

.qual-detail-table {
    width: auto;
    min-width: 500px;
    border-collapse: collapse;
    font-size: 0.85rem;
    margin: 0 auto;
}

.qual-detail-table th {
    color: #aaa;
    font-weight: 600;
    text-align: center;
    padding: 0.3rem 1rem;
    border-bottom: 1px solid #0f3460;
}

.qual-detail-table td {
    padding: 0.3rem 1rem !important;
    text-align: center;
    background: transparent !important;
    font-variant-numeric: tabular-nums;
}

.qual-best-time {
    color: #4eca7a;
    font-weight: 600;
}
