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

:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #8b5cf6;
    --background-start: #0f0f1a;
    --background-end: #1a1a2e;
    --card-bg: rgba(30, 30, 50, 0.8);
    --card-border: rgba(99, 102, 241, 0.2);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --success-color: #10b981;
    --error-color: #ef4444;
    --gradient-1: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --gradient-2: linear-gradient(135deg, #10b981 0%, #06b6d4 100%);
    --gradient-3: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(180deg, var(--background-start) 0%, var(--background-end) 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    text-align: center;
    padding: 3rem 0;
    margin-bottom: 2rem;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.logo-icon {
    font-size: 3rem;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.header h1 {
    font-size: 3rem;
    font-weight: 700;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    font-size: 1.25rem;
    color: var(--text-secondary);
    font-weight: 300;
}

/* Main Content */
.main-content {
    flex: 1;
}

.models-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 1.5rem;
}

/* Model Card */
.model-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 1.5rem;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    cursor: pointer;
}

.model-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary-color);
    box-shadow: 0 20px 40px rgba(99, 102, 241, 0.2);
}

.model-card.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.3);
}

.model-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.model-icon {
    font-size: 2.5rem;
    min-width: 50px;
}

.model-info h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}

.model-author {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.model-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.model-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tag {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary-color);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.tag.params {
    background: rgba(139, 92, 246, 0.15);
    color: var(--secondary-color);
}

.tag.size {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success-color);
}

/* Action Buttons */
.model-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn {
    padding: 0.625rem 1rem;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.btn-download {
    background: var(--gradient-1);
    color: white;
    flex: 1;
}

.btn-download:hover {
    opacity: 0.9;
    transform: scale(1.02);
}

.btn-install {
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    flex: 1;
}

.btn-install:hover {
    background: rgba(99, 102, 241, 0.3);
}

.btn-try {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success-color);
    border: 1px solid var(--success-color);
    flex: 1;
}

