:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #657382;
  --line: #dbe2ea;
  --blue: #2563eb;
  --teal: #0f766e;
  --amber: #b45309;
  --red: #b91c1c;
  --green: #15803d;
  --slate: #334155;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  font-weight: 700;
}

h2 {
  font-size: 17px;
  font-weight: 700;
}

#metaLine,
.section-head span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

button {
  min-height: 36px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 6px;
  padding: 0 14px;
  font-weight: 650;
  cursor: pointer;
}

button:hover {
  border-color: #9fb0c3;
}

button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.button-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 6px;
  padding: 0 14px;
  font-weight: 650;
  cursor: pointer;
  text-decoration: none;
}

.button-link:hover {
  border-color: #9fb0c3;
}

#runTracking {
  border-color: #164e63;
  background: #155e75;
  color: #ffffff;
}

#startLab {
  border-color: #2563eb;
  background: #eff6ff;
  color: #1d4ed8;
}

#updateStrategies {
  border-color: #0f766e;
  background: #0f766e;
  color: #ffffff;
}

main {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 22px 28px 36px;
}

.strategy-shell > * {
  min-width: 0;
}

.section {
  margin-bottom: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
  margin-bottom: 14px;
}

.section-head > div {
  min-width: 0;
}

.notice {
  margin-bottom: 18px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid #f5c16c;
  background: #fff7ed;
  color: #7c2d12;
  font-size: 14px;
}

.hidden {
  display: none;
}

.strategy-tabs {
  position: sticky;
  top: 76px;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  padding: 10px;
  backdrop-filter: blur(8px);
}

.strategy-tab {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 8px 12px;
  font-weight: 650;
}

.strategy-tab.active {
  border-color: #0f766e;
  background: #ecfdf5;
  color: #0f766e;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: grid;
  gap: 18px;
}

.cockpit {
  border-color: #cbd5e1;
}

.timing-signal-preview {
  border-color: #bfdbfe;
}

.lab-overview {
  border-color: #bbf7d0;
}

.lab-strategy-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.lab-strategy-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 10px 12px;
}

.lab-strategy-row strong {
  display: block;
  font-size: 14px;
}

.lab-strategy-row span {
  color: var(--muted);
  font-size: 12px;
}

.lab-strategy-metrics {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.lab-strategy-metrics span {
  min-width: 72px;
  text-align: right;
  color: var(--ink);
  font-weight: 650;
}

.timing-signal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.timing-signal-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 12px;
}

.timing-signal-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.timing-signal-main {
  display: grid;
  gap: 3px;
  margin-top: 12px;
}

.timing-signal-main strong {
  font-size: 20px;
}

.timing-signal-main span,
.timing-signal-sub {
  color: var(--muted);
  font-size: 12px;
}

.timing-signal-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-top: 10px;
}

.timing-data-freshness {
  margin-top: 14px;
  border-top: 1px solid #edf1f5;
  padding-top: 14px;
}

.timing-data-freshness-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: baseline;
  margin-bottom: 10px;
}

.timing-data-freshness-head h3 {
  margin: 0;
  font-size: 15px;
}

.timing-data-freshness-head span {
  color: var(--muted);
  font-size: 12px;
}

.cockpit-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 18px;
}

.cockpit-grid > * {
  min-width: 0;
}

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

.cockpit-metric {
  min-width: 0;
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 12px;
}

.cockpit-metric .value {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cockpit-metric p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.cockpit-panel {
  display: grid;
  gap: 12px;
}

.cockpit-action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid #edf1f5;
  padding-top: 12px;
}

.cockpit-action-row span {
  color: var(--muted);
  font-size: 12px;
}

.compact-list {
  display: grid;
  gap: 8px;
}

.compact-list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 10px 12px;
}

.compact-list-row > div {
  min-width: 0;
}

.compact-list-row strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-list-row span:not(.badge) {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.strategy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  min-height: 188px;
  background: #fbfcfd;
}

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

.card-title {
  font-size: 16px;
  font-weight: 750;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
  background: #e8eef5;
  color: var(--slate);
}

.badge.watch,
.badge.OPEN_NEXT_OPEN {
  background: #fef3c7;
  color: #92400e;
}

.badge.HOLD,
.badge.candidate,
.badge.dashboard {
  background: #dcfce7;
  color: #166534;
}

.badge.health-green {
  background: #dcfce7;
  color: #166534;
}

