/* ===== Базовые стили ===== */
:root {
    --bg: #f8f9fa;
    --surface: #ffffff;
    --text: #1a1a2e;
    --text-secondary: #6c757d;
    --border: #e9ecef;
    --accent: #2c3e6b;
    --accent-light: #4a6fa5;
    --accent-dark: #1a2744;
    --winter-blue: #d6e4f0;
    --winter-ice: #e8f0f8;
    --winter-snow: #f0f4f8;
    --male: #2c3e6b;
    --female: #8ba4c7;
    --chart-1: #2c3e6b;
    --chart-2: #4a6fa5;
    --chart-3: #8ba4c7;
    --chart-4: #b8cce0;
    --chart-5: #d6e4f0;
    --shadow: 0 2px 8px rgba(0,0,0,0.06);
    --radius: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ===== Hero ===== */
.hero {
    text-align: center;
    padding: 60px 20px 40px;
    background: linear-gradient(135deg, var(--accent-dark) 0%, var(--accent) 50%, var(--accent-light) 100%);
    color: white;
    margin-bottom: 40px;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 50%, rgba(255,255,255,0.03) 0%, transparent 50%);
    pointer-events: none;
}

.hero h1 {
    font-size: 42px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 8px;
}

.hero h1 .accent {
    color: var(--winter-blue);
}

.hero .subtitle {
    font-size: 18px;
    opacity: 0.85;
    margin-bottom: 30px;
}

.year-nav {
    display: flex;
    justify-content: center;
    gap: 8px;
}

.year-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.7);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.year-dot:hover {
    background: rgba(255,255,255,0.2);
    color: white;
}

.year-dot.active {
    background: white;
    color: var(--accent);
    border-color: white;
}

/* ===== Sections ===== */
.section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 32px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.section h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 24px;
    color: var(--accent);
    padding-bottom: 12px;
    border-bottom: 2px solid var(--winter-ice);
}

/* ===== Stats Cards ===== */
.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--winter-snow);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    text-align: center;
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-card .label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card .value {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
}

.stat-card .sub {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.stat-card .sub .male { color: var(--male); font-weight: 600; }
.stat-card .sub .female { color: var(--female); font-weight: 600; }

/* ===== Charts ===== */
.chart-wrapper {
    position: relative;
    width: 100%;
    max-height: 400px;
}

.chart-wrapper.chart-horizontal {
    max-height: 500px;
}

.chart-wrapper canvas {
    width: 100% !important;
    max-height: 400px;
}

.chart-wrapper.chart-horizontal canvas {
    max-height: 500px;
}

/* ===== Lists (Regions, Cities) ===== */
.list-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 6px;
}

.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--winter-snow);
    border-radius: 6px;
    font-size: 14px;
    transition: background 0.2s;
}

.list-item:hover {
    background: var(--winter-ice);
}

.list-item .name {
    color: var(--text);
}

.list-item .count {
    font-weight: 600;
    color: var(--accent);
    min-width: 50px;
    text-align: right;
}

.list-item.hidden,
.locality-row.hidden {
    display: none;
}

.list-toggle {
    grid-column: 1 / -1;
    text-align: center;
    padding: 10px;
    margin-top: 4px;
    background: none;
    border: 1px dashed var(--border);
    border-radius: 6px;
    color: var(--accent-light);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.list-toggle:hover {
    background: var(--winter-ice);
    border-color: var(--accent-light);
}

/* ===== Sticky Bar ===== */
.sticky-bar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1000;
    background: linear-gradient(135deg, var(--accent-dark) 0%, var(--accent) 100%);
    color: white;
    padding: 8px 16px;
    border-bottom-right-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    transform: translateY(-100%);
    transition: transform 0.3s ease;
    pointer-events: none;
}

.sticky-bar.visible {
    transform: translateY(0);
    pointer-events: auto;
}

.sticky-bar-inner {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sticky-season {
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: 0.3px;
}

.sticky-year-nav {
    display: flex;
    gap: 4px;
}

.sticky-year-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.75);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    border: 2px solid transparent;
    user-select: none;
}

.sticky-year-dot:hover {
    background: rgba(255,255,255,0.25);
    color: white;
}

.sticky-year-dot.active {
    background: white;
    color: var(--accent);
    border-color: white;
}

/* ===== Distance Switcher ===== */
.dist-nav {
    display: flex;
    gap: 6px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.dist-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 16px;
    border-radius: 20px;
    background: var(--winter-snow);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid var(--border);
    user-select: none;
}

.dist-btn:hover {
    background: var(--winter-ice);
    color: var(--accent);
}

.dist-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* ===== Locality Table ===== */
.locality-info {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.locality-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 4px;
}

.locality-header {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 4px;
}

.locality-header span:first-child {
    text-align: left;
}

.locality-header span {
    text-align: center;
}

.locality-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    padding: 6px 12px;
    align-items: center;
    border-radius: 6px;
    transition: background 0.2s;
}

.locality-row:hover {
    background: var(--winter-snow);
}

.locality-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.locality-bar-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.locality-bar {
    flex: 1;
    height: 16px;
    background: var(--winter-ice);
    border-radius: 8px;
    overflow: hidden;
    min-width: 40px;
}

.locality-bar-fill {
    display: block;
    height: 100%;
    background: var(--accent);
    border-radius: 8px;
    transition: width 0.3s ease;
}

.locality-bar-nonlocal {
    background: var(--female);
}

.locality-pct {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 45px;
    text-align: right;
}

@media (max-width: 768px) {
    .locality-header,
    .locality-row {
        grid-template-columns: 1.5fr 1fr 1fr;
        gap: 4px;
        padding: 6px 8px;
    }

    .locality-name {
        font-size: 12px;
    }

    .locality-bar {
        min-width: 30px;
        height: 12px;
    }

    .locality-pct {
        font-size: 11px;
        min-width: 38px;
    }
}

/* ===== Footer ===== */
.footer {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-secondary);
    font-size: 14px;
}

.footer a {
    color: var(--accent-light);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .hero h1 {
        font-size: 28px;
    }

    .hero .subtitle {
        font-size: 15px;
    }

    .year-dot {
        width: 42px;
        height: 42px;
        font-size: 12px;
    }

    .section {
        padding: 20px;
    }

    .section h2 {
        font-size: 20px;
    }

    .stats-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .stat-card .value {
        font-size: 22px;
    }

    .list-container {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .hero {
        padding: 40px 16px 30px;
    }

    .hero h1 {
        font-size: 24px;
    }

    .stats-cards {
        grid-template-columns: 1fr 1fr;
    }
}
