:root {
  --bg: #f1eadf;
  --ink: #171412;
  --muted: #6d625a;
  --paper: rgba(255, 251, 245, 0.82);
  --line: rgba(23, 20, 18, 0.1);
  --shadow: rgba(58, 37, 20, 0.14);
  --amber: #d76f2d;
  --olive: #2f5c42;
  --rose: #a63c3c;
  --steel: #385262;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(215, 111, 45, 0.16), transparent 30%),
    radial-gradient(circle at bottom right, rgba(56, 82, 98, 0.14), transparent 28%),
    var(--bg);
}

.backdrop {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(23, 20, 18, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 20, 18, 0.03) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(circle at center, black 55%, transparent 100%);
  pointer-events: none;
}

.shell {
  width: min(1280px, calc(100vw - 24px));
  margin: 0 auto;
  padding: 18px 0 40px;
}

.panel {
  position: relative;
  border: 1px solid var(--line);
  background: var(--paper);
  backdrop-filter: blur(12px);
  box-shadow: 0 12px 40px var(--shadow);
  overflow: hidden;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.42), transparent 36%);
  pointer-events: none;
}

.hero {
  display: grid;
  grid-template-columns: 1.7fr 0.9fr;
  gap: clamp(20px, 4vw, 48px);
  padding: clamp(22px, 4vw, 40px);
  border-radius: 28px;
  animation: rise 720ms cubic-bezier(.2,.8,.2,1) both;
}

.eyebrow,
.section-kicker,
.meta-label {
  display: inline-block;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.hero h1,
.section-head h2 {
  font-family: "Space Grotesk", sans-serif;
  letter-spacing: -0.04em;
  margin: 10px 0 0;
}

.hero h1 {
  font-size: clamp(34px, 7vw, 72px);
  line-height: 0.96;
  max-width: 10ch;
}

.hero-text {
  max-width: 56ch;
  font-size: clamp(15px, 2vw, 18px);
  line-height: 1.7;
  color: #3c332f;
}

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

.mode-pill,
.heartbeat {
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.6);
}

.mode-pill {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.heartbeat {
  display: inline-flex;
  gap: 10px;
  align-items: center;
}

.heartbeat-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 0 rgba(47, 92, 66, 0.4);
  animation: pulse 2s infinite;
}

.overview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.metric {
  border-radius: 24px;
  padding: 20px;
  min-height: 150px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.metric-primary {
  background: linear-gradient(140deg, rgba(215, 111, 45, 0.16), rgba(255, 255, 255, 0.78));
}

.metric-label {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.metric-value {
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(30px, 4vw, 48px);
  letter-spacing: -0.06em;
  margin-top: 14px;
}

.metric-sub {
  margin-top: 8px;
  color: #443a34;
}

.main-grid {
  display: grid;
  grid-template-columns: 1.35fr 0.92fr;
  gap: 14px;
  margin-top: 16px;
}

.window-panel,
.gates-panel,
.chart-panel,
.tape-panel {
  border-radius: 26px;
  padding: 24px;
}

.window-panel {
  min-height: 340px;
}

.chart-panel {
  min-height: 300px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.window-meta,
.signal-grid,
.gate-list,
.chart-legend {
  display: grid;
  gap: 12px;
}

.window-meta {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 22px;
}

.window-meta strong,
.signal-card strong {
  display: block;
  margin-top: 10px;
  font-size: 20px;
}

.progress-wrap {
  margin-top: 22px;
}

.progress-rail {
  height: 16px;
  border-radius: 999px;
  background: rgba(23, 20, 18, 0.08);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--amber), #eab77d);
  transition: width 500ms ease;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  color: var(--muted);
}

.signal-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 18px;
}

.signal-card,
.gate-row {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.48);
  padding: 16px;
}

.gate-list {
  margin-top: 18px;
}

.gate-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.gate-row strong {
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.chart-wrap {
  margin-top: 20px;
  height: 220px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255,255,255,0.75), rgba(255,255,255,0.2));
  border: 1px solid var(--line);
  padding: 14px;
}

#equityChart {
  width: 100%;
  height: 100%;
}

#equityPath {
  fill: none;
  stroke: var(--steel);
  stroke-width: 1.8;
  vector-effect: non-scaling-stroke;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-legend {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 14px;
  color: var(--muted);
}

.tape {
  display: grid;
  gap: 10px;
  margin-top: 18px;
  max-height: 620px;
  overflow: auto;
  padding-right: 6px;
}

.tape-item {
  display: grid;
  gap: 4px;
  border-left: 3px solid var(--line);
  padding: 10px 0 10px 14px;
}

.tape-item strong {
  font-size: 14px;
}

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

.mode-live {
  background: rgba(166, 60, 60, 0.13);
  color: #7e2c2c;
}

.mode-shadow,
.mode-dry_run {
  background: rgba(215, 111, 45, 0.14);
  color: #8a4f23;
}

.status-running .heartbeat-dot {
  background: var(--olive);
}

.status-degraded .heartbeat-dot {
  background: var(--amber);
}

.status-halted .heartbeat-dot,
.status-crashed .heartbeat-dot {
  background: var(--rose);
  animation: none;
}

.is-pass {
  color: var(--olive);
}

.is-fail {
  color: var(--rose);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(47, 92, 66, 0.42);
  }
  70% {
    box-shadow: 0 0 0 14px rgba(47, 92, 66, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(47, 92, 66, 0);
  }
}

@media (max-width: 980px) {
  .hero,
  .main-grid,
  .overview {
    grid-template-columns: 1fr;
  }

  .window-meta,
  .chart-legend {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100vw - 16px, 1280px);
    padding-top: 8px;
  }

  .hero,
  .window-panel,
  .gates-panel,
  .chart-panel,
  .tape-panel {
    border-radius: 22px;
    padding: 18px;
  }

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