:root {
  color-scheme: dark;
  --bg: #020402;
  --panel: rgba(1, 20, 10, 0.86);
  --line: rgba(116, 255, 164, 0.42);
  --text: #caffd6;
  --muted: #7ac790;
  --hot: #ffea7a;
  --danger: #ff6f6f;
  --cyan: #8dfcff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(rgba(120, 255, 150, 0.045) 50%, rgba(0, 0, 0, 0.12) 50%) 0 0 / 100% 4px,
    radial-gradient(circle at 50% 30%, rgba(58, 159, 73, 0.18), transparent 46%),
    #020402;
  color: var(--text);
  font-family: "Courier New", Courier, monospace;
  letter-spacing: 0;
  text-shadow: 0 0 8px rgba(115, 255, 143, 0.75);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 120px rgba(0, 0, 0, 0.9);
}

.shell {
  width: min(2560px, 100%);
  margin: 0 auto;
  padding: 18px clamp(14px, 1.1vw, 32px);
}

.topbar,
footer,
.panel {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 0 24px rgba(51, 255, 96, 0.13), inset 0 0 22px rgba(51, 255, 96, 0.08);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  min-height: 96px;
  padding: 18px 22px;
}

.eyebrow,
.panel-title {
  margin: 0 0 8px;
  color: var(--hot);
  font-size: 0.82rem;
}

h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 4.4rem);
  line-height: 0.96;
  font-weight: 700;
}

.status {
  display: grid;
  gap: 8px;
  min-width: 230px;
  text-align: right;
}

.status span,
.kpi,
.signal {
  border: 1px solid rgba(116, 255, 164, 0.3);
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.22);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.95fr) repeat(4, minmax(300px, 1fr));
  grid-auto-flow: dense;
  gap: 14px;
  margin-top: 14px;
  align-items: start;
}

.panel {
  min-width: 0;
  padding: 14px;
  border-radius: 4px;
}

.wide {
  grid-column: span 3;
}

.chart-panel svg {
  width: 100%;
  height: 330px;
  display: block;
}

.command {
  grid-row: span 2;
}

.command svg {
  width: 100%;
  height: 172px;
  display: block;
  margin: 0 0 14px;
}

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

.kpi strong {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  min-height: 1rem;
}

.kpi span {
  display: block;
  margin-top: 8px;
  color: var(--text);
  font-size: clamp(1.05rem, 1.8vw, 1.65rem);
  white-space: nowrap;
}

.strategy {
  grid-column: span 3;
}

.auto-trade {
  margin-top: 14px;
}

.auto-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(520px, 2.2fr) minmax(360px, 1fr);
  gap: 12px;
  align-items: stretch;
}

.switch-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 48px;
  border: 1px solid rgba(116, 255, 164, 0.3);
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.24);
  cursor: pointer;
}

.switch-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch {
  width: 46px;
  height: 24px;
  border: 1px solid rgba(116, 255, 164, 0.52);
  background: rgba(255, 111, 111, 0.16);
  box-shadow: inset 0 0 10px rgba(255, 111, 111, 0.18);
}

.switch::after {
  content: "";
  display: block;
  width: 18px;
  height: 18px;
  margin: 2px;
  background: var(--danger);
  box-shadow: 0 0 10px rgba(255, 111, 111, 0.75);
  transition: transform 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.switch-row input:checked + .switch {
  background: rgba(116, 255, 164, 0.16);
}

.switch-row input:checked + .switch::after {
  transform: translateX(22px);
  background: var(--text);
  box-shadow: 0 0 12px rgba(116, 255, 164, 0.95);
}

.switch-row b,
.trade-limits b {
  display: block;
  color: var(--cyan);
  font-size: 0.82rem;
}

.switch-row small,
.trade-limits span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.25;
}

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

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

.trade-limits div {
  min-height: 58px;
  border: 1px solid rgba(116, 255, 164, 0.26);
  padding: 8px;
  background: rgba(0, 0, 0, 0.2);
}

.playback-panel {
  margin-top: 14px;
}

.playback-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(540px, 2.2fr) minmax(360px, 0.9fr);
  gap: 12px;
  align-items: stretch;
}

.timeline-wrap {
  border: 1px solid rgba(116, 255, 164, 0.3);
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.22);
}

.timeline-meta {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.8rem;
}

.timeline-meta strong {
  color: var(--hot);
  font-size: clamp(0.95rem, 1vw, 1.25rem);
  white-space: nowrap;
}

.timeline-meta span:last-child {
  text-align: right;
}

#scenario-timeline {
  width: 100%;
  accent-color: var(--text);
}

.playback-actions {
  display: grid;
  grid-template-columns: minmax(80px, 0.75fr) minmax(90px, 0.85fr) minmax(130px, 1.1fr);
  gap: 8px;
}

.playback-actions button,
.playback-actions select {
  width: 100%;
  min-height: 58px;
  border: 1px solid rgba(116, 255, 164, 0.34);
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  font: inherit;
  text-shadow: inherit;
}

.playback-actions button {
  cursor: pointer;
}

