/* The Investments performance page (/admin/investments/performance): page-specific styles on top of investments-area.css.
   The period toolbar, the value figures, chart wraps with a busy veil, legends and keys, stat tile grids, the monthly
   returns calendar (heat cells, hatched month in progress), the underwater layout, Growth sources (totals, split bar,
   rows) and the Compare chips. Every color is an --iv-* token; dark mode follows the tokens. */

.ivp { gap: 1rem; }

/* ------------------------------------------------------------------ Period toolbar */

.ivp-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .75rem 1.5rem;
    padding: 12px 16px;
    border: 1px solid var(--iv-border);
    border-radius: 18px;
    background: var(--iv-hero-bg);
    box-shadow: var(--iv-shadow);
}

.ivp-toolbar-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ivp-toolbar-eyebrow { display: inline-flex; align-items: center; gap: .4rem; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--iv-green); }
.ivp-toolbar-range { font-family: var(--tx-font); font-size: 16px; font-weight: 600; color: var(--iv-text); font-variant-numeric: tabular-nums; }
.ivp-toolbar-hint { font-size: 11.5px; line-height: 1.4; color: var(--iv-muted); }
.ivp-range { flex: 0 1 420px; min-width: min(100%, 300px); }

/* ------------------------------------------------------------------ Shared bits */

.ivp-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    min-height: 160px;
    padding: 1.25rem;
    border-radius: 14px;
    background: var(--iv-neutral-soft);
    color: var(--iv-muted);
    font-size: 13px;
    text-align: center;
}

.ivp-empty-glyph { font-size: 20px; color: var(--iv-green); }

