*, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: "Poppins", Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background-color: #f4f8ff;
    flex-direction: column;
    overflow-x: hidden;
}

.chart-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 0 15px;
    box-sizing: border-box;
    gap: 20px;
}

.chart {
    flex: 1;
    max-width: 500px;
    text-align: center;
    box-sizing: border-box;
}

.legend-container {
    width: 20%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
}

.legend-container #legend {
    display: flex;
    flex-direction: column;
}

.legend-container #legend-left,
.legend-container #legend-right {
    flex-direction: column;
    align-items: flex-start;
    margin: 0;
}

.legend-container div {
    display: flex;
    margin-bottom: 5px;
    white-space: nowrap;
}

.legend-container div span {
    width: 20px;
    height: 20px;
    display: inline-block;
    margin-right: 10px;
    flex-shrink: 0;
}

.chart-title {
    font-size: 1.5rem;
    font-weight: bold;
    line-height: 1.5em;
    margin: 0;
}

.chart-subtitle {
    text-align: center;
    font-size: 1.1rem;
    font-weight: 400;
    line-height: 1.75em;
    color: #222;
    margin-bottom: 20px;
}

.tooltip {
    position: absolute;
    background-color: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: .8rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 1000;
}

canvas {
    width: 100% !important;
    height: auto !important;
    max-width: 500px;
    box-sizing: border-box;
}

.legend-disabled {
    text-decoration: line-through;
}

#chart1 {
    order: 1;
}
#chart2 {
    order: 3;
}
#legend-container {
    order: 2;
}

.legend-tooltip {
    position: absolute;
    background-color: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.8rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 1000;
}

@media (max-width: 768px) {
    body {
        justify-content: flex-start;
        padding: 0 15px;
    }

    .chart-container {
        flex-direction: row;
        align-items: center;
        padding: 0;
        flex-wrap: wrap;
    }

    .legend-container {
        flex-direction: row;
        justify-content: center;
        width: 100%;
    }

    .legend-container #legend {
        flex-direction: row;
        gap: 60px;
    }

    .legend-container #legend-left,
    .legend-container #legend-right {
        display: flex;
        flex-direction: column;
        width: 48%;
    }

    .legend-container div {
        margin-bottom: 10px;
        font-size: .9rem;
    }

    .chart {
        width: 100%;
        margin: 0 auto;
    }

    .chart-title {
        font-size: 1.3rem;
    }

    .chart-subtitle {
        font-size: 1rem;
    }

    #chart1 {
        width: 50%;
        order: 2;
    }
    #chart2 {
        width: 50%;
        order: 3;
    }
    #legend-container {
        order: 1;
    }

    .legend-tooltip {
        display: none;
    }
}
