/* The redesign's components, built on tokens.css.
 *
 * Every value here comes from the mockup. Where the mockup showed one state
 * only, the missing states (hover, focus, disabled) follow its own logic
 * rather than a new idea: tint for hover, accent border plus ring for focus.
 */

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-body);
  font: 400 14px/1.5 var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, figure { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* Numbers everywhere are mono and tabular so columns line up. */
.num, td.num, .nums td, table.dt td {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

:where(a, button, input, select, summary):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---------- Layout ---------- */

.layout { display: flex; min-height: 100vh; align-items: stretch; }

.sidebar {
  width: var(--sidebar-width);
  flex: 0 0 var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border-soft);
  padding: var(--space-5) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  position: sticky;
  top: 0;
  height: 100vh;
}

.content {
  flex: 1 1 auto;
  min-width: 0;            /* or a wide table stretches the whole page */
  padding: var(--space-6) var(--space-8) var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.page-eyebrow {
  color: var(--text-label);
  font-size: 13px;
  margin-bottom: var(--space-1);
}

.page-title { font-size: 30px; font-weight: 600; letter-spacing: -0.02em; color: var(--text); }
.page-title .sep { color: var(--border-strong); font-weight: 400; margin: 0 var(--space-2); }

.page-head-actions { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }

/* ---------- Sidebar ---------- */

.brand { display: flex; align-items: center; gap: var(--space-3); color: inherit; }
/* 36px on a 10px radius, as measured in the mockup. The mark inside is
 * currentColor, so inverting the badge inverts the mark - which is how the
 * mockup draws it light on the sign-in page and dark here. The file logo this
 * replaced had to be forced white with an invert filter, which is why it
 * looked like a different drawing. */
.brand-mark {
  width: 36px; height: 36px; border-radius: var(--radius-md);
  background: var(--surface-inverse);
  color: var(--text-inverse);
  display: inline-flex; align-items: center; justify-content: center;
  flex: none;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; color: var(--text); }
.brand-sub { font-size: 12px; color: var(--text-label); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: var(--space-3);
  height: var(--control-md); padding: 0 var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-muted); font-weight: 500; font-size: 14px;
}
.nav-item svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav-item:hover { background: var(--surface-nav-hover); color: var(--text); }
.nav-item.is-current { background: var(--accent-tint); color: var(--accent); }
.nav-item-danger { color: var(--danger); }
.nav-item-danger:hover { background: var(--danger-tint); color: var(--danger); }

.side-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-label);
  margin-bottom: var(--space-2);
}
.side-card {
  border: 1px solid var(--border-soft); border-radius: var(--radius-lg);
  padding: var(--space-3); display: flex; flex-direction: column; gap: var(--space-3);
}
.side-card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.side-card-title { font-weight: 600; color: var(--text); }
.side-note {
  display: flex; gap: var(--space-2); align-items: flex-start;
  font-size: 12px; color: var(--warning-strong);
}
.side-note-icon { width: 15px; height: 15px; flex: none; margin-top: 2px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: var(--space-2); }
.side-status { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; font-size: 12px; color: var(--text-subtle); }

.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex: none; }
.dot-positive { background: var(--positive-dot); }
.dot-warning { background: var(--warning-dot); }

/* ---------- Controls ---------- */

.btn {
  display: inline-flex; align-items: center; gap: var(--space-2);
  height: var(--control-md); padding: 0 14px;
  border-radius: var(--radius-md); border: 1px solid var(--border);
  background: var(--surface); color: var(--text-body);
  font: 500 13.5px var(--font-sans); cursor: pointer; white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn:hover { border-color: var(--border-strong); background: var(--surface-hover); }
.btn-primary {
  background: var(--accent); border-color: var(--accent); color: var(--text-inverse);
  height: var(--control-sm); border-radius: 9px;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-inverse { background: var(--surface-inverse); border-color: var(--surface-inverse); color: var(--text-inverse); }
.btn-inverse:hover { background: #000; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn[disabled]:hover { border-color: var(--border); background: var(--surface); }

.field {
  height: var(--control-md); box-sizing: border-box;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 0 var(--space-3);
  font: 500 13.5px var(--font-mono); color: var(--text);
  background: var(--surface); outline: none;
}
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }

.field-group {
  display: inline-flex; align-items: center; gap: var(--space-2);
  height: var(--control-md); padding: 0 var(--space-1) 0 var(--space-3);
  border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface);
}
.field-group label { font-size: 12.5px; color: var(--text-faint); }
.field-group .field { border: 0; box-shadow: none; height: 34px; padding: 0 var(--space-1); width: 110px; }

.segmented {
  display: flex; gap: var(--space-1); padding: var(--space-1);
  background: var(--surface-sunken); border-radius: var(--radius-md);
}
.segment {
  flex: 1 1 0; height: var(--control-sm); background: transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: var(--radius-sm);
  font: 500 13px var(--font-sans); color: var(--text-faint); cursor: pointer;
  white-space: nowrap;   /* "Single order" wrapped and made the control two lines tall */
  padding: 0 12px;
}
.segment:hover { color: var(--text); }
.segment.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-card); }

/* An accent-filled active segment. The plain .segment keeps the mockup's
 * white-on-grey, which is what the sidebar and the chart's view switch use;
 * this modifier is for the pages where the active mode should read as a
 * choice the operator made, in the same purple as the primary buttons. */
.segmented-accent .segment.is-active {
  background: var(--accent); color: var(--text-inverse); box-shadow: none;
}
.segmented-accent .segment.is-active:hover { background: var(--accent-hover); color: var(--text-inverse); }

.tabs { display: flex; align-items: center; gap: var(--space-5); border-bottom: 1px solid var(--border-soft); }
.tab {
  display: inline-flex; align-items: center; gap: var(--space-2);
  height: var(--control-tab); padding: 0 2px;
  border: 0; border-bottom: 2px solid transparent; background: none;
  font: 500 14px var(--font-sans); color: var(--text-faint); cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--text); border-bottom-color: var(--accent); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 9px;
  border-radius: 999px; font-size: 12px; font-weight: 500;
  background: var(--surface-sunken); color: var(--text-subtle);
}
.chip-quiet {
  background: var(--surface-nav-hover); color: var(--text-faint);
  font-family: var(--font-mono); font-size: 11px; font-weight: 400;
  border-radius: var(--radius-chip); height: 20px; padding: 0 6px;
}
/* Inside a table cell the mockup uses a 6px rectangle rather than a pill:
   at 11px a full pill reads as a button. */
