/* Performance-by-Period bar chart -- ported from src/sp5/temp/sp5_holdings_mockup.html */
.sp5-chart-wrap { position: relative; width: 100%; height: 320px; }
.sp5-chart-wrap svg { width: 100%; height: 100%; overflow: visible; }
.sp5-chart-axis-label {
  font-size: 10px;
  fill: var(--sp5-ink-faint);
  font-family: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", Menlo, Consolas, "Liberation Mono", monospace;
}
.sp5-chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--sp5-accent-strong);
  color: #fff;
  font-size: 0.74rem;
  padding: 0.35rem 0.55rem;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, -120%);
  z-index: 3;
}
.sp5-chart-bar { cursor: pointer; }
.sp5-chart-bar--pos { fill: var(--sp5-positive); }
.sp5-chart-bar--neg { fill: var(--sp5-negative); }
.sp5-chart-bar--partial { opacity: 0.45; }
.sp5-chart-bar:hover { opacity: 0.8; }
.sp5-chart-zero-line { stroke: var(--sp5-ink-faint); stroke-width: 1; }

/* --- Allocation Over Time + Breadth chart -- ported from the mockup's
   .alloc-time-*, .alloc-legend, .breadth-* rules --- */
.sp5-breadth-chart-wrap { height: 180px; }
.sp5-breadth-winner { fill: var(--sp5-positive); }
.sp5-breadth-purgatory { fill: var(--sp5-heat-0); }
.sp5-breadth-loser { fill: var(--sp5-negative); }

.sp5-alloc-legend {
  display: flex; align-items: center; gap: 0.3rem; flex-wrap: wrap; font-size: 0.7rem; color: var(--sp5-ink-muted);
}
.sp5-alloc-legend__swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 0.15rem; }

.sp5-alloc-time-grid { display: flex; flex-direction: column; gap: 1px; }
.sp5-alloc-time-row { display: flex; align-items: center; gap: 0.5rem; }
.sp5-alloc-time-label {
  flex-shrink: 0; width: 140px; font-size: 0.64rem; color: var(--sp5-ink-faint); text-align: right;
  font-family: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", Menlo, Consolas, "Liberation Mono", monospace;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sp5-alloc-time-ratio {
  flex-shrink: 0; width: 148px; font-size: 0.64rem; color: var(--sp5-ink-faint); text-align: left;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.sp5-alloc-time-bar {
  display: flex; flex: 1; height: 15px; border-radius: 2px; overflow: hidden;
  background: var(--sp5-surface-alt); cursor: crosshair;
}
.sp5-alloc-time-seg { flex: 1 1 0; min-width: 1px; }

/* --- Gain/Loss by Ticker scroll region -- same pattern as Holdings' Ledger
   (.sp5-ledger-scroll): filter chips + column headers + totals bar all stay
   pinned while just the ticker list scrolls beneath them. Three sticky
   layers stacked here (chips, then head-row, then totals-row) instead of
   Holdings' two, since this table also has a totals summary bar worth
   keeping visible. Offsets are measured in JS (performance.js) since the
   chip row can wrap on narrow viewports, same reasoning as Holdings. */
.sp5-tpnl-scroll {
  max-height: min(70vh, 640px);
  overflow: auto;
  border: 1px solid var(--sp5-border);
  border-radius: 8px;
}
.sp5-tpnl-scroll .sp5-filter-row {
  position: sticky; top: 0; left: 0; z-index: 3;
  background: var(--sp5-surface);
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--sp5-border);
}
/* Cancels sp5.css's base .sp5-table-wrap { overflow-x: auto } -- that alone
   (any non-'visible' overflow-x with overflow-y left at the default) makes
   this a second, nested scroll container that breaks the sticky offsets
   below it. Same bug, same fix, as .sp5-ledger-scroll .sp5-table-wrap. */
