:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #20242a;
  --muted: #68707a;
  --line: #dfe4df;
  --soft: #eef2ee;
  --blue: #2f5f9f;
  --green: #227a55;
  --amber: #a76716;
  --red: #aa3d3d;
  --violet: #6750a4;
  --shadow: 0 14px 38px rgba(30, 36, 42, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

/* Numeric readouts use tabular figures so prices/PnL stay column-aligned. */
.metric-card strong,
.metric-tile .value,
.pc-kpi b,
.pc-headline,
.testing-stats strong,
.blotter-row,
.signal-row,
.candidate-row,
.alert-row {
  font-variant-numeric: tabular-nums;
}

.app-shell {
  min-height: 100vh;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfa;
}

.brand {
  padding-right: 28px;
  border-right: 1px solid var(--line);
}

.brand h1 {
  font-size: 21px;
  line-height: 1.1;
}

.app-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.app-nav {
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f4f6f4;
}

.nav-item {
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 750;
  white-space: nowrap;
}

.nav-item.active {
  border-color: #cbd8ce;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 4px 14px rgba(30, 36, 42, 0.07);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.05;
}

h2 {
  max-width: 760px;
  margin-bottom: 0;
  font-size: 20px;
  line-height: 1.15;
  font-weight: 750;
}

h3 {
  margin-bottom: 0;
  font-size: 17px;
}

.legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.info-trigger {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid #cfd8cf;
  border-radius: 50%;
  background: #fff;
  color: #3d454d;
  font-size: 12px;
  font-weight: 850;
  line-height: 1;
}

.info-trigger:hover,
.info-trigger:focus-visible {
  border-color: #b8c3bc;
  background: #f1f4f1;
}

.hover-card {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 30;
  display: none;
  width: min(260px, 80vw);
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: var(--shadow);
  color: #3d454d;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.35;
  text-align: left;
}

.info-trigger:hover .hover-card,
.info-trigger:focus-visible .hover-card {
  display: block;
}

.page-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.page-title span {
  color: var(--muted);
  font-size: 13px;
}

.research-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}

.sync-control {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.sync-button {
  min-height: 26px;
  padding: 3px 8px;
  border: 1px solid #cfd8cf;
  border-radius: 5px;
  background: #fff;
  color: #3d454d;
  font-size: 12px;
  font-weight: 750;
}

.sync-button:hover {
  border-color: #b8c3bc;
  background: #f1f4f1;
}

.sync-control span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 8px;
  border-radius: 50%;
  vertical-align: 1px;
}

.dot.good {
  background: var(--green);
}

.dot.watch {
  background: var(--amber);
}

.dot.risk {
  background: var(--red);
}

.workspace {
  display: grid;
  gap: 22px;
  width: 100%;
  max-width: 1540px;
  margin: 0 auto;
  padding: 28px;
}

.page-panel {
  display: none;
}

.page-panel.active {
  display: grid;
  gap: 22px;
}

.topbar,
.filters,
.section-heading,
.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.status-row,
.metric-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.nav-item:hover {
  border-color: #b8c3bc;
  background: #f1f4f1;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(118px, 1fr));
  gap: 8px;
}

