:root {
  --bg: #f3f6f8;
  --navbar: #070b11;
  --navbar-soft: #141b26;
  --brand-yellow: #ffd34f;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --ink: #172033;
  --muted: #667085;
  --faint: #98a2b3;
  --line: #d9e1ea;
  --line-strong: #b8c4d2;
  --green: #00856f;
  --red: #cf3f52;
  --amber: #b66d00;
  --blue: #2266d8;
  --violet: #7a59cc;
  --shadow: 0 18px 48px rgba(22, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
}

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #eef3f6;
}

.auth-shell {
  width: min(420px, calc(100vw - 32px));
}

.auth-panel,
.panel,
.kpi,
.section-band {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-panel {
  padding: 34px;
}

.auth-panel h1 {
  margin: 18px 0 24px;
  font-size: 26px;
  line-height: 1.15;
  font-weight: 760;
}

.brand-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: #111827;
  background: var(--brand-yellow);
  font-size: 12px;
  font-weight: 760;
}

.auth-panel .brand-mark {
  width: 42px;
  height: 42px;
}

.auth-form {
  display: grid;
  gap: 16px;
}

.auth-form label,
.config-row {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(34, 102, 216, 0.14);
}

.form-error {
  margin: 0;
  color: var(--red);
  font-weight: 780;
}

.primary-button,
.secondary-button,
.icon-button,
.range-selector button {
  border-radius: 7px;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.primary-button {
  padding: 10px 15px;
  color: #fff;
  background: var(--ink);
  font-weight: 700;
}

.secondary-button {
  padding: 9px 13px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  font-weight: 650;
}

.secondary-button.danger {
  color: var(--red);
  border-color: #f3bfca;
}

.icon-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  font-size: 18px;
}

.primary-button:hover,
.secondary-button:hover,
.icon-button:hover,
.range-selector button:hover {
  transform: translateY(-1px);
}

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

.app-navbar {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 58px;
  padding: 0 24px;
  color: #f8fafc;
  background: var(--navbar);
  border-bottom: 1px solid #1d2633;
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.brand strong {
  display: block;
  font-size: 15px;
  font-weight: 720;
  white-space: nowrap;
}

.brand small,
.navbar-user,
.navbar-user a,
.navbar-status small {
  color: #aeb8c7;
}

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

.nav a,
.navbar-user a,
.group-index a {
  text-decoration: none;
}

.nav a {
  display: flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 7px;
  color: #cbd5e1;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}

.nav a.active,
.nav a:hover {
  color: #fff;
  background: var(--navbar-soft);
}

.navbar-spacer {
  flex: 1 1 auto;
}

.mode-switch {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.mode-switch button {
  min-height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  color: #aeb8c7;
  background: transparent;
  font-size: 12px;
  font-weight: 720;
  cursor: pointer;
}

.mode-switch button.active {
  color: #111827;
  background: var(--brand-yellow);
}

.real-runner-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: #f8fafc;
  background: rgba(207, 63, 82, 0.16);
  font-size: 12px;
  font-weight: 760;
  cursor: pointer;
  white-space: nowrap;
}

.real-runner-toggle.on {
  background: rgba(0, 133, 111, 0.18);
}

.real-runner-toggle .runner-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--red);
  box-shadow: 0 0 0 3px rgba(207, 63, 82, 0.18);
}

.real-runner-toggle.on .runner-dot {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(0, 133, 111, 0.18);
}

.navbar-status {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 168px;
  max-width: 280px;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.navbar-status strong,
.navbar-status small {
  display: block;
  font-size: 11px;
  line-height: 1.2;
}

.navbar-status strong {
  font-weight: 700;
}

.navbar-status small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 99px;
  background: var(--faint);
  box-shadow: 0 0 0 4px rgba(152, 162, 179, 0.16);
}

.dot.good {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(0, 133, 111, 0.18);
}

.dot.warn {
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(182, 109, 0, 0.18);
}

.dot.bad {
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(207, 63, 82, 0.18);
}

.navbar-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex: 0 0 auto;
  font-size: 13px;
}

.navbar-user a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 7px;
  color: #fff;
  background: #202734;
  font-weight: 650;
}

.main {
  min-width: 0;
  padding: 22px 28px 28px;
  display: grid;
  gap: 16px;
}

.topbar,
.section-head,
.panel-head,
.book-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.topbar {
  padding: 8px 0 2px;
}

