:root {
  --bg: #020704;
  --panel: rgba(5, 24, 10, 0.94);
  --panel-2: rgba(8, 32, 14, 0.86);
  --line: rgba(94, 202, 93, 0.52);
  --line-soft: rgba(94, 202, 93, 0.22);
  --text: #d8ffd0;
  --muted: #78ad78;
  --green: #a4ff9d;
  --amber: #ffd865;
  --red: #ff7474;
  --blue: #72b7ff;
  --mono: "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  min-height: 100%;
  margin: 0;
}

body {
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 22% 0%, rgba(76, 201, 86, 0.13), transparent 28rem),
    linear-gradient(180deg, #020704 0%, #03110a 52%, #020704 100%);
  font-family: var(--mono);
  letter-spacing: 0;
}

body::before {
  position: fixed;
  inset: 0;
  pointer-events: none;
  content: "";
  background-image: repeating-linear-gradient(to bottom, rgba(255,255,255,.035) 0, rgba(255,255,255,.035) 1px, transparent 1px, transparent 5px);
  opacity: .32;
}

.app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding: 10px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 54px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(6, 26, 11, .96), rgba(3, 13, 6, .94));
  box-shadow: 0 0 22px rgba(83, 255, 101, .12);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
}

.logo {
  display: grid;
  grid-template-columns: repeat(3, 8px);
  grid-template-rows: repeat(3, 8px);
  gap: 3px;
  width: 34px;
  height: 34px;
  padding: 4px;
  border: 1px solid rgba(164,255,157,.46);
}

.logo span {
  display: block;
  background: var(--green);
  box-shadow: 0 0 10px rgba(164,255,157,.74);
}

h1, h2, p { margin: 0; }

h1 {
  overflow: hidden;
  color: var(--green);
  font-size: clamp(20px, 2.9vw, 28px);
  line-height: 1;
  white-space: nowrap;
  text-overflow: ellipsis;
}

small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.status-line,
.kpis {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: nowrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 7px;
  border: 1px solid var(--line);
  background: rgba(9, 35, 15, .78);
  color: var(--green);
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
  white-space: nowrap;
}

.pill.wait { color: var(--amber); border-color: rgba(255,216,101,.72); }
.pill.bad { color: var(--red); border-color: rgba(255,116,116,.72); }
.pill.info { color: var(--blue); border-color: rgba(114,183,255,.72); }

.check-icon {
  width: 13px;
  height: 13px;
  margin-left: 5px;
  color: currentColor;
  stroke-width: 3;
  flex: 0 0 auto;
}

.content {
  display: grid;
  gap: 12px;
  max-width: 1380px;
  margin: 12px auto 0;
}

.kpis {
  overflow: hidden;
}

.view-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
}

.view-tabs button {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 7px;
  align-items: center;
  min-width: 0;
  min-height: 38px;
  padding: 7px 8px;
  border: 1px solid rgba(94, 202, 93, .28);
  background: rgba(4, 16, 8, .84);
  color: var(--muted);
  font: 900 11px/1.1 var(--mono);
  text-align: left;
  text-transform: uppercase;
  cursor: pointer;
}

.tab-index {
  color: var(--green);
  font-size: 9px;
}

.tab-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.view-tabs button.active {
  border-color: var(--line);
  background: rgba(10, 43, 18, .92);
  color: var(--green);
  box-shadow: inset 0 -2px 0 rgba(164, 255, 157, .75);
}

.kpis article {
  flex: 1 1 0;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line-soft);
  background: rgba(4, 16, 8, .88);
}

.kpis span,
.panel-head span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.kpis strong {
  display: block;
  overflow: hidden;
  margin-top: 6px;
  color: var(--green);
  font-size: clamp(13px, 2.7vw, 20px);
  line-height: 1;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.kpis strong.ok {
  color: var(--green);
}

.kpis strong.bad {
  color: var(--red);
}

.kpis strong.wait {
  color: var(--amber);
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, .8fr);
  gap: 10px;
  align-items: start;
}

.overview-paper-board {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, .55fr);
  gap: 10px;
  margin-top: 10px;
}

.panel {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line-soft);
  background: var(--panel);
}

.wide {
  grid-column: 1 / -1;
}

.runtime-panel {
  order: -2;
}

.brain-panel {
  order: -1;
}

.brain-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.brain-summary div {
  min-width: 0;
  padding: 8px 0;
  border-bottom: 1px solid var(--line-soft);
}