.sp5-tpnl-scroll .sp5-table-wrap { overflow-x: visible; }
.sp5-tpnl-scroll .sp5-tpnl-head-row {
  position: sticky; top: var(--sp5-tpnl-filter-row-h, 44px); z-index: 2;
  background: var(--sp5-surface);
  padding-top: 0.5rem; padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--sp5-border);
}
.sp5-tpnl-scroll .sp5-tpnl-totals-row {
  position: sticky; z-index: 1;
  top: calc(var(--sp5-tpnl-filter-row-h, 44px) + var(--sp5-tpnl-head-row-h, 34px));
}

/* --- Gain/Loss by Ticker -- ported from the mockup's .tpnl-* rules --- */
.sp5-tpnl-head-row, .sp5-tpnl-totals-row, .sp5-tpnl-summary {
  display: grid;
  /* Ticker widened 64px -> 110px (was too narrow even just for the symbol,
     let alone an industry-colored pill) and a new 90px column added right
     after it for the Last Close price, which used to be crammed as
     unlabeled inline text inside the Ticker cell itself. */
  grid-template-columns: 110px 90px 100px 190px 1fr 1fr 1fr 150px 116px 170px 116px 170px 150px 22px;
  min-width: 2180px;
  gap: 0.75rem;
}
.sp5-tpnl-head-row {
  padding: 0 0.75rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--sp5-ink-faint);
  font-weight: 600;
}
.sp5-tpnl-totals-row {
  align-items: center;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.35rem;
  font-size: 0.85rem;
  font-weight: 700;
  background: var(--sp5-surface-alt);
  border: 1px solid var(--sp5-border);
  border-radius: 8px;
}
/* Visual break right after Total G/L % -- everything left is gain/loss for the
   selected window, everything right is account composition (cost basis / value
   / % of account), a different kind of number entirely. nth-child(9), not
   (8), now that Last Close price is its own column ahead of it. */
.sp5-tpnl-head-row > :nth-child(9),
.sp5-tpnl-totals-row > :nth-child(9),
.sp5-tpnl-summary > :nth-child(9) {
  border-left: 1px solid var(--sp5-border);
  padding-left: 0.85rem;
  margin-left: 0.1rem;
}
/* Ticker column is wider (110px) than the pill itself -- center it in the
   column instead of hugging the left edge. */
.sp5-tpnl-head-row > :first-child,
.sp5-tpnl-totals-row > :first-child,
.sp5-tpnl-summary > :first-child {
  text-align: center;
}
.sp5-tpnl-list { display: flex; flex-direction: column; gap: 0.35rem; }
.sp5-tpnl-row { border: 1px solid var(--sp5-border); border-radius: 8px; background: var(--sp5-surface); }
.sp5-tpnl-summary {
  cursor: pointer; list-style: none; align-items: center;
  padding: 0.5rem 0.75rem; font-size: 0.85rem; border-radius: 8px;
}
.sp5-tpnl-summary:hover { background: var(--sp5-surface-alt); }
.sp5-tpnl-summary::-webkit-details-marker { display: none; }
.sp5-tpnl-caret {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--sp5-accent-soft); color: var(--sp5-accent); border: 1.5px solid var(--sp5-accent);
  font-size: 0.7rem; transform: rotate(-90deg); transition: transform 200ms ease; justify-self: end;
}
.sp5-tpnl-row[open] > .sp5-tpnl-summary .sp5-tpnl-caret { transform: rotate(0deg); }
.sp5-tpnl-body { padding: 0 0.75rem 0.75rem; border-top: 1px solid var(--sp5-border); margin-top: 0.1rem; }
.sp5-tpnl-empty-note { font-size: 0.8rem; color: var(--sp5-ink-faint); padding: 0.5rem 0; }

.sp5-tx-badge {
  display: inline-flex; align-items: center; padding: 0.15rem 0.5rem; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700;
}
.sp5-tx-badge--buy { background: var(--sp5-accent-soft); color: var(--sp5-accent); }
.sp5-tx-badge--sell { background: var(--sp5-surface-alt); color: var(--sp5-ink-muted); }
