/* SearchADX Report. Profit desk for the arbitrage team. */
:root {
  color-scheme: light;
  --bg: #eef1f0;
  --surface: #ffffff;
  --surface-2: #f6f8f7;
  --ink: #142027;
  --muted: #5e6e75;
  --line: #d5dcda;
  --profit: #0b7a5c;
  --profit-soft: #dff1ea;
  --loss: #b4382a;
  --loss-soft: #f8e3df;
  --revenue: #2b59c3;
  --spend: #b86e0c;
  --focus: #2b59c3;
  --warn-bg: #fff4dc;
  --warn-ink: #6b4a00;
  --radius-s: 4px;
  --radius-m: 8px;
  --font: "Archivo", "Helvetica Neue", Arial, system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1719; --surface: #172226; --surface-2: #1c292e; --ink: #e4ecea; --muted: #8fa1a6; --line: #26353a;
    --profit: #3cc497; --profit-soft: #143a2f; --loss: #f0705f; --loss-soft: #3f1f1a; --revenue: #7fa2f5; --spend: #e9a84a;
    --focus: #7fa2f5; --warn-bg: #3a2f12; --warn-ink: #f3d68b;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1719; --surface: #172226; --surface-2: #1c292e; --ink: #e4ecea; --muted: #8fa1a6; --line: #26353a;
  --profit: #3cc497; --profit-soft: #143a2f; --loss: #f0705f; --loss-soft: #3f1f1a; --revenue: #7fa2f5; --spend: #e9a84a;
  --focus: #7fa2f5; --warn-bg: #3a2f12; --warn-ink: #f3d68b;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--font);
  font-size: 15px; line-height: 1.45; font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--revenue); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.hidden { display: none !important; }
