/* The Investments holdings page (/admin/investments/holdings): the summary strip, the view menu, the holdings table
   (symbol cell, price source dot, weight bar, 52-week range, footer totals), the heat map (squarified tiles with
   color levels and a legend), the investment account cards and the broker view. Built on investments-area.css tokens;
   the grids sit inside .admin-shell, so admin-grid.css skins them. Shared by the Activity grids (ivh-grid, ivh-sym,
   ivh-grid-bones, ivh-group-*, ivh-foot-*). */

:root {
    --ivh-heat-base: #E6EBF1;
    --ivh-heat-gap: #FFFFFF;
    --ivh-heat-cash: #CBD5E1;
    --ivh-heat-ink-strong: #FFFFFF;
    --ivh-heat-stripe: rgba(255, 255, 255, .22);
    --ivh-src-live: var(--iv-green);
    --ivh-src-broker: var(--iv-slice-other);
}

[data-bs-theme="dark"] {
    --ivh-heat-base: #1C2333;
    --ivh-heat-gap: #10131C;
    --ivh-heat-cash: #334155;
    --ivh-heat-ink-strong: #F8FAFC;
    --ivh-heat-stripe: rgba(255, 255, 255, .07);
}

.iv-page-holdings .iv-card,
.iv-page-holdings .iv-card-body { min-width: 0; }

/* ------------------------------------------------------------------ Summary strip */

.ivh-tiles {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    min-width: 0;
}

.ivh-tiles .iv-stat { height: 100%; }

@media (max-width: 1399.98px) {
    .ivh-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 767.98px) {
    .ivh-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
}

@media (max-width: 379.98px) {
    .ivh-tiles { grid-template-columns: minmax(0, 1fr); }
}

/* ------------------------------------------------------------------ View menu */

.ivh-viewbar { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; min-width: 0; }
.tx-seg.ivh-views { min-width: min(100%, 640px); }

/* ------------------------------------------------------------------ Grids (table, broker; the Activity grids reuse these) */

.ivh-table-body { min-width: 0; }

/* The holdings table fills a tall card and scrolls inside it (Height="100%" on the grid). */
/* Sized to its rows (--ivh-rows, set by the card) up to a tall window; a long list scrolls inside it. */
.ivh-grid-wrap {
    --ivh-fit: calc(182px + var(--ivh-rows, 12) * 50px);
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: min(72vh, 900px, var(--ivh-fit));
    min-height: min(420px, var(--ivh-fit));
}

.ivh-grid-host { width: 100%; max-width: 100%; min-width: 0; transition: opacity .2s ease; }
.ivh-grid-host.is-refreshing { opacity: .55; }

@media (max-width: 767.98px) {
    .ivh-grid-wrap { height: min(72vh, var(--ivh-fit)); min-height: min(360px, var(--ivh-fit)); }
}

.ivh-grid-bones { padding: 2px 0 6px; }

/* The symbol cell: logo, ticker (a link), owner chip, name, and the row's bell / open buttons. */
.ivh-sym { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ivh-sym-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1 1 auto; }
.ivh-sym-line { display: flex; align-items: center; gap: 6px; min-width: 0; }

.ivh-sym-ticker {
    font-family: var(--tx-font);
    font-size: 13.5px;
    font-weight: 700;
    color: var(--iv-text);
    text-decoration: none;
    white-space: nowrap;
}

