/* Scrooch. Soft synthwave on a calm dark field: one magenta-to-cyan horizon, numbers in
   mono, every colour has a word beside it. Mobile first (390px), wider screens add room. */

:root {
  --bg-0: #0b0b16;
  --bg-1: #120f22;
  --card: rgba(255, 255, 255, .035);
  --line: rgba(255, 255, 255, .07);
  --text: #ecebf7;
  --muted: #a09cbc;
  --faint: #6c6888;
  --magenta: #ff6ec7;
  --violet: #a78bfa;
  --cyan: #5ee7ff;
  --amber: #ffd166;
  --green: #7ef2b1;
  --red: #ff7b8a;
  --mono: "JetBrains Mono", "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --r: 14px;
}

* { box-sizing: border-box; }
html { background: var(--bg-0); }
body {
  margin: 0; min-height: 100vh; color: var(--text);
  font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(120% 60% at 50% 115%, rgba(255, 110, 199, .10), transparent 60%),
    radial-gradient(80% 50% at 85% -10%, rgba(94, 231, 255, .08), transparent 60%),
    linear-gradient(180deg, var(--bg-0), var(--bg-1)) fixed;
}
body::before {
  content: ""; position: fixed; inset: 0 0 auto 0; height: 2px; z-index: 50;
  background: linear-gradient(90deg, var(--magenta), var(--violet), var(--cyan));
}
h2 { margin: 22px 0 8px; font: 600 11px/1.4 var(--sans); letter-spacing: .09em;
     text-transform: uppercase; color: var(--muted); }
h3 { margin: 14px 0 6px; font: 600 11px/1.4 var(--sans); letter-spacing: .09em;
     text-transform: uppercase; color: var(--faint); }
.card h2 { margin-top: 0; }
a { color: var(--cyan); }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { text-align: right; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; text-transform: none; letter-spacing: 0; font-weight: 400; }
.missing { color: var(--faint); font-style: italic; }
.pos { color: var(--green); }
.neg { color: var(--red); }

