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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 0.85rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-image: url('/images/background-hyundai.jpg');
    background-size: cover;
    background-attachment: fixed;
    background-position: center;
    min-height: 100vh;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.3);
    z-index: -1;
    pointer-events: none;
}

/* ============= Login Page Styles ============= */
body.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
}

.login-container {
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 400px;
}

.login-container h2 {
    color: #333;
    margin-bottom: 30px;
    text-align: center;
    font-size: 28px;
}

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-weight: 500;
    font-size: 14px;
}

input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    transition: border-color 0.3s;
    font-family: inherit;
}

input[type="text"]:focus,
input[type="password"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 5px rgba(102, 126, 234, 0.3);
}

button {
    /* width: 100%; */
    padding: 0.75rem;
    display: inline;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
}

button:hover {
    transform: translateY(-2px);
}

button:active {
    transform: translateY(0);
}

button.inline {
    padding: 3px 7px;
}

.alert {
    padding: 12px 15px;
    margin-bottom: 20px;
    border-radius: 5px;
    font-size: 14px;
}

.alert-danger {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.alert-success {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.demo-info {
    margin-top: 25px;
    padding: 15px;
    background-color: #f5f5f5;
    border-left: 4px solid #667eea;
    border-radius: 5px;
    font-size: 13px;
}

.demo-info strong {
    display: block;
    margin-bottom: 8px;
    color: #333;
}

.demo-info code {
    background-color: #e8e8e8;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    color: #555;
}

/* ============= Error Page Styles ============= */
body.error-page {
    display: flex;
    justify-content: center;
    align-items: center;
}

.error-container {
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 500px;
    text-align: center;
}

.error-container h1 {
    color: #d32f2f;
    margin-bottom: 20px;
}

.error-container p {
    color: #555;
    margin-bottom: 30px;
    line-height: 1.6;
}

.error-container a {
    display: inline-block;
    padding: 12px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-decoration: none;
    border-radius: 5px;
    transition: transform 0.2s;
}

.error-container a:hover {
    transform: translateY(-2px);
}

/* ============= Home Page Styles ============= */
body.home-page {
    padding: 10px;
}

.navbar {
    /* white card with a thin gradient strip on top */
    background: linear-gradient(90deg, #667eea, #764ba2) top / 100% 4px no-repeat, white;
    padding: 14px 18px 12px;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    min-width: 0;
}

.brand-icon {
    flex: none;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    box-shadow: 0 3px 8px rgba(102, 126, 234, 0.4);
}

.brand-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.brand-label {
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #999;
    font-weight: 600;
}

.brand-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: #334bb8;
    line-height: 1.2;
}

.brand-title.muted {
    color: #aaa;
    font-weight: 500;
    font-style: italic;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px 4px 4px;
    border-radius: 999px;
    background: #f4f5fb;
    color: #444;
    font-weight: 500;
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 700;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logout-btn {
    padding: 7px 16px;
    background: white;
    color: #dc3545;
    border: 1px solid #f1b0b7;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: background 0.2s, color 0.2s;
}

.logout-btn:hover {
    background: #dc3545;
    color: white;
    transform: none;
}

.main-card {
    background: white;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.main-card h2, .main-card h3 {
    color: #333;
    margin-bottom: 15px;
}

.main-card h2 {
    color: #667eea;
    display: flex;
    align-items: center;
    gap: 10px;
}

.main-card p {
    color: #666;
    line-height: 1.6;
    margin-bottom: 10px;
}

.no-rally-card {
    text-align: center;
    padding: 40px 20px;
    max-width: 640px;
    margin: 40px auto;
}

.main-card.no-rally-card h2 {
    justify-content: center;
    font-size: 26px;
}

.no-rally-icon {
    font-size: 56px;
    margin-bottom: 10px;
}

.no-rally-refresh {
    margin-top: 25px;
}

.refresh-btn {
    padding: 10px 28px;
    background: #334bb8;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 500;
    font-size: 15px;
    transition: background 0.3s;
}

.refresh-btn:hover {
    background: #263a94;
}

.main-card p.no-rally-hint {
    color: #999;
    font-size: 14px;
    margin-top: 20px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.info-card {
    background: white;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.info-card h3 {
    color: #667eea;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.info-card ul {
    list-style: none;
    color: #555;
}

.info-card li {
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

.info-card li:last-child {
    border-bottom: none;
}

/* ============= Stage toolbar ============= */
.stage-toolbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.stage-picker {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1 1 360px;
    max-width: 560px;
}

label.stage-label {
    margin: 0;
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #999;
    font-weight: 600;
}

.stage-select-row {
    display: flex;
    align-items: stretch;
    gap: 6px;
}

select.stage-selector {
    flex: 1;
    min-width: 0;
    appearance: none;
    -webkit-appearance: none;
    padding: 9px 36px 9px 12px;
    border: 1px solid #c9cdee;
    border-radius: 8px;
    background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23667eea' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 12px center;
    color: #222;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

select.stage-selector:hover { border-color: #667eea; }

select.stage-selector:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.25);
}

button.stage-step {
    flex: none;
    width: 38px;
    padding: 0;
    border: 1px solid #c9cdee;
    border-radius: 8px;
    background: white;
    color: #667eea;
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1;
}

button.stage-step:hover:not(:disabled) {
    background: #eef0fc;
    border-color: #667eea;
    transform: none;
}

button.stage-step:disabled {
    color: #ccd0e3;
    cursor: default;
    transform: none;
}

button.results-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    font-size: 0.9rem;
    box-shadow: 0 3px 8px rgba(102, 126, 234, 0.35);
}

.results-btn-icon { font-size: 0.95rem; }

.results-btn-ext {
    font-size: 0.7rem;
    font-weight: 600;
    opacity: 0.8;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    padding: 1px 5px;
}

.loading-line {
    color: #888;
    font-style: italic;
    margin-bottom: 8px;
}

.error-line {
    background: #f8d7da;
    color: #721c24;
    border-radius: 6px;
    padding: 9px 12px;
    margin-bottom: 10px;
}

.badge {
    display: inline-block;
    padding: 4px 12px;
    background: #667eea;
    color: white;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.success-icon {
    color: #28a745;
    font-size: 20px;
}

/* ============= Results table ============= */
.results-scroll {
    margin-top: 1rem;
    border: 1px solid #e1e4ee;
    border-radius: 10px;
    /* the table scrolls inside this box (both ways), so headers and first columns can stay frozen */
    max-height: calc(100vh - 210px);
    min-height: 260px;
}

table.results-table {
    border-collapse: separate; /* keeps borders on sticky cells */
    border-spacing: 0;
    min-width: 100%;
    --crew-col-w: 230px; /* set from JS to the real crew column width */
}

.results-table th, .results-table td {
    border-right: 1px solid #eceef5;
    border-bottom: 1px solid #e6e8f0;
    padding: 6px 10px;
    text-align: center;
    font-size: 0.75rem;
    line-height: 1.35;
}

.results-table th {
    background: #f4f5fb;
    color: #555;
    font-weight: normal;
    border-bottom: 2px solid #d9dcef;
    position: sticky;
    top: 0;
    z-index: 10;
}

.results-table th strong { color: #333; }

/* the crew and result columns stay frozen on the left; headers stay frozen on top */
.results-table th:first-child,
.results-table td:first-child {
    position: sticky;
    left: 0;
    text-align: left;
}
.results-table th:nth-child(2),
.results-table td:nth-child(2) {
    position: sticky;
    left: var(--crew-col-w);
    box-shadow: 4px 0 6px -4px rgba(0, 0, 0, 0.18);
}
.results-table th:first-child,
.results-table th:nth-child(2) { z-index: 11; }
.results-table td:first-child,
.results-table td:nth-child(2) { z-index: 8; }

.results-table th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.results-table th.sortable:hover { background: #e4e7f5; }
.results-table th .sort-arrow { color: #667eea; font-size: 0.7rem; margin-left: 2px; }

.results-table td { background: white; color: #333; }
.results-table td strong { font-size: 0.85rem; color: #222; }

/* subtle zebra rows and row hover; early / exact / late cells keep their colours */
.results-table tbody tr:nth-child(even) td:not(.sign-early):not(.sign-equal):not(.sign-late):not(.result-cell) { background: #fafbfe; }
.results-table tbody tr:hover td:not(.sign-early):not(.sign-equal):not(.sign-late) { background: #eef1fd; }
.results-table tbody tr:hover td { box-shadow: inset 0 1px 0 #d9def7, inset 0 -1px 0 #d9def7; }
.results-table tbody tr:hover td:nth-child(2) { box-shadow: inset 0 1px 0 #d9def7, inset 0 -1px 0 #d9def7, 4px 0 6px -4px rgba(0, 0, 0, 0.18); }

.results-table td.sign-early { background-color: #FFB3BA; }
.results-table td.sign-equal { background-color: #C8E6C9; }
.results-table td.sign-late  { background-color: #FFF9C4; }

/* crew cell: start number badge | names / car */
.results-table td.crew-cell { padding: 6px 12px 6px 8px; min-width: 210px; }

.crew-link {
    display: flex;
    align-items: center;
    gap: 10px;
}

.crew-nr {
    flex: none;
    min-width: 32px;
    height: 28px;
    padding: 0 6px;
    border-radius: 6px;
    background: #334bb8;
    color: white;
    font-weight: 700;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-variant-numeric: tabular-nums;
}

/* start numbers with letters (e.g. R3) get a different colour */
.crew-nr.crew-nr-alt { background: #764ba2; }

.crew-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.crew-names { white-space: nowrap; }
.crew-ini { color: #999; }
.crew-surname { color: #222; font-weight: 600; }
.crew-sep { color: #c3c7d6; margin: 0 6px; }

.crew-car {
    color: #8a8fa3;
    font-size: 0.7rem;
    margin-top: 1px;
}

/* stage result column */
.results-table td.result-cell { background: #f6f7fd; }
.results-table td.result-cell strong { font-size: 0.95rem; color: #334bb8; }

dialog {
    margin: revert;
    /* padding: 1rem; */
    border-radius: 0.75rem;
    min-width: 45vw;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
    border-width: 2px;

    /* z-index: 10; */
}

dialog::backdrop {
    /* background-color: hsl(229, 60%, 50%, 0.3); */
    background-color: rgba(0, 0, 0, 0.5);
}

dialog div.buttons {
    width: 100%;
    text-align: right;
}

dialog h1 {
    background-color: #667eea;
    color: white;
    padding: 0.5rem;
    font-size: 1.25rem;
}

dialog .modal-error {
    background: red;
    color: yellow;
}

dialog .modal-container {
    padding: 0.5rem;
}

.modal-crew {
    display: inline-block;
}

.modal-crew h2, .modal-crew h3 {
    text-align: right;
    margin: 0;
}

.modal-crew h2 {
    color: #333333;
}

.modal-crew h3 {
    color: #555555;
}

a.no-link {
    text-decoration: unset;
    color: black;
}

span.start-number {
    /* background-color: #667eea; */
    /* color: white; */
    /* padding: 1px; */
}

form.upload-form {
    margin-top: 1rem;
}

.status-message {
    padding: 12px;
    border-radius: 4px;
    display: none;
}

.status-message.success {
    background-color: #d4edda;
    color: #155724;
    display: block;
}

.status-message.error {
    background-color: #f8d7da;
    color: #721c24;
    display: block;
}

.status-message.loading {
    background-color: #d1ecf1;
    color: #0c5460;
    display: block;
}


/* ============= Start time edit dialog ============= */
dialog.modal-start-time {
    padding: 0;
    border: none;
    border-radius: 12px;
    min-width: 0;
    width: min(520px, calc(100vw - 32px));
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
    overflow: hidden;
}

.modal-start-time .st-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
}

.modal-start-time .st-title {
    font-size: 1.2rem;
    font-weight: 600;
}

.modal-start-time .st-stage {
    font-size: 0.9rem;
    opacity: 0.9;
    margin-top: 2px;
}

.modal-start-time .st-body {
    padding: 18px 20px 8px;
}

.modal-start-time .st-crew {
    display: flex;
    align-items: center;
    gap: 14px;
    padding-bottom: 14px;
    margin-bottom: 16px;
    border-bottom: 1px solid #eee;
}

.modal-start-time .st-start-nr {
    min-width: 44px;
    height: 44px;
    padding: 0 8px;
    border-radius: 8px;
    background: #334bb8;
    color: white;
    font-size: 1.2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-start-time .st-crew-names {
    font-size: 1rem;
    font-weight: 600;
    color: #333;
}

.modal-start-time .st-crew-car {
    color: #777;
    margin-top: 2px;
}

.modal-start-time .st-grid {
    display: grid;
    grid-template-columns: auto 1fr 1fr;
    gap: 10px 12px;
    align-items: center;
}

.modal-start-time .st-col-head {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #999;
}

.modal-start-time .st-row-label {
    margin: 0;
    color: #555;
    font-weight: 600;
    font-size: 0.85rem;
}

.modal-start-time .st-readonly,
.modal-start-time input.st-input {
    width: 100%;
    padding: 9px 10px;
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
}

.modal-start-time .st-readonly {
    background: #f4f5f9;
    border: 1px solid #e6e8f0;
    color: #666;
}

.modal-start-time input.st-input {
    border: 1px solid #c9cdee;
    background: white;
    color: #222;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.modal-start-time input.st-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.25);
}

.modal-start-time .st-date-wrap {
    position: relative;
}

.modal-start-time .st-date-wrap input.st-input {
    padding-right: 38px;
}

.modal-start-time .st-cal-btn {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    padding: 4px 6px;
    background: none;
    border-radius: 4px;
    font-size: 1rem;
    line-height: 1;
    opacity: 0.7;
}

.modal-start-time .st-cal-btn:hover {
    background: #eef0f6;
    opacity: 1;
    transform: translateY(-50%);
}

/* hidden native date field: only its calendar popup is used */
.modal-start-time .st-date-picker {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 0;
    padding: 0;
    border: 0;
    opacity: 0;
    pointer-events: none;
}

.modal-start-time .st-time {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.modal-start-time .st-error {
    background: #f8d7da;
    color: #721c24;
    border-radius: 6px;
    padding: 9px 12px;
    margin-bottom: 14px;
}

.modal-start-time .st-empty {
    background: #fff8e1;
    color: #7a5b00;
    border-radius: 6px;
    padding: 12px;
}

.modal-start-time .st-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px 18px;
}

.modal-start-time .st-footer button {
    padding: 9px 20px;
    font-size: 0.95rem;
}

.modal-start-time .st-btn-secondary {
    background: #eef0f6;
    color: #444;
}

.modal-start-time button:disabled {
    opacity: 0.55;
    cursor: default;
    transform: none;
}

@media (max-width: 480px) {
    .modal-start-time .st-grid {
        grid-template-columns: 1fr 1fr;
    }
    .modal-start-time .st-grid > div:first-child {
        display: none;
    }
    .modal-start-time .st-row-label {
        grid-column: 1 / -1;
        margin-top: 4px;
    }
}

/* ============= Stage point result dialog (reuses the start time dialog styles) ============= */
dialog.modal-point-result {
    width: min(1040px, calc(100vw - 32px));
    overflow: auto; /* taller than small screens: allow scrolling */
}

.modal-point-result .pr-work {
    display: grid;
    grid-template-columns: minmax(300px, 400px) 1fr;
    gap: 0;
    border-bottom: 1px solid #eee;
}

.modal-point-result .pr-left {
    padding: 18px 20px 14px;
    border-right: 1px solid #eee;
}

.modal-point-result .pr-right {
    position: relative;
    display: flex;
    flex-direction: column;
    background: #f7f8fc;
    min-height: 380px;
}

.modal-point-result .pr-facts {
    background: #f7f8fc;
    border: 1px solid #e6e8f0;
    border-radius: 8px;
    padding: 4px 12px;
    margin-bottom: 16px;
}

.modal-point-result .pr-fact {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 7px 0;
    border-bottom: 1px dashed #e1e4ee;
}

.modal-point-result .pr-fact:last-child {
    border-bottom: none;
}

.modal-point-result .pr-fact-label {
    color: #777;
    font-size: 0.8rem;
    white-space: nowrap;
}

.modal-point-result .pr-fact-value {
    text-align: right;
    color: #333;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.modal-point-result .pr-fact-sub {
    display: block;
    color: #999;
    font-weight: normal;
    font-size: 0.75rem;
}

.modal-point-result .pr-tag {
    display: inline-block;
    margin-left: 4px;
    padding: 1px 6px;
    border-radius: 4px;
    background: #fff3cd;
    color: #8a6d00;
    font-size: 0.7rem;
    font-weight: 600;
    vertical-align: 1px;
}

.modal-point-result .pr-hint {
    margin-top: 12px;
    color: #999;
    font-size: 0.75rem;
    line-height: 1.4;
}

.modal-point-result .pr-map {
    flex: 1;
    min-height: 340px;
}

.modal-point-result .pr-map-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    padding: 8px 12px;
    border-top: 1px solid #e6e8f0;
    background: white;
}

.modal-point-result .pr-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    color: #555;
    font-size: 0.75rem;
}

.modal-point-result .pr-legend span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.modal-point-result .lg {
    display: inline-block;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
}

.modal-point-result .lg-target  { background: #dc3545; }
.modal-point-result .lg-before  { background: #2f6fdb; }
.modal-point-result .lg-closest { background: #1e9e4a; }
.modal-point-result .lg-after   { background: #f08c00; }

.modal-point-result .pr-track-btn {
    padding: 6px 12px;
    font-size: 0.8rem;
    background: #eef0f6;
    color: #334bb8;
}

.modal-point-result .pr-map-msg {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: rgba(255, 248, 225, 0.95);
    color: #7a5b00;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.8rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    white-space: nowrap;
}

@media (max-width: 760px) {
    .modal-point-result .pr-work {
        grid-template-columns: 1fr;
    }
    .modal-point-result .pr-left {
        border-right: none;
        border-bottom: 1px solid #eee;
    }
    .modal-point-result .pr-right,
    .modal-point-result .pr-map {
        min-height: 280px;
    }
}

/* ============= GPS file upload dialog (reuses the start time dialog styles) ============= */
.modal-gps-file .gf-warning {
    background: #fff8e1;
    color: #7a5b00;
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 14px;
    line-height: 1.45;
}

.modal-gps-file form.upload-form {
    margin-top: 0;
}

.modal-gps-file .gf-drop {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin: 0;
    padding: 26px 16px;
    border: 2px dashed #c9cdee;
    border-radius: 10px;
    background: #f7f8fc;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.modal-gps-file .gf-drop:hover,
.modal-gps-file .gf-drop.gf-drag {
    border-color: #667eea;
    background: #eef0fc;
}

.modal-gps-file .gf-drop.gf-chosen {
    border-style: solid;
    border-color: #1e9e4a;
    background: #f1faf4;
}

.modal-gps-file .gf-icon {
    font-size: 2rem;
    line-height: 1;
}

.modal-gps-file .gf-main {
    color: #333;
    font-weight: 600;
    font-size: 0.95rem;
    word-break: break-all;
}

.modal-gps-file .gf-sub {
    color: #999;
    font-size: 0.75rem;
    font-weight: normal;
}

/* the real file input stays in the form, but hidden: the label opens it */
.modal-gps-file .gf-drop input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.modal-gps-file .status-message {
    margin-top: 14px;
    border-radius: 6px;
}

/* manual (referee) point result in the table */
em.manual-mark {
    color: #8a6d00;
    font-size: 0.7rem;
}

/* ============= Result warnings ============= */
.results-table td.has-warning {
    box-shadow: inset 0 0 0 2px #f08c00;
}

.warn-mark {
    display: inline-block;
    margin-left: 3px;
    color: #e67700;
    font-size: 0.85rem;
    cursor: help;
}

.warn-mark.warn-checked {
    color: #b5b9c9;
}

button.warn-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    padding: 9px 14px;
    font-size: 0.85rem;
    background: #fff4e0;
    color: #a35a00;
    border: 1px solid #f5c26b;
}

button.warn-filter-btn.active {
    background: #f08c00;
    color: white;
    border-color: #f08c00;
}

button.warn-filter-btn.all-checked {
    background: #f1faf4;
    color: #1e7a3c;
    border-color: #a8dcb8;
}

.warn-filter-x {
    font-size: 0.7rem;
    opacity: 0.85;
    text-decoration: underline;
}

.modal-point-result .pr-warnings {
    background: #fff4e0;
    border: 1px solid #f5c26b;
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 14px;
}

.modal-point-result .pr-warnings-title {
    color: #a35a00;
    font-weight: 700;
    margin-bottom: 4px;
}

.modal-point-result .pr-warning {
    color: #7a4a00;
    font-size: 0.8rem;
    line-height: 1.4;
    padding-left: 10px;
    position: relative;
}

.modal-point-result .pr-warning::before {
    content: "•";
    position: absolute;
    left: 0;
}

/* ============= Replay dialog (reuses the start time dialog styles) ============= */
.results-table td.result-cell.clickable { cursor: pointer; }
.results-table td.result-cell.clickable:hover { background: #e6eafc; }

dialog.modal-replay {
    width: min(1100px, calc(100vw - 32px));
    overflow: auto;
}

.modal-replay .rp-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-replay .rp-nr {
    background: rgba(255, 255, 255, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.modal-replay .rp-head-text { min-width: 0; }

.modal-replay .rp-map-wrap {
    position: relative;
    background: #f7f8fc;
}

.modal-replay .rp-map {
    height: min(58vh, 560px);
    min-height: 300px;
}

.modal-replay .rp-controls {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    padding: 10px 16px;
    border-top: 1px solid #e6e8f0;
}

.modal-replay button.rp-play {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-replay button.rp-play:disabled { opacity: 0.5; transform: none; }

.modal-replay .rp-speeds {
    display: inline-flex;
    border: 1px solid #c9cdee;
    border-radius: 8px;
    overflow: hidden;
}

.modal-replay button.rp-speed {
    padding: 6px 10px;
    border-radius: 0;
    background: white;
    color: #334bb8;
    font-size: 0.8rem;
    border-right: 1px solid #e1e4ee;
}

.modal-replay button.rp-speed:last-child { border-right: none; }
.modal-replay button.rp-speed:hover { transform: none; background: #eef0fc; }
.modal-replay button.rp-speed.active { background: #334bb8; color: white; }

.modal-replay .rp-readout {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
}

.modal-replay .rp-readout > div {
    display: flex;
    flex-direction: column;
}

.modal-replay .rp-label {
    font-size: 0.65rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #999;
    font-weight: 600;
}

.modal-replay .rp-value {
    font-size: 1rem;
    font-weight: 700;
    color: #222;
    font-variant-numeric: tabular-nums;
    min-width: 6.5em;
}

.modal-replay label.rp-follow {
    margin: 0 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: #555;
    cursor: pointer;
}

.modal-replay .rp-timeline { padding: 4px 16px 6px; }

.modal-replay .rp-track-area {
    position: relative;
    height: 56px;
}

.modal-replay canvas.rp-chart {
    position: absolute;
    left: 8px;
    right: 8px;
    top: 0;
    width: calc(100% - 16px);
    height: 40px;
    border-radius: 6px;
    background: #f4f5fb;
}

.modal-replay .rp-ticks {
    position: absolute;
    left: 8px;
    right: 8px;
    top: 0;
    height: 40px;
    pointer-events: none;
}

.modal-replay .rp-tick {
    position: absolute;
    top: 0;
    width: 3px;
    height: 40px;
    margin-left: -1px;
    border-radius: 2px;
    background: #8a8fa3;
    cursor: pointer;
    pointer-events: auto;
}

.modal-replay .rp-tick:hover { width: 5px; margin-left: -2px; }
.modal-replay .rp-tick.early { background: #e03131; }
.modal-replay .rp-tick.exact { background: #2f9e44; }
.modal-replay .rp-tick.late  { background: #f08c00; }

.modal-replay input.rp-slider {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    margin: 0;
    accent-color: #334bb8;
    cursor: pointer;
}

.modal-replay .rp-ends {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 0.72rem;
    color: #888;
    font-variant-numeric: tabular-nums;
}

.modal-replay .rp-hint {
    text-align: center;
    color: #aaa;
}

/* moving car marker on the map (Leaflet divIcon) */
.rp-car-icon { background: none; border: none; }

.rp-car {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #334bb8;
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
    color: white;
    font-weight: 700;
    font-size: 0.72rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 640px) {
    .modal-replay .rp-hint { display: none; }
    .modal-replay label.rp-follow { margin-left: 0; }
}

dialog.modal-replay:focus { outline: none; }

/* ============= Replay: ideal car (ghost) ============= */
.rp-ghost {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.8);
    border: 3px dashed #764ba2;
    color: #764ba2;
    font-weight: 800;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.3);
}

.modal-replay .rp-vs { min-width: 5.5em; }
.modal-replay .rp-vs.exact { color: #2f9e44; }
.modal-replay .rp-vs.early { color: #e03131; }
.modal-replay .rp-vs.late  { color: #e67700; }
.modal-replay .rp-vs.off   { color: white; background: #e03131; border-radius: 4px; padding: 0 6px; font-size: 0.85rem; }

.modal-replay .rp-ghost-ctrl {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 0.8rem;
    color: #555;
}

.modal-replay label.rp-check {
    margin: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-weight: normal;
    font-size: 0.8rem;
}

.modal-replay .rp-ghost-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px dashed #764ba2;
    color: #764ba2;
    font-weight: 800;
    font-size: 0.65rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.modal-replay select.rp-ref {
    padding: 4px 8px;
    border: 1px solid #c9cdee;
    border-radius: 6px;
    font-size: 0.8rem;
    font-family: inherit;
    background: white;
}

.modal-replay .rp-ghost-note { color: #a35a00; }
