*, *::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: linear-gradient(135deg, #1a237e 0%, #283593 100%);
    color: white;
    padding: 1rem 1.25rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.15);
}

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: 1.25rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08), 0 0 1px rgba(0,0,0,0.05);
}

.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: 6px;
    background: #1a237e;
    color: white;
    text-decoration: none;
    cursor: pointer;
    font-size: 0.875rem;
    transition: background 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover { background: #283593; box-shadow: 0 1px 4px rgba(0,0,0,0.15); }
.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; }

/* Row with validation error */
.row-has-error td { background: #fff5f5 !important; }
.cell-has-error { position: relative; }
.cell-error-text {
    font-size: 0.7rem;
    color: #c62828;
    font-weight: 600;
    white-space: nowrap;
    margin-top: 2px;
}

/* 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;
}

/* Tab warning banner */
.tab-warning {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #e3f2fd;
    color: #0d47a1;
    border-bottom: 2px solid #1565c0;
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    z-index: 999;
}
.tab-warning button {
    background: #1565c0;
    color: white;
    border: none;
    padding: 0.3rem 0.8rem;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
}
.tab-warning button:hover {
    background: #0d47a1;
}
.tab-warning .btn-ignore {
    background: transparent;
    color: #1565c0;
    border: 1px solid #1565c0;
}
.tab-warning .btn-ignore:hover {
    background: #bbdefb;
}

/* 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);
}

/* Update modal */
.update-modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center; z-index: 2000;
}
.update-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);
    text-align: center;
}
.update-modal-box h3 { margin-bottom: 0.75rem; font-size: 1.1rem; color: #2e7d32; }
.update-modal-box p { margin-bottom: 1rem; font-size: 0.9rem; color: #555; }
.update-modal-box .btn { min-width: 120px; }

/* 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: 220px;
    background: #fafafa;
    border-right: 1px solid #e0e0e0;
    padding: 0.5rem 0;
    flex-shrink: 0;
}

.nav-group {
    margin-bottom: 0.25rem;
}

.admin-nav a {
    display: block;
    padding: 0.6rem 1rem 0.6rem 1.25rem;
    text-decoration: none;
    color: #444;
    font-size: 0.875rem;
    border-left: 4px solid transparent;
    transition: background 0.12s ease, border-color 0.12s ease;
}

.admin-nav a:hover {
    background: #eee;
    border-left-color: #bbb;
}

.admin-nav a.active {
    background: #fff;
    font-weight: 600;
    color: #1a237e;
}

/* Per-group accent colors on active links */
.nav-group[data-group="prep"] a.active { border-left-color: #1565c0; color: #1565c0; }

/* Standalone link (outside groups) */
.admin-nav > a.active { border-left-color: #1a237e; color: #1a237e; }

.nav-group-header {
    display: block;
    padding: 0.5rem 1rem 0.5rem 1.25rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #888;
    cursor: pointer;
    user-select: none;
    border-left: 4px solid transparent;
    transition: color 0.12s ease;
}

/* Group header accent colors */
.nav-group[data-group="prep"] > .nav-group-header { border-left-color: #1565c0; color: #1565c0; }

.nav-group-header:hover { opacity: 0.8; }
.nav-group-header::before { content: '▸ '; }
.nav-group.open > .nav-group-header::before { content: '▾ '; }
.nav-group:not(.open) > a { display: none; }

.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: 1.25rem;
    font-size: 1.25rem;
    padding-bottom: 0.5rem;
    border-bottom: 3px solid #1a237e;
}

/* 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: none;
    border-bottom: 1px solid #e8e8e8;
    text-align: left;
}

.admin-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #555;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    border-bottom: 2px solid #e0e0e0;
}

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

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

/* Shared vehicle highlight */
tr.shared-highlight td { animation: shared-pulse 4s ease-out; }
@keyframes shared-pulse {
    0%, 30% { background: #c8e6c9; }
    100% { background: transparent; }
}

/* Driver edit 2-row layout */
.driver-edit-table .driver-edit-row2 td { border-bottom: 2px solid #e0e0e0; }
.driver-edit-table .driver-edit-row1 td { border-bottom: none; }
.driver-edit-table .driver-edit-nr { vertical-align: middle; text-align: center; }

/* Tiny class button under start number */
.btn-class-tiny {
    display: block;
    margin: 0.25rem auto 0;
    padding: 0.1rem 0.4rem;
    font-size: 0.7rem;
    border: 1px solid #999;
    border-radius: 3px;
    background: #f5f5f5;
    color: #555;
    cursor: pointer;
    white-space: nowrap;
    max-width: 55px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.btn-class-tiny:hover { background: #e0e0e0; border-color: #666; }

/* Admin forms */
.admin-form {
    background: white;
    border-radius: 8px;
    padding: 1.25rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08), 0 0 1px rgba(0,0,0,0.05);
    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 4px rgba(0,0,0,0.08), 0 0 1px rgba(0,0,0,0.05);
    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; }

/* Round config inputs (mellantider, varv) */
.round-config-input {
    width: 52px;
    padding: 0.3rem 0.4rem;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 0.9rem;
    font-weight: 600;
    text-align: center;
    background: #f8f9fa;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.round-config-input:focus {
    border-color: #1a237e;
    box-shadow: 0 0 0 2px rgba(26,35,126,0.12);
    outline: none;
    background: #fff;
}
.round-config-label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: #555;
    font-weight: 500;
}

/* Checkpoint distance inline editor */
.dist-grid {
    display: inline-flex;
    align-items: stretch;
    gap: 0;
}
.dist-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.dist-cell .cp {
    min-width: 68px;
    text-align: center;
    box-sizing: border-box;
    padding: 0.35rem 0.5rem;
    border-radius: 4px 4px 0 0;
    font-size: 0.8rem;
    line-height: 1.4;
}
.dist-cell-start {
    justify-content: center;
}
.dist-cell-start .cp {
    min-width: 44px;
    padding: 0.5rem 0.6rem;
    font-size: 0.9rem;
    border-radius: 4px;
    background: #1565c0;
    color: #fff;
}
.dist-cell .dist-input {
    width: 68px;
    font-size: 0.85rem;
    padding: 0.3rem 0.25rem;
    border: 2px solid #e3f2fd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    text-align: center;
    background: #fff;
    transition: border-color 0.15s;
}
.dist-cell .dist-input:focus {
    border-color: #1565c0;
    outline: none;
}
.dist-cell .dist-input::placeholder { color: #bbb; }
.dist-arrow {
    display: flex;
    align-items: flex-start;
    padding: 0.85rem 0.15rem 0;
    color: #90caf9;
    font-size: 1.3rem;
    line-height: 1;
}

/* Round stepper (mellantider/varv) */
.round-stepper {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}
.round-stepper-label {
    font-weight: 600;
    color: #555;
    margin-right: 0.15rem;
}
.round-stepper-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #f8f9fa;
    font-size: 1.1rem;
    font-weight: 700;
    color: #555;
    cursor: pointer;
    user-select: none;
    line-height: 1;
    padding: 0;
}
.round-stepper-btn:hover { background: #e8eaf6; border-color: #1a237e; color: #1a237e; }
.round-stepper-btn:active { background: #c5cae9; }
.round-stepper-value {
    min-width: 28px;
    text-align: center;
    font-weight: 700;
    font-size: 1rem;
}

/* Station card */
.station-card {
    background: white;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08), 0 0 1px rgba(0,0,0,0.05);
    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.modal-wide {
    max-width: 900px;
}
.modal-box p { margin: 0 0 1rem; font-size: 0.95rem; }
.modal-box .modal-title { margin: 0 0 0.75rem; font-size: 1.05rem; color: #1a1a1a; }
.modal-box .modal-title-danger { margin: 0 0 0.75rem; font-size: 1.05rem; color: #c62828; }
.modal-box .modal-message { margin: 0 0 1.25rem; font-size: 0.95rem; color: #444; white-space: pre-line; line-height: 1.5; }

/* 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.modal-actions-row { flex-direction: row; }
.modal-box .modal-actions .btn { width: 100%; text-align: center; }
.modal-box .modal-actions-row .btn { width: auto; min-width: 100px; }

/* 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;
}

/* ===== Admin page — sportig & bold facelift ===== */

/* 1. Body & bakgrund */
.admin-page {
    background: #eef0f4;
}

/* 2. Header — mörk med accent-stripe */
.admin-page header {
    background: #12151a;
    border-bottom: 3px solid #e53935;
    padding: 0.85rem 1.25rem;
}
.admin-page header h1 {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

/* 3. Nav sidebar — mörk med ljus text */
.admin-page .admin-nav {
    width: 230px;
    background: #1a1d23;
    border-right: none;
    display: flex;
    flex-direction: column;
}
.admin-page .admin-nav a {
    color: #9ca3af;
    border-left: 4px solid transparent;
    padding: 0.65rem 1rem 0.65rem 1.25rem;
    font-size: 0.875rem;
    transition: all 0.15s ease;
}
.admin-page .admin-nav a:hover {
    color: #e5e7eb;
    background: rgba(255,255,255,0.06);
    border-left-color: rgba(255,255,255,0.15);
}
.admin-page .admin-nav a.active {
    color: #fff;
    font-weight: 600;
    background: rgba(255,255,255,0.1);
}

/* Nav group accents — always show left border color */
.admin-page .nav-group[data-group="prep"] a    { border-left-color: #2979ff; }
.admin-page .admin-nav > a:not(.nav-group-header) { border-left-color: #e53935; }

/* Active state: diagonal gradient highlight */
.admin-page .nav-group[data-group="prep"] a.active {
    border-left-color: #2979ff;
    background: linear-gradient(160deg, rgba(41,121,255,0.2) 0%, transparent 60%);
}
.admin-page .admin-nav > a.active {
    border-left-color: #e53935;
    background: linear-gradient(160deg, rgba(229,57,53,0.2) 0%, transparent 60%);
}

/* Nav group headers — starkare */
.admin-page .nav-group-header {
    color: #6b7280;
    background: none;
    padding: 0.75rem 1rem 0.4rem 1.25rem;
    border-left: 4px solid transparent;
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    margin-top: 0.25rem;
}
.admin-page .nav-group[data-group="prep"] > .nav-group-header    { color: #2979ff; border-left-color: #2979ff; }

/* Standalone nav link */
.admin-page .admin-nav > a {
    color: #9ca3af;
    margin-top: 0.5rem;
    border-top: 1px solid rgba(255,255,255,0.08);
    padding-top: 0.75rem;
}

/* 4. Content area */
.admin-page .admin-content {
    padding: 2rem;
}

/* 5. Section h2 — vänster-bar istället för underline */
.admin-page .admin-section h2 {
    border-bottom: none;
    border-left: 4px solid #e53935;
    padding-left: 0.75rem;
    padding-bottom: 0;
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: #1a1d23;
}

/* 6. Admin-tabeller — stark header */
.admin-page .admin-table th {
    background: #1a1d23;
    color: #fff;
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: none;
}
.admin-page .admin-table td {
    border-bottom-color: #e5e7eb;
}
.admin-page .admin-table tbody tr:hover {
    background: #f0f4ff;
}

/* 7. Cards/forms — subtil vänsterkant */
.admin-page .admin-form {
    border-left: 4px solid #e53935;
    border-radius: 4px 8px 8px 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.admin-page .round-group {
    border-left: 4px solid #2979ff;
    border-radius: 4px 8px 8px 4px;
}
.admin-page .station-card {
    border-left: 4px solid #ff6d00;
    border-radius: 4px 8px 8px 4px;
}

/* 8. Knappar — inom admin */
.admin-page .btn {
    font-weight: 600;
    letter-spacing: 0.01em;
    text-transform: uppercase;
    font-size: 0.8rem;
    padding: 0.55rem 1.15rem;
    border-radius: 4px;
}
.admin-page .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.admin-page .btn-primary {
    background: #e53935;
}
.admin-page .btn-primary:hover {
    background: #c62828;
}

/* 9. Overview tabs (i admin) */
.admin-page .overview-tabs {
    border-bottom-color: #1a1d23;
}
.admin-page .overview-tabs a.active {
    color: #1a1d23;
    border-color: #1a1d23;
    font-weight: 700;
}
.admin-page .overview-subtabs a.active {
    background: #1a1d23;
}

/* ===== End admin page styles ===== */

/* Announcements */
.announcement-list { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem; }
.announcement { border-radius: 6px; padding: 0.7rem 1rem; font-size: 0.9rem; border-left: 4px solid; }
.announcement-title { font-weight: 700; margin-bottom: 0.15rem; }
.announcement-info    { background: linear-gradient(160deg, rgba(25,118,210,0.18) 0%, rgba(25,118,210,0.04) 50%, transparent 100%); border-color: #1976d2; color: #0d47a1; }
.announcement-success { background: linear-gradient(160deg, rgba(56,142,60,0.18) 0%, rgba(56,142,60,0.04) 50%, transparent 100%); border-color: #388e3c; color: #1b5e20; }
.announcement-warning { background: linear-gradient(160deg, rgba(245,124,0,0.18) 0%, rgba(245,124,0,0.04) 50%, transparent 100%); border-color: #f57c00; color: #e65100; }
.announcement-danger  { background: linear-gradient(160deg, rgba(211,47,47,0.18) 0%, rgba(211,47,47,0.04) 50%, transparent 100%); border-color: #d32f2f; color: #b71c1c; }

/* Admin announcement list */
.admin-announcement-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    border-left: 4px solid transparent;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    border-radius: 4px;
    margin-bottom: 2px;
}
.admin-announcement-item:last-child { border-bottom: none; margin-bottom: 0; }
.admin-announcement-item.ann-item-info    { border-left-color: #2979ff; background: linear-gradient(160deg, rgba(41,121,255,0.12) 0%, transparent 50%); }
.admin-announcement-item.ann-item-success { border-left-color: #388e3c; background: linear-gradient(160deg, rgba(56,142,60,0.12) 0%, transparent 50%); }
.admin-announcement-item.ann-item-warning { border-left-color: #f57c00; background: linear-gradient(160deg, rgba(245,124,0,0.12) 0%, transparent 50%); }
.admin-announcement-item.ann-item-danger  { border-left-color: #d32f2f; background: linear-gradient(160deg, rgba(211,47,47,0.12) 0%, transparent 50%); }
.admin-announcement-content { flex: 1; min-width: 0; }
.admin-announcement-content .ann-title { font-weight: 600; font-size: 0.9rem; color: #e5e7eb; }
.admin-announcement-content .ann-text { font-size: 0.85rem; color: #9ca3af; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-announcement-meta { font-size: 0.75rem; color: #6b7280; white-space: nowrap; }
.admin-announcement-actions { display: flex; gap: 0.25rem; }

.nav-toggle { display: none; }

/* 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.8125rem; }
    .admin-table th, .admin-table td { padding: 0.5rem; }
    .admin-table input,
    .admin-table select { min-height: 2rem; font-size: 0.875rem; }
    .admin-table input[type="checkbox"] { min-width: 20px; min-height: 20px; }

    /* Better horizontal table scroll */
    .admin-table,
    .timing-table,
    .startlist-table,
    .results-table { -webkit-overflow-scrolling: touch; }

    /* Admin layout */
    .admin-layout { flex-direction: column; }
    .admin-nav {
        width: 100%;
        display: flex;
        overflow-x: auto;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
        padding: 0;
        background: white;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
    }
    .admin-nav a {
        white-space: nowrap;
        border-left: none;
        border-bottom: none;
        border-right: 1px solid #eee;
        padding: 0.75rem 1rem;
        min-height: 44px;
        display: flex;
        align-items: center;
        scroll-snap-align: start;
    }
    .admin-nav a.active { border-left: none; border-bottom: 2px solid #1a237e; background: transparent; }
    .nav-group[data-group="prep"] a.active { border-bottom-color: #1565c0; }
    .nav-group { display: contents; margin-bottom: 0; }
    .nav-group-header { display: none; }
    .nav-group:not(.open) > a { display: flex; }
    .admin-content { padding: 0.75rem; }
    .admin-form .form-row { flex-direction: column; gap: 0.5rem; align-items: stretch; }

    /* Toolbars — wrap buttons */
    .toolbar { flex-wrap: wrap; gap: 0.5rem; }
    .toolbar .btn { min-height: 44px; flex: 0 0 auto; }
    #drivers-section .toolbar .btn { flex: 1 1 calc(50% - 0.25rem); text-align: center; }

    /* Forms — bigger inputs */
    .admin-form input,
    .admin-form select,
    .admin-form textarea { padding: 0.625rem; font-size: 1rem; }
    .admin-form label { font-size: 0.875rem; }
    .admin-form .btn,
    .admin-section .btn { padding: 0.625rem 1rem; font-size: 0.875rem; min-height: 44px; }

    /* Section headings */
    .admin-section h2 { font-size: 1.1rem; }
    .round-group { padding: 0.75rem; }

    /* Station cards — stack vertically */
    .station-card { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
    .station-card .station-actions { width: 100%; }
    .station-card .station-actions .btn { min-height: 44px; }

    /* Modals */
    .modal-box { width: 95%; padding: 1.25rem; }
    .modal-box .modal-actions .btn { min-height: 44px; }

    /* Result tabs — horizontal scroll */
    .overview-tabs,
    .overview-subtabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
    .overview-tabs a,
    .overview-subtabs a { white-space: nowrap; flex-shrink: 0; }

    /* 10. Admin page — hamburger dropdown nav */
    .admin-page .nav-toggle {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        width: 100%;
        padding: 0.75rem 1rem;
        background: #1a1d23;
        color: #e5e7eb;
        border: none;
        border-bottom: 1px solid #2d3139;
        font-size: 0.9rem;
        font-family: inherit;
        cursor: pointer;
    }
    .admin-page .nav-toggle-icon { font-size: 1.2rem; }
    .admin-page .nav-toggle-arrow {
        margin-left: auto;
        font-size: 0.7rem;
        transition: transform 0.2s;
    }
    .admin-page .admin-nav.nav-open .nav-toggle-arrow {
        transform: rotate(180deg);
    }
    .admin-page .admin-nav {
        width: 100%;
        flex-direction: column;
        border-right: none;
        padding: 0;
        background: #1a1d23;
        overflow: visible;
        position: relative;
    }
    .admin-page .admin-nav a {
        display: none;
        color: #9ca3af;
        white-space: nowrap;
        border-left: none;
        border-bottom: 1px solid #2d3139;
        padding: 0.75rem 1rem 0.75rem 2.5rem;
        min-height: 44px;
        align-items: center;
    }
    .admin-page .admin-nav.nav-open a {
        display: flex;
    }
    .admin-page .admin-nav a.active {
        color: #fff;
        background: rgba(255,255,255,0.1);
    }
    .admin-page .nav-group-header { display: none; }
    .admin-page .nav-group { display: contents; }
    .admin-page .nav-group:not(.open) > a { display: none; }
    .admin-page .admin-nav.nav-open .nav-group:not(.open) > a { display: flex; }
    .admin-page #app-version { display: none; }
    .admin-page .admin-content { padding: 0.75rem; }
    .admin-page .admin-section h2 { font-size: 1.1rem; margin-bottom: 1rem; }
    .admin-page .round-group { padding: 0.75rem; }
    .admin-page .btn { padding: 0.625rem 1rem; min-height: 44px; }

    /* Header — wrap on mobile */
    .admin-page header { flex-direction: column; align-items: flex-start; gap: 0.4rem; }
    .admin-page header h1 { font-size: 0.95rem; }
    .header-title { flex-wrap: wrap; }

    /* Edit-mode table — hide headers on mobile, table is compact enough with 2-row layout */
    .admin-table.driver-edit-table thead { display: none; }
}

/* --- Bottom sheet (mobile time entry) --- */
.bottom-sheet-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1100;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.bottom-sheet-overlay.visible { opacity: 1; }

.bottom-sheet {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: #fff;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.15);
    padding: 0.75rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom));
    transform: translateY(100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1101;
}
.bottom-sheet-overlay.visible .bottom-sheet { transform: translateY(0); }

.bottom-sheet-handle {
    width: 36px; height: 4px;
    background: #ccc; border-radius: 2px;
    margin: 0 auto 0.75rem;
}

.bottom-sheet-header {
    display: flex; justify-content: space-between; align-items: baseline;
    margin-bottom: 1rem;
}
.bottom-sheet-driver {
    font-size: 1.15rem; font-weight: 700; color: #1a237e;
}
.bottom-sheet-cp {
    font-size: 1rem; font-weight: 600; color: #555;
    background: #f0f0f0; padding: 0.2rem 0.6rem; border-radius: 4px;
}

.bottom-sheet-body { margin-bottom: 1rem; }

.bottom-sheet-input {
    width: 100%; box-sizing: border-box;
    font-size: 1.75rem; font-family: monospace;
    padding: 0.75rem 1rem;
    border: 2px solid #1a237e; border-radius: 8px;
    text-align: center; letter-spacing: 0.05em;
    outline: none;
}
.bottom-sheet-input:focus { border-color: #3949ab; box-shadow: 0 0 0 3px rgba(57,73,171,0.2); }

.bottom-sheet-error {
    display: none; color: #c62828; font-size: 0.9rem;
    font-weight: 600; margin-top: 0.5rem; text-align: center;
}

/* Bottom sheet checkpoint indicator */
.bs-cp-indicator {
    display: flex; align-items: center; justify-content: center;
    gap: 4px; padding: 0.5rem 0; margin-bottom: 0.5rem;
    flex-wrap: wrap;
}
.bs-cp-dot {
    position: relative;
    min-width: 36px; height: 30px; border-radius: 6px;
    border: 2px solid #ccc; background: #f0f0f0; color: #999;
    font-size: 0.75rem; font-weight: 700; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    padding: 0 6px; transition: all 0.2s ease;
    margin: 10px 0;
}
.bs-cp-dot.active::before,
.bs-cp-dot.active::after {
    content: ''; position: absolute; left: 50%; transform: translateX(-50%);
    width: 0; height: 0;
    border-left: 5px solid transparent; border-right: 5px solid transparent;
}
.bs-cp-dot.active::before {
    top: -8px; border-bottom: 6px solid #888;
}
.bs-cp-dot.active::after {
    bottom: -8px; border-top: 6px solid #888;
}
.bs-cp-dot.active.filled::before { border-bottom-color: #2e7d32; }
.bs-cp-dot.active.filled::after { border-top-color: #2e7d32; }
.bs-cp-dot.filled { background: #c8e6c9; border-color: #2e7d32; color: #1b5e20; }
.bs-cp-dot.active {
    background: #fff; border-color: #888; color: #333;
    transform: scale(1.1);
    animation: bs-glow-grey 1.5s ease-in-out infinite;
}
.bs-cp-dot.active.filled {
    background: #e8f5e9; border-color: #2e7d32; color: #1b5e20;
    transform: scale(1.1);
    animation: bs-glow-green 1.5s ease-in-out infinite;
}
.bs-cp-sep { color: #bbb; font-size: 0.8rem; }

@keyframes bs-glow-grey {
    0%, 100% { box-shadow: 0 0 4px rgba(80,80,80,0.3); }
    50% { box-shadow: 0 0 14px rgba(80,80,80,0.5); }
}
@keyframes bs-glow-green {
    0%, 100% { box-shadow: 0 0 4px rgba(27,94,32,0.3); }
    50% { box-shadow: 0 0 14px rgba(27,94,32,0.5); }
}

/* Bottom sheet slide transitions */
.bs-content { transition: transform 0.15s ease, opacity 0.15s ease; }
.bs-slide-out-left { transform: translateX(-30%); opacity: 0; }
.bs-slide-out-right { transform: translateX(30%); opacity: 0; }
.bs-slide-in-right { transform: translateX(30%); opacity: 0; }
.bs-slide-in-left { transform: translateX(-30%); opacity: 0; }

.bottom-sheet-nav {
    display: flex; gap: 0.5rem;
}
.bottom-sheet-nav-btn {
    flex: 1; min-height: 48px; font-size: 1rem;
}

/* --- Mobile timing view --- */
.mob-time-header {
    display: flex; gap: 0; padding: 0.5rem 0;
    border-bottom: 2px solid var(--primary);
    font-size: 0.8rem; font-weight: 700; color: #1a237e;
}
.mob-th { flex: 0 0 40px; text-align: center; cursor: pointer; user-select: none; }
.mob-th-name { flex: 1; text-align: left; padding-left: 0.25rem; }

.mob-class-sep {
    font-weight: 700; font-size: 0.85rem; color: var(--primary);
    padding: 0.6rem 0.25rem 0.2rem; border-bottom: 1px solid var(--primary);
}

.mob-driver-row {
    display: flex; align-items: center; gap: 0;
    padding: 0.6rem 0; border-bottom: 1px solid #eee;
    cursor: pointer; -webkit-tap-highlight-color: rgba(26,35,126,0.1);
}
.mob-driver-row:active { background: #e8eaf6; }
.mob-driver-row.mob-inactive { opacity: 0.5; }

.mob-cell { flex: 0 0 40px; text-align: center; font-size: 0.85rem; }
.mob-cell-name { flex: 1; text-align: left; padding-left: 0.25rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mob-cell-tid { flex: 0 0 72px; text-align: right; font-size: 0.8rem; font-family: monospace; padding-right: 0.25rem; color: #666; line-height: 1.2; }
.mob-th-tid { flex: 0 0 72px; text-align: right; padding-right: 0.25rem; }
.mob-tid-diff { font-size: 0.65rem; color: #888; font-weight: 400; }
.mob-ui-icon { color: #e65100; font-size: 0.75rem; margin-right: 0.15rem; }
.mob-status-done { color: #2e7d32; font-weight: 600; }
.mob-status-inactive { color: #c62828; font-weight: 600; }
.mob-cell-info { flex: 0 0 32px; text-align: center; font-size: 0.6rem; color: #666; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding-right: 0.15rem; }
.mob-th-info { flex: 0 0 32px; }
.mob-info-penalty { color: #e65100; font-weight: 600; white-space: nowrap; }
.mob-info-flag { color: #555; font-weight: 600; }

/* Driver card */
.mob-card { padding: 0.5rem 0; }
.mob-card-header { margin-bottom: 1rem; }
.mob-back-btn { font-size: 0.85rem; padding: 0.4rem 0.75rem; margin-bottom: 0.5rem; }
.mob-card-title { display: flex; align-items: baseline; gap: 0.5rem; }
.mob-card-nr { font-size: 1.5rem; font-weight: 700; color: #1a237e; }
.mob-card-name { font-size: 1.25rem; font-weight: 600; }
.mob-card-class { font-size: 0.85rem; color: #666; }

/* Checkpoint row */
.mob-cp-row {
    display: flex; align-items: center; justify-content: center;
    gap: 0.25rem; flex-wrap: wrap; margin-bottom: 1rem;
    padding: 0.75rem; background: #f5f5f5; border-radius: 8px;
}
.mob-cp-item { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.mob-cp-btn {
    min-width: 44px; min-height: 44px; border-radius: 8px;
    border: 2px solid #bbb; background: #fff; color: #666;
    font-size: 0.85rem; font-weight: 700; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.mob-cp-btn.filled { background: #c8e6c9; border-color: #2e7d32; color: #1b5e20; }
.mob-cp-btn:active { transform: scale(0.95); }
.mob-cp-time { font-size: 0.7rem; font-family: monospace; color: #555; }
.mob-cp-arrow { color: #999; font-size: 0.9rem; margin: 0 2px; align-self: flex-start; margin-top: 12px; }

/* Total */
.mob-card-total {
    display: flex; align-items: baseline; gap: 0.5rem;
    padding: 0.75rem; background: #e8eaf6; border-radius: 8px;
    margin-bottom: 1rem;
}
.mob-card-total-label { font-weight: 600; color: #1a237e; }
.mob-card-total-time { font-size: 1.25rem; font-weight: 700; font-family: monospace; }
.mob-card-elapsed { font-size: 0.8rem; color: #666; }

/* Fields */
.mob-card-fields { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 1rem; }
.mob-field-row { display: flex; align-items: center; gap: 0.75rem; }
.mob-field-row label { flex: 0 0 80px; font-size: 0.85rem; font-weight: 600; color: #555; }
.mob-field-input { flex: 1; font-size: 1rem; padding: 0.5rem; min-height: 44px; }
.mob-flags { display: flex; gap: 0.5rem; }
.mob-flag { min-width: 44px; min-height: 44px; font-size: 0.95rem; }

/* Card nav */
.mob-card-nav { display: flex; gap: 0.5rem; }
.mob-nav-btn { flex: 1; min-height: 48px; font-size: 1rem; }