.badge.health-yellow {
  background: #fef3c7;
  color: #92400e;
}

.badge.health-red {
  background: #fee2e2;
  color: #991b1b;
}

.badge.EXIT_NEXT_OPEN {
  background: #fee2e2;
  color: #991b1b;
}

.badge.NO_ACTION {
  background: #e5e7eb;
  color: #374151;
}

.badge.signal-long {
  background: #dcfce7;
  color: #166534;
}

.badge.signal-short {
  background: #fee2e2;
  color: #991b1b;
}

.badge.signal-flat {
  background: #e5e7eb;
  color: #374151;
}

.badge.freshness-updated {
  background: #dcfce7;
  color: #166534;
}

.badge.freshness-stale {
  background: #ffedd5;
  color: #9a3412;
}

.badge.freshness-missing {
  background: #e5e7eb;
  color: #374151;
}

.metric-main {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
}

.card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.strategy-detail-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.metric {
  min-width: 0;
}

.label {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 3px;
}

.value {
  font-size: 18px;
  font-weight: 750;
  white-space: nowrap;
}

.positive,
.value.positive {
  color: var(--green);
}

.negative,
.value.negative {
  color: var(--red);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 8px;
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-weight: 700;
  background: #f8fafc;
}

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

.reason-cell {
  max-width: 520px;
  white-space: normal;
  line-height: 1.45;
}

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 18px;
}

.chart {
  min-height: 260px;
}

.chart svg {
  width: 100%;
  height: 260px;
  display: block;
}

.nav-chart {
  min-height: 0;
}

.nav-chart svg {
  height: auto;
}

.toggle-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}

.toggle-line input,
.nav-filter input {
  accent-color: var(--teal);
}

.nav-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.nav-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.nav-actions button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.nav-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px 12px;
}

.nav-filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--ink);
  font-size: 13px;
}

.nav-filter span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.legend-item strong {
  color: var(--ink);
  font-weight: 750;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.axis {
  stroke: #94a3b8;
  stroke-width: 1;
}

.grid-line {
  stroke: #e5eaf0;
  stroke-width: 1;
}

.axis-label {
  fill: var(--muted);
  font-size: 11px;
}

.nav-line {
  fill: none;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-dot {
  stroke: #ffffff;
  stroke-width: 1.5;
}

.label-leader {
  stroke-width: 1;
  opacity: 0.55;
}

.line-label {
  font-size: 12px;
  font-weight: 750;
}

.bar-pos {
  fill: #0f766e;
}

.bar-neg {
  fill: #b91c1c;
}

.bar-label {
  fill: var(--muted);
  font-size: 11px;
}

.opportunity-board {
  margin-bottom: 18px;
}

.eyebrow {
  margin-bottom: 5px;
  color: var(--amber);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.opportunity-heading {
  align-items: flex-start;
}

.opportunity-status {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.opportunity-badge {
  border: 1px solid #d6dee7;
  background: #f8fafc;
  color: var(--slate);
}

.opportunity-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 14px 0;
}

.opportunity-controls label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.opportunity-controls select,
.opportunity-controls input {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  padding: 0 10px;
  font: inherit;
}

.opportunity-controls input {
  width: 92px;
}

.trade-controls {
  margin-bottom: 12px;
}

#tradeLedgerTable {
  min-width: 1180px;
}

.opportunity-grid {
  display: grid;
  grid-template-columns: minmax(420px, 0.95fr) minmax(520px, 1.2fr);
  gap: 16px;
  align-items: stretch;
}

.opportunity-grid > *,
.opportunity-lower-grid > * {
  min-width: 0;
}

.opportunity-lower-grid {
  display: grid;
  grid-template-columns: minmax(520px, 1.25fr) minmax(320px, 0.75fr);
  gap: 16px;
  margin-top: 16px;
}

.opportunity-lower-grid h3,
.bond-detail h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.opportunity-table-wrap {
  min-width: 0;
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.dense-table {
  min-width: 760px;
}

.dense-table th {
  position: sticky;
  top: 0;
  z-index: 1;
}

.dense-table td,
.dense-table th {
  padding: 8px 7px;
}

.signal-row {
  cursor: pointer;
}

.signal-row:hover,
.selected-row {
  background: #f1f5f9;
}

.curve-panel {
  min-width: 0;
  min-height: 380px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 8px;
}

.curve-panel canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  height: 100%;
  min-height: 380px;
}

.side-pill,
.candidate-leg {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 800;
}

.side-long {
  border-color: rgba(185, 28, 28, 0.28);
  background: rgba(239, 68, 68, 0.1);
  color: #b91c1c;
}

.side-short {
  border-color: rgba(4, 120, 87, 0.26);
  background: rgba(16, 185, 129, 0.11);
  color: #047857;
}

.side-neutral {
  border-color: rgba(100, 116, 139, 0.2);
  background: rgba(100, 116, 139, 0.1);
  color: #64748b;
}

.candidate-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 10px;
}

.candidate-card {
  display: block;
  width: 100%;
  min-height: 132px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 12px;
  color: var(--ink);
  text-align: left;
}

.candidate-card:hover,
.selected-card {
  border-color: #9fb0c3;
  background: #f8fafc;
}

.candidate-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
}