.metric-card,
.detail-panel,
.strategy-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric-card {
  min-height: 82px;
  padding: 11px 12px;
  text-align: left;
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.metric-card strong {
  display: block;
  margin: 5px 0 1px;
  font-size: 24px;
  line-height: 1;
}

.metric-card small,
.section-heading span {
  color: var(--muted);
  font-size: 12px;
}

.filter-card {
  cursor: pointer;
}

.filter-card.active {
  border-color: #9fb6dc;
  outline: 2px solid rgba(47, 95, 159, 0.16);
}

.filter-card:hover {
  border-color: #b4c0c9;
}

.filters {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 190px;
  align-items: end;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cfd8cf;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

input,
select {
  min-height: 38px;
  padding: 8px 10px;
}

textarea {
  min-height: 86px;
  padding: 10px;
  resize: vertical;
}

.futures-filter {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.futures-options {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-chip {
  min-height: 32px;
  padding: 5px 10px;
  border: 1px solid #cfd8cf;
  border-radius: 999px;
  background: #fff;
  color: #3d454d;
  font-size: 12px;
  font-weight: 750;
}

.filter-chip.active {
  border-color: #9fb6dc;
  background: #eaf0f8;
  color: var(--blue);
}

.filter-chip:hover {
  border-color: #b8c3bc;
  background: #f1f4f1;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(520px, 1.35fr);
  gap: 18px;
  align-items: start;
}

.strategy-list {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.strategy-card {
  display: grid;
  gap: 12px;
  width: 100%;
  padding: 15px;
  text-align: left;
}

.strategy-card.active {
  border-color: #9fb6dc;
  outline: 2px solid rgba(47, 95, 159, 0.16);
}

.strategy-card:hover {
  border-color: #b4c0c9;
}

.card-top,
.card-bottom {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  display: grid;
  gap: 4px;
}

.card-title strong {
  font-size: 15px;
  line-height: 1.25;
}

.card-title span,
.card-bottom {
  color: var(--muted);
  font-size: 13px;
}

.status-badge,
.priority-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
  line-height: 1;
  white-space: nowrap;
}

.status-badge.candidate {
  background: #e8f4ef;
  color: var(--green);
}

.status-badge.researching {
  background: #eaf0f8;
  color: var(--blue);
}

.status-badge.watch {
  background: #fff2dd;
  color: var(--amber);
}

.status-badge.archived {
  background: #efedf6;
  color: var(--violet);
}

.status-badge.rejected {
  background: #fae9e9;
  color: var(--red);
}

.priority-badge {
  background: #f0f2f4;
  color: #555d66;
}

.metric-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.metric-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfb;
  color: #3c444c;
  font-size: 12px;
}

.detail-panel {
  min-height: 640px;
  padding: 20px;
}

.empty-detail {
  display: grid;
  place-items: center;
  min-height: 420px;
  color: var(--muted);
  text-align: center;
}

.detail-header {
  align-items: flex-start;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.detail-title {
  display: grid;
  gap: 7px;
}

.detail-title h3 {
  font-size: 24px;
}

.hypothesis {
  margin: 16px 0;
  color: #3c444c;
  line-height: 1.5;
}

.metric-table {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.metric-tile {
  display: grid;
  grid-template-columns: minmax(118px, 1fr) auto;
  gap: 8px;
  min-height: 78px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.metric-tile .name {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.metric-tile .value {
  margin-top: 4px;
  font-size: 21px;
  font-weight: 800;
}

.metric-tile .range {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
}

.evidence-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.evidence-box {
  min-height: 108px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.evidence-box strong {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
}

.evidence-box p,
.history-list p,
.reason-box {
  margin-bottom: 0;
  color: #3d454d;
  font-size: 13px;
  line-height: 1.45;
}

.detail-section {
  margin-top: 20px;
}

.detail-section h4 {
  margin: 0 0 10px;
  font-size: 14px;
}

.reason-box {
  padding: 12px;
  border-left: 3px solid var(--red);
  border-radius: 6px;
  background: #fff8f8;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-item {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.history-date {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.measure-table {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.measure-rule {
  min-height: 112px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.measure-rule strong {
  display: block;
  margin-bottom: 6px;
}

.measure-rule p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.range-list {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.range-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 6px;
  background: #fff;
  color: #3d454d;
  font-size: 12px;
}

.range-row span {
  font-weight: 800;
}

.range-row strong {
  margin: 0;
  text-align: right;
}

.range-row.good {
  border-color: rgba(34, 122, 85, 0.28);
  border-left-color: var(--green);
  background: rgba(34, 122, 85, 0.07);
}

.range-row.watch {
  border-color: rgba(167, 103, 22, 0.28);
  border-left-color: var(--amber);
  background: rgba(167, 103, 22, 0.07);
}

.range-row.risk {
  border-color: rgba(170, 61, 61, 0.28);
  border-left-color: var(--red);
  background: rgba(170, 61, 61, 0.07);
}

.measure-dialog {
  width: min(920px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(30, 36, 42, 0.22);
}

.measure-dialog::backdrop {
  background: rgba(32, 36, 42, 0.38);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.dialog-close {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: #3d454d;
  font-weight: 800;
}

.dialog-close:hover {
  border-color: #b8c3bc;
  background: #f1f4f1;
}

.connection-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 11px;
  border: 1px solid #e1c58f;
  border-radius: 999px;
  background: #fff6e6;
  color: var(--amber);
  font-size: 12px;
  font-weight: 750;
  line-height: 1;
  white-space: nowrap;
}

.alerts-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1.4fr) minmax(280px, 0.9fr);
  gap: 14px;
}

.alert-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.alert-queue {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.alert-row {
  display: grid;
  grid-template-columns:
    minmax(150px, 1.1fr)
    minmax(110px, 0.8fr)
    minmax(150px, 1fr)
    minmax(86px, 0.6fr)
    minmax(74px, 0.5fr)
    minmax(96px, 0.6fr)
    minmax(150px, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 42px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  color: #3d454d;
  font-size: 12px;
}

.alert-row.status-row {
  color: var(--muted);
}

.alert-row strong {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
}

.source-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 9px;
  border: 1px solid #b9d2c4;
  border-radius: 999px;
  background: #eff8f2;
  color: var(--green);
  font-size: 12px;
  font-weight: 750;
  line-height: 1;
}

.ops-panel {
  min-height: 220px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 148px;
  border: 1px dashed #cbd5ce;
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--muted);
  font-size: 14px;
}

.watchlist-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 46px;
  border-top: 1px solid var(--line);
  color: #3d454d;
}

.watchlist-row:first-of-type {
  margin-top: 10px;
}

.watchlist-row span {
  color: var(--muted);
  font-size: 13px;
}

.schema-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.schema-list span {
  min-height: 34px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfb;
  color: #3d454d;
  font-size: 13px;
}

.readiness-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  color: #3d454d;
  font-size: 14px;
}

.testing-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.testing-hero h2 {
  font-size: 28px;
  font-weight: 850;
}

.testing-hero span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.mode-toggle,
.range-control {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid #d7dbd8;
  border-radius: 10px;
  background: #fff;
}

.mode-toggle span,
.mode-toggle button,
.range-control span {
  min-height: 30px;
  padding: 7px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #20242a;
  font-size: 12px;
  font-weight: 800;
}

.mode-toggle .active,
.range-control .active {
  background: #dff7e9;
  color: #126a3d;
}

.bridge-status {
  min-height: 32px;
  padding: 8px 10px;
  border: 1px solid #d5d8d6;
  border-radius: 8px;
  background: #fff;
  color: #59616a;
  font-size: 12px;
  font-weight: 750;
}

.bridge-status[data-tone="good"] {
  border-color: rgba(34, 122, 85, 0.28);
  background: rgba(34, 122, 85, 0.07);
  color: #126a3d;
}

.bridge-status[data-tone="watch"] {
  border-color: rgba(167, 103, 22, 0.28);
  background: rgba(167, 103, 22, 0.07);
  color: #80580d;
}

.bridge-status[data-tone="risk"] {
  border-color: rgba(170, 61, 61, 0.28);
  background: rgba(170, 61, 61, 0.07);
  color: #963126;
}

.chart-panel,
.strategy-table-panel,
.testing-status-panel,
.strategy-ticket {
  border: 1px solid #d5d8d6;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(30, 36, 42, 0.04);
}

.panel-toolbar span,
.testing-table .table-head,
.status-head {
  color: #6f7680;
  font-size: 12px;
}

.testing-grid {
  display: grid;
  grid-template-columns: minmax(420px, 0.95fr) minmax(520px, 1fr);
  gap: 18px;
}

.testing-grid-single {
  grid-template-columns: 1fr;
}

.chart-panel,
.strategy-table-panel,
.testing-status-panel {
  padding: 18px;
}

.panel-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.panel-toolbar h3 {
  font-size: 24px;
}

.dark-action {
  min-height: 38px;
  padding: 8px 16px;
  border: 0;
  border-radius: 9px;
  background: #171717;
  color: #fff;
  font-size: 13px;
  font-weight: 750;
}

.progress-chart {
  position: relative;
  min-height: 320px;
  border: 1px solid #e1e5e2;
  border-radius: 12px;
  overflow: hidden;
  background:
    linear-gradient(#fff 0 0) padding-box,
    repeating-linear-gradient(90deg, transparent 0 17%, rgba(211, 219, 214, 0.48) 17.1% 17.3%) border-box;
}

.progress-chart svg {
  width: 100%;
  height: 100%;
  min-height: 320px;
}

.progress-chart line {
  stroke: #bfc8c2;
  stroke-dasharray: 8 7;
}

.progress-chart circle {
  fill: #40518e;
}

.chart-fill {
  fill: url(#testingChartFill);
}

.chart-line {
  fill: none;
  stroke: #26a96a;
  stroke-width: 3;
}

.chart-callout {
  position: absolute;
  right: 22%;
  top: 24%;
  min-width: 70px;
  padding: 13px 16px;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(30, 36, 42, 0.12);
  text-align: center;
  font-weight: 850;
}

.testing-table {
  display: grid;
  overflow: hidden;
}

.table-row,
.status-row {
  display: grid;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  border-bottom: 1px solid #edf0ee;
  color: #111;
  font-size: 13px;
}

.table-row {
  grid-template-columns: minmax(160px, 1.25fr) 90px 82px 80px minmax(160px, 1fr) 112px;
}

.status-row {
  grid-template-columns: 150px minmax(190px, 0.9fr) minmax(260px, 1.2fr) 130px 70px;
}

.table-row:last-child,
.status-row:last-child {
  border-bottom: 0;
}

.table-head,
.status-head {
  min-height: 34px;
  color: #7b828a;
  font-size: 11px;
  text-transform: uppercase;
}

.table-row button,
.status-row button {
  justify-self: start;
  min-height: 32px;
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  background: #f7f7f7;
  color: #171717;
  font-size: 12px;
  font-weight: 750;
}

mark {
  display: inline-flex;
  width: max-content;
  min-height: 22px;
  align-items: center;
  padding: 0 9px;
  border-radius: 999px;
  background: #e9f8ef;
  color: #137342;
  font-size: 12px;
  font-weight: 750;
  line-height: 1;
}

.strategy-ticket {
  padding: 16px 18px;
}

.ticket-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid #edf0ee;
}

.ticket-header h3 {
  margin-bottom: 4px;
  font-size: 20px;
}

.ticket-header span:not(.status-badge) {
  color: var(--muted);
  font-size: 12px;
}

.ticket-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  margin-top: 8px;
}

.ticket-grid div {
  min-height: 92px;
  padding: 12px 10px;
  border-bottom: 1px solid #edf0ee;
}

.ticket-grid strong {
  display: block;
  margin-bottom: 7px;
  color: #7b828a;
  font-size: 11px;
  text-transform: uppercase;
}

.ticket-grid p,
.status-row span {
  margin-bottom: 0;
  color: #20242a;
  font-size: 12px;
  line-height: 1.45;
}

.ticket-subgrid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  margin-top: 10px;
  border-top: 1px solid #edf0ee;
}

.ticket-subgrid > div {
  min-height: 94px;
  padding: 12px 10px;
  border-bottom: 1px solid #edf0ee;
}

.ticket-subgrid strong {
  display: block;
  margin-bottom: 7px;
  color: #7b828a;
  font-size: 11px;
  text-transform: uppercase;
}

.ticket-subgrid p,
.ticket-subgrid li {
  color: #20242a;
  font-size: 12px;
  line-height: 1.45;
}

.ticket-subgrid p {
  margin-bottom: 0;
}

.ticket-subgrid ul {
  display: grid;
  gap: 5px;
  margin: 0;
  padding-left: 18px;
}

.strategy-ticket-list {
  display: grid;
  gap: 12px;
}

.contract-pill,
.state-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.contract-pill {
  background: #eef1f5;
  color: #4f5d70;
}

.state-pill {
  min-width: 72px;
  justify-content: center;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
}

.state-pill.live {
  background: #e6f7ed;
  color: #1d6b28;
}

.state-pill.scanning {
  background: #fff1cb;
  color: #80580d;
}

.gain {
  color: #18a36b;
}

.loss {
  color: #d93025;
}

.muted {
  color: #6b7890;
}

.testing-workspace {
  display: grid;
  grid-template-columns: minmax(360px, 0.88fr) minmax(560px, 1.4fr);
  gap: 14px;
  align-items: start;
}

.testing-queue-panel,
.testing-card {
  border: 1px solid #d5d8d6;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(30, 36, 42, 0.04);
}

.testing-queue-panel {
  padding: 14px;
  position: sticky;
  top: 88px;
}

.testing-queue-panel .panel-toolbar {
  margin-bottom: 8px;
}

.testing-queue-panel .panel-toolbar h3,
.testing-status-panel .panel-toolbar h3 {
  font-size: 17px;
}

.testing-candidate-table {
  display: grid;
  overflow-x: auto;
}

.candidate-row {
  display: grid;
  grid-template-columns: minmax(170px, 1.25fr) 64px 112px minmax(130px, 1fr) minmax(110px, 0.8fr) minmax(190px, 1.25fr);
  gap: 10px;
  align-items: center;
  min-width: 860px;
  min-height: 46px;
  border-bottom: 1px solid #edf0ee;
  color: #303942;
  font-size: 12px;
}

.candidate-row:last-child {
  border-bottom: 0;
}

.candidate-row strong {
  font-size: 13px;
}

.candidate-head {
  min-height: 30px;
  color: #747d86;
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.candidate-table-row {
  grid-template-columns: minmax(170px, 1.25fr) 70px 112px 70px 100px 88px 86px 76px minmax(160px, 1fr) minmax(170px, 1fr);
  min-width: 1180px;
}

.candidate-table-row p {
  margin: 0;
  color: #52606d;
  font-size: 12px;
  line-height: 1.35;
}

.testing-card {
  overflow: hidden;
}

.testing-card-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, auto);
  gap: 18px;
  align-items: start;
  padding: 16px 18px;
  border-bottom: 1px solid #edf0ee;
}

.testing-title-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.testing-title-line h3 {
  font-size: 18px;
  line-height: 1.2;
}

.testing-card-header p {
  margin: 7px 0 0;
  color: #52606d;
  font-size: 13px;
  line-height: 1.45;
}

.testing-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(96px, 1fr));
  gap: 8px;
}

.testing-stats span {
  min-height: 56px;
  padding: 9px 10px;
  border: 1px solid #e1e5e2;
  border-radius: 6px;
  background: #fbfcfb;
  color: #69727b;
  font-size: 11px;
  font-weight: 800;
}

.testing-stats strong {
  display: block;
  margin-bottom: 4px;
  color: #20242a;
  font-size: 13px;
  line-height: 1.25;
}

.strategy-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-bottom: 1px solid #edf0ee;
}

.strategy-card-grid div {
  min-height: 112px;
  padding: 13px 14px;
  border-right: 1px solid #edf0ee;
  border-bottom: 1px solid #edf0ee;
}

.strategy-card-grid div:nth-child(3n) {
  border-right: 0;
}

.strategy-card-grid strong,
.signal-head,
.testing-diagnostics strong {
  color: #6f7680;
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.strategy-card-grid p {
  margin: 6px 0 0;
  color: #20242a;
  font-size: 12px;
  line-height: 1.45;
}

.signal-log {
  margin: 14px 18px;
  overflow-x: auto;
  border: 1px solid #e1e5e2;
  border-radius: 7px;
}

.signal-row {
  display: grid;
  grid-template-columns: 92px 88px 88px minmax(190px, 1.1fr) 110px minmax(170px, 1fr);
  gap: 10px;
  align-items: center;
  min-width: 760px;
  min-height: 38px;
  padding: 0 10px;
  border-bottom: 1px solid #edf0ee;
  color: #3f4a55;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  font-weight: 700;
}

.signal-row:last-child {
  border-bottom: 0;
}

.signal-row b {
  display: inline-flex;
  min-width: 58px;
  justify-content: center;
  padding: 3px 7px;
  border-radius: 5px;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 11px;
  font-weight: 900;
}

.signal-row b.long {
  background: #ddf4e8;
  color: #25631f;
}

.signal-row b.short {
  background: #fde5e2;
  color: #963126;
}

.signal-row.open {
  background: #f3f8f5;
}

.signal-head {
  min-height: 32px;
  background: #f6f8f6;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
}

.testing-empty-row {
  padding: 14px;
  color: #69727b;
  font-size: 13px;
}

.testing-diagnostics {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  padding: 0 18px 16px;
}

.testing-diagnostics div:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.testing-diagnostics ul {
  display: grid;
  gap: 5px;
  margin: 7px 0 0;
  padding-left: 18px;
}

.testing-diagnostics li,
.testing-diagnostics p {
  margin: 0;
  color: #52606d;
  font-size: 12px;
  line-height: 1.45;
}

/* ===== Testing page: paper-trade cards ===== */
.paper-cards {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.paper-card {
  border: 1px solid #d8dcd9;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(30, 36, 42, 0.05);
  overflow: hidden;
}

.pc-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px 12px;
}

.pc-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.pc-title strong {
  font-size: 17px;
  font-weight: 800;
}

.pc-inst {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 9px;
  border-radius: 6px;
  background: #eef1f5;
  color: #4f5d70;
  font-size: 12px;
  font-weight: 750;
  line-height: 1;
}

.pc-stage {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.pc-headline {
  text-align: right;
  font-size: 22px;
  font-weight: 850;
  line-height: 1.1;
  white-space: nowrap;
}

.pc-headline small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.pc-kpis {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 1px;
  margin: 0 18px;
  border: 1px solid #ebeeec;
  border-radius: 9px;
  overflow: hidden;
  background: #ebeeec;
}

.pc-kpi {
  padding: 8px 10px;
  background: #fbfcfb;
}

.pc-kpi label {
  display: block;
  margin-bottom: 2px;
  color: #7b828a;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.pc-kpi b {
  font-size: 14px;
  font-weight: 850;
  color: #20242a;
}

.pc-meta {
  margin: 10px 18px 0;
  color: #69727b;
  font-size: 11.5px;
}

.pc-blotter {
  margin: 12px 18px 0;
  border: 1px solid #e4e8e5;
  border-radius: 9px;
  overflow-x: auto;
}

.blotter-row {
  display: grid;
  grid-template-columns: 78px 64px 64px 52px minmax(150px, 1fr) 54px 92px 96px minmax(120px, 0.9fr);
  align-items: center;
  gap: 8px;
  min-width: 760px;
  min-height: 36px;
  padding: 0 12px;
  border-bottom: 1px solid #edf0ee;
  color: #2f3a44;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  font-weight: 650;
}

.blotter-row:last-child {
  border-bottom: 0;
}

.blotter-row.open {
  background: #f3f8f5;
}

.blotter-head {
  min-height: 30px;
  background: #f6f8f6;
  color: #7b828a;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.blotter-row b {
  display: inline-flex;
  min-width: 50px;
  justify-content: center;
  padding: 2px 6px;
  border-radius: 5px;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 10px;
  font-weight: 900;
}

.blotter-row b.long {
  background: #ddf4e8;
  color: #25631f;
}

.blotter-row b.short {
  background: #fde5e2;
  color: #963126;
}

.bl-reason {
  color: #8a929b;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 11px;
  font-weight: 600;
}

.pc-blotter-empty {
  margin: 12px 18px 0;
  padding: 16px;
  border: 1px dashed #d8dcd9;
  border-radius: 9px;
  color: #69727b;
  font-size: 13px;
  text-align: center;
}

.pc-foot {
  margin: 12px 18px 0;
  color: #52606d;
  font-size: 12px;
  font-weight: 650;
}

.pc-foot.pc-next {
  color: #80580d;
}

.pc-details {
  margin-top: 12px;
  border-top: 1px solid #edf0ee;
}

.pc-details > summary {
  list-style: none;
  padding: 11px 18px;
  color: #2f5f9f;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  user-select: none;
}

.pc-details > summary::-webkit-details-marker {
  display: none;
}

.pc-details > summary::before {
  content: "\25B8  ";
  color: #9aa2ab;
}

.pc-details[open] > summary::before {
  content: "\25BE  ";
}

.pc-detail-body {
  display: grid;
  gap: 16px;
  padding: 4px 18px 18px;
}

.pc-detail-block h4 {
  margin: 0 0 7px;
  color: #6f7680;
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.pc-rules {
  display: grid;
  gap: 8px;
  margin: 0;
}

.pc-rules div {
  display: grid;
  grid-template-columns: minmax(120px, 180px) 1fr;
  gap: 12px;
}

.pc-rules dt {
  color: #3d454d;
  font-size: 12px;
  font-weight: 750;
}

.pc-rules dd {
  margin: 0;
  color: #52606d;
  font-size: 12px;
  line-height: 1.45;
}

.pc-detail-block ul {
  display: grid;
  gap: 5px;
  margin: 0;
  padding-left: 18px;
}

.pc-detail-block li {
  color: #52606d;
  font-size: 12px;
  line-height: 1.45;
}

/* Collapsible promotion checklist */
.workflow-collapse {
  margin-top: 18px;
  border: 1px solid #d8dcd9;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(30, 36, 42, 0.04);
  overflow: hidden;
}

.workflow-collapse > summary {
  list-style: none;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  padding: 15px 18px;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  user-select: none;
}

.workflow-collapse > summary::-webkit-details-marker {
  display: none;
}

.workflow-collapse > summary::before {
  content: "\25B8";
  color: #9aa2ab;
  font-size: 13px;
}

.workflow-collapse[open] > summary::before {
  content: "\25BE";
}

.workflow-collapse > summary small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.workflow-collapse .status-table {
  padding: 0 18px 14px;
}

.workflow-collapse .status-row {
  grid-template-columns: 150px minmax(190px, 0.9fr) minmax(260px, 1.2fr) 130px;
}

@media (max-width: 1060px) {
  .app-header {
    position: static;
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    padding: 18px;
  }

  .brand {
    padding-right: 0;
    border-right: 0;
  }

  .app-nav {
    overflow-x: auto;
  }

  .content-grid,
  .measure-table,
  .alerts-grid {
    grid-template-columns: 1fr 1fr;
  }

  .testing-workspace,
  .testing-card-header {
    grid-template-columns: 1fr;
  }

  .testing-queue-panel {
    position: static;
  }

  .testing-grid {
    grid-template-columns: 1fr;
  }

  .strategy-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .strategy-table-panel,
  .testing-status-panel {
    overflow-x: auto;
  }

  .table-row,
  .status-row {
    min-width: 880px;
  }

  .summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .filters {
    grid-template-columns: 1fr;
  }

  .pc-kpis {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 760px) {
  .pc-head {
    flex-direction: column;
  }

  .pc-headline {
    text-align: left;
  }

  .pc-kpis {
    grid-template-columns: repeat(2, 1fr);
  }

  .pc-rules div {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .workspace {
    padding: 16px;
  }

  .topbar,
  .filters,
  .detail-header,
  .history-item,
  .content-grid,
  .summary-grid,
  .metric-table,
  .evidence-grid,
  .measure-table,
  .alerts-grid,
  .ticket-grid,
  .ticket-subgrid,
  .strategy-card-grid,
  .testing-stats,
  .testing-diagnostics,
  .schema-list {
    grid-template-columns: 1fr;
  }

  .testing-hero,
  .panel-toolbar,
  .ticket-header {
    align-items: stretch;
    flex-direction: column;
  }

  .state-pill {
    justify-self: start;
    text-align: left;
  }

  .strategy-card-grid div {
    border-right: 0;
  }

  .mode-toggle,
  .range-control {
    width: max-content;
  }

  .topbar,
  .filters,
  .detail-header {
    align-items: stretch;
    flex-direction: column;
  }

  .alert-row {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 12px 0;
  }

  .research-toolbar,
  .sync-control {
    justify-items: start;
    justify-content: flex-start;
  }

  .app-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
  }

  h2 {
    font-size: 19px;
  }

  .metric-card {
    min-height: 78px;
  }
}

/* --- Bake-off page ---------------------------------------------------------- */
.bakeoff-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.bakeoff-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.bakeoff-controls label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

.bakeoff-controls select {
  width: auto;
  min-width: 132px;
}

.bakeoff-meta {
  margin: 14px 0 0;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.bakeoff-table-wrap {
  margin-top: 8px;
  overflow-x: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.bakeoff-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.bakeoff-table thead th {
  position: sticky;
  top: 0;
  background: var(--soft);
  color: var(--muted);
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.bakeoff-table th.num,
.bakeoff-table td.num {
  text-align: right;
}

.bakeoff-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--soft);
  white-space: nowrap;
}

.bakeoff-table tbody tr:last-child td {
  border-bottom: none;
}

.bakeoff-table tbody tr:hover {
  background: var(--soft);
}

.bakeoff-table .strat-cell {
  font-weight: 600;
}

.bakeoff-table .params-cell {
  color: var(--muted);
  font-size: 12px;
  white-space: normal;
  min-width: 240px;
}

.bakeoff-table .inst-pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 22px;
  background: var(--soft);
  border: 1px solid var(--line);
  font-size: 11px;
  font-weight: 600;
}

.bakeoff-table td.gain { color: var(--green); }
.bakeoff-table td.loss { color: var(--red); }
.bakeoff-table td.good { color: var(--green); font-weight: 600; }
.bakeoff-table td.watch { color: var(--amber); }
.bakeoff-table td.risk { color: var(--red); }
.bakeoff-table td.muted { color: var(--muted); }

.bakeoff-empty {
  padding: 28px 12px;
  text-align: center;
  color: var(--muted);
}
