:root {
  --bg: #0b0d10;
  --panel: #14181d;
  --panel-2: #1b2027;
  --line: #262d36;
  --ink: #e7ecf2;
  --muted: #8b97a6;
  --accent: #6ee7b7;
  --accent-dim: #2b5a48;
  --warn: #f0b45e;
  --buyer: #7dd3fc;
  --dealerA: #c4b5fd;
  --dealerB: #fca5a5;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
/* a11y: a visible keyboard-focus ring on the dark theme (the browser default is
   near-invisible here), and respect reduced-motion. */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
.mono, .pid, .list.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 14px 22px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.brand { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.brand .dot { color: var(--accent); }
.tag { color: var(--muted); font-style: italic; }
.ledger { margin-left: auto; font-size: 12px; color: var(--muted); }
.ledger.ok { color: var(--accent); }
.ledger.err { color: var(--dealerB); }

.desk {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px;
  background: var(--line); min-height: calc(100vh - 160px);
}
@media (max-width: 900px) { .desk { grid-template-columns: 1fr; } }
.form input { max-width: 100%; }
.panel { background: var(--panel); display: flex; flex-direction: column; }
.panel[data-role="buyer"] { border-top: 3px solid var(--buyer); }
.panel[data-role="dealerA"] { border-top: 3px solid var(--dealerA); }
.panel[data-role="dealerB"] { border-top: 3px solid var(--dealerB); }

.phead {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.who { font-weight: 600; font-size: 15px; }
.pid { color: var(--muted); font-size: 11px; max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pbody { padding: 14px 16px; display: flex; flex-direction: column; gap: 18px; }

.block h3 { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--ink); }
.block h3 .hint { color: var(--muted); font-weight: 400; }
.form { display: flex; flex-direction: column; gap: 8px; }
.form label { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.form input {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--ink);
  padding: 6px 8px; border-radius: 6px; width: 130px; font: inherit;
}
button {
  background: var(--accent); color: #06231a; border: 0; border-radius: 7px;
  padding: 8px 12px; font-weight: 600; cursor: pointer; font: inherit;
}
button:hover { filter: brightness(1.08); }
button:disabled { background: var(--panel-2); color: var(--muted); cursor: not-allowed; }
button.ghost { background: var(--panel-2); color: var(--ink); border: 1px solid var(--line); }
button.award { width: 100%; margin-top: 10px; }

.list { display: flex; flex-direction: column; gap: 8px; }
.empty { color: var(--muted); font-size: 12px; padding: 8px 0; }
.card {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; font-size: 13px;
}
.card .price { font-weight: 700; font-size: 15px; }
.card.win { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-dim) inset; }
.card .row { display: flex; justify-content: space-between; }
.card .sub { color: var(--muted); font-size: 11px; }

.blind {
  border: 1px dashed var(--line); border-radius: 8px; padding: 14px;
  color: var(--muted); font-size: 12px; text-align: center; font-style: italic;
}

.foot { border-top: 1px solid var(--line); background: var(--panel); padding: 14px 22px; }
.privacy-note { color: var(--muted); font-size: 12px; max-width: 900px; }
.reg { margin-top: 8px; font-size: 12px; color: var(--warn); }

.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line); color: var(--ink);
  padding: 10px 16px; border-radius: 8px; font-size: 13px; opacity: 0;
  transition: opacity .2s; pointer-events: none; max-width: 80vw;
}
.toast.show { opacity: 1; }
.toast.err { border-color: var(--dealerB); color: var(--dealerB); }

/* ---- app shell (app.html): Segel-style sidebar + main ---- */
body.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side {
  background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 20px;
  padding: 20px 16px; position: sticky; top: 0; height: 100vh;
}
.side-brand { font-size: 21px; font-weight: 800; letter-spacing: -.02em; color: var(--ink); text-decoration: none; }
.side-brand .dot { color: var(--accent); }
.side-net { font-size: 10.5px; letter-spacing: .12em; color: var(--muted); line-height: 1.7; }
.side-net span { color: #838e9b; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 8px;
  color: var(--muted); font-size: 13.5px; text-decoration: none;
}
.side-nav a .ic { width: 16px; text-align: center; opacity: .8; font-size: 13px; }
.side-nav a:hover { background: var(--panel-2); color: var(--ink); }
.side-nav a.on { background: var(--panel-2); color: var(--ink); box-shadow: inset 2px 0 0 var(--accent); }
.side-sep { height: 1px; background: var(--line); margin: 8px 6px; }
/* In-desk nav: smooth-scroll to a section, leaving a little breathing room at the
   top so it doesn't butt against the topbar. (reduced-motion is honoured by the
   global * { scroll-behavior: auto } rule above.) */
html { scroll-behavior: smooth; }
#top, #nav-rfq, #nav-settle, #nav-audit { scroll-margin-top: 76px; }

/* "How to drive it" guide strip under the stats row. */
.howto { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px;
  padding: 10px 22px; font-size: 12.5px; color: var(--muted);
  background: var(--panel-2); border-bottom: 1px solid var(--line); }
