/* Tokens: light default, dark via OS preference or the toggle (data-theme wins both ways).
   Series colors are the validated categorical palette (slots in fixed order); text never uses series colors. */
:root {
  color-scheme: light;
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --surface-0: #f4f4f2;
  --surface-1: #fcfcfb;
  --surface-2: #f0efec;
  --border: #e2e1dc;
  --grid: #ecebe7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #7a7974;
  --accent: #2a78d6;
  --accent-text: #ffffff;

  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #4a3aa7; --series-8: #e34948;

  --up: #1baf7a;
  --down: #e34948;
  --volume: #e9e8e3;
  --good-text: #0f7a3d;
  --bad-text: #c0302f;
  --critical: #e34948;
  --critical-fill: #e3494826;
  --warning-bg: #fff6e0; --warning-text: #8a5300;
  --warning-border: #eda100;
  --error-bg: #fdecec;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-0: #121211; --surface-1: #1a1a19; --surface-2: #232321; --border: #2f2f2d; --grid: #262624;
    --text-primary: #ffffff; --text-secondary: #c3c2b7; --text-muted: #8f8e86;
    --accent: #3987e5; --accent-text: #ffffff;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
    --up: #199e70; --down: #e66767; --volume: #2a2a28;
    --good-text: #4cc98a; --bad-text: #f08585;
    --critical: #e66767; --critical-fill: #e6676726;
    --warning-bg: #2d2511; --warning-border: #c98500; --warning-text: #e5ae45; --error-bg: #351b1b;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-0: #121211; --surface-1: #1a1a19; --surface-2: #232321; --border: #2f2f2d; --grid: #262624;
  --text-primary: #ffffff; --text-secondary: #c3c2b7; --text-muted: #8f8e86;
  --accent: #3987e5; --accent-text: #ffffff;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
  --up: #199e70; --down: #e66767; --volume: #2a2a28;
  --good-text: #4cc98a; --bad-text: #f08585;
  --critical: #e66767; --critical-fill: #e6676726;
  --warning-bg: #2d2511; --warning-border: #c98500; --warning-text: #e5ae45; --error-bg: #351b1b;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--surface-0); color: var(--text-primary); font: 14px/1.45 var(--font-sans); }
h1 { font-size: 20px; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 13px; margin: 0; font-weight: 650; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-secondary); }
code { font-family: var(--font-mono); font-size: 12px; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.pos { color: var(--good-text); }
.neg { color: var(--bad-text); }
[hidden] { display: none !important; }

button, .button, select, input { font: inherit; color: inherit; }
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-1); cursor: pointer; text-decoration: none; white-space: nowrap;
}
button:hover, .button:hover { background: var(--surface-2); }
button:focus-visible, .button:focus-visible, select:focus-visible, input:focus-visible, tr:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
button:disabled { opacity: .55; cursor: default; }
.link-btn { border: 0; background: none; padding: 0; height: auto; color: var(--accent); }
.link-btn:hover { background: none; text-decoration: underline; }
.icon-btn { width: 32px; padding: 0; font-size: 16px; }

select, input[type=number], input[type=text], input[type=date], input[type=search] {
  width: 100%; height: 32px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-1);
}
input.invalid { border-color: var(--bad-text); }