table.dt .chip { border-radius: var(--radius-chip); height: 20px; font-size: 11px; font-weight: 600; padding: 0 7px; font-family: var(--font-mono); }
table.dt .chip-accent, table.dt .chip-warning {
  border-radius: 999px; height: 24px; font-size: 12px; padding: 0 9px;
  font-weight: 500; font-family: var(--font-sans);
}
.chip-accent { background: var(--accent-tint); color: var(--accent-hover); }
.chip-positive { background: var(--positive-tint); color: var(--positive); }
.chip-warning { background: var(--warning-tint); color: var(--warning); }
.chip-danger { background: var(--danger-tint); color: var(--danger); }

.filter-row { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }

.filter-chip {
  display: inline-flex; align-items: center; gap: var(--space-2);
  height: var(--control-sm); padding: 0 var(--space-3);
  border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-body);
  font: 500 13px var(--font-sans); cursor: pointer;
}
.filter-chip:hover { border-color: var(--border-strong); color: var(--text); }
.filter-chip.is-active { background: var(--surface-inverse); border-color: var(--surface-inverse); color: var(--text-inverse); }
.filter-chip .count { font-family: var(--font-mono); opacity: 0.7; }

/* The inline "?" next to a column header. It was styled by the old
 * stylesheet; without a rule here it falls back to a browser default button,
 * which is Arial with a 2px black border and reads as a defect. */
.help {
  width: 18px; height: 18px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 50%;
  background: var(--surface); color: var(--text-faint);
  font: 600 10px var(--font-sans); line-height: 1; cursor: help;
  vertical-align: middle; margin-left: 4px;
}
.help:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-tint); }

.tab-count { color: var(--text-faint); font-size: 13px; }
.tab.is-active .tab-count { color: var(--text-faint); }

.tab-pane[hidden] { display: none; }
.pane-tools {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3); flex-wrap: wrap;
  padding: var(--space-3) var(--space-5);
}

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
}
.card-title { font-size: 15px; font-weight: 600; color: var(--text); }
.card-body { padding: 0 var(--space-5) var(--space-5); }
.card-inverse { background: var(--surface-inverse); border-color: var(--surface-inverse); color: var(--text-inverse); }
.card-inverse .card-title, .card-inverse .stat-value { color: var(--text-inverse); }
.card-inverse .stat-label,
.card-inverse .stat-hint,
.card-inverse .num { color: var(--text-inverse-muted); }

/* A filesystem path has no spaces to break at, so without this it runs
 * past the edge of its card. */
.path { font-family: var(--font-mono); font-size: 12px; color: var(--text-faint);
        overflow-wrap: anywhere; white-space: normal; }

/* Cards converted from the old markup put their content straight inside the
 * card, with no .card-body wrapper. Without these, the title and the table sit
 * flush against the card's edge. A table cannot take padding, so it gets a
 * margin and a width to match. */
.card > .card-title { display: block; padding: var(--space-4) var(--space-5) var(--space-2); }
.card > table.kv { width: calc(100% - var(--space-5) * 2); margin: 0 var(--space-5) var(--space-4); }
.card > .chip-row, .card > p, .card > .pagination { padding: 0 var(--space-5) var(--space-4); }
.card > .empty { padding: var(--space-5); }

.card-grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

.stat-label { font-size: 12.5px; color: var(--text-label); }
.stat-value { font: 600 26px/1.15 var(--font-mono); color: var(--text); font-variant-numeric: tabular-nums; }
.stat-hint { font-size: 11.5px; color: var(--text-label); font-family: var(--font-mono); }
.stat-row { display: grid; gap: var(--space-4) var(--space-5); grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }

/* A stat block: label, figure, an optional bar, an optional hint. Measured
 * in the mockup: 12px label, 20px/500 figure, 11.5px hint, 6px between them,
 * two columns with 16px/20px gaps. */
.stat-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4) var(--space-5);
}
.stat { display: flex; flex-direction: column; gap: 6px; }
.stat-figure {
  font: 500 20px/1.3 var(--font-mono); font-variant-numeric: tabular-nums;
  color: var(--text);
}
.stat-footer {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3); margin-top: var(--space-4);
  padding-top: var(--space-3); border-top: 1px solid var(--border-faint);
}

.headline { display: flex; align-items: baseline; gap: var(--space-2); flex-wrap: wrap; }
.headline-figure {
  font: 500 40px/1.1 var(--font-mono); font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em; color: var(--text);
}

.subcards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); margin-top: var(--space-4); }
.subcard {
  border: 1px solid var(--border-soft); border-radius: var(--radius-md);
  padding: var(--space-3); display: flex; flex-direction: column; gap: 6px;
}
.subcard-title { font-weight: 600; font-size: 13px; color: var(--text); }
.subcard-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2); font-size: 12px; }
.subcard-row .num { font-size: 12px; color: var(--text); }

.meter { height: 4px; border-radius: 2px; background: var(--border-faint); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.meter-warning > span { background: var(--warning-dot); }

/* ---------- Tables ---------- */

.table-wrap { overflow: auto; max-width: 100%; }

table.dt { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
table.dt th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-sunken); color: var(--text-faint);
  font-weight: 500; font-size: 11.5px; letter-spacing: 0.01em;
  text-align: right; white-space: nowrap;
  padding: 10px 12px; border-bottom: 1px solid var(--border-soft);
}
table.dt td {
  text-align: right; white-space: nowrap;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border-faint);
  color: var(--text-body); background: var(--surface);
}
table.dt tbody tr:hover td { background: var(--surface-row-hover); }
table.dt th.l, table.dt td.l { text-align: left; }
/* The symbol column stays put while the rest scrolls sideways. */
table.dt th.stk, table.dt td.stk { position: sticky; left: 0; z-index: 1; box-shadow: 1px 0 0 var(--border-soft); }
table.dt th.stk { z-index: 2; }
table.dt tr.is-selected td { background: var(--accent-tint); }

/* The run history sits in a narrow card, so its rows are tighter than a
 * full-width data table's. */
table.dt-compact td, table.dt-compact th { padding: 7px 10px; }
table.dt-compact td a { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--text); }
table.dt-compact td a:hover { color: var(--accent); }
.run-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); flex: none; }
.run-dot.is-current { background: var(--accent); }