.brain-summary span,
.brain-block h3 {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.brain-summary strong {
  display: block;
  overflow: hidden;
  margin-top: 5px;
  color: var(--blue);
  font-size: 13px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brain-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
  align-items: start;
}

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

.runtime-summary div {
  min-width: 0;
  padding: 7px;
  border: 1px solid rgba(94, 202, 93, .18);
  background: rgba(0, 0, 0, .22);
}

.runtime-summary span,
.section-head span {
  display: block;
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
}

.runtime-summary strong {
  display: block;
  overflow: hidden;
  margin-top: 4px;
  color: var(--green);
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.runtime-window {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  margin-top: 6px;
}

.window-kv {
  min-width: 0;
  padding: 6px 7px;
  border: 1px solid rgba(94, 202, 93, .16);
  background: rgba(0, 0, 0, .16);
}

.window-kv span {
  display: block;
  color: var(--muted);
  font-size: 8px;
  font-weight: 900;
  text-transform: uppercase;
}

.window-kv strong {
  display: block;
  overflow: hidden;
  margin-top: 3px;
  color: var(--text);
  font-size: 9px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.runtime-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, .65fr);
  gap: 12px;
  margin-top: 12px;
  align-items: start;
}

.runtime-chart-block,
.runtime-side {
  min-width: 0;
}

.runtime-side {
  display: grid;
  gap: 8px;
}

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

.section-head h3 {
  margin: 0;
  color: var(--green);
  font-size: 12px;
  text-transform: uppercase;
}

.chart-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  gap: 8px;
  align-items: stretch;
  margin-top: 8px;
}

.chart-wrap {
  width: 100%;
  height: 315px;
  border: 1px solid rgba(94, 202, 93, .18);
  background:
    linear-gradient(90deg, rgba(164, 255, 157, .06) 1px, transparent 1px),
    linear-gradient(180deg, rgba(164, 255, 157, .06) 1px, transparent 1px),
    rgba(0, 0, 0, .26);
  background-size: 20% 100%, 100% 25%;
}

.chart-legend {
  display: grid;
  align-content: start;
  gap: 7px;
  min-width: 0;
  padding: 8px;
  border: 1px solid rgba(94, 202, 93, .22);
  background: rgba(3, 13, 6, .72);
}

.legend-item {
  display: grid;
  grid-template-columns: 11px minmax(0, 1fr);
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  line-height: 1.35;
  text-transform: uppercase;
}

.legend-item strong {
  display: block;
  color: var(--text);
  font-size: 10px;
  line-height: 1.2;
}

.legend-item .blue { color: var(--blue); }
.legend-item .green { color: var(--green); }
.legend-item .amber { color: var(--amber); }
.legend-item .white { color: #fff; }

.legend-item > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.swatch {
  display: inline-block;
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  margin-top: 2px;
  border: 1px solid currentColor;
  box-shadow: 0 0 10px currentColor;
}

.swatch.blue { background: var(--blue); color: var(--blue); }
.swatch.green { background: var(--green); color: var(--green); }
.swatch.amber { background: var(--amber); color: var(--amber); }
.swatch.trade { background: #fff; color: #fff; transform: rotate(45deg); }

#runtime-chart {
  display: block;
  width: 100%;
  height: 100%;
}

.brain-block {
  min-width: 0;
}

.brain-block h3 {
  color: var(--green);
}

.compact-list {
  display: grid;
  gap: 5px;
  margin-top: 6px;
}

.compact-row,
.empty {
  min-width: 0;
  padding-top: 6px;
  border-top: 1px solid rgba(94, 202, 93, .18);
}

.compact-row strong,
.compact-row span,
.empty {
  overflow-wrap: anywhere;
}

.compact-row strong {
  display: block;
  color: var(--text);
  font-size: 10px;
  line-height: 1.25;
}

.compact-row span,
.empty {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.35;
}

.recommendation-action-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid rgba(94, 202, 93, .16);
  background: rgba(3, 13, 6, .62);
}

.recommendation-action-row strong,
.recommendation-action-row span {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.recommendation-action-row strong {
  color: var(--text);
  font-size: 10px;
}

.recommendation-action-row span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 8px;
}

.recommendation-action-row div:last-child {
  display: flex;
  gap: 5px;
}

.recommendation-action-row button {
  min-height: 24px;
  padding: 0 6px;
  border: 1px solid var(--line-soft);
  background: rgba(3, 13, 6, .78);
  color: var(--green);
  font: 900 8px/1 var(--mono);
  text-transform: uppercase;
  cursor: pointer;
}