/* ---------------------------------------------------------------- layout */
.topbar {
  position: sticky; top: 0; z-index: 10; height: 52px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; background: var(--surface-1); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.topbar-right { display: flex; align-items: center; gap: 12px; min-width: 0; }
.store { color: var(--text-muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; }
.badge-warn { background: var(--warning-bg); border: 1px solid var(--warning-border); color: var(--text-primary); }

.layout { display: grid; grid-template-columns: 360px minmax(0, 1fr); min-height: calc(100vh - 52px); }
.sidebar { background: var(--surface-1); border-right: 1px solid var(--border); padding: 12px 16px 24px; overflow-y: auto; height: calc(100vh - 52px); position: sticky; top: 52px; }
.main { padding: 20px 24px 40px; min-width: 0; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .main { padding: 16px; }
  .store { display: none; }
}

/* ---------------------------------------------------------------- sidebar */
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 10px; margin-bottom: 12px; }
.tabs { flex-wrap: wrap; }
.tabs button { flex: 1 0 auto; border: 0; background: transparent; height: 30px; padding: 0 6px; font-size: 13px; }
.tabs button[aria-selected=true] { background: var(--surface-1); box-shadow: 0 1px 2px #0000001a; font-weight: 600; }
.block { padding: 12px 0; border-bottom: 1px solid var(--border); display: grid; gap: 8px; }
.block h2 { display: flex; justify-content: space-between; align-items: baseline; }
.desc { margin: 0; color: var(--text-secondary); font-size: 13px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.field { display: grid; gap: 4px; }
.field > label { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--text-secondary); }
.field .range { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.hint { color: var(--text-muted); font-size: 12px; }
.check { display: flex !important; align-items: center; gap: 8px; font-size: 13px !important; color: var(--text-primary) !important; justify-content: flex-start !important; cursor: pointer; }
.param-group { border: 0; margin: 0; padding: 0; display: grid; gap: 8px; }
.param-group + .param-group { margin-top: 6px; }
.param-group legend { font-size: 12px; font-weight: 600; color: var(--text-muted); padding: 0; margin-bottom: 4px; }
.coverage { font-size: 12px; color: var(--text-muted); display: grid; gap: 2px; }
.actions { display: flex; gap: 8px; margin-top: 14px; }
.actions .primary { flex: 1; height: 38px; }
.progress { display: grid; gap: 4px; margin-top: 10px; }
.progress progress { width: 100%; height: 6px; accent-color: var(--accent); }
.form-errors { margin-top: 12px; padding: 8px 10px; border-radius: 8px; background: var(--error-bg); border: 1px solid var(--bad-text); font-size: 13px; display: grid; gap: 2px; }

.run { display: flex; align-items: stretch; gap: 4px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; background: var(--surface-1); }
.run.active { border-color: var(--accent); }
.run-open { flex: 1; height: auto; display: grid; justify-items: start; gap: 2px; padding: 8px 10px; border: 0; background: none; text-align: left; white-space: normal; }
.run .icon-btn { border: 0; height: auto; color: var(--text-muted); }
.run-title { font-weight: 600; }
.run-sub { font-size: 12px; color: var(--text-muted); }
.run-stats { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- results */
.empty { max-width: 640px; margin: 12vh auto; text-align: center; color: var(--text-secondary); }
.empty h1 { margin-bottom: 8px; color: var(--text-primary); }
.result-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.result-head p { margin: 4px 0 0; }
.result-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.warnings { display: grid; gap: 6px; margin-bottom: 14px; }
.warning { display: flex; gap: 10px; align-items: flex-start; padding: 8px 12px; border-radius: 8px; background: var(--warning-bg); border: 1px solid var(--warning-border); font-size: 13px; }
.warn-icon { flex: none; width: 18px; height: 18px; border-radius: 50%; background: var(--warning-border); color: #fff; font-weight: 700; font-size: 12px; display: grid; place-items: center; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-bottom: 16px; }
#live-tiles { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }   /* 7 tiles on one row on a laptop */
.tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.tile-label { font-size: 12px; color: var(--text-muted); }
.tile-value { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; margin: 2px 0; }
.tile-sub { font-size: 12px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }

.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.card-tools { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); }
.legend-key { display: inline-flex; align-items: center; gap: 6px; }
.mk { display: inline-block; width: 0; height: 0; }
.mk-long { border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 8px solid var(--series-1); }
.mk-short { border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 8px solid var(--series-2); }
.mk-exit { width: 8px; height: 8px; border-radius: 50%; background: var(--text-secondary); }
.mk-detect-up, .mk-detect-down { width: 7px; height: 7px; margin-right: 2px; }
.mk-detect-up { background: var(--up); }
.mk-detect-down { background: var(--down); }

.chart { position: relative; width: 100%; }
.chart-price { height: 560px; }
.chart-portfolio { height: 340px; }
.chart-canvas { position: absolute; inset: 0; }
.chart-legend {
  position: absolute; top: 6px; left: 8px; right: 70px; z-index: 3; pointer-events: none;
  display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 12px; color: var(--text-secondary); font-variant-numeric: tabular-nums;
}
.chart-legend .lg-strong { color: var(--text-primary); font-weight: 600; }
.lg-item { display: inline-flex; align-items: center; gap: 5px; }
.swatch { display: inline-block; width: 10px; height: 3px; border-radius: 2px; }

.table-wrap { overflow: auto; max-height: 520px; }
table.trades { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.trades th { position: sticky; top: 0; background: var(--surface-1); z-index: 1; text-align: left; border-bottom: 1px solid var(--border); padding: 0; }
.trades th button { border: 0; background: none; height: 30px; width: 100%; justify-content: flex-start; padding: 0 8px; font-weight: 600; color: var(--text-secondary); border-radius: 0; }
.trades th.num button { justify-content: flex-end; }
.trades td { padding: 6px 8px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
.trades .num { text-align: right; }
.trades tbody tr { cursor: pointer; }
.trades tbody tr:hover { background: var(--surface-2); }

.logs summary { cursor: pointer; list-style: none; }
.logs summary::-webkit-details-marker { display: none; }
.logs summary h2::before { content: "▸ "; }
.logs[open] summary h2::before { content: "▾ "; }
.logs pre { max-height: 300px; overflow: auto; font: 12px/1.5 var(--font-mono); color: var(--text-secondary); margin: 10px 0 0; white-space: pre-wrap; }

/* ---------------------------------------------------------------- strategy builder */
.view-tabs { display: inline-flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 10px; margin-bottom: 16px; }
.view-tabs button { border: 0; background: transparent; height: 30px; }
.view-tabs button[aria-selected=true] { background: var(--surface-1); box-shadow: 0 1px 2px #0000001a; font-weight: 600; }
.rules-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.strategy-io { margin-top: 6px; }
.rules-actions:not([hidden]) + .strategy-io { margin-top: 6px; }
.rules-actions button { height: 28px; padding: 0 10px; font-size: 13px; }
button.danger { color: var(--bad-text); }
.flash { font-size: 12px; color: var(--good-text); }
.primary-soft { border-color: var(--accent); color: var(--accent); font-weight: 600; }

.builder { max-width: 1100px; }
.builder-head { display: grid; gap: 6px; margin-bottom: 12px; }
.name-input { font-size: 20px; font-weight: 650; height: 40px !important; border-color: transparent !important; background: transparent !important; padding: 0 !important; }
.name-input:hover, .name-input:focus { border-color: var(--border) !important; background: var(--surface-1) !important; padding: 0 8px !important; }
.desc-input { border-color: transparent !important; background: transparent !important; padding: 0 !important; color: var(--text-secondary); }
.desc-input:hover, .desc-input:focus { border-color: var(--border) !important; background: var(--surface-1) !important; padding: 0 8px !important; }
.builder-status { border-radius: 8px; padding: 8px 12px; margin-bottom: 14px; font-size: 13px; }
.builder-status.ok { background: color-mix(in srgb, var(--good-text) 10%, var(--surface-1)); border: 1px solid color-mix(in srgb, var(--good-text) 40%, transparent); }
.builder-status.bad { background: var(--error-bg); border: 1px solid var(--bad-text); }
.builder-status ul { margin: 4px 0 0; padding-left: 18px; }
.builder-card h3.rule-title { font-size: 13px; margin: 14px 0 6px; color: var(--text-primary); }

.ind-list { display: grid; gap: 8px; margin-bottom: 10px; }
.ind-row { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; background: var(--surface-1); display: grid; gap: 8px; }
.ind-main { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ind-main .icon-btn { margin-left: auto; border: 0; color: var(--text-muted); }
.id-input { width: 110px !important; font-family: var(--font-mono); font-weight: 600; }
.ind-fn { flex: 1 1 220px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inline-field { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-secondary); }
.inline-field select { width: auto; }
.ind-opts { display: flex; flex-wrap: wrap; gap: 8px 12px; }
.opt { display: grid; gap: 2px; font-size: 12px; color: var(--text-secondary); }
.opt input, .opt select { width: 120px; height: 30px; }
.outputs code { margin-left: 6px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.row-actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }

.picker { border: 1px solid var(--border); border-radius: 10px; background: var(--surface-1); margin-top: 10px; box-shadow: 0 8px 24px #0000001f; }
.picker input { border: 0 !important; border-bottom: 1px solid var(--border) !important; border-radius: 10px 10px 0 0 !important; height: 40px !important; width: 100%; box-sizing: border-box; padding: 0 12px; outline-offset: -2px; }
.picker-list { max-height: 360px; overflow: auto; padding: 4px 0; }
.picker-group { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); padding: 8px 12px 4px; }
.picker-item { display: flex; gap: 10px; width: 100%; justify-content: flex-start; border: 0; border-radius: 0; height: 30px; background: none; text-align: left; }
.picker-item:hover, .picker-item:focus-visible { background: var(--surface-2); }
.picker-item strong { min-width: 150px; font-family: var(--font-mono); font-size: 12.5px; }

.side-toggle { margin-bottom: 4px; }
.hold-row { margin-top: 12px; display: grid; gap: 2px; }
#short-copy { margin-top: 8px; }
.rule-group { border-left: 3px solid var(--accent); padding: 6px 0 6px 10px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.rule-group.nested { border-left-color: var(--series-2); margin-left: 4px; background: color-mix(in srgb, var(--surface-2) 50%, transparent); border-radius: 0 8px 8px 0; padding-right: 8px; }
.group-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.group-head select { width: auto; font-weight: 600; }
.group-head .icon-btn { border: 0; color: var(--text-muted); }
.group-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.spacer { flex: 1; }
.cond-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cond-row .icon-btn { border: 0; color: var(--text-muted); }
.operand-box { display: inline-flex; gap: 6px; align-items: center; }
select.operand { width: auto; max-width: 280px; }
select.op { width: auto; }
input.num { width: 100px; }
.empty-group { margin: 2px 0; }
.rule-text { margin-top: 12px; padding: 8px 10px; background: var(--surface-2); border-radius: 8px; font-size: 12.5px; color: var(--text-secondary); display: grid; gap: 2px; }
.rule-text:empty { display: none; }
.risk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.risk-grid .field { align-content: start; }
.risk-grid .flabel { font-size: 12px; color: var(--text-secondary); }
@media (max-width: 900px) { select.operand { max-width: 100%; } .cond-row { align-items: stretch; } }
@media (max-width: 600px) {
  .cond-row { background: var(--surface-2); border-radius: 8px; padding: 8px 36px 8px 8px; position: relative; }
  .cond-row > .icon-btn { position: absolute; top: 6px; right: 4px; }
  .cond-row > .spacer { display: none; }
  .row-actions .inline-field, .group-head { flex-wrap: wrap; }
}

/* detections (order-flow study) */
.study-note { margin: 0 0 8px; }
table.study { margin-bottom: 12px; }
table.study th[scope=row] { text-align: left; padding: 6px 8px; font-weight: 600; white-space: nowrap; border-bottom: 1px solid var(--grid); }
table.study th[scope=col] { padding: 6px 8px; font-weight: 600; color: var(--text-secondary); }
table.study tr.muted th, table.study tr.muted td { color: var(--text-muted); font-weight: 400; }
.detections-list { max-height: 420px; overflow: auto; }
.detections-list thead th { padding: 6px 8px; font-weight: 600; color: var(--text-secondary); }
.detections-list td.detail { white-space: normal; min-width: 320px; color: var(--text-secondary); }

/* signal discovery */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; font-size: 12.5px; cursor: pointer; user-select: none; }
.chip input { margin: 0; }
.chip:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface-1)); }
.top-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 8px; }
.top-item { display: grid; gap: 4px; min-width: 0; white-space: normal; text-align: left; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-1); height: auto; justify-content: stretch; }
.top-item[aria-selected=true] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.top-item .ti-head { display: flex; gap: 8px; align-items: baseline; }
.top-item .ti-rank { font-weight: 700; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.top-item .ti-name { font-weight: 600; font-size: 13px; line-height: 1.3; }
.top-item .ti-stats { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.top-item .ti-win { font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; }
.chart-discovery { height: 520px; }
.zone { display: inline-block; width: 12px; height: 10px; border-radius: 2px; margin-right: 4px; }
.zone-good { background: color-mix(in srgb, var(--good-text) 45%, transparent); }
.zone-bad { background: color-mix(in srgb, var(--bad-text) 45%, transparent); }
.conditions { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr)); gap: 10px; }
.cond-group { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; }
.cond-group h4 { margin: 0 0 6px; font-size: 12px; color: var(--text-secondary); font-weight: 600; }
.cond-line { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; font-size: 12.5px; padding: 3px 0; font-variant-numeric: tabular-nums; }
.cond-bar { grid-column: 1 / -1; height: 6px; background: var(--surface-2); border-radius: 3px; position: relative; overflow: hidden; }
.cond-bar i { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 3px; }
.cond-bar b { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--text-secondary); }
tr.unranked td { color: var(--text-muted); }
tr.selected td { background: color-mix(in srgb, var(--accent) 8%, transparent); }
#d-table th { padding: 0; }
.skipped { margin-top: 10px; }
.skipped div { columns: 2 260px; padding-top: 6px; }
#d-filter { width: 220px; height: 30px; }
#d-history .run { margin-bottom: 6px; }

@media (max-width: 600px) { #d-filter { width: 100%; } .chart-discovery { height: 420px; } #d-detail .card-tools { flex-wrap: wrap; } }

/* ---------------------------------------------------------------- compute servers, queue, live progress */
.servers-chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px; font-size: 12px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot-on { background: var(--up); }
.dot-off { background: var(--text-muted); }
.dot-warn { background: var(--warning-border); }
.block-head { display: flex; align-items: center; justify-content: space-between; }
.servers { display: grid; gap: 8px; }
.jobs { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); align-items: start; margin-top: 12px; }
.jobs > p { grid-column: 1 / -1; }
.job { padding: 12px 14px; gap: 4px; }
.job .spark { height: 48px; }
.server-card, .job { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; display: grid; gap: 3px; min-width: 0; background: var(--surface-1); }
.server-name { display: flex; align-items: center; gap: 8px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.job-title { font-size: 13px; overflow-wrap: anywhere; }
.job progress { width: 100%; height: 6px; accent-color: var(--accent); }
.job-actions { display: flex; align-items: center; gap: 12px; margin-top: 4px; flex-wrap: wrap; }
.job-actions .primary-soft { height: 28px; }
.tag { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-secondary); background: var(--surface-2); border-radius: 6px; padding: 1px 6px; }
.state { font-size: 12px; font-weight: 600; }
.state::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; background: var(--text-muted); }
.state-running::before { background: var(--accent); }
.state-queued::before { background: var(--warning-border); }
.state-done::before { background: var(--up); }
.state-failed { color: var(--bad-text); }
.state-failed::before { background: var(--down); }
.job-running { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.badge-soft { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-secondary); font-size: 11px; }
.live { display: grid; gap: 6px; margin-top: 8px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-1); min-width: 0; }
.live[hidden] { display: none; }
.live-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.live .flabel { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.spark { width: 100%; height: 64px; display: block; }
.spark-main { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; }
.spark-bench { fill: none; stroke: var(--text-muted); stroke-width: 1.5; stroke-dasharray: 4 3; }
.live-legend { display: flex; gap: 14px; }
.live-legend span { display: inline-flex; align-items: center; gap: 6px; }
.key { display: inline-block; width: 14px; height: 0; border-top: 2px solid var(--series-1); }
.key-bench { border-top: 2px dashed var(--text-muted); }
.live-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; font-size: 12px; font-variant-numeric: tabular-nums; }
.live-stat { display: grid; }
.live-table { font-size: 12px; table-layout: fixed; width: 100%; }
.live-table th:nth-child(1), .live-table td:nth-child(1) { width: 24px; }
.live-table th:nth-child(3), .live-table td:nth-child(3) { width: 52px; }
.live-table th:nth-child(4), .live-table td:nth-child(4) { width: 46px; }
.live-table th:nth-child(5), .live-table td:nth-child(5) { width: 46px; }

