/* ==========================================================================
   APNEA CONTROL CENTER - STREAMER DASHBOARD (Rediseno)
   ========================================================================== */

:root {
    --bg-primary: #070811;
    --bg-topbar:  #0c0d1a;
    --bg-panel:   #101224;
    --bg-card:    #15182f;
    --bg-card-hover: #1c2040;
    --bg-input:   #0a0b18;

    --border-subtle:  rgba(255,255,255,0.08);
    --border-default: rgba(255,255,255,0.14);
    --border-accent:  rgba(0,229,255,0.4);

    --accent-cyan:       #00e5ff;
    --accent-cyan-dim:   rgba(0,229,255,0.12);
    --accent-yellow:     #ffd60a;
    --accent-yellow-dim: rgba(255,214,10,0.15);
    --accent-red:        #ff2d55;
    --accent-red-dim:    rgba(255,45,85,0.15);
    --accent-green:      #00e676;
    --accent-green-dim:  rgba(0,230,118,0.15);

    --text-primary:   #ffffff;
    --text-secondary: #c5c9ea;
    --text-muted:     #8e94be;

    --font-ui:   'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Courier New', monospace;

    --topbar-height: 64px;
    --tabs-height:   44px;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-ui);
    display: flex;
    flex-direction: column;
    user-select: none;
}

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-cyan); }

/* ==========================================================================
   TOPBAR
   ========================================================================== */
.streamer-topbar {
    height: var(--topbar-height);
    background: var(--bg-topbar);
    border-bottom: 1px solid var(--border-default);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 16px;
    flex-shrink: 0;
    z-index: 30;
}

/* Marca */
.topbar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.live-dot-pulse {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent-red);
    box-shadow: 0 0 10px var(--accent-red);
    animation: livePulse 1.8s infinite;
    flex-shrink: 0;
}

@keyframes livePulse {
    0%   { transform: scale(0.95); opacity: 0.8; }
    50%  { transform: scale(1.25); opacity: 1; box-shadow: 0 0 14px var(--accent-red); }
    100% { transform: scale(0.95); opacity: 0.8; }
}

.brand-text {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 900;
    color: #fff;
    letter-spacing: 0.08em;
    white-space: nowrap;
}

/* Sesion */
.topbar-session {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
}

.session-dropdown {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    color: #fff;
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 700;
    padding: 5px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    outline: none;
    max-width: 260px;
    min-width: 130px;
}

.session-dropdown:focus { border-color: var(--accent-cyan); }

.session-discs-wrap {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.session-disc-badge {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: var(--radius-sm);
    background: var(--accent-cyan-dim);
    color: var(--accent-cyan);
    border: 1px solid rgba(0,229,255,0.3);
    white-space: nowrap;
    flex-shrink: 0;
}

.session-counts {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* Grupo OT y Reloj Oficial en una sola línea horizontal */
.topbar-live-time-group {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0,0,0,0.35);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 5px 12px;
    white-space: nowrap;
    flex-shrink: 0;
    margin-left: auto;
}

.topbar-ot-target {
    font-family: var(--font-mono);
    font-size: 15px;
    font-weight: 900;
    color: #ffffff;
    letter-spacing: 0.03em;
}

.topbar-pipe {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--border-default);
    opacity: 0.5;
}

.countdown-value {
    font-family: var(--font-mono);
    font-size: 16px;
    font-weight: 900;
    color: var(--accent-cyan);
    letter-spacing: 0.04em;
    line-height: 1;
    transition: color 0.3s;
}

.countdown-value.warn  { color: var(--accent-yellow); }
.countdown-value.over  { color: var(--accent-red); }

.clock-value.official-clock {
    font-family: var(--font-mono);
    font-size: 16px;
    font-weight: 900;
    color: var(--accent-green);
    letter-spacing: 0.04em;
    line-height: 1;
    margin-left: 14px;
}

.topbar-sse-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--accent-green-dim);
    border: 1px solid rgba(0,230,118,0.3);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.topbar-sse-badge .sse-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--accent-green);
    box-shadow: 0 0 6px var(--accent-green);
}