.topbar h1 {
  margin: 2px 0 5px;
  font-size: 25px;
  line-height: 1.18;
  font-weight: 760;
}

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

.topbar-actions.stacked {
  max-width: 760px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  text-transform: uppercase;
  font-weight: 760;
  font-size: 10px;
}

.muted {
  color: var(--muted);
}

.note {
  margin: 10px 0 0;
  font-size: 12px;
}

.range-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.range-selector.compact {
  max-width: 430px;
}

.range-selector button {
  min-height: 30px;
  padding: 0 10px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 650;
}

.range-selector button.active {
  color: #fff;
  background: var(--ink);
}

.status-badge,
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.status-badge.neutral,
.pill.neutral {
  color: #4b5563;
  background: #ecf0f4;
}

.status-badge.good,
.pill.good {
  color: #05604f;
  background: #daf3ed;
}

.status-badge.warn,
.pill.warn {
  color: #7a4800;
  background: #fff0d1;
}

.status-badge.bad,
.pill.bad {
  color: #8d2031;
  background: #ffe1e7;
}

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

.kpi {
  min-height: 108px;
  padding: 16px;
  position: relative;
  overflow: hidden;
}

.kpi.primary {
  border-color: rgba(0, 133, 111, 0.34);
}

.kpi span,
.metric-label {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  font-weight: 760;
}

.kpi strong {
  display: block;
  margin: 9px 0 5px;
  font-size: 25px;
  line-height: 1.1;
  font-weight: 760;
  overflow-wrap: anywhere;
}

.kpi small {
  color: var(--muted);
  font-weight: 650;
}

.section-band,
.panel {
  padding: 16px;
}

.section-head h2,
.panel-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 720;
}

.strategy-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(235px, 1fr));
  gap: 14px;
  margin-top: 16px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.strategy-card {
  min-width: 235px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel-soft);
}

.strategy-card.paused {
  background: #fffbf2;
}

.strategy-card h3 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 720;
}

.metric-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  font-size: 12px;
}

.metric-row strong {
  text-align: right;
}

.live-trade-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(330px, 0.55fr);
  gap: 16px;
  align-items: stretch;
}

.live-market-panel,
.live-side-panel {
  min-width: 0;
}

.live-clock {
  min-width: 96px;
  text-align: right;
}

.live-clock span,
.live-market-meta span,
.entry-tape-head span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 760;
  text-transform: uppercase;
}

.live-clock strong {
  display: block;
  margin-top: 2px;
  font-size: 22px;
  line-height: 1;
  font-weight: 780;
}

.live-market-meta {
  display: grid;
  grid-template-columns: 0.72fr 1fr 0.78fr;
  gap: 10px;
  margin: 14px 0 10px;
}

.live-market-meta > div {
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.live-market-meta strong,
.live-market-meta small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-market-meta strong {
  margin-top: 6px;
  font-size: 17px;
  font-weight: 760;
}

.live-market-meta small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 640;
}

.live-progress {
  height: 5px;
  border-radius: 99px;
  background: #e6edf4;
  overflow: hidden;
}

.live-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--blue));
  transition: width 220ms ease;
}

.chart-shell {
  position: relative;
  min-width: 0;
}

#liveMarketChart {
  height: 360px;
  cursor: crosshair;
}

.chart-tooltip {
  position: absolute;
  z-index: 10;
  min-width: 210px;
  max-width: 320px;
  padding: 9px 10px;
  color: #f8fafc;
  background: rgba(12, 18, 28, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  box-shadow: 0 14px 30px rgba(17, 24, 39, 0.22);
  font-size: 11px;
  line-height: 1.45;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, calc(-100% - 12px));
  transition: opacity 100ms ease;
}

.chart-tooltip.visible {
  opacity: 1;
}

.chart-tooltip.global {
  position: fixed;
  transform: translate(12px, calc(-100% - 12px));
}

.chart-tooltip strong {
  display: block;
  margin-bottom: 3px;
  color: #fff;
  font-size: 12px;
}

.chart-tooltip span {
  display: block;
  color: #cbd5e1;
}

.chart-tooltip .tooltip-subline {
  color: #9aa6b8;
  padding-left: 8px;
}

.live-side-panel {
  display: grid;
  align-content: start;
  gap: 12px;
}

.live-side-panel .book-grid {
  margin-top: 0;
}

.entry-tape-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 4px;
}

.entry-tape {
  display: grid;
  gap: 8px;
  max-height: 240px;
  overflow: auto;
}

.source-signal-panel {
  margin-top: 16px;
}