/* ---------------------------------------------------------------- live sessions */
.dot-bad { background: var(--down); }
.live-item { display: grid; gap: 3px; justify-items: start; height: auto; padding: 8px 10px; text-align: left; white-space: normal; border-radius: 10px; width: 100%; min-width: 0; }
.live-item.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface-1)); }
.live-item .server-name { width: 100%; min-width: 0; }
.vbadges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.vbadge { font-size: 11.5px; border-radius: 999px; padding: 1px 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-secondary); white-space: nowrap; }
.vbadge-identical { border-color: var(--up); color: var(--good-text); background: color-mix(in srgb, var(--up) 10%, var(--surface-1)); }
.vbadge-different, .vbadge-failed { border-color: var(--down); color: var(--bad-text); background: var(--error-bg); }
.vbadge-unavailable { border-style: dashed; }
.feeds { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.feed { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; display: grid; gap: 3px; }
.events-wrap { max-height: 360px; overflow-y: auto; }
.evk { font-size: 11px; border-radius: 6px; padding: 1px 6px; background: var(--surface-2); color: var(--text-secondary); white-space: nowrap; }
.evk-gap, .evk-late-trade, .evk-disconnected, .evk-failure, .evk-record-error, .evk-slow-step { background: var(--error-bg); color: var(--bad-text); }
.evk-connected, .evk-recording, .evk-live-start, .evk-start, .evk-resume { background: color-mix(in srgb, var(--up) 12%, var(--surface-1)); color: var(--good-text); }
.evk-verification, .evk-resume-check { background: color-mix(in srgb, var(--accent) 12%, var(--surface-1)); color: var(--accent); }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--font-mono); font-size: 11.5px; overflow-wrap: anywhere; }
.small-table { font-size: 12px; }
.trades th:not(:has(button)) { padding: 7px 8px; font-weight: 600; color: var(--text-secondary); }
.trades th.num:not(:has(button)) { text-align: right; }
.trades td.mono, .trades td.detail { white-space: normal; min-width: 14ch; }
.vblock { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 10px; display: grid; gap: 6px; }
.vblock h4, #live-report h4 { margin: 8px 0 2px; font-size: 13px; }
.divergence { border: 1px solid var(--down); border-radius: 10px; padding: 10px 12px; background: var(--error-bg); display: grid; gap: 6px; }
.div-title { font-weight: 650; }
.div-grid { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 10px; align-items: baseline; }
.div-grid code { overflow-wrap: anywhere; }
.diff-row td { background: color-mix(in srgb, var(--down) 8%, transparent); }
.events-list { margin: 0; padding-left: 18px; font-size: 12.5px; display: grid; gap: 3px; }
#live-verifications tr.active td, #live-verifications tbody tr:hover td { background: var(--surface-2); cursor: pointer; }
#live-title { overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- Data tab (market data downloads) */
.sym-entry { display: flex; gap: 6px; }
.sym-entry input { flex: 1; min-width: 0; }
.sym-entry input:not(:placeholder-shown) { text-transform: uppercase; }
.sym-chips { min-height: 28px; align-items: center; margin-top: 2px; }
.sym-chip { cursor: default; padding: 2px 4px 2px 10px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chip-x { height: 20px; width: 20px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--text-secondary); font-size: 15px; line-height: 1; }
.chip-x:hover { background: var(--surface-2); color: var(--text-primary); }
.sym-picks, .period-picks { display: flex; flex-wrap: wrap; gap: 4px; }
.pick { height: 24px; padding: 0 8px; font-size: 12px; border-radius: 6px; color: var(--text-secondary); }
.pick[aria-pressed="true"] { border-color: var(--accent); color: var(--text-primary); background: color-mix(in srgb, var(--accent) 10%, var(--surface-1)); }
.period-picks { margin-top: -4px; }
.plan-result { display: grid; gap: 10px; margin-top: 4px; }
.plan-block { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; display: grid; gap: 6px; background: var(--surface-1); }
.plan-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.plan-notes { margin: 0; padding-left: 16px; }
#data-jobs { grid-template-columns: 1fr; margin-bottom: 16px; }
.data-job { gap: 6px; }
.data-progress { display: flex; align-items: center; gap: 10px; }
.data-progress progress { flex: 1; height: 8px; accent-color: var(--accent); }
.data-progress .pct { font-variant-numeric: tabular-nums; font-weight: 650; min-width: 3.5ch; text-align: right; }
.data-rows td { vertical-align: middle; }
.data-rows td.detail { white-space: normal; min-width: 18ch; }
.mini-bar { display: flex; align-items: center; gap: 8px; min-width: 150px; }
.mini-track { position: relative; flex: 0 0 64px; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.mini-fill { position: absolute; inset: 0 auto 0 0; border-radius: 3px; background: var(--accent); }
.mini-bar .small { font-variant-numeric: tabular-nums; white-space: nowrap; }
.rstate { font-size: 12px; white-space: nowrap; }
.rstate::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; background: var(--text-muted); }
.rstate-downloading::before, .rstate-preparing::before, .rstate-checking::before, .rstate-planning::before { background: var(--accent); }
.rstate-done::before, .rstate-downloaded::before { background: var(--up); }
.rstate-failed { color: var(--bad-text); }
.rstate-failed::before { background: var(--down); }
.rstate-empty::before { background: var(--warning-border); }
.data-log summary { cursor: pointer; color: var(--text-secondary); }
.data-log pre { max-height: 260px; overflow: auto; margin: 6px 0 0; }
.cov-table { width: 100%; }
.cov-table td { vertical-align: middle; }
.strip-cell { width: 40%; min-width: 160px; }
.strip { display: flex; gap: 2px; height: 14px; align-items: stretch; }
.cell { flex: 1 1 0; min-width: 2px; max-width: 18px; border-radius: 2px; display: inline-block; }
.cell-full { background: var(--accent); }
.cell-month { background: color-mix(in srgb, var(--accent) 45%, var(--surface-1)); }
.cell-days { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--accent) 55%, var(--surface-1)) 0 2px, transparent 2px 4px); outline: 1px solid color-mix(in srgb, var(--accent) 40%, var(--border)); outline-offset: -1px; }
.cell-none { background: var(--surface-2); outline: 1px solid var(--border); outline-offset: -1px; }
.strip-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; }
.strip-legend span { display: inline-flex; align-items: center; gap: 6px; }
.strip-legend .cell { width: 12px; height: 12px; flex: none; }
#data-coverage .card-head h2 { display: inline-flex; align-items: center; gap: 8px; }
.log-lines { font: 11.5px/1.5 var(--font-mono); background: var(--surface-2); border-radius: 8px; padding: 8px 10px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-secondary); }

