/* Chrome and ink are prop-sidecar's, so the two harnesses that share this
   port also share one visual language. The data-viz roles below are the
   separate thing: a validated categorical set for protocol identity, plus
   one blue/red pair for landed-versus-reverted. Green/red was rejected on
   purpose — the pair measures ΔE 4.1 under deuteranopia, i.e. the single
   most important split on this page would be invisible to a red-green
   colourblind reader. Blue/red measures 25.7 and every chart also carries
   a legend and direct labels, so hue is never the only channel. */
:root {
  --bg: #0b0e14;
  --panel: #131722;
  --panel2: #1a2030;
  --border: #232a3a;
  --line: #2c3450;
  --fg: #d7dce5;
  --muted: #8a93a6;
  --accent: #4da3ff;
  --ok: #3ecf8e;
  --warn: #f5b342;
  --bad: #ff5d5d;
  --chip: #1f2738;

  /* chart surface = --panel; every colour below is validated against it */
  --s-landed: #3987e5;
  --s-reverted: #d03b3b;
  --s-single: #3987e5;
  --p-kamino: #d95926;
  --p-marginfi: #199e70;
  --p-drift: #c98500;
  --p-solend: #d55181;
  --p-juplend: #4f8fe6;
  --grid: #232a3a;
  --axis: #2c3450;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font:
    13px/1.5 ui-sans-serif,
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;
}
a {
  color: var(--accent);
  text-decoration: none;
}
code,
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(180deg, #131722, #0f1320);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.brand {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.3px;
}
.brand span {
  color: var(--accent);
}
.topstats {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-left: auto;
  align-items: center;
}
.tstat {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.tstat .l {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.tstat .v {
  font-weight: 600;
}
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}
.dot.ok {
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
}
.dot.bad {
  background: var(--bad);
  box-shadow: 0 0 8px var(--bad);
}
.dot.warn {
  background: var(--warn);
  box-shadow: 0 0 8px var(--warn);
}

button,
select,
input {
  font: inherit;
  color: var(--fg);
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 10px;
}
button {
  cursor: pointer;
}
button:hover {
  border-color: var(--accent);
}
button.primary {
  background: var(--accent);
  color: #06101f;
  border-color: var(--accent);
  font-weight: 600;
}
button.ghost {
  background: transparent;
}
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

main {
  padding: 16px;
  max-width: 1600px;
  margin: 0 auto;
}
.grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  margin-bottom: 14px;
}
.two {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 1100px) {
  .two {
    grid-template-columns: 1fr;
  }
}
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}
.card h3 {
  margin: 0 0 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  font-weight: 600;
}
.card .big {
  font-size: 24px;
  font-weight: 700;
}
.card .sub {
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}
.pos {
  color: var(--ok);
}
.neg {
  color: var(--bad);
}
.warnc {
  color: var(--warn);
}

/* Our capture against the field. Our number is a status: green when we
   are up, red when we are down, muted at zero. The field is not a
   status, so it wears the accent, never green or red. */
section.block.hero .hero-row {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
  align-items: flex-start;
  margin-bottom: 12px;
}
.hero-main {
  min-width: 280px;
}
.hero-value {
  font-size: 56px;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}
.hero-value.pos {
  color: var(--ok);
}
.hero-value.neg {
  color: var(--bad);
}
.hero-value.flat {
  color: var(--muted);
}
.hero-sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
}
.hero-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  flex: 1;
  min-width: 260px;
}
.kpi {
  display: flex;
  flex-direction: column;
  border-left: 2px solid var(--border);
  padding-left: 12px;
}
.kpi .l {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.kpi .v {
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.kpi .v.field {
  color: var(--accent);
}
.kpi .s {
  color: var(--muted);
  font-size: 11px;
}

section.block {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 14px;
}
section.block > h2 {
  margin: 0 0 12px;
  font-size: 13px;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
section.block > h2 .tag {
  color: var(--muted);
  font-weight: 400;
  font-size: 11px;
}

table {
  width: 100%;
  border-collapse: collapse;
}
.datatable {
  font-size: 12px;
}
.datatable th,
.datatable td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}
.datatable th {
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.5px;
}
.datatable th.sortable {
  cursor: pointer;
  user-select: none;
}
.datatable th.sortable:hover {
  color: var(--fg);
}
.datatable th.sorted::after {
  content: " ▾";
  color: var(--accent);
}
.datatable tbody tr:hover {
  background: var(--panel2);
}
.datatable td.num,
.datatable th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.datatable tr.rowlink {
  cursor: pointer;
}
.datatable tr.silent td {
  color: var(--warn);
}
.scrollx {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.scrolly {
  max-height: 480px;
  overflow-y: auto;
}

.chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--muted);
  font-size: 11px;
}
.chip.on {
  background: rgba(62, 207, 142, 0.15);
  color: var(--ok);
}
.chip.off {
  background: rgba(255, 93, 93, 0.15);
  color: var(--bad);
}
.chip.gated {
  background: rgba(245, 179, 66, 0.15);
  color: var(--warn);
}
/* Protocol identity: a 8px dot in the validated categorical hue plus the
   name, so the colour is never the only thing carrying it. */
.pb {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1;
  white-space: nowrap;
}
.pb > i {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex: 0 0 8px;
  display: block;
}

.pk {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--chip);
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  border: 1px solid transparent;
}
.pk:hover {
  color: var(--fg);
  border-color: var(--line);
}
.pk.copied {
  background: rgba(62, 207, 142, 0.18);
  color: var(--ok);
}
#toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--chip);
  color: var(--fg);
  border: 1px solid var(--line);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 60;
}
#toast.show {
  opacity: 1;
}