/* A score drawn as a bar next to its number: a column of values that all sit
 * between 0.6 and 0.95 is unreadable as text alone. */
.cell-meter { display: inline-flex; align-items: center; gap: var(--space-2); justify-content: flex-end; }
.cell-meter .meter { width: 56px; flex: none; }
.cell-meter .num { font-size: 13px; }
.chip.reason-pill { border: 0; cursor: help; }

/* Rank and symbol in one cell, as the mockup has them: an 18px grey number,
 * 12px gap, then the symbol over its variant and market. */
/* The parameter chips. They were .pill-params, which lived in the old
 * stylesheet this page no longer loads, so they had been rendering as bare
 * browser buttons in grey. The first one carries the strategy and is dark,
 * as in the mockup; the rest are quiet. */
.param-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 7px; border: 0; border-radius: var(--radius-chip);
  font: 400 11.5px var(--font-mono); cursor: pointer;
  background: var(--surface-nav-hover); color: var(--text-body);
}
.param-chip:hover { background: var(--accent-tint); color: var(--accent-hover); }
/* The strategy. */
.param-chip-strong { background: var(--surface-inverse); color: var(--text-inverse); }
.param-chip-strong:hover { background: #000; color: var(--text-inverse); }
/* A grid that is switched on, and one that is not: the mockup makes the
 * difference visible rather than leaving it to be read off a number. */
.param-chip-on { background: var(--accent-tint); color: var(--accent-hover); }
.param-chip-off {
  background: var(--surface); color: var(--text-label);
  box-shadow: inset 0 0 0 1px var(--border-soft);
}
.param-chip-off:hover { background: var(--surface-nav-hover); color: var(--text-body); }
/* One line, as in the mockup: wrapping these chips made every row in the
 * table twice as tall as the design, because the row grows to the
 * tallest cell. The table already scrolls sideways.
 *
 * Left-aligned, because right-aligning chips of different widths leaves
 * every row starting in a different place and the column reads as scattered. */
.cell-params { display: flex; align-items: center; gap: 4px; flex-wrap: nowrap; justify-content: flex-start; }
table.dt td.params-cell, table.dt th.params-head { text-align: left; }

/* Actions are icon buttons in the mockup, not a row of worded links. */
/* The blacklist control comes from a partial shared with pages the redesign
 * has not reached, so it keeps its markup and gets its look here. */
.mini-danger {
  display: inline-flex; align-items: center; justify-content: center;
  height: 30px; padding: 0 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--danger); font: 500 12px var(--font-sans); cursor: pointer;
  white-space: nowrap;
}
.mini-danger:hover { background: var(--danger-tint); border-color: var(--danger-tint); }
.muted-figure { color: var(--text-subtle); }

.icon-action {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent; color: var(--text-subtle);
  cursor: pointer; padding: 0;
}
.icon-action svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-action:hover { background: var(--accent-tint); color: var(--accent-hover); }
.icon-action.is-danger:hover { background: var(--danger-tint); color: var(--danger); }

.cell-actions { display: inline-flex; align-items: center; gap: 2px; justify-content: flex-end; white-space: nowrap; }
.icon-action.is-marked { color: var(--danger); cursor: default; }

.cell-id { display: flex; align-items: center; gap: var(--space-3); }
.cell-rank { width: 18px; flex: none; color: var(--text-label); font-size: 12px; text-align: left; }
.symbol-trigger {
  border: 0; background: none; padding: 0; cursor: pointer; text-align: left;
  font: 600 13.5px var(--font-mono); color: var(--text-body);
}
.symbol-trigger:hover { color: var(--accent); }

.cell-symbol { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }
.cell-symbol b { font-weight: 600; font-size: 13.5px; color: var(--text-body); }
/* line-height normal, not the body's 1.5: inherited, it made the sub-line
 * 17px instead of 14 and every row in the table 2px taller than the
 * mockup's 57. */
.cell-symbol small { color: var(--text-label); font-size: 11px; line-height: normal; }

/* These have to out-specify `table.dt td`, which sets the cell colour: as
 * bare classes they lost to it, so a positive Net PnL was never green. */
.pos, table.dt td.pos { color: var(--positive-figure); }
.neg, table.dt td.neg { color: var(--danger); }
.warn, table.dt td.warn, table.dt td .warn { color: var(--warning-strong); }
table.dt td.muted-figure { color: var(--text-subtle); }

/* The mockup keeps only the figures in the mono face. Chips and controls
 * inside a cell stay in Geist, which `table.dt td` would otherwise override. */
table.dt td .icon-action,
table.dt td .mini-danger,
table.dt td .filter-chip { font-family: var(--font-sans); }

/* Weights the mockup gives particular columns: the score is the thing the
 * table is sorted by, and a result that made the whitelist is a verdict. */
table.dt td.col-score { font-weight: 600; }
table.dt td.col-holdout { font-size: 12.5px; }
table.dt td.col-pnl { font-weight: 500; }

/* Key/value blocks inside a card. They share table.dt's markup but not its
 * behaviour: a label belongs on the left, there is no sticky header to hold,
 * and a long value has to wrap rather than push the card past its column. */
table.kv { width: 100%; font-size: 13px; }
table.kv td { padding: 8px 0; border-bottom: 1px solid var(--border-faint); vertical-align: top; }
table.kv tr:last-child td { border-bottom: 0; }
table.kv td:first-child {
  text-align: left; white-space: normal;
  color: var(--text-faint); font-family: var(--font-sans); font-size: 12.5px;
  width: 45%;
}
table.kv td:last-child {
  text-align: right; white-space: normal; overflow-wrap: anywhere;
  color: var(--text); font-family: var(--font-mono); font-variant-numeric: tabular-nums;
}
table.kv tbody tr:hover td { background: transparent; }

.chip-row { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip-row span {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 var(--space-3); border-radius: 999px;
  background: var(--surface-sunken); color: var(--text-subtle); font-size: 12.5px;
}

.table-foot {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border-faint);
  font-size: 12.5px; color: var(--text-faint);
}