.candidate-card-head strong {
  color: var(--ink);
  font-size: 14px;
}

.candidate-symbols {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 28px;
}

.candidate-metrics {
  display: grid;
  gap: 5px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.bond-detail {
  min-height: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 14px;
}

.detail-kv {
  display: grid;
  grid-template-columns: minmax(90px, 0.5fr) minmax(0, 1fr);
  gap: 9px 12px;
  font-size: 13px;
}

.detail-kv span {
  color: var(--muted);
}

.detail-kv strong {
  min-width: 0;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.detail-stack {
  display: grid;
  gap: 8px;
}

.detail-row {
  display: grid;
  grid-template-columns: auto minmax(100px, 1fr) repeat(4, auto);
  gap: 8px;
  align-items: center;
  border-top: 1px solid #edf1f5;
  padding-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.detail-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.empty-cell,
.empty-state {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.empty-cell {
  height: 96px;
  text-align: center;
}

.sleeve-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.sleeve {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
}

.sleeve-title {
  font-weight: 750;
  margin-bottom: 9px;
}

.sleeve .row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 0;
  border-top: 1px solid #edf1f5;
  color: var(--muted);
  font-size: 12px;
}

.sleeve .row strong {
  color: var(--ink);
}

body.modal-open {
  overflow: hidden;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.45);
}

.modal.hidden {
  display: none;
}

.modal-panel {
  width: min(760px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
}

.modal-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.98);
}

#strategyDetailSubtitle {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.detail-body {
  padding: 18px;
}

.detail-section {
  margin-bottom: 18px;
}

.detail-section:last-child {
  margin-bottom: 0;
}

.detail-section h3 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 750;
}

.detail-section p {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.65;
}

.detail-list {
  margin: 0;
  padding-left: 18px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.65;
}

.detail-list li + li {
  margin-top: 4px;
}

.detail-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-chips span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
  color: var(--slate);
  font-size: 13px;
  font-weight: 650;
}

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

.detail-metric {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fbfcfd;
}

.detail-metric span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}

.detail-metric strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 16px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid #164e63;
  border-radius: 6px;
  padding: 0 12px;
  background: #155e75;
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.detail-link:hover {
  background: #164e63;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(520px, calc(100vw - 44px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.18);
  color: var(--ink);
  font-size: 13px;
}

@media (max-width: 980px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .strategy-tabs {
    position: static;
  }

  .strategy-grid,
  .two-col,
  .sleeve-grid,
  .cockpit-grid,
  .opportunity-grid,
  .opportunity-lower-grid {
    grid-template-columns: 1fr;
  }

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

  .cockpit-action-row,
  .compact-list-row {
    align-items: stretch;
    flex-direction: column;
  }

  .cockpit-action-row .button-link {
    justify-content: center;
  }

  .opportunity-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .opportunity-status {
    justify-content: flex-start;
  }

  .opportunity-table-wrap {
    max-height: 360px;
  }

  .detail-row {
    grid-template-columns: 1fr 1fr;
  }

  main {
    padding: 16px;
  }

  .modal {
    align-items: flex-start;
    padding: 12px;
  }

  .modal-panel {
    max-height: calc(100vh - 24px);
  }

  .modal-head {
    align-items: stretch;
    flex-direction: column;
  }

  .detail-metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
/* Public snapshot: local machine actions are intentionally unavailable. */
#startLab,
#runTracking,
#updateStrategies,
#labOverview .button-link {
  display: none !important;
}