/* ---------------------------------------------------------------- discovery: signal groups */
.group-list .group-item { align-content: start; }
.group-item[disabled] { opacity: 0.75; cursor: default; }
.group-item.reached { border-color: color-mix(in srgb, var(--up) 55%, var(--border)); }
.g-members { margin: 2px 0 4px; padding-left: 16px; display: grid; gap: 1px; font-size: 12.5px; text-align: left; }
.g-members li { overflow-wrap: anywhere; }
.badge-good { background: color-mix(in srgb, var(--up) 14%, var(--surface-1)); border: 1px solid color-mix(in srgb, var(--up) 50%, var(--border)); color: var(--good-text); font-size: 11px; }
.rule-summary { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; overflow-wrap: anywhere; }
.group-head .within { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.group-head .within .within-input { width: 56px; min-width: 0; flex: none; height: 28px; padding: 0 6px; }
.group-list { grid-template-columns: repeat(auto-fill, minmax(min(330px, 100%), 1fr)); }
.scale-box { display: inline-flex; align-items: center; gap: 4px; }
.operand-box input.scale { width: 64px; }

/* ---------------------------------------------------------------- failure patterns */
.failures { margin-top: 14px; display: grid; gap: 8px; min-width: 0; }
.failures > * { min-width: 0; }
#failures-card .failures { margin-top: 0; }
.fp-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.fp-head h3.rule-title { margin: 0; font-size: 15px; }
#d-failures .fp-head h3.rule-title { font-size: 13px; }
.fp-summary { margin: 0; background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }
.fp-table td { vertical-align: middle; }
.fp-table th.fp-check, .fp-table td.fp-check { width: 44px; text-align: center; }
.fp-table th .th-text { display: block; padding: 6px 8px; font-weight: 600; }
.fp-table td.fp-text { min-width: 220px; overflow-wrap: anywhere; }
.fp-table tr.fp-suggested td { background: color-mix(in srgb, var(--up) 6%, transparent); }
.fp-badge { margin-left: 6px; white-space: nowrap; }
.fp-table input[type="checkbox"] { width: 16px; height: 16px; margin: 0; }
.fp-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.fp-actions .spacer { flex: 1; }
.fp-selection { color: var(--text-secondary); }
.fp-profiles-box summary { cursor: pointer; color: var(--text-secondary); padding: 4px 0; }
.fp-profiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px 16px; margin-top: 6px; }
.fp-tip { grid-column: 1 / -1; min-height: 1.4em; font-variant-numeric: tabular-nums; }
.fp-profile { margin: 0; min-width: 0; }
.fp-profile figcaption { color: var(--text-secondary); margin-bottom: 2px; }
.fp-chart { width: 100%; height: auto; display: block; overflow: visible; }
.fp-bar { fill: var(--series-1); }
.fp-bar.low { fill: var(--critical); }
.fp-bar.thin { opacity: 0.35; }
.fp-hit { fill: transparent; }
.fp-hit:hover { fill: color-mix(in srgb, var(--text-muted) 12%, transparent); }
.fp-axis { stroke: var(--border); stroke-width: 1; }
.fp-base { stroke: var(--text-secondary); stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }
.fp-label { font-size: 9px; fill: var(--text-muted); font-family: var(--font-sans); }
.fp-values { font-size: 11.5px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.fp-actions button { min-width: 0; max-width: 100%; height: auto; min-height: 32px; padding: 4px 12px; white-space: normal; text-align: center; }
@media (max-width: 700px) { .fp-actions .spacer { display: none; } .fp-actions button { flex: 1 1 100%; } }

/* ---------------------------------------------------------------- variant studies */
.study-choices { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 6px 0 10px; }
.study-choice { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; flex-wrap: wrap; }
.study-choice input[type="checkbox"] { width: 16px; height: 16px; margin: 0; }
input.study-num { width: 64px; height: 28px; }
.study-start { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.study-existing { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
#study-view { display: grid; gap: 0; min-width: 0; }
#study-view > * { min-width: 0; }
.study-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; flex: none; }
.study-row { display: grid; grid-template-columns: auto minmax(120px, 220px) minmax(120px, 1fr) minmax(0, 1.4fr); gap: 10px; align-items: center; padding: 4px 0; font-size: 13px; }
.study-row progress { width: 100%; }
@media (max-width: 700px) { .study-row { grid-template-columns: auto 1fr; } .study-row progress, .study-row .muted { grid-column: 1 / -1; } }
.study-verdict h2 { font-size: 15px; margin: 0 0 8px; }
.verdict-list { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 6px; font-size: 13.5px; }
.verdict-list li { padding: 6px 10px; border-radius: 8px; background: var(--surface-2); border-left: 3px solid var(--border); overflow-wrap: anywhere; }
.verdict-list li.verdict-pays { border-left-color: var(--up); }
.verdict-list li.verdict-fails { border-left-color: var(--down); }
.verdict-list li.verdict-unclear, .verdict-list li.verdict-few { border-left-color: var(--text-muted); }
.warning-text { color: var(--bad-text); }
.study-table td { vertical-align: top; }
.study-table th .th-text { display: block; padding: 6px 8px; font-weight: 600; }
.study-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.study-legend .legend-key { display: inline-flex; align-items: center; }
.study-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px 20px; }
.study-figure { margin: 0; min-width: 0; }
.study-figure figcaption { color: var(--text-secondary); margin-bottom: 4px; }
.study-chart { width: 100%; height: auto; display: block; }
.study-grid { stroke: var(--grid); stroke-width: 1; }
.study-axis { font-size: 10px; fill: var(--text-muted); font-family: var(--font-sans); }
.study-zero { stroke: var(--text-muted); stroke-width: 1; }
.study-cost { stroke: var(--bad-text); stroke-width: 1.5; stroke-dasharray: 5 4; }
.study-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.study-dot { stroke: var(--surface-1); stroke-width: 2; }
.study-cross { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 2 3; pointer-events: none; }
.study-hit { fill: transparent; }
.study-tip { min-height: 3.2em; margin-top: 6px; display: grid; gap: 2px; font-variant-numeric: tabular-nums; }
details.card > summary { cursor: pointer; list-style: revert; }
details.card > summary h2 { display: inline; font-size: 15px; }
.study-method { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 4px; color: var(--text-secondary); }
.history-title { font-size: 12px; font-weight: 600; color: var(--text-muted); margin: 4px 0 8px; text-transform: uppercase; letter-spacing: .04em; }

/* ---------------------------------------------------------------- market reversal overlay, settings tuning */
.rev-toggle { cursor: pointer; gap: 4px; }
.rev-toggle input { width: 14px; height: 14px; margin: 0 4px 0 0; }
.tuning-table th .th-text { display: block; padding: 6px 8px; font-weight: 600; }
.tuning-table td { vertical-align: middle; }
.tuning-row { cursor: pointer; }
.tuning-row:hover td { background: var(--surface-2); }
.tuning-row.selected td { background: color-mix(in srgb, var(--accent) 9%, var(--surface-1)); }
.tuning-table tr.best td { background: color-mix(in srgb, var(--up) 7%, transparent); }
.tuning-table tr.default td { background: var(--surface-2); }
.tuning-badge { margin-left: 6px; white-space: nowrap; }
.tuning-actions { display: flex; gap: 6px; justify-content: flex-end; white-space: nowrap; }
.tuning-actions button { height: 26px; padding: 0 10px; font-size: 12px; }
.tuning-detail { margin-top: 12px; }
.tuning-table td.wrap { white-space: normal; min-width: 150px; }
.tuning-table td.wrap:first-child { min-width: 200px; }

/* ---------------------------------------------------------------- live recordings (Data tab) */
.rec-section { margin-bottom: 18px; }
.field[hidden], .check[hidden] { display: none !important; }
.rec-section .card-head { margin-bottom: 8px; }
.state-cancelled::before { background: var(--text-muted); }
.rec-grid { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 3px 14px; margin: 8px 0; font-size: 12.5px; }
.rec-grid dt { color: var(--text-muted); }
.rec-grid dd { margin: 0; color: var(--text-secondary); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.rec-warn { color: var(--warning-text); font-weight: 600; }
@media (max-width: 600px) { .rec-grid { grid-template-columns: minmax(0, 1fr); } .rec-grid dt { margin-top: 4px; } }

/* ---------------------------------------------------------------- signal lab */
.field.full, .hint.full { grid-column: 1 / -1; }
.lab-analyses { display: grid; gap: 8px; }
.lab-an { border: 1px solid var(--border); border-left: 3px solid var(--an-color); border-radius: 10px; padding: 8px 10px; display: grid; gap: 6px; background: var(--surface-1); }
.lab-an.off { opacity: 0.55; }
.lab-an-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.lab-an-head strong { font-size: 13px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lab-an-head .icon-btn { border: 0; color: var(--text-muted); height: 24px; width: 24px; }
.lab-an-head input { margin: 0; accent-color: var(--an-color); }
.lab-swatch { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--an-color); }
.lab-rule { margin: 0; }
.lab-an-sel { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.lab-opt { display: grid; grid-template-columns: minmax(0, 1fr) 84px; align-items: center; gap: 2px 8px; }
.lab-opt > label { grid-column: 1 / -1; font-size: 12px; color: var(--text-secondary); }
.lab-opt input[type=range] { width: 100%; margin: 0; accent-color: var(--an-color); height: 24px; }
.lab-opt input[type=number] { height: 28px; }
.lab-opt-select { grid-template-columns: minmax(0, 1fr); }
.lab-an .link-btn { justify-self: start; font-size: 12px; }
.lab-add { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; }
.lab-add input[type=search] { grid-column: 1 / -1; }
#lab-tiles { grid-template-columns: repeat(auto-fill, minmax(138px, 1fr)); }
.lab-status { margin: 10px 0 0; min-height: 1.4em; }
.lab-status.busy { color: var(--accent); }
#lab-result { transition: opacity 0.15s; }
#lab-result.stale { opacity: 0.6; }
.chart-lab { height: 480px; }
.zone-right { background: color-mix(in srgb, var(--text-muted) 45%, transparent); }
.zone-wrong { background: color-mix(in srgb, var(--critical) 45%, transparent); }
.zone-none { border: 1px dashed var(--text-muted); height: 8px; width: 10px; }
.mk-timeout { width: 8px; height: 8px; border-radius: 50%; background: var(--text-secondary); }
.lab-legend .lg-signal { flex-basis: 100%; color: var(--text-primary); }
.lab-legend .lg-signal.failure { color: var(--bad-text); }
.lab-months { display: grid; gap: 4px; }
.lab-month { display: grid; grid-template-columns: 64px minmax(0, 1fr) 96px; align-items: center; gap: 10px; font-size: 12px; font-variant-numeric: tabular-nums; }
.lab-mbar { position: relative; display: flex; height: 12px; border-radius: 4px; overflow: hidden; background: var(--surface-2); }
.lab-mbar i.right { background: color-mix(in srgb, var(--text-muted) 60%, transparent); }
.lab-mbar i.wrong { background: color-mix(in srgb, var(--critical) 60%, transparent); }
.lab-mbar i + i { border-left: 2px solid var(--surface-1); }
.lab-mbar b { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--text-primary); }
.lab-mval { text-align: right; color: var(--text-secondary); }
.lab-signals-wrap { max-height: 420px; }
#lab-signals th .th-text { display: block; padding: 6px 8px; font-weight: 600; }
#lab-signals tbody tr { cursor: pointer; }
#lab-signals td .zone { vertical-align: -1px; }
@media (max-width: 600px) { .chart-lab { height: 420px; } .lab-month { grid-template-columns: 56px minmax(0, 1fr) 84px; } }

/* ---------------------------------------------------------------- exit settings sweep */
.sw-settings { display: grid; gap: 6px; margin: 8px 0 12px; }
.sw-setting { display: grid; grid-template-columns: minmax(170px, 220px) 90px minmax(160px, 1fr) 90px; grid-template-areas: "name now text off" ". . note note"; align-items: center; gap: 2px 10px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; }
.sw-setting.idle { opacity: 0.6; }
.sw-setting .sw-name { grid-area: name; }
.sw-setting .sw-now { grid-area: now; font-variant-numeric: tabular-nums; }
.sw-setting input[type=text] { grid-area: text; font-variant-numeric: tabular-nums; }
.sw-setting .sw-off { grid-area: off; font-size: 12px !important; }
.sw-setting .sw-note { grid-area: note; }
.sw-others summary { cursor: pointer; font-size: 13px; color: var(--text-secondary); margin: 6px 0; }
.sw-others .sw-setting { margin-bottom: 6px; }
.sw-opts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; max-width: 640px; }
.sw-count { margin: 10px 0 4px; font-variant-numeric: tabular-nums; }
.sw-live table { margin-top: 6px; }
.sw-history { display: grid; gap: 8px; }
.sw-history .run-open { display: grid; gap: 2px; text-align: left; justify-items: start; height: auto; padding: 8px 10px; border: 0; background: none; flex: 1; min-width: 0; }
.sw-verdict { margin: -4px 0 16px; font-size: 14px; }
.sw-heat-tools .sw-fixed { display: inline-flex; align-items: center; gap: 6px; }
.sw-heat-tools select { width: auto; height: 28px; }
.sw-heat-wrap { overflow-x: auto; }
.sw-heat { border-collapse: separate; border-spacing: 2px; font-size: 12px; font-variant-numeric: tabular-nums; }
.sw-heat th { color: var(--text-secondary); font-weight: 600; padding: 4px 8px; text-align: center; white-space: nowrap; }
.sw-heat th.corner { text-align: left; color: var(--text-muted); font-weight: 500; }
.sw-heat tbody th { text-align: right; }
.sw-heat td { position: relative; min-width: 64px; padding: 8px 10px; text-align: center; border-radius: 4px; cursor: pointer; color: var(--text-primary); }
.sw-heat td.empty { color: var(--text-muted); cursor: default; }
.sw-heat td.unranked { color: var(--text-muted); }
.sw-heat td.sel { outline: 2px solid var(--text-primary); outline-offset: -2px; }
.sw-heat td:focus-visible { outline: 2px solid var(--accent); }
.sw-heat .sw-best, .sw-heat .sw-asset { position: absolute; top: 1px; font-style: normal; font-size: 10px; line-height: 1; }
.sw-heat .sw-best { right: 3px; }
.sw-heat .sw-asset { left: 3px; }
.sw-sel-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.sw-sel-title { font-size: 14px; font-weight: 600; }
.sw-sel-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px 16px; margin-bottom: 10px; }
.sw-sel-stats > p { grid-column: 1 / -1; margin: 0; }
.sw-part h4 { margin: 0 0 4px; font-size: 12px; color: var(--text-secondary); }
.sw-stats { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--text-secondary); }
.sw-stats b { color: var(--text-primary); font-weight: 600; }
.sw-stats b.pos { color: var(--good-text); } .sw-stats b.neg { color: var(--bad-text); }
.chart-sweep { height: 320px; }
.sw-table tbody tr { cursor: pointer; }
.sw-table tr.unranked td { color: var(--text-muted); }
.sw-table tr.sw-asset-row td:first-child { font-weight: 600; }
@media (max-width: 800px) {
  .sw-setting { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name now" "text text" "off off" "note note"; }
  .sw-opts { grid-template-columns: minmax(0, 1fr); }
  .chart-sweep { height: 260px; }
}

/* ---------------------------------------------------------------- sharing between servers */
.share-modes { display: grid; gap: 4px; }
a.button { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
a.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
a.button.primary:hover { filter: brightness(1.08); }
a.button.disabled { opacity: .45; pointer-events: none; }
.upload-progress { display: flex; align-items: center; gap: 10px; }
.upload-progress progress { flex: 1; height: 8px; accent-color: var(--accent); }
.upload-progress .small { font-variant-numeric: tabular-nums; }
.packages { display: grid; gap: 4px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.package-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.package-row > span { flex: 1 1 200px; color: var(--text-secondary); }
.repair-btn { margin-left: 8px; font-size: 12px; }

/* ---------------------------------------------------------------- lab: movement filter */
#lab-mv:empty { display: none; }
.lab-mv { --an-color: var(--text-secondary); }
.mk.mk-removed { width: 7px; height: 7px; border-radius: 1px; background: var(--text-muted); }

/* ---------------------------------------------------------------- analysis exports */
.ax-candles { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.ax-export .job-actions { align-items: center; }
.ax-export .job-actions a.button { height: 30px; }
#ax-section { margin-bottom: 16px; }
.flabel { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }
#ax-block .grid2 > .field { min-width: 0; }
#ax-block input[type=datetime-local] { min-width: 0; width: 100%; font-size: 13px; }

/* ---------------------------------------------------------------- discovery: flat markets */
.zone.zone-flat { background: color-mix(in srgb, var(--text-muted) 30%, transparent); }
#d-flat-market td.wrap, #d-flat-readings td.wrap { white-space: normal; min-width: 180px; }
.sep-bar { display: inline-block; vertical-align: middle; width: 60px; height: 6px; border-radius: 3px; background: var(--surface-2); margin-left: 6px; overflow: hidden; }
.sep-bar > i { display: block; height: 100%; background: var(--accent); }

/* ---------------------------------------------------------------- Filters tab */
.fl-card .fl-card-stats { margin: 6px 0 0; color: var(--text-primary); }
.fl-card .fl-card-spread { margin: 4px 0 0; }
.fl-card .fl-card-spread:empty, .fl-card .fl-card-stats:empty { display: none; }
.fl-red-key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: -1px; background: color-mix(in srgb, var(--critical) 45%, transparent); }
.fl-limit.off > input[type=range], .fl-limit.off > input[type=number] { opacity: .45; }
.fl-limit > label { display: flex; align-items: center; gap: 6px; }
.fl-limit > label input { margin: 0; accent-color: var(--an-color); }
.fl-days { display: flex; flex-wrap: wrap; gap: 4px; }
.fl-days .chip { padding: 2px 8px; font-size: 12px; }
.fl-hours-pick { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.fl-hours-pick select { width: auto; }
.lab-legend .lg-excluded { color: var(--bad-text); }
#fl-highlight { width: auto; margin-left: 4px; font-size: 12px; padding: 2px 6px; }
.fl-profile { display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 2px; height: 120px; align-items: stretch; margin-top: 8px; }
.fl-profile-days { grid-template-columns: repeat(7, minmax(0, 1fr)); max-width: 380px; margin-top: 16px; }
.fl-prof-col { display: flex; flex-direction: column; min-width: 0; }
.fl-prof-bars { flex: 1; display: flex; align-items: flex-end; gap: 1px; border-bottom: 1px solid var(--border); }
.fl-prof-bars i { flex: 1; display: block; border-radius: 2px 2px 0 0; min-height: 1px; }
.fl-prof-flat, .fl-prof-key.fl-prof-flat { background: color-mix(in srgb, var(--text-muted) 55%, transparent); }
.fl-prof-ex, .fl-prof-key.fl-prof-ex { background: color-mix(in srgb, var(--critical) 60%, transparent); }
.fl-prof-label { font-size: 10px; text-align: center; color: var(--text-muted); margin-top: 2px; overflow: hidden; }
.fl-prof-key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: -1px; }
@media (max-width: 520px) { .fl-profile .fl-prof-col:nth-child(even) .fl-prof-label { visibility: hidden; } }
/* the strategy builder's market filters */
.fl-builder-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(290px, 100%), 1fr)); gap: 10px; margin: 8px 0; align-items: start; }
.fl-builder-list .lab-an { margin: 0; }
.fl-builder-add { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.fl-builder-add select { width: auto; max-width: 100%; }
.fl-builder-combine { max-width: 320px; margin-top: 8px; }
/* the builder's indicator rows stay within the page on a phone */
.ind-list { grid-template-columns: minmax(0, 1fr); }
.ind-row { grid-template-columns: minmax(0, 1fr); }
.ind-row, .ind-main > * { min-width: 0; max-width: 100%; }
.ind-main input, .ind-main select { max-width: 100%; }
.builder-card .outputs { overflow-wrap: anywhere; }
.builder-card .outputs code { white-space: normal; overflow-wrap: anywhere; }
.operand-box, select.operand { min-width: 0; max-width: 100%; }

/* ---- Models tab */
.model-verdict { padding: 10px 14px; border-radius: 10px; background: var(--surface-2); border-left: 4px solid var(--text-muted); margin: 0 0 14px; font-size: 13.5px; overflow-wrap: anywhere; }
.model-verdict.good { border-left-color: var(--up); }
.model-verdict.bad { border-left-color: var(--down); }
.model-table { width: 100%; }
.model-table tr.chosen td { background: var(--surface-2); font-weight: 600; }
.model-thresholds { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: 16px; }
.model-thresholds > div { min-width: 0; overflow-x: auto; }
.feat-list { display: grid; gap: 4px; }
.feat-row { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 3fr) 52px; gap: 10px; align-items: center; font-size: 12.5px; }
.feat-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feat-bar { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.feat-bar i { display: block; height: 100%; background: var(--series-1); border-radius: 5px; }
.feat-val { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-secondary); }
.model-advanced { margin-top: 10px; }
.model-advanced summary { cursor: pointer; font-size: 13px; color: var(--text-secondary); }
.fl-model-info { margin: 4px 0; color: var(--text-secondary); overflow-wrap: anywhere; }