.legend { display: flex; align-items: center; gap: var(--space-4); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

.empty { padding: var(--space-8) var(--space-5); text-align: center; color: var(--text-faint); }

/* ---------- Chart ---------- */

.chart-shell { display: flex; flex-direction: column; gap: var(--space-3); }
.chart-view-switch { align-self: flex-start; }
.chart-view-switch .segment { padding: 0 14px; }
.loading-card { padding: var(--space-5); }
.chart-action-form { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.capital-input { width: 120px; }

.drawing-toolbar { display: flex; align-items: center; gap: var(--space-1); flex-wrap: wrap; }
.tool-button {
  display: inline-flex; align-items: center; gap: 6px;
  height: var(--control-sm); padding: 0 10px;
  border: 1px solid var(--border-soft); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-subtle);
  font: 500 12.5px var(--font-sans); cursor: pointer;
}
.tool-button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tool-button:hover { border-color: var(--border-strong); color: var(--text); }
.tool-button.is-active { background: var(--accent-tint); border-color: var(--accent-tint); color: var(--accent-hover); }

#chart-wrap {
  position: relative; background: var(--surface);
  border: 1px solid var(--border-soft); border-radius: var(--radius-lg);
  overflow: hidden; min-height: 460px;
}
.chart-pane { display: none; width: 100%; height: 100%; min-height: 460px; }
.chart-pane.active { display: block; }
#drawing-layer { position: absolute; inset: 0; pointer-events: none; }
.fib-hover {
  position: absolute; pointer-events: none; z-index: 3;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 6px 8px;
  font: 500 11.5px var(--font-mono); color: var(--text);
  box-shadow: var(--shadow-pop);
}

/* ---------- Login ----------
 * Two halves, as the mockup draws them: the product on a dark panel with the
 * spiral the strategy is named after, the form on the light one. Values are
 * the mockup's own.
 */

.login-page { margin: 0; display: flex; flex-wrap: wrap; min-height: 100vh; background: var(--bg); }

.login-aside {
  flex: 1 1 480px; min-width: 0; box-sizing: border-box; min-height: 520px;
  background: var(--surface-inverse); color: var(--text-inverse);
  padding: 40px 48px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 48px;
  position: relative; overflow: hidden;
}
.login-spiral { position: absolute; right: -180px; bottom: -60px; width: 900px; height: auto; opacity: 0.9; }

.login-brand { display: flex; align-items: center; gap: var(--space-3); position: relative; }
.login-mark {
  width: 40px; height: 40px; border-radius: 11px; background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.login-brand-text { display: flex; flex-direction: column; gap: 2px; }
.login-brand-name { font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.login-brand-sub { font-size: 12px; color: #A9B0BC; }

.login-pitch { display: flex; flex-direction: column; gap: 28px; position: relative; max-width: 460px; }
.login-pitch h1 {
  font-size: 44px; line-height: 1.08; font-weight: 600;
  letter-spacing: -0.03em; text-wrap: balance;
}
.login-points { display: flex; flex-direction: column; gap: var(--space-3); font-size: 14px; color: #C9CED6; }
.login-points > div { display: flex; align-items: center; gap: var(--space-3); }
.login-points .num { width: 28px; flex: none; font-size: 12px; color: #6E7684; }

.login-status {
  display: flex; align-items: center; gap: var(--space-2);
  font-size: 12.5px; color: #A9B0BC; position: relative;
}

.login-main {
  flex: 1 1 480px; min-width: 0; box-sizing: border-box;
  padding: 40px var(--space-6);
  display: flex; align-items: center; justify-content: center;
}
.login-form { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 28px; }
.login-heading { display: flex; flex-direction: column; gap: var(--space-2); }
.login-heading h2 { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; color: var(--text); }
.login-heading p { font-size: 14px; color: var(--text-subtle); }

.login-fields { display: flex; flex-direction: column; gap: 18px; }
.login-field { display: flex; flex-direction: column; gap: var(--space-2); }
.login-field label { font-size: 13px; font-weight: 500; color: var(--text-body); }

/* Taller and rounder than the fields inside the dashboard: this is the only
 * thing on the page, and the mockup sizes it accordingly. */
.fld {
  width: 100%; height: 48px; box-sizing: border-box;
  border: 1px solid var(--border); border-radius: 12px; padding: 0 14px;
  font: 500 15px var(--font-sans); color: var(--text); background: var(--surface); outline: none;
}
.fld:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }

.login-password { position: relative; }
.login-password .fld { padding-right: 48px; }
.eye {
  position: absolute; right: 6px; top: 6px; width: 36px; height: 36px;
  border: 0; border-radius: var(--radius-sm); background: transparent;
  color: var(--text-faint); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.eye:hover { background: var(--surface-nav-hover); color: var(--text); }

.login-remember {
  display: flex; align-items: center; gap: 10px; min-height: 44px;
  font-size: 14px; color: var(--text-muted); cursor: pointer;
}
.login-remember input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }

.go {
  display: flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: 48px; border: 0; border-radius: 12px;
  background: var(--accent); color: var(--text-inverse);
  font: 600 15px var(--font-sans); cursor: pointer;
}
.go:hover { filter: brightness(1.08); }

.login-foot {
  display: flex; justify-content: space-between; gap: var(--space-3);
  padding-top: var(--space-5); border-top: 1px solid var(--border-soft);
  font-size: 12px; color: var(--text-label);
}

.login-error {
  display: flex; align-items: flex-start; gap: var(--space-2);
  padding: var(--space-3); border-radius: var(--radius-md);
  background: var(--danger-tint); color: var(--danger); font-size: 13px;
}
.login-error svg { width: 16px; height: 16px; flex: none; margin-top: 1px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

@media (max-width: 900px) {
  .login-aside { min-height: 360px; padding: var(--space-6) var(--space-5); gap: var(--space-6); }
  .login-pitch h1 { font-size: 30px; }
}

/* ---------- Chart ---------- */

.chart-shell { display: flex; flex-direction: column; gap: var(--space-3); }
.chart-view-switch { align-self: flex-start; }
.chart-view-switch .segment { padding: 0 14px; }
.loading-card { padding: var(--space-5); }
.chart-action-form { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.capital-input { width: 120px; }

.drawing-toolbar { display: flex; align-items: center; gap: var(--space-1); flex-wrap: wrap; }
.tool-button {
  display: inline-flex; align-items: center; gap: 6px;
  height: var(--control-sm); padding: 0 10px;
  border: 1px solid var(--border-soft); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-subtle);
  font: 500 12.5px var(--font-sans); cursor: pointer;
}
.tool-button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tool-button:hover { border-color: var(--border-strong); color: var(--text); }
.tool-button.is-active { background: var(--accent-tint); border-color: var(--accent-tint); color: var(--accent-hover); }

#chart-wrap {
  position: relative; background: var(--surface);
  border: 1px solid var(--border-soft); border-radius: var(--radius-lg);
  overflow: hidden; min-height: 460px;
}
.chart-pane { display: none; width: 100%; height: 100%; min-height: 460px; }
.chart-pane.active { display: block; }
#drawing-layer { position: absolute; inset: 0; pointer-events: none; }
.fib-hover {
  position: absolute; pointer-events: none; z-index: 3;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 6px 8px;
  font: 500 11.5px var(--font-mono); color: var(--text);
  box-shadow: var(--shadow-pop);
}

/* ---------- Login ---------- */

.login-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: var(--space-6) var(--space-4);
}
.login-card { width: 100%; max-width: 380px; padding: var(--space-6); }
.login-brand { margin-bottom: var(--space-6); }
.login-form { display: flex; flex-direction: column; gap: var(--space-4); }
.login-label { display: flex; flex-direction: column; gap: 6px; }
.login-label .field { font-family: var(--font-sans); }
.login-submit { justify-content: center; height: var(--control-md); margin-top: var(--space-1); }
.login-error {
  display: flex; align-items: flex-start; gap: var(--space-2);
  padding: var(--space-3); border-radius: var(--radius-md);
  background: var(--danger-tint); color: var(--danger); font-size: 13px;
}
.login-error svg { width: 16px; height: 16px; flex: none; margin-top: 1px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

/* ---------- Pagination ----------
 * The buttons carry no class of their own, so without this they are browser
 * defaults. Values are the mockup's .pg: 34px square, 8px radius, the quiet
 * border, mono digits. */

/* Right-aligned: the pager sits at the end of the table it belongs to,
 * where the eye already is after reading a row to its end. */
.pagination { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--space-1); padding: var(--space-3) var(--space-5); }
.table-foot .pagination { padding: 0; }
.pagination button {
  min-width: 34px; height: 34px; padding: 0 8px;
  border: 1px solid var(--border-soft); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-muted);
  font: 500 12.5px var(--font-mono); cursor: pointer;
}
.pagination button:hover:not(:disabled) { border-color: var(--border-strong); color: var(--text); }
.pagination button.selected {
  background: var(--accent); border-color: var(--accent); color: var(--text-inverse);
}
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.page-gap {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 34px; color: var(--text-label);
  font: 500 12.5px var(--font-mono); user-select: none;
}

/* ---------- Chart: statistics and trades ----------
 * Both panes are built by the chart's own script with classes that lived
 * only in the old stylesheet, so on the converted page they had no rules at
 * all and rendered as bare tables and text.
 */

.chart-summary {
  display: grid; gap: var(--space-3);
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-bottom: var(--space-4);
}
.chart-summary > div {
  display: flex; flex-direction: column; gap: 4px;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-soft); border-radius: var(--radius-md);
  background: var(--surface);
}
.chart-summary span { font-size: 12.5px; color: var(--text-label); }
.chart-summary strong {
  font: 500 20px/1.2 var(--font-mono); font-variant-numeric: tabular-nums;
  color: var(--text);
}
.chart-summary strong.pos { color: var(--positive-figure); }
.chart-summary strong.neg { color: var(--danger); }

.stats-grid {
  display: grid; gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.stat-section {
  border: 1px solid var(--border-soft); border-radius: var(--radius-lg);
  background: var(--surface); padding: var(--space-4) var(--space-5);
}
.stat-section h2 {
  font-size: 13px; font-weight: 600; color: var(--text);
  margin-bottom: var(--space-2);
}
table.kv.compact td { padding: 7px 0; font-size: 12.5px; }

/* The trade list is a data table and takes the same rules as the others. */
.trade-table-wrap {
  overflow: auto; border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg); background: var(--surface);
}
table.trade-table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
table.trade-table th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-sunken); color: var(--text-faint);
  font-weight: 500; font-size: 11.5px; letter-spacing: 0.01em;
  text-align: right; white-space: nowrap; cursor: pointer;
  padding: 10px 12px; border-bottom: 1px solid var(--border-soft);
}
table.trade-table th:hover { color: var(--text); }
table.trade-table th:first-child, table.trade-table td:first-child { text-align: left; }
table.trade-table td {
  text-align: right; white-space: nowrap; padding: 11px 12px;
  border-bottom: 1px solid var(--border-faint); color: var(--text-body);
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
}
table.trade-table tbody tr:hover td { background: var(--surface-row-hover); }
table.trade-table td.pos { color: var(--positive-figure); }
table.trade-table td.neg { color: var(--danger); }