.panel-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line-soft);
}

h2 {
  color: var(--green);
  font-size: 14px;
  text-transform: uppercase;
}

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

.health-current-state {
  display: grid;
  gap: 5px;
  margin: 5px 0 10px;
  padding-left: 8px;
  border-left: 1px solid rgba(94, 202, 93, .24);
}

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

.overview-strategy-card {
  display: grid;
  gap: 7px;
  min-width: 0;
  padding: 8px;
  border: 1px solid rgba(94, 202, 93, .2);
  background: rgba(0, 0, 0, .18);
}

.overview-strategy-card.ok {
  border-color: rgba(164, 255, 157, .45);
}

.overview-strategy-card.bad {
  border-color: rgba(255, 116, 116, .45);
}

.overview-strategy-card.wait {
  border-color: rgba(255, 216, 101, .36);
}

.overview-strategy-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: start;
  min-width: 0;
}

.overview-strategy-head strong,
.overview-strategy-head span,
.overview-strategy-card p,
.overview-strategy-card small {
  overflow: hidden;
  text-overflow: ellipsis;
}

.overview-strategy-head strong {
  display: block;
  color: var(--text);
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
}

.overview-strategy-head span,
.overview-strategy-card p,
.overview-strategy-card small {
  display: block;
  color: var(--muted);
  line-height: 1.35;
}

.overview-strategy-head span {
  margin-top: 2px;
  font-size: 8px;
  white-space: nowrap;
}

.overview-strategy-card small {
  color: var(--amber);
  font-size: 8px;
  line-height: 1.25;
}

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

.overview-strategy-metrics div {
  min-width: 0;
  padding: 5px;
  border: 1px solid rgba(94, 202, 93, .16);
  background: rgba(3, 13, 6, .62);
}

.overview-strategy-metrics span {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 6.8px;
  font-weight: 900;
  text-transform: uppercase;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.overview-strategy-metrics strong {
  display: block;
  overflow: hidden;
  margin-top: 3px;
  color: var(--text);
  font-size: 9px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.overview-strategy-metrics strong.ok {
  color: var(--green);
}

.overview-strategy-metrics strong.bad {
  color: var(--red);
}

.overview-strategy-metrics strong.wait {
  color: var(--amber);
}

.decision-comparison {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  padding: 5px;
  border: 1px solid rgba(94, 202, 93, .16);
  background: rgba(3, 13, 6, .68);
}

.decision-comparison.ok {
  border-color: rgba(164, 255, 157, .38);
}

.decision-comparison.wait {
  border-color: rgba(255, 216, 101, .34);
}

.decision-comparison.bad {
  border-color: rgba(255, 116, 116, .38);
}

.decision-comparison div {
  min-width: 0;
}

.decision-comparison span,
.decision-comparison strong {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.decision-comparison span {
  color: var(--muted);
  font-size: 6.8px;
  font-weight: 900;
  text-transform: uppercase;
}

.decision-comparison strong {
  margin-top: 3px;
  color: var(--text);
  font-size: 8px;
}

.decision-board {
  display: grid;
  gap: 6px;
}

.decision-board-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-width: 0;
  padding: 7px;
  border: 1px solid rgba(94, 202, 93, .18);
  background: rgba(3, 13, 6, .62);
}

.decision-board-row.ok {
  border-color: rgba(164, 255, 157, .38);
}

.decision-board-row.wait {
  border-color: rgba(255, 216, 101, .34);
}

.decision-board-row.bad {
  border-color: rgba(255, 116, 116, .38);
}

.decision-board-row strong,
.decision-board-row span {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.decision-board-row strong {
  color: var(--text);
  font-size: 10px;
}

.decision-board-row span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 8px;
}

.decision-board-row button {
  min-height: 26px;
  padding: 0 7px;
  border: 1px solid var(--line-soft);
  background: rgba(3, 13, 6, .78);
  color: var(--green);
  font: 900 9px/1 var(--mono);
  text-transform: uppercase;
  cursor: pointer;
}

.exec-runtime-strip {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  min-width: 0;
  padding: 5px 6px;
  border: 1px solid rgba(94, 202, 93, .16);
  background: rgba(3, 13, 6, .72);
}

.exec-runtime-strip.ok {
  border-color: rgba(164, 255, 157, .38);
}

.exec-runtime-strip.wait {
  border-color: rgba(255, 216, 101, .34);
}

.exec-runtime-strip.bad {
  border-color: rgba(255, 116, 116, .38);
}

.exec-runtime-strip strong,
.exec-runtime-strip span {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.exec-runtime-strip strong {
  color: var(--green);
  font-size: 7px;
  font-weight: 900;
  text-transform: uppercase;
}

.exec-runtime-strip span {
  color: var(--muted);
  font-size: 8px;
  line-height: 1.25;
}

.paper-trade-list {
  max-height: 198px;
  overflow: auto;
  padding-right: 2px;
}

.paper-trade-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  min-width: 0;
  padding-top: 6px;
  border-top: 1px solid rgba(94, 202, 93, .18);
}

.strategy-snapshot-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  min-width: 0;
  padding-top: 6px;
  border-top: 1px solid rgba(94, 202, 93, .18);
}

.strategy-snapshot-row.ok {
  border-top-color: rgba(164, 255, 157, .34);
}

.strategy-snapshot-row.bad {
  border-top-color: rgba(255, 116, 116, .34);
}

.strategy-snapshot-row.wait {
  border-top-color: rgba(255, 216, 101, .28);
}

.strategy-snapshot-row strong,
.strategy-snapshot-row span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.strategy-snapshot-row strong {
  color: var(--text);
  font-size: 10px;
  line-height: 1.25;
  white-space: nowrap;
}

.strategy-snapshot-row span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.3;
  white-space: nowrap;
}