.source-signal-summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 740;
}

.signal-chip,
.signal-threshold {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
}

.signal-chip.up {
  color: var(--green);
  background: rgba(0, 137, 116, 0.08);
  border-color: rgba(0, 137, 116, 0.18);
}

.signal-chip.down {
  color: var(--red);
  background: rgba(212, 55, 81, 0.08);
  border-color: rgba(212, 55, 81, 0.18);
}

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

.source-signal-card {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid #9aa6b8;
  border-radius: 8px;
  background: var(--panel-soft);
}

.source-signal-card.up {
  border-left-color: var(--green);
}

.source-signal-card.down {
  border-left-color: var(--red);
}

.source-signal-card.neutral {
  border-left-color: #9aa6b8;
}

.source-signal-card.stale {
  opacity: 0.62;
}

.source-signal-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.source-signal-top strong,
.source-signal-top small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-signal-top strong {
  font-size: 13px;
  font-weight: 780;
}

.source-signal-top small,
.source-signal-sub {
  color: var(--muted);
  font-size: 10px;
  font-weight: 640;
}

.source-direction {
  flex: 0 0 auto;
  align-self: flex-start;
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--muted);
  background: #eef3f8;
  font-size: 10px;
  font-weight: 820;
  text-transform: uppercase;
}

.source-direction.up {
  color: var(--green);
  background: rgba(0, 137, 116, 0.1);
}

.source-direction.down {
  color: var(--red);
  background: rgba(212, 55, 81, 0.1);
}

.source-signal-price {
  margin-top: 10px;
  font-size: 20px;
  line-height: 1;
  font-weight: 800;
}

.source-signal-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 720;
}

.source-signal-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-signal-quality {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 9px;
}

.source-signal-quality span {
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fff;
  font-size: 10px;
  font-weight: 720;
}

.source-signal-quality strong {
  display: block;
  margin-top: 2px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1;
  font-weight: 820;
}

.source-signal-sub {
  margin-top: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-chip {
  display: grid;
  gap: 5px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.entry-chip.entry {
  border-left: 4px solid var(--green);
}

.entry-chip.exit {
  border-left: 4px solid var(--amber);
}

.entry-chip.resolution {
  border-left-color: var(--blue);
}

.entry-chip .entry-top {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.entry-chip strong {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  font-weight: 720;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-chip small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 620;
}

.entry-chip .trade-value {
  color: var(--ink);
  font-size: 11.5px;
  font-weight: 760;
}

.ops-grid,
.data-grid,
.chart-grid,
.config-layout {
  display: grid;
  gap: 18px;
}

.ops-grid {
  grid-template-columns: minmax(0, 1.35fr) minmax(340px, 0.65fr);
}

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

.data-grid {
  grid-template-columns: minmax(0, 1fr) minmax(420px, 0.85fr);
}

.chart-grid {
  grid-template-columns: minmax(0, 1fr) minmax(380px, 0.42fr);
}

.chart-grid .xl {
  grid-column: 1 / -1;
}

canvas {
  display: block;
  width: 100%;
  height: 300px;
  max-width: 100%;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: crosshair;
}

#bankrollChart {
  height: 280px;
}

#strategyBankrollChart {
  height: 280px;
}

#analyticsBankrollChart,
#dailyChart {
  height: 300px;
}

.chart-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 680;
  text-transform: uppercase;
}

.chart-control select {
  min-width: 170px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  font-weight: 720;
  text-transform: none;
  padding: 0 10px;
  outline: none;
}

#priceActionChart {
  height: 430px;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chart-legend i {
  width: 18px;
  height: 3px;
  display: inline-block;
  border-radius: 99px;
}

.chart-legend b {
  display: inline-block;
}

.chart-legend .triangle {
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 11px solid var(--ink);
}

.chart-legend .diamond {
  width: 10px;
  height: 10px;
  background: var(--ink);
  transform: rotate(45deg);
}

.chart-legend .tag-swatch {
  width: 20px;
  height: 9px;
  border-radius: 4px;
  background: var(--green);
  box-shadow: inset 4px 0 0 var(--green), 0 0 0 1px var(--line);
}

.chart-legend .tag-anchor {
  width: 11px;
  height: 11px;
  border: 2px solid var(--green);
  border-radius: 999px;
  background: #fff;
}

.book-grid {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.book-side {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: var(--panel-soft);
}

.book-side.up {
  border-left: 4px solid var(--blue);
}

.book-side.down {
  border-left: 4px solid var(--red);
}

.book-title {
  align-items: center;
  margin-bottom: 10px;
}

.book-title h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 720;
}

