* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 50%, #667eea 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
    position: relative;
}

.header h1 {
    font-size: 3em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    background: linear-gradient(45deg, #fff, #f0f8ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.last-update {
    font-size: 1em;
    opacity: 0.9;
    margin-bottom: 15px;
    background: rgba(255,255,255,0.1);
    padding: 10px 20px;
    border-radius: 25px;
    display: inline-block;
    backdrop-filter: blur(10px);
}

.admin-toggle {
    position: absolute;
    top: 0;
    right: 0;
    background: rgba(255,255,255,0.2);
    border: 2px solid rgba(255,255,255,0.3);
    color: white;
    padding: 8px 15px;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.admin-toggle:hover {
    background: rgba(255,255,255,0.3);
    transform: scale(1.05);
}

.admin-panel {
    background: white;
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    display: none;
    border: 2px solid #ff6b6b;
}

.admin-panel.active {
    display: block;
}

.admin-panel h2 {
    color: #ff6b6b;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.controls-panel {
    background: rgba(255,255,255,0.1);
    padding: 20px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    margin-bottom: 30px;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #333;
}

.form-group input {
    width: 100%;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 16px;
    margin: 5px;
    transition: all 0.3s ease;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn.danger {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
}

.status {
    padding: 12px 20px;
    border-radius: 8px;
    margin: 15px 0;
    display: none;
    font-weight: 500;
}

.status.success {
    background: #d4edda;
    color: #155724;
    border-left: 4px solid #28a745;
}

.status.error {
    background: #f8d7da;
    color: #721c24;
    border-left: 4px solid #dc3545;
}

.status.info {
    background: #d1ecf1;
    color: #0c5460;
    border-left: 4px solid #17a2b8;
}

.auto-update-control {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255,255,255,0.1);
    padding: 10px 15px;
    border-radius: 25px;
    backdrop-filter: blur(10px);
}

.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255,255,255,0.3);
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #4CAF50;
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.main-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.metric-card {
    background: white;
    padding: 25px;
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    border-left: 5px solid;
    position: relative;
    overflow: hidden;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100px;
    background: linear-gradient(45deg, transparent, rgba(255,255,255,0.1));
    transform: rotate(45deg) translate(50px, -50px);
}

.metric-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 25px 50px rgba(0,0,0,0.15);
}

