:root {
  --bg: #0b0f14; --card: #121821; --line: #1d2632; --line2: #1a222d; --ink: #e6edf3; --ink2: #c3ccd6;
  --muted: #9aa7b4; --blue: #7cb8ff; --orange: #ffa95e; --green: #6ee7a0; --green2: #34d27b;
  --amber: #f5c66b; --violet: #c9a7ff; --teal: #6ee7d8; --sel: #172131;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 13px/1.4 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; }
.wrap { max-width: 1600px; margin: 0 auto; padding: 18px 20px 40px; display: flex; flex-direction: column; gap: 14px; }
h1 { margin: 0; font-size: 20px; letter-spacing: -0.01em; }
h2 { margin: 0; font-size: 14px; font-weight: 600; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill-ok { background: #10261a; color: var(--green); } .pill-wait { background: #2a2414; color: var(--amber); }
.pill-bad { background: #2e1a0f; color: var(--orange); }
.ctl { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
input[type=search] { background: var(--card); color: var(--ink); border: 1px solid #263140; border-radius: 6px; padding: 6px 8px; font: inherit; width: 160px; }
.btn { min-height: 32px; padding: 6px 12px; border-radius: 6px; border: 1px solid #263140; background: var(--card); color: var(--ink); font: 600 12px/1 inherit; cursor: pointer; }
.btn.on { border-color: var(--amber); color: var(--amber); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.kpi .v { font: 600 22px var(--mono); }
.split { display: flex; flex-wrap: wrap; gap: 14px; align-items: stretch; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; display: flex; flex-direction: column; min-width: 0; }
.legs { flex: 999 1 820px; } .tape { flex: 1 1 600px; } .half { flex: 1 1 520px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding: 12px 14px 8px; }
.scroll-x { overflow-x: auto; }
.legs-scroll, .tape-scroll { max-height: 720px; overflow-y: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
.tbl th { color: var(--muted); font-weight: 500; text-align: right; padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; background: var(--card); }
.tbl td { padding: 5px 8px; border-bottom: 1px solid var(--line2); text-align: right; white-space: nowrap; }
.tbl th:first-child, .tbl td:first-child { padding-left: 14px; } .tbl th:last-child, .tbl td:last-child { padding-right: 14px; }
.tbl .l { text-align: left; } .num { font-family: var(--mono); }
#legs-table { min-width: 1020px; }
th .sort { all: unset; cursor: pointer; color: inherit; font: inherit; display: inline-flex; align-items: center; gap: 4px; min-height: 24px; }
th .sort:hover { color: var(--ink); } th .sort:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 3px; }
th[aria-sort="ascending"] .sort, th[aria-sort="descending"] .sort { color: var(--ink); }
th .arrow { font-size: 9px; min-width: 8px; }
.tape-tbl { table-layout: fixed; min-width: 0; }
.tape-tbl .c-time { width: 46px; } .tape-tbl .c-event { width: 88px; } .tape-tbl .c-trade { width: 152px; }
.tape-tbl .c-price { width: 46px; } .tape-tbl .c-now { width: 84px; }
.ev { display: inline-block; padding: 1px 6px; border-radius: 4px; font-size: 11px; font-weight: 600; background: #1a222d; }
.ev-us1 { color: #7cb8ff; } .ev-us2 { color: #9fc5ff; background: #16202c; } .ev-g1 { color: #6ee7d8; }
.ev-g2 { color: #a5efe5; background: #142224; } .ev-views { color: #f5c66b; }
.tape-tbl td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; vertical-align: top; }
.tape-tbl th:first-child, .tape-tbl td:first-child { padding-left: 10px; } .tape-tbl th:last-child, .tape-tbl td:last-child { padding-right: 10px; }
.tape-tbl td, .tape-tbl th { padding-left: 5px; padding-right: 5px; }
.sub { font-size: 10.5px; color: var(--muted); }
.sub-head { padding: 10px 14px 2px; color: var(--muted); font-size: 12px; font-weight: 600; border-top: 1px solid var(--line); }
tr.rec td { background: #0f1f22; }
.leg-btn { all: unset; cursor: pointer; display: flex; flex-direction: column; gap: 1px; min-height: 30px; justify-content: center; }
.leg-btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 3px; }
.leg-btn .t { font-weight: 600; color: var(--ink); white-space: normal; max-width: 230px; }
.leg-btn .s { color: var(--muted); font: 11px var(--mono); }
tr.sel { background: var(--sel); }
.b { color: var(--blue); } .a { color: var(--orange); } .g { color: var(--green); } .am { color: var(--amber); }
.vi { color: var(--violet); } .te { color: var(--teal); } .i2 { color: var(--ink2); }
.flow { display: flex; align-items: center; gap: 6px; }
.flow .bar { display: flex; width: 80px; height: 8px; border-radius: 4px; overflow: hidden; background: var(--line2); }
.flow .bar i { display: block; height: 100%; }
.st { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.st-two { background: #10261a; color: var(--green); } .st-one { background: #2a2414; color: var(--amber); }
.st-none { background: #2e1a0f; color: var(--orange); } .st-closed { background: #1a222d; color: var(--muted); }
.st-unwind { background: #231a33; color: var(--violet); } .st .st-sub { font-weight: 500; opacity: 0.85; }
.st-mm { background: transparent; color: var(--teal); border: 1px solid #1f4a45; font-weight: 500; margin-left: 4px; }
.badge { display: inline-block; text-align: center; border-radius: 4px; font-size: 9.5px; font-weight: 700; letter-spacing: 0.03em; padding: 1px 4px; }
.badge-print { background: #1a222d; color: var(--muted); } .badge-fill { background: #1d4a31; color: var(--green); }
tr.mine { background: #10221a; }
.chips { display: flex; gap: 6px; }
.chip { min-height: 28px; padding: 4px 10px; border-radius: 999px; font: 600 12px inherit; cursor: pointer; border: 1px solid #263140; background: transparent; color: var(--muted); }
.chip.on { border-color: var(--blue); background: #172a42; color: var(--ink); }
.foot { padding: 8px 14px; border-top: 1px solid var(--line); margin-top: auto; }
.stats { display: flex; gap: 14px; flex-wrap: wrap; } .stats b { color: var(--ink); font-family: var(--mono); }
.detail-body { display: flex; flex-wrap: wrap; gap: 16px; padding: 0 14px 14px; }
.ladder-box { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.ladder { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.col { display: flex; flex-direction: column; gap: 3px; }
.lv { position: relative; display: flex; justify-content: space-between; align-items: center; padding: 4px 8px; border-radius: 4px; font: 12px var(--mono); min-height: 22px; }
.lv .bar { position: absolute; top: 0; bottom: 0; border-radius: 4px; }
.lv span { position: relative; } .lv.ours { outline: 1.5px solid var(--green2); outline-offset: -1.5px; }
.chart-box { flex: 2 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; }
.k { display: inline-block; vertical-align: middle; }
.k-mid { width: 14px; height: 2px; background: var(--ink); } .k-band { width: 14px; height: 8px; background: rgba(124,184,255,.16); border: 1px dashed #4b6a8c; }
.k-analyst { width: 14px; border-top: 2px dashed var(--violet); } .k-model { width: 14px; border-top: 2px dashed var(--teal); }
.k-buy, .k-sell { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); } .k-sell { background: var(--orange); }
.k-fill { width: 9px; height: 9px; border: 2px solid var(--green2); transform: rotate(45deg); }
.chart { position: relative; height: 300px; background: #0e131a; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.chart svg { width: 100%; height: 100%; display: block; }
.an { padding: 10px 14px; border-top: 1px solid var(--line2); display: flex; flex-direction: column; gap: 4px; }
.an .h { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.an .r { color: var(--ink2); font-size: 12px; line-height: 1.5; white-space: normal; }
.gap { position: relative; width: 110px; height: 10px; background: var(--line2); border-radius: 5px; }
.gap .mid0 { position: absolute; left: 50%; top: -2px; width: 1px; height: 14px; background: #4a5768; }
.gap i { position: absolute; top: 0; height: 10px; border-radius: 5px; }
.empty { padding: 14px; color: var(--muted); }
footer { line-height: 1.6; }
.meters { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; padding: 0 14px 12px; }
.meter { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.meter .v { font: 600 20px var(--mono); }
.meter .cap { color: var(--muted); font-size: 12px; }
.mbar { position: relative; height: 8px; border-radius: 4px; background: var(--line2); overflow: hidden; }
.mbar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; }
.lvl-ok { background: var(--green2); } .lvl-mid { background: var(--amber); } .lvl-hi { background: var(--orange); }
.lvl-over { background: #ff6b6b; }
.t-ok { color: var(--green); } .t-mid { color: var(--amber); } .t-hi { color: var(--orange); } .t-over { color: #ff8787; }
.capcell { display: flex; align-items: center; gap: 6px; }
.capcell .mbar { width: 46px; height: 6px; }

.legcell { display: flex; align-items: center; gap: 4px; }
.copy-tk { min-width: 24px; min-height: 24px; padding: 2px 6px; border: 1px solid transparent; border-radius: 5px; background: transparent;
  color: var(--muted); font: 12px var(--mono); cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.copy-tk:hover { color: var(--ink); border-color: #263140; background: var(--line2); }
.copy-tk:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.copy-tk.with-text { font-size: 12px; font-weight: 400; vertical-align: middle; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 8px); background: #172a42; color: var(--ink);
  border: 1px solid var(--blue); border-radius: 8px; padding: 8px 14px; font: 12px var(--mono); opacity: 0; pointer-events: none;
  transition: opacity .15s, transform .15s; z-index: 10; max-width: calc(100vw - 32px); overflow-wrap: anywhere; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

/* ── trade flow: the event × title map ─────────────────────────────────────── */
.fscale { display: inline-flex; align-items: center; gap: 6px; }
.fscale i { display: inline-block; width: 90px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, var(--orange), #3a3f47, var(--blue)); }
.fm { padding: 2px 14px 12px; display: flex; flex-direction: column; gap: 8px; }
.fm-row { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 10px; align-items: start; }
.fm-lab { display: flex; flex-direction: column; gap: 3px; padding-top: 6px; }
.fm-lab .num { font-size: 11px; }
.fm-strip { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.fm-quiet { align-self: center; color: var(--muted); font-size: 11px; padding: 0 4px; }
.tile { all: unset; box-sizing: border-box; cursor: pointer; position: relative; min-width: 150px; max-width: 100%; display: flex; flex-direction: column;
  gap: 2px; padding: 0 8px 4px; border: 1px solid var(--line); border-radius: 6px; background: #0e131a; overflow: hidden; }
.tile:hover { border-color: #33445a; }
.tile:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.tile.sel { border-color: var(--ink2); background: var(--sel); }
.tile.filt { box-shadow: 0 0 0 1px var(--amber) inset; }
.tile .tbar { display: flex; height: 4px; margin: 0 -8px 3px; }
.tile .tbar i { display: block; height: 100%; }
.tile .th { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; min-width: 0; }
.tile .tt { font-weight: 600; font-size: 12px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .tpos { font: 700 10.5px var(--mono); color: var(--green); white-space: nowrap; }
.tile .tn { font: 11px var(--mono); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile svg { display: block; width: 100%; height: 30px; margin-top: 1px; }

/* ── the tape, grouped by taker order ──────────────────────────────────────── */
.tape-ctl { gap: 8px; }
.tape-ctl select { background: var(--card); color: var(--ink); border: 1px solid #263140; border-radius: 6px; padding: 4px 6px; font: inherit; }
.tape-leg { flex-basis: 100%; display: flex; }
.tape-leg:empty { display: none; }
.tape-leg .chip { color: var(--amber); border-color: #5a4a23; }
.tape-tbl .c-trade { width: 168px; } .tape-tbl .c-price { width: 64px; } .tape-tbl .c-event { width: 100px; }
.szb { display: inline-block; height: 6px; border-radius: 3px; vertical-align: middle; margin-right: 5px; }
.xp { all: unset; cursor: pointer; display: inline-block; width: 14px; color: var(--muted); text-align: center; }
.xp:hover { color: var(--ink); } .xp:focus-visible { outline: 2px solid var(--blue); border-radius: 3px; }
.xp0 { display: inline-block; width: 14px; }
tr.big td { font-weight: 600; }
tr.kid td { background: #0e141c; color: var(--ink2); font-size: 11px; padding-top: 2px; padding-bottom: 2px; }
tr.kid td.kid-t { padding-left: 24px; }
.tape-tbl .leg-link { all: unset; cursor: pointer; display: block; overflow: hidden; text-overflow: ellipsis; }
.tape-tbl .leg-link:hover { color: var(--blue); text-decoration: underline; }
.tape-tbl .leg-link:focus-visible { outline: 2px solid var(--blue); border-radius: 3px; }
.kpi .ks { white-space: pre-line; }

/* ── the legs table: a row jumped to from the tape or the flow map ─────────── */
#legs tr.flash td { background: #2a2414; box-shadow: inset 0 1px 0 var(--amber), inset 0 -1px 0 var(--amber); transition: background .3s; }
@media (prefers-reduced-motion: reduce) { #legs tr.flash td { transition: none; } }
.tstat { display: flex; min-width: 0; }
.st.st-xs { font-size: 10px; padding: 1px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tape-scroll { max-height: 460px; }

/* ── trade flow tiles: the mid over the window ─────────────────────────────── */
.tile .tmid { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 11px; height: 20px; }
.tile .tmid svg { flex: 1 1 auto; width: auto; min-width: 30px; height: 20px; margin: 0; overflow: visible; }
.tile .tmid .num { flex: none; font-size: 11px; white-space: nowrap; }
.tile .midl { fill: none; stroke: var(--ink2); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.tile .mid0 { stroke: #33445a; stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.tile .mid15 { fill: rgba(124,184,255,.07); }

/* compliance over time, above the trade flow */
.cc { position: relative; padding: 0 14px 8px; }
.cc svg { display: block; width: 100%; height: 112px; overflow: visible; }
.cc .ax { fill: var(--muted); font: 10px var(--mono); }
.cc .grid { stroke: var(--line); stroke-width: 1; }
.cc .goal { stroke: var(--amber); stroke-width: 1; stroke-dasharray: 2 3; opacity: .8; }
.cc .ln { fill: none; stroke-width: 1.8; }
.cc .ln.live { stroke-dasharray: 4 3; stroke-width: 1.6; }
.cc .p-TV { stroke: var(--teal); } .cc .p-Movies { stroke: var(--violet); }
.cc .hair { stroke: var(--ink2); stroke-width: 1; opacity: .5; }
.cc .tip { position: absolute; top: 4px; pointer-events: none; background: var(--sel); border: 1px solid var(--line);
  border-radius: 6px; padding: 4px 8px; font: 11px var(--mono); color: var(--ink); white-space: nowrap; }
.cc-legend { display: flex; gap: 12px; align-items: center; color: var(--muted); }
.cc-legend b { font: 600 13px var(--mono); }
.cc-legend .k-TV { color: var(--teal); } .cc-legend .k-Movies { color: var(--violet); }
.cc .empty { height: 112px; display: flex; align-items: center; justify-content: center; }
/* the compliance card stays at the top of the window while the trade flow below it scrolls */
.flowpair { display: flex; flex-direction: column; gap: inherit; }
#comp-card { position: sticky; top: 0; z-index: 5; box-shadow: 0 6px 14px rgba(0, 0, 0, .45); }
#comp-card .card-head { padding-top: 8px; padding-bottom: 2px; }
