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

html {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden !important;
}

body {
    display: flex !important;
    flex-direction: column !important;
    height: 100vh !important;
    margin: 0 !important;
    padding: 0 !important;
    font-family: 'Segoe UI', Arial, sans-serif;
    background: #f5f5f5;
    overflow: hidden !important;
    -webkit-text-size-adjust: 100%;
}

.site-header, header {
    flex-shrink: 0 !important;
    width: 100% !important;
    z-index: 1000;
}

.tab-navigation {
    flex-shrink: 0 !important;
    display: flex;
    background: #d4d4d4;
    border-bottom: 1px solid #999;
    padding: 0 20px;
    flex-wrap: nowrap;
    align-items: flex-end;
    z-index: 999;
}

.tab-btn {
    padding: 8px 20px !important;
    font-size: 14px !important;
    background: white;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    color: #666;
    margin-right: 2px;
    border-radius: 6px 6px 0 0;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    height: 40px !important;
    transition: all 0.2s;
}

.tab-btn:hover { background: #f0f0f0; color: #333; }
.tab-btn.active {
    background: #F9FAFB !important;
    border-bottom: 3px solid #667eea;
    color: #333;
    font-weight: 600;
}

.tab-content {
    display: none;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    width: 100%;
}

.tab-content.active {
    display: block !important;
}

footer {
    flex-shrink: 0 !important;
    width: 100% !important;
    background: #1f2937 !important;
    color: #9ca3af !important;
    text-align: center !important;
    padding: 2px 2px !important;
    font-size: 12px !important;
    border-top: 1px solid #374151 !important;
    z-index: 1000;
}

.stats-wrapper {
    display: flex;
    height: 100%;
    background: white;
}

.stats-left {
    width: 40%;
    min-width: 280px;
    max-width: 500px;
    border-right: 1px solid #ddd;
    background: #f9fafb;
    padding: 15px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
}

.stats-resizer {
    width: 5px;
    background: #d4d4d4;
    cursor: col-resize;
    flex-shrink: 0;
}
.stats-resizer:hover { background: #667eea; }

.stats-right {
    flex: 1;
    min-width: 300px;
    background: white;
    position: relative;
    overflow: hidden;
}

#matchFrame { width: 100%; height: 100%; border: none; display: none; }
#matchPlaceholder {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    display: flex; align-items: center; justify-content: center;
    color: #6b7280; font-size: 16px; text-align: center; padding: 20px; flex-direction: column; gap: 10px;
}
#matchPlaceholder.active { display: flex; }
#matchPlaceholder:not(.active) { display: none; }

#matchLoader {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    display: none; flex-direction: column; align-items: center; justify-content: center;
    background: rgba(255,255,255,0.95); z-index: 10; gap: 10px;
}
#matchLoader.active { display: flex; }

