html {
    -webkit-text-size-adjust: 100%;
}

:root {
    --bg: #08090d;
    --bg-2: #0e1016;
    --panel: #14161d;
    --panel-alt: #1c1f29;
    --text: #f2f4fa;
    --muted: #98a1b3;
    --accent: #ff7a18;
    --accent-strong: #ffb020;
    --accent-soft: rgba(255, 122, 24, 0.14);
    --warning: #ffc24d;
    --danger: #ff5b5b;
    --success: #25c79a;
    --border: rgba(255, 255, 255, 0.08);
    --shadow: 0 14px 34px rgba(0, 0, 0, 0.62);
    font-family: 'Segoe UI', 'Roboto', sans-serif;
}

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

body {
    margin: 0;
    background:
        radial-gradient(1200px 520px at 78% -8%, rgba(255, 122, 24, 0.1), transparent 60%),
        radial-gradient(900px 480px at 5% 0%, rgba(255, 176, 32, 0.06), transparent 55%),
        var(--bg);
    background-attachment: fixed;
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    touch-action: pan-y;
}

#gapHighlightControl {
    display: none !important;
}

body.is-admin #gapHighlightControl {
    display: inline-flex !important;
}

img,
canvas,
svg,
video {
    max-width: 100%;
    height: auto;
    display: block;
}

.app-shell {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 1rem 1.25rem 2rem;
    width: 100%;
    max-width: none;
    margin: 0;
}

.env-banner {
    padding: 0.8rem 1rem;
    border-radius: 14px;
    border: 1px solid rgba(255, 159, 67, 0.45);
    background: linear-gradient(135deg, rgba(255, 159, 67, 0.2), rgba(255, 107, 107, 0.24));
    color: #ffe7cf;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-align: center;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}


.login-env-banner {
    margin-bottom: 1rem;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 14px;
    background:
        linear-gradient(90deg, var(--accent), var(--accent-strong), transparent) top left / 100% 2px no-repeat,
        linear-gradient(135deg, #0d0f15, #16191f);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    position: relative;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent-strong), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    letter-spacing: 0.1em;
    font-size: 1.1rem;
    color: #04111f;
}

.brand-logo {
    height: 40px;
    width: auto;
    display: block;
    filter: drop-shadow(0 2px 7px rgba(255, 122, 24, 0.4));
}

.brand-meta {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-left: 0.85rem;
    border-left: 2px solid var(--accent-soft);
}

.brand-title {
    margin: 0;
    font-size: 0.82rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--accent);
}

.brand-subtitle {
    margin: 0;
    color: var(--muted);
    font-size: 0.72rem;
    letter-spacing: 0.04em;
}

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

.upload-card {
    padding: 0.35rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    text-align: center;
}

.upload-label {
    margin: 0;
    font-size: 0.7rem;
    color: var(--muted);
}

.upload-value {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 600;
}

.select-label {
    font-size: 0.75rem;
    color: var(--muted);
}

.user-select {
    padding: 0.4rem 0.75rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
    font-size: 0.9rem;
}

.status-banner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.85rem;
    border-radius: 12px;
    background: rgba(15, 21, 34, 0.94);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 320;
    max-width: min(420px, calc(100vw - 2rem));
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.status-banner.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.status-loading {
    background: var(--warning);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.8);
        opacity: 0.7;
    }

    50% {
        transform: scale(1);
        opacity: 1;
    }

    100% {
        transform: scale(0.8);
        opacity: 0.7;
    }
}

.mobile-tabs {
    display: none;
    gap: 0.5rem;
    justify-content: center;
}

.tab-button {
    flex: 1;
    padding: 0.6rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--panel);
    color: var(--text);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.tab-active {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #04111f;
    border-color: transparent;
}

.app-main {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    grid-auto-flow: row dense;
}

@media (min-width: 1200px) {
    .app-main {
        grid-template-columns: repeat(4, minmax(240px, 1fr));
    }
}

.panel.card {
    background: var(--panel);
    padding: 1rem;
    border-radius: 18px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-width: 0;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.panel-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.panel-header .compare-btn {
    flex-shrink: 0;
    min-width: 160px;
}

.panel-header .reanalyze-btn {
    flex-shrink: 0;
    min-width: 44px;

}

.icon-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    /* ajusta si usas otro radio */
    cursor: pointer;
    line-height: 1;
}

.icon-btn .mdi {
    font-size: 20px;
}

/* Si ya tienes hover/active en .primary-btn, puedes omitir esto */
.icon-btn:hover {
    filter: brightness(0.95);
}

.icon-btn:active {
    transform: translateY(1px);
}

.icon-btn:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.filters-panel {
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--panel-alt);
    padding: 0.25rem 0.75rem 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.filters-toggle {
    border: none;
    background: transparent;
    color: var(--text);
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.35rem 0;
    cursor: pointer;
    gap: 0.5rem;
}

.filters-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.filters-toggle-icon {
    width: 1.8rem;
    height: 1.8rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, border-color 0.3s ease, background 0.3s ease;
}

.filters-toggle-icon::before {
    content: '';
    border: solid currentColor;
    border-width: 0 2px 2px 0;
    display: inline-block;
    padding: 0.25rem;
    transform: rotate(45deg);
    transition: transform 0.3s ease;
}

.filters-panel-body {
    overflow: hidden;
    max-height: 600px;
    opacity: 1;
    padding-top: 0.45rem;
    transition: max-height 0.35s ease, opacity 0.25s ease, padding 0.35s ease;
}

.filters-panel.collapsed .filters-panel-body {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    pointer-events: none;
}

.filters-panel.collapsed .filters-toggle-icon {
    transform: rotate(-90deg);
    border-color: var(--border);
    background: rgba(255, 255, 255, 0.05);
}

.filters-panel.collapsed .filters-toggle-icon::before {
    transform: rotate(-45deg);
}

.filters-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.6rem;
    padding: 0.35rem 0;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.75rem;
    color: var(--muted);
}

.filter-inputs {
    display: flex;
    gap: 0.35rem;
}

.filter-inputs input,
.filter-group select {
    flex: 1;
    padding: 0.4rem 0.45rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
    font-size: 0.85rem;
}

.filter-hint {
    display: block;
    font-size: 0.7rem;
    color: var(--muted);
}

.panel-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.panel-subtitle {
    margin: 0;
    color: var(--muted);
    font-size: 0.85rem;
}

.session-list {
    display: grid;
    align-content: start;
    gap: 0.65rem;
    min-height: 160px;
    max-height: clamp(320px, 55vh, 620px);
    overflow-y: auto;
    padding-right: 0.4rem;
    scrollbar-gutter: stable;
}

.session-usage-summary {
    padding: 0.65rem 0.8rem;
    border-radius: 12px;
    background: rgba(255, 122, 24, 0.08);
    border: 1px solid rgba(255, 122, 24, 0.18);
    color: var(--text);
    font-size: 0.85rem;
}

.session-card {
    padding: 0.8rem;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--panel-alt);
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    cursor: pointer;
    transition: border 0.2s ease;
    min-width: 0;
    position: relative;
    padding-top: 1.4rem;
    padding-right: 1.4rem;
}

.session-card:hover {
    border-color: var(--accent);
}

.session-card.active {
    border-color: var(--accent-strong);
    box-shadow: 0 0 0 2px rgba(255, 122, 24, 0.25);
}

.session-meta {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.session-meta strong {
    font-size: 0.95rem;
}

.session-info {
    display: flex;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--muted);
    flex-wrap: wrap;
}

.session-badge {
    padding: 0.2rem 0.45rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 0.75rem;
}

.session-card .session-remove-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    z-index: 2;
}

.session-list-status {
    min-height: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.35rem;
    gap: 0.5rem;
}

.session-list-status .error {
    color: var(--danger);
}

.session-list-status button {
    border-radius: 999px;
    border: 1px solid var(--border);
    padding: 0.2rem 0.75rem;
    background: transparent;
    color: var(--text);
    cursor: pointer;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 0.6rem;
}

.summary-card {
    padding: 0.9rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
}

.summary-card.notes-card {
    cursor: pointer;
    grid-column: 1 / -1;
    padding-bottom: 1px;
}

.notes-preview {
    font-size: 0.85rem;
    color: var(--muted);
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    margin-top: 0.25rem;
}

.summary-label {
    margin: 0;
    color: var(--muted);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.summary-value {
    margin: 0.4rem 0 0;
    font-size: 1.4rem;
    font-weight: 600;
}

.summary-card .note {
    display: block;
    margin-top: 0.15rem;
    font-size: 0.75rem;
    color: var(--muted);
}

.summary-value.bonus {
    color: var(--accent-strong);
}

.alerts {
    padding: 0.75rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed rgba(255, 255, 255, 0.2);
    min-height: 60px;
}

.alert {
    font-size: 0.85rem;
    margin: 0;
    padding: 0.25rem 0;
}

.alert.important {
    color: var(--warning);
}

.empty-state {
    color: var(--muted);
    font-size: 0.85rem;
    text-align: center;
    margin: 0.4rem 0;
}

.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

.lap-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    min-width: 380px;
}

.lap-table td:first-child,
.lap-table th:first-child {
    width: 28px;
    padding-left: 0.2rem;
    padding-right: 0.2rem;
}

.lap-table td:last-child,
.lap-table th:last-child {
    width: 36px;
    text-align: center;
    padding-left: 0.15rem;
    padding-right: 0.15rem;
}

.lap-table th,
.lap-table td {
    padding: 0.45rem 0.35rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.lap-table th {
    text-align: left;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--muted);
}

.lap-table tbody tr.best-row {
    background: rgba(255, 107, 107, 0.12);
}

.lap-table tbody tr.selected {
    border-left: 3px solid var(--accent-strong);
}

.lap-table tbody tr.lap-previewing {
    background: rgba(255, 122, 24, 0.1);
    border-left: 3px solid var(--accent);
}

.lap-table tbody tr.lap-previewing td {
    color: var(--text);
}

.lap-table tbody tr[data-lap-key]:hover:not(.optimal-row) {
    background: rgba(255, 255, 255, 0.04);
}

.reset-preview-btn {
    color: var(--accent);
    border-color: rgba(255, 122, 24, 0.3);
    font-size: 0.82rem;
}

.lap-table tbody td button {
    border: none;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 0.2rem 0.4rem;
    color: var(--text);
    cursor: pointer;
}

.lap-table input[type='checkbox'] {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
}

.table-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--muted);
}

.status-pill {
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 0.75rem;
}

.status-pill.highlighted {
    border-color: transparent;
    background: rgba(255, 107, 107, 0.2);
    color: var(--danger);
}

.graph-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.85rem;
    align-items: start;
}

/* Gridstack chart grid overrides */
.grid-stack {
    background: transparent;
    width: 100%;
}

/* Override gridstack's top:0;left:0;width:100%;height:100% with inset gap */
.grid-stack-item > .grid-stack-item-content {
    inset: 4px !important;
    width: auto !important;
    height: auto !important;
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Make the inner graph-card fill the gridstack item completely */
.grid-stack-item > .grid-stack-item-content > .graph-card {
    flex: 1 1 0% !important;
    min-height: 0 !important;
    height: auto !important;
    border-radius: 10px;
    box-sizing: border-box;
    display: flex !important;
    flex-direction: column !important;
}

/* chart-wrapper fills remaining space after header */
.grid-stack-item > .grid-stack-item-content .chart-wrapper {
    flex: 1 1 0% !important;
    min-height: 0 !important;
    height: auto !important;
    position: relative !important;
}

.grid-stack-item > .grid-stack-item-content .map-view {
    flex: 1 1 0% !important;
    min-height: 0 !important;
    height: auto !important;
}

/* Minisectors / sectors wrappers inside gridstack: scroll horizontally, fill vertically */
.grid-stack-item > .grid-stack-item-content .minisectors-wrapper {
    flex: 1 1 0%;
    min-height: 0;
    overflow-x: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.grid-stack-item > .grid-stack-item-content .chart-wrapper canvas {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
}

/* Collapsed (minimized) card — only show header */
.grid-stack-item > .grid-stack-item-content .graph-card.is-minimized .chart-wrapper,
.grid-stack-item > .grid-stack-item-content .graph-card.is-minimized .chart-empty-note {
    display: none;
}

/* Gridstack drag handle cursor */
.grid-stack-item .graph-card-header {
    cursor: grab;
    user-select: none;
}
.grid-stack-item .graph-card-header:active {
    cursor: grabbing;
}

/* Hidden gridstack item */
.grid-stack-item.chart-card-hidden {
    display: none !important;
}

.analysis-secondary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.graph-card.map-card {
    order: 1;
}

.graph-card.delta-card {
    order: 2;
}

.graph-card:not(.map-card):not(.delta-card) {
    order: 3;
}

.graph-card {
    background: var(--panel-alt);
    border-radius: 14px;
    padding: 0.75rem;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    min-width: 0;
    overflow: hidden;
}

.graph-title {
    margin: 0;
    font-size: 0.85rem;
    color: var(--muted);
}

.chart-empty-note {
    margin: 0;
    font-size: 0.78rem;
    color: #ffbf69;
}

.chart-card.is-empty canvas {
    opacity: 0.28;
}

.map-view {
    width: 100%;
    height: 220px;
    border-radius: 10px;
    overflow: hidden;
}

.graph-card canvas {
    width: 100% !important;
    height: 100%;
    min-height: 0;
    display: block;
}

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

.zoom-reset-btn {
    display: none;
    align-items: center;
    gap: 0.35rem;
}

.zoom-reset-btn.is-visible {
    display: inline-flex;
}

.analysis-header {
    align-items: center;
    gap: 1rem;
}

.coach-diagnostic-panel {
    margin: 0 0 14px;
    padding: 14px;
    border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
    border-radius: 12px;
    background: color-mix(in srgb, var(--panel) 92%, var(--accent) 8%);
}

/* Ventana flotante del Coach (escritorio): se abre con el botón Coach de la barra. */
.coach-diagnostic-panel.is-floating {
    position: fixed;
    top: 72px;
    right: 24px;
    z-index: 340;
    width: min(460px, calc(100vw - 32px));
    min-width: 300px;
    max-height: calc(100vh - 96px);
    margin: 0;
    overflow: auto;
    resize: both;
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.coach-diagnostic-panel.is-floating[hidden] {
    display: none;
}

.coach-diagnostic-panel.is-floating .coach-diagnostic-header {
    position: sticky;
    top: -14px;
    margin: -14px -14px 0;
    padding: 10px 14px;
    background: color-mix(in srgb, var(--panel) 96%, var(--accent) 4%);
    border-bottom: 1px solid var(--border);
    cursor: grab;
    touch-action: none;
    user-select: none;
    z-index: 1;
}

.coach-diagnostic-panel.is-floating .coach-diagnostic-header:active {
    cursor: grabbing;
}

.coach-diagnostic-panel:not(.is-floating) .coach-float-close {
    display: none;
}

@media (max-width: 760px) {
    .coach-float-toggle {
        display: none;
    }
}

.coach-diagnostic-header > div:first-child {
    margin-right: auto;
}

.coach-diagnostic-header,
.coach-diagnostic-summary,
.coach-diagnostic-segment-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.coach-diagnostic-kicker {
    display: block;
    margin-bottom: 2px;
    color: var(--accent);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.coach-diagnostic-status,
.coach-diagnostic-meta,
.coach-diagnostic-empty {
    color: var(--muted);
    font-size: 0.78rem;
}

.coach-diagnostic-content {
    margin-top: 12px;
}

.coach-diagnostic-summary {
    justify-content: flex-start;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.coach-diagnostic-chip {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--panel-alt);
    font-size: 0.74rem;
}

.coach-diagnostic-chip.is-warning {
    border-color: #e0a229;
    color: #e0a229;
}

.coach-diagnostic-layout {
    display: grid;
    grid-template-columns: minmax(220px, 0.8fr) minmax(280px, 1.2fr);
    gap: 12px;
}

.coach-diagnostic-list {
    display: grid;
    max-height: 260px;
    gap: 6px;
    overflow: auto;
}

.coach-diagnostic-segment {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: inherit;
    text-align: left;
    background: var(--panel-alt);
    cursor: pointer;
}

.coach-diagnostic-segment:hover,
.coach-diagnostic-segment.is-selected {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--panel-alt) 86%, var(--accent) 14%);
}

.coach-diagnostic-detail {
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel-alt);
}

.coach-diagnostic-phases,
.coach-diagnostic-features {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin-top: 9px;
}

.coach-diagnostic-metric {
    padding: 7px;
    border-radius: 7px;
    background: var(--panel);
    font-size: 0.72rem;
}

.coach-diagnostic-metric strong,
.coach-diagnostic-metric span {
    display: block;
}

.coach-insights {
    display: grid;
    gap: 7px;
    margin-top: 10px;
}

.coach-opportunity-ranking {
    margin: 10px 0 12px;
}

.coach-opportunity-list {
    display: grid;
    /* Tantas columnas como quepan: en la columna lateral, una por fila */
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 7px;
}

.coach-opportunity {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    padding: 9px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: inherit;
    text-align: left;
    background: var(--panel-alt);
    cursor: pointer;
}

.coach-opportunity:hover {
    border-color: var(--accent);
}

.coach-opportunity-rank {
    display: grid;
    width: 24px;
    height: 24px;
    place-items: center;
    border-radius: 50%;
    color: #111;
    background: var(--accent);
    font-size: 0.72rem;
    font-weight: 800;
}

.coach-opportunity strong,
.coach-opportunity small {
    display: block;
}

.coach-opportunity small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 0.68rem;
}

.coach-opportunity b {
    color: var(--accent);
    font-size: 0.76rem;
}

.coach-opportunity.is-gain .coach-opportunity-rank {
    background: #34d399;
}

.coach-opportunity.is-gain b {
    color: #34d399;
}

.coach-zone-strengths {
    margin: 8px 0 0;
    padding: 0 0 0 18px;
    color: #34d399;
    font-size: 0.8rem;
}

.coach-insight {
    padding: 9px;
    border: 1px solid var(--border);
    border-left: 3px solid var(--muted);
    border-radius: 7px;
    background: var(--panel);
}

.coach-insight-recommendation {
    border-left-color: var(--accent);
}

.coach-insight-observation {
    border-left-color: var(--warning);
}

.coach-insight-experimental {
    border-left-color: var(--warning);
    border-left-style: dashed;
}

.coach-insight-label {
    color: var(--accent);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
}

.coach-experimental-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    border: 1px dashed var(--warning);
    border-radius: 999px;
    color: var(--warning);
    font-size: 0.58rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    vertical-align: middle;
}

.coach-insight p {
    margin: 5px 0;
    color: var(--muted);
    font-size: 0.76rem;
    line-height: 1.35;
}

.coach-diagnostic-metric span {
    margin-top: 3px;
    color: var(--muted);
}

.coach-zones {
    margin: 4px 0 10px;
}

.coach-zone-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.coach-zone-chip {
    display: flex;
    align-items: baseline;
    gap: 6px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: inherit;
    background: var(--panel-alt);
    font-size: 0.74rem;
    cursor: pointer;
}

.coach-zone-chip span {
    color: var(--muted);
    font-size: 0.7rem;
}

.coach-zone-chip:hover,
.coach-zone-chip.is-selected {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--panel-alt) 84%, var(--accent) 16%);
}

.coach-zone-chip.is-selected span {
    color: var(--accent);
}

.coach-dev {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.coach-dev-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 7px;
    color: var(--muted);
    background: transparent;
    font-size: 0.72rem;
    cursor: pointer;
}

.coach-dev-toggle:hover,
.coach-dev-toggle.is-active {
    border-color: var(--accent);
    color: var(--accent);
}

.coach-dev-block {
    margin-top: 10px;
}

@media (max-width: 760px) {
    .coach-diagnostic-layout {
        grid-template-columns: 1fr;
    }

    .coach-opportunity-list {
        grid-template-columns: 1fr;
    }
}

.analysis-heading {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}


.primary-chart-control {
    display: none;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.05);
    font-size: 0.78rem;
    color: var(--muted);
}

.analysis-axis-control {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.05);
    font-size: 0.78rem;
    color: var(--muted);
}

.primary-chart-control select {
    background: transparent;
    border: none;
    color: var(--text);
    font: inherit;
    cursor: pointer;
    appearance: none;
    padding: 0;
}

.analysis-axis-control select {
    background: transparent;
    border: none;
    color: var(--text);
    font: inherit;
    cursor: pointer;
    appearance: none;
    padding: 0;
}

.primary-chart-control select:focus-visible {
    outline: none;
}

.analysis-axis-control select:focus-visible {
    outline: none;
}

.toggle-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.6rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    cursor: pointer;
    user-select: none;
    font-size: 0.75rem;
}

.toggle-chip input {
    width: 16px;
    height: 16px;
}

.analysis-panel {
    min-height: 520px;
}

.analysis-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 0;
    min-width: 0;
}

.chart-card {
    height: 260px;
    min-height: 0;
}

.chart-card canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    min-height: 0;
}

.comparison-list {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    align-items: stretch;
    position: relative;
    z-index: 2;
    margin-bottom: 0.5rem;
}


.comparison-card {
    padding: 0.45rem 0.55rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
}

.reference-lap-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 0 0 0.75rem;
    padding: 0.7rem 0.85rem;
    border-radius: 12px;
    border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border));
    background: linear-gradient(135deg, rgba(0, 184, 255, 0.12), rgba(255, 255, 255, 0.03));
}

.reference-lap-copy {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.reference-lap-label {
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.reference-lap-copy #referenceLapSummary {
    font-size: 0.82rem;
    color: var(--text);
}

.reference-lap-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.comparison-main {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;
}

.comparison-card strong {
    font-size: 0.82rem;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.comparison-meta {
    color: var(--muted);
    font-size: 0.72rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.color-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.25);
    flex-shrink: 0;
}

.comparison-card button {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.2rem 0.4rem;
    color: var(--text);
    cursor: pointer;
    font-size: 0.72rem;
    flex: 0 0 auto;
}

.primary-btn,
.ghost-btn {
    border-radius: 12px;
    padding: 0.45rem 0.9rem;
    border: none;
    font-weight: 600;
    cursor: pointer;
}

.primary-btn {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #0b121d;
    border: 1px solid transparent;
}

.reanalyze-btn {
    background: transparent;
    /* adiós gradiente */
    color: #6b7280;
    /* gris discreto */
    padding: 4px;
    /* casi solo el icono */
    width: auto;
    height: auto;
    min-width: unset;
    border-radius: 8px;
    margin-left: 0;
    /* alineado a la izquierda */
    border-width: 0;
}

/* Tamaño real del icono */
.reanalyze-btn .mdi {
    font-size: 20px;
}

/* Hover sutil */
.reanalyze-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: #111827;
}

/* Active / feedback táctil */
.reanalyze-btn:active {
    background-color: rgba(0, 0, 0, 0.08);
}

.login-body {
    background:
        radial-gradient(1100px 600px at 50% -10%, rgba(255, 122, 24, 0.16), transparent 60%),
        radial-gradient(800px 500px at 90% 110%, rgba(255, 176, 32, 0.08), transparent 55%),
        #08090d;
    color: #f3f4f6;
    min-height: calc(var(--login-vh, 1vh) * 100);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    max-width: 100vw;
    overflow-x: hidden;
}

.login-container {
    width: 100%;
    max-width: 430px;
}

.login-card {
    position: relative;
    background: linear-gradient(160deg, #14161d, #0e1015);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 2rem 1.75rem 1.75rem;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 122, 24, 0.06);
    overflow: hidden;
}

.login-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent-strong), var(--accent));
}

.login-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    margin: 0.25rem 0 1.5rem 0;
}

.login-logo {
    width: 100%;
    max-width: 300px;
    height: auto;
    filter: drop-shadow(0 6px 18px rgba(255, 122, 24, 0.32));
}

.login-tagline {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    color: var(--muted);
}

.login-card form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.login-card label {
    font-weight: 600;
    font-size: 0.82rem;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.login-card input[type="text"],
.login-card input[type="password"] {
    border-radius: 11px;
    border: 1px solid var(--border);
    padding: 0.75rem 0.95rem;
    background: #0a0c11;
    color: #f3f4f6;
    font-size: 16px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.login-card input[type="text"]:focus,
.login-card input[type="password"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(255, 122, 24, 0.18);
}

.login-card .primary-btn {
    margin-top: 0.5rem;
    padding: 0.8rem 1rem;
    font-size: 1rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.login-error {
    color: var(--danger);
    margin: 0;
    font-weight: 600;
}

.ghost-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

button.ghost-icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    padding: 0;
    font-size: 1.1rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    flex: 0 0 38px;
}

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(4, 7, 19, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    flex-direction: column;
    gap: 0.8rem;
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ===========================
   Notes modal (fixed + iOS safe)
   =========================== */

.chart-config-btn {
    color: var(--color-accent, #ff8a30);
    opacity: 0.7;
}
.chart-config-btn:hover { opacity: 1; }

.channel-config-panel {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 260px;
    background: var(--panel-bg, #0b1020);
    border-left: 1px solid rgba(255,122,24,0.2);
    box-shadow: -8px 0 32px rgba(0,0,0,0.5);
    z-index: 1200;
    display: flex;
    flex-direction: column;
    font-size: 13px;
    transform: translateX(100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    padding-bottom: 24px;
}

.channel-config-panel:not([hidden]) {
    transform: translateX(0);
}

.channel-config-panel[hidden] {
    display: flex !important; /* keep in DOM for animation */
    transform: translateX(100%);
    pointer-events: none;
}

.channel-config-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1199;
    opacity: 0;
    transition: opacity 0.25s;
    cursor: default;
}

.channel-config-backdrop:not([hidden]) {
    opacity: 1;
}

.channel-config-backdrop[hidden] {
    display: block !important;
    opacity: 0;
    pointer-events: none;
}

.channel-config-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 16px 12px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--color-text-muted, #7a8aaa);
    text-transform: uppercase;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    position: sticky;
    top: 0;
    background: var(--panel-bg, #0b1020);
    z-index: 1;
}

.channel-config-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 8px;
}

.channel-config-row {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px 10px;
    border-radius: 6px;
    color: var(--color-text, #c8d6f0);
    transition: background 0.15s;
}

.channel-config-row:hover:not(.channel-config-row--nodata) {
    background: rgba(255,255,255,0.05);
}

.channel-config-row--nodata {
    opacity: 0.35;
    cursor: default;
}

.channel-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    flex-shrink: 0;
}

.channel-dot--on {
    background: var(--color-accent, #ff8a30);
}

.chart-card-hidden {
    display: none !important;
}

.notes-modal,
.reanalyze-modal,
.transfer-modal,
.bulk-modal,
.dup-check-modal,
.confirm-modal,
.admin-page,
.upload-modal {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    display: none;
    z-index: 1000;
    overflow: hidden;
    align-items: center;
    justify-content: center;
}

@supports (height: 100dvh) {
    .notes-modal,
    .reanalyze-modal,
    .transfer-modal,
    .bulk-modal,
    .confirm-modal,
    .admin-page,
    .upload-modal {
        height: 100dvh;
    }
}

.notes-modal.is-visible,
.reanalyze-modal.is-visible,
.transfer-modal.is-visible,
.bulk-modal.is-visible,
.dup-check-modal.is-visible,
.confirm-modal.is-visible,
.upload-modal.is-visible {
    display: flex;
}

.admin-page.is-visible {
    display: flex;
    align-items: stretch;
}

.notes-backdrop,
.reanalyze-backdrop,
.transfer-backdrop,
.bulk-backdrop,
.dup-check-backdrop,
.confirm-backdrop,
.upload-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(4, 7, 19, 0.9);
}

.notes-dialog,
.reanalyze-dialog,
.transfer-dialog,
.bulk-dialog,
.dup-check-dialog,
.confirm-dialog,
.upload-dialog {
    position: relative;
    width: min(600px, 92vw);
    max-height: min(90vh, 720px);
    border-radius: 18px;
    background: var(--panel);
    border: 1px solid var(--border);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 1;
    overflow: hidden;
    min-height: 0;
}

.notes-dialog header,
.reanalyze-dialog header,
.transfer-dialog header,
.bulk-dialog header,
.dup-check-dialog header,
.confirm-dialog header,
.upload-dialog header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    flex: 0 0 auto;
}

/* ─── Admin page layout ──────────────────────────────────────────────────────── */

.admin-page {
    background: var(--bg);
    flex-direction: row;
}

.admin-sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.25rem 0 1.25rem;
    gap: 0;
    overflow-y: auto;
}

.admin-back-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    background: none;
    border: none;
    color: var(--accent);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 0;
    transition: background 0.15s;
    text-align: left;
}

.admin-back-btn:hover {
    background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.admin-sidebar-title {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 1.25rem 1.25rem 0.4rem;
    margin: 0;
}

.admin-nav {
    display: flex;
    flex-direction: column;
    padding: 0.25rem 0.6rem;
    gap: 0.15rem;
}

.admin-nav-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.65rem 0.75rem;
    background: none;
    border: none;
    border-radius: 10px;
    color: var(--text-soft);
    font-size: 0.9rem;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, color 0.15s;
}

.admin-nav-item:hover {
    background: var(--panel-alt);
    color: var(--text);
}

.admin-nav-item.is-active {
    background: color-mix(in srgb, var(--accent) 14%, transparent);
    color: var(--accent);
    font-weight: 600;
}

.admin-nav-item .mdi {
    font-size: 1.15rem;
    width: 1.25rem;
    text-align: center;
    flex-shrink: 0;
}

.admin-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 2.5rem;
}