.topbar-sse-badge .sse-label {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 800;
    color: var(--accent-green);
}

.topbar-sse-badge.disconnected { background: var(--accent-red-dim); border-color: var(--accent-red); }
.topbar-sse-badge.disconnected .sse-dot { background: var(--accent-red); box-shadow: none; }
.topbar-sse-badge.disconnected .sse-label { color: var(--accent-red); }

/* ==========================================================================
   TABS
   ========================================================================== */
.streamer-tabs-bar {
    height: var(--tabs-height);
    background: var(--bg-topbar);
    border-bottom: 1px solid var(--border-default);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    gap: 8px;
    flex-shrink: 0;
    z-index: 20;
}

.streamer-tabs-left {
    display: flex;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
}
.streamer-tabs-left::-webkit-scrollbar { display: none; }

.tab-install-btn {
    background: rgba(0, 229, 255, 0.12);
    border: 1px solid rgba(0, 229, 255, 0.35);
    color: var(--accent-cyan);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 800;
    font-family: var(--font-mono, monospace);
    cursor: pointer;
    transition: all 0.15s;
    height: 28px;
    flex-shrink: 0;
    margin-left: auto;
}

.tab-install-btn:hover {
    background: var(--accent-cyan);
    color: #000;
    border-color: var(--accent-cyan);
}

@media (max-width: 520px) {
    .tab-install-btn .tab-install-label {
        display: none;
    }
    .tab-install-btn {
        padding: 4px 8px;
    }
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: all 0.15s;
    height: 32px;
}

.tab-btn .tab-num {
    background: rgba(255,255,255,0.08);
    font-family: var(--font-mono);
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 3px;
}

.tab-btn:hover { color: #fff; background: rgba(255,255,255,0.05); }

.tab-btn.active {
    color: var(--accent-cyan);
    background: var(--accent-cyan-dim);
    border-bottom: 2px solid var(--accent-cyan);
}

.tab-btn.active .tab-num {
    background: var(--accent-cyan);
    color: #000;
}

/* ==========================================================================
   CONTENEDOR DE VISTAS
   ========================================================================== */
.streamer-views {
    flex: 1;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.streamer-view {
    display: none;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    min-height: 0;
}

.streamer-view.active { display: flex; }

/* ==========================================================================
   TAB 1: HEAT ACTUAL (3 bloques: prev / actual / next)
   ========================================================================== */
.heat-trio-wrap {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 14px 16px;
    display: flex;
    gap: 14px;
    align-items: flex-start;
    min-height: 0;
}

/* Bloque de un heat */
.heat-block {
    flex: 1;
    min-width: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow: hidden;
}

.heat-block.is-current {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 20px rgba(0,229,255,0.18);
}

.heat-block.is-prev,
.heat-block.is-next {
    opacity: 0.75;
}

.heat-block-header {
    background: rgba(0,0,0,0.35);
    padding: 8px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-subtle);
}

.heat-block-ot {
    font-family: var(--font-mono);
    font-size: 15px;
    font-weight: 900;
    color: #fff;
}

.heat-block-tag {
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.08);
    color: var(--text-secondary);
    letter-spacing: 0.04em;
}

.heat-block.is-current .heat-block-tag {
    background: var(--accent-cyan);
    color: #000;
}

.heat-block-lanes {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Card de carril dentro del heat block */
.lane-card-item {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-subtle);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    cursor: pointer;
    transition: background 0.15s;
    position: relative;
}

.lane-card-item:last-child { border-bottom: none; }

.lane-card-item:hover { background: var(--bg-card-hover); }

.lane-card-item.performing {
    border-left: 3px solid var(--accent-cyan);
    box-shadow: inset 0 0 12px rgba(0,229,255,0.08);
}

.lane-card-item.sp-active {
    border-left: 3px solid var(--accent-yellow);
    box-shadow: inset 0 0 12px rgba(255,214,10,0.08);
}

.lane-card-item.judging {
    border-left: 3px solid var(--accent-yellow);
}

.lane-card-item.judged {
    border-left: 3px solid rgba(0,230,118,0.6);
}

.lane-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.lane-title-pill {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 900;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 6px;
}

