/* ════════════════════════════════════════════════════════════════════
   Positions tab
   ════════════════════════════════════════════════════════════════════ */

/* ── Backtest link (Positions summary table) ───────────────────────── */
.bt-link {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; padding: 2px 8px;
  background: var(--surface-tinted); color: var(--foreground);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  text-decoration: none; cursor: pointer; transition: all .12s;
  font-family: var(--font-mono); text-transform: uppercase; letter-spacing: .08em;
}
.bt-link:hover { background: var(--hover-tint); border-color: var(--ring); }

/* ════════════════════════════════════════════════════════════════════
   Tranche detail — grouped, scannable per-tranche breakdown
   ════════════════════════════════════════════════════════════════════ */

.datatable.tranche-detail { table-layout: auto; }
.datatable.tranche-detail tbody td { border-bottom: none; padding: 8px 12px; }

/* ── Per-deal column subheader (repeats under each deal-group-row) ─── */
.tranche-subhead th {
  text-align: left; font-weight: 500;
  font-size: 10px; color: var(--muted-foreground);
  text-transform: uppercase; letter-spacing: .08em;
  padding: 8px 12px;
  background: transparent;
  border-bottom: 1px solid var(--border);
  font-family: inherit;
}
.tranche-subhead th.num { text-align: right; font-family: var(--font-mono); }
.tranche-subhead th:first-child { padding-left: 18px; }

/* ── Per-deal tbodies — stripe is rendered once per tbody (not per row),
   so one continuous element spans the header and another spans all the
   tranche rows. position:relative on tbody establishes the containing
   block for the absolutely-positioned stripe pseudo. ───────────────── */
.deal-header-tbody, .deal-tranches-tbody { position: relative; }
.deal-header-tbody::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--accent);
}
.deal-tranches-tbody::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--accent); opacity: .3;
}

/* ── Deal-group header row ─────────────────────────────────────────── */
.deal-group-row > td {
  padding: 0 !important;
  background: var(--accent-bg);
  position: relative;
}
.deal-header-tbody:not(:first-of-type) > .deal-group-row > td {
  border-top: 1px solid var(--border);
}
.deal-group-row:hover { background: transparent !important; }
.dgr-wrap {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 12px 14px 12px 18px; flex-wrap: wrap;
}
.dgr-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.dgr-name {
  font-family: var(--font-mono); font-size: 13px; font-weight: 600;
  color: var(--foreground); letter-spacing: .01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dgr-stats {
  display: flex; align-items: center; gap: 22px; flex-wrap: wrap;
  font-family: var(--font-mono);
}
.dgr-stat { display: flex; flex-direction: column; line-height: 1.15; }
.dgr-k {
  font-size: 9px; color: var(--muted-foreground);
  text-transform: uppercase; letter-spacing: .1em;
}
.dgr-v {
  font-size: 13px; color: var(--foreground); font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.dgr-stat.dgr-total .dgr-v { font-weight: 700; }

/* ── Tranche row ───────────────────────────────────────────────────── */
.tranche-row { transition: background .12s; }
.tranche-row > td:first-child { padding-left: 18px; }
.tranche-row.is-last > td { padding-bottom: 12px; }
.tranche-row.is-past { color: var(--muted-foreground); }
.tranche-row.is-past .tr-value strong { color: var(--foreground); }

/* tranche label cell */
.tr-label {
  font-family: var(--font-mono); font-size: 12px;
  white-space: nowrap;
}
.tr-label-text { color: var(--foreground); }
.tr-label-share {
  margin-left: 6px; font-size: 11px;
  color: var(--muted-foreground); font-variant-numeric: tabular-nums;
}
.tranche-row.is-past .tr-label-text { color: var(--muted-foreground); }

/* date cell */
.tr-date { font-family: var(--font-mono); }
.tr-date-main { font-size: 12px; color: var(--foreground); }
.tr-date-rel  { font-size: 10px; color: var(--muted-foreground); margin-top: 2px; }
.tranche-row.is-past .tr-date-main { color: var(--muted-foreground); }

/* tokens cell with share bar */
.tr-tokens { min-width: 160px; font-family: var(--font-mono); }
.tr-tokens-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
}
.tr-tokens-val {
  font-size: 12px; color: var(--foreground);
  font-variant-numeric: tabular-nums; text-align: left;
}
.tr-tokens-pct {
  font-size: 10px; color: var(--muted-foreground);
  font-variant-numeric: tabular-nums; text-align: right;
}
.tranche-row.is-past .tr-tokens-val { color: var(--muted-foreground); }
.tr-tokens-bar {
  margin-top: 4px; height: 3px; width: 100%;
  background: var(--surface-tinted); border-radius: 2px; overflow: hidden;
}
.tr-tokens-bar > span {
  display: block; height: 100%;
  background: var(--accent); opacity: .55;
  transition: width .25s ease;
}

/* status pill */
.tr-pill {
  font-size: 10px; padding: 2px 8px; letter-spacing: .06em;
  text-transform: uppercase; font-weight: 600;
}
.tr-pill-mtm {
  color: var(--muted-foreground);
  background: var(--surface-tinted);
  border-color: var(--border-strong);
}

/* discount column */
.tr-disc { font-size: 12px; color: var(--chart-3); }
.tr-disc.is-zero { color: var(--muted-foreground); }

/* mtm value (informational — what it'd be worth at spot, undiscounted) */
.tr-mtm { font-size: 12px; color: var(--muted-foreground); }

/* unrealized yield — discount expressed in dollars, captured as time passes */
.tr-yield { font-size: 12px; color: var(--profit); }
.tr-yield.is-zero { color: var(--muted-foreground); }
.tranche-row.is-past .tr-yield { color: var(--muted-foreground); }

/* deal-header yield stat picks up the same accent */
.dgr-yield { color: var(--profit); }

/* value column */
.tr-value { font-size: 13px; }
.tr-value strong { font-weight: 600; }

/* hover */
.tranche-row:hover { background: var(--hover-tint); }