/* ---- Pipeline tab */
.pipe-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.pipe-step { padding: 8px 12px; border-radius: 8px; background: var(--surface-2); border-left: 4px solid var(--text-muted); min-width: 0; }
.pipe-step.done { border-left-color: var(--up); }
.pipe-step.failed { border-left-color: var(--down); }
.pipe-step.fallback { border-left-color: var(--warning-border); }
.pipe-step.kept { border-left-color: var(--border); }
.pipe-step p { margin: 4px 0 0; overflow-wrap: anywhere; }
.pipe-step-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.pipe-num { font-variant-numeric: tabular-nums; color: var(--text-secondary); min-width: 1.2em; }
.pipe-badge { font-size: 11.5px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-secondary); white-space: nowrap; }
.pipe-step.done .pipe-badge, .pipe-live-step.done .pipe-badge { color: var(--up); border-color: currentColor; }
.pipe-step.failed .pipe-badge, .pipe-live-step.failed .pipe-badge { color: var(--down); border-color: currentColor; }
.pipe-step.fallback .pipe-badge, .pipe-live-step.fallback .pipe-badge { color: var(--warning-text); border-color: currentColor; }
.pipe-live { display: grid; gap: 4px; margin-top: 8px; font-size: 12.5px; }
.pipe-more { margin-top: 10px; }
.pipe-more summary { cursor: pointer; font-size: 13px; color: var(--text-secondary); }
.pipe-readings td { vertical-align: top; }

