/* Wanted monitor. The Stealth Phantom look of Solana Ghost's monitor (graphite surfaces, thin borders, DM Sans +
   Space Grotesk, letter-spaced eyebrows, small pills), with Wanted's own accent: poster amber. Dark only. */

:root {
  color-scheme: dark;
  --bg: #090c11;
  --top: #0e1216;
  --panel: #11161e;
  --raised: #161c25;
  --border: #29313e;
  --line: #222a35;
  --text: #edf3f3;
  --muted: #9aa7b4;
  --subtle: #8491a0;
  --acc: #eac18a;
  --acc-soft: #251f18;
  --acc-line: #745b3f;
  --mint: #9cf6d4;
  --green: #91deb7;
  --red: #ee91a1;
  --violet: #c2a8ff;
  --cyan: #8ddcec;
  --font: "DM Sans", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: "Space Grotesk", "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --pad: clamp(16px, 1.7vw, 40px);
  --gap: clamp(12px, 1.1vw, 24px);
  --radius: 12px;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
}
@media (min-width: 1900px) { :root { font-size: 15px; } }

*, *::before, *::after { box-sizing: border-box; }
html, body { background: var(--bg); color: var(--text); margin: 0; }
body { min-height: 100vh; display: flex; flex-direction: column; overflow-x: hidden; }
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3, h4 { font-family: var(--display); font-weight: 500; }
a { color: var(--acc); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
code, .mono { font-family: var(--mono); font-size: 0.92em; }

/* ---- top bar */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: var(--gap);
  padding: 10px var(--pad); padding-top: calc(10px + env(safe-area-inset-top, 0px));
  background: color-mix(in srgb, var(--top) 94%, transparent); border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px); flex-wrap: nowrap;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-family: var(--display); font-size: 1.15rem; letter-spacing: 0.14em; }
.brand:hover { text-decoration: none; }
.brand svg { width: 28px; height: 28px; }
.nav { display: flex; gap: 4px; flex-wrap: nowrap; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: var(--muted); padding: 6px 12px; border-radius: 8px; border: 1px solid transparent; white-space: nowrap; flex: none; }
.nav a:hover { color: var(--text); text-decoration: none; background: var(--raised); }
.nav a[aria-current="page"] { color: var(--acc); border-color: var(--acc-line); background: var(--acc-soft); }
.status { margin-left: auto; display: flex; align-items: center; gap: 14px; min-width: 0; }
.account { display: flex; align-items: center; gap: 12px; flex: none; }
.top .menu-btn { display: none; }
.light { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 0.9rem; white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.light::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--subtle); }
.light[data-state="ok"]::before { background: var(--green); box-shadow: 0 0 8px var(--green); }
.light[data-state="warn"]::before { background: var(--acc); }
.light[data-state="bad"]::before { background: var(--red); }

main { flex: 1; width: 100%; max-width: 1680px; margin: 0 auto; padding: var(--pad); padding-bottom: calc(var(--pad) + env(safe-area-inset-bottom, 0px)); }