.metric-card.profit { border-left-color: #28a745; }
.metric-card.revenue { border-left-color: #007bff; }
.metric-card.orders { border-left-color: #ffc107; }
.metric-card.turnover { border-left-color: #17a2b8; }
.metric-card.salary { border-left-color: #6f42c1; }
.metric-card.teddy { border-left-color: #fd7e14; }

.metric-card h3 {
    color: #495057;
    margin-bottom: 15px;
    font-size: 1.1em;
    display: flex;
    align-items: center;
    gap: 10px;
}

.metric-value {
    font-size: 2.2em;
    font-weight: bold;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.metric-label {
    color: #6c757d;
    font-size: 0.9em;
}

/* Стили для топа трейдеров */
.top-traders-section {
    background: white;
    padding: 25px;
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.1);
    margin-bottom: 30px;
    margin-top: 30px;
}

.top-traders-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.top-traders-header h3 {
    color: #495057;
    font-size: 1.3em;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.expand-btn {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    font-size: 14px;
    padding: 8px 16px;
    transition: all 0.3s ease;
}

.expand-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.3);
}

.expand-btn.expanded {
    background: linear-gradient(135deg, #dc3545 0%, #fd7e14 100%);
}

.top-traders-section.expanded .top-category {
    max-height: none;
    overflow: visible;
}

.top-traders-section.expanded .top-trader-item:nth-child(n+6) {
    display: flex;
}

.top-traders-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-top: 20px;
}

.top-category {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 15px;
    padding: 20px;
    border-top: 4px solid #667eea;
    max-height: 400px;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.top-traders-section.expanded .top-category {
    max-height: none;
}

.top-category h4 {
    color: #495057;
    margin-bottom: 20px;
    font-size: 1.2em;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.top-trader-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    margin-bottom: 10px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
    position: relative;
}

.top-trader-item:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.top-trader-item:nth-child(n+6) {
    display: none;
}

.top-traders-section.expanded .top-trader-item:nth-child(n+6) {
    display: flex;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.trader-position {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.1em;
    margin-right: 15px;
    color: white;
    flex-shrink: 0;
}

.trader-position.gold {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.4);
}

.trader-position.silver {
    background: linear-gradient(135deg, #C0C0C0 0%, #A0A0A0 100%);
    box-shadow: 0 0 15px rgba(192, 192, 192, 0.4);
}

.trader-position.bronze {
    background: linear-gradient(135deg, #CD7F32 0%, #B8860B 100%);
    box-shadow: 0 0 15px rgba(205, 127, 50, 0.4);
}

.trader-position.other {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.trader-info {
    flex-grow: 1;
    min-width: 0; /* Исправление для переполнения текста */
}

.trader-info .trader-name {
    font-weight: bold;
    color: #495057;
    margin-bottom: 5px;
    font-size: 1em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.trader-value {
    color: #667eea;
    font-weight: 600;
    font-size: 1.1em;
}

.crown-icon {
    position: absolute;
    top: -8px;
    right: 10px;
    font-size: 1.2em;
    color: #FFD700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.6);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

.chart-section {
    background: white;
    padding: 25px;
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.1);
    min-height: 300px;
    display: flex;
    flex-direction: column;
}

/* Исправление для финансовой отчетности на всю ширину */
.chart-section:has(.financial-details) {
    grid-column: 1 / -1;
}

.chart-section h3 {
    color: #495057;
    margin-bottom: 20px;
    font-size: 1.3em;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chart-container {
    position: relative;
    height: 350px;
    width: 100%;
    margin-top: 20px;
}

.traders-section {
    background: white;
    padding: 25px;
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.1);
    grid-column: 1 / -1;
    margin-top: 20px;
}

.traders-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.trader-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 20px;
    border-radius: 15px;
    border-left: 4px solid #667eea;
    transition: all 0.3s ease;
}

.trader-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

.trader-card .trader-name {
    font-size: 1.2em;
    font-weight: bold;
    color: #495057;
    margin-bottom: 15px;
    white-space: normal; /* Разрешаем перенос для карточек трейдеров */
}

.trader-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.trader-stat {
    text-align: center;
}

.trader-stat-value {
    font-size: 1.5em;
    font-weight: bold;
    color: #667eea;
}

.trader-stat-label {
    font-size: 0.8em;
    color: #6c757d;
    margin-top: 5px;
}

.loading {
    text-align: center;
    padding: 60px 20px;
    color: white;
}

.spinner {
    border: 4px solid rgba(255,255,255,0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.financial-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.financial-item {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    border-left: 4px solid #667eea;
}

.financial-item h4 {
    color: #495057;
    margin-bottom: 10px;
    font-size: 1em;
}

.financial-value {
    font-size: 1.3em;
    font-weight: bold;
    color: #667eea;
}

@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .top-traders-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .header h1 {
        font-size: 2em;
    }
    
    .header {
        position: static; /* Исправление для мобильных */
    }
    
    .admin-toggle {
        position: static;
        display: block;
        margin: 10px auto 0;
        width: fit-content;
    }
    
    .main-metrics {
        grid-template-columns: 1fr;
    }
    
    .traders-grid {
        grid-template-columns: 1fr;
    }

    .top-traders-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .controls-panel {
        flex-direction: column;
        align-items: stretch;
    }
    
    .auto-update-control {
        justify-content: center;
    }
    
    .btn {
        width: 100%;
        margin: 5px 0;
    }
    
    .expand-btn {
        width: auto;
        margin: 0;
    }
}