:root {
            --sidebar-bg: #1e1e2d;
            --sidebar-text: #9d9da6;
            --sidebar-active: #3699ff;
            --header-bg: #fff;
            --card-bg: #fff;
            --text-primary: #3f4254;
            --text-secondary: #7e8299;
            --success: #1bc5bd;
            --danger: #f64e60;
            --warning: #ffa800;
            --border-color: #ebedf3;
        }

/* Dark theme overrides */
.theme-dark {
    --sidebar-bg: #151522;
    --sidebar-text: #b3b7c2;
    --sidebar-active: #8ab4f8;
    --header-bg: #11131a;
    --card-bg: #161a23;
    --text-primary: #eef1f6;
    --text-secondary: #aeb4c0;
    --success: #1bc5bd;
    --danger: #ff6b6b;
    --warning: #ffc861;
    --border-color: #2a2f3a;
    background-color: #0f1117;
}

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Roboto', sans-serif;
        }

        body {
            display: flex;
            background-color: #f4f6fa;
            color: var(--text-primary);
        }
        /* Sidebar Styles */
        .sidebar {
            width: 250px;
            background-color: var(--sidebar-bg);
            color: var(--sidebar-text);
            height: 100vh;
            position: fixed;
            left: 0;
            top: 0;
            padding: 20px 0;
        }

        .logo {
            display: flex;
            align-items: center;
            padding: 0 25px 30px;
            color: #fff;
            font-size: 1.5rem;
            font-weight: 500;
        }

        .logo i {
            margin-right: 10px;
            color: var(--sidebar-active);
        }

        .nav-links {
            list-style: none;
        }

        .nav-links li a {
            display: flex;
            align-items: center;
            padding: 12px 25px;
            color: var(--sidebar-text);
            text-decoration: none;
            transition: all 0.3s;
        }

        .nav-links li a i {
            margin-right: 10px;
            width: 20px;
            text-align: center;
        }

        .nav-links li.active a,
        .nav-links li:hover a {
            color: #fff;
            background-color: rgba(255, 255, 255, 0.1);
            border-left: 3px solid var(--sidebar-active);
        }

        /* Main Content */
        .main-content {
            flex: 1;
            margin-left: 250px;
            padding: 20px 30px;
        }

        /* Top Navigation */
        .top-nav {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 16px 0;
            margin-bottom: 30px;
            border-bottom: 1px solid var(--border-color);
            position: sticky;
            top: 0;
            background: var(--header-bg);
            z-index: 10;
        }

        .top-nav h1 {
            font-size: 1.3rem;
            font-weight: 600;
            color: var(--text-primary);
            margin: 0;
        }

        .search-bar {
            position: relative;
            width: 300px;
        }

        .search-bar input {
            width: 100%;
            padding: 8px 12px 8px 36px;
            border: 1px solid var(--border-color);
            border-radius: 8px;
            font-size: 0.8rem;
            outline: none;
            transition: all 0.2s;
        }

        .search-bar input:focus {
            border-color: var(--sidebar-active);
            box-shadow: 0 0 0 3px rgba(54, 153, 255, 0.1);
        }

        .search-bar i {
            position: absolute;
            left: 15px;
            top: 50%;
            transform: translateY(-50%);
            color: var(--text-secondary);
        }

        .user-profile {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background-color: #f3f6f9;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 600;
            color: var(--text-primary);
        }

        

        /* Responsive adjustments */
        @media (max-width: 1200px) {
            .stats-container {
                grid-template-columns: repeat(2, 1fr);
            }
        }

        /* Chart Styles */
        .charts-container {
            display: grid;
            grid-template-columns: 1fr;
            gap: 20px;
            margin-bottom: 30px;
        }

        .chart-card {
            background-color: var(--card-bg);
            border-radius: 10px;
            padding: 20px;
            box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
            border: 1px solid var(--border-color);
            transition: transform 0.25s, box-shadow 0.25s;
        }

        .chart-card:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 14px rgba(0, 0, 0, 0.08);
        }

        .chart-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
        }

        .chart-header h3 {
            font-size: 1rem;
            font-weight: 600;
            color: var(--text-primary);
            margin: 0;
        }

        .channels-header h2 {
            display: flex;
            align-items: center;
            gap: 10px;
        }
        .count-badge {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            background: rgba(54, 153, 255, 0.12);
            color: var(--sidebar-active);
            border: 1px solid rgba(54, 153, 255, 0.35);
            padding: 2px 10px;
            border-radius: 999px;
            font-size: 0.8rem;
        }
        .chart-actions {
            display: flex;
            flex-direction: column;
            gap: 8px;
            max-height: 520px;
            overflow: auto;
            padding-right: 6px;
        }
        .btn {
            padding: 6px 12px;
            border: 1px solid var(--border-color);
            background: transparent;
            border-radius: 8px;
            padding: 6px 10px;
            font-size: 0.8rem;
            transition: all 0.2s;
            color: var(--text-primary);
        }

        .btn-sm {
            padding: 4px 10px;
            font-size: 0.75rem;
        }

        .btn:hover {
            transform: translateY(-1px);
        }
        .btn.active {
            background-color: var(--sidebar-active);
            color: white;
            border-color: var(--sidebar-active);
            box-shadow: 0 6px 18px rgba(54,153,255,0.35);
        }

        .chart-wrapper {
            position: relative;
            height: 400px;
            width: 100%;
        }

        @media (max-width: 1200px) {
            .stats-container,
            .charts-container,
            .user-activity-container {
                grid-template-columns: 1fr;
            }
        }
        
        .user-activity-container {
            display: grid;
            grid-template-columns: 300px 1fr; /* Colonne fixe pour la liste, le reste pour le wrapper graphique+profils */
            gap: 20px;
            margin-top: 30px;
        }

        /* Wrapper pour graphique + profils dans la colonne de droite */
        .chart-and-profiles-wrapper {
            display: flex;
            flex-direction: column;
            gap: 16px;
        }



        @media (max-width: 768px) {
            .stats-container {
                grid-template-columns: 1fr;
            }
            
            .main-content {
                margin-left: 0;
                padding: 15px;
            }
            
            .sidebar {
                transform: translateX(-100%);
                transition: transform 0.3s ease;
                z-index: 1000;
            }
            
            .sidebar.active {
                transform: translateX(0);
            }
        }
        button {
            background-color: #7289da;
            border: none;
            padding: 10px 20px;
            color: #ffffff;
            border-radius: 4px;
            cursor: pointer;
            font-weight: bold;
            transition: background-color 0.2s;
        }
        button:hover {
            background-color: #677bc4;
        }
        button:disabled {
            background-color: #4f545c;
            cursor: not-allowed;
        }
        .channels-container {
            background-color: var(--card-bg);
            padding: 20px;
            border-radius: 10px;
            margin-bottom: 20px;
            box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
            border: 1px solid var(--border-color);
        }
        .channels-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 15px;
        }
        .channels-header h2 {
            margin: 0;
            color: var(--text-primary);
            font-size: 1rem;
            font-weight: 600;
        }
        .channels-grid {
            display: flex;
            flex-direction: column;
            gap: 10px;
        }
        .channel-card {
            display: flex;
            align-items: center;
            gap: 12px;
            background-color: transparent;
            padding: 10px 12px;
            position: relative; /* For positioning the status bubble */
            border-radius: 8px;
            border: 1px solid var(--border-color);
            transition: all 0.2s;
            cursor: pointer;
            text-align: left;
            width: 100%;
        }
        .avatar-wrapper {
            position: relative;
            width: 40px;
            height: 40px;
            flex-shrink: 0;
        }
        .user-avatar {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            object-fit: cover;
        }
        .user-avatar-decoration {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 120%; /* Agrandie pour encadrer l'avatar */
            height: 120%;
            pointer-events: none; /* Allow clicks on the avatar itself */
        }
        .user-info {
            display: flex;
            flex-direction: column;
            justify-content: center;
            
            overflow: hidden; /* Pour masquer le texte du pseudo qui dépasse */
        }
        .user-nickname {
            font-size: 0.85rem;
            font-weight: 500;
            padding-right: 40px; /* Ajout d'espace pour forcer la troncature des noms longs */
            color: var(--text-primary);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis; /* Coupe le texte avec "..." par défaut */
            display: block;
        }
        .channel-card:hover .user-nickname.is-overflowing {
            overflow: visible; /* Révèle le texte complet au survol */
            animation: ping-pong-scroll 4s ease-in-out infinite;
        }
        @keyframes ping-pong-scroll {
            0%, 100% {
                transform: translateX(0);
            }
            50% {
                transform: translateX(var(--scroll-x, -20px)); /* Utilise la variable JS */
            }
        }
        .user-tag {
            font-size: 0.7rem;
            color: var(--text-secondary);
        }
        .user-status-bubble {
            position: absolute;
            top: 8px;
            right: 8px;
            width: 10px;
            height: 10px;
            background-color: var(--success); /* #1bc5bd */
            border-radius: 50%;
            border: 2px solid var(--card-bg); /* Same as card background for a nice effect */
        }
        .user-inactive-status {
            position: absolute;
            top: 8px;
            right: 12px;
            font-size: 0.7rem;
            font-style: italic;
            color: var(--text-secondary);
        }
        .channel-card:hover {
            border-color: var(--sidebar-active);
            background-color: #f0f2f5; /* Un gris clair, plus clair que le tag utilisateur */
        }
        .channel-card.selected {
            border-color: var(--sidebar-active);
            background-color: rgba(54, 153, 255, 0.12);
            box-shadow: 0 2px 8px rgba(54,153,255,0.20);
        }
        /* User Stats Card Styles */
        .stats-card {
            background-color: var(--card-bg);
            border-radius: 8px;
            padding: 20px;
            box-shadow: 0 0 15px rgba(0,0,0,0.05);
            display: flex;
            gap: 20px;
            align-items: flex-start;
        }
        .stats-card-left {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 10px;
            flex-basis: 120px;
            flex-shrink: 0;
        }
        .stats-card-avatar {
            width: 80px;
            height: 80px;
            border-radius: 50%;
        }
        .stats-card-nickname {
            font-weight: 600;
            font-size: 1.1rem;
            text-align: center;
            word-break: break-word;
        }
        .stats-card-username {
            font-size: 0.9rem;
            color: var(--text-secondary);
        }
        .stats-card-right {
            flex-grow: 1;
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 20px;
        }
        .stats-group h4 {
            margin-bottom: 10px;
            font-weight: 500;
            border-bottom: 1px solid var(--border-color);
            padding-bottom: 5px;
        }
        .stats-item, .friend-item {
            display: flex;
            justify-content: space-between;
            font-size: 0.9rem;
            padding: 4px 0;
        }
        .stats-label {
            color: var(--text-secondary);
        }
        .stats-value, .friend-time {
            font-weight: 500;
        }
        .friends-list .friend-item {
            gap: 10px;
            justify-content: flex-start;
            align-items: center;
        }
        .friend-avatar {
            width: 24px;
            height: 24px;
            border-radius: 50%;
        }
        .friend-name {
            flex-grow: 1;
        }
        .channel-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 10px;
        }
        .channel-name {
            font-weight: bold;
            color: #ffffff;
        }
        .member-count {
            background-color: #43b581;
            color: white;
            padding: 2px 8px;
            border-radius: 10px;
            font-size: 12px;
            font-weight: bold;
        }
        .channel-info {
            font-size: 12px;
            color: #99aab5;
        }
        .chart-container {
            background-color: #36393f;
            padding: 20px;
            border-radius: 8px;
            margin-bottom: 20px;
            height: 400px;
        }
        .chart-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 15px;
        }
        .chart-header h3 {
            display: flex;
            align-items: center;
            gap: 10px;
        }
        .chart-header h3::after {
            content: attr(data-sub);
            font-size: 0.85rem;
            color: var(--text-secondary);
            font-weight: 500;
        }
        .chart-header h2 {
            margin: 0;
            color: #ffffff;
        }
        .stats-container {
            background-color: #36393f;
            padding: 20px;
            border-radius: 8px;
            margin-bottom: 20px;
        }
        .stats-header h2 {
            margin: 0 0 15px 0;
            color: #ffffff;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            background-color: #2f3136;
            border-radius: 6px;
            overflow: hidden;
        }
        th, td {
            padding: 12px 15px;
            text-align: left;
            border-bottom: 1px solid #40444b;
        }
        th {
            background-color: #40444b;
            color: #ffffff;
            font-weight: bold;
        }
        td {
            color: #dcddde;
        }
        tr:hover {
            background-color: #36393f;
        }
        .loading {
            text-align: center;
            color: #99aab5;
            padding: 20px;
        }
        .error {
            background-color: #f04747;
            color: white;
            padding: 10px;
            border-radius: 4px;
            margin: 10px 0;
        }
        .success {
            background-color: #43b581;
            color: white;
            padding: 10px;
            border-radius: 4px;
            margin: 10px 0;
        }

        /* Loader Styles */
        .loader-overlay {
            position: absolute;
            top: 0;
            left: 250px; /* To not cover the sidebar */
            right: 0;
            bottom: 0;
            background: rgba(244, 246, 250, 0.8);
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 1001;
            display: none; /* Hidden by default */
        }
        .loader-spinner {
            border: 5px solid #f3f3f3;
            border-top: 5px solid var(--sidebar-active);
            border-radius: 50%;
            width: 50px;
            height: 50px;
            animation: spin 1s linear infinite;
        }
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }
/* ============================================
   MULTI-USER STATS GRID STYLES
   ============================================ */