.lane-disc-tag {
    font-size: 9px;
    font-weight: 800;
    padding: 2px 5px;
    border-radius: 3px;
    background: var(--accent-cyan-dim);
    color: var(--accent-cyan);
    border: 1px solid rgba(0,229,255,0.25);
}

.attempt-status-badge {
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 900;
    padding: 3px 7px;
    border-radius: 3px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
}

.attempt-status-badge.pending   { background: rgba(255,255,255,0.08); color: var(--text-secondary); border: 1px solid rgba(255,255,255,0.15); }
.attempt-status-badge.performing { background: rgba(0,229,255,0.18); color: var(--accent-cyan); border: 1px solid var(--accent-cyan); animation: statusPulse 1.2s infinite alternate; }
.attempt-status-badge.sp-active { background: rgba(255,214,10,0.22); color: var(--accent-yellow); border: 1px solid var(--accent-yellow); animation: statusPulse 0.8s infinite alternate; }
.attempt-status-badge.judging   { background: rgba(255,214,10,0.15); color: var(--accent-yellow); border: 1px solid rgba(255,214,10,0.4); }
.attempt-status-badge.judged    { background: var(--accent-green-dim); color: var(--accent-green); border: 1px solid rgba(0,230,118,0.4); }
.attempt-status-badge.dns       { background: rgba(0,176,255,0.18); color: #00b0ff; border: 1px solid #00b0ff; }
.attempt-status-badge.dq        { background: var(--accent-red-dim); color: var(--accent-red); border: 1px solid var(--accent-red); }

@keyframes statusPulse {
    from { opacity: 0.65; }
    to   { opacity: 1; }
}

.lane-athlete-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.lane-athlete-name {
    font-size: 14px;
    font-weight: 800;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.15s;
}

.lane-card-item:hover .lane-athlete-name { color: var(--accent-cyan); }

.badge-country {
    background: rgba(255,255,255,0.1);
    color: #fff;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 3px;
    flex-shrink: 0;
    white-space: nowrap;
}

.lane-metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1.2fr 1fr;
    background: rgba(0,0,0,0.3);
    border-radius: var(--radius-sm);
    padding: 7px 10px;
    gap: 6px;
    border: 1px solid var(--border-subtle);
}

.l-metric { display: flex; flex-direction: column; gap: 2px; }

.l-label {
    font-size: 9px;
    font-family: var(--font-mono);
    font-weight: 800;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.l-val {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 900;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.l-val.ap-color       { color: var(--accent-yellow); }
.l-val.ep-color       { color: var(--text-secondary); }
.l-val.ep-performing  { color: var(--accent-cyan); }
.l-val.judged-color   { color: var(--accent-green); }

.lane-card-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 22px;
}

/* Espacio reservado fijo para tarjeta */
.lane-footer-card {
    width: 76px;
    min-width: 76px;
    height: 20px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
}

/* Espacio reservado para puntos a la derecha */
.lane-footer-points {
    min-width: 68px;
    height: 20px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    margin-left: auto;
}

.lane-points-badge {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 900;
    color: var(--accent-cyan);
    background: var(--accent-cyan-dim);
    padding: 2px 7px;
    border-radius: 3px;
    border: 1px solid rgba(0,229,255,0.25);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 68px;
    box-sizing: border-box;
    white-space: nowrap;
}

.card-tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 76px;
    box-sizing: border-box;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 900;
    padding: 3px 0;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: center;
}