/* ---------------------------------------------------------------- market regimes in the builder */
.regime-tabs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 10px 0; }
.regime-tab { height: 30px; border-radius: 15px; background: var(--surface-2); color: var(--text-secondary); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.regime-tab.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.regime-tabs #regime-add { height: 30px; border-radius: 15px; }
.regime-chip { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-secondary); font-size: 12px; font-weight: 500; letter-spacing: 0; text-transform: none; vertical-align: 2px; }
.link-btn.danger { color: var(--bad-text); }
#regime-confirm { width: 70px; }

/* ---------------------------------------------------------------- the pipeline's regimes */
.regime-strip-box { margin: 12px 0; }
.regime-strip { position: relative; height: 22px; border-radius: 6px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); }
.regime-strip span { position: absolute; top: 0; bottom: 0; opacity: .85; }
.regime-strip .regime-cut { position: absolute; top: -2px; bottom: -2px; width: 2px; margin-left: -1px; background: var(--text-primary); }
.regime-strip-labels { position: relative; height: 16px; margin-top: 3px; }
.regime-strip-labels span { position: absolute; top: 0; padding-left: 4px; white-space: nowrap; }
.regime-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 6px; }
.regime-legend .swatch, #p-regimes-report td .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.pipe-splits { margin: 6px 0 10px; padding-left: 18px; }
.pipe-splits li { margin: 2px 0; }
#p-regimes-report td:last-child { min-width: 280px; white-space: normal; }
#p-regimes-report td:nth-child(2) { min-width: 120px; }

/* ---------------------------------------------------------------- discovery: the final strategy */
#d-strategy-card { border-color: var(--accent); }
#d-strategy .d-gap { margin: 8px 0; }
#d-strategy .d-gap-lines { margin: 4px 0 12px; padding-left: 18px; }
#d-strategy .d-gap-lines li { margin: 3px 0; }
#d-final-elements td.d-wrap { white-space: normal; min-width: 160px; max-width: 380px; }