.ivp-chart-wrap { position: relative; min-width: 0; }
.ivp-chart { width: 100%; min-width: 0; }
.ivp-chart-wrap.is-busy::after,
.ivp-tiles.is-busy::after,
.ivp-growth-body.is-busy::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 12px;
    background: color-mix(in srgb, var(--tx-surface, #FFFFFF) 55%, transparent);
    animation: ivp-veil .25s ease both;
}

[data-bs-theme="dark"] .ivp-chart-wrap.is-busy::after,
[data-bs-theme="dark"] .ivp-tiles.is-busy::after,
[data-bs-theme="dark"] .ivp-growth-body.is-busy::after { background: rgba(16, 19, 28, .55); }

.ivp-tiles.is-busy,
.ivp-growth-body.is-busy { position: relative; }

@keyframes ivp-veil {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* A color key: a short bar (or dashes) before a legend label; set --ivp-key. */
.ivp-key {
    display: inline-block;
    flex: 0 0 auto;
    width: 14px;
    height: 4px;
    margin-right: 6px;
    border-radius: 2px;
    background: var(--ivp-key, var(--iv-green));
    vertical-align: middle;
}

.ivp-key-dash { background: repeating-linear-gradient(90deg, var(--ivp-key, var(--iv-hero-secondary)) 0 4px, transparent 4px 7px); }

.ivp-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 8px; font-size: 12px; color: var(--iv-muted); }
.ivp-legend-item { display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; }
.ivp-legend-item strong { font-variant-numeric: tabular-nums; }
.ivp-note { margin: 6px 0 0; }

/* The figures over the value chart. */
.ivp-figures { display: flex; flex-wrap: wrap; gap: 10px 28px; margin: 0 0 10px; }
.ivp-figure { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ivp-figure-caption { display: inline-flex; align-items: center; font-size: 10.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--iv-muted); white-space: nowrap; }
.ivp-figure-value { font-family: var(--tx-font); font-size: 20px; font-weight: 600; color: var(--iv-text); white-space: nowrap; }
.ivp-figure-tone { color: var(--iv-tone, var(--iv-text)); }

/* Stat tile grids. */
.ivp-tiles { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ivp-tiles .iv-stat { height: 100%; }
.ivp-tiles-5 { margin-top: 12px; grid-template-columns: repeat(auto-fit, minmax(138px, 1fr)); }
.ivp-tiles-stack { grid-template-columns: minmax(0, 1fr); }

.ivp-risk .iv-card-body { display: flex; flex-direction: column; }
.ivp-risk .ivp-tiles { flex: 1 1 auto; align-content: start; }
.ivp-value .iv-card-body { min-width: 0; }

/* Benchmark chips carry the ticker in a muted second word. */
.ivp-bench-chips { margin: 0 0 12px; }
.ivp-chip-ticker { font-size: 10.5px; font-weight: 700; opacity: .7; }

/* ------------------------------------------------------------------ Monthly returns calendar */

.ivp-cal-scroll { padding-bottom: 4px; border-radius: 12px; }
.ivp-cal-scroll:focus-visible { outline: 2px solid var(--iv-focus); outline-offset: 2px; }

.ivp-cal {
    width: 100%;
    min-width: 780px;
    border-collapse: separate;
    border-spacing: 4px;
    font-variant-numeric: tabular-nums;
}

.ivp-cal th {
    padding: 2px 0 6px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .05em;
    text-align: center;
    text-transform: uppercase;
    color: var(--iv-muted);
}

.ivp-cal th.ivp-cal-year { padding: 0 10px 0 2px; text-align: left; font-size: 12.5px; letter-spacing: 0; color: var(--iv-text); }
.ivp-cal thead th.ivp-cal-year { font-size: 10.5px; letter-spacing: .05em; color: var(--iv-muted); }
.ivp-cal-total-head { text-align: right !important; padding-right: 10px !important; }

.ivp-cal-cell {
    height: 40px;
    padding: 0 4px;
    border-radius: 9px;
    background-color: var(--iv-tile);
    color: var(--iv-text);
    font-size: 11.5px;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    transition: transform .15s ease;
}

.ivp-cal-cell.is-up { background-color: color-mix(in srgb, var(--iv-positive) var(--ivp-heat, 20%), var(--iv-tile)); }
.ivp-cal-cell.is-down { background-color: color-mix(in srgb, var(--iv-negative) var(--ivp-heat, 20%), var(--iv-tile)); }
.ivp-cal-cell.is-strong { color: #FFFFFF; }
.ivp-cal-cell.is-empty { background-color: transparent; box-shadow: inset 0 0 0 1px var(--iv-tile-border); }
.ivp-cal-cell:not(.is-empty):hover { transform: scale(1.04); }

.ivp-cal-cell.is-partial,
.ivp-cal-swatch.is-partial {
    background-image: repeating-linear-gradient(135deg, rgba(255, 255, 255, .42) 0 4px, transparent 4px 9px);
}

[data-bs-theme="dark"] .ivp-cal-cell.is-partial,
[data-bs-theme="dark"] .ivp-cal-swatch.is-partial {
    background-image: repeating-linear-gradient(135deg, rgba(0, 0, 0, .28) 0 4px, transparent 4px 9px);
}

.ivp-cal-total {
    padding: 0 10px;
    border-left: 1px solid var(--iv-tile-border);
    font-size: 12.5px;
    font-weight: 700;
    text-align: right;
    white-space: nowrap;
}

.ivp-cal-total.is-partial::after { content: " *"; color: var(--iv-muted); font-weight: 600; }

.ivp-cal-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; margin-top: 10px; font-size: 11.5px; color: var(--iv-muted); }
.ivp-cal-scale { display: inline-flex; align-items: center; gap: 6px; }
.ivp-cal-ramp { display: inline-block; width: 56px; height: 10px; border-radius: 5px; }
.ivp-cal-ramp-neg { background: linear-gradient(90deg, color-mix(in srgb, var(--iv-negative) 80%, var(--iv-tile)), color-mix(in srgb, var(--iv-negative) 14%, var(--iv-tile))); }
.ivp-cal-ramp-pos { background: linear-gradient(90deg, color-mix(in srgb, var(--iv-positive) 14%, var(--iv-tile)), color-mix(in srgb, var(--iv-positive) 80%, var(--iv-tile))); }
.ivp-cal-hatch-key { display: inline-flex; align-items: center; gap: 6px; }
.ivp-cal-swatch { display: inline-block; width: 18px; height: 12px; border-radius: 4px; background-color: color-mix(in srgb, var(--iv-positive) 40%, var(--iv-tile)); }

/* ------------------------------------------------------------------ Underwater */

.ivp-underwater-body {
    display: grid;
    gap: 1rem;
    grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
    align-items: start;
}

.ivp-underwater-side { display: flex; flex-direction: column; gap: 10px; min-width: 0; }

/* ------------------------------------------------------------------ Growth sources */

.ivp-growth-periods .iv-chip { padding: 3px 10px; }
.ivp-growth-body { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.ivp-growth-totals { display: grid; gap: 8px; grid-template-columns: repeat(3, minmax(0, 1fr)); }

.ivp-growth-total {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    padding: 9px 10px;
    border: 1px solid var(--iv-tile-border);
    border-radius: 12px;
    background: var(--iv-tile);
}

.ivp-growth-value { font-family: var(--tx-font); font-size: 15px; font-weight: 600; color: var(--iv-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.ivp-split {
    display: flex;
    height: 10px;
    overflow: hidden;
    border-radius: 5px;
    background: var(--iv-track);
}

.ivp-split-new { background: var(--iv-interest); transition: width .5s cubic-bezier(.2, .8, .2, 1); }
.ivp-split-market { background: var(--iv-green); transition: width .5s cubic-bezier(.2, .8, .2, 1); }
.ivp-split-market.is-down { background: var(--iv-negative); }
.ivp-growth-narrative { margin: 0; }
.ivp-growth-rows { margin-top: 2px; }
.ivp-growth-row .iv-row-title { flex-wrap: wrap; }
.ivp-growth-row .iv-row-detail { white-space: normal; }

/* ------------------------------------------------------------------ Compare holdings */

.ivp-compare-picks { display: flex; flex-direction: column; gap: 6px; margin: 0 0 12px; }
.ivp-compare-chip .ivp-key { width: 10px; height: 10px; margin-right: 0; border-radius: 50%; }
.ivp-compare-more { border-style: dashed; }
.ivp-compare-legend .ivp-legend-item { padding: 3px 9px; border-radius: 999px; background: var(--iv-neutral-soft); }
.ivp-compare-legend .is-benchmark { background: var(--iv-accent-soft); }

/* ------------------------------------------------------------------ Responsive */

@media (max-width: 1199.98px) {
    .ivp-risk .ivp-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 991.98px) {
    .ivp-risk .ivp-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ivp-underwater-body { grid-template-columns: minmax(0, 1fr); }
    .ivp-underwater-side .ivp-tiles-stack { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 575.98px) {
    .ivp-toolbar { padding: 12px; border-radius: 16px; }
    .ivp-range { flex-basis: 100%; min-width: 0; }
    .ivp-figure-value { font-size: 17px; }
    .ivp-tiles .iv-stat-chip { display: none; }
    .ivp-underwater-side .ivp-tiles-stack { grid-template-columns: minmax(0, 1fr); }
    .ivp-growth-totals { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 399.98px) {
    .ivp-risk .ivp-tiles { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
    .ivp-cal-cell, .ivp-split-new, .ivp-split-market { transition: none; }
    .ivp-cal-cell:not(.is-empty):hover { transform: none; }
    .ivp-chart-wrap.is-busy::after, .ivp-tiles.is-busy::after, .ivp-growth-body.is-busy::after { animation: none; }
}
