html,
body {
    margin: 0;
    padding: 0;
    background: transparent;
    font-family: system-ui, sans-serif;
    color: #ffffff;
}

.widget-shell {
    min-height: 100vh;
    box-sizing: border-box;
    padding: 24px;
    border-radius: 24px;
    background: linear-gradient(180deg, #0f1720, #152330);
}

.widget-shell.is-loading {
    cursor: progress;
}

.widget-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
}

.widget-header h2 {
    margin: 0;
    font-size: 1.4rem;
}

.widget-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
}

.range-selector,
.aggregation-selector {
    display: flex;
    gap: 8px;
    padding: 4px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.045);
}

.range-selector button,
.aggregation-selector button {
    border: 0;
    padding: 8px 13px;
    border-radius: 10px;
    background: transparent;
    color: #dbe7f2;
    cursor: pointer;
    white-space: nowrap;
}

.range-selector button:hover,
.aggregation-selector button:hover {
    background: rgba(255, 255, 255, 0.08);
}

.range-selector button.active,
.aggregation-selector button.active {
    background: #2f89ff;
    color: #ffffff;
    box-shadow: 0 5px 16px rgba(47, 137, 255, 0.25);
}

.chart-container {
    position: relative;
    height: 460px;
}

.history-meta {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 18px;
}

.history-meta-item {
    min-width: 0;
    padding: 12px 14px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.035);
}

.history-meta-wide {
    grid-column: span 2;
}

.history-meta-item span,
.history-meta-item strong {
    display: block;
}

.history-meta-item span {
    margin-bottom: 5px;
    color: #8fa2b5;
    font-size: 0.73rem;
    font-weight: 650;
    letter-spacing: 0.055em;
    text-transform: uppercase;
}

.history-meta-item strong {
    overflow-wrap: anywhere;
    color: #edf5fc;
    font-size: 0.9rem;
    font-weight: 550;
    line-height: 1.35;
}

.widget-footer {
    margin-top: 14px;
    color: #94a3b8;
    font-size: 0.86rem;
}

@media (max-width: 900px) {
    .widget-header {
        flex-direction: column;
    }

    .widget-controls {
        justify-content: flex-start;
    }

    .history-meta {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .history-meta-wide {
        grid-column: span 2;
    }
}

@media (max-width: 600px) {
    .widget-shell {
        min-height: 100vh;
        padding: 16px;
        border-radius: 0;
    }

    .widget-controls,
    .range-selector,
    .aggregation-selector {
        width: 100%;
    }

    .range-selector,
    .aggregation-selector {
        display: grid;
    }

    .range-selector {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .aggregation-selector {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .chart-container {
        height: 380px;
    }

    .history-meta {
        grid-template-columns: 1fr;
    }

    .history-meta-wide {
        grid-column: auto;
    }
}

.quality-note {
    margin: 10px 0 0;
    padding: 10px 12px;
    border: 1px solid rgba(255, 190, 80, 0.28);
    border-radius: 10px;
    background: rgba(255, 190, 80, 0.08);
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.82rem;
    line-height: 1.4;
}

.quality-note[hidden] {
    display: none;
}
