/* Whale bots dashboard. Hydrographic-chart identity: cool sea-ink on chart paper (light) or deep water (dark),
   one type family (Archivo) whose width axis does the work: expanded for the BTC mark, condensed for dense data.
   Bot colours match the static report (validated categorical slots 1-4); buy/sell is its own diverging pair. */

:root {
  color-scheme: light;
  --page: #f1f4f4;
  --surface: #fbfcfb;
  --surface-2: #eef2f2;
  --ink: #14212b;
  --ink-2: #4a5862;
  --muted: #74828a;
  --grid: #dfe5e6;
  --axis: #c2cbce;
  --ring: rgba(20, 33, 43, 0.1);
  --bot-0: #2a78d6;
  --bot-1: #eb6834;
  --bot-2: #1baf7a;
  --bot-3: #eda100;
  --buy: #256abf;
  --sell: #e34948;
  --buy-wash: rgba(37, 106, 191, 0.14);
  --sell-wash: rgba(227, 73, 72, 0.14);
  --good: #006300;
  --warn: #9a6400;
  --bad: #c22f2f;
  --font: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-family: var(--font);
  font-variation-settings: "wdth" 92;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0b141b;
    --surface: #121e27;
    --surface-2: #172631;
    --ink: #e6edef;
    --ink-2: #b4c1c7;
    --muted: #7f8f97;
    --grid: #1f2e38;
    --axis: #304350;
    --ring: rgba(255, 255, 255, 0.08);
    --bot-0: #3987e5;
    --bot-1: #d95926;
    --bot-2: #199e70;
    --bot-3: #c98500;
    --buy: #4a8ee0;
    --sell: #e66767;
    --buy-wash: rgba(74, 142, 224, 0.18);
    --sell-wash: rgba(230, 103, 103, 0.18);
    --good: #0ca30c;
    --warn: #fab219;
    --bad: #e66767;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0b141b;
  --surface: #121e27;
  --surface-2: #172631;
  --ink: #e6edef;
  --ink-2: #b4c1c7;
  --muted: #7f8f97;
  --grid: #1f2e38;
  --axis: #304350;
  --ring: rgba(255, 255, 255, 0.08);
  --bot-0: #3987e5;
  --bot-1: #d95926;
  --bot-2: #199e70;
  --bot-3: #c98500;
  --buy: #4a8ee0;
  --sell: #e66767;
  --buy-wash: rgba(74, 142, 224, 0.18);
  --sell-wash: rgba(230, 103, 103, 0.18);
  --good: #0ca30c;
  --warn: #fab219;
  --bad: #e66767;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--page); color: var(--ink); }
body { font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-underline-offset: 2px; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--buy); outline-offset: 2px; }
.num, td, .tabular { font-variant-numeric: tabular-nums; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* -- masthead ---------------------------------------------------------------------------------------------------- */
.mast {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: end;
  gap: 8px 32px;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--grid);
  background: var(--surface);
}
.mast h1 { margin: 0; font-size: 15px; font-weight: 600; color: var(--ink-2); font-variation-settings: "wdth" 100; }
.mark { display: flex; align-items: baseline; gap: 14px; }
.mark-value {
  font-size: clamp(34px, 5vw, 58px);
  font-weight: 650;
  line-height: 0.95;
  letter-spacing: -0.01em;
  font-variation-settings: "wdth" 125;
}
.mark-move { font-size: 15px; color: var(--ink-2); }
.vitals { display: flex; flex-wrap: wrap; gap: 6px 22px; justify-content: flex-end; color: var(--ink-2); font-size: 13px; }
.vital b { color: var(--ink); font-weight: 600; }
.status-ok { color: var(--good); }
.status-bad { color: var(--bad); }
.status-warn { color: var(--warn); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: currentColor; margin-right: 6px; vertical-align: 1px; }
.live .dot { animation: ping 0.9s ease-out 1; }
@keyframes ping { from { box-shadow: 0 0 0 0 currentColor; } to { box-shadow: 0 0 0 7px transparent; } }
@media (prefers-reduced-motion: reduce) { .live .dot { animation: none; } }

