/*
 * Live strategy runs.
 *
 * One row per strategy × instrument, because that is the unit that starts and stops. The
 * signal chip carries colour and the stop button is always reachable — a run the trader
 * cannot stop in one click is a run they will not start in the first place.
 */
.runs {
  display: flex;
  flex-direction: column;
  gap: var(--space-1, 0.25rem);
  min-height: 0;
  overflow-y: auto;
}

.runs__rows {
  display: flex;
  flex-direction: column;
  gap: var(--space-1, 0.25rem);
}

.runs__row {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto auto auto;
  align-items: center;
  gap: var(--space-2, 0.5rem);
  padding: var(--space-1, 0.25rem) 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--font-size-xs, 0.6875rem);
}

.runs__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.runs__instrument {
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.runs__signal {
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.runs__signal {
  display: flex;
  align-items: center;
  gap: var(--space-1, 0.25rem);
}

.runs__signal--long {
  color: var(--green);
}

.runs__signal--short {
  color: var(--orange);
}

/* Neither long nor short is not a third opinion — it is the absence of one, and it should
   read as quiet rather than as a third colour competing for attention. */
.runs__signal--flat {
  color: var(--ink-muted);
}

/* Conviction as a bar, because "0.72" is a number the eye has to read and a bar is one it
   does not. */
.runs__strength {
  display: block;
  width: 2.5rem;
  height: 2px;
  background: var(--line);
  overflow: hidden;
}

.runs__strength i {
  display: block;
  height: 100%;
  width: 0;
  background: currentColor;
}

/*
 * The auto-built tuning form. Two columns so the labels line up down the block and the
 * inputs stay a consistent target — a form whose fields jog left and right with the label
 * length is one that gets misclicked mid-session.
 */
.runs__params {
  display: flex;
  flex-direction: column;
  gap: var(--space-1, 0.25rem);
  padding-bottom: var(--space-2, 0.5rem);
  border-bottom: 1px solid var(--line);
}

.runs__param {
  display: grid;
  grid-template-columns: 1fr 5rem;
  align-items: center;
  gap: var(--space-2, 0.5rem);
}

.runs__param input[type='number'],
.runs__param input[type='text'],
.runs__param select {
  width: 100%;
  min-width: 0;
  background: var(--surface-2, transparent);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius, 2px);
  padding: 0.15rem 0.3rem;
  font: inherit;
  font-variant-numeric: tabular-nums;
}

.runs__param input[type='checkbox'] {
  justify-self: start;
}

/*
 * A benched run. Bordered rather than hidden — the point of quarantine is that the trader
 * can see what stopped and why, and put it back with one click.
 */
.runs__row--benched {
  grid-template-columns: auto auto 1fr auto;
  border-left: 2px solid var(--orange);
  padding-left: var(--space-1, 0.25rem);
}

.runs__error {
  color: var(--orange);
  min-width: 0;
}

/*
 * The recent-calls strip under a run. Deliberately tiny: it is context for a decision
 * already made, not a reading to trade off, and anything larger would compete with the
 * live signal chip beside it.
 */
.runs__recent {
  grid-column: 1 / -1;
  display: flex;
  gap: var(--space-1, 0.25rem);
  opacity: 0.6;
}

.runs__past {
  font-size: var(--font-size-xs, 0.6875rem);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.runs__past--buy {
  color: var(--green);
}

.runs__past--sell {
  color: var(--orange);
}

/*
 * The weights editor. A range input rather than a number field: the trader is expressing a
 * relative preference between strategies, not entering a figure, and dragging says that
 * where typing 37 does not.
 */
.runs__weights {
  display: flex;
  flex-direction: column;
  gap: var(--space-1, 0.25rem);
  padding-bottom: var(--space-2, 0.5rem);
  border-bottom: 1px solid var(--line);
}

.runs__weight {
  display: grid;
  grid-template-columns: 1fr 6rem 2.5rem;
  align-items: center;
  gap: var(--space-2, 0.5rem);
  font-size: var(--font-size-xs, 0.6875rem);
}

.runs__weight input[type='range'] {
  width: 100%;
  accent-color: var(--green);
}

.runs__weight .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* A preset that has been edited away from says so, because a picker showing "standard"
   over params that are no longer standard is worse than no picker at all. */
.runs__preset.is-dirty {
  border-color: var(--orange);
  color: var(--orange);
}

/*
 * The scoreboard. Net leads and is the only coloured column: win rate and fire count are
 * context for it, not competitors — a strategy can win 80% of its trades and still be the
 * one to switch off.
 */
.score {
  display: flex;
  flex-direction: column;
  gap: var(--space-1, 0.25rem);
  min-height: 0;
  overflow-y: auto;
}

.score__rows {
  display: flex;
  flex-direction: column;
}

.score__row {
  display: grid;
  grid-template-columns: 1fr auto 2.5rem 3.5rem 3.5rem;
  gap: var(--space-2, 0.5rem);
  align-items: center;
  padding: 0.15rem 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--font-size-xs, 0.6875rem);
  font-variant-numeric: tabular-nums;
}

.score__net {
  font-weight: 600;
}

.score__row--up .score__net {
  color: var(--green);
}

.score__row--down .score__net {
  color: var(--orange);
}

.score__cell {
  color: var(--ink-muted);
  text-align: right;
}

/*
 * Alerts. The form is three controls on one line because the whole promise is "set an
 * alert in under three seconds", and a control that needs scrolling to reach breaks it.
 */
.alerts {
  display: flex;
  flex-direction: column;
  gap: var(--space-1, 0.25rem);
}

.alerts__form {
  display: grid;
  grid-template-columns: 1fr 3rem auto;
  gap: var(--space-1, 0.25rem);
  align-items: center;
}

.alerts__form input,
.alerts__form select {
  min-width: 0;
  background: var(--surface-2, transparent);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius, 2px);
  padding: 0.15rem 0.3rem;
  font: inherit;
  font-variant-numeric: tabular-nums;
}

