/* ── Investments ─────────────────────────────────────────── */
.investments-summary {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.holding-ticker {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: var(--text-base);
  color: var(--text-bright);
  letter-spacing: 0.03em;
}

.holding-name {
  font-size: var(--text-caption);
  color: var(--muted);
  margin-top: 2px;
}

.holding-type-pill {
  display: inline-block;
  padding: 2px 8px;
  font-size: var(--text-caption);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-radius: 20px;
  background: var(--surface2);
  color: var(--text-dim);
}

.holding-bar-wrap {
  width: 80px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 4px;
}

.holding-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
}

.gain { color: var(--green); }
.loss { color: var(--red); }

/* ── Sortable table headers ──────────────────────────────── */
th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

th.sortable:hover { color: var(--text-bright); }

th.sortable .sort-icon {
  display: inline-block;
  margin-left: 5px;
  font-size: var(--text-caption);
  opacity: 0.35;
  transition: opacity 0.15s, color 0.15s;
}

th.sortable.sort-asc .sort-icon,
th.sortable.sort-desc .sort-icon {
  opacity: 1;
  color: var(--accent);
}

/* ── Holding row ─────────────────────────────────────────── */
tr.holding-row {
  transition: background 0.12s;
}

div.holding-security-cell {
  display: inline-block;
  cursor: pointer;
}
div.holding-security-cell:hover .holding-ticker {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.expand-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: var(--text-caption);
  padding: 4px 6px;
  line-height: 1;
  transition: color 0.15s;
  display: block;
  width: 100%;
}
.expand-btn:hover {
  color: var(--text-bright);
}

tr.holding-subrow td {
  background: var(--subrow-bg);
  padding-top: 8px;
  padding-bottom: 8px;
}
tr.holding-subrow:hover td {
  background: var(--subrow-bg-hover) !important;
}

.holding-subrow-acct {
  font-size: var(--text-sm);
  color: var(--text-dim);
  padding-left: 8px;
  border-left: 2px solid var(--border);
}
.holding-subrow-inst {
  font-size: var(--text-caption);
  color: var(--muted);
  margin-top: 2px;
  padding-left: 10px;
}

/* ── Holding detail modal ────────────────────────────────── */
.modal--wide {
  max-width: 620px !important;
}

.hd-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
}

.hd-ticker {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--text-bright);
  line-height: 1.1;
}

.hd-full-name {
  font-size: var(--text-sm);
  color: var(--muted);
  margin-top: 4px;
  max-width: 380px;
}

.hd-close-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: var(--text-base);
  width: 28px;
  height: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.12s, color 0.12s;
  flex-shrink: 0;
}
.hd-close-btn:hover { border-color: var(--text); color: var(--text); }

.hd-totals {
  display: flex;
  gap: 12px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.hd-total-item {
  flex: 1;
  min-width: 110px;
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 12px 14px;
}

.hd-total-label {
  font-size: var(--text-caption);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 6px;
}

.hd-total-value {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-bright);
  white-space: nowrap;
}

.hd-section-label {
  font-size: var(--text-caption);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 10px;
}

.hd-table-wrap {
  overflow-x: auto;
}

.hd-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
}