.playback-actions label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.72rem;
}

.performance-row {
  display: grid;
  grid-template-columns: minmax(360px, 0.78fr) minmax(520px, 0.92fr) minmax(640px, 1.3fr);
  gap: 14px;
  margin-top: 14px;
}

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

.scenario-card {
  min-height: 74px;
  border: 1px solid rgba(116, 255, 164, 0.26);
  padding: 10px;
  background: rgba(0, 0, 0, 0.22);
}

.scenario-card strong {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.scenario-card span {
  display: block;
  margin-top: 9px;
  color: var(--text);
  font-size: clamp(0.95rem, 1vw, 1.34rem);
  white-space: nowrap;
}

.scenario-card small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.75rem;
}

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

.pnl-panel svg {
  width: 100%;
  height: 128px;
  display: block;
  margin: 0 0 10px;
}

.pnl-card {
  min-height: 78px;
  border: 1px solid rgba(116, 255, 164, 0.26);
  padding: 10px;
  background: rgba(0, 0, 0, 0.22);
}

.pnl-card strong {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.pnl-card span {
  display: block;
  margin-top: 10px;
  font-size: clamp(1rem, 1.1vw, 1.42rem);
}

.pnl-card small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.25;
}

.pnl-card.positive span,
.trade-side.buy {
  color: var(--text);
}

.pnl-card.negative span,
.trade-side.sell {
  color: var(--danger);
}

.trade-log {
  display: grid;
  gap: 7px;
  max-height: 278px;
  overflow: auto;
  padding-right: 4px;
}

.trade-row {
  display: grid;
  grid-template-columns: 96px 70px minmax(90px, 1fr) 92px 76px minmax(180px, 1.8fr);
  gap: 8px;
  align-items: center;
  min-height: 38px;
  border: 1px solid rgba(116, 255, 164, 0.22);
  padding: 7px 9px;
  background: rgba(0, 0, 0, 0.2);
}

.trade-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trade-side {
  color: var(--cyan);
  font-weight: 700;
}

.signal {
  margin-bottom: 10px;
}

.signal b {
  color: var(--cyan);
}

.intel ul {
  margin: 0;
  padding-left: 18px;
}

.intel li {
  margin-bottom: 12px;
}

.news-panel {
  margin-top: 14px;
}

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

.news-card {
  min-height: 122px;
  border: 1px solid rgba(116, 255, 164, 0.27);
  padding: 12px;
  background: rgba(0, 0, 0, 0.24);
}

.news-card a {
  color: var(--text);
  text-decoration: none;
}

.news-card a:hover {
  color: var(--hot);
}

.news-card small {
  display: block;
  margin-top: 10px;
  color: var(--muted);
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 14px;
  padding: 10px 14px;
  color: var(--muted);
  font-size: 0.8rem;
}

.axis path,
.axis line,
.grid line {
  stroke: rgba(116, 255, 164, 0.25);
}

.axis text {
  fill: var(--muted);
  font-family: "Courier New", Courier, monospace;
}

@media (max-width: 1100px) {
  .dashboard-grid,
  .news-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .wide,
  .strategy {
    grid-column: span 2;
  }

  .auto-layout,
  .playback-layout,
  .performance-row {
    grid-template-columns: 1fr;
  }

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

@media (min-width: 1101px) and (max-width: 1700px) {
  .shell {
    width: 100%;
  }

  .dashboard-grid {
    grid-template-columns: minmax(320px, 0.9fr) minmax(300px, 1.2fr) minmax(300px, 1fr);
  }

  .wide,
  .strategy {
    grid-column: span 2;
  }

  .auto-layout {
    grid-template-columns: 1fr;
  }

  .playback-layout {
    grid-template-columns: 1fr;
  }

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

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

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

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

@media (max-width: 720px) {
  .shell {
    padding: 10px;
  }

  .topbar,
  footer {
    display: block;
  }

  .status {
    margin-top: 14px;
    text-align: left;
  }

  .dashboard-grid,
  .news-grid,
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .wide,
  .strategy {
    grid-column: auto;
  }

  .chart-panel svg {
    height: 260px;
  }

  .trade-limits {
    grid-template-columns: 1fr;
  }

  .playback-actions {
    grid-template-columns: 1fr;
  }

  .strategy-toggles,
  .pnl-grid,
  .scenario-grid {
    grid-template-columns: 1fr;
  }

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

@media (min-width: 1900px) {
  .topbar {
    min-height: 118px;
  }

  .dashboard-grid {
    gap: 18px;
  }

  .panel {
    padding: 16px;
  }

  .chart-panel svg {
    height: 410px;
  }

  .command svg {
    height: 230px;
  }

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

  .auto-layout {
    grid-template-columns: minmax(260px, 0.75fr) minmax(700px, 2.2fr) minmax(420px, 0.95fr);
  }

  .playback-layout {
    grid-template-columns: minmax(260px, 0.7fr) minmax(900px, 2.4fr) minmax(420px, 0.9fr);
  }

  .news-card {
    min-height: 148px;
  }
}
