@layer components {
    .portfolio-chart-panel {
        width: 100%;
    }

    .portfolio-chart-canvas-wrap {
        height: 15rem;
        position: relative;
        width: 100%;
    }

    .portfolio-chart-tooltip {
        background: var(--dashboard-color-surface);
        border: 1px solid var(--dashboard-color-border);
        border-radius: 0;
        box-shadow: none;
        color: var(--dashboard-color-text);
        left: 0;
        max-width: calc(100% - 1rem);
        min-width: min(14rem, calc(100% - 1rem));
        opacity: 0;
        padding: 0.625rem 0.75rem;
        pointer-events: none;
        position: absolute;
        top: 0;
        transition: opacity 0.08s ease;
        z-index: 2;
    }

    .portfolio-chart-tooltip.is-visible {
        opacity: 1;
    }

    .portfolio-chart-tooltip__title {
        color: var(--dashboard-color-text-subtle);
        font-size: 0.8125rem;
        font-weight: 400;
        line-height: 1.25;
        margin-bottom: 0.5rem;
    }

    .portfolio-chart-tooltip__list {
        display: grid;
        gap: 0.375rem;
        margin: 0;
    }

    .portfolio-chart-tooltip__row {
        align-items: baseline;
        display: grid;
        gap: 0.875rem;
        grid-template-columns: max-content 1fr;
    }

    .portfolio-chart-tooltip__row--summary {
        border-top: 0;
        margin-top: 0.25rem;
        padding-top: 0;
    }

    .portfolio-chart-tooltip__label {
        color: var(--dashboard-color-text-subtle);
        font-size: 0.8125rem;
        font-weight: 400;
        line-height: 1.25;
        margin: 0;
        white-space: nowrap;
    }

    .portfolio-chart-tooltip__value {
        color: var(--dashboard-color-text);
        font-size: 0.8125rem;
        font-variant-numeric: tabular-nums;
        font-weight: 400;
        line-height: 1.25;
        margin: 0;
        text-align: right;
        white-space: nowrap;
    }

    .portfolio-chart-tooltip__value--positive {
        color: var(--dashboard-color-positive);
    }

    .portfolio-chart-tooltip__value--negative {
        color: var(--dashboard-color-negative);
    }

    .portfolio-chart-legend {
        display: flex;
        flex-wrap: wrap;
        gap: 0.75rem 1.5rem;
        justify-content: center;
        margin-top: 1rem;
    }

    .portfolio-chart-legend-item {
        align-items: center;
        background: transparent;
        border: 0;
        color: #475569;
        cursor: pointer;
        display: flex;
        font-size: 0.8125rem;
        font-weight: 500;
        gap: 0.5rem;
        padding: 0;
        transition: color 0.15s ease, opacity 0.15s ease;
    }

    .portfolio-chart-legend-item:hover {
        color: #1e293b;
    }

    .portfolio-chart-legend-label {
        cursor: default;
    }

    .portfolio-chart-legend-item.is-hidden {
        opacity: 0.35;
    }

    .portfolio-chart-legend-swatch {
        border-radius: 9999px;
        flex: 0 0 auto;
        height: 0.1875rem;
        width: 1.5rem;
    }

    .portfolio-chart-legend-swatch-value {
        background: rgb(var(--dashboard-color-brand-rgb));
    }

    .portfolio-chart-legend-swatch-cashflow {
        background: repeating-linear-gradient(
            90deg,
            rgb(var(--dashboard-color-brand-rgb) / 65%) 0,
            rgb(var(--dashboard-color-brand-rgb) / 65%) 5px,
            transparent 5px,
            transparent 9px
        );
    }

    .portfolio-chart-legend-swatch-profit-loss {
        background: linear-gradient(90deg, var(--dashboard-color-positive) 0 50%, var(--dashboard-color-negative) 50% 100%);
    }

    .portfolio-chart-legend-swatch-benchmark {
        background: var(--dashboard-color-benchmark);
    }

    @media (min-width: 48rem) {
        .portfolio-chart-canvas-wrap {
                height: 18rem;
            }
    }
}
