:root {
  --ink: #101828;
  --muted: #5c667a;
  --paper: #f6f7f1;
  --surface: rgba(255, 255, 250, 0.82);
  --surface-strong: rgba(255, 255, 250, 0.96);
  --line: rgba(16, 24, 40, 0.14);
  --line-strong: rgba(16, 24, 40, 0.24);
  --green: #27624a;
  --blue: #255f85;
  --amber: #a05d17;
  --red: #8d2f3c;
  --violet: #5a4f8a;
  --shadow: 0 18px 55px rgba(16, 24, 40, 0.08);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(37, 95, 133, 0.08), transparent 32%),
    linear-gradient(180deg, rgba(39, 98, 74, 0.08), transparent 38%),
    var(--paper);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.trading-shell {
  display: grid;
  gap: 22px;
  width: min(1440px, 100%);
  min-height: 100svh;
  margin: 0 auto;
  padding: 32px 28px 54px;
}

.trading-header {
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.trading-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-bottom: 26px;
}

.trading-nav a,
.action-row button,
.memory-head button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 250, 0.72);
  color: var(--blue);
  font-size: 0.86rem;
  font-weight: 760;
  text-decoration: none;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.trading-nav a:hover,
.trading-nav a:focus-visible,
.action-row button:hover,
.action-row button:focus-visible,
.memory-head button:hover,
.memory-head button:focus-visible {
  border-color: rgba(37, 95, 133, 0.34);
  background: rgba(255, 255, 255, 0.9);
  transform: translateY(-1px);
}

.title-row,
.stage-head,
.memory-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: end;
}

.title-row > *,
.stage-head > *,
.memory-head > * {
  min-width: 0;
}

.kicker,
.panel-kicker {
  margin: 0;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  line-height: 1.08;
}

h1 {
  margin-bottom: 0;
  font-size: 3.5rem;
  overflow-wrap: anywhere;
}

h2 {
  margin: 7px 0 0;
  font-size: 1.55rem;
}

.run-status {
  display: grid;
  gap: 5px;
  min-width: 250px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.run-status span,
.market-strip span,
.ticket-grid dt,
.debate-columns span,
.field span,
.analyst-set legend,
.memory-item span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 760;
}

.run-status strong {
  color: var(--green);
  font-size: 1.45rem;
  overflow-wrap: anywhere;
}

.trading-workbench,
.decision-layout {
  display: grid;
  grid-template-columns: minmax(280px, 350px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.decision-layout {
  grid-template-columns: minmax(280px, 0.8fr) minmax(300px, 0.9fr) minmax(0, 1.35fr);
}

.control-panel,
.stage-panel,
.trade-ticket,
.debate-panel,
.report-panel,
.memory-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 250, 0.96), rgba(255, 255, 250, 0.72)),
    var(--surface);
  box-shadow: var(--shadow);
}

.control-panel {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 15px;
  padding: 18px;
}

.panel-head {
  display: grid;
  gap: 3px;
}

.field {
  display: grid;
  gap: 7px;
}

.field input,
.field select {
  width: 100%;
  min-height: 40px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.78);
}

.field input:focus,
.field select:focus {
  border-color: rgba(37, 95, 133, 0.5);
  outline: 3px solid rgba(37, 95, 133, 0.12);
}

.split-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.analyst-set {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin: 0;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.52);
}

.analyst-set legend {
  padding: 0 5px;
}

.analyst-set label {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 720;
}

.analyst-set input {
  width: 16px;
  height: 16px;
  accent-color: var(--green);
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.action-row button:first-child {
  border-color: rgba(39, 98, 74, 0.38);
  background: var(--green);
  color: white;
}

.stage-panel,
.trade-ticket,
.debate-panel,
.report-panel,
.memory-panel {
  padding: 18px;
}

.progress-meter {
  display: grid;
  gap: 7px;
  min-width: 210px;
}

.progress-meter span {
  justify-self: end;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 780;
}

.progress-meter div {
  width: 210px;
  height: 8px;
  overflow: hidden;
  border: 1px solid rgba(16, 24, 40, 0.1);
  border-radius: 999px;
  background: rgba(16, 24, 40, 0.08);
}

.progress-meter i {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--blue), var(--amber));
  transition: width 220ms ease;
}

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