.admin-tab-panel {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    max-width: 900px;
}

.admin-tab-panel[hidden] {
    display: none;
}

.admin-panel-heading {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 0.25rem;
}

.admin-toolbar {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.notes-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    flex: 0 0 auto;
}

.modal-title-group {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.modal-subtitle {
    font-size: 0.85rem;
    color: var(--text-soft);
    margin: 0;
}

.notes-dialog textarea {
    background: var(--panel-alt);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.75rem;
    color: var(--text);
    font-family: 'Roboto Mono', monospace;
    font-size: 16px;
    /* IMPORTANT: evita auto-zoom iOS al focus */
    line-height: 1.35;
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    /* IMPORTANT: permite scroll interno correcto */
    overflow: auto;
    resize: vertical;
    -webkit-text-size-adjust: 100%;
}

.notes-actions .primary-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.reanalyze-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.reanalyze-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.reanalyze-field .field-label {
    font-size: 0.95rem;
    color: var(--text-soft);
    margin: 0;
}

.reanalyze-field select {
    width: 100%;
    min-height: 2.6rem;
    background: var(--panel-alt);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.6rem 0.75rem;
    color: var(--text);
    font: inherit;
}

.reanalyze-field select:focus-visible {
    outline: 2px solid rgba(0, 201, 167, 0.45);
    outline-offset: 2px;
}

.field-stepper {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.field-stepper input {
    flex: 1 1 auto;
    min-width: 0;
    background: var(--panel-alt);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.6rem 0.75rem;
    text-align: center;
    color: var(--text);
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

.stepper-btn {
    min-width: 44px;
    min-height: 44px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--panel-alt);
    color: var(--text);
    font-size: 1.2rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, border-color 0.15s ease;
}

.stepper-btn:active {
    transform: scale(0.97);
    border-color: var(--accent);
}

.reanalyze-actions {
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
}

.reanalyze-status {
    display: none;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-soft);
    font-size: 0.9rem;
}

.inline-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-top-color: var(--accent);
    border-radius: 50%;
    display: inline-block;
    animation: spin 1s linear infinite;
}

.reanalyze-dialog.is-busy .reanalyze-status {
    display: inline-flex;
}

.reanalyze-dialog.is-busy .reanalyze-actions .ghost-btn,
.reanalyze-dialog.is-busy .reanalyze-actions .primary-btn,
.reanalyze-dialog.is-busy .field-stepper button,
.reanalyze-dialog.is-busy .field-stepper input,
.reanalyze-dialog.is-busy .reanalyze-field select,
.reanalyze-dialog.is-busy .reanalyze-toggle {
    pointer-events: none;
    opacity: 0.6;
}

.reanalyze-toggle {
    justify-content: flex-start;
    gap: 0.5rem;
    align-self: flex-start;
}

.transfer-body {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.transfer-session-label {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-soft);
}

.transfer-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.transfer-field .field-label {
    font-size: 0.85rem;
    color: var(--text-soft);
    margin: 0;
}

.transfer-field select {
    background: var(--panel-alt);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.6rem 0.75rem;
    color: var(--text);
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

.transfer-note {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-soft);
}

.transfer-actions {
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
}

.transfer-status {
    display: none;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-soft);
    font-size: 0.9rem;
}

.transfer-dialog.is-busy .transfer-status {
    display: inline-flex;
}

.transfer-dialog.is-busy .transfer-actions .ghost-btn,
.transfer-dialog.is-busy .transfer-actions .primary-btn,
.transfer-dialog.is-busy .transfer-field select {
    pointer-events: none;
    opacity: 0.6;
}

.dup-check-modal {
    z-index: 1100;
}

.confirm-modal {
    z-index: 1200;
}

.dup-check-dialog {
    width: min(420px, 92vw);
}

.confirm-dialog {
    width: min(460px, 92vw);
}

.confirm-message {
    margin: 0;
    color: var(--text);
    line-height: 1.55;
    white-space: pre-line;
}

.toast-stack {
    position: fixed;
    right: 1rem;
    top: auto;
    bottom: 1rem;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.75rem;
    width: min(380px, calc(100vw - 2rem));
    max-width: calc(100vw - 2rem);
    z-index: 1400;
    pointer-events: none;
}

.app-toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    align-self: flex-end;
    gap: 0.75rem;
    width: 100%;
    max-width: 100%;
    max-height: min(40vh, 280px);
    overflow: auto;
    padding: 0.9rem 1rem;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: rgba(11, 18, 29, 0.96);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
    color: var(--text);
}

.app-toast.is-success {
    border-color: rgba(34, 197, 94, 0.45);
}

.app-toast.is-warning {
    border-color: rgba(245, 158, 11, 0.45);
}

.app-toast.is-error {
    border-color: rgba(244, 67, 54, 0.45);
}

.app-toast.is-info {
    border-color: rgba(255, 122, 24, 0.45);
}

.app-toast-body {
    flex: 1 1 auto;
    min-width: 0;
}

.app-toast-title {
    margin: 0 0 0.2rem;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.app-toast-message {
    margin: 0;
    white-space: pre-line;
    line-height: 1.45;
}

.app-toast-close {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    cursor: pointer;
}

.dup-check-body {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.25rem 0;
}

.dup-session-card {
    background: var(--row-alt, rgba(255,255,255,0.03));
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.dup-session-row {
    font-size: 0.875rem;
    color: var(--text);
    margin: 0;
}

.dup-session-date {
    font-size: 0.8rem;
    color: var(--text-muted, #888);
}

.dup-check-question {
    font-size: 0.875rem;
    color: var(--text-muted, #888);
    margin: 0;
}

.dup-check-actions {
    justify-content: flex-end;
}

.bulk-dialog {
    width: min(1040px, 95vw);
    max-height: min(92vh, 760px);
}

.bulk-body {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 0;
    flex: 1 1 auto;
}

.bulk-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.bulk-select-all {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-soft);
    font-size: 0.9rem;
}

.bulk-count {
    color: var(--text-soft);
    font-size: 0.85rem;
}

.bulk-table-wrapper {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--panel-alt);
    overflow: auto;
    min-height: 160px;
    max-height: min(52vh, 430px);
}

.bulk-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.bulk-table th,
.bulk-table td {
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 0.55rem;
    text-align: left;
    white-space: nowrap;
}

.bulk-table th:first-child,
.bulk-table td:first-child {
    width: 44px;
}

.bulk-table tbody tr:last-child td {
    border-bottom: none;
}

.bulk-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.04);
}

.bulk-table .empty-row td {
    text-align: center;
    color: var(--muted);
    white-space: normal;
}

.bulk-transfer-row {
    display: flex;
    justify-content: flex-end;
}

.bulk-transfer-row .transfer-field {
    min-width: min(340px, 100%);
}

.bulk-actions {
    align-items: center;
    justify-content: flex-end;
    gap: 0.55rem;
}

.bulk-status {
    margin-right: auto;
    display: none;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-soft);
    font-size: 0.9rem;
}

.bulk-dialog.is-busy .bulk-status {
    display: inline-flex;
}

.bulk-dialog.is-busy .bulk-actions .ghost-btn,
.bulk-dialog.is-busy .bulk-actions .primary-btn,
.bulk-dialog.is-busy .bulk-select-all,
.bulk-dialog.is-busy .bulk-table input,
.bulk-dialog.is-busy .bulk-transfer-row .transfer-field select {
    pointer-events: none;
    opacity: 0.6;
}

.danger-btn {
    border-color: rgba(255, 78, 110, 0.45);
    color: #ff7b93;
}

.admin-btn {
    margin-left: 0.4rem;
}


.admin-form {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
    gap: 0.6rem;
}

.admin-form.admin-form-devices {
    grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
}

.admin-form input,
.admin-form select {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.6rem 0.75rem;
    color: var(--text);
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

.admin-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.admin-row {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 0.75rem;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--panel);
}

.admin-row-main {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
}

.admin-row-main input,
.admin-row-main select {
    background: var(--panel-alt);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.55rem 0.7rem;
    color: var(--text);
    font-size: 16px;
}

.admin-row-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.admin-row-meta {
    margin: 0;
    color: var(--text-soft);
    font-size: 0.8rem;
}

.admin-row .token-field {
    font-family: 'Roboto Mono', monospace;
}

.admin-row .toggle-chip {
    justify-content: flex-start;
}

.admin-row-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text);
}

.admin-source-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.1rem 0.45rem;
    border-radius: 4px;
    letter-spacing: 0.02em;
}

.admin-source-yaml {
    background: color-mix(in srgb, var(--accent) 15%, transparent);
    color: var(--accent);
}

.admin-source-iracing {
    background: color-mix(in srgb, #f0a500 15%, transparent);
    color: #c8880a;
}

.admin-source-manual {
    background: color-mix(in srgb, var(--text-muted) 15%, transparent);
    color: var(--text-muted);
}

/* Evita scroll de la página al abrir modal */
body.modal-open {
    overflow: hidden;
    height: 100%;
    overscroll-behavior: contain;
}

/* Mobile: el modal ocupa el viewport real (sin zoom raro / sin overflow) */
@media (max-width: 720px) {
    .notes-modal,
    .reanalyze-modal,
    .transfer-modal,
    .bulk-modal,
    .confirm-modal,
    .upload-modal {
        align-items: stretch;
        justify-content: center;
        padding: 0;
        overflow: hidden;
    }

    .notes-dialog,
    .reanalyze-dialog,
    .transfer-dialog,
    .bulk-dialog,
    .confirm-dialog,
    .upload-dialog {
        width: 100vw;
        max-width: 100vw;
        border-radius: 0;
        margin: 0;
        padding: calc(env(safe-area-inset-top, 0px) + 14px) calc(env(safe-area-inset-right, 0px) + 14px) calc(env(safe-area-inset-bottom, 0px) + 14px) calc(env(safe-area-inset-left, 0px) + 14px);
        height: var(--notes-modal-height, 100vh);
        min-height: var(--notes-modal-height, 100vh);
        max-height: var(--notes-modal-height, 100vh);
    }

    @supports (height: 100dvh) {
        .notes-dialog,
        .reanalyze-dialog,
        .transfer-dialog,
        .bulk-dialog,
        .confirm-dialog,
        .upload-dialog {
            height: var(--notes-modal-height, 100dvh);
            min-height: var(--notes-modal-height, 100dvh);
            max-height: var(--notes-modal-height, 100dvh);
        }
    }

    .toast-stack {
        top: auto;
        right: 0.75rem;
        left: 0.75rem;
        bottom: calc(4.75rem + env(safe-area-inset-bottom));
        width: auto;
        max-width: min(360px, calc(100vw - 1.5rem));
        margin-left: auto;
        align-items: stretch;
    }

    .app-toast {
        width: 100%;
        max-width: 100%;
        max-height: min(34vh, 220px);
    }

    /* Admin page: stack sidebar on top as horizontal tabs */
    .admin-page.is-visible {
        flex-direction: column;
    }

    .admin-sidebar {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 0.5rem 0.75rem;
        gap: 0.25rem;
        overflow-x: auto;
        overflow-y: hidden;
        flex-shrink: 0;
    }

    .admin-sidebar-title {
        display: none;
    }

    .admin-back-btn {
        padding: 0.45rem 0.75rem;
        border-radius: 8px;
    }

    .admin-nav {
        flex-direction: row;
        padding: 0;
        gap: 0.2rem;
        flex-wrap: nowrap;
    }

    .admin-nav-item {
        padding: 0.4rem 0.75rem;
        font-size: 0.82rem;
        white-space: nowrap;
    }

    .admin-nav-item .mdi {
        display: none;
    }

    .admin-content {
        padding: 1rem;
        overflow-y: auto;
        flex: 1;
    }

    .notes-actions {
        flex-wrap: wrap;
        gap: 0.4rem;
    }

    .field-stepper {
        gap: 0.5rem;
    }

    .admin-form,
    .admin-form.admin-form-devices {
        grid-template-columns: 1fr;
    }

    .admin-row-main {
        grid-template-columns: 1fr;
    }

    .admin-row-actions {
        justify-content: flex-start;
    }

    .bulk-transfer-row {
        justify-content: stretch;
    }

    .bulk-transfer-row .transfer-field {
        min-width: 0;
        width: 100%;
    }
}

@media (max-width: 900px) {
    .app-main {
        grid-template-columns: 1fr;
    }

    .mobile-tabs {
        display: flex;
    }

    .panel {
        display: none;
    }

    .panel.panel-visible {
        display: flex;
    }
}


.table-actions-bottom {
    margin-top: 0.75rem;
}

.table-actions-bottom .compare-btn {
    width: 100%;
}

.compare-btn {
    min-height: 44px;
}

@media (max-width: 720px) {
    .app-shell {
        padding: 0.75rem 0.85rem 1.25rem;
    }

    .app-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-controls {
        width: 100%;
        flex-wrap: wrap;
    }

    .status-banner {
        top: auto;
        bottom: calc(0.85rem + env(safe-area-inset-bottom));
        right: 0.85rem;
        left: 0.85rem;
        max-width: none;
        border-radius: 12px;
    }

    .graph-grid {
        grid-template-columns: 1fr;
    }

    .comparison-list {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        width: 100%;
        align-content: flex-start;
    }

    .graph-card {
        padding: 0.65rem;
    }

    .graph-card canvas {
        min-height: 160px;
    }

    .comparison-card {
        flex: 1 1 calc(50% - 0.5rem);
        min-width: 150px;
        padding: 0.5rem 0.55rem;
        gap: 0.35rem;
        flex-direction: row;
        align-items: center;
        border-radius: 14px;
    }

    .comparison-main {
        min-width: 0;
    }

    .comparison-card strong {
        font-size: 0.8rem;
    }

    .comparison-meta {
        font-size: 0.68rem;
    }

    .comparison-card .ghost-icon-btn {
        width: 32px;
        height: 32px;
        flex: 0 0 32px;
    }

    .reference-lap-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .reference-lap-actions {
        justify-content: stretch;
    }

    .reference-lap-actions .ghost-btn {
        flex: 1 1 0;
    }

    .session-card {
        grid-template-columns: 1fr;
    }

    .analysis-controls {
        width: 100%;
    }

    .analysis-controls .toggle-chip,
    .analysis-controls .ghost-btn,
    .analysis-controls .ghost-icon-btn {
        width: 100%;
        justify-content: center;
    }

}

@media (max-width: 520px) {
    .panel.card {
        padding: 0.85rem;
    }

    .filters-row {
        grid-template-columns: 1fr;
    }

    .filter-inputs {
        flex-direction: column;
    }

    .map-view {
        height: clamp(240px, 50vh, 420px);
    }

    .analysis-controls button,
    .analysis-controls .toggle-chip {
        width: 100%;
        justify-content: center;
    }

    .primary-btn,
    .ghost-btn {
        width: 100%;
        min-height: 44px;
    }

    .panel-header {
        flex-direction: column;
    }


    /* --- Lap panel: mantener título + icono en la misma línea (mobile incluido) --- */
    #lapPanel .panel-header {
        flex-direction: row !important;
        align-items: center !important;
        flex-wrap: nowrap !important;
    }

    #lapPanel .panel-header>div {
        min-width: 0;
        /* permite que el título pueda encogerse */
    }

    #lapPanel .panel-title {
        white-space: nowrap;
        /* evita salto de línea del título */
        overflow: hidden;
        text-overflow: ellipsis;
        /* si no cabe, "..." */
    }

    #lapPanel .reanalyze-btn {
        margin-left: auto;
        /* empuja el icono a la derecha */
        flex: 0 0 auto;
    }
}

/* Debug helper: add the class below to <body> while testing to highlight overflow sources */
/* .debug-overflow * {
    outline: 1px solid rgba(255, 0, 0, 0.4);
} */

/* ─── Evolución de tiempos ─────────────────────────────────────────────────── */

.evolution-section {
    padding: 0.75rem 0 0;
    border-top: 1px solid var(--border);
    margin-top: 0.5rem;
}

.evolution-title {
    margin-bottom: 0.5rem !important;
}

.evolution-chart-wrapper {
    position: relative;
    height: 140px;
}

/* ─── Mini-sectores ─────────────────────────────────────────────────────────── */

.minisectors-section,
.braking-section {
    background: var(--panel-alt);
    border-radius: 14px;
    padding: 0.75rem;
    border: 1px solid var(--border);
}

.secondary-data-card {
    min-width: 0;
}

.secondary-data-card .minisectors-wrapper {
    min-width: 0;
}

.section-subheading {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    margin-bottom: 0.6rem;
    flex-wrap: wrap;
}

.section-subheading .panel-title {
    margin: 0;
    font-size: 0.9rem;
}

.section-subheading .note {
    color: var(--muted);
    font-size: 0.75rem;
    margin: 0;
}

.braking-threshold-control {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--muted);
}
.braking-threshold-control input {
    width: 4.5rem;
    padding: 0.15rem 0.35rem;
    font-size: 0.8rem;
}

/* Tabla de auditoría (panel admin) */
/* Modal de calidad de sesión */
.quality-dialog { max-width: 700px; width: 92%; }
.quality-body { overflow: auto; max-height: 70vh; }
.quality-report {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.78rem;
    line-height: 1.45;
    white-space: pre;
    margin: 0;
    color: var(--text-soft, #dfe6f1);
}

/* ─── Visor de setup del coche (iRacing) ─────────────────────────────────────── */
.setup-dialog { max-width: 760px; width: 92%; }
.setup-body { overflow: auto; max-height: 70vh; min-height: 0; }
.setup-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 0.85rem;
}
.setup-section {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.75rem 0.85rem;
    background: rgba(255, 255, 255, 0.02);
}
.setup-section-title {
    margin: 0 0 0.5rem;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--text, #eef3fb);
}
.setup-subsection { margin-top: 0.55rem; }
.setup-subtitle {
    margin: 0 0 0.2rem;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}
