.kview-chart {
    container-type: inline-size;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.kview-chart--panel,
.kview-chart--compact {
    background: var(--gradient-surface);
    border: 1px solid var(--divider);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-sm);
    padding: clamp(1rem, 2vw, 1.5rem);
}

.kview-chart--compact {
    padding: 1rem;
}

.kview-chart--bare {
    padding: 0;
}

.kview-chart__header {
    display: flex;
    min-width: 0;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.kview-chart__header > div:first-child {
    min-width: 0;
}

.kview-chart__title {
    margin: 0;
    color: var(--text-primary);
    font-family: var(--font-display);
    font-size: clamp(1rem, 1.8vw, 1.2rem);
    font-weight: 700;
    letter-spacing: 0;
    line-height: 1.2;
}

.kview-chart__subtitle {
    max-width: 42rem;
    margin: 0.35rem 0 0;
    color: var(--text-secondary);
    font-size: 0.82rem;
    line-height: 1.45;
}

.kview-chart__summary {
    display: flex;
    flex: 0 0 auto;
    flex-wrap: wrap;
    max-width: 100%;
    align-items: flex-end;
    gap: 0.8rem;
    text-align: right;
}

.kview-chart__metric-label {
    display: block;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    line-height: 1.2;
    text-transform: uppercase;
}

.kview-chart__metric-value {
    display: block;
    margin-top: 0.22rem;
    color: var(--text-primary);
    font-family: var(--font-display);
    font-size: clamp(1.1rem, 2.4vw, 1.5rem);
    font-weight: 750;
    line-height: 1;
}

.kview-chart__legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem 1rem;
    margin: 0 0 0.75rem;
    padding: 0;
    list-style: none;
}

.kview-chart__legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-secondary);
    font-size: 0.76rem;
    font-weight: 650;
    line-height: 1;
}

.kview-chart__legend-line {
    width: 1.45rem;
    height: 0;
    border-top: 2px solid currentColor;
    border-radius: var(--radius-pill);
}

.kview-chart__legend-line--dashed {
    border-top-style: dashed;
}

.kview-chart__legend-line--bar {
    height: 0.55rem;
    border-top: 0;
    border-radius: var(--radius-sm);
    background: currentColor;
}

.kview-chart__canvas {
    position: relative;
    width: 100%;
}

.kview-chart__canvas canvas {
    width: 100% !important;
    height: 100% !important;
}

@container (max-width: 560px) {
    .kview-chart__header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.8rem;
    }

    .kview-chart__summary {
        width: 100%;
        align-items: flex-start;
        justify-content: space-between;
        text-align: left;
    }
}
