/* Section total as real <tfoot> — nested flex (never display:flex on <td>) */
#portfolio-panel .ds-holdings-table tfoot.ds-holdings-tfoot {
  display: table-footer-group;
}
#portfolio-panel .ds-holdings-table tfoot.ds-holdings-tfoot[hidden] {
  display: none !important;
}
#portfolio-panel .ds-holdings-table tfoot.ds-holdings-tfoot tr {
  border-top: 1px solid var(--ds-border);
  background: transparent;
}
#portfolio-panel .ds-holdings-table tfoot.ds-holdings-tfoot td.ds-td-total-row {
  padding: 0.55rem 1rem;
  vertical-align: middle;
  font-size: var(--ds-text-body);
  box-sizing: border-box;
  /* Keep table-cell display — flex on <td> breaks colspan width */
}
#portfolio-panel .ds-holdings-table .ds-td-total-inner {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  width: 100%;
  min-width: 0;
}
#portfolio-panel .ds-holdings-table .ds-td-total-label {
  text-align: right;
  font-weight: 600;
  color: var(--ds-text-muted);
  letter-spacing: 0.01em;
  flex: 0 1 auto;
  white-space: nowrap;
}
#portfolio-panel .ds-holdings-table .ds-td-total-value {
  text-align: right;
  font-weight: 600;
  color: var(--ds-text);
  white-space: nowrap;
  flex: 0 0 auto;
}
/* Legacy detached footer (if any remaining outside tables) */
.ds-section-total-footer {
  display: none;
  margin-top: 0;
  padding: 0.5rem 1rem 0.5rem 0.5rem;
  border-top: 1px solid var(--ds-border);
  text-align: right;
  font-size: var(--ds-text-body);
  font-weight: 600;
  color: var(--ds-text);
  font-variant-numeric: tabular-nums;
}
details[open] > .ds-group-body > .ds-section-total-footer:not([hidden]) {
  display: block;
}
/*
 * Hide summary totals only for holdings/group collapsibles (totals live in
 * tfoot / ledger when open). Do NOT apply to History chart stacks
 * (details.ds-chart-stack-section / .ds-chart-stack) — their title totals
 * stay visible when the section is expanded.
 */
details.ds-group[open] > summary .ds-summary-total,
details.ds-subgroup[open] > summary .ds-summary-total {
  visibility: hidden;
}
/*
 * Legacy RE equity list markup kept in DOM for older clients; always hidden.
 * Mobile + desktop use the same #re-table holdings component (priority cols on D1).
 */
.ds-re-equity-list,
.ds-re-equity-list-total {
  display: none !important;
}
@media (max-width: 640px) {
  #portfolio-panel .ds-group--static[data-section="re"] .ds-group-body,
  #portfolio-panel details[data-collapse-key="overview:holdings-re"] .ds-group-body,
  #portfolio-panel details[data-collapse-key="snapshot:holdings-re"] .ds-group-body {
    overflow-x: hidden;
  }
  /* Edit mode: show all RE columns (Property · Bank · Value · Mortgage · Equity) */
  body.portfolio-table-edit #portfolio-panel .ds-re-table col.ds-holdings-col-bank,
  body.portfolio-table-edit #portfolio-panel .ds-re-table col.ds-holdings-col-num:nth-child(3),
  body.portfolio-table-edit #portfolio-panel .ds-re-table col.ds-holdings-col-num:nth-child(4) {
    display: table-column !important;
    width: auto !important;
    max-width: none !important;
    padding: 0 !important;
    border: 0 !important;
  }
  body.portfolio-table-edit #portfolio-panel .ds-re-table .ds-col-bank,
  body.portfolio-table-edit #portfolio-panel .ds-re-table .ds-td-bank,
  body.portfolio-table-edit #portfolio-panel .ds-re-table th.ds-col-num:nth-child(3),
  body.portfolio-table-edit #portfolio-panel .ds-re-table th.ds-col-num:nth-child(4),
  body.portfolio-table-edit #portfolio-panel .ds-re-table td.ds-td-num:nth-child(3),
  body.portfolio-table-edit #portfolio-panel .ds-re-table td.ds-td-num:nth-child(4) {
    display: table-cell !important;
    width: auto !important;
    max-width: none !important;
    padding: 0.5rem 0.5rem !important;
    border: inherit !important;
  }
  body.portfolio-table-edit #portfolio-panel .ds-re-table col.ds-holdings-col-id,
  body.portfolio-table-edit #portfolio-panel .ds-re-table col.ds-holdings-col-num {
    width: auto !important;
  }
}