.setup-rows { display: flex; flex-direction: column; gap: 0.12rem; }
.setup-row {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    font-size: 0.78rem;
    line-height: 1.4;
    padding: 0.12rem 0;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.05);
}
.setup-row:last-child { border-bottom: none; }
.setup-key { color: var(--muted); }
.setup-val {
    color: var(--text-soft, #dfe6f1);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    text-align: right;
    white-space: nowrap;
}
.setup-empty { color: var(--muted); font-size: 0.85rem; margin: 0; }

/* Balance del coche (Nivel A) */
.balance-meta { color: var(--muted); font-size: 0.8rem; margin: 0 0 0.75rem; }
.balance-list { display: flex; flex-direction: column; gap: 0.6rem; }
.balance-insight {
    border: 1px solid var(--border, #2a3445);
    border-left-width: 3px;
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    background: var(--surface-soft, rgba(255, 255, 255, 0.02));
}
.balance-understeer { border-left-color: #f0a23b; }
.balance-oversteer { border-left-color: #e0563f; }
.balance-thermal { border-left-color: #4a9fe0; }
.balance-insight-head {
    display: flex; align-items: center; gap: 0.5rem;
    flex-wrap: wrap; margin-bottom: 0.35rem;
}
.balance-tag {
    font-size: 0.65rem; font-weight: 700; letter-spacing: 0.05em;
    padding: 0.1rem 0.4rem; border-radius: 4px; text-transform: uppercase;
    color: #0c1118;
}
.balance-tag-understeer { background: #f0a23b; }
.balance-tag-oversteer { background: #e0563f; }
.balance-tag-thermal { background: #4a9fe0; }
.balance-where { font-size: 0.78rem; color: var(--text-soft, #dfe6f1); font-weight: 600; }
.balance-phase {
    font-size: 0.68rem; font-weight: 600; letter-spacing: 0.02em;
    padding: 0.08rem 0.4rem; border-radius: 4px; cursor: help;
    background: rgba(120, 170, 255, 0.12); color: var(--text-soft, #dfe6f1);
    border: 1px solid rgba(120, 170, 255, 0.28);
}
.balance-confound {
    font-size: 0.66rem; font-weight: 700; letter-spacing: 0.03em;
    padding: 0.1rem 0.4rem; border-radius: 4px;
    background: rgba(240, 162, 59, 0.18); color: #f0a23b;
    border: 1px solid rgba(240, 162, 59, 0.5); cursor: help;
}
.balance-confounded { opacity: 0.92; }
/* Validación cruzada por guiñada (gyro_z): segunda señal objetiva. */
.balance-cross {
    font-size: 0.66rem; font-weight: 700; letter-spacing: 0.03em;
    padding: 0.1rem 0.4rem; border-radius: 4px; cursor: help;
}
.balance-cross-agree {
    background: rgba(74, 200, 130, 0.16); color: #57c98a;
    border: 1px solid rgba(74, 200, 130, 0.45);
}
.balance-cross-disagree {
    background: rgba(240, 162, 59, 0.16); color: #f0a23b;
    border: 1px solid rgba(240, 162, 59, 0.45);
}
/* Distintivos explicables: cursor de ayuda; al pulsar abren el modal de hint. */
.balance-hint { cursor: help; }
.balance-hint:focus-visible { outline: 2px solid rgba(120, 170, 255, 0.7); outline-offset: 1px; }
/* Modal de explicación (hint) — cómodo en móvil. */
.hint-modal {
    position: fixed; inset: 0; width: 100vw; height: 100vh;
    display: none; z-index: 1100; align-items: center; justify-content: center;
}
@supports (height: 100dvh) { .hint-modal { height: 100dvh; } }
.hint-modal.is-visible { display: flex; }
.hint-backdrop { position: absolute; inset: 0; background: rgba(4, 7, 19, 0.9); }
.hint-dialog {
    position: relative; z-index: 1; width: min(420px, 92vw);
    border-radius: 14px; background: var(--panel); border: 1px solid var(--border);
    padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: 0.6rem;
}
.hint-dialog header {
    display: flex; justify-content: space-between; align-items: center; gap: 0.5rem;
}
.hint-title { margin: 0; font-size: 0.95rem; }
.hint-text { margin: 0; font-size: 0.86rem; line-height: 1.45; color: var(--text-soft, #dfe6f1); }
.hint-close {
    background: none; border: none; color: var(--text-soft, #dfe6f1);
    font-size: 1.1rem; cursor: pointer; padding: 0.1rem 0.3rem; line-height: 1;
}
.hint-close:hover { color: var(--text, #fff); }
/* Curva con ancla geográfica: pulsable para centrar el mapa (panel inline). */
.balance-insight-clickable { cursor: pointer; transition: border-color 0.12s ease, background 0.12s ease; }
.balance-insight-clickable:hover,
.balance-insight-clickable:focus-visible {
    border-color: rgba(120, 170, 255, 0.6);
    background: rgba(120, 170, 255, 0.06); outline: none;
}
.balance-insight-clickable .balance-where .mdi { font-size: 0.85em; opacity: 0.75; }
/* Curva seleccionada (sincronizada con el ápex resaltado en el mapa). */
.balance-insight.is-selected {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--panel-alt, rgba(255,255,255,0.02)) 82%, var(--accent) 18%);
    box-shadow: inset 3px 0 0 var(--accent);
}
.balance-insight.is-selected .balance-where { color: var(--accent); }
/* Nivel B: cambio de reglaje sugerido. */
.balance-rx {
    margin-top: 0.6rem; padding: 0.5rem 0.6rem; border-radius: 6px;
    font-size: 0.82rem; line-height: 1.35;
}
.balance-rx-available {
    background: rgba(86, 197, 122, 0.12);
    border: 1px solid rgba(86, 197, 122, 0.4);
}
.balance-rx-note {
    background: rgba(255, 255, 255, 0.04);
    border: 1px dashed rgba(255, 255, 255, 0.18);
}
.balance-rx-tag {
    font-size: 0.64rem; font-weight: 700; letter-spacing: 0.04em;
    text-transform: uppercase; color: var(--muted);
}
.balance-rx-conf {
    font-size: 0.62rem; font-weight: 700; letter-spacing: 0.03em;
    text-transform: uppercase; color: #e0a23a;
    border: 1px solid rgba(224, 162, 58, 0.5); border-radius: 4px;
    padding: 0.04rem 0.32rem;
}
.balance-rx-why { margin: 0.3rem 0 0; font-size: 0.78rem; color: var(--muted); }
.balance-rx-alts { margin: 0.3rem 0 0; font-size: 0.74rem; color: var(--muted); }
.balance-rx-note p:first-child, .balance-rx-available strong { display: inline; }
.balance-conf { font-size: 0.72rem; color: var(--muted); margin-left: auto; }
.balance-headline { margin: 0 0 0.2rem; font-weight: 600; font-size: 0.9rem; }
.balance-detail { margin: 0; font-size: 0.82rem; color: var(--muted); }
.balance-evidence { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.5rem; }
.balance-chip {
    font-size: 0.7rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    color: var(--text-soft, #dfe6f1);
    background: rgba(255, 255, 255, 0.05);
    padding: 0.12rem 0.4rem; border-radius: 4px;
}
.balance-corners { margin-top: 0.9rem; }
.balance-corners summary { cursor: pointer; color: var(--muted); font-size: 0.82rem; }
.balance-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; margin-top: 0.5rem; }
.balance-table th, .balance-table td {
    text-align: right; padding: 0.25rem 0.5rem;
    border-bottom: 1px solid var(--border, #2a3445); white-space: nowrap;
}
.balance-table th:first-child, .balance-table td:first-child,
.balance-table th:nth-child(2), .balance-table td:nth-child(2) { text-align: left; }
.balance-table th { color: var(--muted); font-weight: 600; }

.audit-table { font-size: 0.8rem; }
.audit-table th, .audit-table td { white-space: nowrap; text-align: left; padding: 0.3rem 0.5rem; }
.audit-table .audit-detail { white-space: normal; color: var(--muted); }
.audit-table .audit-ts { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.audit-event {
    display: inline-block; padding: 0.05rem 0.45rem; border-radius: 6px;
    font-size: 0.72rem; font-weight: 600; background: rgba(255,255,255,0.08);
}
.audit-login_failed { background: rgba(229, 72, 77, 0.22); color: #ff9aa0; }
.audit-login_success { background: rgba(48, 164, 108, 0.22); color: #74e0a3; }
.audit-session_deleted, .audit-user_deleted { background: rgba(229, 72, 77, 0.18); color: #ff9aa0; }
.audit-device_token_invalid { background: rgba(245, 166, 35, 0.22); color: #ffc46b; }
.audit-token-box { margin-top: 0.3rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; }
.audit-token {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.75rem;
    color: var(--text, inherit); background: rgba(255,255,255,0.06);
    padding: 0.1rem 0.35rem; border-radius: 4px; word-break: break-all; white-space: normal;
}
.audit-token-copy { padding: 0.1rem 0.3rem; width: auto; height: auto; min-width: 0; min-height: 0; font-size: 0.85rem; line-height: 1; }
.audit-token-actions, .audit-token-form { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; }
.audit-token-actions { flex-basis: 100%; }
.audit-token-form:empty { display: none; }
.audit-token-form { flex-basis: 100%; }
.audit-token-form select, .audit-token-form input { font-size: 0.78rem; padding: 0.2rem 0.4rem; }
.audit-token-btn { font-size: 0.75rem; padding: 0.15rem 0.55rem; }
.audit-token-state { font-size: 0.75rem; color: var(--muted); }
.audit-token-state.is-ok { color: #74e0a3; }

.minisectors-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.minisectors-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
    min-width: 280px;
}

.minisectors-table th {
    padding: 0.3rem 0.5rem;
    text-align: right;
    color: var(--muted);
    font-weight: 600;
    font-size: 0.72rem;
    white-space: nowrap;
}

.minisectors-table th.sector-idx-header {
    text-align: left;
}

.minisectors-table td {
    padding: 0.25rem 0.5rem;
    text-align: right;
    border-radius: 4px;
}

.sector-label {
    text-align: left !important;
    color: var(--muted);
    font-size: 0.7rem;
    white-space: nowrap;
    padding-right: 0.75rem !important;
}

.sector-cell {
    font-variant-numeric: tabular-nums;
    border-radius: 4px !important;
}

.sector-best {
    font-weight: 700;
}

.minisectors-table tbody tr.sector-active td {
    outline: 1px solid var(--accent);
    outline-offset: -1px;
}

.minisectors-table tbody tr.sector-active .sector-label {
    color: var(--accent);
    font-weight: 600;
}

.analysis-secondary-grid.has-maximized .secondary-data-card.is-maximized {
    grid-column: 1 / -1;
}

/* ─── Análisis de frenada ───────────────────────────────────────────────────── */

.braking-lap {
    margin-bottom: 1rem;
}

.braking-lap:last-child {
    margin-bottom: 0;
}

.braking-lap-label {
    font-size: 0.82rem;
    font-weight: 600;
    margin: 0 0 0.4rem;
}

.braking-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
}

.braking-table th {
    padding: 0.25rem 0.5rem;
    text-align: left;
    color: var(--muted);
    font-weight: 600;
    font-size: 0.72rem;
    border-bottom: 1px solid var(--border);
}

.braking-table td {
    padding: 0.25rem 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.analysis-controls .ghost-btn.is-active {
    border-color: rgba(255, 176, 32, 0.55);
    background: rgba(255, 122, 24, 0.18);
    color: #ffe0b8;
}

.range-analysis-section {
    margin-top: 1rem;
}

.range-analysis-table-wrapper {
    min-width: 0;
}

.range-analysis-table th,
.range-analysis-table td {
    white-space: nowrap;
}

.stats-channel-group {
    text-align: center;
}

.stats-channel-sub {
    font-size: 0.68rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.range-lap-chip {
    display: inline-block;
    width: 0.65rem;
    height: 0.65rem;
    border-radius: 999px;
    background: var(--lap-color, var(--accent));
    margin-right: 0.45rem;
    vertical-align: middle;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.decel-peak {
    color: var(--danger);
    font-weight: 600;
}

.braking-no-data {
    font-size: 0.78rem;
    margin: 0.25rem 0;
}

@media (max-width: 720px) {
    .evolution-chart-wrapper {
        height: 120px;
    }

    .analysis-secondary-grid {
        grid-template-columns: 1fr;
    }

    .minisectors-table {
        font-size: 0.72rem;
    }

    .braking-table {
        font-size: 0.72rem;
    }
}

/* ─── Tendencia de ritmo ────────────────────────────────────────────────────── */

.rhythm-section {
    padding: 0.75rem 0 0;
    border-top: 1px solid var(--border);
    margin-top: 0.5rem;
}

.rhythm-section .graph-title {
    margin-bottom: 0.5rem;
}

.rhythm-chart-wrapper {
    position: relative;
    height: 150px;
}

/* ─── Sector times en tabla ──────────────────────────────────────────────────── */

.th-sector {
    color: var(--muted);
    font-size: 0.78rem;
    min-width: 52px;
}

.sector-td {
    font-variant-numeric: tabular-nums;
    font-size: 0.78rem;
    text-align: right;
    border-radius: 3px;
}

/* ─── Swipe dots ─────────────────────────────────────────────────────────────── */

.swipe-dots {
    display: none;
    justify-content: center;
    gap: 6px;
    padding: 4px 0 2px;
}

.swipe-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transition: background 0.2s, transform 0.2s;
}

.swipe-dot.dot-active {
    background: var(--accent);
    transform: scale(1.3);
}

@media (max-width: 720px) {
    .swipe-dots {
        display: flex;
    }

    .rhythm-chart-wrapper {
        height: 120px;
    }
}

/* ─── Vuelta óptima teórica ─────────────────────────────────────────────────── */

.summary-card.optimal-card .summary-value {
    color: var(--accent);
}

.summary-card.optimal-card .note {
    color: var(--success);
    font-size: 0.72rem;
}

/* ─── Pin de referencia en comparación ──────────────────────────────────────── */

.comparison-card .card-actions {
    display: flex;
    align-items: center;
    gap: 0.1rem;
    flex-shrink: 0;
}

.toggle-lap-visibility {
    opacity: 0.45;
    font-size: 1rem;
    transition: opacity 0.15s;
}

.toggle-lap-visibility:hover,
.toggle-lap-visibility.is-active {
    opacity: 1;
}

.toggle-lap-visibility.is-active {
    color: var(--text-muted);
}

.comparison-card.is-hidden-lap {
    opacity: 0.45;
}

.comparison-card.is-hidden-lap .color-dot {
    opacity: 0.4;
}

.pin-compare {
    opacity: 0.45;
    font-size: 1rem;
    transition: opacity 0.15s;
}

.pin-compare:hover,
.pin-compare.is-active {
    opacity: 1;
}

.pin-compare.is-active {
    color: var(--accent);
}

.comparison-card.is-pinned-ref {
    border-left: 2px solid var(--accent);
}

.comparison-card.is-saved-reference {
    box-shadow: inset 0 0 0 1px rgba(0, 184, 255, 0.24);
}

.save-reference-lap {
    opacity: 0.55;
    font-size: 1rem;
    transition: opacity 0.15s;
}

.save-reference-lap:hover,
.save-reference-lap.is-active {
    opacity: 1;
}

.save-reference-lap.is-active {
    color: var(--accent);
}

/* ─── Session card: potencial ───────────────────────────────────────────────── */

.session-potential {
    color: var(--success);
    font-size: 0.78rem;
    font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   NEW UX/UI REDESIGN — 3-column layout, bottom-nav, FAB, settings drawer
   ═══════════════════════════════════════════════════════════════════════════════ */

/* ─── Desktop 3-column layout ────────────────────────────────────────────────── */

@media (min-width: 900px) {
    .mobile-tabs { display: none !important; }
    .bottom-nav { display: none !important; }

    /* 2-column layout: sessions sidebar | main area */
    .app-main {
        grid-template-columns: 280px 1fr;
        grid-template-rows: auto;
        align-items: start;
    }

    #sessionsPanel {
        grid-column: 1;
        grid-row: 1;
        position: sticky;
        top: 1rem;
        max-height: calc(100vh - 7rem);
        overflow-y: auto;
    }

    .main-area {
        grid-column: 2;
        grid-row: 1;
        display: flex;
        flex-direction: column;
        gap: 1rem;
        min-width: 0;
    }

    /* Pit-lane review + Lap table side by side */
    .details-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
        align-items: start;
    }

    /* Always show these panels on desktop */
    .details-row .panel,
    #insightsPanel,
    #lapPanel {
        display: flex !important;
    }

    body:not(.section-history) #historyPanel { display: none; }
    body.section-history #comparisonPanel { display: none; }
    body.section-history .details-row { display: none; }

}

/* ─── Mobile layout ──────────────────────────────────────────────────────────── */

@media (max-width: 899px) {
    .main-area { display: contents; }
    .details-row { display: contents; }
}

/* ─── Bottom nav ─────────────────────────────────────────────────────────────── */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: rgba(10, 14, 22, 0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    padding: 0.35rem 0 calc(0.35rem + env(safe-area-inset-bottom));
    display: none;
    justify-content: space-around;
    align-items: center;
    gap: 0;
}

.bottom-nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 0.4rem 0.25rem;
    background: none;
    border: none;
    color: var(--muted);
    font-size: 0.65rem;
    cursor: pointer;
    transition: color 0.2s;
    min-height: 52px;
}

.bottom-nav-btn i { font-size: 1.35rem; display: block; }
.bottom-nav-btn.bottom-nav-active { color: var(--accent); }
.bottom-nav-btn.bottom-nav-active i {
    filter: drop-shadow(0 0 6px var(--accent));
}

@media (max-width: 899px) {
    .bottom-nav { display: flex; }
    .app-shell { padding-bottom: calc(4rem + env(safe-area-inset-bottom)); }
}

/* ─── Header nav (desktop only) ──────────────────────────────────────────────── */

.header-nav {
    display: none;
    gap: 0.25rem;
    align-items: center;
}

.nav-section-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.8rem;
    border-radius: 10px;
    background: none;
    border: 1px solid transparent;
    color: var(--muted);
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.nav-section-btn:hover { color: var(--text); background: rgba(255,255,255,0.06); }
.nav-section-btn.nav-section-active { color: var(--accent); border-color: rgba(255,122,24,0.3); background: rgba(255,122,24,0.08); }

@media (min-width: 900px) {
    .header-nav { display: flex; }
}

/* ─── FAB ────────────────────────────────────────────────────────────────────── */

.fab {
    position: fixed;
    bottom: calc(5rem + env(safe-area-inset-bottom));
    right: 1rem;
    z-index: 90;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.2rem;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #04111f;
    font-weight: 700;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(255, 122, 24, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
}

.fab:hover { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(255,122,24,0.5); }
.fab[hidden] { display: none !important; }

@media (min-width: 900px) {
    .fab { display: none !important; }
}

/* ─── History panel ──────────────────────────────────────────────────────────── */

.history-panel {
    min-height: 300px;
}

.history-panel .evolution-section,
.history-panel .rhythm-section {
    padding-top: 0;
    border-top: none;
    margin-top: 0;
}

/* ─── Settings drawer ────────────────────────────────────────────────────────── */

.settings-drawer {
    position: fixed;
    top: 0;
    right: -320px;
    width: 300px;
    height: 100vh;
    z-index: 200;
    background: var(--panel);
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 1.25rem;
    gap: 1rem;
    overflow-y: auto;
}

.settings-drawer.is-open { right: 0; }

.settings-drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.settings-backdrop {
    position: fixed;
    inset: 0;
    z-index: 199;
    background: rgba(0,0,0,0.5);
    display: none;
}

.settings-backdrop.is-visible { display: block; }

.settings-section {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.settings-section-label {
    font-size: 0.75rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 0;
}

/* ─── Keyboard shortcut hint ─────────────────────────────────────────────────── */

.kbd-hint {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.7rem;
    color: var(--muted);
    opacity: 0.7;
}

kbd {
    display: inline-block;
    padding: 1px 5px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.72rem;
    background: rgba(255,255,255,0.06);
}

/* ─── Override old grid for new 3-column layout ──────────────────────────────── */

@media (min-width: 1200px) {
    .app-main {
        grid-template-columns: 300px 1fr;
    }
    .details-row {
        grid-template-columns: 380px 1fr;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SESSIONS PANEL REDESIGN
   ═══════════════════════════════════════════════════════════════════════════════ */

/* ─── Panel header compact ───────────────────────────────────────────────────── */

.sessions-header {
    padding-bottom: 0;
}

.sessions-header .panel-title {
    font-size: 0.9rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
}

/* ─── Usage summary: thin pill ───────────────────────────────────────────────── */

#sessionsPanel .session-usage-summary {
    padding: 0.35rem 0.65rem;
    font-size: 0.75rem;
    border-radius: 8px;
    background: rgba(255, 122, 24, 0.07);
    border-color: rgba(255, 122, 24, 0.15);
}

/* ─── Filters: compact single-column ─────────────────────────────────────────── */

#sessionsPanel .filters-panel {
    padding: 0.15rem 0.5rem 0.4rem;
    border-radius: 12px;
}

#sessionsPanel .filters-toggle {
    font-size: 0.8rem;
    padding: 0.25rem 0;
    gap: 0.35rem;
    color: var(--muted);
}

#sessionsPanel .filters-toggle-label {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

#sessionsPanel .filters-toggle-icon {
    width: 1.4rem;
    height: 1.4rem;
}

#sessionsPanel .filters-row {
    grid-template-columns: 1fr;
    gap: 0.4rem;
    padding: 0.15rem 0;
}

/* ─── Day groups ─────────────────────────────────────────────────────────────── */

.day-group {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.day-header {
    width: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.55rem 0.65rem;
    background: var(--panel-alt);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s, background 0.15s;
    user-select: none;
}

.day-header:hover {
    border-color: rgba(255, 122, 24, 0.35);
    background: rgba(255, 122, 24, 0.05);
}

.day-header:focus-visible {
    outline: 3px solid rgba(255, 122, 24, 0.28);
    outline-offset: -3px;
}

.day-header-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
    flex: 1;
}

.day-name {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text);
    text-transform: capitalize;
}

.day-stats {
    font-size: 0.72rem;
    color: var(--accent);
    font-weight: 600;
}

.day-circuit {
    font-size: 0.68rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.day-meta {
    font-size: 0.68rem;
    color: var(--muted);
}

.day-toggle-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    margin-top: 2px;
    transition: transform 0.25s;
}

.day-toggle-icon::before {
    content: '';
    border: solid currentColor;
    border-width: 0 1.5px 1.5px 0;
    display: inline-block;
    padding: 3px;
    transform: rotate(45deg);
    transition: transform 0.25s;
}

.day-header[aria-expanded="false"] .day-toggle-icon {
    transform: rotate(-90deg);
}

.day-sessions {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 0.25rem 0 0.1rem 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.2s ease;
    max-height: 2000px;
    opacity: 1;
}

.day-sessions.is-collapsed {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    pointer-events: none;
}

#sessionsPanel .filter-group {
    gap: 0.1rem;
    font-size: 0.68rem;
}

#sessionsPanel .filter-group label {
    font-size: 0.65rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

#sessionsPanel .filter-inputs input,
#sessionsPanel .filter-group select {
    padding: 0.28rem 0.4rem;
    font-size: 0.75rem;
    border-radius: 7px;
    height: 28px;
    line-height: 1;
}

#sessionsPanel .filter-inputs {
    gap: 0.2rem;
}

/* date inputs: hide the icon on webkit to save space */
#sessionsPanel input[type="date"]::-webkit-calendar-picker-indicator {
    width: 14px;
    height: 14px;
    opacity: 0.5;
    cursor: pointer;
}

.filter-reset-btn {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    padding: 0.3rem 0.6rem;
    color: var(--muted);
    border-color: transparent;
    background: none;
    margin-top: 0.1rem;
}

.filter-reset-btn:hover {
    color: var(--text);
}

/* ─── Session list: fill available space in sidebar ──────────────────────────── */

#sessionsPanel {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

#sessionsPanel .session-list {
    flex: 1;
    min-height: 100px;
    max-height: none;
    gap: 0.4rem;
}

@media (min-width: 900px) {
    #sessionsPanel .session-list {
        /* sidebar already constrains height via sticky + max-height */
        overflow-y: auto;
    }
}

/* ─── Session cards: compact 3-row design ────────────────────────────────────── */

.session-card {
    padding: 0.6rem 0.65rem;
    padding-top: 0.6rem;
    padding-right: 0.65rem;
    border-radius: 12px;
    gap: 0.2rem;
    display: flex;
    flex-direction: column;
}

/* Override the old grid-template-columns */
.session-card {
    grid-template-columns: unset;
}

.sc-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
}

.sc-top {
    justify-content: space-between;
}

.sc-date {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex: 1;
}

.session-card .session-remove-btn {
    position: static;
    opacity: 0;
    font-size: 0.85rem;
    width: 22px;
    height: 22px;
    min-width: 22px;
    flex-shrink: 0;
    transition: opacity 0.15s;
}

.session-card:hover .session-remove-btn,
.session-card:focus-within .session-remove-btn {
    opacity: 0.6;
}

.session-card:hover .session-remove-btn:hover {
    opacity: 1;
}

.sc-times {
    gap: 0.4rem;
    flex-wrap: nowrap;
}

.sc-best {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
}

.sc-circuit,
.sc-meta {
    font-size: 0.72rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Cartel «iRacing en directo» */
.live-banner {
    position: fixed;
    left: 50%;
    bottom: 1rem;
    transform: translateX(-50%);
    z-index: 1200;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    max-width: calc(100vw - 2rem);
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border, rgba(255, 255, 255, 0.15));
    border-radius: 999px;
    background: var(--surface, #1c1f26);
    color: var(--text);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
    font-size: 0.82rem;
}

.live-banner[hidden] { display: none; }

.live-banner-dot {
    flex: none;
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 50%;
    background: #d9534f;
    animation: sc-live-pulse 1.6s ease-in-out infinite;
}

.live-banner-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.live-banner-btn { flex: none; padding: 0.25rem 0.8rem; }

@media (prefers-reduced-motion: reduce) {
    .live-banner-dot { animation: none; }
}

/* Sesión recibida en vivo que todavía no se ha cerrado */
.sc-live {
    margin-left: 0.4rem;
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
    font-size: 0.66rem;
    font-weight: 700;
    color: #fff;
    background: #d9534f;
    animation: sc-live-pulse 1.6s ease-in-out infinite;
}

@keyframes sc-live-pulse {
    50% { opacity: 0.55; }
}

@media (prefers-reduced-motion: reduce) {
    .sc-live { animation: none; }
}

/* Session id label in Pit-lane review (debugging) — subtle, monospace, click-to-copy */
.session-id-label {
    margin: 0.15rem 0 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.68rem;
    color: var(--muted);
    opacity: 0.65;
    cursor: pointer;
}
.session-id-label:hover {
    opacity: 1;
    color: var(--accent);
}

/* Active card accent line */
.session-card.active {
    border-left: 3px solid var(--accent);
    padding-left: calc(0.65rem - 2px);
}

/* ─── Mobile overrides (keep cards a bit larger) ─────────────────────────────── */

@media (max-width: 899px) {
    .session-card {
        padding: 0.7rem 0.75rem;
        gap: 0.25rem;
        border-radius: 14px;
    }

    .sc-date { font-size: 0.85rem; }
    .sc-best { font-size: 0.95rem; }
    .sc-circuit, .sc-meta { font-size: 0.78rem; }

    .session-card .session-remove-btn {
        opacity: 0.5;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   FLAT THEME OVERRIDES
   Flat, data-first, clean typography. No shadows, minimal borders.
   ═══════════════════════════════════════════════════════════════════════════════ */

:root {
    --bg: #0d0f14;
    --panel: #13171f;
    --panel-alt: #181d27;
    --text: #dce5f0;
    --muted: #6b7d99;
    --accent: #ff8a30;
    --accent-strong: #ff8a30;
    --border: rgba(255, 255, 255, 0.07);
    --shadow: none;
    --radius-card: 8px;
    --radius-sm: 6px;
    font-family: 'Inter', 'Segoe UI', 'Roboto', sans-serif;
}

/* ─── Flat cards ─────────────────────────────────────────────────────────────── */

.panel.card,
.graph-card,
.session-card,
.day-header,
.filters-panel,
.summary-card,
.comparison-card,
.minisectors-section,
.braking-section,
.history-panel,
.settings-drawer {
    box-shadow: none !important;
    border-radius: var(--radius-card) !important;
}

.app-header,
.status-banner {
    box-shadow: none !important;
    border-radius: var(--radius-card) !important;
}

/* ─── Header: flat strip ─────────────────────────────────────────────────────── */

.app-header {
    background: var(--panel) !important;
    border: 1px solid var(--border) !important;
    padding: 0.6rem 1rem !important;
}

.brand-icon {
    background: var(--accent) !important;
    border-radius: var(--radius-sm) !important;
    width: 32px !important;
    height: 32px !important;
    font-size: 0.85rem !important;
}

.brand-title {
    font-size: 0.95rem !important;
}

/* ─── Status banner: thin pill ───────────────────────────────────────────────── */

.status-banner {
    background: var(--panel) !important;
    border: 1px solid var(--border) !important;
    padding: 0.4rem 0.85rem !important;
    font-size: 0.78rem !important;
}

/* ─── Buttons: flat ──────────────────────────────────────────────────────────── */

.primary-btn {
    background: var(--accent) !important;
    border-radius: var(--radius-sm) !important;
    box-shadow: none !important;
    font-weight: 600 !important;
    letter-spacing: 0.02em !important;
}

.ghost-btn {
    border-radius: var(--radius-sm) !important;
    box-shadow: none !important;
}

/* ─── Nav & tabs: flat underline style ───────────────────────────────────────── */

.nav-section-btn {
    border-radius: var(--radius-sm) !important;
    font-size: 0.8rem !important;
}

.nav-section-btn.nav-section-active {
    background: rgba(255, 122, 24, 0.1) !important;
    border-color: rgba(255, 122, 24, 0.25) !important;
}

.bottom-nav {
    background: var(--panel) !important;
    border-top: 1px solid var(--border) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

/* ─── Summary cards: compact data blocks ─────────────────────────────────────── */

.summary-card {
    background: var(--panel-alt) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm) !important;
    padding: 0.55rem 0.65rem !important;
}

.summary-value {
    font-size: 1.05rem !important;
    font-weight: 700 !important;
    letter-spacing: -0.01em !important;
}

.summary-label {
    font-size: 0.65rem !important;
    text-transform: uppercase !important;
    letter-spacing: 0.06em !important;
    color: var(--muted) !important;
}

/* ─── Session cards: flat rows ───────────────────────────────────────────────── */

.session-card {
    border-radius: var(--radius-sm) !important;
    border: 1px solid var(--border) !important;
    background: var(--panel-alt) !important;
}

.session-card.active {
    border-left: 2px solid var(--accent) !important;
    background: rgba(255, 122, 24, 0.04) !important;
}

.session-card:hover {
    border-color: rgba(255, 122, 24, 0.3) !important;
}

/* ─── Day groups: thin separator ─────────────────────────────────────────────── */

.day-header {
    background: transparent !important;
    border: none !important;
    border-bottom: 1px solid var(--border) !important;
    border-radius: 0 !important;
    padding: 0.45rem 0.25rem !important;
}

.day-header:hover {
    background: rgba(255, 122, 24, 0.03) !important;
    border-color: rgba(255, 122, 24, 0.2) !important;
}

.day-sessions {
    border-left: 2px solid rgba(255, 122, 24, 0.15) !important;
}

.day-name {
    font-size: 0.78rem !important;
    color: var(--muted) !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
}

.day-stats {
    font-size: 0.7rem !important;
}

/* ─── Charts & map: flat containers ──────────────────────────────────────────── */

.graph-card {
    background: var(--panel-alt) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-card) !important;
}

/* ─── Filters: borderless inputs ─────────────────────────────────────────────── */

#sessionsPanel .filters-panel {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
}

#sessionsPanel .filter-inputs input,
#sessionsPanel .filter-group select {
    background: var(--panel-alt) !important;
    border-color: var(--border) !important;
    border-radius: var(--radius-sm) !important;
}

/* ─── Loading bar instead of spinner ─────────────────────────────────────────── */

.session-usage-summary {
    background: transparent !important;
    border: none !important;
    border-bottom: 1px solid var(--border) !important;
    border-radius: 0 !important;
    padding: 0.3rem 0 0.3rem 0 !important;
    font-size: 0.72rem !important;
    color: var(--muted) !important;
}

/* ─── Toggle chips: flat pills ───────────────────────────────────────────────── */

.toggle-chip {
    border-radius: var(--radius-sm) !important;
}

/* ─── FAB: flat ──────────────────────────────────────────────────────────────── */

.fab {
    box-shadow: none !important;
    border-radius: var(--radius-sm) !important;
    background: var(--accent) !important;
    color: #0d0f14 !important;
}

/* ─── Modals: flat sheets ─────────────────────────────────────────────────────── */

.notes-dialog,
.reanalyze-dialog,
.transfer-dialog,
.bulk-dialog {
    box-shadow: none !important;
    border-radius: var(--radius-card) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

/* ─── Fix: filter inputs confined to container ───────────────────────────────── */

.filters-panel-body {
    overflow: hidden;
    min-width: 0;
}

.filters-row {
    min-width: 0;
}

.filter-group {
    min-width: 0;
}

.filter-inputs {
    min-width: 0;
}

.filter-inputs input,
.filter-group select,
.filter-group input {
    min-width: 0;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
}

/* ─── Hide scrollbar on session list ────────────────────────────────────────── */

.session-list {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.session-list::-webkit-scrollbar {
    display: none;
}

#sessionsPanel {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#sessionsPanel::-webkit-scrollbar {
    display: none;
}

/* ─── Graph card maximize / minimize ─────────────────────────────────────────── */

.graph-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.25rem;
}

.graph-card-header .graph-title {
    flex: 1;
    min-width: 0;
}

.card-maximize-btn,
.card-minimize-btn {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 0.15rem 0.25rem;
    border-radius: 4px;
    font-size: 0.85rem;
    line-height: 1;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}

.graph-card:hover .card-maximize-btn,
.graph-card:hover .card-minimize-btn {
    opacity: 0.65;
}

.card-maximize-btn:hover,
.card-minimize-btn:hover {
    opacity: 1 !important;
    color: var(--accent);
}

.graph-card.is-minimized {
    height: auto !important;
    min-height: 0 !important;
}

.graph-card.is-minimized .card-minimize-btn {
    opacity: 0.5;
}

.graph-card.is-minimized > :not(.graph-card-header) {
    display: none !important;
}

/* chart-wrapper: Chart.js reads this div's height (not the canvas directly) */
.chart-wrapper {
    position: relative;
    width: 100%;
    height: 220px;
}

.chart-wrapper canvas {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
}

.gg-chart-wrapper {
    width: 100%;
    aspect-ratio: 1 / 1;
    height: auto !important;
    min-height: 0 !important;
    max-width: 100%;
    max-height: 100%;
    margin: 8px auto 12px;
    align-self: center;
}

.stacked-telemetry-wrapper {
    flex: 1 1 0%;
    min-height: 0;
    display: grid;
    grid-template-rows: repeat(6, minmax(92px, 1fr));
    gap: 0;
}

.stacked-telemetry-chart {
    position: relative;
    min-height: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.stacked-telemetry-chart:first-child {
    border-top: 0;
}

.stacked-telemetry-chart canvas {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
}

/* Override the global canvas rule for wrappers */
.graph-card canvas {
    width: 100% !important;
    height: 100% !important;
    min-height: 0;
}

/* Maximized layout: big card full-width on top, others 2-per-row below */
.graph-grid.has-maximized {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    align-items: start;
}

.graph-grid.has-maximized .graph-card.is-maximized {
    grid-column: 1 / -1 !important;
    grid-row: 1 !important;
    order: -1 !important;
}

.graph-grid.has-maximized .graph-card:not(.is-maximized) {
    grid-row: auto !important;
    order: unset !important;
}

/* Heights set on chart-wrapper and map-view so Chart.js reads the container */
.graph-grid.has-maximized .graph-card.is-maximized .chart-wrapper,
.graph-grid.has-maximized .graph-card.is-maximized .map-view {
    height: clamp(300px, 50vh, 480px) !important;
}

.graph-grid.has-maximized .graph-card:not(.is-maximized) .chart-wrapper,
.graph-grid.has-maximized .graph-card:not(.is-maximized) .map-view {
    height: 160px !important;
}

.graph-grid.has-maximized .graph-card:not(.is-maximized) .graph-title {
    font-size: 0.75rem;
}

/* Mobile: single column, all normal size */
@media (max-width: 720px) {
    .chart-wrapper { height: 180px; }

    .graph-grid.has-maximized {
        grid-template-columns: 1fr !important;
    }

    .graph-grid.has-maximized .graph-card.is-maximized,
    .graph-grid.has-maximized .graph-card:not(.is-maximized) {
        grid-column: 1 !important;
        grid-row: auto !important;
    }

    .graph-grid.has-maximized .graph-card.is-maximized .chart-wrapper,
    .graph-grid.has-maximized .graph-card.is-maximized .map-view,
    .graph-grid.has-maximized .graph-card:not(.is-maximized) .chart-wrapper,
    .graph-grid.has-maximized .graph-card:not(.is-maximized) .map-view {
        height: 180px !important;
    }
}

/* ─── Analysis library panel ─────────────────────────────────────────────────── */

.analysis-card-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto;
    flex: 1;
}

.analysis-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 0.85rem;
    background: var(--panel-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: border-color 0.15s;
    cursor: pointer;
}

.analysis-card:hover {
    border-color: rgba(255, 122, 24, 0.3);
}

.analysis-card.is-active {
    border-left: 3px solid var(--accent);
    background: rgba(255, 122, 24, 0.05);
}

.analysis-card-main {
    flex: 1;
    min-width: 0;
}

.analysis-card-title {
    margin: 0;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.analysis-card-meta {
    margin: 0.1rem 0 0;
    font-size: 0.72rem;
    color: var(--muted);
}

.analysis-card-stats {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    margin-top: 0.3rem;
}

.analysis-card-stats span {
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.15rem 0.45rem;
    color: var(--muted);
    font-size: 0.68rem;
    line-height: 1.2;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.analysis-card-actions {
    display: flex;
    gap: 0.3rem;
    flex-shrink: 0;
}

/* ─── Active analysis bar ────────────────────────────────────────────────────── */

.active-analysis-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.65rem;
    background: rgba(255, 122, 24, 0.08);
    border: 1px solid rgba(255, 122, 24, 0.2);
    border-radius: 6px;
    font-size: 0.78rem;
    color: var(--accent);
    flex-shrink: 0;
    max-width: 280px;
    min-width: 0;
    order: -1;
}

.active-analysis-bar[hidden] {
    display: none;
}

.quick-analysis-btn[hidden] {
    display: none;
}

.active-analysis-bar i {
    flex-shrink: 0;
}

#activeAnalysisName {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    color: var(--text);
    font-weight: 600;
}

/* ─── Analysis edit drawer ───────────────────────────────────────────────────── */

.analysis-edit-drawer {
    position: fixed;
    top: 0;
    right: -380px;
    width: 360px;
    max-width: 95vw;
    height: 100vh;
    z-index: 210;
    background: var(--panel);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1.25rem;
    overflow-y: auto;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.analysis-edit-drawer.is-open {
    right: 0;
}

.analysis-edit-backdrop {
    position: fixed;
    inset: 0;
    z-index: 209;
    background: rgba(0,0,0,0.4);
    display: none;
}

.analysis-edit-backdrop.is-visible {
    display: block;
}

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

.analysis-title-input {
    flex: 1;
    background: var(--panel-alt);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.4rem 0.6rem;
    min-width: 0;
}

.analysis-notes-input {
    width: 100%;
    background: var(--panel-alt);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.82rem;
    padding: 0.5rem 0.6rem;
    resize: vertical;
    min-height: 60px;
    box-sizing: border-box;
}

.analysis-edit-laps {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.analysis-edit-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

/* ─── Analysis picker dropdown ───────────────────────────────────────────────── */

.analysis-picker {
    position: fixed;
    z-index: 300;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 240px;
    max-width: calc(100vw - 16px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    overflow: hidden;
}

.analysis-picker-list {
    max-height: 220px;
    overflow-y: auto;
}

.analysis-picker-item {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    font-size: 0.82rem;
    text-align: left;
    cursor: pointer;
    transition: background 0.1s;
}

.analysis-picker-item:hover {
    background: rgba(255,255,255,0.06);
}

.analysis-picker-item.is-active {
    color: var(--accent);
}

.analysis-picker-more {
    color: var(--accent);
    font-weight: 600;
}

.analysis-picker-new {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: none;
    border: none;
    color: var(--accent);
    font-size: 0.82rem;
    text-align: left;
    cursor: pointer;
}

.analysis-picker-new:hover {
    background: rgba(255,122,24,0.08);
}

.analysis-picker-current {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    width: 100%;
    padding: 0.55rem 0.75rem;
    background: rgba(255,122,24,0.1);
    border: none;
    border-bottom: 1px solid var(--border);
    color: var(--accent);
    font-size: 0.82rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.analysis-picker-current:hover {
    background: rgba(255,122,24,0.18);
}

/* ─── Add-to-analysis button in lap table ────────────────────────────────────── */

.add-analysis-btn {
    color: var(--accent);
    border: none;
    background: none;
    padding: 0.2rem 0.4rem;
}

.add-analysis-btn:hover {
    background: rgba(255,122,24,0.1) !important;
}

/* ─── Lap badges ─────────────────────────────────────────────────────────────── */

.lap-badge {
    display: inline-block;
    margin-left: 0.35rem;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    vertical-align: middle;
    line-height: 1.5;
}

.lap-badge-incomplete {
    background: rgba(255, 152, 0, 0.18);
    color: #ff9800;
    border: 1px solid rgba(255, 152, 0, 0.35);
}

.lap-badge-offtrack {
    background: rgba(244, 67, 54, 0.15);
    color: #f44336;
    border: 1px solid rgba(244, 67, 54, 0.35);
}

/* Tramos OUT/IN (antes del 1er cruce / tras el último) */
.lap-badge-segment {
    margin-left: 0;
    background: rgba(255, 138, 48, 0.14);
    color: var(--accent);
    border: 1px solid rgba(255, 138, 48, 0.4);
    letter-spacing: 0.06em;
}

.lap-badge-in {
    background: rgba(120, 144, 200, 0.16);
    color: #9fb2e0;
    border-color: rgba(120, 144, 200, 0.4);
}

/* Fila de tramo: atenuada y en cursiva para diferenciarla de vueltas reales */
tr.is-segment-lap td {
    opacity: 0.75;
    font-style: italic;
}

/* ─── Upload modal ───────────────────────────────────────────────────────────── */

.upload-body {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
}

.upload-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 2rem 1rem;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.upload-dropzone:hover,
.upload-dropzone.drag-over {
    border-color: var(--accent);
    background: rgba(255,122,24,0.05);
}

.upload-dropzone-icon {
    font-size: 2.4rem;
    color: var(--text-muted);
    line-height: 1;
}

.upload-dropzone-label {
    font-size: 0.95rem;
    color: var(--text);
    margin: 0;
}

.upload-dropzone-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0;
}

.upload-dropzone-formats {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0.25rem 0 0;
}

.upload-ibt-options {
    padding: 0.5rem 0.25rem 0;
}

.upload-ibt-option-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    color: var(--text-secondary, #aaa);
    cursor: pointer;
}

.upload-ibt-option-label input[type="checkbox"] {
    accent-color: var(--accent);
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
}

.upload-queue {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.upload-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.3rem 0.75rem;
    align-items: center;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.55rem 0.75rem;
    font-size: 0.82rem;
}

.upload-item-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
    font-weight: 500;
}

.upload-item-status {
    text-align: right;
    white-space: nowrap;
    font-size: 0.78rem;
}

.upload-item-status.uploading { color: var(--accent); }
.upload-item-status.processing { color: var(--accent); }
.upload-item-status.done { color: #4caf50; }
.upload-item-status.warning { color: var(--warning); }
.upload-item-status.error { color: #f44336; }

.upload-item-bar-wrap {
    grid-column: 1 / -1;
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.upload-item-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s;
}

.upload-item-detail {
    grid-column: 1 / -1;
    font-size: 0.73rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Lap Library */
.lap-library-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 0.8rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--panel-alt);
    margin-bottom: 0.5rem;
    gap: 0.5rem;
}

.lap-library-row:hover {
    border-color: var(--accent);
}

.lap-library-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    min-width: 0;
}

.lap-library-driver {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-style: italic;
}

.lap-library-car {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text);
}

.lap-library-circuit {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.lap-library-time {
    font-family: var(--font-mono, monospace);
    font-size: 0.85rem;
    color: var(--accent);
    font-weight: 600;
}

.lap-library-actions {
    display: flex;
    gap: 0.3rem;
    flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   MOBILE UX REDESIGN — compacto, cabecera sticky, barra inferior sólida
   (swipe lateral eliminado; la barra inferior es la única navegación)
   ═══════════════════════════════════════════════════════════════════════════════ */

@keyframes zlPanelFade {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

@media (max-width: 899px) {
    .app-shell {
        gap: 0.55rem;
        padding: 0.55rem 0.65rem calc(4.75rem + env(safe-area-inset-bottom));
    }

    /* ── Cabecera compacta, TODO en una sola línea; no flota: se va con el scroll ── */
    .app-header {
        position: relative;
        z-index: 90;
        flex-direction: row !important;
        align-items: center !important;
        flex-wrap: nowrap !important;
        justify-content: flex-start !important;
        gap: 0.4rem;
        padding: 0.4rem 0.6rem !important;
    }

    .sessions-toggle-btn {
        flex: 0 0 auto;
    }

    .brand {
        min-width: 0;
        flex: 0 1 auto;
    }

    .brand-logo {
        height: 26px;
        width: auto;
        max-width: 38vw;
        object-fit: contain;
    }

    /* En móvil el wordmark del logo ya identifica la app: ocultamos el texto extra */
    .brand-meta {
        display: none;
    }

    .header-controls {
        width: auto !important;
        flex-wrap: nowrap !important;
        gap: 0.3rem;
        min-width: 0;
        margin-left: auto;
        flex: 0 1 auto;
    }

    .header-controls .select-label {
        display: none;
    }

    /* Controles más pequeños para que quepan en una línea */
    .app-header .ghost-icon-btn {
        width: 34px;
        height: 34px;
    }

    .header-controls .admin-btn {
        padding: 0.3rem 0.5rem;
        font-size: 0.78rem;
    }

    .user-select {
        max-width: 110px;
        min-width: 0;
        flex: 0 1 auto;
        font-size: 0.8rem;
        padding: 0.3rem 0.45rem;
    }

    /* El banner de estado no debe taparse con la cabecera fija */
    .status-banner {
        top: 3.75rem;
        bottom: auto;
        left: auto;
        right: 0.75rem;
        width: fit-content;
        max-width: min(360px, calc(100vw - 1.5rem));
        align-items: flex-start;
    }

    /* ── Paneles: más compactos y con transición suave (sin salto) ── */
    .panel.card {
        padding: 0.8rem !important;
        border-radius: 10px !important;
    }

    .panel.panel-visible {
        animation: zlPanelFade 0.18s ease;
    }

    .panel-title {
        font-size: 0.95rem;
    }

    /* ── Barra inferior: sólida, mejores zonas táctiles, píldora activa ── */
    .bottom-nav {
        padding: 0.3rem 0.45rem calc(0.3rem + env(safe-area-inset-bottom)) !important;
        gap: 0.25rem;
    }

    .bottom-nav-btn {
        border-radius: 10px;
        padding: 0.35rem 0.2rem;
        min-height: 50px;
        font-size: 0.62rem;
        font-weight: 600;
        letter-spacing: 0.015em;
        transition: color 0.15s ease, background 0.15s ease;
    }

    .bottom-nav-btn i {
        font-size: 1.4rem;
    }

    .bottom-nav-btn.bottom-nav-active {
        background: rgba(255, 138, 48, 0.12);
    }

    /* Sustituimos el glow por algo más limpio y plano */
    .bottom-nav-btn.bottom-nav-active i {
        filter: none;
    }
}

/* Pantallas muy estrechas: un punto más de compacidad */
@media (max-width: 520px) {
    .panel.card {
        padding: 0.5rem !important;
    }

    .bottom-nav-btn span {
        font-size: 0.6rem;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SESSIONS DRAWER — menú de sesiones off-canvas desde la izquierda (todos los tamaños)
   Hamburguesa en la cabecera lo abre; backdrop o botón de cierre lo ocultan.
   ═══════════════════════════════════════════════════════════════════════════════ */

.sessions-toggle-btn {
    display: inline-flex;
    flex: 0 0 auto;
}

#sessionsPanel {
    position: fixed !important;
    top: 0;
    left: 0;
    width: 340px;
    max-width: 88vw;
    height: 100vh;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex !important;
    flex-direction: column;
    gap: 0.75rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--panel) !important;
    border: none !important;
    border-right: 1px solid var(--border) !important;
    border-radius: 0 !important;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
    /* anula el sidebar fijo de escritorio (grid/sticky) */
    grid-column: auto !important;
    grid-row: auto !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 1rem !important;
}

@supports (height: 100dvh) {
    #sessionsPanel { height: 100dvh; }
}

#sessionsPanel.is-open {
    transform: none;
}

/* Cabecera del drawer pegada arriba al hacer scroll de la lista */
#sessionsPanel .sessions-header {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--panel);
    padding-bottom: 0.5rem;
}

.sessions-backdrop {
    position: fixed;
    inset: 0;
    z-index: 199;
    background: rgba(0, 0, 0, 0.5);
    display: none;
}

.sessions-backdrop.is-visible {
    display: block;
}

/* Botón de fijar ("pin") el drawer: resaltado cuando está activo */
.sessions-pin-btn.is-active {
    color: var(--accent);
    border-color: rgba(255, 138, 48, 0.45);
    background: rgba(255, 138, 48, 0.12);
}

/* Escritorio/tablet: el área principal pasa a ancho completo (sin columna fija) */
@media (min-width: 900px) {
    .app-main {
        grid-template-columns: 1fr !important;
    }

    .main-area {
        grid-column: 1 / -1 !important;
    }

    /* ── PUSH: el drawer empuja el contenido a la derecha en vez de taparlo ── */
    /* width:auto (no 100%) para que el margen reduzca el ancho útil sin overflow */
    .app-shell {
        width: auto;
        transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    body.sessions-open .app-shell {
        margin-left: 340px;
    }

    /* En modo push no atenuamos el contenido: sin backdrop oscuro */
    .sessions-backdrop {
        display: none !important;
    }
}

/* Móvil/tablet estrecho: overlay clásico con bloqueo de scroll de fondo */
@media (max-width: 899px) {
    body.sessions-open {
        overflow: hidden;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   MOBILE WORKSPACE — navegación nativa: 3 pestañas + segmented control (solo ≤899px)
   Escritorio NO se ve afectado: la barra está oculta y las reglas viven en el media query.
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Oculta por defecto (escritorio) */
.mobile-workspace-bar {
    display: none;
}

@media (max-width: 899px) {
    /* ── Sesiones vuelve a ser un panel normal en móvil (no drawer) ── */
    #sessionsPanel {
        position: static !important;
        transform: none !important;
        width: auto !important;
        max-width: none !important;
        height: auto !important;
        max-height: none !important;
        z-index: auto !important;
        overflow: visible !important;
        box-shadow: none !important;
        border-right: none !important;
        border: 1px solid var(--border) !important;
        border-radius: 10px !important;
    }

    /* En móvil la cabecera del drawer no necesita sticky ni botón de cierre */
    #sessionsPanel .sessions-header {
        position: static;
    }

    .sessions-toggle-btn,
    .sessions-drawer-close,
    .sessions-pin-btn,
    .sessions-backdrop {
        display: none !important;
    }

    /* ── Aislamiento total por pestaña/segmento ──
       Solo se ve el panel/segmento activo; al hacer scroll no se revela nada más. */
    #sessionsPanel,
    #comparisonPanel,
    #lapPanel,
    #historyPanel,
    #insightsPanel {
        display: none !important;
    }

    body.mobile-tab-sessions #sessionsPanel { display: flex !important; }
    body.mobile-tab-saved #historyPanel { display: flex !important; }
    body.mobile-tab-analysis.seg-pitlane #insightsPanel { display: flex !important; }
    body.mobile-tab-analysis.seg-laps #lapPanel { display: flex !important; }
    body.mobile-tab-analysis.seg-charts #comparisonPanel { display: flex !important; }

    /* ── Neutralizar gridstack en móvil: flujo vertical estático (sin posición absoluta) ──
       Así ocultar tarjetas no deja huecos y las alturas son predecibles. */
    #graphGrid.grid-stack {
        height: auto !important;
        min-height: 0 !important;
    }

    #graphGrid > .grid-stack-item {
        position: static !important;
        transform: none !important;
        inset: auto !important;
        top: auto !important;
        left: auto !important;
        width: 100% !important;
        height: auto !important;
        margin: 0 0 0.35rem 0 !important;
    }

    #graphGrid > .grid-stack-item > .grid-stack-item-content {
        position: static !important;
        inset: auto !important;
        height: auto !important;
    }

    /* La tarjeta y su cuerpo dejan de usar flex:1 (que colapsa sin altura fija
       del item) y pasan a dimensionarse por su contenido con altura explícita. */
    #graphGrid .graph-card {
        flex: 0 0 auto !important;
        height: auto !important;
    }

    #graphGrid .chart-wrapper {
        flex: 0 0 auto !important;
        height: 200px !important;
        min-height: 200px !important;
    }

    #graphGrid .map-view {
        flex: 0 0 auto !important;
        height: 300px !important;
        min-height: 300px !important;
    }

    /* El segmento "Gráficos" muestra TODAS las tarjetas, incluido el mapa
       (igual que en escritorio: el mapa es una tarjeta más del grid). */

    /* ── Barra de workspace (contexto + segmented control) ── */
    .mobile-workspace-bar {
        display: none;
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.25rem 0.65rem 0.1rem;
    }

    body.mobile-tab-analysis .mobile-workspace-bar {
        display: flex;
    }

    .mobile-ctx-row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
        min-width: 0;
    }

    .mobile-ctx {
        display: flex;
        align-items: center;
        gap: 0.4rem;
        background: none;
        border: none;
        color: var(--text);
        font-weight: 700;
        font-size: 0.9rem;
        padding: 0;
        min-width: 0;
        cursor: pointer;
    }

    .mobile-ctx .mobile-ctx-session {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mobile-ctx .mdi-chevron-down {
        color: var(--accent);
        font-size: 1.1rem;
        flex: 0 0 auto;
    }

    .mobile-ctx-laps {
        color: var(--muted);
        font-size: 0.76rem;
        white-space: nowrap;
        flex: 0 0 auto;
    }

    .mobile-seg {
        display: flex;
        gap: 2px;
        background: var(--panel-alt);
        border: 1px solid var(--border);
        border-radius: 10px;
        padding: 3px;
    }

    .mobile-seg-btn {
        flex: 1;
        padding: 0.3rem 0.5rem;
        border: none;
        background: none;
        color: var(--muted);
        font-weight: 600;
        font-size: 0.8rem;
        border-radius: 7px;
        cursor: pointer;
        transition: background 0.15s ease, color 0.15s ease;
    }

    .mobile-seg-btn.is-active {
        background: var(--accent);
        color: #0d0f14;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   MOBILE — Controles de "Comparación activa" en una sola línea compacta (≤899px)
   (zonas acel./freno, heatmap, gráfico principal, config de la vista)
   ═══════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 899px) {
    body,
    body * {
        -webkit-user-select: none;
        user-select: none;
        -webkit-touch-callout: none;
    }

    body,
    a,
    button,
    input,
    select,
    textarea,
    label,
    summary,
    [role="button"],
    .session-card,
    .bottom-nav-btn,
    .nav-section-btn,
    .toggle-chip,
    .primary-btn,
    .ghost-btn,
    .ghost-icon-btn,
    .icon-btn {
        -webkit-tap-highlight-color: transparent;
    }

    input,
    textarea,
    select,
    option,
    [contenteditable],
    .allow-select,
    .allow-select * {
        -webkit-user-select: text;
        user-select: text;
        -webkit-touch-callout: default;
    }

    .analysis-controls {
        width: 100% !important;
        flex-wrap: wrap !important;
        align-items: center;
        gap: 0.35rem;
        overflow-x: visible;
        padding-bottom: 2px;
    }

    /* Nada de width:100% / apilado: cada control ocupa lo justo y no se parte */
    .analysis-controls .toggle-chip,
    .analysis-controls .ghost-btn,
    .analysis-controls .ghost-icon-btn,
    .analysis-controls .primary-chart-control,
    .analysis-controls .analysis-axis-control {
        width: auto !important;
        flex: 0 0 auto !important;
        white-space: nowrap;
    }

    /* Los controles con texto se alinean a la izquierda... */
    .analysis-controls .toggle-chip,
    .analysis-controls .ghost-btn,
    .analysis-controls .primary-chart-control,
    .analysis-controls .analysis-axis-control {
        justify-content: flex-start !important;
    }

    #analysisRangeToggleBtn,
    #analysisRangeClearBtn {
        order: -1;
    }

    .analysis-controls .toggle-chip {
        padding: 0.3rem 0.5rem;
        font-size: 0.76rem;
        gap: 0.35rem;
    }

    /* ...pero el botón de icono (config de la vista) mantiene su icono centrado
       y se alinea al extremo derecho de la fila. */
    .analysis-controls .ghost-icon-btn {
        width: 34px;
        height: 34px;
        flex: 0 0 34px !important;
        justify-content: center !important;
    }

    .analysis-controls .chart-config-btn {
        margin-left: auto;
    }

    /* "Gráfico principal": ocultamos la etiqueta y dejamos solo el desplegable */
    .analysis-controls .primary-chart-control .chart-label {
        display: none;
    }

    .analysis-controls .primary-chart-control select {
        font-size: 0.78rem;
        padding: 0.3rem 0.4rem;
        max-width: 130px;
    }

    .analysis-controls .analysis-axis-control .chart-label {
        display: none;
    }

    .analysis-controls .analysis-axis-control select {
        font-size: 0.78rem;
        padding: 0.3rem 0.4rem;
        max-width: 130px;
    }
}

/* ==========================================================================
   Reproductor de telemetría
   Barra flotante que mueve el cursor de todos los gráficos a ritmo real.
   Discreta en reposo (semitransparente) y plenamente opaca al usarla.
   ========================================================================== */

.telemetry-player {
    position: fixed;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%) translateY(0);
    z-index: 320;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    width: min(600px, calc(100vw - 24px));
    padding: 0.5rem 0.7rem;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
    background: color-mix(in srgb, var(--panel) 88%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: var(--shadow);
    opacity: 0.62;
    transition: opacity 0.22s ease, transform 0.22s ease, box-shadow 0.22s ease;
}

.telemetry-player[hidden] {
    display: none;
}

.telemetry-player:hover,
.telemetry-player:focus-within,
.telemetry-player.is-playing,
.telemetry-player.is-scrubbing {
    opacity: 1;
}

.telemetry-player.is-scrubbing {
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.72);
}

/* Aparición/salida */
.telemetry-player.is-entering {
    opacity: 0;
    transform: translateX(-50%) translateY(14px);
}

.player-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease;
}

.player-btn:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
}

.player-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.player-btn .mdi {
    font-size: 1.15rem;
    line-height: 1;
}

.player-play-btn {
    width: 34px;
    height: 34px;
    background: var(--accent);
    color: #12130f;
}

.player-play-btn:hover {
    background: var(--accent-strong);
    color: #12130f;
}

.player-play-btn .mdi {
    font-size: 1.3rem;
}

.player-toggle-btn[aria-pressed="true"] {
    color: var(--accent-strong);
    background: var(--accent-soft);
}

/* --- Barra de progreso arrastrable --- */
.player-scrub {
    position: relative;
    flex: 1 1 auto;
    min-width: 60px;
    height: 24px;
    display: flex;
    align-items: center;
    cursor: pointer;
    touch-action: none;
}

.player-scrub:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 999px;
}

.player-scrub-track {
    position: relative;
    width: 100%;
    height: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    overflow: hidden;
    transition: height 0.15s ease;
}

.player-scrub:hover .player-scrub-track,
.telemetry-player.is-scrubbing .player-scrub-track {
    height: 6px;
}

.player-scrub-fill {
    position: absolute;
    inset: 0 auto 0 0;
    width: 0;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--accent), var(--accent-strong));
}

