 main {
    flex: 1;
}

.stats-page,
.stats-page * {
    box-sizing: border-box;
}

.stats-page {
    width: min(1200px, calc(100% - 40px));
    margin: 0 auto;
    padding: 40px 0 70px;
}

.stats-header {
    margin-bottom: 24px;
}

.stats-header h1 {
    margin: 0;
    font-size: 2rem;
}

.stats-header p {
    margin: 6px 0 0;
    color: #7c8a99;
}

.period-selector {
    display: flex;
    align-items: center;
    gap: 7px;
    overflow-x: auto;
    margin-bottom: 22px;
    padding-bottom: 3px;
    scrollbar-width: none;
}

.period-selector::-webkit-scrollbar {
    display: none;
}

.period-selector a {
    flex-shrink: 0;
    padding: 8px 13px;
    border: 1px solid #24303c;
    border-radius: 7px;
    background: #0f141a;
    color: #8492a0;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 600;
    transition: 0.2s;
}

.period-selector a:hover {
    border-color: #3c4b5c;
    color: #c8d2dc;
}

.period-selector a.active {
    border-color: #315f94;
    background: #17365b;
    color: #d7e9ff;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.stat-card {
    position: relative;
    display: flex;
    min-width: 0;
    height: 235px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 20px;
    border: 1px solid #1f2a36;
    border-radius: 11px;
    background: #0f141a;
    text-align: center;
    transition:
        transform 0.2s ease,
        border-color 0.2s ease,
        background 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-3px);
    border-color: #354555;
    background: #10161d;
}

.stat-icon {
    display: flex;
    width: auto;
    height: auto;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
    background: transparent;
    color: #6fa8ef;
    font-size: 2.2rem;
}

.stat-label {
    margin: 0 0 8px;
    color: #c3ccd5;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.25;
}

.stat-value {
    display: block;
    margin: 0;
    color: #f1f4f7;
    font-size: 1.5rem;
    line-height: 1.2;
}

.stat-value.stat-text {
    max-width: 100%;
    overflow: hidden;
    color: #f1f4f7;
    font-size: 1.3rem;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stat-secondary {
    margin: 9px 0 0;
    color: #a0acb8;
    font-size: 0.82rem;
    line-height: 1.5;
}

.stat-secondary strong {
    color: #c9d3dd;
}

.stat-film {
    display: -webkit-box;
    max-width: 100%;
    overflow: hidden;
    color: #f1f4f7;
    text-decoration: none;
    text-align: center;
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1.3;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.stat-film:hover {
    color: #78aff3;
}

.evolution,
.previous-text {
    position: absolute;
    right: 15px;
    bottom: 18px;
    left: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
}

.evolution.up {
    color: #66c98a;
}

.evolution.down {
    color: #df7777;
}

.evolution.equal {
    color: #7e8a96;
}

.previous-text {
    color: #778695;
    font-weight: 500;
}

.previous-text i {
    flex-shrink: 0;
    font-size: 0.35rem;
}

.previous-text span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.record-card {
    cursor: pointer;
}

.record-tooltip {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 20;
    width: calc(100% - 30px);
    max-height: calc(100% - 30px);
    padding: 18px;
    overflow-y: auto;
    border: 1px solid #2d3b49;
    border-radius: 10px;
    background: #111820;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
    opacity: 0;
    visibility: hidden;
    transform: translate(-50%, -45%);
    pointer-events: none;
    transition:
        opacity 0.18s ease,
        transform 0.18s ease,
        visibility 0.18s ease;
}

.record-card:hover .record-tooltip,
.record-card:focus .record-tooltip,
.record-card.open .record-tooltip {
    display: flex;
    flex-direction: column;
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%);
    pointer-events: auto;
}

.record-tooltip strong {
    margin-bottom: 8px;
    color: #8593a1;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.record-tooltip a {
    padding: 6px 0;
    border-top: 1px solid #202a35;
    color: #dce4ec;
    text-decoration: none;
    font-size: 0.78rem;
}

.record-tooltip a:hover {
    color: #78aff3;
}

.analysis-section,
.studios-section,
.movies-section {
    margin-top: 20px;
    padding: 22px;
    border: 1px solid #253341;
    border-radius: 13px;
    background: #0f141a;
}

.section-heading,
.movies-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
}

.section-heading h2,
.movies-heading h2 {
    margin: 0;
    font-size: 1.1rem;
}

.section-kicker {
    display: block;
    margin-bottom: 5px;
    color: #6fa8ef;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.chart-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-bottom: 20px;
}

.chart-button {
    padding: 8px 13px;
    border: 1px solid #263441;
    border-radius: 7px;
    background: #0b1015;
    color: #8797a7;
    cursor: pointer;
    font: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    transition: 0.2s;
}

.chart-button:hover {
    border-color: #3a526b;
    color: #c6d2dd;
}

.chart-button.active {
    border-color: #386fae;
    background: #17365b;
    color: #d8eaff;
}

.chart-wrapper {
    position: relative;
    width: 100%;
    height: 390px;
}

.studio-podium {
    display: flex;
    min-height: 240px;
    align-items: flex-end;
    justify-content: center;
    gap: 8px;
    padding-top: 15px;
}