/* --- tabs ----------------------------------------------------------- */
/* One question per tab. The header stays; the body shows one panel at a
   time so a reader lands on "how are we doing" and drills down on
   purpose rather than scrolling through everything. */
.tabbar {
  display: flex;
  gap: 2px;
  flex-basis: 100%;
  border-top: 1px solid var(--border);
  margin-top: 4px;
  padding-top: 4px;
  overflow-x: auto;
}
.tabbar button {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px 8px 0 0;
  color: var(--muted);
  padding: 7px 14px;
  font-weight: 600;
  font-size: 12.5px;
  letter-spacing: 0.2px;
  white-space: nowrap;
}
.tabbar button:hover {
  color: var(--fg);
  border-color: transparent;
  background: var(--panel2);
}
.tabbar button.active {
  color: var(--fg);
  background: var(--panel);
  border-color: var(--border);
  border-bottom-color: var(--panel);
  box-shadow: inset 0 2px 0 var(--accent);
}
.tabbar button .n {
  color: var(--muted);
  font-weight: 400;
  margin-left: 6px;
  font-variant-numeric: tabular-nums;
}
.tab {
  display: none;
}
.tab.active {
  display: block;
}
.tab-intro {
  color: var(--muted);
  font-size: 12px;
  margin: 2px 0 14px;
}
/* Anything that names an on-chain address or signature copies on click:
   the `.pk` chip and any cell carrying `data-copy`. */
[data-copy] {
  cursor: pointer;
}
[data-copy]:hover {
  color: var(--fg);
  text-decoration: underline dotted var(--line);
}
[data-copy].copied {
  color: var(--ok);
}

/* --- live gate ------------------------------------------------------ */
.tune-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}
.tune {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--panel2);
}
.tune .k {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-bottom: 6px;
}
.tune .row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.tune input {
  width: 120px;
  font-variant-numeric: tabular-nums;
}
.tune .cfg {
  color: var(--muted);
  font-size: 11px;
  margin-top: 6px;
}
.tune.overridden {
  border-color: var(--warn);
}
.tune.overridden .cfg {
  color: var(--warn);
}

/* --- charts --------------------------------------------------------- */
.chartbox {
  position: relative;
  width: 100%;
}
.chartbox svg {
  display: block;
  width: 100%;
}
.chartbox .empty {
  color: var(--muted);
  font-size: 12px;
  padding: 28px 4px;
  text-align: center;
}
.legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: center;
  color: var(--muted);
  font-size: 11px;
}
.legend .k {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend .k i {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: block;
}
#tip {
  position: fixed;
  z-index: 70;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.08s;
  background: #0d1220;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 11.5px;
  line-height: 1.5;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  max-width: 320px;
}
#tip.show {
  opacity: 1;
}
#tip .t {
  color: var(--muted);
  margin-bottom: 3px;
}
#tip .r {
  display: flex;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}
#tip .r i {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  display: block;
}

#gate {
  position: fixed;
  inset: 0;
  background: rgba(7, 10, 16, 0.95);
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
}
#gate.show {
  display: flex;
}
#gate .box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  width: 340px;
}
#gate h1 {
  font-size: 16px;
  margin: 0 0 6px;
}
#gate p {
  color: var(--muted);
  font-size: 12px;
  margin: 0 0 14px;
}
#gate input {
  width: 100%;
  margin-bottom: 10px;
}
.err {
  color: var(--bad);
  font-size: 12px;
  min-height: 18px;
}