.kill {
  border: 1px solid var(--axis);
  background: var(--surface);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  font-weight: 600;
}
.kill[aria-pressed="true"] { background: var(--bad); border-color: var(--bad); color: #fff; }
.kill:disabled { cursor: not-allowed; color: var(--muted); }
.banner { margin: 0; padding: 8px 24px; background: var(--bad); color: #fff; font-weight: 600; }
.banner[hidden] { display: none; }

/* -- layout -------------------------------------------------------------------------------------------------------- */
main { padding: 16px 24px 48px; display: grid; gap: 16px; max-width: 1680px; margin: 0 auto; }
.row { display: grid; gap: 16px; }
.row.bots { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row.chart { grid-template-columns: minmax(0, 2.2fr) minmax(280px, 1fr); }
.row.halves { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.row.thirds { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1200px) {
  .row.bots { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .row.thirds { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .chart-box { height: 380px; }
  .book-box { height: 560px; }
  .mast { grid-template-columns: 1fr; padding: 16px; }
  .vitals { justify-content: flex-start; }
  main { padding: 12px 16px 40px; }
  .row.bots, .row.chart, .row.halves { grid-template-columns: 1fr; }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--ring);
  border-radius: 8px;
  padding: 14px 16px;
  min-width: 0;
}
.panel > h2 {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 600;
  font-variation-settings: "wdth" 100;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.panel > h2 .sub { font-size: 12px; font-weight: 400; color: var(--muted); }
.panel > h2 .tools { margin-left: auto; display: flex; gap: 6px; font-weight: 400; font-size: 12px; align-items: center; }
.empty { color: var(--muted); font-size: 13px; padding: 10px 0; }

.seg { display: inline-flex; border: 1px solid var(--axis); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 3px 9px; cursor: pointer; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--surface-2); color: var(--ink); font-weight: 600; }
select, input[type="number"] {
  font: inherit; font-size: 12px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--axis); border-radius: 6px; padding: 2px 6px;
}
input[type="number"] { width: 70px; }

/* -- bots ---------------------------------------------------------------------------------------------------------- */
.bot { display: grid; gap: 10px; align-content: start; border-top: 3px solid var(--c); }
.bot header { display: flex; align-items: baseline; gap: 8px; }
.bot header a { font-weight: 600; font-size: 15px; text-decoration: none; font-variation-settings: "wdth" 100; }
.bot header a:hover { text-decoration: underline; }
.bot .state { margin-left: auto; font-size: 12px; color: var(--ink-2); }
.bot .equity { display: flex; align-items: baseline; gap: 10px; }
.bot .equity strong { font-size: 24px; font-weight: 600; font-variation-settings: "wdth" 110; }
.pos-line { font-size: 13px; color: var(--ink-2); display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; }
.pos-line dt { color: var(--muted); }
.pos-line dd { margin: 0; color: var(--ink); }
.up { color: var(--good); }
.down { color: var(--bad); }
.spark { width: 100%; height: 44px; display: block; }
.meters { display: grid; gap: 7px; }
.meter { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; font-size: 12px; color: var(--ink-2); }
.meter .val { color: var(--ink); }
.meter .track { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--surface-2); position: relative; }
.meter .fill { position: absolute; inset: 0 auto 0 0; border-radius: 3px; background: var(--c); max-width: 100%; }
.meter .fill.pass { background: var(--c); }
.meter .tick { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); left: 66.6%; }
.bot .notes { font-size: 12px; color: var(--muted); }

/* -- lists / tables --------------------------------------------------------------------------------------------------- */
.scroll { max-height: 420px; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; position: sticky; top: 0; background: var(--surface); }
th, td { padding: 4px 8px 4px 0; border-bottom: 1px solid var(--grid); vertical-align: top; }
td.r, th.r { text-align: right; }
.chip { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.chip i { width: 9px; height: 9px; border-radius: 2px; background: var(--c); display: inline-block; }
.side-buy { color: var(--buy); font-weight: 600; }
.side-sell { color: var(--sell); font-weight: 600; }
.outcome { font-size: 12px; padding: 1px 6px; border-radius: 4px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.outcome.filled { background: var(--buy-wash); color: var(--ink); }
.outcome.blocked { background: var(--sell-wash); color: var(--ink); }
.outcome.near { border: 1px dashed var(--axis); background: transparent; }
.reason { color: var(--ink-2); }
.time { color: var(--muted); white-space: nowrap; }
.log { display: grid; gap: 0; }
.log-row { display: grid; grid-template-columns: 62px 120px minmax(0, 1fr); gap: 4px 10px; padding: 6px 0; border-bottom: 1px solid var(--grid); font-size: 13px; }
.log-row .what { min-width: 0; }
.log-row .what .reason { display: block; overflow-wrap: anywhere; }

/* -- price chart / book ---------------------------------------------------------------------------------------------- */
.chart-box { height: 560px; position: relative; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--ink-2); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 3px; background: var(--c); display: inline-block; border-radius: 2px; }
.legend i.dash { background: repeating-linear-gradient(90deg, var(--c) 0 4px, transparent 4px 7px); }
.legend i.tri { width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 8px solid var(--c); background: none; }
.book-box { height: 640px; position: relative; }
.book-box canvas { width: 100%; height: 100%; display: block; }

/* -- bars (CVD, funding) ------------------------------------------------------------------------------------------ */
.bars { display: grid; gap: 4px; font-size: 12px; }
.bar-row { display: grid; grid-template-columns: 104px minmax(0, 1fr) 78px; gap: 8px; align-items: center; }
.bar-row .name { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .val { text-align: right; font-variant-numeric: tabular-nums; }
.bar-track { position: relative; height: 14px; }
.bar-track::before { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--axis); }
.bar-fill { position: absolute; top: 2px; bottom: 2px; }
.bar-fill.pos { left: 50%; background: var(--buy); border-radius: 0 4px 4px 0; }
.bar-fill.neg { right: 50%; background: var(--sell); border-radius: 4px 0 0 4px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px 16px; margin: 4px 0 12px; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 19px; font-weight: 600; font-variation-settings: "wdth" 105; }
.split { display: flex; height: 10px; border-radius: 4px; overflow: hidden; gap: 2px; margin-top: 4px; }
.split .b { background: var(--buy); }
.split .s { background: var(--sell); }
h3 { font-size: 13px; font-weight: 600; margin: 12px 0 6px; color: var(--ink-2); }

/* -- tooltip ------------------------------------------------------------------------------------------------------- */
.tip {
  position: fixed;
  z-index: 10;
  pointer-events: none;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--axis);
  border-radius: 6px;
  padding: 7px 9px;
  font-size: 12px;
  max-width: 320px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}
.tip[hidden] { display: none; }
.tip b { display: block; margin-bottom: 3px; }
.tip div { display: flex; justify-content: space-between; gap: 14px; color: var(--ink-2); }
.tip div span:last-child { color: var(--ink); font-variant-numeric: tabular-nums; }

.foot { color: var(--muted); font-size: 12px; text-align: center; padding: 8px; }
.back { font-size: 13px; color: var(--ink-2); }

/* Embedded preview tile (?embed=1): no scrollbars, no controls */
html.embed { overflow: hidden; }
html.embed #kill { display: none; }
