/* ── Strategy Monitor · Trades view (feature #52) ────────────────────────────
   The artifact's Trades tab: one row per signal, its life as a line of steps per
   leg. Its gain / block tones below follow the rates tokens' theme split; its
   neutral tokens are the app's own (--bg, --panel, --text, --text-dim, --border). */
:root { --rm-gain: #4dc48b; --rm-block: #e2a646; }
html.scheme-light { --rm-gain: #17794f; --rm-block: #9a5f06; }
#tr-wrap { --tr-step: 86px; --tr-ring: color-mix(in srgb, var(--rm-success) 28%, transparent); }
/* The filters hide rows and days with the hidden attribute; the display the classes below set
   must not win over it (it did: a .tr-key is a grid, so hidden rows stayed on screen). */
#tr-wrap [hidden], #tg-wrap [hidden] { display: none !important; }
#tr-wrap .gain { color: var(--rm-gain); }
#tr-wrap .loss { color: var(--rm-miss); }
#tr-wrap .block { color: var(--rm-block); }
#tr-wrap .live { color: var(--rm-success); }
#tr-wrap .mono { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-variant-numeric: tabular-nums; }
.tr-range { gap: 10px; }
.tr-date { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-dim); }
.tr-date input { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 3px 6px; }
.tr-sum { margin: 0 0 6px; font-size: 14px; color: var(--text); }
.tr-sum b { font-weight: 600; }

/* Filters: one dropdown per facet, and the "Backtest on all" switch. */
.tr-filters { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; margin: 0 0 12px; }
.tr-fsel { display: flex; flex-direction: column; gap: 4px; }
.tr-fsel label { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-dim); }
.tr-fsel .box { position: relative; }
.tr-fsel .box::after { content: ""; position: absolute; right: 12px; top: 50%; width: 6px; height: 6px; border-right: 1.5px solid var(--text-dim); border-bottom: 1.5px solid var(--text-dim); transform: translateY(-70%) rotate(45deg); pointer-events: none; }
.tr-fsel select { appearance: none; -webkit-appearance: none; font: inherit; font-size: 12.5px; font-weight: 500; color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 6px 30px 6px 10px; cursor: pointer; min-width: 128px; max-width: 100%; }
.tr-fsel select:hover, .tr-fsel select.on { border-color: var(--text); }
.tr-fsel select.on { box-shadow: inset 0 0 0 1px var(--text); }
.tr-ghost { font: inherit; font-size: 12.5px; color: var(--text-dim); background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 6px 8px; cursor: pointer; }
.tr-ghost:hover { color: var(--text); border-color: var(--border); }
.tr-switch { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; background: none; border: 0; padding: 6px 0; font: inherit; font-size: 12.5px; color: var(--text); cursor: pointer; }
.tr-switch .track { width: 30px; height: 17px; border-radius: 999px; background: var(--border); position: relative; transition: background .15s; flex: none; }
.tr-switch .thumb { position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: var(--panel); transition: transform .15s; }
.tr-switch[aria-checked="true"] .track { background: var(--rm-success); }
.tr-switch[aria-checked="true"] .thumb { transform: translateX(13px); }

/* One day, then one row per signal: its id, its lanes, its outcome. */
.tr-day h2 { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-dim); margin: 16px 0 4px; }
.tr-key { display: grid; grid-template-columns: 132px minmax(0, 1fr) minmax(0, 150px); column-gap: 20px; row-gap: 10px; align-items: start; padding: 12px 0; border-top: 1px solid var(--border); }
.tr-k-id { display: flex; flex-direction: column; gap: 1px; }
.tr-k-time { font-size: 17px; font-weight: 600; line-height: 1.3; font-variant-numeric: tabular-nums; color: var(--text); }
.tr-k-side { font-size: 12px; font-weight: 600; margin-left: 6px; }
.tr-k-strat { font-size: 12px; color: var(--text-dim); }
.tr-k-out { text-align: right; display: flex; flex-direction: column; gap: 1px; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text); }
.tr-k-out small { font-weight: 400; font-size: 12px; color: var(--text-dim); }
.tr-k-out small.block { color: var(--rm-block); }
.tr-none { color: var(--text-dim); font-size: 13px; padding-top: 3px; }
.tr-empty { color: var(--text-dim); padding: 20px 0; margin: 0; }