.hd-table thead th {
  text-align: left;
  font-size: var(--text-caption);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  padding: 0 10px 8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.hd-table tbody tr {
  border-bottom: 1px solid var(--border);
}
.hd-table tbody tr:last-child { border-bottom: none; }

.hd-table tbody td {
  padding: 12px 10px;
  vertical-align: middle;
}

.hd-acct-name {
  font-weight: 600;
  color: var(--text-bright);
  font-size: var(--text-base);
}

.hd-acct-inst {
  font-size: var(--text-caption);
  color: var(--muted);
  margin-top: 2px;
}

/* ── Holding detail: live stock section ───────────────────── */
.hd-stock-section {
  margin: 16px 0 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px 12px;
}

.hd-stock-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.hd-live-price {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.hd-live-spinner {
  font-size: var(--text-sm);
  color: var(--muted);
}

.hd-price-value {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-bright);
}

.hd-price-change {
  font-size: var(--text-sm);
  font-weight: 600;
}
.hd-price-change.gain { color: var(--green); }
.hd-price-change.loss { color: var(--red); }

.hd-price-asof {
  font-size: var(--text-caption);
  color: var(--muted);
}

.hd-period-tabs {
  display: flex;
  gap: 4px;
}

.hd-period-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: var(--text-caption);
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.hd-period-btn:hover { border-color: var(--text); color: var(--text); }
.hd-period-btn.active { border-color: var(--color-investment); color: var(--color-investment); }
#accountHistoryModal .hd-period-btn.active { border-color: var(--ah-chart-color, var(--color-investment)); color: var(--ah-chart-color, var(--color-investment)); }

.hd-stock-chart-wrap {
  position: relative;
  height: 180px;
}

.hd-stock-error {
  font-size: var(--text-sm);
  color: var(--muted);
  text-align: center;
  padding: 24px 0;
}

.hd-cash-msg {
  font-size: var(--text-base);
  color: var(--muted);
  font-style: italic;
  padding: 16px 0;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.hd-ticker-edit-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: var(--text-md);
  width: 26px;
  height: 26px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.12s, color 0.12s;
  flex-shrink: 0;
}
.hd-ticker-edit-btn:hover { border-color: var(--accent); color: var(--accent); }

.hd-ticker-override-badge {
  font-size: var(--text-caption);
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  border-radius: 4px;
  padding: 2px 8px;
  margin-top: 4px;
  display: inline-block;
}

.hd-ticker-override-form {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
}

.hd-link-ticker-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--accent);
  font-size: var(--text-sm);
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-style: normal;
  transition: border-color 0.12s;
}
.hd-link-ticker-btn:hover { border-color: var(--accent); }

.ticker-override-tag {
  font-size: var(--text-caption);
  color: var(--accent);
  background: var(--accent-dim);
  border-radius: 3px;
  padding: 1px 5px;
  margin-left: 4px;
  font-weight: 500;
  vertical-align: middle;
}

/* ── Holding detail: fundamentals info grid ───────────────── */
.hd-info-grid {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.hd-info-group {
  flex: 1;
  min-width: 150px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}

.hd-info-group-label {
  font-size: var(--text-caption);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 8px;
}

.hd-info-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: var(--text-sm);
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
}
.hd-info-row:last-child { border-bottom: none; }
.hd-info-row span:first-child { color: var(--text-dim); white-space: nowrap; }
.hd-info-row span:last-child  { font-weight: 600; color: var(--text-bright); text-align: right; }

.hd-info-loading {
  font-size: var(--text-sm);
  color: var(--muted);
  padding: 12px 0;
}

.hd-analyst-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: var(--text-caption);
  font-weight: 700;
  text-transform: capitalize;
}

/* ── Ticker override inline form ─────────────────────────── */
.hd-ticker-input {
  text-transform: uppercase;
  width: 130px;
  padding: 6px 10px;
  font-size: var(--text-base);
}

.hd-form-cancel {
  padding: 6px 10px;
  background: transparent;
  color: var(--text-dim);
  border: none;
  cursor: pointer;
  font-size: var(--text-base);
  font-family: var(--font-sans);
  transition: color 0.15s;
}
.hd-form-cancel:hover { color: var(--text); }

/* ── Account history modal ───────────────────────────────── */
.ah-name {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--text-bright);
}
.ah-inst {
  font-size: var(--text-base);
  color: var(--text-dim);
  margin-top: 2px;
}
.ah-no-data {
  text-align: center;
  color: var(--text-dim);
  padding: 40px 0;
  font-size: var(--text-md);
}