.book-title span {
  font-size: 18px;
  font-weight: 760;
}

.liquidity-bar {
  height: 6px;
  margin-bottom: 8px;
  border-radius: 99px;
  background: #e8edf3;
  overflow: hidden;
}

.liquidity-bar span {
  display: block;
  height: 100%;
  min-width: 5%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--blue));
}

.table-wrap {
  overflow: auto;
  margin-top: 12px;
}

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

th,
td {
  padding: 11px 9px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  font-weight: 760;
  letter-spacing: 0;
}

td small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.event-list {
  display: grid;
  gap: 10px;
  max-height: 470px;
  overflow: auto;
  margin-top: 12px;
}

.event-list.compact-list {
  max-height: 520px;
}

.event-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.event-item.entry {
  border-left: 4px solid var(--green);
}

.event-item.exit {
  border-left: 4px solid var(--amber);
}

.event-item.resolution {
  border-left-color: var(--blue);
}

.event-item div {
  display: flex;
  align-items: center;
  gap: 7px;
}

.strategy-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 99px;
}

.event-item strong {
  display: block;
  font-size: 12px;
  font-weight: 700;
}

.event-item small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.config-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.config-summary h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 720;
  overflow-wrap: anywhere;
}

.config-layout {
  grid-template-columns: 260px minmax(0, 1fr);
  align-items: start;
}

.strategy-manager-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.strategy-manager-summary h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 720;
  overflow-wrap: anywhere;
}