.player-scrub-handle {
    position: absolute;
    top: 50%;
    left: 0;
    width: 11px;
    height: 11px;
    margin-left: -5.5px;
    border-radius: 50%;
    background: var(--text);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.4);
    transform: translateY(-50%) scale(0.85);
    transition: transform 0.15s ease;
    pointer-events: none;
}

.player-scrub:hover .player-scrub-handle,
.telemetry-player.is-scrubbing .player-scrub-handle {
    transform: translateY(-50%) scale(1.15);
}

/* --- Reloj y velocidad --- */
.player-time {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: baseline;
    gap: 0.22rem;
    font-size: 0.74rem;
    font-variant-numeric: tabular-nums;
    color: var(--muted);
    white-space: nowrap;
}

.player-time strong {
    font-weight: 600;
    color: var(--text);
}

.player-time-sep {
    opacity: 0.45;
}

.player-speed {
    flex: 0 0 auto;
    padding: 0.2rem 0.3rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--panel-alt);
    color: var(--text);
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
}

.player-speed:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

/* El botón de apertura marca estado cuando el reproductor está abierto */
.player-open-btn[aria-pressed="true"],
.video-open-btn[aria-pressed="true"] {
    color: var(--accent-strong);
    background: var(--accent-soft);
}

/* ==========================================================================
   Vídeo on-board (GoPro)
   Ventana flotante con el vídeo local y el overlay de telemetría en canvas.
   Escritorio: se arrastra por la cabecera y se redimensiona por la esquina.
   Móvil: fija arriba a todo el ancho.
   ========================================================================== */