.multi-user-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 14px;
    padding: 14px 14px 24px;
    background: transparent;
}

/* Compact user stats cards */
.user-stats-card {
    background: var(--card-bg);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
    transition: transform 0.25s, box-shadow 0.25s;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.user-stats-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.12);
    border-color: var(--sidebar-active);
}

.user-card-header {
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    /* Background will be set inline based on user's channel status */
}

.user-card-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    object-fit: cover;
}

.user-card-info {
    flex: 1;
    color: white;
}

.user-card-nickname {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0 0 2px 0;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.user-card-username {
    font-size: 0.7rem;
    opacity: 0.85;
    margin: 0;
    line-height: 1.1;
}

.bot-badge-small {
    display: inline-block;
    background: rgba(255, 255, 255, 0.25);
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.6rem;
    font-weight: 600;
    margin-top: 4px;
}

.periods-compact-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 12px;
}

.period-card-compact {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 8px;
    transition: all 0.2s;
}

.period-card-compact:hover {
    background: #e9ecef;
    transform: translateY(-2px);
}

.period-header-compact {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.period-icon-compact {
    font-size: 1rem;
}

.period-title-compact {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.period-stats-compact {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-label-compact {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-weight: 600;
}

.stat-value-compact {
    font-size: 1.1rem;
    font-weight: 700;
    color: #667eea;
}

.top-friends-compact {
    padding: 10px 14px 14px;
    border-top: 1px solid #e9ecef;
}

.top-friends-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
}

.friends-compact-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
}

.friends-compact-list::-webkit-scrollbar {
    width: 6px;
}

.friends-compact-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.friends-compact-list::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.friends-compact-list::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.friend-compact {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: #f8f9fa;
    border-radius: 6px;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

.friend-compact:has([style*="linear-gradient"]) {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transform: scale(1.02);
}

.friend-rank-compact {
    font-weight: 700;
    color: #667eea;
    min-width: 20px;
}

.friend-avatar-compact {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.friend-name-compact {
    flex: 1;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-card-footer {
    padding: 8px 12px;
    background: #f8f9fa;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: left;
    border-top: 1px solid #e9ecef;
    margin-top: auto; /* Colle le footer en bas de la carte */
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.user-card-footer i {
    margin-right: 5px;
}

.user-card-footer .last-activity {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-active {
    color: #1bc5bd;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.status-active i {
    font-size: 0.6rem;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.error-users {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 30px;
    text-align: center;
    color: var(--text-secondary);
    grid-column: 1 / -1;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
    border: 1px solid var(--border-color);
}

.error-users i {
    font-size: 2rem;
    color: #f64e60;
    margin-bottom: 15px;
    display: block;
}

.error-users p {
    margin: 0;
    font-size: 0.9rem;
}

/* Period Toggle Bar */
.period-toggle-bar {
    display: flex;
    gap: 10px;
    padding: 12px 16px;
    flex-wrap: wrap;
    background: var(--card-bg);
    border-radius: 10px;
    margin: 20px 20px 0 20px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
    border: 1px solid var(--border-color);
    position: sticky; /* Reste visible quand on scroll les cartes */
    top: 0; /* Collé au haut de son conteneur */
    z-index: 20;
}

.period-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.period-btn .icon {
    font-size: 1rem;
}

.period-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.25);
}

.period-btn:hover:not(.active) {
    background: rgba(54, 153, 255, 0.08);
    border-color: var(--sidebar-active);
    transform: translateY(-1px);
}

.period-btn:active {
    transform: translateY(0);
}

@media (max-width: 768px) {
    .period-toggle-bar {
        justify-content: center;
    }
    .period-btn {
        flex: 1 1 calc(50% - 12px);
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .multi-user-stats-grid {
        grid-template-columns: 1fr;
    }
    
    .periods-compact-grid {
        grid-template-columns: 1fr;
    }
}

/* Loading state for multi-user view */
#userStatsContainer .loading {
    text-align: center;
    padding: 30px 20px;
    color: #667eea;
    font-size: 0.9rem;
    background: var(--card-bg);
    border-radius: 10px;
    margin: 12px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
    border: 1px solid var(--border-color);
}

#userStatsContainer .loading i {
    font-size: 2.5rem;
    margin-bottom: 15px;
    display: block;
}

/* ============================================
   USER PROFILE PANEL STYLES (SINGLE VIEW - PRESERVED)
   ============================================ */
.user-profile-panel {
    margin-top: 16px;
    background: transparent;
    border-radius: 12px;
    overflow: visible;
    box-shadow: none;
    animation: slideIn 0.3s ease-out;
}

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

.profile-panel-content {
    background: white;
    margin: 3px;
    border-radius: 14px;
    overflow: hidden;
}

/* Profile Header */
.profile-header {
    position: relative;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 60px 40px 30px;
    color: white;
}

.close-profile-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    backdrop-filter: blur(10px);
}

.close-profile-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.profile-banner {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 120px;
    overflow: hidden;
}

.profile-decoration {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.3;
}

.profile-info {
    position: relative;
    display: flex;
    align-items: center;
    gap: 25px;
}

.profile-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 5px solid white;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    object-fit: cover;
}

.profile-details {
    flex: 1;
}

.profile-nickname {
    font-size: 2rem;
    font-weight: 700;
    margin: 0 0 5px 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.profile-username {
    font-size: 1.1rem;
    opacity: 0.9;
    margin: 0 0 10px 0;
}

.bot-badge {
    display: inline-block;
    background: rgba(255, 255, 255, 0.25);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 8px;
    backdrop-filter: blur(10px);
}

.bot-badge i {
    margin-right: 5px;
}

.profile-last-update {
    font-size: 0.9rem;
    opacity: 0.8;
    margin-top: 10px;
}

.profile-last-update i {
    margin-right: 5px;
}

/* Periods Grid */
.periods-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    padding: 24px;
    background: #f8f9fa;
}

.period-card {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
    transition: all 0.25s;
    border: 1px solid var(--border-color);
}

.period-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.08);
    border-color: var(--sidebar-active);
}

