:root {
  --bg: #0a0a0a;
  --panel: #0e0e0e;
  --line: #333;
  --line-dim: #1f1f1f;
  --fg: #e8e8e8;
  --muted: #8c8c8c;
  --dim: #5c5c5c;
  --hi: #ffffff;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body { font: 13px/1.5 var(--mono); -webkit-font-smoothing: antialiased; }
main { max-width: 1400px; margin: 0 auto; padding: 0 16px 32px; }
a { color: var(--fg); text-decoration: none; border-bottom: 1px dotted var(--dim); }
a:hover { color: var(--hi); border-bottom-color: var(--hi); }

/* ---------- boot ---------- */
#boot {
  position: fixed; inset: 0; z-index: 50; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  transition: opacity .5s;
}
#boot.done { opacity: 0; pointer-events: none; }
#boot-log { color: var(--muted); font-size: 13px; min-width: 340px; }
#boot-log b { color: var(--hi); font-weight: 400; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 16px; background: rgba(10,10,10,.92); backdrop-filter: blur(4px);
  border-bottom: 1px solid var(--line);
}
.prompt { color: var(--muted); }
.prompt .cmd { color: var(--hi); }
.cursor { color: var(--hi); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.telemetry { display: flex; gap: 20px; color: var(--dim); font-size: 12px; flex-wrap: wrap; }
.telemetry b { color: var(--fg); font-weight: 400; }

/* ---------- sections & panes ---------- */
h2.section {
  font-size: 12px; font-weight: 600; letter-spacing: .08em; color: var(--muted);
  margin: 28px 0 10px;
}
h2.section .hint { font-weight: 300; color: var(--dim); letter-spacing: 0; margin-left: 8px; }

.pane, .tile, .wallet {
  position: relative; background: var(--panel); border: 1px solid var(--line);
}
/* crosshair corner brackets */
.pane::before, .pane::after, .tile::before, .tile::after, .wallet::before, .wallet::after {
  content: ""; position: absolute; width: 8px; height: 8px; pointer-events: none;
}
.pane::before, .tile::before, .wallet::before { top: -1px; left: -1px; border-top: 1px solid var(--hi); border-left: 1px solid var(--hi); }
.pane::after, .tile::after, .wallet::after { bottom: -1px; right: -1px; border-bottom: 1px solid var(--hi); border-right: 1px solid var(--hi); }

/* ---------- status ---------- */
.status-pane {
  margin-top: 20px; padding: 16px 20px;
  display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap;
}
.indicator {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 20px; font-weight: 700; letter-spacing: .12em; padding: 4px 12px;
  border: 1px solid var(--line);
}
.indicator .dot { width: 10px; height: 10px; border: 1px solid currentColor; }
.indicator.running { background: var(--hi); color: #000; border-color: var(--hi); }
.indicator.running .dot { background: #000; animation: blink 1s steps(1) infinite; }
.indicator.idle { color: var(--muted); }
.indicator.stale { color: var(--muted); border-style: dashed; }
.indicator.stale .dot { border-style: dashed; animation: blink 2s steps(1) infinite; }
.status-sub { color: var(--muted); margin-top: 6px; font-size: 12px; }

/* ---------- key/value ---------- */
.kv { margin: 0; display: grid; gap: 0; }
.kv > div { display: flex; justify-content: space-between; gap: 16px; padding: 5px 0; border-bottom: 1px solid var(--line-dim); }
.kv > div:last-child { border-bottom: 0; }
.kv dt { color: var(--muted); font-size: 11px; letter-spacing: .06em; align-self: center; }
.kv dd { margin: 0; text-align: right; color: var(--fg); }
.kv dd small { color: var(--dim); }
.kv.inline { display: flex; gap: 28px; flex-wrap: wrap; }
.kv.inline > div { flex-direction: column; gap: 2px; border: 0; padding: 0; }
.kv.inline dd { text-align: left; }

/* ---------- tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.tile { padding: 14px 16px; }
.tile .label { color: var(--muted); font-size: 11px; letter-spacing: .06em; }
.tile .value { font-size: 24px; font-weight: 600; color: var(--hi); margin: 6px 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .value .unit { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 4px; }
.tile .sub { color: var(--dim); font-size: 12px; }

/* ---------- run ---------- */
.run-pane { padding: 16px 20px; }
.run-grid { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 28px; }
.run-right { min-width: 0; }
.chart-wrap { margin-top: 18px; border-top: 1px solid var(--line-dim); padding-top: 12px; }
/* home-page TODAY cards: stats (#/today), wallet table (rows open #/today/<wallet>), chart (#/chart) */
.chart-card, .card-frame { position: relative; border: 1px solid var(--line); padding: 12px 14px 8px; background: var(--bg); }
.chart-card::before, .chart-card::after, .card-frame::before, .card-frame::after { content: ""; position: absolute; width: 10px; height: 10px; pointer-events: none; }
.chart-card::before, .card-frame::before { top: -1px; left: -1px; border-top: 1px solid var(--hi); border-left: 1px solid var(--hi); }
.chart-card::after, .card-frame::after { bottom: -1px; right: -1px; border-bottom: 1px solid var(--hi); border-right: 1px solid var(--hi); }
.card-hint { text-align: right; font-size: 11px; margin-bottom: 2px; }
.day-card { display: flex; flex-direction: column; }
.day-card .kv { flex: 1; }  /* rows spread to the full panel height, like before it was a card */
.wallet-table-card { padding-bottom: 4px; }
#run-wallets tbody tr[data-href] { cursor: pointer; }
#run-wallets tbody tr[data-href]:hover td { background: #151515; color: var(--hi); }
#run-wallets .row-open { color: var(--dim); margin-left: 6px; font-size: 11px; }
#run-wallets tbody tr[data-href]:hover .row-open { color: var(--hi); }
.chart-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 11px; letter-spacing: .06em; }
.legend { display: flex; gap: 16px; letter-spacing: 0; }
.legend svg { vertical-align: middle; margin-right: 6px; }
#chart { position: relative; height: 230px; margin-top: 6px; }
#chart svg { display: block; }
.chart-tip {
  position: absolute; pointer-events: none; background: #000; border: 1px solid var(--line);
  padding: 6px 10px; font-size: 11px; white-space: nowrap; display: none; z-index: 2;
}
.chart-tip .tt { color: var(--muted); margin-bottom: 2px; }
.empty { color: var(--dim); padding: 30px 0; text-align: center; }

/* ---------- tables ---------- */
.grid { width: 100%; border-collapse: collapse; font-size: 12px; }
.grid th {
  text-align: left; font-weight: 600; font-size: 11px; letter-spacing: .06em; color: var(--muted);
  padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.grid td { padding: 5px 10px; border-bottom: 1px solid var(--line-dim); white-space: nowrap; }
.grid tbody tr:hover td { background: #151515; }
.grid .r { text-align: right; }
.grid .muted { color: var(--dim); }
.sortable th[data-k] { cursor: pointer; user-select: none; }
.sortable th[data-k]:hover { color: var(--hi); }
.sortable th.asc::after { content: " ▲"; color: var(--hi); }
.sortable th.desc::after { content: " ▼"; color: var(--hi); }
.tag { border: 1px solid var(--line); padding: 0 5px; font-size: 11px; }
.tag.fail { background: var(--hi); color: #000; border-color: var(--hi); }
/* signature column hidden for now — delete this line to bring it back */
.col-sig { display: none; }
.t-short { display: none; }

/* ---------- wallets ---------- */
.wallets { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 10px; }
.wallet { padding: 14px 16px; }
.wallet-head { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1px solid var(--line); padding-bottom: 8px; margin-bottom: 6px; }
.wallet-name { font-size: 15px; font-weight: 700; letter-spacing: .1em; color: var(--hi); }
.wallet-tag { color: var(--dim); font-size: 11px; }
.wallet .big { font-size: 22px; font-weight: 600; color: var(--hi); }
.wallet .big .unit { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 4px; }
.wallet .bigsub { color: var(--dim); font-size: 12px; margin-bottom: 8px; }

/* ---------- feed ---------- */
.feed-pre { margin: 0; padding: 10px 14px; font-size: 12px; color: var(--muted); white-space: pre; overflow-x: auto; min-height: 60px; background: var(--bg); border: 1px solid var(--line-dim); }
.feed-pre .new { color: var(--hi); animation: fadein .8s; }

/* ---------- clickable cards ---------- */
a.clickable { display: block; color: inherit; text-decoration: none; cursor: pointer; transition: border-color .15s, background .15s; }
a.clickable:hover, a.clickable:focus-visible { border-color: #8c8c8c; background: #121212; color: inherit; outline: none; }
.open-hint { position: absolute; top: 10px; right: 12px; color: var(--dim); font-size: 11px; transition: color .15s; }
.open-hint.inline { position: static; margin-left: 6px; }
a.clickable:hover .open-hint, a.clickable:focus-visible .open-hint { color: var(--hi); }

/* ---------- inspect view (overlay) ---------- */
body.view-open { overflow: hidden; }
.view { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .82); backdrop-filter: blur(2px); display: flex; justify-content: center; align-items: flex-start; padding: 32px 16px; animation: fadein .18s; }
.view[hidden] { display: none; }
.view-panel { position: relative; width: 100%; max-width: 1180px; max-height: 100%; display: flex; flex-direction: column; background: var(--bg); border: 1px solid var(--line); animation: rise .2s ease-out; }
.view-panel::before, .view-panel::after { content: ""; position: absolute; width: 10px; height: 10px; pointer-events: none; }
.view-panel::before { top: -1px; left: -1px; border-top: 1px solid var(--hi); border-left: 1px solid var(--hi); }
.view-panel::after { bottom: -1px; right: -1px; border-bottom: 1px solid var(--hi); border-right: 1px solid var(--hi); }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.view-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.view-path { color: var(--muted); }
.view-path b { color: var(--hi); font-weight: 400; }
.view-bar button { padding: 4px 10px; }
.view-bar .esc { font-size: 10px; color: var(--dim); margin-left: 4px; }
.view-body { overflow-y: auto; padding: 4px 20px 28px; flex: 1; overscroll-behavior: contain; }
.vhero { padding: 18px 0 6px; }
.vhero-val { font-size: 34px; font-weight: 700; color: var(--hi); }
.vhero-val .unit { font-size: 14px; font-weight: 400; color: var(--muted); margin-left: 6px; }
.vhero-sub { color: var(--dim); font-size: 12px; margin-top: 2px; }
.vsec { margin-top: 22px; }
h3.vh { font-size: 12px; font-weight: 600; letter-spacing: .08em; color: var(--muted); margin: 0 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--line-dim); }
h3.vh .hint { font-weight: 300; color: var(--dim); letter-spacing: 0; margin-left: 8px; }
.calc { margin-top: 8px; padding: 8px 12px; border: 1px solid var(--line-dim); background: var(--panel); font-size: 12px; color: var(--fg); }
.calc b { color: var(--hi); }
.note { color: var(--dim); font-size: 11px; line-height: 1.6; margin: 14px 0 0; max-width: 820px; }
.grid tr.total td { border-top: 1px solid var(--line); border-bottom: 0; color: var(--hi); font-weight: 600; }
.vchart { position: relative; height: 240px; }

/* big chart view (#/chart) */
.cv-bar { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; padding-top: 16px; }
.cv-group { display: flex; gap: 4px; align-items: center; }
.cv-group .lab { color: var(--dim); font-size: 10px; letter-spacing: .08em; margin-right: 4px; }
.cv-bar button.on { color: #000; background: var(--hi); border-color: var(--hi); }
.cv-bar button.off { opacity: .4; }
.cv-bar button svg { vertical-align: middle; margin-right: 6px; }
.cv-range { color: var(--fg); margin: 14px 0 4px; font-size: 13px; }
.bigchart { position: relative; height: min(58vh, 520px); min-height: 280px; margin-top: 6px; }
.cv-help { color: var(--dim); font-size: 11px; margin-top: 4px; }
.wv-top { display: grid; grid-template-columns: minmax(240px, 1fr) minmax(280px, 420px); gap: 28px; align-items: start; }
.wv-top .kv { margin-top: 18px; }
.wv-name { font-size: 18px; font-weight: 700; letter-spacing: .12em; color: var(--hi); padding-top: 18px; }
.wv-name .hint { font-size: 11px; font-weight: 300; letter-spacing: 0; color: var(--dim); margin-left: 8px; }
.wv-name + #v-hero .vhero { padding-top: 6px; }

/* share bar */
.split { display: flex; gap: 2px; height: 14px; margin: 4px 0 8px; }
.split span { display: block; min-width: 2px; }
.split-legend { display: flex; flex-wrap: wrap; gap: 18px; font-size: 11px; color: var(--muted); margin-bottom: 10px; }
.split-legend i { display: inline-block; width: 10px; height: 10px; margin-right: 6px; vertical-align: -1px; }
.split-legend b { color: var(--fg); font-weight: 400; margin-left: 4px; }

/* histogram */
.hist { display: grid; gap: 4px; max-width: 760px; }
.hrow { display: grid; grid-template-columns: 170px 1fr 48px; gap: 12px; align-items: center; font-size: 11px; }
.hlab { color: var(--muted); white-space: nowrap; }
.hbar { height: 10px; background: var(--line-dim); }
.hbar span { display: block; height: 100%; background: var(--fg); }
.hval { text-align: right; color: var(--fg); }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

/* ---------- filters ---------- */
.history { padding: 14px 16px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filters label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 10px; letter-spacing: .08em; }
.filters label.grow { flex: 1 1 200px; }
input, select, button {
  font: 12px var(--mono); color: var(--fg); background: var(--bg);
  border: 1px solid var(--line); padding: 5px 8px; border-radius: 0; outline: none;
}
input:focus, select:focus { border-color: var(--hi); }
input[type="date"] { color-scheme: dark; }
input[type="number"] { width: 100px; }
button { cursor: pointer; color: var(--muted); }
button:hover:not(:disabled) { color: #000; background: var(--hi); border-color: var(--hi); }
button:disabled { opacity: .35; cursor: default; }
.btns { display: flex; gap: 6px; }
.filter-summary { color: var(--dim); font-size: 12px; margin: 12px 0 6px; }
.filter-summary b { color: var(--fg); font-weight: 400; }
.table-scroll { overflow-x: auto; }
.pager { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 10px; color: var(--dim); font-size: 12px; }

/* value changed */
.flash { animation: flash 1.2s; }
@keyframes flash { 0% { background: var(--hi); color: #000; } 100% { background: transparent; } }

footer { border-top: 1px solid var(--line); color: var(--dim); font-size: 11px; padding: 14px 16px; text-align: center; }

@media (max-width: 900px) {
  .run-grid { grid-template-columns: 1fr; }
}
/* phones only — tablet/desktop styles above are untouched */
@media (max-width: 600px) {
  .topbar { position: static; padding: 8px 16px; gap: 4px; }
  .prompt { font-size: 12px; }
  .telemetry { gap: 12px; font-size: 11px; }
  h2.section { margin: 22px 0 8px; font-size: 11px; }

  .status-pane { margin-top: 16px; padding: 14px; gap: 14px; }
  .indicator { font-size: 16px; }
  .kv.inline { display: grid; grid-template-columns: repeat(3, auto); justify-content: space-between; gap: 12px; width: 100%; }

  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .tile { padding: 10px 12px; }
  .tile .label { font-size: 10px; letter-spacing: .03em; }
  .tile .value { font-size: 18px; margin: 4px 0 2px; }
  .tile .sub { font-size: 11px; }

  .run-pane, .history { padding: 12px; }
  .run-grid { gap: 16px; }
  .kv dt { font-size: 10px; }
  .kv dd { font-size: 12px; }
  #chart { height: 200px; }

  .grid { font-size: 11px; }
  .grid th, .grid td { padding: 5px 6px; }
  /* keep the time column pinned while the trade table scrolls sideways */
  .trades th:first-child, .trades td:first-child { position: sticky; left: 0; z-index: 1; background: var(--panel); }
  .view .trades th:first-child, .view .trades td:first-child { background: var(--bg); }
  .trades tbody tr:hover td:first-child { background: #151515; }
  .t-long { display: none; }
  .t-short { display: inline; }
  .table-scroll, .feed-pre { scrollbar-color: #333 transparent; scrollbar-width: thin; }

  .wallets { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .wallet { padding: 12px; }
  .wallet .big { font-size: 20px; }
  .wallet-name { font-size: 14px; }

  .feed-pre { font-size: 11px; padding: 8px 10px; }

  /* inspect view goes full screen on phones */
  .view { padding: 0; }
  .view-panel { border: 0; height: 100%; }
  .view-bar { padding: 10px 12px; }
  .view-path { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .view-body { padding: 0 12px 24px; }
  .vhero-val { font-size: 26px; }
  .vchart { height: 200px; }
  .bigchart { height: 340px; min-height: 0; }
  .cv-bar { gap: 8px; }
  .cv-group { flex-wrap: wrap; }
  .cv-bar button { padding: 6px 9px; }
  .cv-range { font-size: 12px; }
  .wv-top { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .hrow { grid-template-columns: 120px 1fr 36px; gap: 8px; font-size: 10px; }
  .split-legend { gap: 12px; }

  .filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .filters label.grow, .btns { grid-column: 1 / -1; }
  /* 16px stops iPhones from zooming the page when a field is tapped */
  .filters input, .filters select { width: 100%; min-width: 0; font-size: 16px; padding: 4px 6px; }
  .btns button { flex: 1; padding: 8px; }
  .filter-summary { font-size: 11px; }
}
#v-wallets tbody tr:not(.total) { cursor: pointer; }
#v-wallets tbody tr:not(.total):hover td { background: #151515; color: var(--hi); }