/* header and tabs */
.top {
  position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 14px;
  padding: 12px 16px 0; background: rgba(11, 11, 22, .85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand {
  font-weight: 700; letter-spacing: .02em;
  background: linear-gradient(90deg, var(--magenta), var(--cyan));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.tabs a {
  padding: 8px 10px 10px; color: var(--muted); text-decoration: none; font-size: 14px;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs a[aria-selected="true"] { color: var(--text); border-bottom-color: var(--magenta); }
.tabs a:focus-visible { outline: 2px solid var(--cyan); outline-offset: -2px; }

main { max-width: 1120px; margin: 0 auto; padding: 14px 16px 40px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px 16px; margin: 12px 0;
}
.label { font-size: 11px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }

/* HOME */
.status {
  margin: 6px 0 4px; font-family: var(--mono); font-size: 15px; line-height: 1.9;
  display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline;
}
.status .name { font-family: var(--sans); font-weight: 700; }
.status .mode {
  font-size: 11px; letter-spacing: .1em; padding: 1px 8px; border-radius: 999px;
  border: 1px solid var(--violet); color: var(--violet);
}
.status .mode.live { border-color: var(--red); color: var(--red); }
.status .bal { font-size: 22px; font-weight: 600; }
.status .since { color: var(--faint); font-size: 12px; }
.needs {
  border: 1px solid rgba(255, 123, 138, .45); background: rgba(255, 123, 138, .07);
  border-radius: var(--r); padding: 10px 14px; margin: 10px 0;
}
.needs h2 { margin: 0 0 4px; color: var(--red); }
.needs ul { margin: 0; padding-left: 18px; }
.mission-head, .mission-foot { display: flex; justify-content: space-between; gap: 10px;
                               align-items: baseline; }
.mission-foot { font-size: 12px; color: var(--faint); margin-top: 6px; }
.bar { height: 10px; border-radius: 999px; background: rgba(255, 255, 255, .06);
       margin-top: 10px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0;
         background: linear-gradient(90deg, var(--magenta), var(--cyan));
         box-shadow: 0 0 14px rgba(255, 110, 199, .5); border-radius: 999px; }
.spark-card { padding-bottom: 8px; }
#spark { width: 100%; height: 64px; display: block; margin-top: 6px; }
#spark .line { fill: none; stroke: var(--cyan); stroke-width: 1.6;
               filter: drop-shadow(0 0 4px rgba(94, 231, 255, .6)); }
#spark .area { fill: url(#sparkfill); }
.brief ol { margin: 0; padding-left: 20px; }
.brief li { margin: 6px 0; }
.brief li .mono { color: var(--cyan); }

/* DESK */
.seats { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 8px; scrollbar-width: thin; }
.seat {
  flex: 0 0 auto; display: flex; flex-direction: column; gap: 2px; align-items: flex-start;
  padding: 7px 10px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); cursor: pointer; font: inherit;
}
.seat b { font-size: 11px; letter-spacing: .08em; }
.seat span { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.seat:hover, .seat:focus-visible { border-color: var(--violet); outline: none; }
.flow { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.flow .node { text-align: center; flex: 1; }
.flow .node b { display: block; font: 600 22px/1.2 var(--mono); }
.flow .node span { font-size: 11px; color: var(--muted); text-transform: uppercase;
                   letter-spacing: .08em; }
.flow .arrow { color: var(--faint); }
.arms { display: grid; grid-template-columns: 1fr; gap: 10px; }
.arm { margin: 0; }
.arm header { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.arm .name { font-weight: 600; }
.badge {
  display: inline-block; font-size: 10px; letter-spacing: .08em; padding: 1px 7px;
  border-radius: 999px; border: 1px solid var(--line); color: var(--muted);
  text-transform: uppercase; white-space: nowrap;
}
.badge.shadow { border-color: var(--violet); color: var(--violet); }
.badge.probation { border-color: var(--amber); color: var(--amber); }
.badge.scaled { border-color: var(--green); color: var(--green); }
.badge.retired, .badge.fail, .badge.gated { border-color: var(--red); color: var(--red); }
.badge.pass { border-color: var(--green); color: var(--green); }
.badge.insufficient, .badge.untestable { border-color: var(--amber); color: var(--amber); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 10px 0 6px; }
.stats div { font-size: 11px; color: var(--muted); }
.stats b { display: block; font: 500 14px/1.3 var(--mono); color: var(--text); }
.arm details { margin-top: 6px; color: var(--muted); font-size: 13px; }
.arm summary { cursor: pointer; color: var(--muted); }
.arm dl { margin: 6px 0 0; }
.arm dt { color: var(--faint); font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
          margin-top: 6px; }
.arm dd { margin: 0; }
.distance { font-size: 13px; color: var(--muted); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 500; color: var(--faint); font-size: 11px;
     text-transform: uppercase; letter-spacing: .07em; padding: 6px 8px;
     border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r);
          background: var(--card); }
.empty td { color: var(--faint); font-style: italic; }

/* MARKET */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; }
.chip { font-family: var(--mono); font-size: 12px; padding: 2px 9px; border-radius: 999px;
        border: 1px solid var(--line); color: var(--muted); }
.chip.hot { border-color: var(--magenta); color: var(--magenta); }
.gauges { display: grid; gap: 8px; }
.gauge { display: grid; grid-template-columns: 52px 1fr 128px; gap: 10px; align-items: center;
         font-size: 13px; }
.gauge .track { position: relative; height: 8px; border-radius: 999px;
                background: rgba(255, 255, 255, .06); }
.gauge .track::after { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px;
                       width: 1px; background: var(--faint); }
.gauge .fill { position: absolute; top: 0; bottom: 0; border-radius: 999px; }
.gauge .fill.long { background: var(--green); }
.gauge .fill.short { background: var(--red); }
.heat { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 14px; }
.hist .bars { display: flex; align-items: flex-end; gap: 1px; height: 54px;
              border-bottom: 1px solid var(--line); }
.hist .bars i { flex: 1; background: var(--violet); opacity: .8; min-height: 1px;
                border-radius: 2px 2px 0 0; }
.hist .bars i.below { background: var(--red); }
.hist .bars i.above { background: var(--green); }
.hist .bars i.mark { background: var(--cyan); }
.hist .cap { display: flex; justify-content: space-between; font-size: 11px;
             color: var(--faint); margin-top: 3px; }

/* BRAIN */
.board { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.board .col { background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
              padding: 10px 12px; min-height: 64px; }
.board .col ul { margin: 6px 0 0; padding: 0; list-style: none; font-family: var(--mono);
                 font-size: 13px; }
.note { margin: 8px 0; }
.note p { margin: 4px 0 0; color: var(--muted); }
pre.md { white-space: pre-wrap; font: 12px/1.5 var(--mono); color: var(--muted);
         max-height: 420px; overflow: auto; }

/* LOG */
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filters label { font-family: var(--mono); font-size: 12px; color: var(--muted);
                 display: inline-flex; align-items: center; gap: 4px; min-height: 30px;
                 padding: 0 8px; border: 1px solid var(--line); border-radius: 999px; }
.log { font: 12px/1.6 var(--mono); max-height: 70vh; overflow-y: auto; }
.log div { display: grid; grid-template-columns: 6ch 9ch 1fr; gap: 8px;
           border-bottom: 1px dashed var(--line); padding: 3px 0; }
.log .k { color: var(--magenta); }
.log .t { color: var(--faint); }

dialog {
  background: var(--bg-1); color: var(--text); border: 1px solid var(--line);
  border-radius: var(--r); max-width: 560px; width: calc(100% - 24px); padding: 18px;
}
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog .close { float: right; background: none; border: 1px solid var(--line);
                color: var(--muted); border-radius: 8px; padding: 4px 10px; cursor: pointer; }
dialog ul { padding-left: 18px; }
dialog .recent { font-size: 12px; color: var(--muted); }

@media (min-width: 760px) {
  main { padding: 20px 28px 48px; }
  .arms { grid-template-columns: repeat(2, 1fr); }
  .heat { grid-template-columns: repeat(3, 1fr); }
  .board { grid-template-columns: repeat(4, 1fr); }
  .status { font-size: 16px; }
  .status .bal { font-size: 26px; }
}
@media (min-width: 1200px) {
  .arms { grid-template-columns: repeat(3, 1fr); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
body[data-stale]::after {
  content: "stale: retrying"; position: fixed; right: 12px; bottom: 12px; z-index: 60;
  font: 11px var(--mono); color: var(--amber); border: 1px solid var(--amber);
  border-radius: 999px; padding: 2px 9px; background: var(--bg-0);
}
/* 390px: Home is the whole first screen */
@media (max-width: 480px) {
  main { padding: 8px 12px 32px; }
  .card { padding: 10px 12px; margin: 8px 0; }
  .status { line-height: 1.6; margin: 2px 0; }
  #spark { height: 40px; }
  .brief li { margin: 3px 0; font-size: 14px; line-height: 1.4; }
  .needs { padding: 8px 12px; margin: 8px 0; font-size: 14px; }
}
