:root {
  --thor-bg: #05080b;
  --thor-panel: #0b1117;
  --thor-panel-raised: #101922;
  --thor-line: #22313d;
  --thor-line-hot: #3a5263;
  --thor-text: #edf7ff;
  --thor-muted: #8295a4;
  --thor-cyan: #49d8ff;
  --thor-green: #35e5a0;
  --thor-red: #ff647b;
  --thor-amber: #ffc95c;
}

body[data-page-id="ai_trading"] .main {
  max-width: calc(100vw - var(--nav-width, 240px));
  padding: 0;
  background: var(--thor-bg);
}

.thor50-shell {
  position: relative;
  min-height: calc(100vh - var(--nav-height, 64px));
  padding: 20px;
  overflow: hidden;
  color: var(--thor-text);
  background-color: var(--thor-bg);
  background-image:
    linear-gradient(rgba(73, 216, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(73, 216, 255, 0.025) 1px, transparent 1px);
  background-size: 36px 36px;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

.thor50-shell *,
.thor50-shell *::before,
.thor50-shell *::after {
  box-sizing: border-box;
  letter-spacing: 0;
}

.thor50-command-header {
  display: flex;
  min-height: 88px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border: 1px solid var(--thor-line);
  border-left: 3px solid var(--thor-cyan);
  padding: 14px 18px;
  background: rgba(8, 13, 18, 0.96);
}

.thor50-identity {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 16px;
}

.thor50-logo {
  width: 154px;
  height: 58px;
  object-fit: cover;
  object-position: left center;
  border-right: 1px solid var(--thor-line);
  padding-right: 16px;
}

.thor50-kicker,
.thor50-sector-code {
  color: var(--thor-cyan);
  font-family: "Roboto Mono", Consolas, monospace;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.thor50-identity h1 {
  margin: 2px 0 0;
  font-size: 28px;
  line-height: 1;
  color: var(--thor-text);
}

.thor50-identity h1 span {
  color: var(--thor-amber);
  font-weight: 500;
}

.thor50-connection {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
  min-width: 160px;
  justify-content: flex-end;
}

.thor50-connection strong,
.thor50-connection span {
  display: block;
  text-align: right;
}

.thor50-connection strong {
  font-family: "Roboto Mono", Consolas, monospace;
  font-size: 12px;
  color: var(--thor-amber);
}

.thor50-connection div > span {
  margin-top: 3px;
  color: var(--thor-muted);
  font-size: 10px;
}

.thor50-signal {
  width: 10px;
  height: 10px;
  border: 2px solid var(--thor-amber);
  border-radius: 50%;
  box-shadow: 0 0 12px rgba(255, 201, 92, 0.55);
}

.thor50-shell[data-status="live"] .thor50-signal {
  border-color: var(--thor-green);
  background: var(--thor-green);
  box-shadow: 0 0 14px rgba(53, 229, 160, 0.65);
}

.thor50-shell[data-status="live"] .thor50-connection strong { color: var(--thor-green); }
.thor50-shell[data-status="error"] .thor50-signal,
.thor50-shell[data-status="offline"] .thor50-signal { border-color: var(--thor-red); box-shadow: 0 0 12px rgba(255, 100, 123, 0.5); }
.thor50-shell[data-status="error"] .thor50-connection strong,
.thor50-shell[data-status="offline"] .thor50-connection strong { color: var(--thor-red); }

.thor50-access-state {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 201, 92, 0.45);
  background: rgba(255, 201, 92, 0.07);
  color: var(--thor-amber);
}

.thor50-access-state strong,
.thor50-access-state span { display: block; }
.thor50-access-state div > span { margin-top: 2px; color: #c5b98f; font-size: 12px; }

.thor50-tabs {
  display: flex;
  align-items: stretch;
  min-height: 48px;
  margin-top: 12px;
  border: 1px solid var(--thor-line);
  background: rgba(8, 13, 18, 0.96);
  overflow-x: auto;
}

.thor50-tab {
  position: relative;
  display: inline-flex;
  min-width: 142px;
  height: 46px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-right: 1px solid var(--thor-line);
  padding: 0 14px;
  background: transparent;
  color: var(--thor-muted);
  font: 700 12px Inter, "Segoe UI", sans-serif;
  cursor: pointer;
}

.thor50-tab::after {
  content: "";
  position: absolute;
  right: 10px;
  bottom: 0;
  left: 10px;
  height: 2px;
  background: transparent;
}

.thor50-tab:hover,
.thor50-tab:focus-visible { color: var(--thor-text); background: #101821; }
.thor50-tab.active { color: var(--thor-cyan); }
.thor50-tab.active::after { background: var(--thor-cyan); }
.thor50-tab .material-icons { font-size: 17px; }
.thor50-tab b {
  display: inline-grid;
  min-width: 18px;
  height: 18px;
  place-items: center;
  padding: 0 4px;
  border: 1px solid var(--thor-line-hot);
  border-radius: 3px;
  color: var(--thor-text);
  font-size: 9px;
}

.thor50-view { display: none; padding-top: 12px; }
.thor50-view.active { display: block; }

.thor50-primary-strip {
  display: grid;
  grid-template-columns: 1.25fr 1fr 1fr;
  border: 1px solid var(--thor-line);
  background: rgba(8, 13, 18, 0.95);
}

.thor50-primary-metric {
  min-width: 0;
  min-height: 124px;
  padding: 20px;
  border-right: 1px solid var(--thor-line);
}

.thor50-primary-metric:last-child { border-right: 0; }
.thor50-primary-metric > span,
.thor50-system-grid article span {
  display: block;
  color: var(--thor-muted);
  font-family: "Roboto Mono", Consolas, monospace;
  font-size: 10px;
  font-weight: 700;
}

.thor50-primary-metric strong {
  display: block;
  margin-top: 10px;
  overflow-wrap: anywhere;
  color: var(--thor-text);
  font-size: 34px;
  line-height: 1;
}

.thor50-primary-metric small {
  display: block;
  margin-top: 9px;
  color: var(--thor-muted);
  font: 10px "Roboto Mono", Consolas, monospace;
}

.thor50-primary-metric.equity { border-top: 2px solid var(--thor-green); }
.thor50-primary-metric.pnl { border-top: 2px solid var(--thor-amber); }

.thor50-telemetry-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(280px, 0.65fr);
  gap: 12px;
  margin-top: 12px;
}

.thor50-chart-sector,
.thor50-risk-sector {
  min-width: 0;
  border: 1px solid var(--thor-line);
  background: rgba(8, 13, 18, 0.96);
}

.thor50-chart-sector > header,
.thor50-risk-sector > header,
.thor50-section-heading {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--thor-line);
}

.thor50-chart-sector h2,
.thor50-risk-sector h2,
.thor50-section-heading h2 {
  margin: 3px 0 0;
  color: var(--thor-text);
  font-size: 14px;
}

.thor50-chart-legend { display: flex; gap: 14px; color: var(--thor-muted); font-size: 10px; }
.thor50-chart-legend span::before { content: ""; display: inline-block; width: 14px; height: 2px; margin: 0 5px 3px 0; background: var(--thor-green); }
.thor50-chart-legend span:last-child::before { background: var(--thor-cyan); }

.thor50-chart-wrap {
  position: relative;
  width: 100%;
  height: 330px;
  min-height: 260px;
  overflow: hidden;
}

#thor50-equity-chart { display: block; width: 100%; height: 100%; }
.thor50-chart-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #526573;
  font: 11px "Roboto Mono", Consolas, monospace;
  pointer-events: none;
}
.thor50-chart-empty[hidden] { display: none; }

.thor50-risk-sector { padding-bottom: 14px; }
.thor50-orbit {
  position: relative;
  width: 154px;
  height: 154px;
  margin: 18px auto;
  border: 1px solid #29404f;
  border-radius: 50%;
}

.thor50-orbit::before,
.thor50-orbit::after {
  content: "";
  position: absolute;
  inset: 14px;
  border: 1px solid #1b2b36;
  border-radius: 50%;
}

.thor50-orbit::after { inset: 35px; border-color: var(--thor-cyan); opacity: 0.65; }
.thor50-orbit-core { position: absolute; inset: 0; z-index: 1; display: grid; place-content: center; text-align: center; }
.thor50-orbit-core strong { color: var(--thor-text); font-size: 24px; }
.thor50-orbit-core span { margin-top: 3px; color: var(--thor-cyan); font: 9px "Roboto Mono", Consolas, monospace; }

.thor50-risk-bars { display: grid; gap: 13px; padding: 0 16px; }
.thor50-risk-bars > div { display: grid; grid-template-columns: 1fr auto; gap: 5px 12px; color: var(--thor-muted); font-size: 10px; }
.thor50-risk-bars b { color: var(--thor-text); font-family: "Roboto Mono", Consolas, monospace; }
.thor50-risk-bars i { grid-column: 1 / -1; display: block; height: 4px; background: #17232c; overflow: hidden; }
.thor50-risk-bars em { display: block; width: 0; height: 100%; background: var(--thor-cyan); transition: width 220ms ease; }
.thor50-risk-bars > div:nth-child(2) em { background: var(--thor-red); }
.thor50-risk-bars > div:nth-child(3) em { background: var(--thor-amber); }

.thor50-system-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  margin-top: 12px;
  border-top: 1px solid var(--thor-line);
  border-left: 1px solid var(--thor-line);
  background: rgba(8, 13, 18, 0.95);
}

.thor50-system-grid article {
  min-width: 0;
  min-height: 84px;
  padding: 14px;
  border-right: 1px solid var(--thor-line);
  border-bottom: 1px solid var(--thor-line);
}

.thor50-system-grid article strong { display: block; margin-top: 9px; overflow-wrap: anywhere; font-size: 17px; }
.thor50-system-grid article.long { box-shadow: inset 0 2px var(--thor-cyan); }
.thor50-system-grid article.short { box-shadow: inset 0 2px #ff9b68; }

.thor50-section-heading {
  border: 1px solid var(--thor-line);
  background: rgba(8, 13, 18, 0.96);
}

.thor50-segmented { display: inline-flex; border: 1px solid var(--thor-line); }
.thor50-segmented button {
  height: 30px;
  min-width: 62px;
  border: 0;
  border-right: 1px solid var(--thor-line);
  background: #0b1218;
  color: var(--thor-muted);
  font-size: 10px;
  cursor: pointer;
}
.thor50-segmented button:last-child { border-right: 0; }
.thor50-segmented button.active { color: var(--thor-cyan); background: #12212b; }

.thor50-readonly,
.thor50-research-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--thor-green);
  font: 700 10px "Roboto Mono", Consolas, monospace;
}
.thor50-readonly .material-icons { font-size: 15px; }
.thor50-research-label { color: var(--thor-amber); }

.thor50-table-wrap {
  width: 100%;
  max-height: calc(100vh - 260px);
  overflow: auto;
  border: 1px solid var(--thor-line);
  border-top: 0;
  background: rgba(5, 9, 12, 0.98);
}

.thor50-table-wrap table { width: 100%; min-width: 1180px; border-collapse: collapse; }
.thor50-table-wrap th,
.thor50-table-wrap td { height: 42px; padding: 8px 11px; border-bottom: 1px solid #17242d; text-align: right; white-space: nowrap; font-size: 11px; }
.thor50-table-wrap th { position: sticky; top: 0; z-index: 2; background: #0d171f; color: var(--thor-muted); font: 700 9px "Roboto Mono", Consolas, monospace; text-transform: uppercase; }
.thor50-table-wrap th:first-child,
.thor50-table-wrap td:first-child,
.thor50-table-wrap th:last-child,
.thor50-table-wrap td:last-child { text-align: left; }
.thor50-table-wrap tbody tr:hover { background: #0e1a22; }
.thor50-empty { height: 160px !important; text-align: center !important; color: #526573; font-family: "Roboto Mono", Consolas, monospace; }

.thor50-side,
.thor50-action {
  display: inline-block;
  min-width: 54px;
  font: 800 9px "Roboto Mono", Consolas, monospace;
  text-align: center;
}
.thor50-side.long { color: var(--thor-cyan); }
.thor50-side.short { color: #ff9b68; }
.thor50-action.open { color: var(--thor-cyan); }
.thor50-action.harvest { color: var(--thor-green); }
.thor50-action.armed,
.thor50-action.reopen { color: var(--thor-amber); }
.positive { color: var(--thor-green) !important; }
.negative { color: var(--thor-red) !important; }

.thor50-validation-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.thor50-validation-grid article { border: 1px solid var(--thor-line); border-top: 2px solid var(--thor-green); padding: 18px; background: rgba(8, 13, 18, 0.96); }
.thor50-validation-grid article:nth-child(2) { border-top-color: var(--thor-cyan); }
.thor50-validation-grid article:nth-child(3) { border-top-color: var(--thor-amber); }
.thor50-validation-grid article > span { color: var(--thor-muted); font: 10px "Roboto Mono", Consolas, monospace; }
.thor50-validation-grid article > strong { display: block; margin-top: 8px; overflow-wrap: anywhere; font-size: 17px; }
.thor50-validation-grid dl { margin: 20px 0 0; }
.thor50-validation-grid dl div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--thor-line); }
.thor50-validation-grid dt { color: var(--thor-muted); }
.thor50-validation-grid dd { margin: 0; font-weight: 800; text-align: right; }

.thor50-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 2px 2px;
  color: #526573;
  font: 9px "Roboto Mono", Consolas, monospace;
}

@media (max-width: 1180px) {
  body[data-page-id="ai_trading"] .main { max-width: 100vw; }
  .thor50-system-grid { grid-template-columns: repeat(3, minmax(120px, 1fr)); }
}

@media (max-width: 820px) {
  .thor50-shell { min-height: 100vh; padding: 10px 10px calc(var(--mobile-bottom-nav-height, 64px) + 18px); }
  .thor50-command-header { min-height: 70px; padding: 10px 12px; }
  .thor50-logo { width: 105px; height: 42px; padding-right: 10px; }
  .thor50-kicker { display: none; }
  .thor50-identity h1 { font-size: 22px; }
  .thor50-connection { min-width: 110px; }
  .thor50-tabs { margin-top: 8px; }
  .thor50-tab { min-width: 54px; flex: 1 0 54px; padding: 0 8px; font-size: 0; }
  .thor50-tab .material-icons { font-size: 19px; }
  .thor50-tab b { font-size: 8px; }
  .thor50-view { padding-top: 8px; }
  .thor50-primary-strip { grid-template-columns: 1fr 1fr; }
  .thor50-primary-metric { min-height: 104px; padding: 14px; }
  .thor50-primary-metric:first-child { grid-column: 1 / -1; border-right: 0; border-bottom: 1px solid var(--thor-line); }
  .thor50-primary-metric:nth-child(2) { border-right: 1px solid var(--thor-line); }
  .thor50-primary-metric strong { font-size: 25px; }
  .thor50-telemetry-grid { grid-template-columns: 1fr; gap: 8px; margin-top: 8px; }
  .thor50-chart-wrap { height: 240px; }
  .thor50-risk-sector { display: grid; grid-template-columns: 130px 1fr; align-items: center; padding: 10px; }
  .thor50-risk-sector > header { grid-column: 1 / -1; margin: -10px -10px 0; }
  .thor50-orbit { width: 108px; height: 108px; margin: 14px auto; }
  .thor50-orbit-core strong { font-size: 19px; }
  .thor50-system-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 8px; }
  .thor50-system-grid article { min-height: 76px; padding: 12px; }
  .thor50-system-grid article strong { font-size: 15px; }
  .thor50-section-heading { align-items: flex-start; flex-direction: column; }
  .thor50-validation-grid { grid-template-columns: 1fr; gap: 8px; margin-top: 8px; }
  .thor50-table-wrap { max-height: calc(100vh - 280px); }
}

@media (max-width: 430px) {
  .thor50-shell { padding-right: 7px; padding-left: 7px; }
  .thor50-command-header { gap: 8px; }
  .thor50-logo { width: 89px; height: 38px; }
  .thor50-identity { gap: 8px; }
  .thor50-connection div > span { max-width: 92px; white-space: normal; }
  .thor50-primary-metric strong { font-size: 22px; }
  .thor50-chart-sector > header { align-items: flex-start; flex-direction: column; }
  .thor50-chart-wrap { height: 210px; }
  .thor50-risk-sector { grid-template-columns: 100px 1fr; }
  .thor50-orbit { width: 88px; height: 88px; }
  .thor50-orbit::before { inset: 9px; }
  .thor50-orbit::after { inset: 24px; }
  .thor50-footer { flex-direction: column; }
}
