/* Exchange overview (/dashboard/views/exchange.html): a dense, near-black ops console on desktop, stacked cards on a phone.
   Tokens from /dashboard/theme.css. One accent (cyan, --ob-onetap) for the agents series and the live dot; P&L green/red
   only for P&L and Up/Down; no left stripes, no gradients, nothing animates. */
.xv-body {
  --xv-panel: #0b0b0d; --xv-edge: rgba(255, 255, 255, 0.09); --xv-edge-lo: rgba(255, 255, 255, 0.06);
  --xv-acc: var(--ob-onetap, #22b8f0);
  margin: 0; background: #000; color: var(--ob-ink, #fff); font: 400 13px/1.45 var(--ob-sans); -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
.xv-body *, .xv-body *::before, .xv-body *::after { box-sizing: border-box; }
.num, .xv-body table, .xv-body dd { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.xv-body a { color: var(--ob-ink-2); text-decoration: none; }
.xv-body a:hover { color: var(--ob-ink); }
.xv-body a:focus-visible, .xv-body button:focus-visible, .tape:focus-visible { outline: 2px solid var(--ob-focus, rgba(255,255,255,.6)); outline-offset: 1px; border-radius: 4px; }
.dim { color: var(--ob-mute); }
.up { color: var(--ob-up); }
.down { color: var(--ob-down); }
.sm { font-size: 12px; }

/* ---------- header ---------- */
.xv-top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; height: 52px; padding: 0 20px; background: #000; border-bottom: 1px solid var(--xv-edge); }
.xv-brand { display: inline-flex; align-items: center; gap: 8px; color: var(--ob-ink) !important; font-weight: 600; font-size: 14px; flex: none; }
.xv-logo { width: 22px; height: 16px; }
.xv-title { margin: 0; font-size: 14px; font-weight: 510; color: var(--ob-label); padding-left: 16px; border-left: 1px solid var(--xv-edge); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.xv-tr { margin-left: auto; display: flex; align-items: center; gap: 14px; flex: none; }
.xv-link { font: 510 12px/1 var(--ob-sans); color: var(--ob-label) !important; background: none; border: 0; padding: 6px 0; cursor: pointer; white-space: nowrap; }
.xv-link:hover { color: var(--ob-ink) !important; }
.xv-top .sh { display: none; }
.xv-status .lg:empty { display: none; }
.xv-status { display: inline-flex; align-items: center; gap: 6px; font: 510 12px/1 var(--ob-sans); color: var(--ob-label); white-space: nowrap; }
.xv-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ob-dim); flex: none; }
.xv-status.on .xv-dot { background: var(--xv-acc); }
.xv-status.on { color: var(--ob-ink-2); }
.xv-status.bad .xv-dot { background: var(--ob-amber); }
.xv-status.bad { color: var(--ob-amber); }

/* ---------- page ---------- */
.xv { max-width: 1680px; margin: 0 auto; padding: 14px 20px 28px; }
.xv-note { margin: 0 0 12px; padding: 9px 12px; background: var(--xv-panel); border: 1px solid var(--xv-edge); border-radius: 8px; color: var(--ob-label); font-size: 12px; }
.xv-note a { color: var(--ob-ink); }
.xv-foot { margin: 14px 0 0; color: var(--ob-mute); font-size: 11px; }

/* ---------- KPIs ---------- */
.xv-kpis { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 8px; margin-bottom: 8px; }
.xv-hero { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.xv-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.k { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 10px 12px; background: var(--xv-panel); border: 1px solid var(--xv-edge); border-radius: 8px; }
.k .lbl { font-size: 11.5px; font-weight: 510; color: var(--ob-label); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.k .v { font-size: 19px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.k .sub { font-size: 11.5px; color: var(--ob-mute); line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.k.hero { justify-content: center; padding: 14px 16px; }
.k.hero .lbl { font-size: 12.5px; }
.k.hero .v { font-size: 34px; line-height: 1.15; margin: 2px 0; }
.k.hero .sub { font-size: 12px; color: var(--ob-label); }

/* ---------- two columns: the main story (flow, markets, makers, tape) and the side (quotes, health) ---------- */
.xv-grid { display: grid; grid-template-columns: minmax(0, 8fr) minmax(0, 4fr); gap: 8px; align-items: start; }
.col-main, .col-side { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.panel { min-width: 0; background: var(--xv-panel); border: 1px solid var(--xv-edge); border-radius: 8px; padding: 12px 14px 14px; display: flex; flex-direction: column; }
.ph { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; min-height: 28px; margin-bottom: 8px; }
.ph h2 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -0.005em; }
.cnt { font-size: 11.5px; color: var(--ob-mute); }
.cnt.warn { color: var(--ob-amber); }
.h3 { margin: 12px 0 6px; font-size: 12px; font-weight: 600; color: var(--ob-ink-2); display: flex; gap: 8px; align-items: baseline; }
.ctls { display: flex; gap: 8px; flex-wrap: wrap; }
.seg { display: inline-flex; background: #0e0e10; border: 1px solid var(--xv-edge-lo); border-radius: 6px; padding: 2px; gap: 2px; }
.seg button { height: 24px; padding: 0 10px; border: 0; border-radius: 4px; background: transparent; color: var(--ob-label); font: 510 12px/1 var(--ob-sans); cursor: pointer; white-space: nowrap; }
.seg button:hover { color: var(--ob-ink); }
.seg button.on { background: #1c1c20; color: var(--ob-ink); }
.seg button[hidden] { display: none; }
.xv-btn { height: 26px; padding: 0 10px; border: 1px solid var(--xv-edge); border-radius: 6px; background: #0e0e10; color: var(--ob-label); font: 510 12px/1 var(--ob-sans); cursor: pointer; white-space: nowrap; }
.xv-btn:hover { color: var(--ob-ink); background: #151517; }
.xv-btn[aria-pressed="true"] { color: var(--ob-ink); border-color: var(--ob-line-hi); }
.empty { color: var(--ob-mute); font-size: 12px; padding: 14px 2px; }
.empty.sm { padding: 6px 0; }
td.empty { text-align: center; }

/* charts */
.chart { margin: 0; display: flex; flex-direction: column; flex: 1; min-height: 0; }
.chart figcaption { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--ob-label); margin-bottom: 4px; }
.legend { display: inline-flex; gap: 14px; flex-wrap: wrap; }
.legend > span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.sw { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.sw.ag { background: #d4d4d8; } /* r27: neutral (cyan means the 1-tap switch) */
.sw.pp { background: var(--ob-ink-2); }
.cbox { position: relative; height: 280px; overflow: hidden; }
.cbox svg, .sbox svg { display: block; max-width: 100%; height: auto; }
.cbox .empty, .sbox .empty { display: grid; place-items: center; height: 100%; }
.xv-body svg .grid { stroke: rgba(255, 255, 255, 0.06); stroke-width: 1; }
.xv-body svg .ax { fill: var(--ob-mute); font: 400 10.5px var(--ob-sans); font-variant-numeric: tabular-nums; }
.xv-body svg .ax.end { fill: var(--ob-ink-2); font-weight: 600; }
.csub { margin: 6px 0 0; font-size: 12px; color: var(--ob-label); }

/* quote flow */
.spark { padding: 8px 10px; border: 1px solid var(--xv-edge-lo); border-radius: 6px; background: #080809; }
.spark .sh { display: flex; justify-content: space-between; align-items: baseline; }
.spark .lbl { font-size: 11.5px; color: var(--ob-label); font-weight: 510; }
.spark b { font-size: 16px; font-weight: 600; }
.sbox { height: 44px; margin: 4px 0 2px; overflow: hidden; }
.spark .sub { font-size: 11px; color: var(--ob-mute); }
.funnel { margin: 8px 0 0; display: grid; gap: 0; }
.funnel > div { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--xv-edge-lo); }
.funnel dt { color: var(--ob-label); font-size: 12px; white-space: nowrap; flex: none; }
.funnel dd { margin: 0; text-align: right; font-weight: 600; font-size: 13px; white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.funnel dd span { font-weight: 400; font-size: 11px; color: var(--ob-mute); margin-right: 8px; }
.rfqs { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
.rfq { min-width: 0; }
.rfq { padding: 6px 8px; border: 1px solid var(--xv-edge-lo); border-radius: 6px; background: #080809; }
.rfq .r1, .rfq .r2 { display: flex; justify-content: space-between; gap: 8px; min-width: 0; }
.rfq .ct { font-weight: 510; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.rfq .r2 { font-size: 11px; color: var(--ob-mute); margin-top: 1px; flex-wrap: wrap; column-gap: 8px; row-gap: 0; }
.rfq .r2 span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.rfq .r2 span:last-child { white-space: nowrap; }
.st { font-size: 11px; font-weight: 510; color: var(--ob-label); white-space: nowrap; }
.st.filled { color: var(--ob-ok); }
.st.open { color: var(--xv-acc); }

/* tables */
.tw { overflow-x: auto; overscroll-behavior-x: contain; margin: 0 -14px; padding: 0 14px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th { text-align: left; font-weight: 510; font-size: 11.5px; color: var(--ob-label); padding: 6px 8px; border-bottom: 1px solid var(--xv-edge); white-space: nowrap; position: sticky; top: 0; background: var(--xv-panel); }
.tbl td { padding: 6px 8px; border-bottom: 1px solid var(--xv-edge-lo); white-space: nowrap; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: rgba(255, 255, 255, 0.025); }
.tbl .r { text-align: right; }
.tbl th:first-child, .tbl td:first-child { padding-left: 0; }
.tbl th:last-child, .tbl td:last-child { padding-right: 0; }
.tbl .nm { font-weight: 510; }
.tbl .cd { margin-left: 6px; font-size: 11px; color: var(--ob-mute); }
.tbl .tm { max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.xv-body:not(.is-op) .op { display: none; }

/* health */
.hgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.hi { display: flex; flex-direction: column; gap: 1px; padding: 7px 9px; border: 1px solid var(--xv-edge-lo); border-radius: 6px; background: #080809; min-width: 0; }
.hi .lbl { font-size: 11px; color: var(--ob-label); font-weight: 510; }
.hi b { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hi .sub { font-size: 11px; color: var(--ob-mute); line-height: 1.35; overflow-wrap: anywhere; }
.hi.bad b { color: var(--ob-amber); }
.alerts .al { display: grid; grid-template-columns: auto 1fr; gap: 8px; font-size: 11.5px; color: var(--ob-ink-2); padding: 4px 0; border-bottom: 1px solid var(--xv-edge-lo); }
.alerts .al span:first-child { color: var(--ob-mute); }
.alerts p { margin: 10px 0 0; }
.alerts a { color: var(--ob-ink); }

/* live tape: one line a row on wide screens, two on a phone */
.tape { max-height: 440px; overflow-y: auto; overscroll-behavior: contain; margin: 0 -14px; padding: 0 14px; }
.tape .tr { display: grid; grid-template-columns: 82px 36px minmax(0, 1fr) minmax(0, 1.3fr) 64px 84px; column-gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--xv-edge-lo); font-size: 12px; align-items: baseline; }
.tape .tt { color: var(--ob-mute); font-size: 11.5px; white-space: nowrap; }
.tape .kd { font-size: 10.5px; font-weight: 600; color: var(--ob-label); }
.tape .rq .kd { color: var(--ob-ink-2, #d4d4d8); }
.tape .tx { min-width: 0; display: flex; gap: 6px; align-items: baseline; overflow: hidden; }
.tape .tx b { font-weight: 510; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.tape .sd { font-size: 11px; font-weight: 600; color: var(--ob-label); flex: none; }
.tape .sd.up { color: var(--ob-up); }
.tape .sd.down { color: var(--ob-down); }
.tape .who .wn, .tape .who .wt { white-space: nowrap; }
.tape .who { color: var(--ob-mute); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.tape .am { font-weight: 600; text-align: right; white-space: nowrap; }
.tape .am2 { text-align: right; color: var(--ob-mute); font-size: 11.5px; white-space: nowrap; }
.tape .tt { grid-column: 1; } .tape .kd { grid-column: 2; } .tape .tx { grid-column: 3; } .tape .who { grid-column: 4; } .tape .am { grid-column: 5; } .tape .am2 { grid-column: 6; }
.tape .tr > span { grid-row: 1; }
.tg { font-style: normal; font-size: 10px; font-weight: 600; padding: 0 4px; border-radius: 3px; background: rgba(255, 255, 255, 0.07); color: var(--ob-label); }
.tg.ag { color: #d4d4d8; background: #1c1c20; } /* r27: neutral Agent tag */

/* ---------- widths ---------- */
@media (max-width: 1500px) {
  .xv-kpis { grid-template-columns: 1fr; }
  .xv-strip { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .xv-strip .k .v { font-size: 17px; }
}
@media (max-width: 1280px) {
  .xv-strip { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .xv-grid { grid-template-columns: minmax(0, 1fr); }
  .col-main, .col-side { display: contents; }
  #pFlow { order: 1; } #pQuotes { order: 2; } #pMkts { order: 3; } #pHealth { order: 4; } #pMakers { order: 5; } #pTape { order: 6; }
}
@media (max-width: 1280px) and (min-width: 900px) {
  #pQuotes { display: grid; grid-template-columns: 1fr 1fr; column-gap: 16px; align-content: start; }
  #pQuotes > .ph { grid-column: 1 / -1; }
  #pQuotes > .spark, #pQuotes > .funnel { grid-column: 1; }
  #pQuotes > .h3 { grid-column: 2; grid-row: 2; margin-top: 0; align-self: start; }
  #pQuotes > .rfqs { grid-column: 2; grid-row: 2 / span 2; margin-top: 26px; align-self: start; }
  .hgrid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .tape .tr { grid-template-columns: 76px minmax(0, 1fr) auto; row-gap: 1px; }
  .tape .kd { display: none; }
  .tape .tr > span { grid-row: auto; }
  .tape .tt { grid-row: 1; grid-column: 1; }
  .tape .tx { grid-row: 1; grid-column: 2; }
  .tape .am { grid-row: 1; grid-column: 3; }
  .tape .who { grid-row: 2; grid-column: 1 / 3; }
  .tape .am2 { grid-row: 2; grid-column: 3; }
}
@media (max-width: 640px) {
  /* r27 responsive: on a phone nothing in a row is cut. The contract wraps at its spaces (the length and Up/Down always
     show), and the who line wraps between the two names (never "Pers" cut mid-word, never the maker's name lost) */
  .tape .tx { display: block; overflow: visible; }
  .tape .tx b { white-space: normal; overflow: visible; text-overflow: clip; }
  .tape .tx .sd { margin-left: 6px; white-space: nowrap; }
  .tape .who { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 4px; row-gap: 1px; overflow: visible; white-space: normal; }
  .tape .who .wn, .tape .who .wt { flex: none; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .tape .who .tg { flex: none; }
}
@media (max-width: 640px) {
  .xv-top { padding: 0 16px; gap: 10px; }
  .xv-brand span { display: none; }
  .xv-title { padding-left: 10px; font-size: 13px; }
  .xv-top .lg { display: none; }
  .xv-top .sh { display: inline; }
  .xv-tr { margin-left: auto; gap: 12px; }
  .xv { padding: 10px 12px 24px; }
  .xv-hero { grid-template-columns: 1fr; }
  .k.hero .v { font-size: 30px; }
  .xv-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel { padding: 12px; }
  .tw, .tape { margin: 0 -12px; padding: 0 12px; }
  /* a wide table scrolls inside its card; its first column (the market, the maker) stays put so each row still says
     what it is, with a hairline where the scrolled columns pass under it */
  .tw { padding: 0; }
  .tbl th:first-child, .tbl td:first-child { position: sticky; left: 0; z-index: 1; background: var(--xv-panel); box-shadow: 1px 0 0 var(--xv-edge-lo); padding-left: 12px; padding-right: 10px; }
  .tbl th:last-child, .tbl td:last-child { padding-right: 12px; }
  .tbl thead th:first-child { z-index: 2; }
  .cbox { height: 200px; }
  .hgrid { grid-template-columns: 1fr 1fr; }
  .tape { max-height: 460px; }
}
@media (max-width: 400px) {
  .funnel dd span { display: none; }
}
@media (max-width: 380px) {
  .hgrid { grid-template-columns: 1fr; }
  .k .v { font-size: 17px; }
}
/* touch: the bar's links, the chart switches and Pause keep their slim look, each with a 44px tall tap area */
@media (pointer: coarse) {
  .xv-brand, .xv-link, .seg button, #tapePause, #xvSignIn { position: relative; }
  .xv-brand::after, .xv-link::after, .seg button::after, #tapePause::after, #xvSignIn::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 44px; margin-top: -22px; }
}
/* touch (r16 devices): the logo alone on a phone is 22px wide; its tap reaches 44px both ways */
@media (pointer: coarse) { .xv-brand::after { left: -11px; right: -11px; } }

/* r22: links in the public view are plain text with a hover state, never underlined */
.xv-note a, .xv-link, .xv-link .lg { text-decoration: none; }
.xv-note a { color: var(--ob-ink); } .xv-note a:hover, .xv-link:hover .lg { color: var(--ob-ink); text-decoration: none; background: var(--ob-hover, rgba(255,255,255,.06)); border-radius: 4px; }

/* r24 phone pass: no words under 12px on a phone (the desktop keeps its dense 11-11.5px type) */
@media (max-width: 640px) {
  .xv-foot, .k .lbl, .k .sub, .cnt, .spark .lbl, .spark .sub, .funnel dd span, .rfq .r2, .st, .tbl th, .tbl .cd, .hi .lbl, .hi .sub,
  .alerts .al, .tape .tt, .tape .kd, .tape .sd, .tape .who, .tape .am2, .tg { font-size: 12px; }
  .k .sub { white-space: normal; } /* two tiles a row at 320: the note wraps instead of losing its end */
}
/* r27 design pass: 44px tap targets on touch screens for the view's links and copy buttons */
@media (pointer: coarse) { #tabCurl, button.mv-copy { min-height: 44px; } }

/* Proof (dashboard/proof.html): a header link, and on phones (no room in the bar) a footer line instead */
.xv-proof-f { display: none; }
.xv-proof-f a { color: var(--ob-label); text-decoration: underline; text-underline-offset: 3px; }
@media (max-width: 480px) { .xv-proof-h { display: none; } .xv-proof-f { display: block; font-size: 13px; } }
/* r27 responsive: the bar never runs past the screen. Up to 900px the short labels (Maker view, Sign in, Exchange): the long
   ones pushed Operator sign-in off a tablet (667-820); up to 420px the title is for screen readers only and the live
   status is its dot, so Trade, Docs and Maker view fit at 320; up to 700px the title (it was cut to "E…" at 667) */
@media (max-width: 900px) {
  .xv-top .lg { display: none; }
  .xv-top .sh { display: inline; }
  .xv-top { gap: 12px; }
  .xv-tr { gap: 12px; }
}
@media (max-width: 700px) {
  .xv-title { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
}
@media (max-width: 420px) {
  .xv-status #xvLiveT { display: none; }
  .xv-tr { gap: 14px; }
}
/* r27 responsive: a tile's note wraps at every width ("waiting for a second …", "2 contracts open · 9…" at 667-1440) */
.k .sub { white-space: normal; }

/* Narrow phones: RFQ contracts wrap instead of losing their window; status stays top right. */
@media (max-width: 640px) {
  .rfq .r1 { align-items: flex-start; }
  .rfq .ct { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }
  .rfq .st { flex: none; }
}