.card-tag.white { background: #fff; color: #000; }
.card-tag.yellow { background: var(--accent-yellow); color: #000; }
.card-tag.red   { background: var(--accent-red); color: #fff; }
.card-tag.dns   { background: rgba(0,176,255,0.2); color: #00b0ff; border: 1px solid #00b0ff; }

/* Contenedor de notas y penalizaciones */
.lane-notes-wrap { display: flex; flex-wrap: wrap; gap: 4px; }

/* En el footer del carril ocupa el espacio central alineado a la izquierda */
.lane-card-footer .lane-notes-wrap {
    flex: 1;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    min-width: 0;
}

.note-chip-mini {
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 2px;
    background: rgba(255,45,85,0.2);
    color: #ff99b3;
    border: 1px solid rgba(255,45,85,0.4);
}

/* Placeholder cuando no hay heat */
.heat-empty-block {
    flex: 1;
    background: var(--bg-panel);
    border: 1px dashed var(--border-subtle);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 11px;
    opacity: 0.5;
    min-height: 80px;
}

/* ==========================================================================
   TOOLBAR COMUN
   ========================================================================== */
.view-toolbar {
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-subtle);
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.toolbar-right { display: flex; align-items: center; }

.toolbar-label {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 800;
    color: var(--accent-cyan);
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.filter-chip-group {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}

.filter-chip, .sort-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    padding: 4px 10px;
    border-radius: 14px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.filter-chip:hover, .sort-btn:hover {
    color: #fff;
    border-color: var(--accent-cyan);
}

.filter-chip.active, .sort-btn.active {
    background: var(--accent-cyan-dim);
    color: var(--accent-cyan);
    border-color: var(--accent-cyan);
    font-weight: 800;
}

/* Toggles de sexo en Overall y Results (M/F) */
.gender-toggle,
.results-gender-toggle {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
    padding: 4px 12px;
    border-radius: 14px;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.gender-toggle[data-gender="M"].active,
.results-gender-toggle[data-gender="M"].active {
    background: var(--accent-cyan-dim);
    color: var(--accent-cyan);
    border-color: var(--accent-cyan);
}

.gender-toggle[data-gender="F"].active,
.results-gender-toggle[data-gender="F"].active {
    background: var(--accent-yellow-dim);
    color: var(--accent-yellow);
    border-color: var(--accent-yellow);
}

.results-gender-toggle[data-gender="ALL"].active {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.4);
}

.sort-dir-icon { font-size: 8px; opacity: 0.8; }

.search-input {
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    color: #fff;
    font-size: 12px;
    width: 220px;
    outline: none;
    transition: border-color 0.15s;
}

.search-input:focus { border-color: var(--accent-cyan); }

/* ==========================================================================
   TABLAS
   ========================================================================== */
.table-scroll-wrap {
    flex: 1;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    text-align: left;
}

.data-table th {
    background: #0b0c1c;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.06em;
    padding: 9px 10px;
    border-bottom: 1px solid var(--border-default);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 5;
}

.data-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    vertical-align: middle;
    white-space: nowrap;
}

.data-table tbody tr:hover { background: rgba(0,229,255,0.05); }

.data-table tbody tr.heat-sep-row td {
    border-top: 2px solid rgba(255,255,255,0.2) !important;
}

tr.row-performing { background: rgba(0,229,255,0.08) !important; border-left: 3px solid var(--accent-cyan); }
tr.row-sp-active  { background: rgba(255,214,10,0.08) !important; border-left: 3px solid var(--accent-yellow); }
tr.row-judging    { background: rgba(255,214,10,0.04) !important; border-left: 3px solid var(--accent-yellow); }
tr.row-judged     { border-left: 3px solid var(--accent-green); }
tr.row-dns        { opacity: 0.5; border-left: 3px solid #00b0ff; }
tr.row-dq         { border-left: 3px solid var(--accent-red); }

.athlete-click-name {
    font-weight: 800;
    color: #fff;
    cursor: pointer;
    transition: color 0.15s;
}

.athlete-click-name:hover { color: var(--accent-cyan); }

.rp-highlight {
    font-family: var(--font-mono);
    font-weight: 900;
    font-size: 12px;
    color: var(--accent-green);
}

.rank-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 800;
    background: rgba(255,255,255,0.06);
    color: var(--text-secondary);
}

.rank-pill.gold   { background: linear-gradient(135deg,#ffd700,#ffae00); color: #000; }
.rank-pill.silver { background: linear-gradient(135deg,#f0f0f0,#a0a0a0); color: #000; }
.rank-pill.bronze { background: linear-gradient(135deg,#e69138,#a64d79); color: #fff; }

.points-bold {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 900;
    color: var(--accent-cyan);
}

.th-sortable { cursor: pointer; user-select: none; transition: color 0.15s; }
.th-sortable:hover { color: var(--accent-cyan) !important; }
.th-sort-icon { font-size: 9px; margin-left: 4px; opacity: 0.5; }
.th-sortable.active-sort { color: var(--accent-cyan) !important; }
.th-sortable.active-sort .th-sort-icon { opacity: 1; }

/* ==========================================================================
   MODAL DE ATLETA
   ========================================================================== */
.athlete-modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(7,8,17,0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 200;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: max(20px, 4vh) 16px 24px;
    overflow-y: auto;
    animation: modalFadeIn 0.18s ease;
}

.athlete-modal-overlay.open { display: flex; }

@keyframes modalFadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.athlete-modal-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    width: 760px;
    max-width: calc(100vw - 32px);
    height: clamp(520px, 82vh, 760px);
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.7);
    flex-shrink: 0;
}

/* Barra superior del modal */
.modal-top-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
    background: var(--bg-topbar);
}

.modal-nav-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-modal-nav {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.15s;
    min-height: 34px;
}

.btn-modal-nav:hover {
    color: var(--accent-cyan);
    border-color: var(--accent-cyan);
    background: var(--bg-card-hover);
}

.modal-nav-counter {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    padding: 0 4px;
}

.modal-btn-close {
    background: rgba(255,255,255,0.08);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.modal-btn-close:hover {
    background: var(--accent-red);
    border-color: var(--accent-red);
    color: #fff;
}

/* Cabecera de atleta en modal */
.modal-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
    background: rgba(0,0,0,0.2);
}

.modal-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-cyan), #0077ff);
    color: #000;
    font-family: var(--font-mono);
    font-size: 18px;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 16px rgba(0,229,255,0.3);
    flex-shrink: 0;
}

.modal-header-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.modal-tags {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
}

.badge-gender {
    background: var(--accent-cyan-dim);
    color: var(--accent-cyan);
    border: 1px solid rgba(0,229,255,0.3);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 3px;
}

.badge-category {
    background: rgba(255,255,255,0.08);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 3px;
}

.modal-name {
    font-size: 20px;
    font-weight: 900;
    color: #fff;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.modal-kpi-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.modal-kpi-pill {
    background: rgba(0,0,0,0.35);
    border: 1px solid var(--border-default);
    padding: 5px 11px;
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 84px;
    box-sizing: border-box;
}

.kpi-label {
    font-family: var(--font-mono);
    font-size: 8px;
    font-weight: 800;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

.kpi-val {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 900;
    color: var(--accent-cyan);
    font-variant-numeric: tabular-nums;
}

/* Tabs de navegación en modal de atleta */
.modal-tabs-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 20px;
    background: rgba(0, 0, 0, 0.35);
    border-bottom: 1px solid var(--border-default);
    flex-shrink: 0;
}

.modal-tab-btn {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.05em;
    padding: 9px 16px;
    cursor: pointer;
    transition: all 0.15s ease;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.modal-tab-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.modal-tab-btn.active {
    color: var(--accent-cyan);
    border-bottom-color: var(--accent-cyan);
    background: var(--accent-cyan-dim);
}

.modal-tab-pane {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex-shrink: 0;
}

/* Cuerpo scrollable del modal manteniendo encabezado y tabs fijos */
.modal-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.modal-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

.modal-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title-tag {
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 900;
    background: var(--accent-cyan-dim);
    color: var(--accent-cyan);
    padding: 2px 6px;
    border-radius: 2px;
}

.modal-section h3 {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 800;
    color: #fff;
    letter-spacing: 0.05em;
}

.modal-table-wrap {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Estilos de pestaña Notas */
.notes-header-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.btn-add-note {
    background: var(--accent-cyan-dim);
    border: 1px solid rgba(0, 229, 255, 0.35);
    color: var(--accent-cyan);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 800;
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-add-note:hover {
    background: var(--accent-cyan);
    color: #000;
}

.notes-add-panel {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.note-textarea {
    width: 100%;
    box-sizing: border-box;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: #fff;
    font-family: var(--font-sans, sans-serif);
    font-size: 13px;
    line-height: 1.5;
    padding: 8px 10px;
    resize: vertical;
    min-height: 64px;
    outline: none;
    transition: border-color 0.15s;
}

.note-textarea:focus {
    border-color: var(--accent-cyan);
}

.notes-add-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.btn-note-cancel {
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
}

.btn-note-cancel:hover {
    color: #fff;
    border-color: var(--border-default);
}

.btn-note-save {
    background: var(--accent-cyan);
    border: none;
    color: #000;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 900;
    padding: 5px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: opacity 0.15s;
}

.btn-note-save:hover {
    opacity: 0.9;
}

.modal-notes-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.athlete-note-card {
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    transition: border-color 0.15s;
}

.athlete-note-card:hover {
    border-color: rgba(255, 255, 255, 0.15);
}

.athlete-note-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.athlete-note-text {
    font-size: 13px;
    color: #f1f5f9;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
}

.athlete-note-date {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
}

.btn-delete-note {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    width: 26px;
    height: 26px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
    transition: all 0.15s;
}

.btn-delete-note:hover {
    background: rgba(255, 45, 85, 0.15);
    color: var(--accent-red);
    border-color: rgba(255, 45, 85, 0.35);
}

.modal-notes-empty {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
    padding: 16px;
    text-align: center;
    background: rgba(0, 0, 0, 0.15);
    border-radius: var(--radius-sm);
    border: 1px dashed var(--border-subtle);
}

/* Timeline juez */
.judge-timeline {
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    max-height: 140px;
    overflow-y: auto;
}

.timeline-entry {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 11px;
    padding: 3px 6px;
    background: rgba(255,255,255,0.03);
    border-radius: 3px;
}

/* ==========================================================================
   RESPONSIVIDAD
   ========================================================================== */

/* Escritorio estrecho */
@media (max-width: 1024px) {
    .heat-trio-wrap {
        padding: 12px;
        gap: 10px;
    }
    .search-input { width: 180px; }
}

/* Tablet */
@media (max-width: 768px) {
    :root {
        --topbar-height: 56px;
        --tabs-height:   40px;
    }

    .streamer-topbar {
        padding: 0 10px;
        gap: 8px;
    }

    /* SSE solo dot */
    .sse-label { display: none; }

    /* Sesión y tiempo en línea horizontal compacta */
    .session-dropdown { font-size: 12px; max-width: 170px; }
    .session-counts { font-size: 12px; }

    .topbar-live-time-group { padding: 4px 8px; gap: 6px; }
    .topbar-ot-target { font-size: 13px; }
    .countdown-value { font-size: 14px; }
    .clock-value.official-clock { font-size: 14px; margin-left: 8px; }

    /* Tabs compactos */
    .streamer-tabs-bar { padding: 0 8px; gap: 2px; }
    .tab-btn { padding: 6px 10px; font-size: 11px; }
    .tab-btn .tab-num { display: none; }

    /* Heat trio: apilado vertical, cada bloque muestra todo su contenido */
    .heat-trio-wrap {
        flex-direction: column;
        align-items: stretch;
        padding: 10px;
        gap: 12px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        min-height: 0;
        height: 100%;
    }

    /* En movil los bloques NO se dividen la altura — se muestran completos con todos sus carriles */
    .heat-block {
        flex: 0 0 auto;
        width: 100%;
        overflow: visible;
    }

    /* Ocultar bloque placeholder vacio en movil para que el heat actual aparezca arriba de todo */
    .heat-empty-block {
        display: none;
    }

    .heat-block.is-prev, .heat-block.is-next {
        opacity: 1;
    }

    /* Toolbar en columna */
    .view-toolbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding: 8px 10px;
    }

    .toolbar-right { width: 100%; }
    .search-input { width: 100%; }

    /* Modal a pantalla completa */
    .athlete-modal-overlay { padding: 0; align-items: flex-end; }
    .athlete-modal-card {
        max-width: 100%;
        height: 88vh;
        max-height: 94vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }
}

/* Movil */
@media (max-width: 480px) {
    :root { --topbar-height: 52px; }

    .streamer-topbar { padding: 0 8px; gap: 6px; }
    .brand-text { font-size: 12px; }

    .topbar-countdown-block { min-width: 80px; padding: 3px 8px; }
    .countdown-value { font-size: 15px; }

    .lane-card-item { padding: 10px 12px; gap: 6px; }
    .lane-metrics-grid { padding: 5px 8px; gap: 4px; }
    .l-val { font-size: 12px; }
    .lane-athlete-name { font-size: 13px; }

    .modal-header { padding: 12px 14px; gap: 12px; }
    .modal-avatar { width: 46px; height: 46px; font-size: 15px; }
    .modal-name { font-size: 16px; }
    .modal-body { padding: 12px 14px 20px; }

    /* Ocultar col tarjetas en overall movil */
    .col-cards { display: none; }

    .btn-modal-nav { padding: 5px 8px; font-size: 10px; min-height: 32px; }
}

/* ==========================================================================
   ANCHOS FIJOS DE COLUMNAS (evita resize por variacion de contenido)
   ========================================================================== */

.startlist-table {
    table-layout: fixed;
    min-width: 980px;
    width: 100%;
}

.results-table {
    table-layout: fixed;
    min-width: 890px;
    width: 100%;
}

.overall-table {
    table-layout: fixed;
    min-width: 650px;
    width: 100%;
}

.startlist-table td,
.results-table td,
.overall-table td {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    font-size: 12px;
}

/* Tablas de modal de atleta con anchos fijos (evita resize horizontal) */
.modal-attempts-table {
    table-layout: fixed;
    width: 100%;
    min-width: 718px;
}

.modal-attempts-table th,
.modal-attempts-table td {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    box-sizing: border-box;
    font-variant-numeric: tabular-nums;
    font-size: 11px;
    padding: 7px 6px;
}

.modal-attempts-table .col-mod-disc { width: 52px; text-align: center; }
.modal-attempts-table .col-mod-sess { width: 114px; text-align: left; }
.modal-attempts-table .col-mod-ot   { width: 60px; text-align: center; }
.modal-attempts-table .col-mod-st   { width: 100px; text-align: center; }
.modal-attempts-table .col-mod-ap   { width: 64px; text-align: right; }
.modal-attempts-table .col-mod-ep   { width: 64px; text-align: right; }
.modal-attempts-table .col-mod-rp   { width: 64px; text-align: right; }
.modal-attempts-table .col-mod-rec  { width: 56px; text-align: center; }
.modal-attempts-table .col-mod-card { width: 88px; text-align: center; }
.modal-attempts-table .col-mod-pts  { width: 56px; text-align: right; }

.modal-disciplines-table {
    table-layout: fixed;
    width: 100%;
    min-width: 580px;
}

.modal-disciplines-table th,
.modal-disciplines-table td {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    box-sizing: border-box;
    font-variant-numeric: tabular-nums;
    font-size: 12px;
    padding: 8px 10px;
}

.modal-disciplines-table .col-disc-disc { width: 80px; text-align: center; }
.modal-disciplines-table .col-disc-pos  { width: 60px; text-align: center; }
.modal-disciplines-table .col-disc-res  { width: 150px; text-align: right; }
.modal-disciplines-table .col-disc-rec  { width: 90px; text-align: center; }
.modal-disciplines-table .col-disc-card { width: 140px; text-align: center; }
.modal-disciplines-table .col-disc-pts  { width: 90px; text-align: right; }

/* Badges de récord con espacio reservado fijo */
.record-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    min-width: 38px;
    max-width: 38px;
    height: 18px;
    box-sizing: border-box;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 900;
    line-height: 1;
    border-radius: var(--radius-sm);
    letter-spacing: 0.04em;
    text-align: center;
    flex-shrink: 0;
}

.record-badge.record-wr {
    background: rgba(255, 45, 85, 0.25);
    color: #ff3b30;
    border: 1px solid #ff3b30;
}

.record-badge.record-cr {
    background: rgba(255, 204, 0, 0.2);
    color: #ffcc00;
    border: 1px solid #ffcc00;
}

.record-badge.record-nr {
    background: rgba(0, 229, 255, 0.2);
    color: var(--accent-cyan);
    border: 1px solid var(--accent-cyan);
}

.record-badge.is-empty {
    color: var(--text-muted);
    opacity: 0.25;
    background: transparent;
    border: 1px solid transparent;
}

/* ==========================================================================
   UNIFORMIDAD TIPOGRÁFICA Y EMOJIS EN OVERALL
   ========================================================================== */
.overall-table td,
.overall-table .athlete-click-name,
.overall-table .badge-country,
.overall-table .points-bold,
.overall-table .rank-pill,
.overall-table .card-mini-tally,
.overall-table .card-mini-item,
.overall-table .card-emoji {
    font-size: 12px !important;
}

.overall-table .badge-country {
    padding: 2px 6px;
    font-weight: 800;
}

.overall-table .rank-pill {
    width: 22px;
    height: 22px;
    font-weight: 800;
}

.overall-table .points-bold {
    font-weight: 900;
}

.overall-table .card-mini-tally {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-family: var(--font-mono);
    font-weight: 700;
}

.overall-table .card-mini-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.overall-table .card-emoji {
    line-height: 1;
    display: inline-block;
    vertical-align: middle;
}

/* ==========================================================================
   HEADER RESPONSIVO EN MOVIL (2 LINEAS LIMPIAS)
   ========================================================================== */
@media (max-width: 768px) {
    .streamer-topbar {
        height: auto;
        min-height: auto;
        flex-direction: column;
        align-items: stretch;
        padding: 8px 10px;
        gap: 6px;
    }

    /* Ocultar elementos adicionales */
    .topbar-brand,
    .session-counts,
    .topbar-sse-badge {
        display: none !important;
    }

    /* Linea 1: Sesion y disciplinas */
    .topbar-session {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 8px;
        flex: none;
    }

    .session-dropdown {
        flex: 1;
        max-width: none;
        min-width: 0;
        font-size: 13px;
    }

    /* Linea 2: Cuenta regresiva OT, OT y Hora Oficial */
    .topbar-live-time-group {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 8px;
        margin-left: 0;
        padding: 4px 10px;
        box-sizing: border-box;
    }

    .topbar-live-time-group .countdown-value {
        font-size: 14px;
    }

    .topbar-live-time-group .topbar-ot-target {
        font-size: 13px;
    }

    .topbar-live-time-group .clock-value.official-clock {
        margin-left: auto;
        font-size: 14px;
    }

    .btn-topbar-install {
        align-self: center;
        width: 100%;
        justify-content: center;
        padding: 6px 10px;
        font-size: 11px;
    }
}

/* ==========================================================================
   PWA INSTALLATION BANNER (OCULTABLE)
   ========================================================================== */
.pwa-install-banner {
    background: #141c2e;
    border: 1px solid rgba(0, 229, 255, 0.35);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    padding: 10px 36px 10px 14px;
    border-radius: var(--radius-sm);
    margin: 8px 16px 0 16px;
    position: relative;
    flex-shrink: 0;
    animation: bannerSlideDown 0.2s ease-out;
}

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

.btn-close-install-banner {
    position: absolute;
    top: 6px;
    right: 8px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    border-radius: 4px;
    transition: all 0.15s;
}

.btn-close-install-banner:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

/* Indicador de pull-to-refresh en movil */
.pull-refresh-indicator {
    position: fixed;
    top: -55px;
    left: 50%;
    transform: translateX(-50%);
    background: #0f1626;
    border: 1px solid var(--accent-cyan);
    color: var(--accent-cyan);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    font-family: var(--font-mono, monospace);
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 100000;
    transition: transform 0.1s ease-out, opacity 0.15s ease-out;
    pointer-events: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
    opacity: 0;
}

.pull-refresh-indicator.ready {
    background: var(--accent-cyan);
    color: #05060b;
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.5);
}

.pull-refresh-icon {
    font-size: 14px;
    transition: transform 0.15s ease-out;
    display: inline-block;
}

.pull-refresh-indicator.refreshing .pull-refresh-icon {
    animation: refreshSpin 0.7s linear infinite;
}

@keyframes refreshSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