.market-strip article {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.56);
}

.market-strip strong {
  display: block;
  margin-top: 5px;
  color: var(--ink);
  font-size: 1rem;
  overflow-wrap: anywhere;
}

.price-canvas {
  display: block;
  width: 100%;
  height: 190px;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(255, 255, 255, 0.48)),
    rgba(255, 255, 255, 0.6);
}

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

.agent-node {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 7px;
  min-height: 118px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
}

.agent-node[data-status="active"] {
  border-color: rgba(37, 95, 133, 0.45);
  background: rgba(37, 95, 133, 0.08);
}

.agent-node[data-status="done"] {
  border-color: rgba(39, 98, 74, 0.38);
  background: rgba(39, 98, 74, 0.08);
}

.agent-node[data-status="skipped"] {
  opacity: 0.56;
}

.agent-node strong {
  overflow-wrap: anywhere;
}

.agent-node p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.48;
  overflow-wrap: anywhere;
}

.node-status {
  display: inline-flex;
  width: fit-content;
  min-height: 24px;
  align-items: center;
  padding: 0 8px;
  border: 1px solid rgba(16, 24, 40, 0.1);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  font-size: 0.74rem;
  font-weight: 780;
}

.ticket-grid {
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
}

.ticket-grid div {
  display: grid;
  gap: 5px;
  padding: 11px 0;
  border-top: 1px solid var(--line);
}

.ticket-grid dd {
  margin: 0;
  color: var(--ink);
  font-weight: 760;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.debate-columns {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.debate-columns article,
.report-item,
.memory-item {
  min-width: 0;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.56);
}

.debate-columns article:nth-child(1) {
  border-left: 4px solid var(--green);
}

.debate-columns article:nth-child(2) {
  border-left: 4px solid var(--red);
}

.debate-columns article:nth-child(3) {
  border-left: 4px solid var(--amber);
}

.debate-columns p {
  margin: 6px 0 0;
  color: var(--ink);
  font-size: 0.94rem;
  line-height: 1.62;
  overflow-wrap: anywhere;
}

.report-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.report-item h3 {
  margin: 0;
  font-size: 1rem;
}

.report-item p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.58;
  overflow-wrap: anywhere;
}

.report-item[data-tone="market"] {
  border-left: 4px solid var(--blue);
}

.report-item[data-tone="fundamentals"] {
  border-left: 4px solid var(--green);
}

.report-item[data-tone="sentiment"] {
  border-left: 4px solid var(--violet);
}

.report-item[data-tone="news"] {
  border-left: 4px solid var(--amber);
}

.memory-panel {
  display: grid;
  gap: 14px;
}

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

.memory-item {
  display: grid;
  gap: 7px;
}

.memory-item strong {
  overflow-wrap: anywhere;
}

.memory-item p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.52;
}

.source-note {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.6;
}

.source-note a {
  color: var(--blue);
  font-weight: 760;
}

@media (max-width: 1120px) {
  .decision-layout,
  .trading-workbench {
    grid-template-columns: 1fr;
  }

  .control-panel {
    position: static;
  }

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

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

@media (max-width: 760px) {
  .trading-shell {
    padding: 22px 16px 42px;
  }

  .title-row,
  .stage-head,
  .memory-head,
  .market-strip,
  .report-list,
  .memory-log,
  .split-fields {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 2.35rem;
  }

  .run-status,
  .progress-meter,
  .progress-meter div {
    width: 100%;
    min-width: 0;
  }

  .agent-graph {
    grid-template-columns: 1fr;
  }

  .analyst-set {
    grid-template-columns: 1fr;
  }
}