/* The lanes: a row of steps per leg, a child lane dropped from the step that spawned it. */
.tr-lanes { display: flex; flex-direction: column; gap: 10px; overflow-x: auto; padding: 5px 4px 2px; }
.tr-lane { display: flex; position: relative; height: 46px; flex: none; margin-left: calc(var(--at, 0) * var(--tr-step) + var(--half, 0px)); }
.tr-lane.child { --half: calc(var(--tr-step) / 2); }
.tr-lane.child::before { content: ""; position: absolute; left: calc(var(--tr-step) / 2 - 1px); top: calc(-1 * var(--drop)); height: var(--drop); width: 1.5px; background: var(--border); }
.tr-node { width: var(--tr-step); flex: none; position: relative; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; color: var(--text); display: flex; flex-direction: column; align-items: center; gap: 2px; font: inherit; }
.tr-node + .tr-node::before { content: ""; position: absolute; top: 6px; right: 50%; width: 100%; height: 1.5px; background: var(--border); }
.tr-dot { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--text-dim); background: var(--bg); position: relative; z-index: 1; box-sizing: border-box; }
.n-fill .tr-dot { background: var(--text); border-color: var(--text); }
.n-blocked .tr-dot { background: var(--rm-block); border-color: var(--rm-block); }
.n-closed.gain .tr-dot { background: var(--rm-gain); border-color: var(--rm-gain); }
.n-closed.loss .tr-dot { background: var(--rm-miss); border-color: var(--rm-miss); }
.tr-node:hover .tr-dot, .tr-node[aria-expanded="true"] .tr-dot { box-shadow: 0 0 0 4px var(--tr-ring); }
.tr-node[aria-expanded="true"] .tr-nl { text-decoration: underline; text-underline-offset: 3px; }
.tr-nl { font-size: 11.5px; font-weight: 600; line-height: 1.3; white-space: nowrap; }
.n-blocked .tr-nl { color: var(--rm-block); }
.n-closed.gain .tr-nl { color: var(--rm-gain); }
.n-closed.loss .tr-nl { color: var(--rm-miss); }
.tr-nt { font-size: 11px; line-height: 1.2; color: var(--text-dim); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tr-rep { color: var(--rm-block); }

/* A step's detail. */
.tr-detail { grid-column: 2 / -1; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.tr-detail[hidden] { display: none; }
.tr-d-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; }
.tr-d-head strong { font-size: 14px; color: var(--text); }
.tr-d-head span { color: var(--text-dim); font-size: 12px; }
.tr-d-head .tr-x { margin-left: auto; background: none; border: 0; color: var(--text-dim); font-size: 20px; line-height: 1; cursor: pointer; padding: 0 4px; }
.tr-kv { margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 18px; }
.tr-kv div { min-width: 0; }
.tr-kv dt { font-size: 11px; color: var(--text-dim); }
.tr-kv dd { margin: 0; font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; color: var(--text); }
.tr-kv .wide { grid-column: 1 / -1; }
.tr-kv .wide dd { font-size: 11.5px; font-weight: 400; color: var(--text-dim); }
.tr-d-msg { margin: 0; font-size: 12.5px; color: var(--text-dim); max-width: 80ch; overflow-wrap: anywhere; white-space: pre-line; }
.tr-d-kid { font-size: 12px; color: var(--text-dim); border-top: 1px solid var(--border); padding-top: 8px; overflow-wrap: anywhere; }
.tr-d-kid b { color: var(--text); font-weight: 600; }

/* The backtest's trade under the signal, folded until asked for. */
.tr-bt-toggle { grid-column: 2; justify-self: start; display: inline-flex; align-items: center; gap: 8px; font: inherit; font-size: 12.5px; font-weight: 500; color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 4px 12px 4px 9px; cursor: pointer; }
.tr-bt-toggle:hover, .tr-bt-toggle[aria-expanded="true"] { border-color: var(--text); }
.tr-bt-toggle svg { width: 11px; height: 11px; color: var(--rm-success); transition: transform .15s; flex: none; }
.tr-bt-toggle[aria-expanded="true"] svg { transform: rotate(90deg); }
.tr-bt-tag { font-weight: 600; color: var(--rm-success); }
.tr-bt-skip { grid-column: 2; justify-self: start; display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 500; color: var(--text-dim); border: 1px dashed var(--border); border-radius: 6px; padding: 4px 12px; }
.tr-bt-skip .tr-bt-tag { color: var(--text-dim); }
.tr-bt-res { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tr-bt-why { color: var(--text-dim); }
.tr-bt { grid-column: 2 / -1; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.tr-bt[hidden] { display: none; }
.tr-bt-head { font-size: 12px; color: var(--text-dim); }
.tr-bt-head b { color: var(--text); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; margin-right: 6px; }
.tr-bt .tr-dot { border-color: var(--rm-success); background: var(--panel); }
.tr-bt .n-fill .tr-dot { background: var(--rm-success); }
.tr-bt .tr-detail { background: var(--bg); }
.tr-cmp { border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.tr-cmp th { text-align: left; padding: 0 20px 5px 0; font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-dim); border-bottom: 1px solid var(--border); }
.tr-cmp td { text-align: left; padding: 4px 20px 4px 0; border-bottom: 1px solid var(--border); color: var(--text); }
.tr-cmp td:first-child, .tr-cmp td.d { color: var(--text-dim); }
.tr-cmp tr:last-child td { border-bottom: 0; font-weight: 600; }
.vm-scroll { overflow-x: auto; }

@media (max-width: 720px) {
  .tr-key { grid-template-columns: minmax(0, 1fr) auto; }
  .tr-lanes, .tr-detail, .tr-bt, .tr-bt-toggle, .tr-bt-skip { grid-column: 1 / -1; }
  .tr-lanes { grid-row: 2; }
  #tr-wrap { --tr-step: 78px; }
  .tr-switch { margin-left: 0; }
}
/* the executor's replay (sprint 79, H2): its own block under the live lanes, folded like the
   backtest's, and the known-difference tags under the three-side table */
#tr-wrap .tr-dim { color: var(--text-dim); }
.tr-rp-skip { border-style: dotted; }
.tr-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin: 6px 0 2px; }
.tr-tags small { margin-left: 4px; }
.tr-cmp-only { grid-column: 2 / -1; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; min-width: 0; }
/* one card per open step; a second card under the first, separated by a rule */
.tr-d { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.tr-d + .tr-d { border-top: 1px dashed var(--border); padding-top: 10px; }