.paper-trade-row strong,
.paper-trade-row span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.paper-trade-row strong {
  color: var(--text);
  font-size: 10px;
  line-height: 1.25;
  white-space: nowrap;
}

.paper-trade-row span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.3;
  white-space: nowrap;
}

.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 11px;
  border: 1px solid rgba(94, 202, 93, .18);
  background: var(--panel-2);
}

.row strong,
.row span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.row strong {
  display: block;
  color: var(--text);
  font-size: 13px;
}

.row span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.strategy-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 11px;
  border: 1px solid rgba(94, 202, 93, .18);
  background: var(--panel-2);
}

.strategy-main {
  min-width: 0;
}

.strategy-main strong,
.strategy-main span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.strategy-main strong {
  color: var(--text);
  font-size: 13px;
}

.strategy-main span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.strategy-actions {
  display: flex;
  gap: 6px;
}

.strategy-actions button {
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line-soft);
  background: rgba(3, 13, 6, .72);
  color: var(--green);
  font: 900 10px/1 var(--mono);
  text-transform: uppercase;
  cursor: pointer;
}

.strategy-actions button:disabled {
  color: var(--muted);
  cursor: wait;
}

.strategy-explanation,
.strategy-results {
  grid-column: 1 / -1;
  min-width: 0;
}

.strategy-explanation {
  display: grid;
  gap: 4px;
  padding-top: 2px;
}

.strategy-explanation p,
.strategy-explanation span {
  margin: 0;
  overflow-wrap: anywhere;
}

.strategy-explanation p {
  color: var(--text);
  font-size: 12px;
  line-height: 1.35;
}

