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

:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --text-primary: #2d3748;
    --text-secondary: #718096;
    --bg-light: #f7fafc;
    --bg-white: #ffffff;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15), 0 4px 10px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.2);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-attachment: fixed;
    min-height: 100vh;
    padding: 20px;
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.6;
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    background: var(--bg-white);
    border-radius: 20px;
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    backdrop-filter: blur(10px);
}

header {
    background: var(--primary-gradient);
    color: white;
    padding: 40px 30px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    animation: pulse 20s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

header h1 {
    font-size: 2.8em;
    margin-bottom: 10px;
    word-wrap: break-word;
    font-weight: 700;
    letter-spacing: -0.5px;
    position: relative;
    z-index: 1;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

@media (max-width: 768px) {
    header {
        padding: 30px 20px;
    }
    
    header h1 {
        font-size: 2em;
    }
}

@media (max-width: 480px) {
    header {
        padding: 25px 15px;
    }
    
    header h1 {
        font-size: 1.6em;
    }
}

main {
    padding: 40px;
    background: var(--bg-light);
}

@media (max-width: 768px) {
    main {
        padding: 25px;
    }
}

@media (max-width: 480px) {
    main {
        padding: 20px;
    }
}

.section {
    margin-bottom: 50px;
    background: var(--bg-white);
    border-radius: 16px;
    padding: 30px;
    box-shadow: var(--shadow-md);
    transition: box-shadow 0.3s ease;
}

.section:hover {
    box-shadow: var(--shadow-lg);
}

.section:last-child {
    margin-bottom: 0;
}

.section h2 {
    color: var(--primary-color);
    font-size: 1.9em;
    margin-bottom: 25px;
    font-weight: 700;
    letter-spacing: -0.3px;
    position: relative;
    padding-bottom: 15px;
}

.section h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 60px;
    height: 4px;
    background: var(--primary-gradient);
    border-radius: 2px;
}

.description {
    color: var(--text-secondary);
    margin-bottom: 25px;
    font-size: 1em;
    line-height: 1.6;
}

/* Текущая статистика */
.current-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px;
    margin-bottom: 0;
}

.stat-card {
    background: var(--bg-white);
    border-radius: 16px;
    padding: 30px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary-gradient);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
}

.stat-card:hover::before {
    transform: scaleX(1);
}

.stat-card.total {
    background: var(--primary-gradient);
    color: white;
    border: none;
}

.stat-card.total::before {
    display: none;
}

.stat-card.male {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    border: none;
}

.stat-card.male::before {
    display: none;
}

.stat-card.female {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    color: white;
    border: none;
}

.stat-card.female::before {
    display: none;
}

.stat-card.unknown {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
}

.stat-label {
    font-size: 0.85em;
    opacity: 0.85;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 600;
}

.stat-value {
    font-size: 3.2em;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -1px;
}

/* Таблица */
.table-container {
    overflow-x: auto;
    margin-top: 25px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    background: var(--bg-white);
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--bg-white);
    border-radius: 12px;
    overflow: hidden;
}

.data-table thead {
    background: var(--primary-gradient);
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table th {
    padding: 18px 16px;
    text-align: center;
    font-weight: 600;
    font-size: 0.9em;
    letter-spacing: 0.3px;
    border-right: 1px solid rgba(255, 255, 255, 0.15);
    text-transform: uppercase;
}

.data-table th:first-child {
    text-align: left;
    padding-left: 20px;
}

.data-table th:last-child {
    border-right: none;
}

.data-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.data-table tbody tr:hover {
    background-color: #f8f9ff;
    transform: scale(1.01);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}

.data-table tbody tr:last-child {
    border-bottom: none;
}

.data-table td {
    padding: 14px 16px;
    text-align: center;
    font-size: 0.95em;
    color: var(--text-primary);
    font-weight: 500;
}

.data-table td:first-child {
    font-weight: 700;
    background-color: #f8f9ff;
    color: var(--primary-color);
    text-align: left;
    padding-left: 20px;
}

.data-table .positive {
    color: #10b981;
    font-weight: 700;
}

.data-table .negative {
    color: #ef4444;
    font-weight: 700;
}

.data-table .loading,
.data-table .error {
    text-align: center;
    padding: 50px;
    color: var(--text-secondary);
    font-style: italic;
    font-size: 1.1em;
}

.data-table .error {
    color: #ef4444;
}

.data-table.matrix-table {
    font-size: 0.88em;
}

.data-table.matrix-table th {
    padding: 14px 12px;
    font-size: 0.82em;
    white-space: nowrap;
}

.data-table.matrix-table td {
    padding: 12px;
    font-size: 0.9em;
}

.data-table .total-row {
    background: linear-gradient(135deg, #e0e7ff 0%, #f3e8ff 100%);
    font-weight: 700;
    border-top: 3px solid var(--primary-color);
}

.data-table .total-row td {
    background: transparent;
    color: var(--primary-color);
    font-size: 1.05em;
    padding: 16px;
}

.data-table .total-row td:first-child {
    background: transparent;
    color: var(--primary-color);
}

/* Footer */
footer {
    background: var(--bg-white);
    padding: 25px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-color);
}

@media (max-width: 768px) {
    footer {
        flex-direction: column;
        gap: 20px;
        padding: 25px;
    }
}

footer p {
    color: var(--text-secondary);
    font-size: 0.9em;
    font-weight: 500;
}

footer p span {
    color: var(--primary-color);
    font-weight: 600;
}

.refresh-btn {
    background: var(--primary-gradient);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
    letter-spacing: 0.3px;
    position: relative;
    overflow: hidden;
}

.refresh-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.refresh-btn:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.refresh-btn:hover::before {
    width: 300px;
    height: 300px;
}

.refresh-btn:active {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.refresh-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.refresh-btn:disabled:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
}

.refresh-btn:disabled::before {
    display: none;
}

/* Плавная анимация появления */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section {
    animation: fadeIn 0.6s ease-out;
}

.stat-card {
    animation: fadeIn 0.6s ease-out;
}

.stat-card:nth-child(1) { animation-delay: 0.1s; }
.stat-card:nth-child(2) { animation-delay: 0.2s; }
.stat-card:nth-child(3) { animation-delay: 0.3s; }
.stat-card:nth-child(4) { animation-delay: 0.4s; }

/* Скроллбар */
.table-container::-webkit-scrollbar {
    height: 8px;
}

.table-container::-webkit-scrollbar-track {
    background: var(--bg-light);
    border-radius: 4px;
}

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

.table-container::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}