.alerts__chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1, 0.25rem);
}

/* A spent alert stays on screen and reads as spent. Hiding it would look identical to an
   armed alert that simply has not fired, which is the one confusion worth preventing. */
.alerts__chip--spent {
  opacity: 0.5;
  border-style: dashed;
}

.alerts__x {
  background: none;
  border: 0;
  color: inherit;
  cursor: pointer;
  padding: 0 0 0 0.2rem;
  font: inherit;
}

/*
 * The alert log. Terminal rows: fixed-width time, source, then the text — the same three
 * columns a tail has had for fifty years, because the eye already knows where to look.
 */
.alog {
  display: flex;
  flex-direction: column;
  gap: var(--space-1, 0.25rem);
  min-height: 0;
}

.alog__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem;
}

.alog__chips .is-active {
  border-color: var(--green);
  color: var(--green);
}

.alog__rows {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
}

.alog__row {
  display: grid;
  grid-template-columns: 5.5rem 3.5rem 1fr;
  gap: var(--space-1, 0.25rem);
  align-items: baseline;
  padding: 0.1rem 0;
  font-size: var(--font-size-xs, 0.6875rem);
  cursor: pointer;
}

.alog__time,
.alog__source {
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

/* Only the two tiers worth interrupting for get a colour here. Colouring every row would
   make the log exactly as unreadable as the toast stack it exists to replace. */
.alog__row--warn .alog__text,
.alog__row--error .alog__text {
  color: var(--orange);
}

.alog__row--success .alog__text {
  color: var(--green);
}

.alog__text {
  min-width: 0;
}

/*
 * The auto-trade block. The arm switch is the largest control on the desk on purpose: it
 * is the one that decides whether the software spends money without being asked.
 */
.bot {
  display: flex;
  flex-direction: column;
  gap: var(--space-1, 0.25rem);
  min-height: 0;
}

.bot__arm {
  padding: var(--space-2, 0.5rem);
  border: 1px solid var(--line);
  border-radius: var(--radius, 2px);
  background: transparent;
  color: var(--ink-muted);
  font: inherit;
  letter-spacing: 0.08em;
  cursor: pointer;
}

/* Armed is the loud state. A disarmed bot looking the same as an armed one is the only
   truly unacceptable outcome in this block. */
.bot__arm.is-armed {
  border-color: var(--green);
  color: var(--green);
  box-shadow: 0 0 10px color-mix(in srgb, var(--green) 35%, transparent);
}

.bot__rows {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
}

.bot__row {
  display: grid;
  grid-template-columns: 1fr auto 1.6fr;
  gap: var(--space-1, 0.25rem);
  padding: 0.1rem 0;
  font-size: var(--font-size-xs, 0.6875rem);
  color: var(--ink-muted);
}

/* A decision that became an order stands out from the many that did not. */
.bot__row.is-taken .bot__action {
  color: var(--green);
}

.bot__reason {
  min-width: 0;
  text-align: right;
}

.runs__auto b {
  color: var(--green);
  font-size: var(--font-size-xs, 0.6875rem);
  letter-spacing: 0.04em;
}

/* The rate meter and the bench. Orange before the ceiling, because a meter read only at
   the limit is a meter that never helped. */
.label.is-hot,
.bot__cooldown {
  color: var(--orange);
}

/* The dry-run banner. Striped and loud on purpose: mistaking a rehearsal for live, or
   live for a rehearsal, is the only mistake in this block that costs money. */
.bot__dry {
  padding: 0.2rem var(--space-2, 0.5rem);
  border: 1px dashed var(--orange);
  color: var(--orange);
  font-size: var(--font-size-xs, 0.6875rem);
  letter-spacing: 0.06em;
  text-align: center;
}
