/* Process > Trades — "Cumulative" (trades_cumulative.js): backtest vs live
   cumulative P&L in a modal. The shell (backdrop, card, head, filter row,
   presets, skeleton lines) is trades_matrix.css's; this adds the controls,
   the line cards, the chart, the composition panel and the table. Light theme. */

/* A fixed height: a filter change never makes the card jump. */
.cu-card { width: min(1320px, calc(100vw - 48px)); height: calc(100vh - 64px); }

/* Series · units · capital */
.cu-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-dim);
}
.cu-seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.cu-seg button {
  border: 0;
  border-right: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-dim);
  font: inherit;
  font-size: 11px;
  padding: 3px 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.cu-seg button:last-child { border-right: 0; }
.cu-seg button:hover { color: var(--text); background: var(--subtle); }
.cu-seg button[aria-checked="true"] {
  background: color-mix(in srgb, var(--accent) 10%, var(--panel));
  color: var(--text);
  font-weight: 600;
}
.cu-seg small { color: var(--text-dim); font-weight: 400; font-size: 10px; }
.cu-capital { display: inline-flex; align-items: center; gap: 4px; }
.cu-capital input {
  width: 92px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  padding: 2px 4px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
#cu-scope b { color: var(--text); }

/* The list's matrix cell, carried into the modal. */
.cu-cell {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  border: 1px solid var(--accent);
  border-radius: 4px;
}
.cu-cell[hidden] { display: none; }
.cu-cell b { color: var(--text); font-weight: 600; }
.cu-cell button { border: 0; background: none; color: var(--text-dim); cursor: pointer; font-size: 11px; }
.cu-cell button:hover { color: var(--text); }

/* Line swatches: backtest blue, live orange (the Live only badge's colour). */
.cu-sw { display: inline-block; width: 12px; height: 3px; border-radius: 2px; vertical-align: middle; }
.cu-sw.cu-bt { background: #2962ff; }
.cu-sw.cu-live { background: var(--warn); }

.cu-body { overflow: auto; padding: 8px 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.cu-body > * { flex-shrink: 0; }

/* One card per visible line: total, then the facts. */
.cu-legend { display: flex; gap: 10px; flex-wrap: wrap; }
.cu-card-kpi {
  flex: 1 1 320px;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 10px;
  min-height: 58px;
}
.cu-card-kpi.cu-backtest { border-left: 3px solid #2962ff; }
.cu-card-kpi.cu-live { border-left: 3px solid var(--warn); }
.cu-kpi-head { display: flex; align-items: center; gap: 6px; }
.cu-kpi-n { margin-left: auto; color: var(--text-dim); font-size: 11px; }
.cu-kpi-total { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; margin: 2px 0; }
.cu-kpi-total small { margin-left: 8px; font-size: 11px; font-weight: 500; color: var(--text-dim); }
.cu-kpi-facts { display: flex; flex-wrap: wrap; gap: 2px 12px; color: var(--text-dim); font-size: 11px; }
.cu-fact b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.cu-body .up,
.cu-fact b.up { color: var(--up); }
.cu-body .down,
.cu-fact b.down { color: var(--down); }

.cu-plot { min-height: 320px; border: 1px solid var(--border); border-radius: 4px; position: relative; }
.cu-plot-skel {
  position: absolute;
  inset: 12px;
  border-radius: 4px;
  background: var(--subtle);
  animation: mx-pulse 1s ease-in-out infinite alternate;
}
.cu-empty,
.cu-error { margin: 0; padding: 120px 16px; text-align: center; color: var(--text-dim); }
.cu-error { color: var(--down); }

/* Composition: the hovered / pinned trade, both sides. */
.cu-comp { border: 1px solid var(--border); border-radius: 4px; padding: 6px 10px; min-height: 34px; }
.cu-hint { margin: 2px 0; color: var(--text-dim); font-size: 11px; }
.cu-comp-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-variant-numeric: tabular-nums; }
.cu-pos { color: var(--text-dim); font-size: 11px; }
.cu-comp-tools { margin-left: auto; display: inline-flex; gap: 4px; }
.cu-comp-tools button {
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--panel);
  color: var(--text-dim);
  font-size: 11px;
  padding: 2px 8px;
  cursor: pointer;
}
.cu-comp-tools button:hover:not(:disabled) { color: var(--text); background: var(--subtle); }
.cu-comp-tools button:disabled { opacity: 0.4; cursor: default; }
.cu-comp-tools .cu-open { color: var(--accent); border-color: var(--accent); }
.cu-comment {
  margin: 4px 0 0;
  color: var(--text-dim);
  font-style: italic;
  font-size: 11px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.cu-grade.is-agree { color: var(--up); }
.cu-grade.is-disagree { color: var(--down); }
.cu-comp-grid { margin-top: 6px; border-collapse: collapse; font-variant-numeric: tabular-nums; width: 100%; }
.cu-comp-grid th,
.cu-comp-grid td { padding: 2px 16px 2px 0; text-align: left; white-space: nowrap; }
.cu-comp-grid thead th { color: var(--text-dim); font-weight: 500; font-size: 11px; }
.cu-comp-grid tbody th { font-weight: 600; }
.cu-comp-grid td.cu-strong { font-weight: 600; }
.cu-comp-grid td.cu-dim { color: var(--text-dim); }
.cu-comp-grid tr.cu-off { opacity: 0.55; }
.cu-body .c-side.buy { color: var(--buy); font-weight: 600; }
.cu-body .c-side.sell { color: var(--sell); font-weight: 600; }

/* The plotted trades. */
.cu-table-wrap { max-height: 260px; overflow: auto; border: 1px solid var(--border); border-radius: 4px; }
.cu-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.cu-table th,
.cu-table td { padding: 3px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; text-align: left; }
.cu-table thead th {
  position: sticky;
  top: 0;
  background: var(--subtle);
  color: var(--text-dim);
  font-weight: 500;
  font-size: 11px;
  cursor: pointer;
  user-select: none;
}
.cu-table thead th.is-sorted { color: var(--text); }
.cu-table thead th[aria-sort="ascending"]::after { content: " ▲"; font-size: 8px; }
.cu-table thead th[aria-sort="descending"]::after { content: " ▼"; font-size: 8px; }
.cu-table .cu-num { text-align: right; }
.cu-table .cu-cum { font-weight: 600; }
.cu-table td.is-agree { color: var(--up); }
.cu-table td.is-disagree { color: var(--down); }
.cu-row { cursor: pointer; }
.cu-row:hover,
.cu-row.is-focus { background: var(--subtle); }
.cu-row.is-pin { background: color-mix(in srgb, var(--accent) 12%, var(--panel)); }
.cu-skel-row td { padding: 2px 8px; }