.trade-filter {
  height: var(--control-md); min-width: 220px; box-sizing: border-box;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 0 var(--space-3); font: 500 13.5px var(--font-sans);
  color: var(--text); background: var(--surface); outline: none;
}
.trade-filter:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }

.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-3);
}
.panel-head .actions { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.button.compact {
  display: inline-flex; align-items: center; height: var(--control-sm); padding: 0 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-body);
  font: 500 12.5px var(--font-sans); cursor: pointer;
}
.button.compact:hover { border-color: var(--border-strong); background: var(--surface-hover); }

.empty-state { padding: var(--space-8) var(--space-5); text-align: center; color: var(--text-faint); }
.chart-pane .muted { color: var(--text-label); }
.chart-pane .pill {
  display: inline-flex; align-items: center; height: 20px; padding: 0 7px;
  border-radius: var(--radius-chip); background: var(--surface-nav-hover);
  color: var(--text-subtle); font-size: 11px;
}

/* The panes scroll inside the chart frame rather than stretching it. */
.stats-pane, .trades-pane { padding: var(--space-5); overflow: auto; }

/* ---------- Chart: the statistics tab ----------
 * Values taken from the mockup: metric cards at 16px radius and 18/20
 * padding, the Net PnL one inverted with a brighter green that works on
 * #0D1117, and the win/loss split drawn as a proportion bar over a
 * two-column table.
 */