/* Auto pay (manual loans/mortgages): schedule + next payment breakdown */
.ah-autopay {
  border-top: 1px solid var(--border);
  margin-top: 20px;
  padding-top: 16px;
}
.ah-autopay[hidden] { display: none; }
.ah-autopay .num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.ah-autopay-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}
.ah-autopay-title {
  font-size: var(--text-caption);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.ah-autopay-edit {
  background: none;
  border: none;
  padding: 0;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--accent-text);
  cursor: pointer;
}
.ah-autopay-edit:hover { text-decoration: underline; }
.ah-autopay-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 12px 20px;
  margin-bottom: 16px;
}
.ah-autopay-label {
  font-size: var(--text-caption);
  color: var(--text-dim);
  margin-bottom: 2px;
}
.ah-autopay-value {
  font-size: var(--text-md);
  color: var(--text-bright);
}
.ah-autopay-next {
  font-size: var(--text-sm);
  color: var(--text);
  margin-bottom: 8px;
}
.ah-autopay-bar {
  display: flex;
  gap: 2px;
  height: 6px;
  margin-bottom: 8px;
}
.ah-autopay-seg { flex-basis: 0; min-width: 3px; }
.ah-autopay-seg.principal, .ah-autopay-key i.principal { background: var(--green); }
.ah-autopay-seg.interest,  .ah-autopay-key i.interest  { background: var(--red); }
.ah-autopay-seg.escrow,    .ah-autopay-key i.escrow    { background: var(--text-dim); }
.ah-autopay-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  font-size: var(--text-sm);
  color: var(--muted);
}
.ah-autopay-key { display: inline-flex; align-items: center; gap: 6px; }
.ah-autopay-key i { width: 8px; height: 8px; display: inline-block; }

/* ── Cost Basis widget ───────────────────────────────────── */
.cb-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 32px;
  padding: 4px 0 16px;
}
.cb-stat-label {
  font-size: var(--text-caption);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.cb-stat-value {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 500;
  color: var(--text-bright);
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
}
.cb-stat-value.gain { color: var(--green); }
.cb-stat-value.loss { color: var(--red); }
.cb-stat-sub {
  font-family: var(--font-mono);
  font-size: var(--text-caption);
  margin-top: 2px;
}
.cb-note {
  font-size: var(--text-sm);
  color: var(--text-dim);
  margin: 0 0 12px;
}
.cb-table-wrap {
  max-height: 320px;
  overflow-y: auto;
}
.cb-table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}
.cb-table-wrap td {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.cb-table-wrap .holding-name,
.cb-partial {
  font-family: var(--font-sans);
}
.cb-partial {
  font-size: 10px;
  color: var(--warning);
  margin-top: 2px;
}

/* ── Dividends & Interest / Contributions widgets ────────── */
.inv-act-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--muted);
  font-size: var(--text-base);
}
.inc-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  font-size: var(--text-sm);
  color: var(--text-dim);
  margin-bottom: 8px;
}
.inc-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.inc-legend-amt {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-bright);
}
.inc-legend-note { color: var(--muted); font-size: var(--text-caption); }
.inc-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}
.inc-chart-wrap { height: 200px; }
.inc-payers {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0 32px;
}
.inc-payer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  min-width: 0;
}
.inc-payer-ticker {
  font-family: var(--font-mono);
  font-size: var(--text-base);
  color: var(--text-bright);
  min-width: 48px;
}
.inc-payer-name {
  flex: 1;
  min-width: 0;
  font-size: var(--text-caption);
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.inc-payer-pct,
.inc-payer-amt {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--text-sm);
}
.inc-payer-pct { color: var(--muted); }
.inc-payer-amt { color: var(--text-bright); min-width: 80px; text-align: right; }

.contrib-group {
  padding: 14px 0;
  border-top: 1px solid var(--border);
}
.contrib-group-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.contrib-group-title {
  font-size: var(--text-caption);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.contrib-group-amt {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--text-lg);
  color: var(--text-bright);
}
.contrib-bar-track {
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
}
.contrib-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
}
.contrib-bar-fill.over { background: var(--warning); }
.contrib-limit-text {
  font-size: var(--text-caption);
  color: var(--text-dim);
  margin: 6px 0 8px;
}
.contrib-limit-text .inv-figure { font-family: var(--font-mono); }
.contrib-over { color: var(--warning); }
.contrib-acct {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: var(--text-sm);
}
.contrib-acct-name {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.contrib-acct-amt {
  margin-left: auto;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
}
.contrib-footnote {
  font-size: var(--text-caption);
  color: var(--muted);
  line-height: 1.5;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