#errBanner:not(:empty) {
  background: rgba(255, 93, 93, 0.12);
  border: 1px solid var(--bad);
  color: var(--bad);
  padding: 8px 12px;
  border-radius: 10px;
  margin-bottom: 12px;
  font-size: 12px;
}
#noteBanner:not(:empty) {
  background: rgba(245, 179, 66, 0.1);
  border: 1px solid var(--warn);
  color: var(--warn);
  padding: 8px 12px;
  border-radius: 10px;
  margin-bottom: 12px;
  font-size: 12px;
}
footer {
  color: var(--muted);
  font-size: 11px;
  margin-top: 18px;
  text-align: center;
}
.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 10px;
}
.filters .spacer {
  margin-left: auto;
}
.muted {
  color: var(--muted);
}
.note {
  color: var(--muted);
  font-size: 11px;
  margin-top: 8px;
}

/* Line detail: the whole tape record, since every layout decision on it is
   meant to be reversible from the raw fields. */
#drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(620px, 100%);
  background: var(--panel);
  border-left: 1px solid var(--line);
  z-index: 65;
  transform: translateX(100%);
  transition: transform 0.16s ease-out;
  display: flex;
  flex-direction: column;
}
#drawer.show {
  transform: translateX(0);
}
#drawer header {
  position: static;
  justify-content: space-between;
}
#drawer pre {
  margin: 0;
  padding: 14px;
  overflow: auto;
  font-size: 11.5px;
  white-space: pre-wrap;
  word-break: break-all;
  flex: 1;
}

