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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.5;
}

header {
    background: #1a237e;
    color: white;
    padding: 1rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

header h1 {
    font-size: 1.25rem;
}

header .meta {
    opacity: 0.8;
    font-size: 0.875rem;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

/* Cards */
.card-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.card {
    background: white;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.card h3 { font-size: 1.1rem; margin-bottom: 0.25rem; }
.card .meta { color: #666; font-size: 0.875rem; }
.card .stats { color: #888; font-size: 0.8rem; }
.card-actions { margin-top: 0.75rem; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    background: #1a237e;
    color: white;
    text-decoration: none;
    cursor: pointer;
    font-size: 0.875rem;
}

.btn:hover { background: #283593; }
.btn-primary { background: #2e7d32; }
.btn-primary:hover { background: #388e3c; }
.btn-large { padding: 0.75rem 2rem; font-size: 1.1rem; width: 100%; }
.btn-small { padding: 0.25rem 0.5rem; font-size: 0.8rem; }

/* Inputs */
.input {
    padding: 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1rem;
}

.input-large {
    font-size: 1.5rem;
    padding: 0.75rem;
    width: 100%;
    text-align: center;
}

/* Station form */
.station-form {
    max-width: 400px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 600;
    font-size: 0.875rem;
}

/* Timing table */
.timing-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    font-size: 0.875rem;
}

.timing-table th,
.timing-table td {
    padding: 0.5rem;
    border: 1px solid #e0e0e0;
    text-align: center;
    white-space: nowrap;
}

.timing-table th {
    background: #1a237e;
    color: white;
    font-weight: 600;
    position: sticky;
    top: 0;
}

/* Give time columns a sensible minimum width */
.timing-table td.cell-complete,
.timing-table td.cell-waiting {
    min-width: 6.5rem;
}

.timing-table tbody tr:nth-child(even) {
    background: #fafafa;
}

.cell-complete { background: #e8f5e9 !important; }
.cell-waiting { color: #999; }
.cell-finish.cell-complete { background: #c8e6c9 !important; font-weight: 700; }

.cell-sector { font-size: 0.8em; color: #888; margin-top: 1px; }

.sortable-th { cursor: pointer; user-select: none; }
.sortable-th:hover { background: #283593; }

/* Flag toggle buttons */
.btn-flag {
    display: inline-block;
    width: 24px; height: 24px;
    font-size: 0.7rem; font-weight: 600;
    border: 1px solid #ccc; border-radius: 3px;
    background: #f5f5f5; cursor: pointer;
    text-align: center; line-height: 22px;
    margin: 0 1px; padding: 0;
}
.btn-flag.active { background: #ffab00; color: #fff; border-color: #ff8f00; }
.btn-flag:hover { background: #e0e0e0; }
.btn-flag.active:hover { background: #ff8f00; }

/* Inactive driver rows (DNF/DSQ/DNS) */
.row-inactive { opacity: 0.5; }
.row-inactive td { text-decoration: line-through; }
.row-inactive td:first-child,
.row-inactive td:last-child,
.row-inactive td:nth-last-child(2),
.row-inactive td:nth-last-child(3) { text-decoration: none; }

/* Pending publish row (light orange tint) */
.row-pending-publish td { background: #fff8e1 !important; }
.row-pending-publish td.cell-complete { background: #fff3e0 !important; }

/* Just-published flash (light green) — uses box-shadow to overlay on top of !important backgrounds */
.row-just-published td { animation: publish-flash 3s ease-out; }
@keyframes publish-flash {
    0% { box-shadow: inset 0 0 0 100px rgba(46, 125, 50, 0.2); }
    100% { box-shadow: inset 0 0 0 100px transparent; }
}

/* Publish countdown badge in row */
.publish-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}
.publish-badge .pub-countdown { color: #e65100; font-size: 0.7rem; }
.publish-badge .pub-btn {
    background: none; border: 1px solid #ccc; border-radius: 3px;
    font-size: 0.75rem; padding: 1px 5px; cursor: pointer; line-height: 1.4;
}
.publish-badge .pub-btn:hover { background: #eee; }
.publish-badge .pub-btn-go { color: #fff; background: #2e7d32; border-color: #2e7d32; }
.publish-badge .pub-btn-go:hover { background: #388e3c; }
.publish-badge .pub-btn-stop { color: #fff; background: #c62828; border-color: #c62828; }
.publish-badge .pub-btn-stop:hover { background: #d32f2f; }

/* Public overview per-class */
.class-heading { margin: 1.5rem 0 0.5rem; font-size: 1.1rem; border-bottom: 2px solid #1a237e; padding-bottom: 0.25rem; }
.overview-class-table { margin-bottom: 1.5rem; }
.cell-diff { font-family: monospace; font-size: 0.85rem; color: #555; }
.penalty-badge { background: #fff3e0; color: #e65100; padding: 1px 4px; border-radius: 3px; font-size: 0.8rem; font-weight: 600; }
.status-dsq { color: #c62828; font-weight: 700; }
.status-dnf { color: #e65100; font-weight: 700; }
.status-dns { color: #666; font-weight: 600; }
.flag-badge { display: inline-block; font-size: 0.65rem; font-weight: 700; padding: 1px 3px; border-radius: 2px; margin-left: 2px; }
.flag-warn { background: #fff9c4; color: #f57f17; border: 1px solid #f9a825; }
.flag-tech { background: #e3f2fd; color: #1565c0; border: 1px solid #42a5f5; }
.flag-fs { background: #fce4ec; color: #c62828; border: 1px solid #ef5350; }
.flag-ui { background: none; color: #e65100; border: none; padding: 0; font-size: 0.85rem; animation: pulse-ui 2.5s ease-in-out infinite; }
@keyframes pulse-ui {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Investigation banner on public pages */
.investigation-banner {
    background: #fff3e0;
    color: #e65100;
    border: 1px solid #ff9800;
    border-radius: 6px;
    padding: 0.5rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    text-align: center;
}

.th-station-sync { font-size: 0.65em; font-weight: 400; white-space: nowrap; margin-top: 2px; }
.th-station-sync.station-ok { color: #2e7d32; }
.th-station-sync.station-warn { color: #e65100; }
.th-station-sync.station-critical { color: #c62828; font-weight: 600; }

.cell-flash {
    animation: flash 1.5s ease-out;
}

@keyframes flash {
    0% { background: #ffeb3b; }
    100% { background: #e8f5e9; }
}

/* Row-level green flash for live updates on public pages */
.row-updated td { animation: publish-flash 3s ease-out; }

/* Row flash for position improvements (green) */
.row-improved td { animation: publish-flash 3s ease-out; }

/* Row flash for position drops (light red) */
.row-dropped-pos td { animation: drop-flash 3s ease-out; }
@keyframes drop-flash {
    0% { box-shadow: inset 0 0 0 100px rgba(229, 115, 115, 0.3); }
    100% { box-shadow: inset 0 0 0 100px transparent; }
}

/* Position change arrows */
.pos-arrow {
    display: inline-block;
    font-size: 0.75em;
    font-weight: 700;
    margin-left: 0.25rem;
    animation: arrow-fade 3.5s ease-out forwards;
}
.pos-arrow-up { color: #2e7d32; }
.pos-arrow-down { color: #e57373; }
@keyframes arrow-fade {
    0%, 70% { opacity: 1; }
    100% { opacity: 0; }
}

/* Status badges */
.badge-planning { color: #666; }
.badge-active { color: #2e7d32; }
.badge-inprogress { color: #f57c00; }
.badge-completed { color: #1565c0; }
.badge-cancelled { color: #c62828; }


/* Feedback */
.feedback {
    padding: 0.75rem;
    border-radius: 4px;
    margin: 1rem 0;
    text-align: center;
    font-weight: 600;
}

.feedback-success { background: #e8f5e9; color: #2e7d32; }
.feedback-error { background: #ffebee; color: #c62828; }
.feedback-warning { background: #fff3e0; color: #f57c00; }

/* Connection status indicator */
.connection-status {
    position: fixed;
    bottom: 0.5rem;
    right: 0.5rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-connected { background: #e8f5e9; color: #2e7d32; }
.status-reconnecting { background: #fff3e0; color: #f57c00; }
.status-disconnected { background: #ffebee; color: #c62828; }

/* Offline sync banner */
.offline-banner {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: #fff3e0;
    color: #e65100;
    border: 1px solid #ffcc80;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.offline-banner button {
    background: #e65100;
    color: white;
    border: none;
    font-size: 0.8rem;
}
.offline-banner button:hover {
    background: #bf360c;
}

/* Dev progress overlay */
.dev-progress-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}
.dev-progress-box {
    background: white;
    border-radius: 8px;
    padding: 1.5rem 2rem;
    min-width: 340px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.dev-progress-title {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 0.75rem;
}
.dev-progress-bar-bg {
    background: #e0e0e0;
    border-radius: 4px;
    height: 8px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}
.dev-progress-bar-fill {
    background: #7b1fa2;
    height: 100%;
    width: 0%;
    transition: width 0.2s ease;
    border-radius: 4px;
}
.dev-progress-text {
    font-size: 0.85rem;
    color: #555;
}

/* Start station stale sync warning */
.sync-warning {
    background: #fff3e0;
    color: #e65100;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 0.5rem;
    border: 1px solid #ffcc80;
}

.driver-stale-unstarted {
    opacity: 0.5;
    font-size: 0.85em;
}

/* Started drivers on start station — compact and dimmed */
.driver-started-done {
    opacity: 0.45;
    padding: 0.25rem 0.75rem;
    font-size: 0.8em;
}

.driver-started-done .driver-number {
    font-size: 0.9em;
    min-width: 2.5rem;
}

.driver-started-done .driver-time {
    font-size: 0.85em;
}

.driver-started-done:hover {
    opacity: 0.7;
}

/* Separator between waiting and registered */
.driver-separator {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0.75rem;
    font-size: 0.75rem;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-top: 1px solid #e0e0e0;
    margin-top: 0.5rem;
}

.btn-history-toggle {
    background: none;
    border: 1px solid #ccc;
    border-radius: 3px;
    padding: 0.15rem 0.5rem;
    font-size: 0.75rem;
    color: #666;
    cursor: pointer;
    text-transform: none;
    letter-spacing: normal;
}

.btn-history-toggle:hover {
    background: #f0f0f0;
    color: #333;
}

.driver-separator-top {
    margin-top: 0;
    border-top: none;
    border-bottom: 1px solid #e0e0e0;
}

/* Public page navigation */
.page-nav {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
    width: 100%;
    margin-top: 0.25rem;
}

.page-nav-link {
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    font-size: 0.8rem;
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    white-space: nowrap;
}

.page-nav-link:hover {
    color: white;
    background: rgba(255,255,255,0.15);
}

.page-nav-active {
    color: white;
    font-weight: 600;
    background: rgba(255,255,255,0.2);
}

/* Utility */
.hidden { display: none !important; }
.loading { text-align: center; color: #999; padding: 2rem; }
.empty { text-align: center; color: #999; padding: 2rem; }
.error { color: #c62828; padding: 1rem; }

/* Admin layout */
.admin-layout {
    display: flex;
    min-height: calc(100vh - 56px);
}

.admin-nav {
    width: 200px;
    background: white;
    border-right: 1px solid #e0e0e0;
    padding: 0;
    flex-shrink: 0;
}

.admin-nav a {
    display: block;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: #333;
    border-bottom: 1px solid #eee;
    font-size: 0.9rem;
}

.admin-nav a:hover { background: #f0f0f0; }
.admin-nav a.active { background: #1a237e; color: white; }

.admin-content {
    flex: 1;
    padding: 1.5rem;
    max-width: 900px;
    min-width: 0;
}

/* Let overview section use full width for the wide timing table */
.admin-content:has(#section-overview.active) {
    max-width: none;
}

.admin-section { display: none; }
.admin-section.active { display: block; }

/* Overview tabs — level 1 (round tabs) */
.overview-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #1a237e;
    margin-bottom: 0;
}
.overview-tabs a {
    padding: 0.5rem 1rem;
    text-decoration: none;
    color: #555;
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    background: #f5f5f5;
    margin-bottom: -2px;
}
.overview-tabs a:hover { background: #e8e8e8; }
.overview-tabs a.active {
    background: white;
    color: #1a237e;
    border-color: #1a237e;
    font-weight: 600;
}

/* Overview tabs — level 2 (document tabs) */
.overview-subtabs {
    display: flex;
    gap: 0.25rem;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid #e0e0e0;
    margin-bottom: 1rem;
}
.overview-subtabs a {
    padding: 0.35rem 0.75rem;
    text-decoration: none;
    color: #666;
    font-size: 0.85rem;
    border-radius: 3px;
}
.overview-subtabs a:hover { background: #f0f0f0; }
.overview-subtabs a.active {
    background: #1a237e;
    color: white;
}

/* Overview document panels */
.overview-doc { display: none; }
.overview-doc.active { display: block; }

.admin-section h2 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

/* Admin tables */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.admin-table th,
.admin-table td {
    padding: 0.5rem 0.75rem;
    border: 1px solid #e0e0e0;
    text-align: left;
}

.admin-table th {
    background: #f5f5f5;
    font-weight: 600;
}

.admin-table tbody tr:hover { background: #fafafa; }

.admin-table input,
.admin-table select {
    width: 100%;
    padding: 0.25rem 0.4rem;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 0.85rem;
}

/* Admin forms */
.admin-form {
    background: white;
    border-radius: 8px;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 1rem;
}

.admin-form .form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.75rem;
    align-items: end;
}

.admin-form .form-row .form-group { flex: 1; margin-bottom: 0; }

.admin-form input,
.admin-form select {
    width: 100%;
    padding: 0.4rem 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.9rem;
}

.admin-form label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
    color: #555;
}

/* Toolbar */
.toolbar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    align-items: center;
}

/* Round group */
.round-group {
    background: white;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 1rem;
}

.round-group h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Checkpoint preview */
.checkpoint-preview {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.8rem;
    color: #666;
    margin-top: 0.5rem;
}

.checkpoint-preview .cp {
    background: #e3f2fd;
    color: #1565c0;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    font-weight: 600;
}

.checkpoint-preview .arrow { color: #999; }

/* Station card */
.station-card {
    background: white;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.station-card .station-info { flex: 1; }
.station-card .station-name { font-weight: 600; }
.station-card .station-checkpoints { font-size: 0.8rem; color: #666; margin-top: 0.25rem; }
.station-card .station-link { font-family: monospace; font-size: 0.8rem; color: #1565c0; }

/* Bridge status in station cards */
.bridge-status {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.4rem;
    font-size: 0.8rem;
    color: #555;
}
.bridge-status-none { opacity: 0.5; }
.bridge-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
.bridge-dot-ok { background: #2e7d32; }
.bridge-dot-warn { background: #e65100; }
.bridge-dot-off { background: #c62828; }
.bridge-dot-none { background: #bbb; }
.bridge-passings { color: #888; }
.bridge-queued { color: #e65100; font-weight: 600; }
.bridge-config-btn { margin-left: auto; font-size: 0.75rem; padding: 0.15rem 0.5rem; }
.bridge-config-panel {
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 0 0 8px 8px;
    margin-top: -0.75rem;
    margin-bottom: 0.75rem;
    padding: 0.75rem 1rem;
}
.bridge-config-form { max-width: 400px; }
.bridge-config-form .form-group { margin-bottom: 0.5rem; }
.bridge-config-form label { font-size: 0.8rem; font-weight: 600; display: block; margin-bottom: 0.15rem; }
.bridge-config-form select,
.bridge-config-form input { width: 100%; padding: 0.3rem 0.5rem; font-size: 0.85rem; }
.bridge-config-feedback { font-size: 0.8rem; }
.bridge-input-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0;
    font-size: 0.85rem;
    border-bottom: 1px solid #eee;
}
.bridge-input-row:last-child { border-bottom: none; }
.bridge-input-id {
    font-family: monospace;
    font-size: 0.8rem;
    color: #666;
    min-width: 80px;
}
.bridge-input-name {
    flex: 1;
    min-width: 100px;
}
.bridge-alias-input {
    padding: 0.2rem 0.4rem;
    font-size: 0.8rem;
    font-family: monospace;
    width: 80px;
    border: 1px solid #ddd;
    border-radius: 3px;
    background: #fafafa;
}
.bridge-alias-input:focus {
    border-color: #1565c0;
    outline: none;
}
.bridge-alias-input::placeholder {
    color: #bbb;
    font-style: italic;
}
.bridge-input-row select {
    padding: 0.2rem 0.4rem;
    font-size: 0.8rem;
    min-width: 150px;
}
.speed-trap-config {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: #fff3e0;
    border: 1px solid #ffcc80;
    border-radius: 6px;
}
.bridge-crash-panel {
    margin-top: 0.5rem;
    padding: 0.75rem;
    background: #fafafa;
    border-top: 1px solid #eee;
}
.bridge-crash-entry {
    margin-bottom: 0.5rem;
    border: 1px solid #eee;
    border-radius: 4px;
    overflow: hidden;
}
.bridge-crash-header {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
    background: #fff;
    cursor: pointer;
}
.bridge-crash-header:hover {
    background: #f5f5f5;
}
.bridge-crash-log {
    padding: 0.5rem 0.6rem;
    margin: 0;
    font-family: monospace;
    font-size: 0.7rem;
    line-height: 1.4;
    background: #1e1e1e;
    color: #d4d4d4;
    max-height: 400px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Station background slideshow (start/intermediate) */
.slideshow-layer {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background: center / cover no-repeat;
    opacity: 0;
    transition: opacity 2s ease-in-out;
}
.slideshow-layer.slideshow-visible {
    opacity: 0.12;
}
/* Ensure station cards are opaque over slideshow */
body.station-slideshow .driver-item,
body.station-slideshow .station-time-panel,
body.station-slideshow .passings-indicator,
body.station-slideshow .feedback,
body.station-slideshow .driver-separator {
    background-color: white;
}
body.station-slideshow .driver-item.driver-has-time { background-color: #f1f8e9; }
body.station-slideshow .driver-item.driver-recent { background-color: #e8f5e9; }
body.station-slideshow .driver-item.driver-selected { background-color: #e8eaf6; }
body.station-slideshow .station-time-panel { background-color: #e8eaf6; }

/* Finish station — checkered flag background */
body.finish-station {
    background:
        url('/images/checkered-flag.png') center / cover no-repeat fixed;
}
/* Ensure station cards are opaque over the checkered pattern */
body.finish-station .driver-item,
body.finish-station .station-time-panel,
body.finish-station .passings-indicator,
body.finish-station .feedback,
body.finish-station .driver-separator {
    background-color: white;
}
body.finish-station .driver-item.driver-has-time { background-color: #f1f8e9; }
body.finish-station .driver-item.driver-recent { background-color: #e8f5e9; }
body.finish-station .driver-item.driver-selected { background-color: #e8eaf6; }
body.finish-station .station-time-panel { background-color: #e8eaf6; }

/* Driver list (station page) */
.driver-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 0.5rem;
}

.driver-item {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.6rem 0.75rem;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: background 0.15s, border-color 0.15s;
}

.driver-main-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
}

.driver-item:hover { background: #e8eaf6; }
.driver-item.driver-selected { border-color: #1a237e; background: #e8eaf6; }
.driver-item.driver-has-time { background: #f1f8e9; }
.driver-item.driver-has-time:hover { background: #e8f5e9; }
.driver-item.driver-recent { border-color: #2e7d32; background: #e8f5e9; }

.driver-time {
    margin-left: auto;
    font-family: monospace;
    font-weight: 700;
    font-size: 1rem;
    color: #2e7d32;
}

.driver-edit-hint {
    font-size: 0.7rem;
    color: #999;
    padding-left: 2rem;
    display: none;
}

.driver-item.driver-has-time:hover .driver-edit-hint { display: block; }

.driver-position {
    font-size: 0.8rem;
    color: #666;
    min-width: 1.5rem;
    text-align: right;
}

.driver-number {
    font-weight: 700;
    min-width: 3rem;
    font-size: 1.1rem;
}

.driver-name {
    flex: 1;
    font-weight: 500;
}

.driver-club, .driver-vehicle {
    font-size: 0.8rem;
    color: #777;
}

.driver-club::before { content: '| '; }
.driver-vehicle::before { content: '| '; }

.driver-details {
    font-size: 0.78rem;
    color: #888;
    padding: 0 0.5rem 0.25rem 2.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.driver-started-done .driver-details { padding-bottom: 0.15rem; }

/* Driver checkpoint progress (station pages) */
.driver-progress {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0.15rem 0.5rem 0.2rem 2.5rem;
    flex-wrap: wrap;
}

.driver-started-done .driver-progress { padding-left: 0.5rem; padding-bottom: 0.1rem; }

.cp-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 5px;
    border-radius: 3px;
    white-space: nowrap;
    line-height: 1.4;
}

.cp-done {
    background: #1565c0;
    color: #fff;
}

.cp-pending {
    background: #e0e0e0;
    color: #aaa;
}

.cp-sep {
    font-size: 0.5rem;
    color: #ccc;
}

/* Selected driver time panel */
.station-time-panel {
    background: #e8eaf6;
    border: 2px solid #1a237e;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

.selected-driver-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
}

.selected-number {
    font-weight: 700;
    font-size: 1.3rem;
}

.selected-name { font-weight: 500; }

.station-time-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.station-time-form .input-large {
    flex: 1;
    text-align: center;
}

.station-time-form .btn-large {
    width: auto;
    white-space: nowrap;
}

/* Checkbox group */
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-weight: normal;
    font-size: 0.9rem;
    cursor: pointer;
}
.checkbox-group label.checkpoint-taken {
    opacity: 0.5;
    cursor: not-allowed;
}
.checkpoint-owner {
    font-size: 0.75rem;
    color: #888;
}

/* Button variants */
.btn-danger { background: #c62828; }
.btn-danger:hover { background: #d32f2f; }
.btn-success { background: #2e7d32; }
.btn-success:hover { background: #388e3c; }
.btn-admin { background: #555; }
.btn-admin:hover { background: #666; }
.btn-outline {
    background: transparent;
    color: #1a237e;
    border: 1px solid #1a237e;
}
.btn-outline:hover { background: #e8eaf6; }

/* Modal */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.modal-overlay.hidden { display: none; }
.modal-box {
    background: #fff; border-radius: 8px; padding: 1.5rem;
    max-width: 400px; width: 90%; box-shadow: 0 4px 24px rgba(0,0,0,0.3);
}
.modal-box p { margin: 0 0 1rem; font-size: 0.95rem; }

/* Results tables (shared between public results page and admin) */
.results-class { margin-bottom: 2rem; }
.results-class h3 { margin: 0 0 0.25rem; font-size: 1.1rem; }
.results-meta { font-size: 0.85rem; color: #666; margin-bottom: 0.5rem; }
.results-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.results-table th, .results-table td { padding: 0.35rem 0.6rem; border: 1px solid #ddd; text-align: left; }
.results-table th { background: #f5f5f5; font-weight: 600; }
.results-table td.pos { text-align: center; font-weight: 700; width: 40px; }
.results-table td.stnr { text-align: center; width: 40px; }
.results-table td.time { text-align: right; font-family: monospace; white-space: nowrap; }
.results-table td.time.dropped { text-decoration: line-through; color: #999; }
.results-table td.time.aggregate { font-weight: 700; }
.results-table tr.no-result td { color: #999; }
.results-table tr.incomplete td { color: #888; }
.results-table .status-label { color: #c62828; font-weight: 600; }
.results-table .status-suffix { color: #c62828; font-size: 0.75em; }
.results-table .round-header { font-size: 0.75rem; }
.modal-box .modal-actions { display: flex; flex-direction: column; gap: 0.5rem; }
.modal-box .modal-actions .btn { width: 100%; text-align: center; }

/* Allow wide tables to scroll horizontally on small screens */
.timing-table,
.admin-table,
.startlist-table,
.results-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Bridge passings indicator */
.passings-indicator {
    background: #e3f2fd;
    border: 1px solid #90caf9;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.75rem;
}

.passings-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.passings-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: #1565c0;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.passings-count {
    font-size: 0.75rem;
    color: #1976d2;
    background: #bbdefb;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    font-weight: 600;
}

.passings-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.passing-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: white;
    border: 1px solid #90caf9;
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    font-size: 0.85rem;
    cursor: default;
}

.passing-chip-time {
    font-family: monospace;
    font-weight: 700;
    color: #1565c0;
}

.passing-chip-source {
    font-size: 0.7rem;
    color: #888;
}

.passing-chip-discard {
    background: none;
    border: none;
    color: #bbb;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0 0.1rem;
    line-height: 1;
}

.passing-chip-discard:hover {
    color: #c62828;
}

/* Passing options in time panel */
.passing-options {
    margin-bottom: 0.75rem;
}

.passing-options-label {
    font-size: 0.8rem;
    color: #555;
    margin-bottom: 0.35rem;
    font-weight: 600;
}

.passing-options-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.4rem;
}

.passing-option-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: #e3f2fd;
    border: 2px solid #1565c0;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.15s, border-color 0.15s;
}

.passing-option-btn:hover {
    background: #bbdefb;
    border-color: #0d47a1;
}

.passing-option-btn:active {
    background: #90caf9;
}

.passing-option-time {
    font-family: monospace;
    font-weight: 700;
    color: #1565c0;
}

.passing-option-source {
    font-size: 0.75rem;
    color: #888;
}

.passing-options-divider {
    font-size: 0.75rem;
    color: #999;
    margin-bottom: 0.25rem;
}

/* Speed trap chips */
.speed-trap-chip {
    background: #fff3e0;
    border-color: #ffcc80;
}
.speed-trap-speed {
    font-family: monospace;
    font-weight: 700;
    color: #e65100;
    font-size: 1rem;
    margin-right: 0.25rem;
}
.speed-trap-option {
    background: #fff3e0 !important;
    border-color: #ffcc80 !important;
}
.speed-trap-option:hover {
    background: #ffe0b2 !important;
}
.speed-trap-option .speed-trap-speed {
    font-size: 0.95rem;
}

/* Mobile responsive */
@media (max-width: 600px) {
    header { padding: 0.75rem; }
    header h1 { font-size: 1rem; }
    main { padding: 0.5rem; }

    /* Compact tables on mobile */
    .timing-table { font-size: 0.7rem; }
    .timing-table th, .timing-table td { padding: 0.2rem 0.3rem; }
    .startlist-table { font-size: 0.75rem; }
    .startlist-table th, .startlist-table td { padding: 0.3rem 0.4rem; }
    .results-table { font-size: 0.75rem; }
    .results-table th, .results-table td { padding: 0.25rem 0.35rem; }
    .admin-table { font-size: 0.75rem; }
    .admin-table th, .admin-table td { padding: 0.3rem 0.5rem; }

    /* Admin layout */
    .admin-layout { flex-direction: column; }
    .admin-nav { width: 100%; display: flex; overflow-x: auto; border-right: none; border-bottom: 1px solid #e0e0e0; }
    .admin-nav a { white-space: nowrap; border-bottom: none; border-right: 1px solid #eee; }
    .admin-content { padding: 0.75rem; }
    .admin-form .form-row { flex-direction: column; gap: 0.5rem; }
}