.video-panel {
    position: fixed;
    right: 18px;
    bottom: 84px;
    z-index: 330;
    display: flex;
    flex-direction: column;
    width: min(520px, calc(100vw - 24px));
    border-radius: 14px;
    border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
    background: color-mix(in srgb, var(--panel) 94%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.video-panel[hidden] {
    display: none;
}

.video-panel-head,
.video-panel-foot {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.45rem 0.35rem 0.6rem;
}

.video-panel-head {
    cursor: grab;
    touch-action: none;
    user-select: none;
    border-bottom: 1px solid var(--border);
}

.video-panel-head:active {
    cursor: grabbing;
}

.video-panel-head button.ghost-icon-btn {
    width: 30px;
    height: 30px;
    font-size: 1rem;
}

.video-panel-head .ghost-icon-btn[aria-pressed="true"][data-action="overlay"] {
    color: var(--accent-strong);
    background: var(--accent-soft);
}

.video-panel-grip {
    color: var(--muted);
}

.video-panel-title {
    font-weight: 700;
    font-size: 0.875rem;
}

.video-panel-spacer {
    flex: 1 1 auto;
}

.video-sync-chip {
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    color: var(--muted);
    background: var(--panel-alt);
}

.video-sync-chip[hidden] {
    display: none;
}

.video-sync-chip[data-tone="success"] {
    color: var(--success);
    background: color-mix(in srgb, var(--success) 14%, transparent);
}

.video-sync-chip[data-tone="warning"] {
    color: var(--warning);
    background: color-mix(in srgb, var(--warning) 14%, transparent);
}

.video-sync-chip[data-tone="danger"] {
    color: var(--danger);
    background: color-mix(in srgb, var(--danger) 14%, transparent);
}

.video-stage {
    position: relative;
    aspect-ratio: 16 / 9;
    background: #000;
}

/* Menú «Datos sobre el vídeo»: qué elementos del overlay se pintan */
.video-overlay-menu {
    position: fixed;
    z-index: 340;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 220px;
    max-height: calc(100vh - 16px);
    overflow-y: auto;
    padding: 0.5rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--panel);
    box-shadow: var(--shadow);
    font-size: 0.8125rem;
}

.video-overlay-menu[hidden] {
    display: none;
}

.video-overlay-menu label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.4rem;
    border-radius: 6px;
    cursor: pointer;
}

.video-overlay-menu label:hover {
    background: var(--panel-alt);
}

.video-overlay-menu input {
    accent-color: var(--accent);
}

.video-overlay-menu-master {
    font-weight: 700;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.15rem;
    border-radius: 6px 6px 0 0;
}

.video-overlay-menu.is-off .video-overlay-menu-items {
    opacity: 0.45;
}

.video-overlay-menu-hint {
    margin: 0.3rem 0.4rem 0.1rem;
    color: var(--muted);
    font-size: 0.75rem;
}

.video-overlay-menu .ghost-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0.2rem 0.4rem 0;
    padding: 0.3rem 0.6rem;
    border-radius: 8px;
    font-size: 0.8125rem;
}

.video-stage video,
.video-overlay-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.video-stage video {
    object-fit: contain;
}

.video-overlay-canvas {
    cursor: pointer;
    touch-action: none;   /* arrastrar etiquetas con el dedo */
}

/* En ajuste manual mandan los controles nativos del vídeo: el overlay no captura clics. */
.video-panel.is-manual .video-overlay-canvas {
    pointer-events: none;
}

.video-stage-msg {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    padding: 0.45rem 0.8rem;
    border-radius: 10px;
    font-size: 0.8125rem;
    color: var(--text);
    background: rgba(8, 9, 13, 0.78);
    pointer-events: none;
    text-align: center;
}

.video-stage-msg[hidden] {
    display: none;
}

.video-drop {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 1rem 1.4rem;
    text-align: center;
    cursor: pointer;
    background: var(--bg-2);
    color: var(--muted);
    font-size: 0.8125rem;
}

.video-drop[hidden] {
    display: none;
}

.video-drop .mdi {
    font-size: 2.2rem;
    color: var(--accent);
}

.video-drop strong {
    color: var(--text);
    font-size: 0.9375rem;
}

.video-drop:hover strong {
    color: var(--accent-strong);
}

.video-panel-foot {
    border-top: 1px solid var(--border);
    flex-direction: column;
    align-items: stretch;
}

.video-foot-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.video-foot-row[hidden],
.video-manual[hidden] {
    display: none;
}

.video-manual {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.video-manual-label {
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-right: 0.15rem;
}

.video-manual-lap {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
    font-size: 0.8125rem;
    color: var(--muted);
}

.video-manual-lap select {
    min-height: 30px;
    padding: 0.15rem 0.4rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--panel-alt);
    color: var(--text);
    font-weight: 600;
}

.video-panel-foot[hidden] {
    display: none;
}

.video-panel-foot .ghost-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    min-height: 30px;
    padding: 0.2rem 0.55rem;
    border-radius: 8px;
    font-size: 0.8125rem;
}

.video-panel-foot .ghost-btn:disabled {
    opacity: 0.45;
    cursor: default;
}

.video-panel-foot .ghost-btn.is-primary {
    color: #0b121d;
    border-color: transparent;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}

.video-nudge {
    display: inline-flex;
    gap: 0.25rem;
}

.video-panel-resize {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 16px;
    height: 16px;
    cursor: nwse-resize;
    touch-action: none;
    background: linear-gradient(135deg, transparent 50%, color-mix(in srgb, var(--accent) 55%, transparent) 50%);
    opacity: 0.7;
}

/* Diálogo «Exportar vídeo» */
.video-export-backdrop {
    position: fixed;
    inset: 0;
    z-index: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.55);
}

.video-export-dialog {
    width: min(460px, 100%);
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    padding: 1.1rem 1.2rem;
    border-radius: 14px;
    border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
    background: var(--panel);
    box-shadow: var(--shadow);
    color: var(--text);
}

.video-export-dialog h3 {
    margin: 0 0 0.8rem;
    font-size: 1.05rem;
}

.video-export-dialog fieldset {
    margin: 0 0 0.8rem;
    padding: 0;
    border: 0;
}

.video-export-dialog legend {
    margin-bottom: 0.35rem;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.video-export-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0;
    font-size: 0.875rem;
    cursor: pointer;
}

.video-export-option[hidden] {
    display: none;
}

.video-export-option small,
.video-export-laps small {
    color: var(--muted);
}

.video-export-dialog input[type="radio"],
.video-export-dialog input[type="checkbox"] {
    accent-color: var(--accent);
}

.video-export-laps {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0.8rem;
    margin: 0.2rem 0 0 1.6rem;
    font-size: 0.8125rem;
}

.video-export-laps.is-disabled {
    opacity: 0.45;
    pointer-events: none;
}

.video-export-dialog select,
.video-export-dialog input[type="number"] {
    min-height: 30px;
    padding: 0.15rem 0.4rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--panel-alt);
    color: var(--text);
    font-weight: 600;
}

.video-export-dialog input[type="number"] {
    width: 3.6rem;
}

.video-export-summary {
    margin: 0.6rem 0 0.2rem;
    font-weight: 600;
    font-size: 0.875rem;
}

.video-export-note {
    margin: 0 0 0.8rem;
    color: var(--muted);
    font-size: 0.75rem;
}

.video-export-progress {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 0.8rem;
    font-size: 0.8125rem;
}

.video-export-progress[hidden] {
    display: none;
}

.video-export-bar {
    height: 8px;
    border-radius: 999px;
    background: var(--panel-alt);
    overflow: hidden;
}

.video-export-bar > div {
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-strong));
    transition: width 0.2s linear;
}

.video-export-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.video-export-actions .primary-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.9rem;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
}

.video-export-actions .primary-btn[hidden] {
    display: none;
}

@media (max-width: 760px) {
    .video-panel {
        left: 8px !important;
        right: 8px !important;
        top: 8px !important;
        bottom: auto !important;
        width: auto !important;
    }

    .video-panel-head {
        cursor: default;
    }

    .video-panel-grip,
    .video-panel-resize {
        display: none;
    }

    .video-foot-row {
        gap: 0.25rem;
    }

    .video-foot-row[data-role="sync-row"] {
        flex-wrap: nowrap;
        overflow-x: auto;
    }

    .video-nudge {
        flex: 0 0 auto;
    }

    .video-panel-foot .ghost-btn {
        width: auto;
        flex: 0 0 auto;
        margin: 0;
        padding: 0.2rem 0.45rem;
    }

    /* Solo icono para que quepa todo en una fila */
    .video-panel-foot [data-action="resync"] span {
        display: none;
    }
}

@media (max-width: 720px) {
    .telemetry-player {
        bottom: 12px;
        gap: 0.4rem;
        padding: 0.45rem 0.55rem;
        opacity: 0.8;
    }

    /* En pantallas estrechas el reloj se queda solo con el tiempo actual */
    .telemetry-player .player-time-sep,
    .telemetry-player #playerTimeTotal {
        display: none;
    }

    .player-btn {
        width: 27px;
        height: 27px;
    }

    .player-time {
        font-size: 0.68rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .telemetry-player,
    .player-scrub-track,
    .player-scrub-handle {
        transition: none;
    }
}

/* En móvil el reproductor pertenece a la pantalla de Análisis */
@media (max-width: 899px) {
    body.mobile-tab-sessions .telemetry-player,
    body.mobile-tab-saved .telemetry-player {
        display: none;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   MÓVIL — rediseño de Vueltas y Gráficos (boceto "ZeroLAPS móvil", sept. 2026)
   Cabecera con la sesión, lista de vueltas táctil + barra "Comparar", Gráficos con
   un canal a la vez, lectura del cursor, hoja "Capas" y pantalla completa.
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Escritorio: todo lo exclusivo de móvil queda oculto y el envoltorio es transparente */
.mobile-header-ctx,
.mobile-lap-kpis,
.mobile-lap-presets,
.mobile-lap-legend,
.mobile-compare-bar,
.mobile-layers-btn,
.mobile-cursor-readout,
.readout-toggle,
.mobile-channel-bar,
.mobile-fs-enter,
.settings-account-section,
.comparison-lapno,
.comparison-gap {
    display: none;
}

.mobile-compare-row {
    display: contents;
}

/* Botón Coach (junto a Capas, mismo estilo): resaltado cuando está activo */
.coach-toggle-btn[aria-pressed="true"] {
    border-color: var(--accent) !important;
    color: var(--accent) !important;
}

.coach-toggle-btn + .mobile-layers-btn,
.video-open-btn + .mobile-layers-btn {
    margin-left: 0;
}

.video-open-btn:disabled {
    opacity: 0.45;
    cursor: default;
}

/* Plegar la columna de vueltas solo tiene sentido en el banco de trabajo */
body:not(.workbench) .laps-rail-head,
body:not(.workbench) .laps-rail {
    display: none;
}

.layers-sheet[hidden],
.layers-sheet-backdrop[hidden] {
    display: none !important;
}

/* Hoja "Capas y opciones" (solo se abre en móvil) */
.layers-sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 400;
    background: rgba(4, 6, 10, 0.62);
}

.layers-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 401;
    max-height: 88vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 8px 16px calc(24px + env(safe-area-inset-bottom));
    background: var(--panel);
    border-top: 1px solid #2b3444;
    border-radius: 20px 20px 0 0;
    color: var(--text);
}

@supports (height: 100dvh) {
    .layers-sheet { max-height: 88dvh; }
}

.layers-sheet-grabber {
    flex: 0 0 auto;
    align-self: center;
    width: 40px;
    height: 5px;
    border-radius: 3px;
    background: #3a4456;
}

.layers-sheet-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.layers-sheet-title {
    flex: 1 1 auto;
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
}

.layers-sheet-header .ghost-icon-btn {
    width: 44px;
    height: 44px;
}

.layers-sheet-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.layers-sheet-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.layers-sheet-label {
    margin: 0;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

/* Capas: los toggle-chips pasan a filas con interruptor */
.layers-toggles {
    display: flex;
    flex-direction: column;
}

.layers-toggles .toggle-chip:not([hidden]) {
    display: flex !important;
    flex-direction: row-reverse;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 52px;
    padding: 0;
    border: none;
    border-bottom: 1px solid #1f2632;
    border-radius: 0;
    background: none;
    font-size: 1rem;
    color: var(--text);
}

.layers-toggles .toggle-chip input {
    -webkit-appearance: none;
    appearance: none;
    position: relative;
    flex: 0 0 auto;
    width: 48px;
    height: 28px;
    margin: 0;
    border-radius: 14px;
    background: #3a4456;
    cursor: pointer;
    transition: background 0.15s ease;
}

.layers-toggles .toggle-chip input::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #ffffff;
    transition: left 0.15s ease;
}

.layers-toggles .toggle-chip input:checked {
    background: var(--accent);
}

.layers-toggles .toggle-chip input:checked::after {
    left: 23px;
}

.layers-axis-seg {
    display: flex;
    gap: 2px;
    min-height: 44px;
    padding: 3px;
    box-sizing: border-box;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.layers-axis-seg button {
    flex: 1 1 0;
    min-height: 38px;
    border: none;
    border-radius: 9px;
    background: none;
    color: var(--muted);
    font-weight: 700;
    font-size: 0.9375rem;
    cursor: pointer;
}

.layers-axis-seg button[aria-pressed="true"] {
    background: var(--accent);
    color: #0d0f14;
}

.layers-channel-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.layers-channel-chip {
    min-height: 44px;
    padding: 0 14px;
    border-radius: 22px;
    border: 1px solid #2b3444;
    background: none;
    color: var(--text);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
}

.layers-channel-chip[aria-pressed="true"] {
    background: rgba(255, 138, 48, 0.16);
    border-color: var(--accent);
    color: #ffb27a;
}

.layers-channel-chip:disabled {
    opacity: 0.4;
    cursor: default;
}

/* Acciones: cada botón es una fila; los botones de icono muestran su etiqueta */
.layers-actions {
    display: flex;
    flex-direction: column;
}

.layers-actions > button:not([hidden]) {
    display: flex !important;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    width: 100% !important;
    height: auto !important;
    min-height: 48px;
    padding: 0 !important;
    border: none;
    border-bottom: 1px solid #1f2632;
    border-radius: 0;
    background: none;
    color: var(--text);
    font-size: 1rem;
    font-weight: 500;
    text-align: left;
}

.layers-actions > button.primary-btn {
    background: none !important;
    color: var(--text) !important;
    box-shadow: none !important;
}

.layers-actions > button.danger-btn {
    color: #f87171;
}

.layers-actions > .ghost-icon-btn::after {
    content: attr(aria-label);
}

.layers-actions > [hidden],
.layers-actions > .zoom-reset-btn:not(.is-visible) {
    display: none !important;
}

.layers-actions .reference-lap-bar {
    margin: 10px 0 0;
}

@media (max-width: 899px) {
    /* Grises con contraste suficiente sobre el fondo oscuro */
    :root {
        --muted: #93a1b8;
    }

    /* ── Cabecera: en Análisis muestra la sesión activa en lugar del logo ── */
    .header-controls .user-select,
    .header-controls .select-label,
    .header-controls .admin-btn,
    #logoutBtn {
        display: none !important;
    }

    .app-header .ghost-icon-btn {
        width: 36px;
        height: 36px;
    }

    body.mobile-tab-analysis .app-header .brand {
        display: none;
    }

    body.mobile-tab-analysis .mobile-header-ctx {
        display: flex;
    }

    .mobile-header-ctx {
        flex: 1 1 auto;
        min-width: 0;
        min-height: 40px;
        align-items: center;
        gap: 0.6rem;
        padding: 0;
        border: none;
        background: none;
        color: var(--text);
        text-align: left;
        cursor: pointer;
    }

    .mobile-header-ctx > .mdi {
        color: var(--accent);
        font-size: 1.25rem;
    }

    .mobile-header-ctx-text {
        display: flex;
        flex-direction: column;
        min-width: 0;
    }

    .mobile-header-ctx-title {
        display: flex;
        align-items: center;
        gap: 0.2rem;
        min-width: 0;
        font-size: 1rem;
        font-weight: 700;
        white-space: nowrap;
    }

    .mobile-header-ctx-title #mobileHeaderSession {
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mobile-header-ctx-title .mdi {
        color: var(--accent);
    }

    .mobile-header-ctx-sub {
        font-size: 0.75rem;
        color: var(--muted);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mobile-header-ctx-sub:empty {
        display: none;
    }

    /* Usuario y cierre de sesión viven en Configuración */
    .settings-account-section {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .settings-user-slot .user-select {
        width: 100%;
        max-width: none;
        min-height: 44px;
        font-size: 1rem;
    }

    .settings-logout-btn {
        width: 100%;
        min-height: 44px;
        justify-content: center;
    }

    /* La sesión ya está en la cabecera: la barra de workspace solo lleva el selector */
    .mobile-ctx-row {
        display: none !important;
    }

    .mobile-seg {
        min-height: 36px;
    }

    .mobile-seg-btn {
        font-size: 0.8125rem;
    }

    .bottom-nav-btn span {
        font-size: 0.75rem;
    }

    /* ── Vueltas: resumen, atajos y leyenda ── */
    #lapPanel .panel-header,
    #lapPanel .table-footer {
        display: none;
    }

    #lapPanel {
        gap: 0.45rem;
    }

    body.seg-laps #lapPanel {
        margin-bottom: 62px;
    }

    .mobile-lap-kpis {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 6px;
    }

    .mobile-kpi {
        display: flex;
        flex-direction: column;
        min-width: 0;
        padding: 5px 8px;
        background: var(--panel-alt);
        border: 1px solid var(--border);
        border-radius: 10px;
    }

    .mobile-kpi-label {
        font-size: 0.625rem;
        font-weight: 600;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        color: var(--muted);
    }

    .mobile-kpi-value {
        font-size: 1.05rem;
        font-weight: 700;
        font-variant-numeric: tabular-nums;
        white-space: nowrap;
    }

    .mobile-kpi-value.is-best { color: #c4b5fd; }
    .mobile-kpi-value.is-optimal { color: var(--accent); }
    .mobile-kpi-value.is-potential { color: #34d399; }

    .mobile-lap-presets {
        display: flex;
        gap: 6px;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .mobile-lap-presets::-webkit-scrollbar {
        display: none;
    }

    .mobile-preset-btn {
        flex: 0 0 auto;
        min-height: 32px;
        padding: 0 12px;
        border-radius: 22px;
        border: 1px solid #3a4456;
        background: var(--panel-alt);
        color: var(--text);
        font-weight: 600;
        font-size: 0.8125rem;
        cursor: pointer;
    }

    .mobile-preset-btn.is-quiet {
        background: none;
        border-color: var(--border);
        color: var(--muted);
    }

    .mobile-lap-legend {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 2px 4px 0;
        font-size: 0.75rem;
        color: var(--muted);
    }

    .mobile-lap-count {
        flex: 1 1 auto;
        min-width: 0;
        font-weight: 600;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mobile-legend-item {
        display: inline-flex;
        align-items: center;
        gap: 4px;
    }

    .mobile-legend-dot {
        width: 7px;
        height: 7px;
        border-radius: 50%;
    }

    .mobile-legend-dot.is-offtrack { background: #ef4444; }
    .mobile-legend-dot.is-incomplete { background: #f59e0b; }

    /* ── Vueltas: la tabla se muestra como lista táctil ── */
    #lapPanel .table-wrapper {
        overflow: visible;
    }

    #lapTable {
        display: block;
        min-width: 0;
    }

    #lapTable thead {
        display: none;
    }

    #lapTable tbody {
        display: flex;
        flex-direction: column;
    }

    #lapTable tbody tr.empty-row {
        display: block;
        padding: 1rem 0.5rem;
        color: var(--muted);
    }

    #lapTable tbody tr[data-lap-key] {
        display: flex;
        align-items: center;
        gap: 8px;
        min-height: 44px;
        padding: 0 8px;
        border: none;
        border-left: none !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.04);
        border-radius: 10px;
        background: transparent;
    }

    #lapTable tbody tr[data-lap-key].selected {
        background: rgba(255, 255, 255, 0.05);
    }

    #lapTable tbody tr[data-lap-key].lap-previewing {
        background: rgba(255, 138, 48, 0.1);
    }

    #lapTable tbody td {
        padding: 0;
        border: none;
        width: auto;
    }

    #lapTable tbody td:first-child {
        display: flex;
        flex: 0 0 26px;
        width: 26px;
        padding: 0;
    }

    /* La casilla es un círculo con el color que tendrá la vuelta en los gráficos.
       Se toca la fila entera, no la casilla. */
    #lapTable .select-lap {
        -webkit-appearance: none;
        appearance: none;
        display: grid;
        place-content: center;
        width: 26px;
        height: 26px;
        margin: 0;
        border: 2px solid #46536a;
        border-radius: 50%;
        background: transparent;
        pointer-events: none;
    }

    #lapTable .select-lap::before {
        content: '';
        width: 10px;
        height: 5px;
        border-left: 3px solid #0d0f14;
        border-bottom: 3px solid #0d0f14;
        transform: translateY(-1px) rotate(-45deg);
        opacity: 0;
    }

    #lapTable .select-lap:checked {
        border-color: var(--lap-color, var(--accent));
        background: var(--lap-color, var(--accent));
    }

    #lapTable .select-lap:checked::before {
        opacity: 1;
    }

    #lapTable tbody td:nth-child(2) {
        display: flex;
        align-items: center;
        gap: 4px;
        flex: 0 0 34px;
        font-size: 1rem;
        font-weight: 600;
        color: var(--muted);
        font-variant-numeric: tabular-nums;
    }

    /* Fuera de pista / incompleta → punto de color */
    #lapTable .lap-badge-offtrack,
    #lapTable .lap-badge-incomplete {
        width: 7px;
        height: 7px;
        margin: 0;
        padding: 0;
        border: none;
        border-radius: 50%;
        font-size: 0;
        line-height: 0;
    }

    #lapTable .lap-badge-offtrack { background: #ef4444; }
    #lapTable .lap-badge-incomplete { background: #f59e0b; }

    #lapTable tbody td:nth-child(3) {
        flex: 1 1 auto;
        min-width: 0;
        font-size: 1.125rem;
        font-weight: 700;
        font-variant-numeric: tabular-nums;
        white-space: nowrap;
    }

    #lapTable tbody tr.best-row td:nth-child(3) {
        color: #c4b5fd;
    }

    #lapTable tbody td:nth-child(4) {
        flex: 0 0 66px;
        text-align: right;
        font-size: 0.875rem;
        font-weight: 600;
        color: var(--muted);
        font-variant-numeric: tabular-nums;
        white-space: nowrap;
    }

    /* Sectores → mini barras de color (morado = mejor sector de la sesión) */
    #lapTable tbody td.sector-td {
        flex: 0 0 20px;
        height: 10px;
        border-radius: 3px;
        background: var(--sc) !important;
        font-size: 0;
        line-height: 0;
        overflow: hidden;
    }

    #lapTable tbody td.sector-td + td.sector-td {
        margin-left: -7px;
    }

    /* Velocidad pico y "añadir a análisis" no caben en la lista */
    #lapTable tbody tr[data-lap-key] td:nth-last-child(-n + 2) {
        display: none;
    }

    /* ── Barra fija "Comparar" (sustituye al botón flotante) ── */
    body.mobile-tab-analysis.seg-laps .mobile-compare-bar {
        display: flex;
    }

    .mobile-compare-bar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: calc(61px + env(safe-area-inset-bottom));
        z-index: 95;
        align-items: center;
        gap: 10px;
        min-height: 56px;
        box-sizing: border-box;
        padding: 8px 14px;
        background: var(--panel);
        border-top: 1px solid var(--border);
    }

    .mobile-compare-info {
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        min-width: 0;
    }

    .mobile-compare-count {
        font-size: 0.75rem;
        font-weight: 600;
        color: var(--muted);
    }

    .mobile-compare-chips {
        display: flex;
        align-items: center;
        gap: 8px;
        font-size: 0.875rem;
        font-weight: 700;
        white-space: nowrap;
        overflow: hidden;
    }

    .mobile-compare-chip {
        display: inline-flex;
        align-items: center;
        gap: 4px;
    }

    .mobile-compare-cta {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        flex: 0 0 auto;
        min-height: 40px;
        padding: 0 18px;
        border: none;
        border-radius: 12px;
        background: var(--accent);
        color: #0d0f14;
        font-weight: 700;
        font-size: 0.9375rem;
        cursor: pointer;
    }

    .mobile-compare-cta:disabled {
        opacity: 0.45;
        cursor: default;
    }

    /* ── Gráficos: cabecera del panel reducida (los controles viven en "Capas") ── */
    #comparisonPanel .analysis-heading,
    #comparisonPanel .analysis-controls {
        display: none !important;
    }

    #comparisonPanel .analysis-header {
        min-height: 0;
        margin: 0;
        padding: 0;
        border: none;
    }

    #comparisonPanel .analysis-header:not(:has(#activeAnalysisBar:not([hidden]))) {
        display: none;
    }

    #comparisonPanel .analysis-body {
        gap: 6px;
    }

    /* Fila: vueltas comparadas (chips) + botón Capas */
    .mobile-compare-row {
        display: flex;
        align-items: center;
        gap: 6px;
        order: 1;
        min-width: 0;
    }

    .mobile-compare-row .comparison-list {
        flex: 1 1 auto;
        display: flex;
        flex-wrap: nowrap;
        gap: 6px;
        min-width: 0;
        margin: 0;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .mobile-compare-row .comparison-list::-webkit-scrollbar {
        display: none;
    }

    .mobile-compare-row .comparison-card {
        flex: 0 0 auto;
        min-width: 0;
        min-height: 28px;
        padding: 0 8px;
        border-radius: 14px;
        border-color: #2b3444;
        background: var(--panel-alt);
    }

    .mobile-compare-row .comparison-main {
        min-height: 28px;
        gap: 5px;
        font-size: 0.8125rem;
        cursor: pointer;
        font-variant-numeric: tabular-nums;
    }

    .mobile-compare-row .comparison-card strong {
        font-size: 0.8125rem;
    }

    .mobile-compare-row .comparison-card.has-gap strong {
        display: none;
    }

    .mobile-compare-row .comparison-meta,
    .mobile-compare-row .comparison-card .card-actions {
        display: none;
    }

    .mobile-compare-row .comparison-card.is-expanded .card-actions {
        display: flex;
        gap: 6px;
    }

    .mobile-compare-row .comparison-card .ghost-icon-btn {
        width: 30px;
        height: 30px;
        flex: 0 0 30px;
    }

    .comparison-lapno {
        display: inline;
        font-weight: 700;
    }

    .comparison-gap {
        display: inline;
        font-weight: 600;
    }

    .comparison-gap.is-slower { color: #f87171; }
    .comparison-gap.is-faster { color: #34d399; }

    .mobile-layers-btn {
        display: inline-flex;
        align-items: center;
        gap: 5px;
        flex: 0 0 auto;
        min-height: 28px;
        margin-left: auto;
        padding: 0 9px;
        border-radius: 14px;
        border: 1px solid #3a4456;
        background: var(--panel-alt);
        color: var(--text);
        font-weight: 600;
        font-size: 0.8125rem;
        cursor: pointer;
    }

    .mobile-layers-btn .mdi {
        font-size: 1rem;
    }

    /* Capas y Vídeo solo con icono: deja sitio a las vueltas comparadas y al Coach */
    #mobileLayersBtn span,
    #videoOpenBtn span {
        display: none;
    }

    /* Lectura común del cursor */
    .mobile-cursor-readout {
        display: grid;
        order: 4;
        grid-auto-flow: column;
        grid-auto-columns: minmax(0, 1fr);
        gap: 4px;
    }

    .readout-cell[hidden] {
        display: none;
    }

    .readout-cell {
        display: flex;
        flex-direction: column;
        min-width: 0;
        padding: 3px 6px;
        background: var(--panel-alt);
        border: 1px solid var(--border);
        border-radius: 10px;
    }

    .readout-label {
        font-size: 0.625rem;
        font-weight: 600;
        color: var(--muted);
        white-space: nowrap;
    }

    .readout-values {
        font-size: 0.9375rem;
        font-weight: 700;
        font-variant-numeric: tabular-nums;
        white-space: nowrap;
        overflow: hidden;
    }

    .readout-cell.is-multi .readout-values {
        font-size: 0.8rem;
    }

    .readout-value.is-slower { color: #f87171; }
    .readout-value.is-faster { color: #34d399; }

    /* Pestañas de canal */
    .mobile-channel-bar {
        display: flex;
        align-items: center;
        gap: 6px;
        order: 5;
        min-width: 0;
    }

    .mobile-fs-btn,
    .mobile-fs-laps {
        display: none;
    }

    .mobile-channel-tabs {
        flex: 1 1 auto;
        display: flex;
        gap: 6px;
        min-width: 0;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .mobile-channel-tabs::-webkit-scrollbar {
        display: none;
    }

    .mobile-channel-tab {
        flex: 0 0 auto;
        min-height: 28px;
        padding: 0 10px;
        border-radius: 14px;
        border: 1px solid #2b3444;
        background: var(--panel-alt);
        color: var(--text);
        font-weight: 700;
        font-size: 0.8125rem;
        white-space: nowrap;
        cursor: pointer;
    }

    .mobile-channel-tab.is-active {
        background: var(--accent);
        border-color: var(--accent);
        color: #0d0f14;
    }

    /* Rejilla de gráficos: mapa fijo arriba y un solo canal (el de la pestaña) */
    body.mobile-tab-analysis #graphGrid.grid-stack {
        display: contents !important;
    }

    #graphGrid > .grid-stack-item {
        order: 6;
    }

    #graphGrid > .grid-stack-item[gs-id="map"] {
        order: 2;
    }

    #graphGrid > .grid-stack-item:not([gs-id="map"]):not(.is-mobile-active) {
        display: none !important;
    }

    /* El Coach va justo debajo del mapa (orden 2); el balance, tras los gráficos */
    #coachDiagnosticPanel {
        order: 3;
    }

    #balanceDiagnosticPanel {
        order: 7;
    }

    #brakingSection,
    #rangeAnalysisSection,
    #lapStatsSection {
        order: 8;
    }

    #graphGrid .graph-card-header {
        display: none;
    }

    #graphGrid .graph-card {
        position: relative;
        padding: 6px !important;
    }

    #graphGrid .graph-card.is-minimized > :not(.graph-card-header):not([hidden]),
    #graphGrid .graph-card.is-minimized .chart-wrapper {
        display: block !important;
    }

    #graphGrid .chart-wrapper {
        height: 236px !important;
        min-height: 236px !important;
    }

    #graphGrid .map-view {
        height: var(--m-map-height, 150px) !important;
        min-height: var(--m-map-height, 150px) !important;
    }

    /* El gráfico deja desplazar la página en vertical; en horizontal mueve el cursor */
    #graphGrid canvas {
        touch-action: pan-y !important;
    }

    .graph-card > .mobile-fs-enter {
        display: flex;
        position: absolute;
        top: 8px;
        right: 8px;
        z-index: 3;
        align-items: center;
        justify-content: center;
        width: 34px;
        height: 34px;
        border: none;
        border-radius: 9px;
        background: rgba(13, 15, 20, 0.72);
        color: var(--text);
        font-size: 1.15rem;
        cursor: pointer;
    }

    /* ── Reproductor compacto, siempre a mano en Gráficos ── */
    body:not(.seg-charts) .telemetry-player {
        display: none !important;
    }

    body.seg-charts #comparisonPanel {
        margin-bottom: 54px;
    }

    .telemetry-player {
        left: 12px;
        right: 12px;
        bottom: calc(69px + env(safe-area-inset-bottom));
        width: auto;
        height: 46px;
        box-sizing: border-box;
        gap: 8px;
        padding: 4px 6px;
        transform: none;
        border-radius: 14px;
        background: var(--panel-alt);
        opacity: 1;
    }

    .telemetry-player.is-entering {
        transform: translateY(14px);
    }

    .telemetry-player .player-btn {
        width: 38px;
        height: 38px;
    }

    .telemetry-player #playerLoopBtn,
    .telemetry-player #playerFollowBtn,
    .telemetry-player #playerCloseBtn,
    .telemetry-player .player-time-sep,
    .telemetry-player #playerTimeTotal {
        display: none;
    }

    .telemetry-player .player-scrub {
        height: 38px;
    }

    .telemetry-player .player-time {
        font-size: 0.875rem;
    }

    .telemetry-player .player-speed {
        min-height: 36px;
        min-width: 48px;
        font-size: 0.8125rem;
    }

    .player-open-btn {
        display: none;
    }

    /* ── Pantalla completa (botón o móvil en horizontal) ── */
    body.charts-fullscreen {
        overflow: hidden;
    }

    body.charts-fullscreen #comparisonPanel .analysis-body {
        position: fixed;
        inset: 0;
        z-index: 150;
        display: grid;
        grid-template-columns: minmax(0, 1fr) 190px;
        grid-template-rows: 52px minmax(0, 0.42fr) minmax(0, 1fr) 56px;
        grid-template-areas:
            "bar bar"
            "delta map"
            "main readout"
            "player player";
        gap: 6px 10px;
        padding: env(safe-area-inset-top) max(12px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(12px, env(safe-area-inset-left));
        background: var(--bg);
    }

    body.charts-fullscreen #comparisonPanel .analysis-body > :not(.mobile-channel-bar):not(.mobile-cursor-readout):not(#graphGrid) {
        display: none !important;
    }

    body.charts-fullscreen .mobile-channel-bar {
        grid-area: bar;
    }

    body.charts-fullscreen .mobile-fs-btn {
        display: inline-flex;
        flex: 0 0 44px;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        border: 1px solid #2b3444;
        border-radius: 10px;
        background: none;
        color: var(--text);
        font-size: 1.3rem;
        cursor: pointer;
    }

    body.charts-fullscreen .mobile-fs-laps {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 0 4px;
        font-weight: 700;
        white-space: nowrap;
    }

    .mobile-fs-lap {
        display: inline-flex;
        align-items: center;
        gap: 4px;
    }

    .mobile-fs-vs {
        color: #5b6679;
    }

    body.charts-fullscreen .mobile-cursor-readout {
        grid-area: readout;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-auto-flow: row;
        align-content: start;
    }

    body.charts-fullscreen #graphGrid > .grid-stack-item {
        display: none !important;
    }

    body.charts-fullscreen #graphGrid > .grid-stack-item[gs-id="map"] {
        display: block !important;
        grid-area: map;
    }

    body.charts-fullscreen #graphGrid > .grid-stack-item[gs-id="delta"] {
        display: block !important;
        grid-area: delta;
    }

    body.charts-fullscreen #graphGrid > .grid-stack-item.is-mobile-active {
        display: block !important;
        grid-area: main;
    }

    /* Con Delta como canal activo ocupa las dos filas */
    body.charts-fullscreen[data-mobile-channel="delta"] #graphGrid > .grid-stack-item[gs-id="delta"] {
        grid-area: auto;
        grid-column: 1;
        grid-row: 2 / 4;
    }

    body.charts-fullscreen #graphGrid > .grid-stack-item,
    body.charts-fullscreen #graphGrid > .grid-stack-item > .grid-stack-item-content,
    body.charts-fullscreen #graphGrid .graph-card {
        height: 100% !important;
        min-height: 0 !important;
        margin: 0 !important;
    }

    body.charts-fullscreen #graphGrid .chart-wrapper,
    body.charts-fullscreen #graphGrid .map-view {
        height: 100% !important;
        min-height: 0 !important;
    }

    body.charts-fullscreen .graph-card > .mobile-fs-enter {
        display: none;
    }

    body.charts-fullscreen .telemetry-player {
        bottom: max(4px, env(safe-area-inset-bottom));
        left: max(12px, env(safe-area-inset-left));
        right: max(12px, env(safe-area-inset-right));
        height: 52px;
    }
}

