.table-box th:nth-child(6),
.table-box td:nth-child(6) {
    min-width: 420px;
}

#debugLog:focus {
    outline: 2px solid #ef4444;
    outline-offset: 3px;
}

#debugLog {
    grid-column: 1 / -1;
    width: auto;
    min-width: 0;
}

.login-benefit {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 390px;
    margin-top: 10px;
    padding: 11px 13px;
    border: 1px solid #ffd19a;
    border-radius: 10px;
    background: linear-gradient(135deg, #fff8ef 0%, #fff0dc 100%);
    box-shadow: 0 5px 14px rgba(168, 84, 0, .10);
    color: #7d3f00;
    font-size: 12px;
    line-height: 1.4;
}

.login-benefit-icon {
    display: grid;
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    place-items: center;
    border-radius: 50%;
    background: var(--orange);
    box-shadow: 0 3px 8px rgba(247, 148, 30, .30);
    color: #fff;
    font-size: 17px;
}

body.ai-login-modal-open {
    overflow: hidden;
}

.ai-login-modal {
    position: fixed;
    z-index: 10000;
    inset: 0;
    display: grid;
    padding: 20px;
    place-items: center;
    background: rgba(11, 16, 32, .62);
    backdrop-filter: blur(4px);
}

.ai-login-dialog {
    position: relative;
    width: min(440px, calc(100vw - 40px));
    padding: 26px;
    border: 1px solid #ffd19a;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 24px 70px rgba(11, 16, 32, .30);
    animation: ai-login-enter .18s ease-out;
}

.ai-login-close {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #777;
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
}

.ai-login-close:hover,
.ai-login-close:focus-visible {
    background: #fff4e6;
    color: #a85400;
}

.ai-login-heading {
    display: flex;
    align-items: center;
    gap: 11px;
    padding-right: 32px;
}

.ai-login-heading h2 {
    margin: 0;
    color: #333;
    font-size: 20px;
}

.ai-login-heading-icon {
    display: grid;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    place-items: center;
    border-radius: 50%;
    background: var(--orange);
    box-shadow: 0 5px 14px rgba(247, 148, 30, .32);
    color: #fff;
    font-size: 20px;
}

#aiLoginDescription {
    margin: 16px 0;
    color: #555;
    font-size: 14px;
    line-height: 1.55;
}

.ai-login-privacy {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 13px;
    border: 1px solid #cde9d6;
    border-radius: 10px;
    background: #f2fbf5;
    color: #27623a;
    font-size: 12px;
    line-height: 1.5;
}

.ai-login-lock {
    flex: 0 0 auto;
    font-size: 17px;
}

.ai-login-actions {
    display: flex;
    justify-content: flex-end;
    gap: 9px;
    margin-top: 20px;
}