/* --- execution desk ------------------------------------------------ */
:root {
  --bg: #07090d;
  --panel: #0d1118;
  --panel2: #121823;
  --border: #202735;
  --line: #303a4d;
  --fg: #e7eaf0;
  --muted: #808a9a;
  --accent: #d9ab4c;
  --ok: #2fd0a0;
  --warn: #e8aa45;
  --bad: #ff6170;
  --chip: #171e2a;
  --grid: #1d2430;
  --axis: #394357;
}
body {
  background:
    radial-gradient(circle at 70% -20%, rgba(70, 89, 120, 0.12), transparent 38%),
    var(--bg);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.025;
  background-image: linear-gradient(rgba(255,255,255,.25) 1px, transparent 1px);
  background-size: 100% 4px;
  z-index: 100;
}
body > header {
  padding: 0;
  gap: 0;
  background: rgba(8, 11, 16, 0.96);
  backdrop-filter: blur(18px);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.25);
}
.desk-head {
  width: 100%;
  min-height: 58px;
  padding: 9px 18px;
  display: flex;
  align-items: center;
  gap: 18px;
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  white-space: nowrap;
}
.brand-mark {
  width: 28px;
  height: 28px;
  display: block;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid rgba(217, 171, 76, 0.55);
  background: rgba(217, 171, 76, 0.06);
}
.brand-title { color: var(--fg); }
.brand-title span { color: var(--accent); }
.brand-sub {
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 1.2px;
  margin-top: 2px;
}
.topstats {
  gap: 20px;
  flex: 1;
  justify-content: flex-end;
}
.tstat {
  min-width: 70px;
  padding-left: 11px;
  border-left: 1px solid var(--border);
}
.tstat .l {
  color: #6f7989;
  font-size: 9px;
  letter-spacing: 0.9px;
}
.tstat .v { font-size: 11px; }
button, select, input {
  border-radius: 3px;
  border-color: #2a3343;
  background: #111722;
}
button:hover, select:hover, input:hover { border-color: #566176; }
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #11100c;
}
button.danger {
  color: #ffd9dd;
  border-color: rgba(255, 97, 112, 0.55);
  background: rgba(255, 97, 112, 0.1);
}
.tabbar {
  width: 100%;
  margin: 0;
  padding: 0 18px;
  gap: 24px;
  background: #090d13;
}
.tabbar button {
  padding: 11px 1px 10px;
  border-bottom-width: 2px;
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.tabbar button.active {
  color: var(--fg);
  border-color: var(--accent);
}
main {
  max-width: 1840px;
  padding: 14px 18px 28px;
}
.risk-strip {
  display: grid;
  grid-template-columns: minmax(210px, 1.45fr) repeat(4, minmax(130px, 0.75fr));
  margin-bottom: 12px;
  border: 1px solid var(--border);
  background: #0a0e14;
}
.risk-cell {
  min-height: 64px;
  padding: 10px 13px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.risk-cell:last-child { border-right: 0; }
.risk-cell .label {
  color: #707a8b;
  font-size: 9px;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.risk-cell .value {
  margin-top: 2px;
  color: var(--fg);
  font: 600 17px/1.25 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.risk-cell .detail { color: var(--muted); font-size: 10px; margin-top: 2px; }
.risk-mode { border-left: 3px solid var(--muted); }
.risk-mode.live {
  border-left-color: var(--bad);
  background: linear-gradient(90deg, rgba(255, 97, 112, 0.09), transparent 60%);
}
.risk-mode.shadow { border-left-color: var(--warn); }
.risk-mode.off { border-left-color: #596274; }
.risk-mode.live .value { color: var(--bad); }
.risk-mode.shadow .value { color: var(--warn); }
.grid {
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.card, section.block {
  border-radius: 4px;
  background: linear-gradient(180deg, #0f141c, #0c1118);
  box-shadow: none;
}
.card {
  min-height: 106px;
  padding: 13px 14px 12px;
  border-top: 2px solid #30394a;
}
.card.money { border-top-color: var(--accent); }
.card.loss { border-top-color: var(--bad); }
.card.quality { border-top-color: var(--ok); }
.card h3 {
  font-size: 9px;
  letter-spacing: 1px;
  margin-bottom: 9px;
}
.card .big {
  font: 650 27px/1.1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: -0.8px;
}
.card .sub { font-size: 10px; margin-top: 7px; }
section.block { padding: 14px 15px; margin-bottom: 10px; }
section.block > h2 {
  font-size: 11px;
  letter-spacing: 0.85px;
  text-transform: uppercase;
}
section.block.hero {
  position: relative;
  overflow: hidden;
  border-color: #2a3342;
}
section.block.hero::after {
  content: "REALIZED";
  position: absolute;
  right: 18px;
  top: 10px;
  color: rgba(255,255,255,.035);
  font: 800 54px/1 ui-monospace, monospace;
  letter-spacing: 6px;
  pointer-events: none;
}
.hero-value {
  font: 700 52px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: -2.5px;
}
.hero-kpis { gap: 0; }
.kpi {
  min-height: 70px;
  padding: 8px 14px;
  border-left: 1px solid var(--border);
}
.kpi .l { font-size: 9px; letter-spacing: .8px; }
.kpi .v { font: 600 20px/1.35 ui-monospace, monospace; }
.datatable th, .datatable td {
  padding: 7px 9px;
  border-bottom-color: #1d2430;
}
.datatable th {
  background: rgba(7, 10, 15, 0.58);
  color: #778193;
  font-size: 9px;
  letter-spacing: .8px;
}
.datatable tbody tr:hover { background: rgba(69, 84, 108, 0.11); }
.chip { border-radius: 2px; }
.tab-intro {
  border: 1px solid var(--border);
  border-left: 3px solid #3d485d;
  padding: 10px 12px;
  background: #0a0e14;
  font-size: 10.5px;
}
#tuneBlock {
  border-color: rgba(232, 170, 69, 0.38);
  background: linear-gradient(180deg, rgba(232,170,69,.05), #0c1118 38%);
}
.tune { border-radius: 3px; background: #0b1017; }
#drawer { background: #090d13; box-shadow: -20px 0 60px rgba(0,0,0,.5); }
#gate .box {
  width: 390px;
  border-radius: 4px;
  border-top: 2px solid var(--accent);
  background: #0c1118;
}
@media (max-width: 1250px) {
  .risk-strip { grid-template-columns: repeat(3, 1fr); }
  .risk-cell { border-bottom: 1px solid var(--border); }
  .grid { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
  .desk-head { align-items: flex-start; flex-direction: column; }
  .topstats { justify-content: flex-start; margin-left: 0; }
}
@media (max-width: 720px) {
  .risk-strip, .grid { grid-template-columns: 1fr; }
  .risk-cell { border-right: 0; }
  main { padding: 10px; }
  .tabbar { overflow-x: auto; gap: 22px; padding: 0 12px; scrollbar-width: none; }
  .tabbar::-webkit-scrollbar { display: none; }
  section.block.hero .hero-row { display: block; }
  .hero-main { min-width: 0; width: 100%; }
  section.block.hero h2 { display: block; line-height: 1.45; }
  section.block.hero h2 .tag {
    display: block;
    margin-top: 4px;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .hero-kpis { grid-template-columns: 1fr; margin-top: 18px; }
  .kpi { border-left: 0; border-top: 1px solid var(--border); padding: 10px 0; }
  section.block.hero::after { display: none; }
  .hero-value { font-size: 38px; }
  .topstats .tstat:nth-of-type(n+5) { display: none; }
}