.howto strong { color: var(--ink); font-weight: 600; }
.howto span { display: inline-flex; align-items: center; gap: 7px; }
.howto b { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px;
  border-radius: 50%; background: var(--accent-dim); color: var(--accent); font-size: 11px; font-weight: 700; }
.howto em { color: var(--ink); font-style: normal; font-weight: 600; }
.howto i { color: var(--muted); }
.howto-x { margin-left: auto; background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; padding: 0 4px; }
.howto-x:hover { color: var(--ink); }

/* Audit-trail view (sidebar → Audit trail): the regulator's post-trade record. */
.audit-view { flex: 1; padding: 22px 24px; overflow-y: auto; }
.audit-title { font-size: 17px; font-weight: 600; margin: 0; }
.audit-title .hint { display: block; font-size: 12px; font-weight: 400; color: var(--muted); margin-top: 5px; }
table.audit { width: 100%; border-collapse: collapse; margin-top: 16px; font-size: 13px; }
table.audit th, table.audit td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
table.audit th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
table.audit tbody tr:hover { background: var(--panel-2); }
table.audit td.num { font-family: ui-monospace, Menlo, monospace; text-align: right; }
table.audit td.mode { color: var(--accent); font-size: 12px; }
.audit-empty { color: var(--muted); margin-top: 18px; }