.podium-item {
    display: flex;
    width: min(220px, 30%);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 18px 14px;
    border: 1px solid #293746;
    border-bottom: 0;
    border-radius: 10px 10px 0 0;
    background: #111820;
    text-align: center;
}

.podium-item.rank-1 {
    min-height: 200px;
    border-color: #416a99;
    background: #142238;
}

.podium-item.rank-2 {
    min-height: 155px;
}

.podium-item.rank-3 {
    min-height: 130px;
}

.podium-rank {
    display: flex;
    width: 34px;
    height: 34px;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    border-radius: 50%;
    background: #1d2a37;
    color: #82b6f5;
    font-weight: 800;
}

.rank-1 .podium-rank {
    background: #234a78;
    color: #e4f0ff;
}

.podium-item strong {
    color: #eef3f7;
    font-size: 1rem;
}

.podium-item > span:last-child {
    margin-top: 7px;
    color: #8fa0b0;
    font-size: 0.8rem;
}

.empty-section {
    margin: 30px 0;
    color: #7e8c9a;
    text-align: center;
}

.movie-count {
    color: #91a5b8;
    font-size: 0.85rem;
}

.movie-tools {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 16px;
}

.movie-search {
    position: relative;
    width: min(500px, 100%);
}

.movie-search i {
    position: absolute;
    top: 50%;
    left: 14px;
    color: #66798b;
    transform: translateY(-50%);
    pointer-events: none;
}

.movie-search input {
    width: 100%;
    padding: 11px 14px 11px 40px;
    border: 1px solid #283643;
    border-radius: 8px;
    outline: none;
    background: #0a0f14;
    color: #e5ebf1;
    font: inherit;
}

.movie-search input:focus {
    border-color: #3d78ba;
}

.movie-search input::placeholder {
    color: #68798a;
}

.movie-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    color: #8595a5;
    font-size: 0.75rem;
}

.movie-legend span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-color {
    display: block;
    width: 10px;
    height: 10px;
    border-radius: 3px;
}

.legend-color.animation {
    background: #703e59;
}

.legend-color.marvel {
    background: #703b3b;
}

.movies-table-wrapper {
    overflow-x: auto;
    border: 1px solid #202c37;
    border-radius: 9px;
}

.movies-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
}

.movies-table th {
    padding: 12px 14px;
    border-bottom: 1px solid #2a3743;
    background: #151d25;
    color: #a8b4c0;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
}

.movies-table td {
    padding: 12px 14px;
    border-bottom: 1px solid #1d2730;
    color: #bdc7d0;
    font-size: 0.8rem;
}

.movies-table tbody tr:last-child td {
    border-bottom: 0;
}

.movies-table tbody tr {
    background: #0c1116;
    transition: background 0.15s ease;
}

.movies-table tbody tr:hover {
    background: #121a22;
}

.movies-table tbody tr.animation-row {
    background: #a53f75;
}

.movies-table tbody tr.animation-row:hover {
    background: #b45487;
}

.movies-table tbody tr.marvel-row {
    background: #b02727;
}

.movies-table tbody tr.marvel-row:hover {
    background: #b33939;
}

.movies-table a {
    color: #e6ebef;
    text-decoration: none;
    font-weight: 600;
}

.movies-table a:hover {
    color: #79b1f4;
}

.no-movies {
    display: none;
    padding: 35px 20px;
    color: #768696;
    text-align: center;
}

@media (max-width: 1100px) {
    .stats-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 850px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .movie-tools {
        align-items: flex-start;
        flex-direction: column;
    }

    .movie-search {
        width: 100%;
    }
}

@media (max-width: 600px) {
    .stats-page {
        width: calc(100% - 24px);
        padding: 24px 0 50px;
    }

    .stats-header h1 {
        font-size: 1.65rem;
    }

    .period-selector {
        margin-right: -12px;
        padding-right: 12px;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .stat-card {
        height: 190px;
        padding: 14px;
    }

    .stat-icon {
        margin-bottom: 12px;
        font-size: 1.8rem;
    }

    .stat-label {
        font-size: 0.78rem;
    }

    .stat-value {
        font-size: 1.2rem;
    }

    .stat-value.stat-text {
        font-size: 1rem;
    }

    .stat-secondary {
        font-size: 0.72rem;
    }

    .previous-text,
    .evolution {
        right: 10px;
        bottom: 11px;
        left: 10px;
        font-size: 0.7rem;
    }

    .analysis-section,
    .studios-section,
    .movies-section {
        padding: 16px;
    }

    .chart-wrapper {
        height: 300px;
    }

    .studio-podium {
        min-height: 190px;
        gap: 4px;
    }

    .podium-item {
        width: 33.333%;
        padding: 12px 7px;
    }

    .podium-item.rank-1 {
        min-height: 165px;
    }

    .podium-item.rank-2 {
        min-height: 130px;
    }

    .podium-item.rank-3 {
        min-height: 110px;
    }

    .podium-item strong {
        font-size: 0.8rem;
    }

    .podium-item > span:last-child {
        font-size: 0.7rem;
    }

    .movie-legend {
        gap: 10px;
    }
}

@media (max-width: 420px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-card {
        height: 175px;
    }

    .chart-selector {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .chart-button {
        width: 100%;
    }
}