.strategy-explanation span {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

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

.strategy-result-block {
  min-width: 0;
  padding: 9px;
  border: 1px solid rgba(94, 202, 93, .2);
  background: rgba(0, 0, 0, .18);
}

.strategy-result-block.bad {
  border-color: rgba(255, 116, 116, .38);
}

.strategy-result-block.wait {
  border-color: rgba(255, 216, 101, .34);
}

.strategy-result-head {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.strategy-result-head strong {
  overflow: hidden;
  color: var(--green);
  font-size: 11px;
  text-transform: uppercase;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.strategy-result-block p {
  display: block;
  overflow: hidden;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.25;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.strategy-result-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}

.strategy-result-metrics div {
  min-width: 0;
}

.strategy-result-metrics span {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 8px;
  font-weight: 900;
  text-transform: uppercase;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.strategy-result-metrics strong {
  display: block;
  overflow: hidden;
  margin-top: 3px;
  color: var(--text);
  font-size: 10px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

pre {
  overflow: auto;
  max-height: 230px;
  margin: 12px 0 0;
  padding: 12px;
  border: 1px solid rgba(94, 202, 93, .18);
  background: rgba(0, 0, 0, .35);
  color: var(--text);
  font: 12px/1.45 var(--mono);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

@media (max-width: 720px) {
  .app { padding: 8px; }
  .topbar {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .status-line { gap: 4px; }
  .status-line .pill {
    flex: 1 1 0;
    min-width: 0;
    padding: 0 4px;
    overflow: hidden;
    font-size: 9px;
    text-overflow: ellipsis;
  }
  .kpis { gap: 5px; }
  .kpis article { padding: 8px 5px; }
  .kpis span { font-size: 8px; }
  .kpis strong { font-size: 11px; }
  .brain-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .brain-summary span { font-size: 8px; }
  .brain-summary strong { font-size: 10px; }
  .brain-grid { grid-template-columns: 1fr; }
  .view-tabs { gap: 4px; }
  .view-tabs button {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    gap: 1px;
    justify-items: center;
    min-height: 34px;
    padding: 5px 4px;
    font-size: 8px;
    text-align: center;
  }
  .tab-index { font-size: 7px; }
  .tab-label { max-width: 100%; }
  .runtime-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
  .runtime-summary div { padding: 7px 5px; }
  .runtime-summary span { font-size: 8px; }
  .runtime-summary strong { font-size: 11px; }
  .runtime-window { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; }
  .window-kv { padding: 7px 5px; }
  .window-kv span { font-size: 7px; }
  .window-kv strong { font-size: 9px; }
  .runtime-layout { grid-template-columns: 1fr; }
  .chart-shell { grid-template-columns: 1fr; gap: 6px; }
  .chart-wrap { height: 245px; }
  .chart-legend { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; padding: 7px; }
  .legend-item { gap: 5px; font-size: 8px; }
  .legend-item strong { font-size: 9px; }
  .grid { grid-template-columns: 1fr; }
}

@media (min-width: 721px) and (max-width: 1120px) {
  .brain-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .runtime-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .runtime-window { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .runtime-layout { grid-template-columns: 1fr; }
  .chart-shell { grid-template-columns: 1fr; }
  .chart-legend { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Maquette POLY REPORT V1 shell */
.app {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
  padding: 12px;
}

.topbar {
  min-height: 58px;
  padding: 9px 18px;
}

.topbar .brand {
  gap: 18px;
}

.top-status {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.side-health-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
}

.side-health-strip span {
  min-width: 0;
  padding: 5px 3px;
  border: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 8px;
  font-weight: 900;
  line-height: 1.25;
  text-align: center;
  text-transform: uppercase;
}

.side-health-strip strong {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 8px;
}

.side-health-strip strong.ok {
  color: var(--green);
}

.side-health-strip strong.wait {
  color: var(--amber);
}

.side-health-strip strong.bad {
  color: var(--red);
}

.shell {
  display: grid;
  grid-template-columns: 186px minmax(0, 1fr);
  gap: 10px;
  min-height: 0;
  margin-top: 6px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: calc(100vh - 86px);
  padding: 9px;
  border: 1px solid var(--line-soft);
  background: rgba(4, 16, 8, .88);
}

.side-title {
  color: #426c43;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.side-block {
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
}

.side-status-block {
  display: grid;
  gap: 7px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
}

.side-refresh {
  margin-top: 0;
}

.mini-kv {
  display: grid;
  gap: 6px;
  margin-top: 8px;
  font-size: 10px;
}

.mini-kv div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
}

.mini-kv strong {
  color: var(--green);
  font-weight: 900;
  text-align: right;
}

main {
  min-width: 0;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.nav.view-tabs {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.nav.view-tabs button {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  min-height: 38px;
  padding: 0 8px 0 0;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font: 900 10px/1.1 var(--mono);
  text-align: left;
  text-transform: uppercase;
}

.nav.view-tabs button:hover,
.nav.view-tabs button.active {
  border-color: var(--line);
  background: rgba(14, 50, 20, .66);
  color: var(--green);
  box-shadow: inset 0 0 18px rgba(164, 255, 157, .07);
}

.nav .icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  font-size: 10px;
}

.nav .label {
  font-size: 10px;
}

.screen-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.screen-head h2 {
  color: var(--green);
  font-size: clamp(18px, 1.55vw, 23px);
  font-weight: 900;
  text-shadow: 0 0 12px rgba(164, 255, 157, .24);
}

.screen-head p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.screen-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
}

.action-button {
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(255, 216, 101, .55);
  background: rgba(45, 35, 8, .72);
  color: var(--amber);
  font: 900 10px/1 var(--mono);
  text-transform: uppercase;
  cursor: pointer;
}

.action-button:hover:not(:disabled) {
  border-color: var(--amber);
  box-shadow: inset 0 0 16px rgba(255, 216, 101, .12);
}

.action-button:disabled {
  cursor: wait;
  opacity: .58;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.metrics article,
.panel {
  background: linear-gradient(180deg, rgba(8, 30, 13, .88), rgba(3, 13, 6, .86));
  box-shadow: inset 0 0 28px rgba(72, 215, 86, .035);
}

.metrics article {
  min-height: 50px;
}

.overview-dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(318px, .38fr);
  gap: 10px;
  align-items: start;
  min-width: 0;
}

.overview-left-column,
.overview-right-column {
  display: grid;
  gap: 10px;
  align-items: start;
  min-width: 0;
}

.runtime-panel,
.brain-panel {
  order: initial;
}

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

.runtime-current-panel .runtime-window {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 8px;
}

.runtime-current-panel .runtime-side {
  margin-top: 8px;
}

.runtime-current-panel,
.paper-trades-panel,
.paper-strategy-panel {
  align-self: start;
}

.runtime-current-panel .compact-list {
  max-height: 120px;
  overflow: auto;
  padding-right: 2px;
}

.paper-strategy-panel {
  padding-bottom: 9px;
}

.chart-wrap {
  height: clamp(285px, 34vh, 340px);
  min-height: 0;
}

.chart-shell {
  grid-template-columns: minmax(0, 1fr) 150px;
  gap: 8px;
}

@media (max-width: 850px) {
  .app {
    gap: 10px;
    padding: 10px;
  }

  .topbar,
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    gap: 10px;
    min-height: 0;
    padding: 9px;
  }

  .sidebar > .side-block:last-child {
    display: none;
  }

  .side-block {
    padding-top: 0;
    border-top: 0;
  }

  .nav.view-tabs {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 5px;
  }

  .nav.view-tabs button {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    justify-items: start;
    min-height: 42px;
    padding: 5px;
    font-size: 8px;
  }

  .nav .icon {
    display: block;
    width: auto;
    height: auto;
    font-size: 8px;
  }

  .nav .label {
    max-width: 100%;
    font-size: 8px;
  }

  .screen-head {
    align-items: start;
    flex-direction: column;
  }

  .screen-actions {
    justify-content: flex-start;
    width: 100%;
  }

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

  .metrics article {
    min-height: 58px;
    padding: 7px 4px;
  }

  .metrics span {
    font-size: 7px;
  }

  .metrics strong {
    font-size: 10px;
  }

  .overview-dashboard {
    grid-template-columns: 1fr;
  }

  .overview-left-column,
  .overview-right-column {
    gap: 8px;
  }

  .overview-strategy-list {
    grid-template-columns: 1fr;
  }

  .strategy-card {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .strategy-results {
    grid-template-columns: 1fr;
  }

  .strategy-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .chart-shell {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .chart-wrap {
    height: 245px;
  }
}

@media (max-width: 520px) {
  .app {
    padding: 6px;
  }

  .topbar {
    gap: 6px;
    padding: 6px;
  }

  .topbar .brand {
    align-items: center;
    gap: 9px;
  }

  .logo {
    grid-template-columns: repeat(3, 6px);
    grid-template-rows: repeat(3, 6px);
    gap: 2px;
    width: 28px;
    height: 28px;
    padding: 4px;
    flex: 0 0 auto;
  }

  h1 {
    max-width: 100%;
    font-size: 17px;
    line-height: 1.05;
    white-space: nowrap;
  }

  small {
    display: none;
  }

  .top-status {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 3px;
    min-width: 0;
  }

  .pill {
    min-height: 22px;
    padding: 0 3px;
    font-size: 6.5px;
  }

  .action-button {
    min-height: 24px;
    padding: 0 7px;
    font-size: 8px;
  }

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

  .chart-wrap {
    height: 224px;
  }

  .screen-head {
    gap: 5px;
    margin-bottom: 6px;
  }

  .screen-head h2 {
    font-size: 17px;
  }

  .screen-head p {
    display: none;
  }

  .screen-head > .pill {
    display: none;
  }

  .metrics {
    gap: 3px;
  }

  .metrics article {
    min-height: 58px;
    padding: 6px 3px;
  }

  .metrics span {
    font-size: 6px;
  }

  .metrics strong {
    font-size: 8px;
    line-height: 1.15;
    white-space: normal;
    overflow-wrap: anywhere;
  }

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

  .paper-trade-list {
    max-height: none;
  }
}