.ts-metrics {
  display: grid; gap: var(--space-3); margin-bottom: var(--space-4);
  grid-template-columns: 2fr repeat(4, 1fr);
}
.ts-metric {
  display: flex; flex-direction: column; justify-content: center; gap: var(--space-2);
  padding: 18px 20px; border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg); background: var(--surface);
}
.ts-metric-label { font-size: 13px; color: var(--text-label); }
.ts-metric-value {
  font-size: 28px; font-weight: 500; color: var(--text);
  font-variant-numeric: tabular-nums; line-height: 1.2;
}
.ts-metric-value.neg { color: #C2410C; }

.ts-metric-net { background: var(--surface-inverse); border-color: var(--surface-inverse); }
.ts-metric-net .ts-metric-label { color: #A9B0BC; }
.ts-net-row { display: flex; align-items: baseline; gap: var(--space-2); flex-wrap: wrap; }
/* A green that reads on the dark card; --positive is for light surfaces. */
.ts-net-value { font-size: 32px; font-weight: 500; color: #5EE0A1; font-variant-numeric: tabular-nums; }
.ts-net-value.neg { color: #FF9A7A; }
.ts-net-row .ts-unit { font-size: 15px; color: #A9B0BC; }
.ts-net-pill {
  font-size: 15px; font-weight: 500; padding: 3px 8px;
  border-radius: var(--radius-chip);
  background: rgba(94, 224, 161, 0.14); color: #5EE0A1;
}
.ts-net-pill.neg { background: rgba(255, 154, 122, 0.14); color: #FF9A7A; }

.ts-columns { display: grid; gap: var(--space-4); grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.ts-column { display: flex; flex-direction: column; gap: var(--space-4); }

.ts-card {
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg); padding: var(--space-5);
  display: flex; flex-direction: column; gap: 18px;
}
.ts-card h2 { font-size: 15px; font-weight: 600; color: var(--text); }
.ts-card-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); flex-wrap: wrap; }
.ts-card-note { font-size: 13px; color: var(--text-subtle); }

.ts-split { display: flex; flex-direction: column; gap: var(--space-2); }
.ts-split-bar { display: flex; gap: 3px; height: 12px; }
.ts-bar-win { border-radius: 6px 2px 2px 6px; background: var(--positive-dot); }
.ts-bar-loss { border-radius: 2px 6px 6px 2px; background: #E0864F; min-width: 8px; }
.ts-split-legend { display: flex; justify-content: space-between; font-size: 12.5px; }
.ts-legend-win { color: var(--positive); display: inline-flex; gap: 6px; align-items: center; }
.ts-legend-loss { color: var(--danger); display: inline-flex; gap: 6px; align-items: center; }
.ts-split-legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.ts-legend-win i { background: var(--positive-dot); }
.ts-legend-loss i { background: #E0864F; }

.ts-split-table { overflow-x: auto; }
.ts-split-table table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.ts-split-table th {
  font-size: 12px; font-weight: 600; text-align: right;
  padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border-soft); width: 32%;
}
.ts-split-table th:first-child { width: auto; }
.ts-th-win { color: var(--positive); }
.ts-th-loss { color: var(--danger); padding-right: 0; }
.ts-split-table td {
  padding: 11px var(--space-3); text-align: right;
  border-bottom: 1px solid var(--border-faint); color: var(--text);
  font-variant-numeric: tabular-nums;
}
.ts-split-table td:last-child { padding-right: 0; }
.ts-split-label { text-align: left; color: var(--text-subtle); padding-left: 0; font-family: var(--font-sans); }
.ts-split-table tr:last-child td { border-bottom: 0; }
.ts-split-table td.pos { color: var(--positive); }
.ts-split-table td.neg { color: var(--danger); }

.ts-gross { display: flex; flex-direction: column; gap: var(--space-2); }
.ts-gross-bar { display: flex; height: 28px; border-radius: var(--radius-sm); overflow: hidden; }
.ts-gross-net {
  background: var(--accent); color: var(--text-inverse);
  font: 500 12px var(--font-mono); display: flex; align-items: center; padding: 0 10px;
}
.ts-gross-fees {
  background: #F4D9C8; color: #7A2A05;
  font: 500 12px var(--font-mono); display: flex; align-items: center; justify-content: center;
}
.ts-gross-note { font-size: 12px; color: var(--text-label); }
.ts-gross-note .num { color: var(--text); }

.ts-tiles { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); }
.ts-tile {
  border: 1px solid var(--border-faint); border-radius: 12px;
  padding: 12px 14px; display: flex; flex-direction: column; gap: 4px;
}
.ts-tile-label { font-size: 12px; color: var(--text-label); }
.ts-tile-value { font-size: 18px; font-weight: 500; color: var(--text); font-variant-numeric: tabular-nums; }
.ts-unit { font-size: 12px; color: var(--text-label); margin-left: 4px; font-weight: 400; }

.ts-card .ts-kv {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: var(--space-4); padding: 11px 0;
  border-bottom: 1px solid var(--border-faint); font-size: 13.5px;
}
.ts-card .ts-kv:last-of-type { border-bottom: 0; }
.ts-kv > span:first-child { color: var(--text-subtle); }
.ts-kv .num { color: var(--text); font-variant-numeric: tabular-nums; }
.ts-kv .num.neg { color: #C2410C; }
.ts-kv .num.is-strong { font-weight: 600; }
.ts-run { color: var(--accent); }

.ts-params { display: flex; flex-direction: column; gap: 10px; padding-top: var(--space-3); }
.ts-params-label { font-size: 13.5px; color: var(--text-subtle); }
.ts-param-chips { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; }
.ts-param { padding: 4px 8px; border-radius: var(--radius-chip); background: var(--surface-nav-hover); color: var(--text-body); }
.ts-param.is-strong { background: var(--surface-inverse); color: var(--text-inverse); }
.ts-param.is-on { background: var(--accent-tint); color: var(--accent-hover); }
.ts-param.is-off { background: var(--surface); color: var(--text-label); box-shadow: inset 0 0 0 1px var(--border-soft); }

@media (max-width: 1100px) {
  .ts-metrics { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .ts-columns { grid-template-columns: minmax(0, 1fr); }
}

/* The equity chart's legend, placed over the canvas at the top-left. */
#equity-chart { position: relative; }
.equity-legend {
  position: absolute; top: var(--space-3); left: var(--space-4); z-index: 2;
  display: flex; gap: var(--space-4); flex-wrap: wrap;
  font-size: 12px; color: var(--text-subtle); pointer-events: none;
}
.equity-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.equity-legend small { color: var(--text-label); }
.equity-swatch-line { width: 14px; height: 2px; border-radius: 1px; background: #12A15E; }
.equity-swatch-bar { width: 10px; height: 10px; border-radius: 2px; background: rgba(224, 134, 79, 0.75); }

/* ---------- Parameter modal ----------
 * Values are the mockup's own: a 560px dialog at 20px radius, sections in
 * bordered boxes, switches instead of words for the grid flags, and the
 * deposit split drawn as three bars whose widths are the shares.
 */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-5);
  background: rgba(13, 17, 23, 0.45);
}

.pm-dialog:focus { outline: none; }
.pm-dialog {
  width: 100%; max-width: 560px; max-height: 90vh; overflow: auto;
  background: var(--surface); border-radius: 20px;
  box-shadow: 0 24px 64px rgba(13, 17, 23, 0.28), 0 0 0 1px rgba(13, 17, 23, 0.06);
  display: flex; flex-direction: column;
}

.pm-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: var(--space-4); padding: var(--space-6) var(--space-6) var(--space-5);
}
.pm-head-text { display: flex; flex-direction: column; gap: 6px; }
.pm-eyebrow {
  font-size: 12px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-label);
}
.pm-head h2 { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; color: var(--text); }
.pm-chips { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12.5px; color: var(--text-subtle); }
.pm-chip { padding: 3px 8px; border-radius: var(--radius-chip); background: var(--surface-nav-hover); }
.pm-chip-score { background: var(--accent-tint); color: var(--accent-hover); }
.pm-chip-score .num { font-weight: 600; }
.pm-close { width: 40px; height: 40px; flex: 0 0 auto; border-radius: var(--radius-md); }

.pm-body { display: flex; flex-direction: column; gap: var(--space-5); padding: 0 var(--space-6) var(--space-6); }
.pm-section { display: flex; flex-direction: column; gap: 10px; }
.pm-section-title { font-size: 12px; font-weight: 600; color: var(--text-label); }

.pm-box { border: 1px solid var(--border-soft); border-radius: 14px; }
.pm-row {
  display: flex; justify-content: space-between; align-items: center; gap: var(--space-4);
  padding: 14px var(--space-4); border-bottom: 1px solid var(--border-faint);
}
.pm-row-text { display: flex; flex-direction: column; gap: 2px; }
.pm-row-name { font-size: 14px; font-weight: 500; color: var(--text); }
.pm-hint { font-size: 12.5px; color: var(--text-label); }
.pm-figure { font-size: 24px; font-weight: 500; color: var(--text); font-variant-numeric: tabular-nums; }
.pm-figure-sm { font-size: 18px; font-weight: 500; color: var(--text); font-variant-numeric: tabular-nums; }
.pm-suffix { font-size: 14px; color: var(--text-label); font-weight: 400; }
.pm-figure-sm .pm-suffix { font-size: 12px; }
.pm-empty { color: var(--text-label); }

.pm-switches { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pm-switch-cell {
  display: flex; justify-content: space-between; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
}
.pm-switch-cell:first-child { border-right: 1px solid var(--border-faint); }
.pm-switch-name { font-size: 14px; font-weight: 600; color: var(--text); }
.swb { display: flex; align-items: center; gap: var(--space-2); min-height: 44px; }
.pm-switch-word { font-size: 12.5px; color: var(--text-label); width: 34px; text-align: right; }
.pm-track {
  position: relative; display: block; width: 36px; height: 20px;
  border-radius: 10px; flex: 0 0 auto; background: #D5D8DE;
}
.pm-track.is-on { background: var(--accent); }
.pm-knob {
  position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  border-radius: 8px; background: var(--surface); box-shadow: 0 1px 2px rgba(13, 17, 23, 0.25);
}
.pm-track.is-on .pm-knob { left: 18px; }

.pm-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.pm-card {
  border: 1px solid var(--border-soft); border-radius: 14px;
  padding: 14px var(--space-4); display: flex; flex-direction: column; gap: 10px;
}
.pm-card-head { display: flex; align-items: center; gap: var(--space-2); }
.pm-card-title { font-size: 14px; font-weight: 500; color: var(--text); }
.pm-icon {
  width: 26px; height: 26px; border-radius: var(--radius-sm); flex: none;
  display: flex; align-items: center; justify-content: center;
}
.pm-icon-buy { background: var(--positive-tint); color: var(--positive); }
.pm-icon-sell { background: #FDF1EA; color: var(--danger); }
.pm-card-foot { display: flex; justify-content: space-between; align-items: baseline; }

.pm-deposit { padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); }
.pm-bars { display: flex; gap: 4px; }
.pm-bar { height: 10px; border-radius: 5px; background: var(--accent); }
.pm-bar-1 { opacity: 0.35; }
.pm-bar-2 { opacity: 0.65; }
.pm-bar-labels { display: flex; gap: 4px; }
.pm-bar-labels > div { display: flex; flex-direction: column; gap: 2px; }

.pm-foot {
  display: flex; justify-content: space-between; align-items: center; gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-soft); background: var(--surface-hover);
  border-radius: 0 0 20px 20px;
}
.pm-link { font-size: 14px; font-weight: 500; display: inline-flex; align-items: center; min-height: 44px; }
.cls {
  display: inline-flex; align-items: center; height: 44px; padding: 0 20px;
  border: 0; border-radius: var(--radius-md);
  background: var(--surface-inverse); color: var(--text-inverse);
  font: 500 14px var(--font-sans); cursor: pointer;
}
.cls:hover { background: #262C36; }

@media (max-width: 560px) {
  .pm-switches, .pm-pair { grid-template-columns: minmax(0, 1fr); }
  .pm-switch-cell:first-child { border-right: 0; border-bottom: 1px solid var(--border-faint); }
}

/* ---------- Narrow screens ----------
   The sidebar becomes a strip across the top; nothing is hidden, because the
   whole navigation is three links. */

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: auto; flex: none; height: auto; position: static;
    flex-direction: row; align-items: center; flex-wrap: wrap;
    gap: var(--space-4);
    border-right: 0; border-bottom: 1px solid var(--border-soft);
  }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .side-section { width: 100%; }
  .side-foot { margin-top: 0; flex-direction: row; align-items: center; gap: var(--space-4); }
  .content { padding: var(--space-4) var(--space-4) var(--space-6); }
  .page-title { font-size: 26px; }
}
/* --- the run-progress panel ------------------------------------------- */

/* Measured from the mockup in "Компонент · Прогресс прогона": a dark card on
   a light page, because it is the one thing on the dashboard that is
   happening right now. Sizes are the mockup's own. */
.run-progress {
  background: var(--surface-inverse);
  color: var(--text-inverse);
  border-radius: 20px;
  padding: 22px 24px;
  margin-bottom: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-shadow: var(--run-shadow);
}

.run-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.run-title { display: flex; align-items: center; gap: 12px; min-width: 0; }

/* The ring pulses only while something is running; reduced motion stops it,
   and the dot stays, so the state is never carried by the animation alone. */
.run-dot {
  position: relative;
  width: 12px;
  height: 12px;
  flex: none;
  border-radius: 50%;
  background: var(--run-accent);
}

.run-dot::after {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 2px solid var(--run-accent);
  animation: run-pulse 1.8s ease-out infinite;
}

@keyframes run-pulse {
  0% { opacity: 0.55; transform: scale(0.6); }
  100% { opacity: 0; transform: scale(1.15); }
}

.run-title-text { display: flex; flex-direction: column; gap: 2px; }
.run-title-text strong { font-size: 16px; font-weight: 600; }
.run-sub { font-size: 12.5px; color: var(--text-inverse-faint); }

.run-timers { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; }
.run-timer { display: flex; flex-direction: column; gap: 2px; align-items: flex-end; }

.run-timer-label {
  font-size: 11px;
  color: var(--run-label);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.run-timer-value {
  font: 500 15px var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.run-stop {
  height: 40px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--run-border);
  background: transparent;
  color: var(--text-inverse);
  font: 500 13.5px var(--font-sans);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.run-stop:hover { border-color: var(--run-accent); }

.run-main { display: flex; flex-direction: column; gap: 10px; }

.run-count {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.run-count-value {
  font: 500 40px var(--font-mono);
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.run-count-of { font-size: 14px; color: var(--text-inverse-faint); }

.run-pct {
  margin-left: auto;
  font: 500 22px var(--font-mono);
  color: var(--run-pct);
  font-variant-numeric: tabular-nums;
}

.run-bar {
  height: 8px;
  border-radius: 4px;
  background: var(--run-track);
  overflow: hidden;
}

.run-bar > span {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: var(--run-accent);
  transition: width 0.2s linear;
}

/* --- stages ------------------------------------------------------------ */

.run-stages {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
  gap: 8px;
}

.run-stage {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--run-tile);
}

.run-stage.is-current {
  background: var(--run-stage-active);
  box-shadow: inset 0 0 0 1px var(--run-accent);
}

.run-stage-badge {
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 600 12px var(--font-sans);
  background: var(--run-badge);
  color: var(--run-label);
}

.run-stage.is-done .run-stage-badge { background: var(--positive-inverse); color: var(--surface-inverse); }
.run-stage.is-current .run-stage-badge { background: var(--run-accent); color: var(--surface-inverse); }

.run-stage-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.run-stage-label { font-size: 13px; font-weight: 600; color: var(--run-label); }
.run-stage.is-done .run-stage-label,
.run-stage.is-current .run-stage-label { color: var(--text-inverse); }
.run-stage-sub { font-size: 11.5px; color: var(--run-label); }

/* --- the mosaic -------------------------------------------------------- */

.run-body { display: flex; flex-wrap: wrap; gap: 20px; align-items: stretch; }
.run-mosaic-pane { flex: 999 1 520px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }

.run-mosaic-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.run-section-title { font-size: 13px; font-weight: 600; color: var(--run-bright); }

.run-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 12px;
  color: var(--text-inverse-faint);
}

.run-legend span { display: inline-flex; align-items: center; gap: 6px; }

.run-swatch { width: 9px; height: 9px; border-radius: 2px; }
.run-swatch-wl { background: var(--positive-inverse); }
.run-swatch-done { background: var(--run-cell-done); }
.run-swatch-skip { background: var(--run-cell-skip); }
.run-swatch-queued { background: var(--run-track); box-shadow: inset 0 0 0 1px var(--run-cell-ring); }

.run-mosaic { display: flex; flex-wrap: wrap; gap: 3px; align-content: flex-start; }

.run-cell { width: 9px; height: 9px; border-radius: 2px; }
.run-cell-wl { background: var(--positive-inverse); }
.run-cell-done { background: var(--run-cell-done); }
.run-cell-skip { background: var(--run-cell-skip); }
.run-cell-queued { background: var(--run-track); box-shadow: inset 0 0 0 1px var(--run-cell-ring); }

/* --- the side column --------------------------------------------------- */

.run-side { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }

.run-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

.run-tile {
  background: var(--run-tile);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.run-tile-label { font-size: 11.5px; color: var(--run-label); }
.run-tile-value { font: 500 20px var(--font-mono); font-variant-numeric: tabular-nums; }
.run-tile-wl { color: var(--positive-inverse); }
.run-tile-skip { color: var(--run-skip-text); }

.run-list { display: flex; flex-direction: column; gap: 8px; }
.run-section-label { font-size: 12px; color: var(--run-label); }

.run-lane { display: flex; align-items: center; gap: 10px; font-size: 12.5px; }
.run-lane-n { color: var(--run-mono-dim); width: 16px; }

.run-lane-symbol {
  width: 112px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--run-bright);
}

/* An activity indicator, not a progress bar. Nothing measures how far
   through its configurations a symbol is, so a filled proportion here would
   be invented; this says "working" and claims nothing more. */
.run-lane-activity {
  flex: 1 1 auto;
  height: 4px;
  border-radius: 2px;
  background: var(--run-track);
  overflow: hidden;
}

.run-lane-activity > span {
  display: block;
  height: 100%;
  width: 40%;
  border-radius: 2px;
  background: var(--run-accent);
  animation: run-slide 1.6s ease-in-out infinite;
}

@keyframes run-slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}

.run-feed-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  padding: 5px 0;
  border-top: 1px solid var(--run-track);
  color: var(--run-bright);
}

.run-tag { font-size: 11.5px; padding: 2px 8px; border-radius: 999px; }
.run-tag-ok { background: var(--run-track); color: var(--text-inverse-faint); }
.run-tag-skipped { background: var(--run-skip-tint); color: var(--run-skip-text); }
.run-tag-error { background: var(--danger-inverse-tint); color: var(--danger-inverse); }

.run-note { margin: 0; font-size: 12.5px; color: var(--text-inverse-faint); }

@media (max-width: 767px) {
  .run-progress { padding: 16px; border-radius: 16px; }
  .run-count-value { font-size: 32px; }
}

/* A symbol that failed outright. The mockup's legend has no such state
   because its demo never errors; a run that does must not colour the
   failure as a pass. */
.run-cell-error { background: var(--danger-inverse); }