/* Portfolio view: holdings per party, aggregated by instrument. */
.pf-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 18px; }
.pf-col { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.pf-col h3 { margin: 0 0 6px; font-size: 14px; }
.pf-col .pid { display: block; font-size: 11px; color: var(--muted); margin-bottom: 10px; }
.pf-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.pf-row:last-child { border-bottom: 0; }
.pf-row .num { font-family: ui-monospace, Menlo, monospace; }
@media (max-width: 760px) { .pf-grid { grid-template-columns: 1fr; } }

/* Verify-privacy view: a live on-ledger proof. */
.vf-verdict { font-size: 22px; font-weight: 700; color: var(--muted); margin-top: 22px; }
.vf-verdict.ok { color: var(--accent); }
.vf-grid { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; max-width: 1150px; }
.vf-row { display: flex; align-items: center; gap: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px 20px; }
.vf-name { width: 200px; font-weight: 600; color: var(--ink); font-size: 15px; }
.vf-detail { flex: 1; color: var(--muted); font-size: 14px; line-height: 1.5; }
.vf-detail b { color: var(--ink); font-family: ui-monospace, Menlo, monospace; }
.vf-badge { width: 34px; height: 34px; flex-shrink: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 17px; }
.vf-badge.ok { background: var(--accent-dim); color: var(--accent); }
.vf-badge.bad { background: #3a1f1f; color: var(--dealerB); }
.vf-note { margin-top: 22px; max-width: 1050px; color: var(--muted); font-size: 13px; line-height: 1.65; }
.vf-note code { font-family: ui-monospace, Menlo, monospace; color: var(--accent); background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }
/* Out-of-the-box: the "what a public chain would leak" contrast panel. */
.vf-contrast { margin-top: 40px; max-width: 1150px; border-top: 1px solid var(--line); padding-top: 28px; }
.vf-contrast h3 { font-size: 17px; color: var(--ink); margin: 0 0 18px; }
.vf-tally { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.vf-stat { flex: 1; min-width: 260px; display: flex; align-items: center; gap: 16px; border: 1px solid var(--line); border-radius: 10px; padding: 16px 20px; color: var(--muted); font-size: 13.5px; line-height: 1.45; }
.vf-stat .vf-num { font-size: 40px; font-weight: 800; font-family: ui-monospace, Menlo, monospace; line-height: 1; }
.vf-stat.leak { background: #3a1f1f; border-color: #5a2f2f; } .vf-stat.leak .vf-num { color: var(--dealerB); }
.vf-stat.safe { background: var(--accent-dim); border-color: var(--accent-dim); } .vf-stat.safe .vf-num { color: var(--accent); }
.vf-cmp { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.vf-cmp th { text-align: left; color: var(--muted); font-weight: 600; padding: 8px 14px; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.vf-cmp td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.vf-cmp td.k { color: var(--ink); font-weight: 600; width: 30%; }
.vf-cmp td.leak { color: var(--dealerB); }
.vf-cmp td.safe { color: var(--accent); }
/* Provable best-execution view. */
.be-intro { max-width: 1050px; color: var(--muted); font-size: 14px; line-height: 1.6; margin: 18px 0 26px; }
.be-intro b { color: var(--ink); }
.be-card { max-width: 1000px; border: 1px solid var(--line); border-radius: 10px; padding: 16px 20px; margin-bottom: 16px; background: var(--panel); }
.be-card.ok { border-color: var(--accent-dim); }
.be-card.warn { border-color: var(--warn); }
.be-head { font-size: 15px; color: var(--ink); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.be-head .hint { color: var(--muted); font-weight: 400; }
.be-verdict { margin-left: auto; font-size: 12.5px; font-weight: 700; padding: 3px 10px; border-radius: 20px; }
.be-verdict.ok { background: var(--accent-dim); color: var(--accent); }
.be-verdict.warn { background: #3a2f1a; color: var(--warn); }
.be-tbl { width: 100%; border-collapse: collapse; margin: 14px 0 8px; font-size: 13px; }
.be-tbl th { text-align: left; color: var(--muted); font-weight: 600; padding: 6px 12px; border-bottom: 1px solid var(--line); font-size: 12px; }
.be-tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); }
.be-tbl td.num { font-family: ui-monospace, Menlo, monospace; }
.be-tbl tr.be-win td { color: var(--accent); }
.be-tbl tr.be-ok td { color: var(--ink); }
.be-tbl tr.be-bad td { color: var(--dealerB); }
.be-tag { font-size: 10px; background: var(--accent-dim); color: var(--accent); padding: 1px 6px; border-radius: 10px; font-weight: 700; vertical-align: middle; }
.be-note { color: var(--muted); font-size: 12.5px; line-height: 1.6; }
.be-card.none { border-style: dashed; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.side .ledger {
  margin: 0; font-size: 11px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; background: var(--panel-2);
}
.side .ledger::before { content: "● "; color: var(--warn); }
.side .ledger.ok::before { color: var(--accent); }
.side .ledger.err::before { color: var(--dealerB); }
.side-lens { font-size: 11px; color: #838e9b; line-height: 1.5; }

.main { display: flex; flex-direction: column; min-width: 0; }
body.app .topbar { justify-content: space-between; }
.topbar-cta { color: var(--muted); font-size: 12px; text-decoration: none; }
.topbar-cta:hover { color: var(--ink); }
body.app .desk { min-height: 0; flex: 1; }

/* KPI stat tiles — one glanceable dashboard row over live ledger state. */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border-bottom: 1px solid var(--line); }
.stat { background: var(--panel); padding: 11px 16px; display: flex; flex-direction: column; gap: 2px; }
.stat .k { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 19px; font-weight: 700; color: var(--ink); }
.stat .l { font-size: 10.5px; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
@media (max-width: 760px) { .stats { grid-template-columns: repeat(2, 1fr); } }

@media (max-width: 760px) {
  body.app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; }
  .side-net, .side-lens { display: none; }
  .side-nav { flex-direction: row; flex-wrap: wrap; margin-left: auto; }
  .side-foot { margin: 0; }
}

/* ============================================================================
   INSTITUTIONAL BRUTALISM — dark trading-terminal ground, brutalist structure:
   sharp corners, thick bright borders, hard near-black offset shadows, chunky
   uppercase labels, exposed grid.
   ========================================================================== */
:root { --line: #3a4553; --panel-2: #191f28; --shadow: #04060a; }
* { border-radius: 0 !important; }
body { font-weight: 450; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.desk { gap: 2px; } .stats { gap: 2px; }
.topbar { border-bottom: 2px solid var(--line); }
.phead { border-bottom: 2px solid var(--line); }
.stat { border-right: 2px solid var(--line); }
.panel[data-role="buyer"], .panel[data-role="dealerA"], .panel[data-role="dealerB"] { border-top-width: 4px; }
.who { text-transform: uppercase; letter-spacing: .05em; font-weight: 800; }
.block h3 { text-transform: uppercase; letter-spacing: .04em; font-weight: 800; font-size: 12px; }
.stat .k { font-weight: 800; }
.card, .vf-row, .vf-stat, .be-card, .pf-col, .audit table, .side .ledger {
  border: 2px solid var(--line); box-shadow: 4px 4px 0 var(--shadow); }
.card.win { border-color: var(--accent); box-shadow: 4px 4px 0 var(--accent-dim); }
.empty, .blind { border: 2px dashed var(--line); }
.form input, input[type=number], input { border: 2px solid var(--line); background: #0e1319; }
button { border: 2px solid #071410; font-weight: 700; letter-spacing: .01em;
  box-shadow: 3px 3px 0 var(--shadow); transition: transform .05s ease, box-shadow .05s ease; }
button:hover:not(:disabled) { filter: none; transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--shadow); }
button.ghost { border: 2px solid var(--line); box-shadow: 3px 3px 0 var(--shadow); }
button:disabled { box-shadow: 3px 3px 0 var(--shadow); }
.side { border-right: 2px solid var(--line); }
.side-nav a.on { box-shadow: none; border: 2px solid var(--accent); }
.vf-verdict { font-weight: 800; }
.vf-badge { border: 2px solid var(--line); box-shadow: 2px 2px 0 var(--shadow); }
.be-verdict, .be-tag { border: 2px solid var(--line); box-shadow: 2px 2px 0 var(--shadow); font-weight: 800; }
.be-verdict.ok { border-color: var(--accent); }
.toast { border: 2px solid var(--line); box-shadow: 4px 4px 0 var(--shadow); }