.num { text-align: right; white-space: nowrap; }
.pos { color: var(--profit); }
.neg { color: var(--loss); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- shell ---------- */
.shell {
  display: grid; grid-template-columns: 220px 1fr; min-height: 100vh;
  background: linear-gradient(to right, var(--surface) 219px, var(--line) 219px, var(--line) 220px, var(--bg) 220px);
}
section[data-panel] { display: flex; flex-direction: column; gap: 20px; }
.side {
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 20px 14px; gap: 22px;
  position: sticky; top: 0; height: 100vh;
}
.brand { font-stretch: 75%; font-weight: 800; font-size: 22px; letter-spacing: -0.01em; padding: 0 8px; line-height: 1.1; }
.brand small { display: block; font-stretch: 100%; font-weight: 500; font-size: 12px; color: var(--muted); letter-spacing: 0; margin-top: 4px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: block; padding: 8px 10px; border-radius: var(--radius-s); color: var(--ink); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--surface-2); }
.nav a[aria-current="page"] { background: var(--ink); color: var(--surface); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 0 8px; font-size: 13px; }
.side-foot .who { font-weight: 600; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; text-align: left; text-decoration: underline; text-underline-offset: 2px; }
.linkbtn:hover { color: var(--ink); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 28px; border-bottom: 1px solid var(--line); background: var(--bg);
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-stretch: 80%; font-weight: 750; font-size: 26px; margin: 0 auto 0 0; letter-spacing: -0.01em; }
.range { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.range .utc { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 2px 8px; }
.content { padding: 24px 28px 48px; display: flex; flex-direction: column; gap: 24px; max-width: 1500px; width: 100%; }

.banner { background: var(--warn-bg); color: var(--warn-ink); padding: 10px 28px; font-size: 14px; border-bottom: 1px solid var(--line); }
.banner strong { font-weight: 700; }

/* ---------- controls ---------- */
.input, .select {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 7px 10px; min-height: 36px;
}
.input[type="date"] { padding: 6px 8px; }
.btn {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 7px 14px; min-height: 36px;
  cursor: pointer; font-weight: 600; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.btn.primary:hover { opacity: 0.9; }
.btn.danger { color: var(--loss); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar .grow { flex: 1 1 200px; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
label.check { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; }

/* ---------- panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); }
.panel-head { display: flex; align-items: baseline; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-head h2 { font-size: 17px; margin: 0; font-weight: 700; }
.panel-head .spacer { flex: 1; }
.panel-body { padding: 18px; }

/* ---------- the P&L equation (signature element) ---------- */
.ledger {
  display: grid; grid-template-columns: 1fr auto 1fr auto 1.25fr; align-items: end; gap: 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 22px 26px 20px;
}
.ledger .term { min-width: 0; }
.ledger .label { font-size: 14px; color: var(--muted); font-weight: 500; }
.ledger .value {
  font-stretch: 70%; font-weight: 700; font-size: clamp(30px, 4.2vw, 54px); line-height: 1; letter-spacing: -0.02em; margin-top: 6px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ledger .op { font-stretch: 70%; font-size: clamp(26px, 3vw, 40px); color: var(--muted); font-weight: 300; padding-bottom: 4px; }
.ledger .rev .value { color: var(--revenue); }
.ledger .spd .value { color: var(--spend); }
.ledger .res { border-left: 3px solid var(--profit); padding-left: 18px; }
.ledger .res.loss { border-left-color: var(--loss); }
.ledger .res .value { font-weight: 800; }
.ledger .delta { font-size: 13px; margin-top: 8px; color: var(--muted); }
.ledger .delta b { font-weight: 600; }
.ledger .bar { grid-column: 1 / -1; height: 8px; display: flex; border-radius: 99px; overflow: hidden; background: var(--surface-2); }
.ledger .bar i { display: block; height: 100%; }
.ledger .bar .b-spend { background: var(--spend); }
.ledger .bar .b-profit { background: var(--profit); }
.ledger .bar .b-loss { background: var(--loss); }
.ledger .barnote { grid-column: 1 / -1; font-size: 13px; color: var(--muted); margin-top: -8px; }

/* compact metric strip */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); }
.metric { padding: 12px 16px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric .k { font-size: 13px; color: var(--muted); }
.metric .v { font-size: 20px; font-weight: 650; margin-top: 2px; }
.metric .d { font-size: 12px; margin-top: 2px; }

.chartwrap { position: relative; height: 320px; }

/* ---------- tables ---------- */
.tablewrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; }
table.data th {
  font-size: 13px; font-weight: 600; color: var(--muted); background: var(--surface-2); position: sticky; top: 0; z-index: 1; white-space: nowrap;
}
table.data th.num, table.data td.num { text-align: right; }
table.data th[data-sort] { cursor: pointer; user-select: none; }
table.data th[data-sort]:hover { color: var(--ink); }
table.data th[aria-sort="ascending"]::after { content: " \2191"; }
table.data th[aria-sort="descending"]::after { content: " \2193"; }
table.data tbody tr:hover td { background: var(--surface-2); }
table.data tfoot td { font-weight: 700; border-top: 2px solid var(--line); border-bottom: 0; }
td.tag { word-break: break-all; max-width: 420px; }
td.nowrap { white-space: nowrap; }
td .sub { display: block; font-size: 12px; color: var(--muted); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12.5px; font-weight: 600; }
.pill.pos { background: var(--profit-soft); }
.pill.neg { background: var(--loss-soft); }
.pill.neutral { background: var(--surface-2); color: var(--muted); }
.empty { padding: 36px 18px; text-align: center; color: var(--muted); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 12px 18px; font-size: 14px; color: var(--muted); }

.totals { display: flex; flex-wrap: wrap; gap: 28px; }
.totals div { display: flex; flex-direction: column; }
.totals .k { font-size: 13px; color: var(--muted); }
.totals .v { font-size: 20px; font-weight: 650; }

.status-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.status-grid .k { font-size: 13px; color: var(--muted); }
.status-grid .v { font-weight: 600; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; background: var(--muted); }
.dot.ok { background: var(--profit); }
.dot.err { background: var(--loss); }
.dot.run { background: var(--spend); }
pre.msg { white-space: pre-wrap; margin: 0; font-size: 12.5px; color: var(--muted); max-width: 520px; font-family: inherit; }

/* ---------- dialogs + toast ---------- */
dialog { border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); color: var(--ink); padding: 0; width: min(440px, 92vw); }
dialog::backdrop { background: rgba(10, 18, 20, 0.45); }
dialog form { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
dialog h3 { margin: 0; font-size: 18px; }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; }
.err { color: var(--loss); font-size: 14px; min-height: 1em; }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--surface);
  padding: 10px 16px; border-radius: var(--radius-s); font-size: 14px; z-index: 50; max-width: 90vw;
}

/* ---------- login ---------- */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 22px; }
.login-card .brand { padding: 0; font-size: 30px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 22px; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; background: var(--bg); }
  .side { border-right: 0; border-bottom: 1px solid var(--line); }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px 16px; gap: 12px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .side-foot { margin-top: 0; margin-left: auto; flex-direction: row; align-items: center; }
  .topbar { position: static; padding: 12px 16px; }
  .content { padding: 16px; }
  .ledger { grid-template-columns: 1fr; gap: 12px; }
  .ledger .op { display: none; }
  .ledger .res { border-left: 0; border-top: 3px solid var(--profit); padding: 12px 0 0; }
  .ledger .res.loss { border-top-color: var(--loss); }
  .metric { border-right: 0; border-bottom: 1px solid var(--line); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