@keyframes ai-login-enter {
    from {
        opacity: 0;
        transform: translateY(8px) scale(.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (max-width: 520px) {
    .ai-login-dialog {
        padding: 22px 18px 18px;
    }

    .ai-login-actions {
        flex-direction: column-reverse;
    }

    .ai-login-actions .btn {
        width: 100%;
    }
}

.developed-by {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 18px;
    padding: 18px 0 8px;
    border-top: 1px solid #eee;
    color: #888;
    font-size: 11px;
}

.developed-by a {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 10px 5px 7px;
    border: 1px solid #eee;
    border-radius: 999px;
    background: linear-gradient(135deg, #fff 0%, #fff8f0 100%);
    box-shadow: 0 3px 10px rgba(74, 74, 74, .08);
    color: var(--gray);
    text-decoration: none;
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.developed-by a:hover,
.developed-by a:focus-visible {
    border-color: #ffc47c;
    box-shadow: 0 5px 14px rgba(247, 148, 30, .18);
    transform: translateY(-1px);
}

.developed-by img {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.footer-tagline {
    margin: 2px 0 10px;
    color: #999;
    font-size: 10px;
    line-height: 1.35;
    text-align: center;
}

#debugLog.debug-error-attention {
    animation: debug-error-pulse .3s ease-in-out 6 alternate;
}

@keyframes debug-error-pulse {
    from {
        border-color: #333;
        background: #0b1020;
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
    to {
        border-color: #ff6b6b;
        background: #29101a;
        box-shadow: 0 0 0 5px rgba(239, 68, 68, .28);
    }
}

.table-box table.controles {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
}

.table-box table.controles td {
    width: auto;
    min-width: 0;
    padding: 4px 6px !important;
    text-align: center !important;
    vertical-align: middle;
    white-space: nowrap;
}

.table-box th:nth-child(6) > table.controles,
.table-box td:nth-child(6) > table.controles {
    margin: 0;
}

.table-box table.controles td.calculated-time {
    text-decoration: line-through;
    text-decoration-thickness: 1.5px;
}

.table-box table.controles td[data-elapsed-time]::after {
    content: attr(data-elapsed-time);
    display: block;
    margin-top: 2px;
    color: #888;
    font-size: 9px;
    font-weight: 500;
    line-height: 1.1;
}

.table-box td[data-pace-unit]::after {
    content: attr(data-pace-unit);
    display: block;
    margin-top: 2px;
    color: #888;
    font-size: 9px;
    font-weight: 600;
    line-height: 1.1;
}

.ai-analysis-actions {
    display: flex;
    gap: 8px;
    margin: 0 0 12px;
    flex-wrap: wrap;
}

.language-picker {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-left: 8px;
    color: #666;
    font-size: 11px;
    font-weight: 700;
}

.language-picker select {
    width: auto;
    padding: 7px 28px 7px 9px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--gray);
    font: inherit;
}

html[lang="es"] #debugLog::before {
    content: "Consola de depuración";
}

#analyzeAiBtn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.ai-button-icon {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
}

.ai-analysis-card {
    margin: 0 0 18px;
    border-left: 4px solid var(--orange);
}

.ai-analysis-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.ai-analysis-header-icon {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: 50%;
    background: #fff4e6;
    color: var(--orange);
}

.ai-analysis-header-icon .ai-button-icon {
    width: 19px;
    height: 19px;
}

.ai-processing {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 52px;
}

.ai-processing-spinner {
    width: 24px;
    height: 24px;
    flex: 0 0 auto;
    border: 3px solid #ffe0bf;
    border-top-color: var(--orange);
    border-radius: 50%;
    animation: ai-spin .8s linear infinite;
}

.ai-processing-title {
    margin-bottom: 3px;
    font-weight: 700;
}

.ai-processing-elapsed {
    margin-top: 4px;
    color: #a85400;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

@keyframes ai-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .ai-processing-spinner {
        animation: none;
    }

    #debugLog.debug-error-attention {
        animation: none;
        border-color: #ff6b6b;
        background: #29101a;
        box-shadow: 0 0 0 4px rgba(239, 68, 68, .28);
    }
}

.ai-analysis-text {
    margin-top: 10px;
    line-height: 1.5;
}

.ai-analysis-text h4 {
    margin: 16px 0 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid #eee;
    color: #333;
    font-size: 14px;
}

.ai-analysis-text h4:first-child {
    margin-top: 10px;
}

.ai-analysis-text p {
    margin: 6px 0;
}

.ai-analysis-text ul,
.ai-analysis-text ol {
    margin: 6px 0 10px;
    padding-left: 22px;
}

.ai-analysis-text li {
    margin: 4px 0;
}

.ai-flags-title {
    margin-top: 12px;
    font-weight: 700;
}

.ai-flags {
    display: grid;
    gap: 8px;
    margin: 8px 0 12px;
}

.ai-flag {
    padding: 9px 10px;
    border: 1px solid #ddd;
    border-left-width: 4px;
    border-radius: 6px;
    background: #fff;
}

.ai-flag-low {
    border-left-color: #eab308;
}

.ai-flag-medium {
    border-left-color: #f97316;
}

.ai-flag-high {
    border-left-color: #dc2626;
}

.ai-flag-athlete {
    font-weight: 700;
}

.ai-flag-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.ai-severity {
    flex: 0 0 auto;
    padding: 2px 6px;
    border-radius: 999px;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .04em;
}

.ai-severity-low {
    background: #fef9c3;
    color: #854d0e;
}

.ai-severity-medium {
    background: #ffedd5;
    color: #9a3412;
}

.ai-severity-high {
    background: #fee2e2;
    color: #991b1b;
}

.ai-flag-doubt {
    margin-top: 6px;
    color: #333;
}

.ai-flag-evidence,
.ai-no-flags {
    margin-top: 3px;
    color: #666;
    font-size: 12px;
}

.ai-evidence-label {
    font-weight: 700;
    color: #555;
}

.ai-structure-warning {
    padding: 9px 10px;
    border-left: 4px solid #f97316;
    border-radius: 6px;
    background: #fff7ed;
    color: #9a3412;
    font-size: 12px;
}

#toggleFullAnalysisBtn {
    margin-top: 2px;
}

.table-box > table > tbody > tr.ai-timing-flag > td,
.table-box > table > tr.ai-timing-flag > td {
    background: #fff7ed !important;
}

.table-box > table > tbody > tr.ai-timing-flag-low > td,
.table-box > table > tr.ai-timing-flag-low > td {
    background: #fefce8 !important;
}

.table-box > table > tbody > tr.ai-timing-flag-high > td,
.table-box > table > tr.ai-timing-flag-high > td {
    background: #fef2f2 !important;
}

.table-box > table > tbody > tr.ai-timing-flag > td:first-child,
.table-box > table > tr.ai-timing-flag > td:first-child {
    box-shadow: inset 4px 0 #f97316;
}

.table-box > table > tbody > tr.ai-timing-flag-low > td:first-child,
.table-box > table > tr.ai-timing-flag-low > td:first-child {
    box-shadow: inset 4px 0 #eab308;
}

.table-box > table > tbody > tr.ai-timing-flag-high > td:first-child,
.table-box > table > tr.ai-timing-flag-high > td:first-child {
    box-shadow: inset 4px 0 #dc2626;
}

.ai-row-flag {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 5px;
    border-radius: 999px;
    background: #ffedd5;
    color: #9a3412;
    font-size: 9px;
    font-weight: 700;
    line-height: 1.2;
    vertical-align: middle;
}

.ai-row-doubt {
    margin-top: 5px;
    padding: 5px 7px;
    border-radius: 5px;
    background: rgba(255,255,255,.72);
    color: #7c2d12;
    font-size: 10px;
    line-height: 1.3;
}

.ai-timing-flag-high .ai-row-doubt {
    color: #7f1d1d;
}

.ai-timing-flag-low .ai-row-doubt {
    color: #713f12;
}

.ai-row-doubt-text {
    font-weight: 600;
}

.ai-row-evidence {
    margin-top: 3px;
    color: #666;
}

.ai-row-evidence summary {
    cursor: pointer;
    font-weight: 700;
}

.ai-row-evidence > div {
    margin-top: 3px;
}

.ai-row-summary {
    padding: 9px 10px;
    border-radius: 6px;
    background: #fff7ed;
    color: #9a3412;
    font-size: 12px;
}

.ai-benchmark-sources {
    margin: 10px 0;
    padding: 8px 10px;
    border: 1px solid #dbeafe;
    border-radius: 6px;
    background: #eff6ff;
    color: #1e3a8a;
    font-size: 11px;
}

.ai-previous-edition {
    margin: 10px 0;
    padding: 9px 10px;
    border: 1px solid #d1fae5;
    border-radius: 6px;
    background: #ecfdf5;
    color: #14532d;
    font-size: 11px;
}

.ai-previous-edition-not_found,
.ai-previous-edition-race_not_found,
.ai-previous-edition-unavailable {
    border-color: #e2e8f0;
    background: #f8fafc;
    color: #475569;
}

.ai-previous-edition-title {
    font-weight: 800;
}

.ai-previous-edition-leaders {
    display: flex;
    flex-wrap: wrap;
    gap: 5px 20px;
    margin-top: 5px;
}

.ai-previous-edition-label {
    font-weight: 700;
}

.ai-benchmark-sources summary {
    cursor: pointer;
    font-weight: 700;
}

.ai-benchmark-sources ul {
    margin: 7px 0 0;
    padding-left: 18px;
}

.ai-benchmark-sources a {
    color: #1d4ed8;
}

.ai-source-type {
    display: inline-block;
    margin-right: 5px;
    padding: 1px 5px;
    border-radius: 999px;
    background: #dbeafe;
    color: #1e40af;
    font-size: 9px;
    font-weight: 800;
}

.ai-source-reason {
    display: block;
    margin: 2px 0;
    color: #475569;
    font-style: italic;
}

.ai-timing-flag-high .ai-row-flag {
    background: #fee2e2;
    color: #991b1b;
}

.ai-timing-flag-low .ai-row-flag {
    background: #fef9c3;
    color: #854d0e;
}

.ai-context-json {
    max-height: 520px;
    overflow: auto;
    margin: 10px 0 0;
    padding: 10px;
    border-radius: 6px;
    background: #f7f7f7;
    font-size: 11px;
    line-height: 1.35;
    white-space: pre;
}

@media (max-width: 700px) {
    .table-box th:nth-child(6),
    .table-box td:nth-child(6) {
        min-width: 320px;
    }
}