/* Pantalla completa en vertical (iOS no deja girar solo): canales apilados, sin mapa */
@media (max-width: 899px) and (orientation: portrait) {
    body.charts-fullscreen #comparisonPanel .analysis-body {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: 52px minmax(0, 0.35fr) minmax(0, 1fr) auto 64px;
        grid-template-areas:
            "bar"
            "delta"
            "main"
            "readout"
            "player";
    }

    body.charts-fullscreen #graphGrid > .grid-stack-item[gs-id="map"],
    body.charts-fullscreen .mobile-fs-laps {
        display: none !important;
    }

    body.charts-fullscreen .mobile-cursor-readout {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        grid-auto-flow: row;
    }

    body.charts-fullscreen[data-mobile-channel="delta"] #graphGrid > .grid-stack-item[gs-id="delta"] {
        grid-row: 2 / 4;
    }
}

/* Con un panel modal abierto (ajustes, capas) el reproductor no debe quedar encima */
@media (max-width: 899px) {
    body.modal-open .telemetry-player,
    body.layers-sheet-open .telemetry-player {
        display: none !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   ESCRITORIO — "banco de trabajo" (boceto "ZeroLAPS escritorio", sept. 2026)
   Todo en una pantalla: vueltas | canales apilados con un eje X | mapa + lectura,
   reproductor como línea de tiempo y tablas en un panel inferior plegable.
   Solo con body.workbench (≥900px). "Diseño libre" (sin la clase) = layout clásico.
   ═══════════════════════════════════════════════════════════════════════════════ */

.desk-seg,
.workbench-splitter,
.chart-resize-handle,
.workbench-side,
.workbench-player-slot,
.workbench-tables,
.workbench-bar-slot,
.readout-head,
.readout-cell-extra,
.layers-layout-toggle {
    display: none;
}

@media (max-width: 899px) {
    .only-desktop {
        display: none !important;
    }

    /* Hoja de Capas compacta: cabe entera sin desplazar en un móvil normal */
    .layers-sheet-title { font-size: 1rem; }
    .layers-sheet-header .ghost-icon-btn { width: 36px; height: 36px; }
    .layers-sheet-body { gap: 12px; }
    .layers-sheet-section { gap: 6px; }
    .layers-sheet-label { font-size: 0.6875rem; }
    .layers-toggles .toggle-chip:not([hidden]) { min-height: 40px; font-size: 0.9375rem; }
    .layers-axis-seg { min-height: 36px; }
    .layers-axis-seg button { min-height: 30px; font-size: 0.875rem; }
    .layers-channel-chips { gap: 6px; }
    .layers-channel-chip { min-height: 32px; padding: 0 11px; border-radius: 16px; font-size: 0.8125rem; }
    .layers-actions > button:not([hidden]) { min-height: 40px; font-size: 0.9375rem; }
}

@media (min-width: 900px) {
    .only-mobile {
        display: none !important;
    }

    /* ── Capas: desplegable anclado al botón (en vez de hoja inferior) ── */
    .layers-sheet {
        right: auto;
        bottom: auto;
        width: 380px;
        max-width: calc(100vw - 24px);
        max-height: min(80vh, 760px);
        gap: 12px;
        padding: 12px 16px 16px;
        border: 1px solid #2b3444;
        border-radius: 14px;
        box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
    }

    .layers-sheet-grabber {
        display: none;
    }

    .layers-sheet-backdrop {
        background: rgba(4, 6, 10, 0.25);
    }

    .layers-sheet-title {
        font-size: 1rem;
    }

    .layers-sheet-header .ghost-icon-btn {
        width: 34px;
        height: 34px;
    }

    .layers-sheet-body {
        gap: 12px;
    }

    .layers-sheet-label {
        font-size: 0.6875rem;
    }

    .layers-toggles .toggle-chip:not([hidden]) {
        min-height: 40px;
        font-size: 0.875rem;
    }

    .layers-toggles .toggle-chip input {
        width: 38px;
        height: 22px;
        border-radius: 11px;
    }

    .layers-toggles .toggle-chip input::after {
        width: 16px;
        height: 16px;
    }

    .layers-toggles .toggle-chip input:checked::after {
        left: 19px;
    }

    .layers-axis-seg {
        min-height: 36px;
    }

    .layers-axis-seg button {
        min-height: 28px;
        font-size: 0.8125rem;
    }

    .layers-channel-chip {
        min-height: 30px;
        padding: 0 11px;
        border-radius: 15px;
        font-size: 0.75rem;
    }

    .layers-actions > button:not([hidden]) {
        min-height: 38px;
        font-size: 0.875rem;
    }

    .layers-layout-toggle {
        display: flex;
        align-items: center;
        gap: 10px;
        width: 100%;
        min-height: 38px;
        padding: 0;
        border: none;
        background: none;
        color: var(--muted);
        font-size: 0.875rem;
        text-align: left;
        cursor: pointer;
    }

    /* Diseño libre: el botón Capas sigue disponible (para volver al banco de trabajo) */
    body:not(.workbench) .mobile-layers-btn {
        display: inline-flex;
        align-self: flex-start;
        align-items: center;
        gap: 6px;
        min-height: 34px;
        padding: 0 12px;
        border-radius: 10px;
        border: 1px solid #3a4456;
        background: var(--panel-alt);
        color: var(--text);
        font-weight: 600;
        font-size: 0.8125rem;
        cursor: pointer;
    }

    /* ── Cabecera: sesión activa + Sesiones · Análisis · Guardados + vista ── */
    body.workbench .app-header .brand {
        display: none;
    }

    body.workbench .mobile-header-ctx {
        display: flex;
        flex: 0 1 auto;
        min-width: 0;
        align-items: center;
        gap: 0.6rem;
        min-height: 44px;
        padding: 0 10px 0 4px;
        border: none;
        border-radius: 10px;
        background: none;
        color: var(--text);
        text-align: left;
        cursor: pointer;
    }

    body.workbench .mobile-header-ctx:hover {
        background: rgba(255, 255, 255, 0.04);
    }

    body.workbench .mobile-header-ctx > .mdi {
        color: var(--accent);
        font-size: 1.2rem;
    }

    body.workbench .mobile-header-ctx-text {
        display: flex;
        flex-direction: column;
        min-width: 0;
    }

    body.workbench .mobile-header-ctx-title {
        display: flex;
        align-items: center;
        gap: 0.2rem;
        font-size: 0.95rem;
        font-weight: 700;
        white-space: nowrap;
    }

    body.workbench .mobile-header-ctx-title .mdi {
        color: var(--accent);
    }

    body.workbench .mobile-header-ctx-sub {
        font-size: 0.75rem;
        color: var(--muted);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    body.workbench .mobile-header-ctx-sub:empty {
        display: none;
    }

    body.workbench:not(.section-history) .desk-seg {
        display: flex;
        gap: 2px;
        padding: 3px;
        background: var(--panel-alt);
        border: 1px solid var(--border);
        border-radius: 10px;
    }

    .desk-seg button {
        height: 30px;
        padding: 0 12px;
        border: none;
        border-radius: 7px;
        background: none;
        color: var(--muted);
        font-size: 0.8125rem;
        font-weight: 600;
        white-space: nowrap;
        cursor: pointer;
    }

    .desk-seg button[aria-pressed="true"] {
        background: var(--accent);
        color: #0d0f14;
        font-weight: 700;
    }

    /* ── Todo cabe en la ventana: sin scroll de página ── */
    body.workbench:not(.section-history) .app-shell {
        height: 100vh;
        box-sizing: border-box;
        padding-bottom: 0.75rem;
        overflow: hidden;
    }

    @supports (height: 100dvh) {
        body.workbench:not(.section-history) .app-shell {
            height: 100dvh;
        }
    }

    body.workbench:not(.section-history) .app-main {
        flex: 1 1 auto;
        min-height: 0;
        grid-template-rows: minmax(0, 1fr);
    }

    body.workbench:not(.section-history) .main-area {
        display: grid;
        grid-template-columns: 300px minmax(0, 1fr);
        grid-template-rows: minmax(0, 1fr);
        gap: 12px;
        height: 100%;
        min-height: 0;
    }

    body.workbench .details-row {
        display: contents;
    }

    body.workbench #insightsPanel {
        display: none !important;
    }

    body.workbench #lapPanel {
        grid-column: 1;
        grid-row: 1;
        display: flex !important;
        flex-direction: column;
        gap: 10px;
        min-height: 0;
        overflow-y: auto;
        padding: 12px !important;
    }

    body.workbench #comparisonPanel {
        grid-column: 2;
        grid-row: 1;
        display: flex;
        flex-direction: column;
        min-width: 0;
        min-height: 0;
        overflow: hidden;
        padding: 12px 12px 0 !important;
    }

    body.workbench.desk-pitlane #lapPanel,
    body.workbench.desk-pitlane #comparisonPanel {
        display: none !important;
    }

    /* Columna de vueltas plegable: cabecera con botón y, plegada, una franja
       estrecha para volver a desplegarla. */
    body.workbench .laps-rail-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin: -4px 0 -2px;
    }

    body.workbench .laps-rail-title {
        font-size: 0.6875rem;
        font-weight: 700;
        letter-spacing: 0.05em;
        text-transform: uppercase;
        color: #6b7d99;
    }

    body.workbench .laps-collapse-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 28px;
        height: 28px;
        border: none;
        border-radius: 7px;
        background: none;
        color: var(--muted);
        font-size: 1.15rem;
        cursor: pointer;
    }

    body.workbench .laps-collapse-btn:hover,
    body.workbench .laps-rail:hover {
        color: var(--text);
        background: rgba(255, 255, 255, 0.06);
    }

    body.workbench .laps-rail {
        display: none;
    }

    body.workbench.laps-collapsed:not(.section-history) .main-area {
        grid-template-columns: 36px minmax(0, 1fr);
    }

    body.workbench.laps-collapsed #lapPanel {
        padding: 4px !important;
        overflow: hidden;
    }

    body.workbench.laps-collapsed #lapPanel > :not(.laps-rail) {
        display: none !important;
    }

    body.workbench.laps-collapsed .laps-rail {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 10px;
        flex: 1 1 auto;
        width: 100%;
        padding: 10px 0;
        border: none;
        border-radius: 8px;
        background: none;
        color: var(--muted);
        font-size: 0.75rem;
        font-weight: 700;
        letter-spacing: 0.05em;
        text-transform: uppercase;
        cursor: pointer;
    }

    body.workbench .laps-rail .mdi {
        font-size: 1.15rem;
    }

    body.workbench .laps-rail span {
        writing-mode: vertical-rl;
        transform: rotate(180deg);
    }

    /* ── Columna izquierda: lista de vueltas ── */
    body.workbench #lapPanel .panel-header,
    body.workbench #lapPanel .table-footer {
        display: none;
    }

    body.workbench .mobile-lap-kpis {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 6px;
    }

    body.workbench .mobile-kpi {
        display: flex;
        flex-direction: column;
        min-width: 0;
        padding: 6px 8px;
        background: var(--panel-alt);
        border: 1px solid var(--border);
        border-radius: 8px;
    }

    body.workbench .mobile-kpi-label {
        font-size: 0.625rem;
        font-weight: 600;
        letter-spacing: 0.05em;
        text-transform: uppercase;
        color: var(--muted);
    }

    body.workbench .mobile-kpi-value {
        font-size: 1rem;
        font-weight: 700;
        font-variant-numeric: tabular-nums;
        white-space: nowrap;
    }

    body.workbench .mobile-kpi-value.is-best { color: #c4b5fd; }
    body.workbench .mobile-kpi-value.is-optimal { color: var(--accent); }
    body.workbench .mobile-kpi-value.is-potential { color: #34d399; }

    body.workbench .mobile-lap-presets {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }

    body.workbench .mobile-preset-btn {
        min-height: 30px;
        padding: 0 11px;
        border-radius: 15px;
        border: 1px solid #3a4456;
        background: var(--panel-alt);
        color: var(--text);
        font-weight: 600;
        font-size: 0.75rem;
        cursor: pointer;
    }

    body.workbench .mobile-preset-btn.is-quiet {
        background: none;
        border-color: var(--border);
        color: var(--muted);
    }

    body.workbench .mobile-lap-legend {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 0 4px;
        font-size: 0.6875rem;
        color: var(--muted);
    }

    body.workbench .mobile-lap-count {
        flex: 1 1 auto;
        min-width: 0;
        font-weight: 600;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    body.workbench .mobile-legend-item {
        display: inline-flex;
        align-items: center;
        gap: 4px;
    }

    body.workbench .mobile-legend-dot {
        width: 6px;
        height: 6px;
        border-radius: 50%;
    }

    body.workbench .mobile-legend-dot.is-offtrack { background: #ef4444; }
    body.workbench .mobile-legend-dot.is-incomplete { background: #f59e0b; }

    body.workbench #lapPanel .table-wrapper {
        overflow: visible;
    }

    body.workbench #lapTable {
        display: block;
        min-width: 0;
    }

    body.workbench #lapTable thead {
        display: none;
    }

    body.workbench #lapTable tbody {
        display: flex;
        flex-direction: column;
    }

    body.workbench #lapTable tbody tr.empty-row {
        display: block;
        padding: 1rem 0.5rem;
        color: var(--muted);
    }

    body.workbench #lapTable tbody tr[data-lap-key] {
        display: flex;
        align-items: center;
        gap: 8px;
        min-height: 46px;
        padding: 0 8px;
        border: none;
        border-left: none !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.04);
        border-radius: 8px;
        background: transparent;
    }

    body.workbench #lapTable tbody tr[data-lap-key]:hover {
        background: rgba(255, 255, 255, 0.035);
    }

    body.workbench #lapTable tbody tr[data-lap-key].selected {
        background: rgba(255, 255, 255, 0.06);
    }

    body.workbench #lapTable tbody tr[data-lap-key].lap-previewing {
        background: rgba(255, 138, 48, 0.1);
    }

    body.workbench #lapTable tbody td {
        padding: 0;
        border: none;
        width: auto;
    }

    body.workbench #lapTable tbody td:first-child {
        display: flex;
        flex: 0 0 20px;
        width: 20px;
    }

    body.workbench #lapTable .select-lap {
        -webkit-appearance: none;
        appearance: none;
        display: grid;
        place-content: center;
        width: 20px;
        height: 20px;
        margin: 0;
        border: 2px solid #46536a;
        border-radius: 50%;
        background: transparent;
        pointer-events: none;
    }

    body.workbench #lapTable .select-lap::before {
        content: '';
        width: 8px;
        height: 4px;
        border-left: 2.5px solid #0d0f14;
        border-bottom: 2.5px solid #0d0f14;
        transform: translateY(-1px) rotate(-45deg);
        opacity: 0;
    }

    body.workbench #lapTable .select-lap:checked {
        border-color: var(--lap-color, var(--accent));
        background: var(--lap-color, var(--accent));
    }

    body.workbench #lapTable .select-lap:checked::before {
        opacity: 1;
    }

    body.workbench #lapTable tbody td:nth-child(2) {
        display: flex;
        align-items: center;
        gap: 3px;
        flex: 0 0 26px;
        font-size: 0.875rem;
        font-weight: 600;
        color: var(--muted);
        font-variant-numeric: tabular-nums;
    }

    body.workbench #lapTable .lap-badge-offtrack,
    body.workbench #lapTable .lap-badge-incomplete {
        width: 6px;
        height: 6px;
        margin: 0;
        padding: 0;
        border: none;
        border-radius: 50%;
        font-size: 0;
        line-height: 0;
    }

    body.workbench #lapTable .lap-badge-offtrack { background: #ef4444; }
    body.workbench #lapTable .lap-badge-incomplete { background: #f59e0b; }

    body.workbench #lapTable tbody td:nth-child(3) {
        flex: 1 1 auto;
        min-width: 0;
        font-size: 1.0625rem;
        font-weight: 700;
        font-variant-numeric: tabular-nums;
        white-space: nowrap;
    }

    body.workbench #lapTable tbody tr.best-row td:nth-child(3) {
        color: #c4b5fd;
    }

    body.workbench #lapTable tbody td:nth-child(4) {
        flex: 0 0 60px;
        text-align: right;
        font-size: 0.8125rem;
        font-weight: 600;
        color: var(--muted);
        font-variant-numeric: tabular-nums;
        white-space: nowrap;
        overflow: hidden;
    }

    body.workbench #lapTable tbody td.sector-td {
        flex: 0 0 14px;
        height: 9px;
        border-radius: 2px;
        background: var(--sc) !important;
        font-size: 0;
        line-height: 0;
        overflow: hidden;
    }

    body.workbench #lapTable tbody td.sector-td + td.sector-td {
        margin-left: -6px;
    }

    body.workbench #lapTable tbody tr[data-lap-key] td:nth-last-child(-n + 2) {
        display: none;
    }

    /* ── Centro: barra única + canales apilados + reproductor ── */
    body.workbench #comparisonPanel .analysis-heading,
    body.workbench #comparisonPanel .analysis-controls {
        display: none !important;
    }

    body.workbench #comparisonPanel .analysis-header {
        min-height: 0;
        margin: 0 0 8px;
        padding: 0;
        border: none;
    }

    body.workbench #comparisonPanel .analysis-header:not(:has(#activeAnalysisBar:not([hidden]))) {
        display: none;
    }

    body.workbench #comparisonPanel .analysis-body {
        flex: 1 1 auto;
        min-height: 0;
        display: grid;
        /* centro | barra divisoria | derecha (ancho ajustable, --wb-side-width) */
        grid-template-columns: minmax(0, 1fr) 14px clamp(300px, var(--wb-side-width, 440px), calc(100% - 494px));
        grid-template-rows: auto minmax(0, 1fr) auto auto;
        grid-template-areas:
            "bar split side"
            "charts split side"
            "player split side"
            "tables tables tables";
        gap: 8px 0;
    }

    /* Barra vertical para repartir el ancho entre el centro y la derecha */
    body.workbench .workbench-splitter {
        grid-area: split;
        display: block;
        position: relative;
        cursor: col-resize;
        touch-action: none;
        outline: none;
    }

    body.workbench .workbench-splitter::after {
        content: '';
        position: absolute;
        top: 0;
        bottom: 0;
        left: 6px;
        width: 2px;
        border-radius: 1px;
        background: var(--border);
        transition: background 0.15s ease;
    }

    body.workbench .workbench-splitter:hover::after,
    body.workbench .workbench-splitter:focus-visible::after,
    body.is-resizing .workbench-splitter::after {
        background: var(--accent);
    }

    body.is-resizing,
    body.is-resizing * {
        user-select: none !important;
    }

    body.workbench #comparisonPanel .analysis-body > * {
        min-width: 0;
    }

    body.workbench .mobile-compare-row {
        grid-area: bar;
        display: flex;
        align-items: center;
        gap: 8px;
        min-width: 0;
    }

    body.workbench .mobile-compare-row .comparison-list {
        flex: 0 1 auto;
        display: flex;
        flex-wrap: nowrap;
        gap: 8px;
        min-width: 0;
        margin: 0;
        overflow-x: auto;
        scrollbar-width: none;
    }

    body.workbench .mobile-compare-row .comparison-card {
        flex: 0 0 auto;
        min-width: 0;
        min-height: 34px;
        padding: 0 4px 0 12px;
        border-radius: 17px;
        border-color: #2b3444;
        background: var(--panel-alt);
    }

    body.workbench .mobile-compare-row .comparison-main {
        min-height: 34px;
        gap: 6px;
        cursor: pointer;
        font-variant-numeric: tabular-nums;
    }

    body.workbench .mobile-compare-row .comparison-card strong {
        font-size: 0.875rem;
    }

    body.workbench .mobile-compare-row .comparison-card.has-gap strong,
    body.workbench .mobile-compare-row .comparison-meta,
    body.workbench .mobile-compare-row .comparison-card .card-actions {
        display: none;
    }

    body.workbench .mobile-compare-row .comparison-card.is-expanded .card-actions {
        display: flex;
        gap: 4px;
    }

    body.workbench .mobile-compare-row .comparison-card .ghost-icon-btn {
        width: 28px;
        height: 28px;
        flex: 0 0 28px;
    }

    body.workbench .comparison-lapno {
        display: inline;
        font-weight: 700;
        font-size: 0.875rem;
    }

    body.workbench .comparison-gap {
        display: inline;
        font-weight: 600;
        font-size: 0.875rem;
    }

    body.workbench .comparison-gap.is-slower { color: #f87171; }
    body.workbench .comparison-gap.is-faster { color: #34d399; }

    body.workbench .workbench-bar-slot {
        display: flex;
        gap: 8px;
        margin-left: auto;
    }

    .workbench-autofit-btn {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        min-height: 34px;
        padding: 0 12px;
        border-radius: 9px;
        border: 1px solid #3a4456;
        background: var(--panel-alt);
        color: var(--text);
        font-weight: 600;
        font-size: 0.8125rem;
        cursor: pointer;
    }

    .workbench-autofit-btn .mdi {
        font-size: 1rem;
    }

    body.workbench .mobile-layers-btn {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        flex: 0 0 auto;
        min-height: 34px;
        padding: 0 12px;
        border-radius: 9px;
        border: 1px solid #3a4456;
        background: var(--panel-alt);
        color: var(--text);
        font-weight: 600;
        font-size: 0.8125rem;
        cursor: pointer;
    }

    body.workbench .mobile-channel-bar,
    body.workbench .mobile-fs-enter {
        display: none !important;
    }

    /* Canales apilados con un solo eje X (Delta siempre arriba) */
    body.workbench #graphGrid.grid-stack {
        grid-area: charts;
        display: flex !important;
        flex-direction: column;
        gap: 5px;
        height: auto !important;
        min-height: 0 !important;
        overflow-y: auto;
    }

    body.workbench #graphGrid > .grid-stack-item {
        position: static !important;
        transform: none !important;
        inset: auto !important;
        top: auto !important;
        left: auto !important;
        width: 100% !important;
        height: auto !important;
        margin: 0 !important;
        position: relative !important;
        flex: 1 1 0;
        min-height: 60px;
    }

    /* Altura fijada por el usuario con el tirador (el resto se reparte el espacio) */
    body.workbench #graphGrid > .grid-stack-item.has-fixed-height {
        flex: 0 0 var(--wb-chart-height);
    }

    body.workbench #graphGrid > .grid-stack-item[gs-id="delta"] {
        order: -1;
    }

    /* Tirador bajo cada canal: arrastrar cambia su alto */
    body.workbench .chart-resize-handle {
        display: block;
        position: absolute;
        left: 0;
        right: 0;
        bottom: -5px;
        height: 8px;
        z-index: 4;
        cursor: row-resize;
        touch-action: none;
    }

    body.workbench .chart-resize-handle::after {
        content: '';
        position: absolute;
        left: 50%;
        top: 2px;
        width: 44px;
        height: 4px;
        margin-left: -22px;
        border-radius: 2px;
        background: #2f3847;
        opacity: 0;
        transition: opacity 0.15s ease, background 0.15s ease;
    }

    body.workbench #graphGrid > .grid-stack-item:hover .chart-resize-handle::after,
    body.workbench .chart-resize-handle:hover::after {
        opacity: 1;
    }

    body.workbench .chart-resize-handle:hover::after,
    body.is-resizing .chart-resize-handle::after {
        background: var(--accent);
        opacity: 1;
    }

    body.workbench #graphGrid > .grid-stack-item[gs-id="gg"]:not(.has-fixed-height) {
        flex: 0 0 340px;
    }

    body.workbench #graphGrid > .grid-stack-item[gs-id="unifiedTelemetry"] {
        flex: 0 0 440px;
    }

    body.workbench #graphGrid > .grid-stack-item.chart-card-hidden,
    body.workbench #graphGrid > .grid-stack-item[gs-id="map"],
    body.workbench #graphGrid > .grid-stack-item[gs-id="minisectors"],
    body.workbench #graphGrid > .grid-stack-item[gs-id="sectors"] {
        display: none !important;
    }

    body.workbench #graphGrid > .grid-stack-item > .grid-stack-item-content {
        position: static !important;
        inset: auto !important;
        height: 100% !important;
    }

    /* Compacto pero legible: título en vertical a la izquierda, márgenes mínimos */
    body.workbench #graphGrid .graph-card {
        position: relative;
        display: flex;
        flex-direction: column;
        height: 100% !important;
        box-sizing: border-box;
        padding: 3px 4px 1px 20px !important;
        gap: 0;
        border-radius: 8px !important;
    }

    body.workbench #graphGrid .graph-card-header {
        position: absolute;
        inset: 0;
        z-index: 2;
        min-height: 0;
        height: auto;
        margin: 0;
        padding: 0;
        border: none;
        background: none;
        pointer-events: none;
        cursor: default;
    }

    body.workbench #graphGrid .graph-title {
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: 18px;
        margin: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
        writing-mode: vertical-rl;
        transform: rotate(180deg);
        white-space: nowrap;
        font-size: 0.6875rem;
        font-weight: 700;
        letter-spacing: 0.03em;
        color: var(--muted);
        border-left: 1px solid var(--border);
    }

    body.workbench #graphGrid .card-minimize-btn,
    body.workbench #graphGrid .card-maximize-btn {
        display: none;
    }

    body.workbench #graphGrid .card-hide-btn {
        position: absolute;
        top: 2px;
        right: 2px;
        width: 22px;
        height: 22px;
        opacity: 0;
        pointer-events: auto;
    }

    body.workbench #graphGrid .graph-card:hover .card-hide-btn {
        opacity: 1;
    }

    body.workbench #graphGrid .graph-card.is-minimized > :not(.graph-card-header):not([hidden]),
    body.workbench #graphGrid .graph-card.is-minimized .chart-wrapper {
        display: block !important;
    }

    body.workbench #graphGrid .chart-wrapper {
        position: relative;
        flex: 1 1 auto;
        height: auto !important;
        min-height: 0 !important;
    }

    /* Reproductor como línea de tiempo bajo los gráficos */
    body.workbench .workbench-player-slot {
        grid-area: player;
        display: block;
    }

    body.workbench .workbench-player-slot .telemetry-player {
        position: static;
        transform: none !important;
        width: auto;
        margin: 0;
        border-radius: 12px;
        opacity: 1;
    }

    body.workbench .workbench-player-slot .telemetry-player[hidden] {
        display: none;
    }

    body.workbench #playerCloseBtn {
        display: none;
    }

    /* ── Derecha: mapa + lectura del cursor + Coach ── */
    body.workbench .workbench-side {
        grid-area: side;
        display: flex;
        flex-direction: column;
        gap: 10px;
        min-height: 0;
        overflow-y: auto;
    }

    /* El mapa crece con el ancho de la columna derecha */
    body.workbench .workbench-map-slot {
        flex: 0 0 auto;
        aspect-ratio: 4 / 3;
        min-height: 220px;
        max-height: 60%;
        position: relative;
        overflow: hidden;
        border: 1px solid var(--border);
        border-radius: 10px;
    }

    /* Alto elegido con el tirador: sustituye a la proporción y al tope del 60 % */
    body.workbench.has-custom-map-height .workbench-map-slot {
        aspect-ratio: auto;
        height: var(--wb-map-height);
        max-height: none;
        min-height: 0;
    }

    body.workbench .map-resize-handle {
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        height: 12px;
        z-index: 6;
        cursor: ns-resize;
        touch-action: none;
    }

    body.workbench .map-resize-handle::after {
        content: '';
        position: absolute;
        left: 50%;
        bottom: 3px;
        width: 44px;
        height: 4px;
        border-radius: 2px;
        transform: translateX(-50%);
        background: var(--muted);
        opacity: 0.55;
    }

    body.workbench .map-resize-handle:hover::after,
    body.is-resizing .map-resize-handle::after {
        background: var(--accent);
        opacity: 1;
    }

    body.workbench .workbench-map-slot #map {
        width: 100%;
        height: 100% !important;
        min-height: 0 !important;
    }

    body.workbench .workbench-side-slot {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    body.workbench .mobile-cursor-readout {
        display: flex;
        flex-direction: column;
        padding: 6px 12px 8px;
        background: var(--panel-alt);
        border: 1px solid var(--border);
        border-radius: 10px;
    }

    body.workbench .readout-head,
    body.workbench .readout-cell {
        display: flex;
        align-items: center;
        min-height: 30px;
        padding: 0;
        border: none;
        border-top: 1px solid rgba(255, 255, 255, 0.05);
        border-radius: 0;
        background: none;
    }

    body.workbench .readout-cell[hidden] {
        display: none;
    }

    body.workbench .readout-head {
        border-top: none;
    }

    body.workbench .readout-head .readout-label {
        font-size: 0.6875rem;
        font-weight: 700;
        letter-spacing: 0.05em;
        text-transform: uppercase;
    }

    body.workbench .mobile-cursor-readout .readout-label {
        flex: 1 1 auto;
        font-size: 0.8125rem;
        font-weight: 500;
        color: var(--muted);
    }

    body.workbench .mobile-cursor-readout .readout-values {
        display: flex;
    }

    body.workbench .mobile-cursor-readout .readout-value {
        width: 56px;
        text-align: right;
        font-size: 0.9375rem;
        font-weight: 700;
        font-variant-numeric: tabular-nums;
    }

    body.workbench .readout-head .readout-value {
        font-size: 0.75rem;
    }

    /* Plegable: queda solo la cabecera con las vueltas */
    body.workbench .readout-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 26px;
        height: 26px;
        margin-left: 6px;
        border: none;
        border-radius: 7px;
        background: none;
        color: var(--muted);
        font-size: 1.1rem;
        cursor: pointer;
    }

    body.workbench .readout-toggle:hover {
        color: var(--text);
        background: rgba(255, 255, 255, 0.05);
    }

    body.workbench .mobile-cursor-readout.is-collapsed .readout-toggle .mdi {
        display: inline-block;
        transform: rotate(180deg);
    }

    body.workbench .mobile-cursor-readout.is-collapsed .readout-cell {
        display: none;
    }

    body.workbench .readout-value.is-empty { color: #5b6679; }
    body.workbench .readout-value.is-slower { color: #f87171; }
    body.workbench .readout-value.is-faster { color: #34d399; }

    body.workbench .workbench-side .coach-diagnostic-panel {
        margin: 0;
    }

    /* ── Panel inferior de tablas ── */
    body.workbench .workbench-tables {
        grid-area: tables;
        display: flex;
        flex-direction: column;
        margin: 0 -12px;
        background: #11151c;
        border-top: 1px solid var(--border);
    }

    .workbench-tables-bar {
        display: flex;
        align-items: center;
        gap: 4px;
        height: 40px;
        padding: 0 12px;
    }

    .workbench-tables-label {
        margin-right: 8px;
        font-size: 0.6875rem;
        font-weight: 700;
        letter-spacing: 0.05em;
        text-transform: uppercase;
        color: #6b7d99;
    }

    .workbench-tables-bar [data-pane] {
        height: 30px;
        padding: 0 12px;
        border: none;
        border-radius: 7px;
        background: none;
        color: var(--muted);
        font-size: 0.8125rem;
        font-weight: 600;
        cursor: pointer;
    }

    .workbench-tables-bar [data-pane].is-active {
        background: var(--panel-alt);
        color: var(--text);
    }

    .workbench-tables-bar [data-pane]:disabled {
        opacity: 0.4;
        cursor: default;
    }

    .workbench-tables-toggle {
        width: 30px;
        height: 30px;
        margin-left: auto;
        border: none;
        border-radius: 7px;
        background: none;
        color: var(--muted);
        font-size: 1.1rem;
        cursor: pointer;
    }

    .workbench-tables.is-open .workbench-tables-toggle .mdi {
        display: inline-block;
        transform: rotate(180deg);
    }

    .workbench-tables-body {
        display: none;
        max-height: 36vh;
        overflow: auto;
        padding: 0 12px 12px;
    }

    .workbench-tables.is-open .workbench-tables-body {
        display: block;
    }

    .workbench-pane {
        display: none;
    }

    .workbench-pane.is-active {
        display: block;
    }

    .workbench-pane > .braking-section,
    .workbench-pane > .graph-card {
        margin: 0;
    }

    /* ── Pitlane como vista propia ── */
    body.workbench.desk-pitlane #insightsPanel {
        grid-column: 1 / -1;
        grid-row: 1;
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) 420px;
        grid-template-areas:
            "head head"
            "summary summary"
            "evolution alerts"
            "rhythm alerts";
        align-content: start;
        gap: 14px 16px;
        min-height: 0;
        overflow-y: auto;
        padding: 20px !important;
    }

    body.workbench.desk-pitlane #insightsPanel > .panel-header { grid-area: head; }
    body.workbench.desk-pitlane #insightsPanel > .summary-grid { grid-area: summary; }
    body.workbench.desk-pitlane #insightsPanel > .alerts { grid-area: alerts; align-self: start; }
    body.workbench.desk-pitlane #insightsPanel > .evolution-section { grid-area: evolution; }
    body.workbench.desk-pitlane #insightsPanel > .rhythm-section { grid-area: rhythm; }

    body.workbench.desk-pitlane #insightsPanel .summary-grid {
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 10px;
    }

    /* Bloque principal: mejor, óptima, consistencia, vueltas, velocidad pico */
    body.workbench.desk-pitlane #insightsPanel .summary-card:nth-child(2) { order: 1; }
    body.workbench.desk-pitlane #insightsPanel .summary-card:nth-child(3) { order: 2; }
    body.workbench.desk-pitlane #insightsPanel .summary-card:nth-child(4) { order: 3; }
    body.workbench.desk-pitlane #insightsPanel .summary-card:nth-child(1) { order: 4; }
    body.workbench.desk-pitlane #insightsPanel .summary-card:nth-child(5) { order: 5; }
    body.workbench.desk-pitlane #insightsPanel .summary-card:nth-child(n + 6) { order: 10; }

    /* (el tema plano fija tamaños con !important: aquí hay que igualarlo) */
    body.workbench.desk-pitlane #insightsPanel .summary-card:nth-child(-n + 5) {
        padding: 14px 16px !important;
    }

    body.workbench.desk-pitlane #insightsPanel .summary-card:nth-child(-n + 5) .summary-value {
        font-size: 2rem !important;
        font-variant-numeric: tabular-nums;
    }

    body.workbench.desk-pitlane #insightsPanel .summary-card:nth-child(2) .summary-value {
        color: #c4b5fd;
    }

    /* Condiciones y calidad de datos: tarjetas compactas */
    body.workbench.desk-pitlane #insightsPanel .summary-card:nth-child(n + 6) {
        padding: 8px 12px !important;
    }

    body.workbench.desk-pitlane #insightsPanel .summary-card:nth-child(n + 6) .summary-value {
        font-size: 0.95rem !important;
    }

    body.workbench.desk-pitlane #insightsPanel .evolution-chart-wrapper,
    body.workbench.desk-pitlane #insightsPanel .rhythm-chart-wrapper {
        height: 260px;
    }
}