/* ---- building blocks */
.eyebrow { color: var(--subtle); font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--gap); margin-bottom: var(--gap); flex-wrap: wrap; }
.page-head h1 { font-size: 1.6rem; }
.sub { color: var(--muted); }
.grid { display: grid; gap: var(--gap); }
.cards { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; min-width: 0; }
.panel h2 { font-size: 1.05rem; margin-bottom: 10px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.card .v { font-family: var(--display); font-size: 1.45rem; margin-top: 4px; overflow-wrap: anywhere; }
.card .n { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }
.card .v.small-v { font-size: 1rem; line-height: 1.4; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.dim { color: var(--muted); }
.warn-text { color: var(--acc); }
.bar { height: 6px; border-radius: 6px; background: var(--raised); overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: var(--acc); border-radius: 6px; }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 1px 9px; border-radius: 999px; font-size: 0.78rem; border: 1px solid var(--border); color: var(--muted); background: var(--raised); white-space: nowrap; }
.pill[data-s="tracking"], .pill[data-s="done"], .pill[data-s="ok"], .pill[data-s="closed"] { color: var(--green); border-color: #36573f; background: #16271e; }
.pill[data-s="running"], .pill[data-s="open"] { color: var(--cyan); border-color: #2f4b58; background: #152029; }
.pill[data-s="paused"], .pill[data-s="queued"], .pill[data-s="waiting_credits"] { color: var(--acc); border-color: var(--acc-line); background: var(--acc-soft); }
.pill[data-s="failed"], .pill[data-s="bad"] { color: var(--red); border-color: #6d3947; background: #341c24; }
.pill[data-s="retired"], .pill[data-s="cancelled"] { color: var(--subtle); }
.tag { display: inline-block; padding: 0 8px; margin: 0 4px 4px 0; border-radius: 6px; background: var(--raised); border: 1px solid var(--line); color: var(--muted); font-size: 0.8rem; }

/* ---- tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--subtle); font-weight: 500; font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; background: var(--top); position: sticky; top: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--raised); }
tbody tr.click { cursor: pointer; }
tbody tr:last-child td { border-bottom: 0; }
td .actions { flex-wrap: nowrap; }
td .actions.many { flex-wrap: wrap; max-width: 240px; }
td .wrap { white-space: normal; display: inline-block; min-width: 14ch; }
th.wrapcell, td.wrapcell { white-space: normal; min-width: 11ch; }
@media (max-width: 1279px) { th, td { padding: 7px 8px; } }
td .signals { max-width: 34ch; }
.table-wrap td:first-child, .table-wrap th:first-child { position: sticky; left: 0; z-index: 1; }
.table-wrap td:first-child { background: var(--panel); }
.table-wrap th:first-child { z-index: 2; }
tbody tr:hover td:first-child { background: var(--raised); }
.empty { color: var(--muted); padding: 18px 4px; }
.more { margin-top: 10px; }

/* ---- forms and buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--raised); color: var(--text); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--acc-line); }
.btn.primary { background: var(--acc); color: #1d160c; border-color: var(--acc); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--red); border-color: #6d3947; }
.btn.small { padding: 3px 10px; font-size: 0.85rem; }
.btn:disabled { opacity: 0.5; cursor: default; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions select, .actions input[type] { width: auto; flex: 0 1 auto; }
form.stack { display: grid; gap: 14px; max-width: 760px; }
label.field { display: grid; gap: 6px; color: var(--muted); font-size: 0.9rem; }
input[type=text], input[type=search], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 8px 11px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
textarea { min-height: 110px; font-family: var(--mono); font-size: 0.9rem; resize: vertical; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 180px; }
.hint { color: var(--subtle); font-size: 0.85rem; }
.msg { min-height: 1.4em; font-size: 0.9rem; }
.msg[data-kind="error"] { color: var(--red); }
.msg[data-kind="ok"] { color: var(--green); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.filters select, .filters input { width: auto; min-width: 120px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { background: transparent; border: 0; padding: 5px 12px; color: var(--muted); cursor: pointer; flex: none; white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--acc-soft); color: var(--acc); }

.field-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 0.9rem; }
div.field { display: grid; gap: 6px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 6px 14px; max-height: 260px; overflow-y: auto; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
label.check { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; line-height: 1.35; font-size: 0.88rem; }
label.check input { margin-top: 2px; accent-color: var(--acc); flex: none; }
ul.plain { margin: 0; padding-left: 18px; display: grid; gap: 6px; color: var(--muted); }
ul.plain b, ul.plain code { color: var(--text); }
.reveal { margin-top: 12px; border: 1px solid var(--acc-line); background: var(--acc-soft); border-radius: 10px; padding: 12px 14px; }
.reveal input { flex: 1 1 320px; width: auto; }
code.tag { font-family: var(--mono); }
.score { display: inline-flex; align-items: center; gap: 8px; }
.score .bar { width: 56px; margin-top: 0; }
.score b { font-weight: 600; font-variant-numeric: tabular-nums; }
td .wrap, span.wrap { white-space: normal; }

/* ---- folding panels (open on wide screens, closed on phones) and a page flow that puts the list first on phones */
details.fold > summary { list-style: none; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; cursor: pointer; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary h2 { margin: 0; }
details.fold > summary::after { content: "Show"; color: var(--acc); font-size: 0.85rem; }
details.fold[open] > summary::after { content: "Hide"; }
details.fold[open] > summary { margin-bottom: 12px; }
.flow { display: flex; flex-direction: column; gap: var(--gap); }

/* ---- bot page */
.poster { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center; }
.poster .badge { width: 64px; height: 64px; border-radius: 14px; background: var(--acc-soft); border: 1px solid var(--acc-line); display: grid; place-items: center; font-family: var(--display); font-size: 1.5rem; color: var(--acc); }
.wallets { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.wallet { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-family: var(--mono); font-size: 0.86rem; color: var(--muted); overflow-wrap: anywhere; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: var(--gap) 0; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { background: transparent; border: 0; border-bottom: 2px solid transparent; padding: 8px 14px; color: var(--muted); cursor: pointer; flex: none; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--acc); border-bottom-color: var(--acc); }
.chart { width: 100%; height: 150px; display: block; }
.chart .axis { stroke: var(--line); }
.chart text { fill: var(--subtle); font-size: 10px; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.kv dt { color: var(--subtle); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }

/* ---- drawer and modal */
.scrim { position: fixed; inset: 0; background: rgba(4, 6, 9, 0.66); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 100vw); background: var(--panel); border-left: 1px solid var(--border); z-index: 41; overflow-y: auto; padding: 20px var(--pad); padding-top: calc(20px + env(safe-area-inset-top, 0px)); }
.drawer pre, pre.json { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow: auto; max-height: 420px; font-size: 0.8rem; }
.modal { position: fixed; left: 50%; top: 22vh; transform: translateX(-50%); width: min(420px, calc(100vw - 32px)); background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; z-index: 42; }
.modal .stack { margin-top: 10px; }
.modal { max-height: calc(100vh - 22vh - 16px); overflow-y: auto; }
select.zones { width: 100%; min-height: 12rem; padding: 4px; font-family: var(--mono); font-size: 0.86rem; }
select.zones option { padding: 3px 6px; }
select.zones optgroup { font-style: normal; font-weight: 600; color: var(--muted); }
input.masked { -webkit-text-security: disc; text-security: disc; font-family: var(--mono); }
.modal input.secret { font-family: var(--mono); font-size: 0.9rem; letter-spacing: 0.02em; }
.close { float: right; }
details summary { cursor: pointer; color: var(--muted); }

/* ---- login */
.login-wrap { flex: 1; display: grid; place-items: center; padding: var(--pad); }
.login { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 28px; display: grid; gap: 14px; }
.login .brand { justify-content: center; font-size: 1.4rem; }

@media (max-width: 1439px) {
  #who { display: none; }
  .status .light { font-size: 0; gap: 0; }           /* a dot each; the full text is its tooltip */
  .status .light::before { width: 10px; height: 10px; }
}

@media (max-width: 1099px) {                          /* the menu: brand, status dots, Menu; the pages open below */
  .top { flex-wrap: wrap; gap: 10px; }
  .top .menu-btn { display: inline-flex; order: 2; }
  .status { order: 1; }
  .nav, .account { display: none; order: 3; flex-basis: 100%; }
  .top.open .nav { display: flex; flex-direction: column; overflow: visible; gap: 2px; padding-top: 6px; }
  .top.open .nav a { padding: 10px 12px; font-size: 1rem; }
  .top.open .account { display: flex; justify-content: space-between; order: 4; padding: 6px 0 4px; border-top: 1px solid var(--line); }
  .top.open #who { display: inline; }
}

@media (max-width: 900px) {                           /* tables become cards: one per row, each value with its name */
  .table-wrap { overflow: visible; border: 0; border-radius: 0; }
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tbody tr { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; padding: 6px 12px; background: var(--panel); }
  .table-wrap tbody tr:hover { background: var(--raised); }
  .table-wrap td, .table-wrap td:first-child { position: static; display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
    padding: 6px 0; border-bottom: 1px dashed var(--line); white-space: normal; text-align: right; background: transparent; overflow-wrap: anywhere; }
  .table-wrap td:last-child { border-bottom: 0; }
  .table-wrap td:empty { display: none; }             /* no value, no line */
  .table-wrap td::before { content: attr(data-label); flex: none; max-width: 45%; color: var(--subtle); font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; text-align: left; }
  .table-wrap td[data-label=""]::before { content: none; }
  .table-wrap td[data-label=""] { justify-content: flex-start; }
  .table-wrap td:first-child { font-weight: 600; }
  td .actions, td .actions.many { flex-wrap: wrap; max-width: none; }
  td .wrap { min-width: 0; text-align: right; }
}

@media (min-width: 701px) and (max-width: 900px) {  /* tablets: two cards a row */
  .table-wrap tbody { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .table-wrap tbody tr { margin-bottom: 0; }
}

@media (max-width: 700px) {
  select.zones { font-family: var(--font); font-size: 0.8rem; }
  .modal { top: 10vh; max-height: calc(100vh - 10vh - 16px); }
  .flow > .lead { order: -1; }
  .page-head h1 { font-size: 1.35rem; }
  .tabs, .seg { flex-wrap: wrap; overflow: visible; }  /* every tab visible: two lines rather than hidden */
  .seg { border-radius: 8px; }
}

@media (max-width: 640px) {
  .poster { grid-template-columns: 1fr; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .card .v { font-size: 1.2rem; }
}

/* ---------------------------------------------------------------------------------------------- the page fits the screen
   W-017: on a screen wider than a phone and at least 560 px high, the header stays and the page fills the rest of the
   window, never longer: a block that holds a list (a table) takes the height the others leave, shared with the other
   list blocks, and its list scrolls inside with its column names kept in view; in a grid, each panel scrolls inside.
   If a page's fixed parts alone are taller than the window, the page area scrolls as a last resort. On a phone the page
   scrolls as usual, and no list is taller than three quarters of the screen: it scrolls inside. */
@media (min-width: 701px) and (min-height: 560px) {
  body { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; }
  main { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: var(--gap); }
  main > * { flex: none; margin-top: 0 !important; margin-bottom: 0 !important; }
  /* the chain from a block down to its list: flex columns that let the list give up height; a panel on the way
     scrolls itself rather than spill onto the next one */
  main :where(:has(.table-wrap):not(.grid, table, thead, tbody, tr, td, .table-wrap)) { display: flex; flex-direction: column; min-height: 0; }
  main :where(.panel:has(.table-wrap)) { overflow: auto; }
  main :where(:has(.table-wrap):not(.grid)) > :where(:has(.table-wrap), .table-wrap) { flex: 0 1 auto; }
  main :where(.grid:has(.table-wrap)) { min-height: 0; grid-auto-rows: minmax(0, 1fr); }
  main :where(.grid:has(.table-wrap)) > * { min-height: 0; overflow: auto; }
  main .table-wrap { min-height: 0; overflow: auto; }
  .table-wrap th:first-child { z-index: 3; }
  /* next to a list, forms and notes give up height first (three times faster) and scroll inside */
  main :where(:has(.table-wrap):not(.grid)) > :where(.grid:not(:has(.table-wrap)), details, .panel:not(:has(.table-wrap))) { flex: 0 3 auto; min-height: 10rem; overflow: auto; }
  main > :is(.grid:not(.cards), details):not(:has(.table-wrap)) { flex: 0 3 auto; min-height: 10rem; overflow: auto; }
  /* a folded section is only its title line: it neither reserves height nor gives any up */
  main :where(.grid:has(> details.fold):not(:has(> details[open])), details.fold:not([open])) { flex: none !important; min-height: 0 !important; }
  main .grid:has(> details.fold) { align-items: start; }  /* an open section does not stretch a folded one */
  main :where(.grid:has(> details[open]), details.fold[open]) { min-height: min(22rem, 45vh) !important; }  /* one opened is being used */
  /* a form that scrolls inside its panel keeps its Save row in view */
  main :is(.panel, details) form.stack > .actions { position: sticky; bottom: -16px; z-index: 2; background: var(--panel); padding-block: 8px 16px; margin-bottom: -8px; }
  /* blocks with a list are as tall as they need and give up height when the screen is short; so are the blocks marked
     .fill (a long form, a bot's tab) */
  main > :is(:has(.table-wrap), .fill) { flex: 0 1 auto; min-height: 8rem; overflow: auto; }
  main > .fill:not(:has(.table-wrap)) { display: flex; flex-direction: column; min-height: 12rem; }
  main > .fill > .grid:not(.cards) { flex: 1 1 auto; min-height: 0; grid-auto-rows: minmax(12rem, 1fr); }  /* a chart row keeps its chart; the tab scrolls */
  main > .fill > .grid:not(.cards) > .panel { display: flex; flex-direction: column; min-height: 0; overflow: auto; }
  main > .fill .panel > svg.chart { flex: 1 1 auto; min-height: 110px; height: auto; }  /* 150 px drawn; squeezed at most a quarter */
}
@media (max-width: 700px), (max-height: 559px) {
  .table-wrap { max-height: 75vh; max-height: 75dvh; overflow: auto; }
}
