:root {
  color-scheme: light;
  --bg: #f4f5f2;
  --ink: #171917;
  --muted: #646b61;
  --line: #d7dbd2;
  --panel: #ffffff;
  --accent: #c6202f;
  --accent-dark: #8f1722;
  --blue: #1b5c8c;
  --green: #3f6b45;
  --shadow: 0 18px 40px rgba(29, 33, 27, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(90deg, rgba(23, 25, 23, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(23, 25, 23, 0.03) 1px, transparent 1px),
    var(--bg);
  background-size: 36px 36px;
  color: var(--ink);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

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

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(18px, 4vw, 56px) 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 245, 242, 0.92);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 52px);
  line-height: 1;
}

h2 {
  font-size: 18px;
}

.status {
  min-width: 88px;
  text-align: center;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
}

.workspace {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px clamp(18px, 4vw, 56px) 42px;
}

.summary-panel,
.guide-panel,
.control-panel,
.candidate-area,
.inspector,
.backtest-panel {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.guide-panel {
  display: grid;
  grid-template-columns: 0.72fr 1.28fr;
  gap: 24px;
  margin-top: 16px;
  padding: 22px 24px;
}

.guide-panel p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.7;
}

.guide-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.guide-steps li {
  min-height: 112px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
}

.guide-steps strong {
  display: block;
  margin-bottom: 8px;
}

.guide-steps span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.summary-panel {
  display: grid;
  grid-template-columns: 1.1fr 1.4fr;
  gap: 26px;
  padding: 24px;
}

.summary-panel p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.6;
}

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

.metrics div,
.backtest-grid div,
.signal-list div {
  border-left: 3px solid var(--line);
  padding-left: 14px;
}

.metrics span,
.backtest-grid span,
.signal-list span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.metrics strong,
.backtest-grid strong {
  font-size: 26px;
}

.control-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr)) auto auto;
  align-items: end;
  gap: 14px;
  margin-top: 16px;
  padding: 18px;
}

.field label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
}

.field small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.field input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #fbfcf8;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease;
}

button:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

button.secondary {
  background: var(--blue);
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
  transform: none;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
  gap: 16px;
  margin-top: 16px;
}

.candidate-area,
.inspector,
.backtest-panel {
  padding: 20px;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

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

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

.candidate {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 68px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
  transition: border-color 160ms ease, transform 160ms ease;
}

.candidate:hover {
  border-color: rgba(198, 32, 47, 0.5);
  transform: translateX(2px);
}

.rank {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: #fff;
  background: var(--ink);
  font-weight: 800;
}

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

.ball {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: #fff;
  background: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

.ball.back {
  background: var(--blue);
}

.candidate small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.score {
  color: var(--green);
  font-weight: 800;
}

canvas {
  width: 100%;
  height: auto;
  margin-top: 16px;
  border-radius: 8px;
  background: #f8faf4;
}

.signal-list {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.signal-list p {
  line-height: 1.5;
}

.backtest-panel {
  margin-top: 16px;
}

.backtest-grid {
  margin-top: 16px;
}

.dist {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.dist span {
  padding: 6px 10px;
  border-radius: 8px;
  background: #eef2e9;
  color: var(--muted);
  font-size: 13px;
}

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

  .summary-panel,
  .guide-panel,
  .main-grid,
  .control-panel {
    grid-template-columns: 1fr;
  }

  .guide-steps {
    grid-template-columns: 1fr;
  }

  .metrics,
  .backtest-grid {
    grid-template-columns: 1fr;
  }

  .candidate {
    grid-template-columns: 36px minmax(0, 1fr);
  }

  .score {
    grid-column: 2;
  }
}