.admin-shell .e-grid .e-rowcell a.ivh-sym-ticker { color: var(--iv-text); font-weight: 700; }
.admin-shell .e-grid .e-rowcell a.ivh-sym-ticker:hover { color: var(--iv-green); text-decoration: underline; }
.ivh-sym-name { font-size: 11.5px; line-height: 1.3; color: var(--iv-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ivh-owner { font-size: 9.5px; padding: 0 6px; }

.ivh-row-actions { display: inline-flex; gap: 4px; margin-left: auto; flex: 0 0 auto; opacity: .55; transition: opacity .15s ease; }
.admin-shell .e-grid .e-row:hover .ivh-row-actions,
.ivh-row-actions:focus-within { opacity: 1; }

@media (hover: none) {
    .ivh-row-actions { opacity: 1; }
}

.ivh-row-btn {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 8px;
    background: var(--iv-icon-bg);
    color: var(--iv-icon);
    font-size: 12px;
    cursor: pointer;
    transition: transform .1s ease, filter .15s ease;
}

.ivh-row-btn:hover { filter: brightness(.95); }
.ivh-row-btn:active { transform: scale(.94); }
.ivh-row-btn:focus-visible { outline: 2px solid var(--iv-focus); outline-offset: 1px; }

.ivh-strong { font-weight: 700; }
.ivh-delta { font-weight: 600; }

/* The price with its source: a green dot for a live quote, grey for the broker's price. */
.ivh-price { display: inline-flex; align-items: center; justify-content: flex-end; gap: 6px; }
.ivh-src { display: inline-block; flex: 0 0 auto; width: 7px; height: 7px; border-radius: 50%; background: var(--ivh-src-broker); }
.ivh-src.is-live { background: var(--ivh-src-live); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ivh-src-live) 18%, transparent); }
.ivh-footnote .ivh-src { margin: 0 4px 0 10px; vertical-align: middle; }
.ivh-footnote .ivh-src:first-child { margin-left: 0; }