.strategy-manager-layout {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.accounts-layout {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.accounts-list-panel {
  position: sticky;
  top: 76px;
}

.account-editor-panel {
  min-width: 0;
}

.account-form {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.wizard-section {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 10px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.wizard-section:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.wizard-section.subtle {
  padding: 14px;
  border: 1px solid #f1d4a6;
  border-radius: 8px;
  background: #fffbf2;
}

.wizard-step {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 99px;
  color: #fff;
  background: var(--ink);
  font-size: 13px;
  font-weight: 780;
}

.wizard-body h3 {
  margin: 2px 0 4px;
  font-size: 15px;
  font-weight: 760;
}

.wizard-body > .muted {
  margin: 0 0 12px;
}

.strategy-param-grid.two {
  grid-template-columns: repeat(2, minmax(180px, 1fr));
}

.strategy-param-grid.three {
  grid-template-columns: repeat(3, minmax(120px, 1fr));
}

.choice-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 10px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  cursor: pointer;
}

.choice-card:has(input:checked) {
  border-color: #8be0c4;
  background: #eefbf7;
}

.choice-card input {
  width: auto;
  grid-row: 1 / span 2;
  margin-top: 2px;
}

.choice-card strong,
.choice-card small {
  display: block;
}

.choice-card strong {
  font-size: 13px;
}

.choice-card small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 640;
}

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.check-row input {
  width: auto;
}

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

.account-strategy-grid {
  display: grid;
  gap: 10px;
}

.account-strategy-item {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.strategy-list-panel {
  position: sticky;
  top: 76px;
}

.managed-strategy-list {
  display: grid;
  gap: 9px;
  margin-top: 12px;
}

.managed-strategy-card {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--muted);
  border-radius: 8px;
  background: #fff;
  text-align: left;
  cursor: pointer;
}

.managed-strategy-card.active {
  border-color: var(--ink);
  border-left-color: var(--green);
  background: #f7fbfa;
}

.managed-strategy-card.paused {
  background: #fffbf2;
}

.managed-strategy-card.draft {
  border-left-color: var(--violet);
}

.managed-strategy-card strong,
.managed-strategy-card span,
.managed-strategy-card small {
  display: block;
}

.managed-strategy-card strong {
  margin: 4px 0 5px;
  font-size: 13px;
  font-weight: 760;
}

.managed-strategy-card span,
.managed-strategy-card small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.strategy-editor-panel {
  min-width: 0;
}

.strategy-editor-identity {
  display: grid;
  grid-template-columns: minmax(220px, 0.7fr) minmax(180px, 0.4fr);
  gap: 12px;
  margin-top: 16px;
}

.strategy-editor-identity .wide {
  grid-column: 1 / -1;
}

.strategy-editor-form {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.source-editor-form {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.strategy-param-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.strategy-param-group h3 {
  margin: 0;
  padding: 12px 14px;
  background: #eef4fa;
  font-size: 13px;
  font-weight: 720;
}

.strategy-param-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  padding: 14px;
}

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

.strategy-editor-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.account-save-actions {
  position: sticky;
  bottom: 0;
  z-index: 6;
  margin: 6px -16px -16px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  border-radius: 0 0 8px 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 -14px 28px rgba(22, 32, 51, 0.08);
  backdrop-filter: blur(10px);
}

.account-save-actions .primary-button {
  min-width: 190px;
}

.simulator-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.simulator-summary h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 720;
}

.simulator-layout {
  display: grid;
  grid-template-columns: minmax(340px, 0.42fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.simulator-control-panel {
  position: sticky;
  top: 76px;
  min-width: 0;
}

.strategy-editor-form.compact .strategy-param-grid {
  grid-template-columns: repeat(2, minmax(130px, 1fr));
}

.simulator-results-panel {
  min-width: 0;
}

.simulator-kpis {
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  margin: 14px 0;
}

.simulator-chart-shell {
  margin-top: 10px;
}

.simulator-chart-head {
  margin-top: 18px;
}

.replay-chart-shell canvas,
#simReplayChart {
  height: 390px;
}

.simulator-metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(110px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.simulator-metric-grid div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.simulator-metric-grid span,
.simulator-metric-grid strong {
  display: block;
}

.simulator-metric-grid span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 680;
}

.simulator-metric-grid strong {
  margin-top: 5px;
  font-size: 16px;
  font-weight: 760;
}

.simulator-table-head {
  margin-top: 18px;
}

.data-table {
  overflow: auto;
}

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

.config-index {
  position: sticky;
  top: 20px;
}

.group-index {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.group-index a {
  padding: 9px 10px;
  border-radius: 7px;
  color: var(--muted);
  background: var(--panel-soft);
  font-size: 12px;
  font-weight: 650;
}

.group-index a:hover {
  color: var(--ink);
  background: #eef4fa;
}

.config-editor {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.config-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.config-group h3 {
  margin: 0;
  padding: 12px 14px;
  background: #eef4fa;
  font-size: 13px;
  font-weight: 720;
}

.config-rows {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 12px;
  padding: 14px;
}

.config-row span {
  overflow-wrap: anywhere;
}

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

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

.flat {
  color: var(--muted);
}

@media (max-width: 1360px) {
  .kpi-grid,
  .analytics-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .strategy-grid {
    grid-template-columns: repeat(3, minmax(235px, 1fr));
  }

  .ops-grid,
  .data-grid,
  .chart-grid {
    grid-template-columns: 1fr;
  }

  .config-rows {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }

  .strategy-param-grid {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }

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

@media (max-width: 1100px) {
  .live-trade-grid {
    grid-template-columns: 1fr;
  }

  .live-market-meta {
    grid-template-columns: 1fr;
  }

  .strategy-manager-layout,
  .accounts-layout,
  .simulator-layout {
    grid-template-columns: 1fr;
  }

  .strategy-list-panel,
  .accounts-list-panel,
  .simulator-control-panel {
    position: static;
  }
}

@media (max-width: 900px) {
  .app-navbar {
    position: static;
    flex-wrap: wrap;
    min-height: auto;
    padding: 10px 16px;
    gap: 10px;
  }

  .nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
  }

  .nav a {
    justify-content: center;
    text-align: center;
  }

  .navbar-spacer {
    display: none;
  }

  .navbar-status {
    margin-left: auto;
  }

  .topbar,
  .section-head,
  .panel-head,
  .config-summary,
  .strategy-manager-summary,
  .strategy-editor-actions {
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .kpi-grid,
  .strategy-grid,
  .config-layout,
  .config-rows,
  .strategy-editor-identity,
  .strategy-param-grid {
    grid-template-columns: 1fr;
  }

  .config-index {
    position: static;
  }
}

@media (max-width: 560px) {
  .app-navbar {
    align-items: stretch;
  }

  .brand,
  .navbar-user,
  .navbar-status {
    width: 100%;
  }

  .navbar-status {
    max-width: none;
    margin-left: 0;
  }

  .navbar-user {
    justify-content: space-between;
  }

  .main {
    padding: 16px;
  }

  .topbar h1 {
    font-size: 22px;
  }

  .kpi strong {
    font-size: 22px;
  }

  .range-selector {
    width: 100%;
  }

  .range-selector button {
    flex: 1 1 calc(50% - 5px);
  }
}