.loader-spinner {
    width: 40px; height: 40px; border: 4px solid #e5e7eb; border-top: 4px solid #667eea;
    border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* ==========================================
   МОБИЛЬНАЯ ВЕРСИЯ
   ========================================== */
@media only screen and (max-width: 768px) {
    html, body {
        overflow-y: auto !important;
        height: auto !important;
    }
    
    body {
        min-height: 100vh !important;
    }
    
    .site-header, header {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        height: 52px !important;
        z-index: 1000 !important;
    }
    
    .tab-navigation {
        position: fixed !important;
        top: 52px !important;
        left: 0 !important;
        right: 0 !important;
        height: 40px !important;
        padding: 0 5px !important;
        z-index: 999 !important;
    }
    
    .tab-btn {
        padding: 6px 10px !important;
        font-size: 12px !important;
        height: 36px !important;
    }
    
    .tab-content {
        margin-top: 92px !important;
        overflow-y: auto !important;
        min-height: calc(100vh - 92px) !important;
    }
    
    body.match-loaded-mobile .tab-navigation {
        display: none !important;
    }
    body.match-loaded-mobile .tab-content {
        margin-top: 52px !important;
    }
    body.match-loaded-mobile footer {
        display: none !important;
    }
    
    #tenStatsWrapper { display: block !important; height: auto !important; }
    #tenStatsLeft { width: 100% !important; max-width: 100% !important; border-right: none; }
    #tenStatsRight { width: 100%; display: none !important; }
    
    #tenMatchesList { overflow-x: auto !important; margin: 0 6px 6px 6px; }
    .matches-table { table-layout: fixed !important; width: 100% !important; font-size: 9.5px !important; }
    
    .matches-table th:nth-child(1), .matches-table td:nth-child(1) { width: 14% !important; padding: 4px 1px !important; }
    .matches-table th:nth-child(2), .matches-table td:nth-child(2) { width: 14% !important; padding: 4px 1px !important; }
    .matches-table th:nth-child(3), .matches-table td:nth-child(3) { width: 12% !important; padding: 4px 1px !important; }
    .matches-table th:nth-child(4), .matches-table td:nth-child(4) { width: 30% !important; padding: 4px 1px !important; }
    .matches-table th:nth-child(5), .matches-table td:nth-child(5) { width: 30% !important; padding: 4px 1px !important; }

    .matches-table th { font-size: 8.5px !important; white-space: nowrap !important; }
    .matches-table td { white-space: normal !important; vertical-align: middle !important; }

    .tourney-name { max-width: 50px !important; font-size: 8.5px !important; }
    .flag-tourney { width: 20px !important; height: 14px !important; }
    .stage-badge { font-size: 8.5px !important; padding: 1px 3px !important; }
    .surface-name { font-size: 8px !important; }
    
    .player-cell { padding-left: 2px !important; white-space: normal !important; }
    .player-name { font-size: 10px !important; margin-bottom: 2px !important; line-height: 1.15 !important; word-break: break-word !important; }
    .player-meta { gap: 2px !important; flex-wrap: wrap !important; }
    .odds-badge { font-size: 9px !important; padding: 1px 3px !important; min-width: 26px !important; }
    .rank-text { font-size: 8.5px !important; }
    .tooltip-text { font-size: 9px !important; padding: 4px 6px !important; }

    body.match-loaded-mobile #tenStatsLeft { display: none !important; }
    body.match-loaded-mobile #tenStatsRight { 
        display: block !important;
        position: fixed !important;
        top: 52px !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        height: calc(100vh - 52px) !important;
        z-index: 999 !important;
        background: white !important;
    }
    body.match-loaded-mobile #tenFrame { 
        display: block !important; 
        width: 100% !important; 
        height: 100% !important;
    }
    body.match-loaded-mobile #tenPlaceholder,
    body.match-loaded-mobile #tenLoader { display: none !important; }
}

/* ==========================================
   НОВЫЙ СТИЛЬ ВКЛАДОК
   ========================================== */
:root {
    --bg: #121212;
    --card: #1e1e24;
    --text: #e0e0e0;
    --muted: #8a8a9a;
    --accent: #4caf50;
    --border: #2a2a35;
}

.tab-navigation {
    flex-shrink: 0 !important;
    display: flex;
    background: var(--card);
    padding: 0 20px;
    align-items: flex-end;
    z-index: 999;
    position: relative;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.tab-btn {
    position: relative;
    padding: 10px 24px !important;
    font-size: 14px !important;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-bottom: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-radius: 8px 8px 0 0;
    margin-right: 4px;
    margin-bottom: -1px !important;
    color: var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    height: 42px !important;
    transition: all 0.2s ease;
    z-index: 5;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

.tab-btn.active {
    background: var(--bg) !important;
    border-top: 2px solid var(--accent) !important;
    border-left: 2px solid var(--accent) !important;
    border-right: 2px solid var(--accent) !important;
    border-bottom: 2px solid var(--bg) !important;
    margin-bottom: -2px !important;
    color: var(--accent) !important;
    font-weight: 700;
    z-index: 10;
}

.tab-btn.active::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: -9999px;
    right: 100%;
    height: 2px;
    background: var(--accent);
    z-index: -1;
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 100%;
    right: -9999px;
    height: 2px;
    background: var(--accent);
    z-index: -1;
}

.tab-content {
    display: none;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    width: 100%;
    background: var(--bg);
    padding: 20px;
}

.tab-content.active {
    display: block !important;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) {
    .tab-navigation {
        padding: 0 5px !important;
        justify-content: space-around;
    }
    
    .tab-btn {
        flex: 1;
        justify-content: center;
        margin-right: 0;
        padding: 8px 4px !important;
        font-size: 12px !important;
    }
    
    .tab-content {
        padding: 10px;
    }
}