.period-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.period-icon {
    font-size: 1.5rem;
}

.period-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

/* Period Stats */
.period-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.stat-box {
    background: linear-gradient(135deg, #f6f8fb 0%, #f0f2f5 100%);
    padding: 14px;
    border-radius: 8px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.stat-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, #667eea, #764ba2);
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-bottom: 6px;
    display: block;
}

.stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    display: block;
}

.stat-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-secondary {
    color: #f64e60;
}

.stat-percent {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 4px;
    font-weight: 500;
}

/* Friends Section */
.friends-section {
    margin-top: 16px;
}

.friends-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    padding-left: 8px;
    border-left: 3px solid #667eea;
}

.friends-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.friend-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: transparent;
    border-radius: 8px;
    transition: all 0.2s;
    border: 1px solid var(--border-color);
}

.friend-card:hover {
    background: rgba(54, 153, 255, 0.05);
    border-color: var(--sidebar-active);
    transform: translateX(3px);
}

.friend-rank {
    font-size: 0.9rem;
    font-weight: 700;
    color: #667eea;
    min-width: 30px;
    text-align: center;
}

.friend-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.friend-info {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.friend-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.8rem;
}

.friend-time {
    font-weight: 700;
    color: #667eea;
    font-size: 0.75rem;
    padding: 3px 10px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 12px;
}