/* Banco de trabajo: los tiradores de gridstack (diseño libre) no aplican */
@media (min-width: 900px) {
    body.workbench #graphGrid .ui-resizable-handle {
        display: none !important;
    }
}

/* Móvil: "Restablecer gráficos" como una fila más de la hoja Capas */
@media (max-width: 899px) {
    .layers-layout-toggle {
        display: flex;
        align-items: center;
        gap: 12px;
        width: 100%;
        min-height: 48px;
        padding: 0;
        border: none;
        background: none;
        color: var(--text);
        font-size: 1rem;
        text-align: left;
        cursor: pointer;
    }
}

/* Banco de trabajo: "Guardados" es una solapa propia; el análisis vuelve al abrir uno */
@media (min-width: 900px) {
    body.workbench.section-history #lapPanel,
    body.workbench.section-history #comparisonPanel,
    body.workbench.section-history #insightsPanel {
        display: none !important;
    }

    body.workbench.section-history #historyPanel {
        display: flex !important;
        width: 100%;
        box-sizing: border-box;
    }

    /* Aprovecha el ancho: análisis y vueltas de la biblioteca en rejilla */
    body.workbench.section-history #analysisList,
    body.workbench.section-history #libraryList {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
        gap: 10px;
        align-items: start;
    }

    body.workbench.section-history #analysisList > *,
    body.workbench.section-history #libraryList > * {
        margin: 0 !important;
        min-width: 0;
    }

    body.workbench.section-history #analysisList > .empty-state,
    body.workbench.section-history #libraryList > .empty-state {
        grid-column: 1 / -1;
    }
}

/* Lista de vueltas vacía: el aviso ocupa toda la fila (no la columna del círculo) */
@media (max-width: 899px) {
    #lapTable tbody tr.empty-row td {
        display: block;
        width: auto;
        flex: none;
    }
}

@media (min-width: 900px) {
    body.workbench #lapTable tbody tr.empty-row td {
        display: block;
        width: auto;
        flex: none;
        text-align: left;
        font-size: 0.8125rem;
    }
}

/* ─── Explorador "Abrir sesión" (src/ui/session-explorer.js) ─────────────────
   Escritorio: modal con columnas Pilotos | Jornadas | Tandas.
   Móvil (<900px): hoja a pantalla completa, una columna según data-screen. */

.header-open-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    white-space: nowrap;
}

.header-open-btn kbd,
.sx-keys kbd {
    font: 500 11px 'Roboto Mono', monospace;
    padding: 1px 6px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 4px;
    color: var(--muted);
}

@media (max-width: 899px) {
    .header-open-btn {
        display: none;
    }
}

body.session-explorer-open {
    overflow: hidden;
}

.sx-overlay {
    position: fixed;
    inset: 0;
    z-index: 1500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(4, 5, 8, 0.74);
}

.sx-overlay[hidden] {
    display: none;
}

.sx-overlay svg {
    width: 18px;
    height: 18px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sx-dialog {
    width: min(1180px, 100%);
    height: min(740px, 100%);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
    color: var(--text);
}

.sx-head {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    flex: none;
}

.sx-heading {
    flex: none;
    min-width: 0;
}

.sx-title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}

.sx-crumb {
    margin: 2px 0 0;
    font-size: 12px;
    color: var(--muted);
}

.sx-search {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    height: 42px;
    padding: 0 14px;
    background: var(--bg-2);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    color: var(--muted);
}

.sx-search:focus-within {
    border-color: var(--accent);
}

.sx-search[hidden] {
    display: none;
}

.sx-search-input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: 0;
    outline: 0;
    color: var(--text);
    font: inherit;
    font-size: 15px;
}

.sx-icon-btn {
    width: 44px;
    height: 44px;
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 10px;
    color: var(--text);
    cursor: pointer;
}

.sx-icon-btn:hover {
    background: var(--panel-alt);
}

.sx-icon-btn[hidden] {
    display: none;
}

.sx-icon-btn svg {
    width: 20px;
    height: 20px;
}

.sx-refresh[aria-busy="true"] {
    cursor: default;
    opacity: 0.7;
}

.sx-refresh.is-spinning svg {
    animation: sx-spin 0.8s linear infinite;
}

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

.sx-recents {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px 16px;
    flex: none;
}

.sx-recents[hidden] {
    display: none;
}

.sx-recents-label {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 104px;
    flex: none;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.sx-recents-label svg {
    width: 16px;
    height: 16px;
}

.sx-recents-row {
    flex: 1;
    min-width: 0;
    display: flex;
    gap: 10px;
}

.sx-recent {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 56px;
    padding: 8px 14px;
    background: var(--panel-alt);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    color: var(--text);
    text-align: left;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}

.sx-recent:hover,
.sx-recent:focus-visible {
    border-color: rgba(255, 122, 24, 0.6);
}

.sx-recent-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.sx-body {
    flex: 1;
    min-height: 0;
    display: flex;
    border-top: 1px solid var(--border);
}

.sx-col {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.sx-owners {
    display: none;
    width: 250px;
    flex: none;
    overflow-y: auto;
    padding: 0 8px 12px;
    border-right: 1px solid var(--border);
}

.sx-overlay.is-multi-owner .sx-owners {
    display: block;
}

.sx-days {
    flex: 1;
    border-right: 1px solid var(--border);
}

.sx-stints {
    width: 430px;
    flex: none;
}

.sx-days-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex: none;
}

.sx-days-title {
    margin-right: auto;
    font-size: 15px;
    font-weight: 700;
}

.sx-years {
    display: flex;
    gap: 6px;
    overflow-x: auto;
}

.sx-years:empty {
    display: none;
}

.sx-seg {
    display: flex;
    gap: 2px;
    padding: 3px;
    background: var(--bg-2);
    border-radius: 9px;
}

.sx-seg-btn {
    height: 32px;
    padding: 0 12px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.sx-seg-btn.is-on {
    background: #2a2f3d;
    color: var(--text);
}

.sx-chip {
    height: 30px;
    padding: 0 12px;
    flex: none;
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: transparent;
    color: #c9cfdb;
    font: inherit;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
}

.sx-chip:hover {
    background: var(--panel-alt);
}

.sx-chip.is-on {
    background: var(--text);
    border-color: var(--text);
    color: var(--bg);
}

.sx-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0 8px 12px;
}

.sx-group-label {
    padding: 14px 12px 6px;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.sx-month {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 14px 12px 8px;
    background: var(--panel);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #c9cfdb;
}

.sx-month .sx-muted {
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
}

.sx-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 56px;
    padding: 10px 12px;
    background: transparent;
    border: 0;
    border-radius: 8px;
    color: var(--text);
    text-align: left;
    font: inherit;
    font-size: 14px;
    cursor: pointer;
}

.sx-row:hover {
    background: var(--panel-alt);
}

.sx-row:focus-visible,
.sx-check:focus-visible,
.sx-recent:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.sx-row.is-sel {
    background: rgba(255, 122, 24, 0.16);
}

.sx-row.is-sel .sx-t1 {
    color: var(--accent-strong);
}

.sx-row.is-dim {
    opacity: 0.45;
}

.sx-row-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.sx-avatar {
    width: 34px;
    height: 34px;
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #2a2f3d;
    font-size: 12px;
    font-weight: 700;
}

.sx-row.is-sel .sx-avatar {
    background: var(--accent);
    color: var(--bg);
}

.sx-chevron {
    display: flex;
    color: #5d6578;
}

.sx-chevron svg {
    width: 16px;
    height: 16px;
}

.sx-day-date {
    width: 104px;
    flex: none;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.sx-day-date .sx-muted,
.sx-row-main .sx-muted,
.sx-day-best .sx-muted {
    font-size: 12px;
}

.sx-day-best {
    flex: none;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
}

.sx-day-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex: none;
    font-size: 13px;
}

.sx-day-card .sx-strong {
    font-size: 15px;
}

.sx-stints .sx-list {
    padding-top: 8px;
}

.sx-stint {
    display: flex;
    align-items: center;
    gap: 6px;
    padding-right: 6px;
}

.sx-stint .sx-row {
    flex: 1;
    min-width: 0;
}

.sx-stint-best {
    width: 64px;
    flex: none;
    text-align: right;
    font-size: 15px;
}

.sx-bars {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 20px;
    flex: none;
}

.sx-bars i {
    width: 3px;
    border-radius: 1px;
    background: #4a5163;
}

.sx-bars i.is-best {
    background: var(--accent);
}

.sx-check {
    width: 40px;
    height: 40px;
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 50%;
    border: 2px solid #565d70;
    background: transparent;
    color: transparent;
    cursor: pointer;
}

.sx-check:hover:not(:disabled) {
    border-color: var(--accent);
}

.sx-check.is-on {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg);
}

.sx-check:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.sx-check svg {
    stroke-width: 2.5;
}

.sx-tag {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(255, 122, 24, 0.18);
    color: var(--accent-strong);
    font-size: 11px;
    font-weight: 500;
    vertical-align: 1px;
}

.sx-foot {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 64px;
    padding: 10px 20px;
    flex: none;
    border-top: 1px solid var(--border);
    background: var(--bg-2);
    font-size: 13px;
}

.sx-foot.is-empty {
    display: none;
}

.sx-keys {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
    flex: none;
}

.sx-cart-info {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
}

.sx-cart-chips {
    flex: 1;
    min-width: 0;
    display: flex;
    gap: 6px;
    overflow-x: auto;
}

.sx-btn {
    height: 40px;
    padding: 0 16px;
    flex: none;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 10px;
    color: var(--text);
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}

.sx-btn:hover {
    background: var(--panel-alt);
}

.sx-btn-small {
    height: 34px;
    margin-top: 8px;
    font-size: 13px;
}

.sx-btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg);
    font-weight: 700;
}

.sx-btn-primary:hover {
    background: var(--accent-strong);
}

.sx-empty {
    padding: 48px 16px;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
}