.ivh-weight { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ivh-weight .iv-bar { flex: 1 1 auto; min-width: 36px; }
.ivh-weight-text { min-width: 48px; font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }

/* 52-week range: a track with a marker, low and high under it. */
.ivh-range { display: flex; flex-direction: column; gap: 5px; min-width: 0; padding-top: 4px; }
.ivh-range .iv-range-track { height: 5px; }
.ivh-range .iv-range-marker { width: 10px; height: 10px; margin: -5px 0 0 -5px; border-color: var(--ag-surface, var(--iv-card)); }
.ivh-range-ends { display: flex; justify-content: space-between; gap: 6px; font-size: 10.5px; color: var(--iv-muted); font-variant-numeric: tabular-nums; }

.ivh-volume { display: inline-flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.ivh-sub { font-size: 10.5px; font-weight: 600; color: var(--iv-muted); }

/* Group captions and footer totals. */
.ivh-group-caption { display: inline-flex; align-items: center; gap: 8px; }
.ivh-group-glyph { color: var(--iv-green); }
.ivh-group-count { font-size: .75rem; font-weight: 600; color: var(--iv-muted); }
.ivh-foot-label { font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--iv-muted); }
.ivh-foot-value { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* The account filter above the table. */
.ivh-filter-row { display: flex; margin: 0 0 10px; }

.ivh-filter-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    padding: 3px 4px 3px 10px;
    border-radius: 999px;
    background: var(--iv-icon-bg);
    color: var(--iv-icon);
    font-size: 12px;
    font-weight: 600;
}

.ivh-filter-pill > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ivh-filter-clear {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

.ivh-filter-clear:hover { background: color-mix(in srgb, var(--iv-icon) 15%, transparent); }
.ivh-filter-clear:focus-visible { outline: 2px solid var(--iv-focus); outline-offset: 1px; }

/* ------------------------------------------------------------------ Heat map */

.ivh-heat {
    position: relative;
    width: 100%;
    border-radius: 16px;
    overflow: hidden;
    background: var(--ivh-heat-gap);
}

.ivh-heat-wide { aspect-ratio: 2.4; }
.ivh-heat-narrow { display: none; aspect-ratio: 1; }

@media (max-width: 767.98px) {
    .ivh-heat-wide { display: none; }
    .ivh-heat-narrow { display: block; }
}

.ivh-tile {
    position: absolute;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 2px;
    margin: 0;
    padding: 8px 9px;
    border: 2px solid var(--ivh-heat-gap);
    border-radius: 10px;
    overflow: hidden;
    background: var(--ivh-heat-bg, var(--ivh-heat-base));
    color: var(--ivh-heat-text, var(--iv-text));
    font-family: var(--tx-font);
    text-align: left;
    cursor: pointer;
    transition: filter .15s ease, box-shadow .15s ease;
}

button.ivh-tile:hover { filter: brightness(1.07) saturate(1.05); z-index: 1; }
button.ivh-tile:focus-visible { outline: 2px solid var(--iv-focus); outline-offset: -4px; z-index: 2; }
.ivh-tile.is-static { cursor: default; }
.ivh-tile-head { display: flex; align-items: center; gap: 6px; min-width: 0; }
.ivh-tile-logo { width: 22px; height: 22px; border-radius: 6px; }
.ivh-tile-symbol { font-size: 13px; font-weight: 700; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ivh-tile-pct { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ivh-tile-value { font-size: 11px; opacity: .85; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ivh-tile.is-lg { padding: 10px 12px; }
.ivh-tile.is-lg .ivh-tile-symbol { font-size: 16px; }
.ivh-tile.is-lg .ivh-tile-pct { font-size: 14px; }
.ivh-tile.is-sm { justify-content: center; padding: 3px 6px; }
.ivh-tile.is-sm .ivh-tile-symbol { font-size: 11px; }
.ivh-tile.is-xs { padding: 0; }

/* Color levels: grey near zero, deeper green up and red down; strong levels carry light ink. */
.ivh-heat-flat { --ivh-heat-bg: var(--ivh-heat-base); --ivh-heat-text: var(--iv-text); }
.ivh-heat-p1 { --ivh-heat-bg: color-mix(in srgb, var(--iv-positive) 20%, var(--ivh-heat-base)); --ivh-heat-text: var(--iv-text); }
.ivh-heat-p2 { --ivh-heat-bg: color-mix(in srgb, var(--iv-positive) 38%, var(--ivh-heat-base)); --ivh-heat-text: var(--iv-text); }
.ivh-heat-p3 { --ivh-heat-bg: color-mix(in srgb, var(--iv-positive) 60%, var(--ivh-heat-base)); --ivh-heat-text: var(--ivh-heat-ink-strong); }
.ivh-heat-p4 { --ivh-heat-bg: color-mix(in srgb, var(--iv-positive) 78%, var(--ivh-heat-base)); --ivh-heat-text: var(--ivh-heat-ink-strong); }
.ivh-heat-p5 { --ivh-heat-bg: color-mix(in srgb, var(--iv-positive) 94%, var(--ivh-heat-base)); --ivh-heat-text: var(--ivh-heat-ink-strong); }
.ivh-heat-n1 { --ivh-heat-bg: color-mix(in srgb, var(--iv-negative) 20%, var(--ivh-heat-base)); --ivh-heat-text: var(--iv-text); }
.ivh-heat-n2 { --ivh-heat-bg: color-mix(in srgb, var(--iv-negative) 38%, var(--ivh-heat-base)); --ivh-heat-text: var(--iv-text); }
.ivh-heat-n3 { --ivh-heat-bg: color-mix(in srgb, var(--iv-negative) 60%, var(--ivh-heat-base)); --ivh-heat-text: var(--ivh-heat-ink-strong); }
.ivh-heat-n4 { --ivh-heat-bg: color-mix(in srgb, var(--iv-negative) 78%, var(--ivh-heat-base)); --ivh-heat-text: var(--ivh-heat-ink-strong); }
.ivh-heat-n5 { --ivh-heat-bg: color-mix(in srgb, var(--iv-negative) 94%, var(--ivh-heat-base)); --ivh-heat-text: var(--ivh-heat-ink-strong); }
.ivh-heat-cash { --ivh-heat-bg: var(--ivh-heat-cash); --ivh-heat-text: var(--iv-text); }
.ivh-heat-other { background-image: repeating-linear-gradient(135deg, transparent 0 7px, var(--ivh-heat-stripe) 7px 14px); }

.ivh-legend {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    font-size: 11px;
    font-weight: 600;
    color: var(--iv-muted);
}

.ivh-legend-scale { display: inline-flex; gap: 2px; }
.ivh-legend-swatch { display: inline-block; width: 18px; height: 10px; border-radius: 3px; background: var(--ivh-heat-bg, var(--ivh-heat-base)); }
.ivh-legend-cash { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; }

@media (max-width: 575.98px) {
    .ivh-legend-swatch { width: 12px; }
}

/* The heat map's loading bones: a rough tree map. */
.ivh-heat-bones {
    display: grid;
    grid-template-columns: 3fr 2fr 1.3fr;
    grid-template-rows: 1fr 1fr;
    gap: 6px;
    aspect-ratio: 2.4;
}

.ivh-heat-bones .dsh-bone { width: 100%; height: 100%; border-radius: 10px; }
.ivh-bone-a { grid-row: 1 / 3; }
.ivh-bone-d { grid-column: 3; grid-row: 1; }
.ivh-bone-e { grid-column: 3; grid-row: 2; }

@media (max-width: 767.98px) {
    .ivh-heat-bones { aspect-ratio: 1; }
}

/* ------------------------------------------------------------------ Account cards */

.ivh-accounts {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr));
    min-width: 0;
}

.ivh-acct {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
    padding: 16px;
    border: 1px solid var(--iv-tile-border);
    border-radius: 16px;
    background: var(--iv-tile);
    transition: border-color .15s ease, box-shadow .15s ease;
}

.ivh-acct:hover { border-color: var(--iv-border); box-shadow: var(--iv-shadow); }
.ivh-acct.is-partner { border-color: color-mix(in srgb, var(--iv-partner) 35%, var(--iv-tile-border)); }
.ivh-acct-bone { gap: 14px; }
.ivh-acct-head { display: flex; align-items: flex-start; gap: 12px; min-width: 0; }
.ivh-acct-titles { display: flex; flex-direction: column; gap: 4px; flex: 1 1 auto; min-width: 0; }

.ivh-acct-name {
    display: flex;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
    margin: 0;
    font-family: var(--tx-font);
    font-size: 15px;
    font-weight: 600;
    color: var(--iv-text);
}

.ivh-acct-name-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ivh-acct-mask { flex: 0 0 auto; font-size: 12px; font-weight: 500; color: var(--iv-muted); }
.ivh-acct-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; color: var(--iv-muted); }
.ivh-acct-inst { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.ivh-acct-value { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 10px; }

.ivh-acct-amount {
    font-family: var(--tx-font);
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -.01em;
    color: var(--iv-text);
    font-variant-numeric: tabular-nums;
}

.ivh-acct-gain { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }

.ivh-acct-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px 12px;
    margin: 0;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--iv-neutral-soft);
}

.ivh-acct-stat { min-width: 0; }
.ivh-acct-stat dt { font-size: 9.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--iv-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ivh-acct-stat dd { margin: 2px 0 0; font-size: 13px; font-weight: 600; color: var(--iv-text); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 399.98px) {
    .ivh-acct-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.ivh-alloc { display: flex; gap: 2px; height: 10px; border-radius: 5px; overflow: hidden; background: var(--iv-track); }
.ivh-alloc-seg { display: block; height: 100%; min-width: 3px; }
.ivh-alloc-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin: -4px 0 0; padding: 0; list-style: none; font-size: 11.5px; color: var(--iv-muted); }
.ivh-alloc-legend li { display: inline-flex; align-items: center; gap: 5px; }
.ivh-alloc-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.ivh-alloc-label { font-weight: 600; color: var(--iv-text); }
.ivh-alloc-share { font-variant-numeric: tabular-nums; }
.ivh-acct-foot { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-top: auto; padding-top: 2px; }
.ivh-fresh { display: inline-flex; align-items: center; gap: 6px; min-width: 0; font-size: 11.5px; color: var(--iv-muted); }
.ivh-fresh-dot { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: var(--iv-tone, var(--iv-slice-other)); }
.ivh-fresh.iv-tone-neutral .ivh-fresh-dot { background: var(--iv-slice-other); }
.ivh-acct-view { min-height: 32px; padding: 4px 12px; font-size: 12.5px; }

/* ------------------------------------------------------------------ Reduced motion */

@media (prefers-reduced-motion: reduce) {
    .ivh-tile, .ivh-row-btn, .ivh-acct, .ivh-grid-host, .ivh-row-actions { transition: none; }
}