.no-friends {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
}

.no-friends i {
    font-size: 2rem;
    opacity: 0.3;
    margin-bottom: 8px;
}

.no-friends p {
    margin: 0;
    font-size: 0.8rem;
}

/* Responsive Design */
@media (max-width: 1400px) {
    .periods-grid {
        grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    }
}

@media (max-width: 768px) {
    .periods-grid {
        grid-template-columns: 1fr;
        padding: 20px;
    }

    .profile-header {
        padding: 40px 20px 20px;
    }

    .profile-info {
        flex-direction: column;
        text-align: center;
    }

    .profile-nickname {
        font-size: 1.5rem;
    }

    .period-stats {
        grid-template-columns: 1fr;
    }
}

/* Enhanced Loading and Error States for Profile Panel */
.user-profile-panel .loading {
    text-align: center;
    padding: 80px 40px;
    color: #667eea;
    font-size: 1.1rem;
    background: white;
    border-radius: 14px;
    margin: 3px;
}

.user-profile-panel .loading i {
    font-size: 3rem;
    margin-bottom: 20px;
    display: block;
}

.user-profile-panel .error {
    background: white;
    border-radius: 14px;
    margin: 3px;
    padding: 60px 40px;
    text-align: center;
}

.user-profile-panel .error i {
    font-size: 4rem;
    color: #f64e60;
    margin-bottom: 20px;
    display: block;
}

.user-profile-panel .error p {
    color: var(--text-primary);
    font-size: 1.1rem;
    margin: 0;
    line-height: 1.6;
}