.btn-try:hover {
    background: rgba(16, 185, 129, 0.3);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: linear-gradient(180deg, #1e1e32 0%, #151525 100%);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 2rem;
    max-width: 450px;
    width: 90%;
    position: relative;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s ease;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.modal-icon {
    font-size: 2rem;
}

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

.modal-body {
    color: var(--text-secondary);
}

.modal-body.hidden {
    display: none;
}

.modal-message {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 10px;
    border-left: 3px solid var(--primary-color);
}

/* Form */
.registration-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input {
    padding: 0.75rem 1rem;
    border: 1px solid var(--card-border);
    border-radius: 10px;
    background: rgba(30, 30, 50, 0.5);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.2s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

.btn-submit {
    background: var(--gradient-1);
    color: white;
    padding: 0.875rem;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    margin-top: 0.5rem;
}

.btn-submit:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

/* Success State */
#modalSuccess {
    text-align: center;
    padding: 2rem 0;
}

.success-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: successPop 0.5s ease;
}

@keyframes successPop {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

#modalSuccess h3 {
    font-size: 1.5rem;
    color: var(--success-color);
    margin-bottom: 1rem;
}

.success-message {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.btn-close-success {
    background: var(--gradient-2);
    color: white;
    padding: 0.75rem 2rem;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.btn-close-success:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

/* Footer */
.footer {
    text-align: center;
    padding: 2rem 0;
    margin-top: 3rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Chart */
.charts-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.chart-container {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 1.5rem;
    backdrop-filter: blur(10px);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

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

.chart-legend {
    display: flex;
    gap: 1.5rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

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

.legend-item.cpu .legend-dot {
    background: #6366f1;
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.6);
}

.legend-item.gpu .legend-dot {
    background: #10b981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

.legend-item.ram .legend-dot {
    background: #f59e0b;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.6);
}

.legend-item.ram-total {
    color: var(--text-muted);
}

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

.copyright {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .header h1 {
        font-size: 2rem;
    }

    .logo-icon {
        font-size: 2rem;
    }

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

    .model-actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

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

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

    .chart-legend {
        flex-wrap: wrap;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background-start);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-hover);
}
// Инициализация графика загрузки
function initChart() {
    const ctx = document.getElementById('loadChart').getContext('2d');
    
    // Градиенты для линий
    const cpuGradient = ctx.createLinearGradient(0, 0, 0, 400);
    cpuGradient.addColorStop(0, 'rgba(99, 102, 241, 0.8)');
    cpuGradient.addColorStop(1, 'rgba(99, 102, 241, 0.1)');
    
    const gpuGradient = ctx.createLinearGradient(0, 0, 0, 400);
    gpuGradient.addColorStop(0, 'rgba(16, 185, 129, 0.8)');
    gpuGradient.addColorStop(1, 'rgba(16, 185, 129, 0.1)');
    
    const initialData = {
        labels: [],
        datasets: [
            {
                label: 'CPU',
                data: [],
                borderColor: '#6366f1',
                backgroundColor: cpuGradient,
                borderWidth: 2,
                fill: true,
                tension: 0.4,
                pointRadius: 0,
                pointHoverRadius: 4
            },
            {
                label: 'GPU',
                data: [],
                borderColor: '#10b981',
                backgroundColor: gpuGradient,
                borderWidth: 2,
                fill: true,
                tension: 0.4,
                pointRadius: 0,
                pointHoverRadius: 4
            }
        ]
    };
    
    const chart = new Chart(ctx, {
        type: 'line',
        data: initialData,
        config: {
            responsive: true,
            maintainAspectRatio: false,
            animation: {
                duration: 1000,
                easing: 'easeInOutQuart'
            },
            plugins: {
                legend: {
                    display: false
                },
                tooltip: {
                    backgroundColor: 'rgba(30, 30, 50, 0.95)',
                    titleColor: '#f8fafc',
                    bodyColor: '#94a3b8',
                    borderColor: 'rgba(99, 102, 241, 0.3)',
                    borderWidth: 1,
                    padding: 12,
                    displayColors: true,
                    callbacks: {
                        label: function(context) {
                            return context.dataset.label + ': ' + context.parsed.y.toFixed(1) + '%';
                        }
                    }
                }
            },
            scales: {
                x: {
                    display: false,
                    grid: {
                        display: false
                    }
                },
                y: {
                    display: true,
                    min: 50,
                    max: 100,
                    grid: {
                        color: 'rgba(99, 102, 241, 0.1)'
                    },
                    ticks: {
                        color: '#64748b',
                        font: {
                            family: 'Inter',
                            size: 10
                        },
                        callback: function(value) {
                            return value + '%';
                        }
                    }
                }
            }
        }
    });
    
    // Генерация случайных значений в диапазоне
    function getRandomValue(min, max) {
        return Math.random() * (max - min) + min;
    }
    
    // Добавление новых данных
    function updateChart() {
        const now = new Date().toLocaleTimeString('ru-RU');
        
        // CPU: 63-77%
        const cpuValue = getRandomValue(63, 77);
        // GPU: 85-88%
        const gpuValue = getRandomValue(85, 88);
        
        // Добавляем новые данные
        if (chart.data.labels.length >= 20) {
            chart.data.labels.shift();
            chart.data.datasets[0].data.shift();
            chart.data.datasets[1].data.shift();
        }
        
        chart.data.labels.push(now);
        chart.data.datasets[0].data.push(cpuValue);
        chart.data.datasets[1].data.push(gpuValue);
        
        chart.update('none');
    }
    
    // Обновление каждые 2-3 секунды (случайно)
    function scheduleUpdate() {
        const delay = Math.random() * 1000 + 2000; // 2000-3000ms
        setTimeout(() => {
            updateChart();
            scheduleUpdate();
        }, delay);
    }
    
    // Заполняем начальными данными
    for (let i = 0; i < 20; i++) {
        const now = new Date();
        now.setSeconds(now.getSeconds() - (20 - i) * 2.5);
        chart.data.labels.push(now.toLocaleTimeString('ru-RU'));
        chart.data.datasets[0].data.push(getRandomValue(63, 77));
        chart.data.datasets[1].data.push(getRandomValue(85, 88));
    }
    
    chart.update();
    scheduleUpdate();
    
    // Сохраняем ссылку на график
    window.currentChart = chart;
    
    return chart;
}

// Инициализация графика RAM
function initRamChart() {
    const ctx = document.getElementById('ramChart').getContext('2d');
    
    // Градиент для RAM
    const ramGradient = ctx.createLinearGradient(0, 0, 0, 400);
    ramGradient.addColorStop(0, 'rgba(245, 158, 11, 0.8)');
    ramGradient.addColorStop(1, 'rgba(245, 158, 11, 0.1)');
    
    const initialData = {
        labels: [],
        datasets: [
            {
                label: 'RAM',
                data: [],
                borderColor: '#f59e0b',
                backgroundColor: ramGradient,
                borderWidth: 2,
                fill: true,
                tension: 0.4,
                pointRadius: 0,
                pointHoverRadius: 4
            }
        ]
    };
    
    const chart = new Chart(ctx, {
        type: 'line',
        data: initialData,
        config: {
            responsive: true,
            maintainAspectRatio: false,
            animation: {
                duration: 1000,
                easing: 'easeInOutQuart'
            },
            plugins: {
                legend: {
                    display: false
                },
                tooltip: {
                    backgroundColor: 'rgba(30, 30, 50, 0.95)',
                    titleColor: '#f8fafc',
                    bodyColor: '#94a3b8',
                    borderColor: 'rgba(245, 158, 11, 0.3)',
                    borderWidth: 1,
                    padding: 12,
                    displayColors: false,
                    callbacks: {
                        label: function(context) {
                            return 'RAM: ' + context.parsed.y.toFixed(1) + '%';
                        }
                    }
                }
            },
            scales: {
                x: {
                    display: false,
                    grid: {
                        display: false
                    }
                },
                y: {
                    display: true,
                    min: 0,
                    max: 60,
                    grid: {
                        color: 'rgba(245, 158, 11, 0.1)'
                    },
                    ticks: {
                        color: '#64748b',
                        font: {
                            family: 'Inter',
                            size: 10
                        },
                        callback: function(value) {
                            return value + '%';
                        }
                    }
                }
            }
        }
    });
    
    // Генерация случайных значений в диапазоне
    function getRandomValue(min, max) {
        return Math.random() * (max - min) + min;
    }
    
    // Добавление новых данных
    function updateChart() {
        const now = new Date().toLocaleTimeString('ru-RU');
        
        // RAM: 35-42%
        const ramValue = getRandomValue(35, 42);
        
        // Добавляем новые данные
        if (chart.data.labels.length >= 20) {
            chart.data.labels.shift();
            chart.data.datasets[0].data.shift();
        }
        
        chart.data.labels.push(now);
        chart.data.datasets[0].data.push(ramValue);
        
        chart.update('none');
    }
    
    // Обновление каждые ~10 секунд (случайно 8-12 сек)
    function scheduleUpdate() {
        const delay = Math.random() * 4000 + 8000; // 8000-12000ms
        setTimeout(() => {
            updateChart();
            scheduleUpdate();
        }, delay);
    }
    
    // Заполняем начальными данными
    for (let i = 0; i < 20; i++) {
        const now = new Date();
        now.setSeconds(now.getSeconds() - (20 - i) * 10);
        chart.data.labels.push(now.toLocaleTimeString('ru-RU'));
        chart.data.datasets[0].data.push(getRandomValue(35, 42));
    }
    
    chart.update();
    scheduleUpdate();
    
    // Сохраняем ссылку на график
    window.currentRamChart = chart;
    
    return chart;
}

// Инициализация после загрузки страницы
document.addEventListener('DOMContentLoaded', () => {
    // Проверяем, что Chart.js загружен
    if (typeof Chart !== 'undefined') {
        initChart();
        initRamChart();
    }
});