.sx-hint {
    margin: 0;
    padding: 16px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

.sx-strong {
    font-weight: 500;
}

.sx-normal {
    font-weight: 400;
}

.sx-muted {
    color: var(--muted);
}

.sx-accent {
    color: var(--accent-strong);
}

.sx-mono {
    font-family: 'Roboto Mono', ui-monospace, monospace;
}

.sx-ell {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Móvil: hoja a pantalla completa, un nivel cada vez. */
@media (max-width: 899px) {
    .sx-overlay {
        padding: 0;
        align-items: stretch;
    }

    .sx-dialog {
        width: 100%;
        height: 100%;
        border: 0;
        border-radius: 0;
        padding-top: env(safe-area-inset-top);
    }

    .sx-head {
        flex-wrap: wrap;
        gap: 4px 8px;
        padding: 8px 12px 10px;
    }

    .sx-heading {
        flex: 1;
        order: 1;
        padding-left: 4px;
    }

    .sx-back {
        order: 0;
    }

    .sx-close {
        order: 0;
    }

    .sx-back:not([hidden]) + .sx-heading ~ .sx-close {
        display: none;
    }

    .sx-icon-btn {
        border: 0;
        border-radius: 22px;
    }

    .sx-title {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .sx-search {
        order: 2;
        flex: 1 0 100%;
        height: 46px;
        margin-top: 4px;
    }

    .sx-search-input {
        font-size: 16px; /* evita el zoom automático de iOS */
    }

    .sx-recents {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 0 0 8px;
    }

    .sx-recents-label {
        width: auto;
        padding: 0 16px;
    }

    .sx-recents-row {
        overflow-x: auto;
        padding: 0 16px;
        scrollbar-width: none;
    }

    .sx-recent {
        flex: 0 0 236px;
        min-height: 68px;
        border-radius: 12px;
        font-size: 14px;
    }

    .sx-body {
        overflow: hidden;
    }

    .sx-body .sx-col,
    .sx-overlay.is-multi-owner .sx-body .sx-owners {
        display: none;
        width: 100%;
        flex: 1;
        border-right: 0;
    }

    .sx-body[data-screen="owners"] .sx-owners,
    .sx-overlay.is-multi-owner .sx-body[data-screen="owners"] .sx-owners,
    .sx-body[data-screen="days"] .sx-days,
    .sx-body[data-screen="stints"] .sx-stints {
        display: flex;
        flex-direction: column;
    }

    .sx-owners {
        overflow-y: auto;
        padding: 0 0 16px;
    }

    .sx-stints {
        overflow-y: auto;
    }

    .sx-stints .sx-list {
        flex: none;
        overflow: visible;
    }

    .sx-days-toolbar {
        padding: 6px 16px 8px;
    }

    .sx-days-title {
        display: none;
    }

    .sx-seg {
        flex: 1 0 100%;
    }

    .sx-seg-btn {
        flex: 1;
        height: 38px;
        font-size: 14px;
    }

    .sx-years {
        flex: 1 0 100%;
    }

    .sx-chip {
        height: 36px;
        font-size: 13px;
    }

    .sx-list {
        padding: 0 0 16px;
    }

    .sx-row {
        min-height: 64px;
        padding: 10px 16px;
        border-radius: 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
        font-size: 15px;
    }

    .sx-month {
        padding: 14px 16px 8px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    }

    .sx-group-label {
        padding: 18px 16px 8px;
    }

    .sx-avatar {
        width: 40px;
        height: 40px;
        font-size: 13px;
    }

    .sx-day-date {
        width: 88px;
    }

    .sx-day-card {
        margin: 4px 16px 8px;
        border: 0;
        border-radius: 12px;
        background: var(--panel-alt);
    }

    .sx-stint {
        padding-right: 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    }

    .sx-stint .sx-row {
        border-bottom: 0;
    }

    .sx-check {
        width: 44px;
        height: 44px;
    }

    .sx-foot.has-cart {
        flex-wrap: wrap;
        padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    }

    .sx-foot .sx-cart-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .sx-foot .sx-cart-chips {
        width: 100%;
    }

    .sx-foot .sx-btn {
        height: 48px;
    }
}

/* Acceso al explorador desde el panel Sesiones: aspecto de buscador. */
.sessions-explorer-cta {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 46px;
    margin: 4px 0 10px;
    padding: 0 14px;
    background: var(--bg-2);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    color: var(--muted);
    font: inherit;
    font-size: 15px;
    text-align: left;
    cursor: pointer;
}

.sessions-explorer-cta:hover,
.sessions-explorer-cta:focus-visible {
    border-color: var(--accent);
    color: var(--text);
}

.sessions-explorer-cta .mdi {
    font-size: 20px;
}


/* Explorador: arrastre desde el borde derecho (móvil). La hoja sigue al dedo. */
.sx-overlay.is-dragging {
    background: transparent;
}

.sx-overlay.is-dragging .sx-dialog {
    box-shadow: -14px 0 32px rgba(0, 0, 0, 0.55);
}

/* Explorador: botón de importar junto a cerrar. En móvil va a la derecha del título. */
@media (max-width: 899px) {
    .sx-refresh,
    .sx-upload {
        order: 1;
    }
}

/* Panel lateral antiguo de sesiones desactivado (SESSIONS_DRAWER_ENABLED en app.js):
   se ocultan el cajón, su hamburguesa, su fondo y el apartado "Sesiones" de la cabecera. */
body.no-sessions-drawer #sessionsPanel,
body.no-sessions-drawer #sessionsToggleBtn,
body.no-sessions-drawer #sessionsBackdrop,
body.no-sessions-drawer .header-nav .nav-section-btn[data-section="sessions"] {
    display: none !important;
}

/* Confirmaciones y avisos lanzados desde el explorador quedan por encima de él. */
body.session-explorer-open .confirm-modal {
    z-index: 1600;
}

body.session-explorer-open .toast-stack {
    z-index: 1700;
}

/* Explorador: acciones de la cesta (comparar y gestión). */
.sx-cart-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: none;
    flex-wrap: wrap;
}

.sx-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.sx-btn-danger {
    color: var(--danger);
    border-color: rgba(255, 91, 91, 0.45);
}

.sx-btn-danger:hover:not(:disabled) {
    background: rgba(255, 91, 91, 0.12);
}

.sx-select {
    height: 40px;
    padding: 0 10px;
    background: var(--bg-2);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 10px;
    color: var(--text);
    font: inherit;
    font-size: 14px;
    cursor: pointer;
}

@media (max-width: 899px) {
    .sx-foot.has-cart {
        flex-direction: column;
        align-items: stretch;
    }

    .sx-cart-actions {
        flex-wrap: wrap;
    }

    .sx-cart-actions .sx-btn,
    .sx-cart-actions .sx-select {
        flex: 1 1 auto;
        height: 44px;
    }
}

/* Confirmación peligrosa (borrar): el aceptar es primary-btn + danger-btn; sin esto
   quedaba texto rosa sobre fondo naranja, casi ilegible. */
.confirm-modal .primary-btn.danger-btn {
    background: var(--danger);
    border-color: var(--danger);
    color: var(--bg);
}

/* ─── Diálogo "Guardados" (src/ui/saved-explorer.js) ─────────────────────────
   Reutiliza los estilos .sx-* del explorador; aquí solo lo propio. */
.sv .sv-filters {
    width: 240px;
    flex: none;
    overflow-y: auto;
    padding: 0 8px 12px;
    border-right: 1px solid var(--border);
}

.sv .sv-list {
    flex: 1;
    border-right: 1px solid var(--border);
}

.sv .sv-detail {
    width: 430px;
    flex: none;
}

.sv .sv-filter {
    min-height: 44px;
}

.sv-chips,
.sv-only-mobile {
    display: none;
}

.sv-action {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.sv .sv-detail-head {
    align-items: stretch;
}

.sv-detail-title {
    font-size: 16px;
    font-weight: 700;
}

.sv-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.sv-actions .sx-btn {
    flex: 1 1 auto;
}

.sv-actions-col {
    flex-direction: column;
}

.sv-actions-col .sv-actions {
    margin-top: 0;
}

.sv-detail-body {
    padding: 0 16px 16px;
}

.sv-detail-body .sx-group-label {
    padding-left: 0;
}

.sv-lapline {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 14px;
}

.sv-dot {
    width: 9px;
    height: 9px;
    flex: none;
    border-radius: 50%;
    background: #4a5163;
}

.sv-notes {
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-line;
    color: #c9cfdb;
}

.sv-switch {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    padding: 6px 0;
    background: transparent;
    border: 0;
    color: #c9cfdb;
    font: inherit;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
}

.sv-switch:disabled {
    opacity: 0.5;
    cursor: wait;
}

.sv-knob {
    position: relative;
    width: 36px;
    height: 22px;
    flex: none;
    border-radius: 11px;
    background: #2a2f3d;
}

.sv-knob i {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--muted);
    transition: left 0.15s ease;
}

.sv-knob.is-on {
    background: var(--accent);
}

.sv-knob.is-on i {
    left: 17px;
    background: var(--bg);
}

.sv-lib-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
}

.sv-lib-time {
    font-size: 22px;
}

.sx-tag.sv-tag-owner {
    background: rgba(78, 168, 255, 0.16);
    color: #8cc6ff;
}

@media (max-width: 899px) {

    .sv .sx-search {
        order: 3;
    }

    .sv .sv-action {
        order: 1;
        width: 44px;
        height: 44px;
        padding: 0;
        border: 0;
        justify-content: center;
    }

    .sv .sv-action span {
        display: none;
    }

    .sv .sv-action svg {
        width: 22px;
        height: 22px;
    }

    .sv .sv-action[hidden] {
        display: none;
    }

    .sv .sx-body[data-screen="list"] .sv-list,
    .sv .sx-body[data-screen="detail"] .sv-detail {
        display: flex;
        flex-direction: column;
    }

    .sv .sv-detail {
        overflow-y: auto;
    }

    .sv .sv-detail .sv-detail-body {
        flex: none;
        overflow: visible;
    }

    .sv-chips {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        padding: 2px 16px 8px;
        flex: none;
    }

    .sv-only-mobile {
        display: flex;
    }

    .sv-lib-time {
        font-size: 28px;
    }

    .sv-actions .sx-btn {
        height: 48px;
    }
}

/* Pestañas comunes "Abrir": Sesiones · Análisis · Biblioteca (ambos diálogos). */
.sx-tabs[hidden] {
    display: none;
}

@media (max-width: 899px) {
    .sx-tabs {
        order: 2;
        flex: 1 0 100%;
    }

    .sx-tabs .sx-seg-btn {
        flex: 1;
        height: 38px;
        font-size: 14px;
    }

    .sx-search {
        order: 3;
    }
}

/* Sin navegación por secciones (todo se abre desde "Abrir…"): fuera la navegación
   de la cabecera y la barra inferior de móvil; lo que flotaba sobre ella baja. */
body.no-section-nav .header-nav,
body.no-section-nav .bottom-nav {
    display: none !important;
}

@media (max-width: 899px) {
    body.no-section-nav .app-shell {
        padding-bottom: calc(0.75rem + env(safe-area-inset-bottom)) !important;
    }

    body.no-section-nav .toast-stack,
    body.no-section-nav .fab {
        bottom: calc(1rem + env(safe-area-inset-bottom));
    }

    body.no-section-nav .mobile-compare-bar {
        bottom: env(safe-area-inset-bottom);
    }

    body.no-section-nav .telemetry-player {
        bottom: calc(8px + env(safe-area-inset-bottom));
    }
}

/* Explorador: "Ver vueltas" en cada tanda para que se vea que la fila la abre.
   Escritorio: píldora que sustituye al gráfico de ritmo al pasar el ratón o con
   foco. Móvil: línea fija bajo los datos de la tanda. */
.sx-stint-open {
    position: relative;
}

.sx-open-line {
    display: none;
}

.sx-open-pill {
    position: absolute;
    top: 50%;
    right: 84px;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 4px 6px 4px 10px;
    border-radius: 14px;
    background: var(--accent);
    color: var(--bg);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    opacity: 0;
    transform: translateY(-50%);
    transition: opacity 0.12s ease;
    pointer-events: none;
}

.sx-open-pill svg,
.sx-open-line svg {
    width: 14px;
    height: 14px;
    stroke-width: 2.5;
}

.sx-stint-open:hover .sx-open-pill,
.sx-stint-open:focus-visible .sx-open-pill {
    opacity: 1;
}

.sx-stint-open:hover .sx-bars,
.sx-stint-open:focus-visible .sx-bars {
    opacity: 0;
}

@media (max-width: 899px) {
    .sx-open-pill {
        display: none;
    }

    .sx-open-line {
        display: inline-flex;
        align-items: center;
        gap: 2px;
        margin-top: 2px;
        color: var(--accent-strong);
        font-size: 13px;
        font-weight: 500;
    }
}

/* ─── Guía de bienvenida (src/ui/guided-tour.js) ──────────────────────────────── */
.settings-tour-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    justify-content: flex-start;
}

.tour-root {
    position: fixed;
    inset: 0;
    z-index: 3000;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.tour-root.is-visible {
    opacity: 1;
}

/* Bloquea clics sobre la app; en pasos sin zona hace de fondo oscuro */
.tour-blocker {
    position: absolute;
    inset: 0;
    background: transparent;
}

.tour-root.is-centered .tour-blocker {
    background: rgba(4, 6, 10, 0.72);
}

/* El hueco iluminado: la sombra enorme oscurece todo lo demás */
.tour-spot {
    position: absolute;
    border-radius: 12px;
    box-shadow:
        0 0 0 2px var(--accent),
        0 0 0 6px rgba(255, 122, 24, 0.25),
        0 0 0 200vmax rgba(4, 6, 10, 0.72);
    pointer-events: none;
    transition: left 0.25s ease, top 0.25s ease, width 0.25s ease, height 0.25s ease;
}

.tour-root.is-centered .tour-spot {
    display: none;
}

.tour-card {
    position: absolute;
    width: min(360px, calc(100vw - 24px));
    background: var(--panel-alt);
    border: 1px solid rgba(255, 122, 24, 0.35);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 14px 16px 12px;
    color: var(--text);
    transition: left 0.25s ease, top 0.25s ease;
}

.tour-card.is-sheet {
    left: 8px !important;
    right: 8px;
    width: auto;
}

.tour-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.tour-card-progress {
    font-size: 0.72rem;
    color: var(--muted);
    letter-spacing: 0.06em;
}

.tour-card-close {
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 1.1rem;
    width: 32px;
    height: 32px;
    margin: -6px -8px 0 0;
    border-radius: 8px;
    cursor: pointer;
}

.tour-card-close:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
}

.tour-card-title {
    margin: 2px 0 6px;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--accent-strong);
}

.tour-card-body p {
    margin: 0 0 6px;
    font-size: 0.9rem;
    line-height: 1.45;
}

.tour-card-dots {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 10px 0 12px;
}

.tour-card-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.16);
}

.tour-card-dots span.is-done {
    background: rgba(255, 122, 24, 0.45);
}

.tour-card-dots span.is-active {
    background: var(--accent);
    width: 16px;
    border-radius: 3px;
}

.tour-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.tour-card-optout {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
}

.tour-card-optout input {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
    margin: 0;
}

.tour-card-nav {
    display: flex;
    gap: 6px;
    margin-left: auto;
}

.tour-card-nav button[hidden] {
    display: none;
}

@media (max-width: 899px) {
    .tour-card-nav button {
        min-height: 40px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tour-root,
    .tour-spot,
    .tour-card {
        transition: none;
    }
}

/* ─── Barra de comparación compacta ─────────────────────────────────────────── */
/* Tira del análisis activo: nombre + iconos sueltos (editar / cerrar) */
.active-analysis-bar {
    gap: 0.35rem;
    padding: 0.15rem 0.25rem 0.15rem 0.6rem;
    min-height: 34px;
    border-radius: 9px;
}

.active-analysis-bar button.ghost-icon-btn {
    width: 26px;
    height: 26px;
    flex: 0 0 26px;
    border-color: transparent;
    border-radius: 7px;
    font-size: 0.95rem;
}

.active-analysis-bar button.ghost-icon-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}

@media (max-width: 899px) {
    .active-analysis-bar {
        max-width: none;
        width: 100%;
    }

    /* Coach, Vídeo y Capas: botones de icono de 32 px pegados a la derecha */
    .mobile-compare-row .mobile-layers-btn {
        width: 32px;
        min-height: 32px;
        height: 32px;
        padding: 0;
        justify-content: center;
        border-radius: 9px;
    }

    .mobile-compare-row .mobile-layers-btn span {
        display: none;
    }

    .mobile-compare-row .mobile-layers-btn .mdi {
        font-size: 1.1rem;
    }

    .mobile-compare-row .comparison-card {
        min-height: 32px;
        border-radius: 10px;
    }

    .mobile-compare-row .comparison-main {
        min-height: 32px;
    }
}

/* ─── Móvil: mapa escalable y tablas plegables ──────────────────────────────── */
.map-card-resize,
.section-fold-btn {
    display: none;
}

@media (max-width: 899px) {
    .map-card-resize {
        display: flex;
        align-items: center;
        justify-content: center;
        height: 22px;
        margin-top: 2px;
        cursor: ns-resize;
        touch-action: none;
    }

    .map-card-resize span {
        width: 44px;
        height: 4px;
        border-radius: 2px;
        background: var(--muted);
        opacity: 0.6;
    }

    body.is-resizing .map-card-resize span {
        background: var(--accent);
        opacity: 1;
    }
}

body:not(.workbench) .braking-section {
    position: relative;
}

body:not(.workbench) .section-fold-btn {
    display: inline-flex;
    position: absolute;
    top: 0.45rem;
    right: 0.45rem;
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    border-color: transparent;
    font-size: 1.2rem;
    transition: transform 0.15s;
}

body:not(.workbench) .braking-section .section-subheading .panel-title {
    padding-right: 36px;
    cursor: pointer;
}

body:not(.workbench) .braking-section:not(.is-folded) .section-fold-btn {
    transform: rotate(180deg);
}

body:not(.workbench) .braking-section.is-folded > :not(.section-subheading):not(.section-fold-btn) {
    display: none;
}

body:not(.workbench) .braking-section.is-folded .section-subheading > :not(.panel-title) {
    display: none;
}

/* ─── Coach: selector de referencia y consistencia ──────────────────────────── */
.coach-mode-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.coach-mode-bar button {
    padding: 5px 10px;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: var(--panel-alt);
    color: var(--text);
    font-size: 0.78rem;
    cursor: pointer;
}

.coach-mode-bar button.is-active {
    background: var(--accent);
    border-color: var(--accent);
    color: #0d0f14;
    font-weight: 600;
}

.coach-consistency-summary {
    justify-content: flex-start;
    flex-wrap: wrap;
    margin: 8px 0;
}

.coach-consistency-row {
    cursor: default;
}

.coach-consistency-bar {
    display: block;
    height: 5px;
    margin-top: 5px;
    border-radius: 3px;
    background: var(--border);
    overflow: hidden;
}

.coach-consistency-bar i {
    display: block;
    height: 100%;
    background: var(--accent);
}

/* Número de zona del Coach sobre el mapa */
.coach-zone-marker {
    width: 22px;
    height: 22px;
    padding: 0;
    border-radius: 50%;
    border: 2px solid #ffffff;
    background: #ff8a30;
    color: #14171d;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.coach-zone-marker.is-selected {
    width: 28px;
    height: 28px;
    line-height: 24px;
    font-size: 13px;
    background: #ffffff;
    border-color: #ff8a30;
}

.coach-consistency-row.is-selected {
    border-color: var(--accent);
}

/* Coach: barra de progreso indeterminada mientras se calcula */
.coach-progress {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.coach-progress p {
    margin: 0;
}

.coach-progress-bar {
    position: relative;
    height: 4px;
    border-radius: 2px;
    background: var(--border);
    overflow: hidden;
}

.coach-progress-bar i {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 35%;
    border-radius: 2px;
    background: var(--accent);
    animation: coach-progress-slide 1.2s ease-in-out infinite;
}

@keyframes coach-progress-slide {
    0% { left: -35%; }
    100% { left: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    .coach-progress-bar i {
        animation: none;
        left: 0;
        width: 100%;
        opacity: 0.5;
    }
}

/* Páginas legales (privacidad, aviso legal, términos) y pie con enlaces */
.legal-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.4rem 1rem;
    margin-top: 1.25rem;
    color: var(--muted);
    font-size: 0.8rem;
}
.legal-footer nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.4rem 1rem;
}
.legal-footer a,
.settings-legal-links a {
    color: var(--muted);
    text-decoration: none;
}
.legal-footer a:hover,
.settings-legal-links a:hover {
    color: var(--accent-strong);
    text-decoration: underline;
}
.settings-legal-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1rem;
    margin-top: 0.75rem;
    font-size: 0.8rem;
}

.legal-body {
    background:
        radial-gradient(1100px 600px at 50% -10%, rgba(255, 122, 24, 0.12), transparent 60%),
        var(--bg);
    color: var(--text);
    min-height: 100vh;
    padding: 1.5rem 16px 2rem;
}
.legal-wrap {
    max-width: 760px;
    margin: 0 auto;
}
.legal-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.legal-home img {
    display: block;
    height: 36px;
    width: auto;
}
.legal-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}
.legal-tabs a {
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.85rem;
    text-decoration: none;
}
.legal-tabs a[aria-current="page"] {
    color: var(--text);
    background: var(--accent-soft);
    border-color: rgba(255, 122, 24, 0.45);
}
.legal-draft {
    margin: 0 0 1rem;
    padding: 0.7rem 0.9rem;
    border: 1px solid rgba(255, 194, 77, 0.4);
    border-radius: 10px;
    background: rgba(255, 194, 77, 0.08);
    color: var(--warning);
    font-size: 0.85rem;
    line-height: 1.5;
}
.legal-doc {
    background: linear-gradient(160deg, var(--panel), #0e1015);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.75rem 1.5rem;
    line-height: 1.65;
}
.legal-doc h1 {
    margin: 0 0 0.25rem;
    font-size: 1.6rem;
}
.legal-doc h2 {
    margin: 1.75rem 0 0.5rem;
    font-size: 1.05rem;
    color: var(--accent-strong);
}
.legal-doc p,
.legal-doc li {
    color: #d5d9e4;
    font-size: 0.95rem;
}
.legal-doc p {
    margin: 0.5rem 0;
}
.legal-doc ul {
    margin: 0.5rem 0;
    padding-left: 1.2rem;
}
.legal-doc a {
    color: var(--accent-strong);
}
.legal-updated {
    color: var(--muted) !important;
    font-size: 0.8rem !important;
}
.legal-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.5rem 0;
    font-size: 0.9rem;
}
.legal-table th,
.legal-table td {
    padding: 0.55rem 0.6rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}
.legal-table th {
    color: var(--muted);
    font-weight: 600;
}
@media (max-width: 520px) {
    .legal-doc { padding: 1.25rem 1rem; }
}

/* Pantalla de acceso con enlace de un solo uso */
.login-hint {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.5;
}
.login-hint strong {
    color: var(--text);
}
.login-hint-block {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.login-link-btn {
    display: block;
    text-align: center;
    text-decoration: none;
}

/* Coach de consistencia: foco, tarjetas por zona y regla de vueltas */
.coach-focus {
    margin: 8px 0;
    padding: 10px 12px;
    border: 1px solid rgba(96, 165, 250, 0.4);
    border-radius: 10px;
    background: rgba(96, 165, 250, 0.14);
}

.coach-focus .coach-diagnostic-kicker {
    color: #8ec0ff;
}

.coach-focus p {
    margin: 4px 0 0;
    color: var(--text);
    font-size: 0.82rem;
    line-height: 1.5;
}

.coach-zone-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 8px 0;
}

.coach-zone {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--panel-alt);
}

.coach-zone {
    cursor: pointer;
}

.coach-zone:hover {
    border-color: rgba(255, 122, 24, 0.5);
}

.coach-zone.is-selected {
    border-color: var(--accent);
}

.coach-zone-head {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin: 0 0 8px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.coach-zone-head .coach-opportunity-rank {
    background: rgba(255, 194, 77, 0.16);
    color: var(--warning);
}

.coach-zone-head strong {
    flex: 1;
    font-size: 0.85rem;
}

.coach-zone-head b {
    color: var(--success);
    font-size: 0.85rem;
}

.coach-zone-phases {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin: 0 0 8px;
}

.coach-zone-phases div {
    padding: 5px 7px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--muted);
    font-size: 0.68rem;
}

.coach-zone-phases b {
    display: block;
    color: var(--text);
    font-size: 0.72rem;
    font-weight: 600;
}

.coach-zone-phases .is-main {
    border-color: rgba(255, 194, 77, 0.5);
    background: rgba(255, 194, 77, 0.1);
    color: var(--warning);
}

.coach-zone-phases .is-main b {
    color: var(--warning);
}

.coach-zone-problem {
    margin: 0 0 6px;
    color: var(--muted);
    font-size: 0.76rem;
    line-height: 1.5;
}

.coach-zone-action {
    display: flex;
    gap: 6px;
    margin: 0 0 8px;
    padding: 7px 9px;
    border-radius: 8px;
    background: rgba(37, 199, 154, 0.12);
    color: var(--success);
    font-size: 0.76rem;
    line-height: 1.5;
}

.coach-zone-action i {
    flex: none;
    margin-top: 1px;
}

.coach-ruler {
    position: relative;
    height: 34px;
    margin: 4px 8px 0;
}

.coach-ruler-axis {
    position: absolute;
    top: 13px;
    right: 0;
    left: 0;
    height: 2px;
    background: var(--border);
}

.coach-ruler-dot {
    position: absolute;
    top: 8px;
    width: 12px;
    height: 12px;
    margin-left: -6px;
    border-radius: 50%;
    background: var(--muted);
}

.coach-ruler-dot.is-slow {
    background: var(--danger);
}

.coach-ruler-dot.is-best {
    top: 6px;
    width: 16px;
    height: 16px;
    margin-left: -8px;
    background: var(--success);
}

.coach-ruler-best {
    position: absolute;
    top: 22px;
    transform: translateX(-50%);
    color: var(--success);
    font-size: 0.66rem;
    white-space: nowrap;
}

.coach-ruler-scale {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin: 0 8px;
    color: var(--muted);
    font-size: 0.64rem;
}

.coach-zone-more {
    margin: 8px 0;
    border: 1px dashed var(--border);
    border-radius: 10px;
    color: var(--muted);
    font-size: 0.76rem;
}

.coach-zone-more summary {
    padding: 8px 12px;
    cursor: pointer;
}

.coach-zone-mini-list {
    display: flex;
    flex-direction: column;
    padding: 0 6px 6px;
}

.coach-zone-mini {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.coach-zone-mini span:nth-child(2) {
    flex: 1;
}

.coach-zone-mini b {
    color: var(--success);
}

.coach-zone-mini.is-selected,
.coach-zone-mini:hover {
    background: var(--accent-soft);
}

/* Verificación en dos pasos (login_2fa.html) */
.login-help {
    margin: 0;
    color: var(--text-muted, var(--text));
    font-size: 0.92rem;
    line-height: 1.4;
}

.totp-qr {
    display: flex;
    justify-content: center;
}

.totp-qr svg {
    width: 200px;
    height: 200px;
    background: #fff;
    border-radius: 8px;
}

.totp-secret {
    margin: 0;
    text-align: center;
}

.totp-secret code {
    font-size: 1rem;
    letter-spacing: 0.06em;
    word-break: break-all;
    user-select: all;
}

/* Dispositivos: el token ya no es editable (solo se guarda su hash) */
.token-field-readonly {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-family: var(--font-mono, monospace);
    font-size: 0.85rem;
    color: var(--text-muted, var(--text));
    padding: 0 0.5rem;
}

.token-weak-badge {
    font-family: inherit;
    font-size: 0.72rem;
    color: var(--danger);
    border: 1px solid var(--danger);
    border-radius: 999px;
    padding: 0 0.4rem;
}

.login-help a {
    color: var(--accent, #ff8a2a);
}

/* Coach: progreso por zona entre sesiones (C2/C12) */
.coach-progress {
    display: grid;
    gap: 0.4rem;
    margin: 0.75rem 0;
}

.coach-progress-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.4rem;
}

.coach-progress-item {
    display: grid;
    grid-template-columns: 1.4rem 1fr;
    gap: 0.5rem;
    align-items: start;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
}

.coach-progress-item > i {
    font-size: 1.2rem;
    line-height: 1.2;
}

.coach-progress-item.is-better > i { color: var(--success, #3ecf8e); }
.coach-progress-item.is-worse > i { color: var(--danger); }
.coach-progress-item.is-same > i { color: var(--text-muted, var(--text)); }

.coach-progress-item strong {
    font-size: 0.85rem;
}

.coach-progress-item p {
    margin: 0.15rem 0;
    font-size: 0.82rem;
    line-height: 1.45;
}

.coach-progress-item small {
    display: block;
    color: var(--text-muted, var(--text));
    font-size: 0.76rem;
    line-height: 1.4;
}

.coach-zone-trend {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-top: 0.4rem;
    font-size: 0.82rem;
    color: var(--text-muted, var(--text));
}

.coach-zone-trend svg {
    flex: 0 0 auto;
    max-width: 100%;
}

.coach-zone-trend path {
    fill: none;
    stroke: var(--accent);
    stroke-width: 1.6;
}

.coach-zone-trend circle {
    fill: var(--accent);
}
