:root {
  color-scheme: dark;
  --bg: #101216;
  --surface: #171a20;
  --surface-2: #20242c;
  --line: #303640;
  --text: #f5f7fa;
  --muted: #9aa4b2;
  --green: #32d583;
  --red: #ff647c;
  --amber: #f7b955;
  --blue: #6cb7ff;
  --violet: #b69cff;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.26);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", Arial,
    sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.topbar {
  min-height: 76px;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(16, 18, 22, 0.96);
  position: sticky;
  top: 0;
  z-index: 20;
}

.agent-toolbar {
  padding: 10px 18px 12px;
  border-bottom: 1px solid var(--line);
  background: #0d1117;
}

.agent-menu,
.agent-controls,
.agent-status-line,
.switch-row {
  display: flex;
  align-items: center;
}

.agent-menu {
  gap: 8px;
  margin-bottom: 10px;
}

.agent-menu button {
  min-height: 24px;
  padding: 0;
  color: #b8c2cf;
  background: transparent;
  font-size: 13px;
}

.agent-menu button:hover {
  color: var(--text);
}

.agent-controls {
  gap: 10px;
  flex-wrap: wrap;
}

.agent-controls label:not(.switch-row) {
  display: grid;
  grid-template-columns: auto minmax(96px, 1fr);
  align-items: center;
  gap: 7px;
}

.agent-controls label span,
.agent-status-line {
  color: var(--muted);
  font-size: 13px;
}

.agent-controls input,
.agent-controls select {
  min-height: 36px;
  min-width: 104px;
  padding: 0 10px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

.agent-controls input {
  width: 118px;
  text-transform: uppercase;
}

.switch-row {
  min-height: 36px;
  gap: 7px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  user-select: none;
}

.switch-row input {
  width: 18px;
  height: 18px;
  min-width: 0;
  min-height: 0;
  accent-color: var(--green);
}

.agent-status-line {
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}

.agent-status-line strong {
  color: var(--blue);
  font-weight: 800;
}

.brand-block,
.topbar-actions,
.market-header,
.section-heading,
.chart-heading,
.plan-heading,
.price-block,
.range-row {
  display: flex;
  align-items: center;
}

.brand-block {
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #f5f7fa;
  color: #101216;
  font-size: 15px;
  font-weight: 900;
}

.brand-block h1,
.brand-block p,
.market-header h2,
.chart-heading h3,
.section-heading h2,
.risk-note p {
  margin: 0;
}

.brand-block h1 {
  font-size: 21px;
  line-height: 1.15;
}

.brand-block p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

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

.connection-pill,
.member-pill,
.updated-at,
.icon-button,
.ghost-button,
.primary-button,
.segmented button {
  min-height: 38px;
  border-radius: 8px;
}

.connection-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
}

.member-pill {
  max-width: 280px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.member-pill.good {
  color: var(--green);
  border-color: rgba(50, 213, 131, 0.45);
}

.member-pill.warn {
  color: var(--amber);
  border-color: rgba(247, 185, 85, 0.45);
}

.member-pill.bad {
  color: var(--red);
  border-color: rgba(255, 100, 124, 0.45);
}

.header-auth-button {
  padding: 0 12px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(247, 185, 85, 0.14);
}

.status-dot.online {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(50, 213, 131, 0.15);
}

.status-dot.offline {
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(255, 100, 124, 0.14);
}

.updated-at {
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  white-space: nowrap;
}

.icon-button {
  width: 40px;
  display: grid;
  place-items: center;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.icon-button:hover,
.ghost-button:hover,
.primary-button:hover,
.segmented button:hover {
  border-color: #566170;
}

.icon-button:active,
.primary-button:active,
.ghost-button:active,
.segmented button:active {
  transform: translateY(1px);
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  min-height: 0;
}

.watch-panel {
  padding: 18px;
  border-right: 1px solid var(--line);
  background: #12151a;
  overflow: auto;
}

.panel-section + .panel-section {
  margin-top: 22px;
}

.section-heading {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.watch-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.watch-heading span {
  color: var(--muted);
  white-space: nowrap;
}

.watch-tabs {
  min-width: 0;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 1px;
  scrollbar-width: none;
}

.watch-tabs::-webkit-scrollbar {
  display: none;
}

.watch-tabs button {
  min-height: 32px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface);
  font-size: 13px;
  font-weight: 850;
  white-space: nowrap;
}

.watch-tabs button.active {
  color: #07130d;
  border-color: rgba(50, 213, 131, 0.82);
  background: var(--green);
}

.section-heading h2 {
  font-size: 15px;
  line-height: 1.2;
}

.section-heading span,
.eyebrow,
.metric span,
.chart-stats,
.watch-meta,
.risk-note {
  color: var(--muted);
}

.symbol-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-bottom: 12px;
}

.symbol-form input {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  text-transform: uppercase;
}

.symbol-form input:focus,
.range:focus-visible,
.watch-tabs button:focus-visible,
.segmented button:focus-visible,
.icon-button:focus-visible,
.ghost-button:focus-visible,
.primary-button:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.primary-button,
.ghost-button {
  border: 1px solid var(--line);
}

.primary-button {
  padding: 0 14px;
  color: #07130d;
  background: var(--green);
  font-weight: 800;
}

.ghost-button {
  padding: 0 12px;
  color: var(--muted);
  background: var(--surface);
}

.ghost-link {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface);
  text-decoration: none;
  font-weight: 800;
}

.ghost-link:hover {
  color: var(--text);
  border-color: #566170;
}

.watch-list {
  display: grid;
  gap: 8px;
}

.watch-item {
  min-height: 74px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 70px;
  gap: 10px;
  padding: 11px;
  color: var(--text);
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.watch-item.active {
  border-color: var(--blue);
  background: #1b2430;
}

.watch-select {
  width: 100%;
  min-height: 100%;
  min-width: 0;
  padding: 0;
  color: var(--text);
  text-align: left;
  background: transparent;
}

.watch-symbol {
  display: block;
  margin-bottom: 7px;
  font-size: 15px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.watch-price {
  display: block;
  font-size: 16px;
  font-weight: 800;
  white-space: nowrap;
}

.watch-meta {
  display: block;
  margin-top: 6px;
  font-size: 12px;
}

.watch-actions {
  display: grid;
  align-content: start;
  justify-items: end;
  gap: 8px;
}

.chance-button {
  min-width: 62px;
  min-height: 30px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: #10151c;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.chance-button.good {
  color: #07130d;
  border-color: rgba(50, 213, 131, 0.72);
  background: var(--green);
}

.chance-button.bad {
  color: #fff5f6;
  border-color: rgba(255, 100, 124, 0.72);
  background: #c93d56;
}

.chance-button.warn {
  color: #1f1505;
  border-color: rgba(247, 185, 85, 0.72);
  background: var(--amber);
}

.chance-button:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.remove-button {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
}

.remove-button:hover {
  color: var(--red);
  background: rgba(255, 100, 124, 0.09);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.segmented button {
  color: var(--muted);
  background: transparent;
}

.segmented button.active {
  color: #081013;
  background: var(--blue);
  font-weight: 800;
}

.range-row {
  justify-content: space-between;
  margin-top: 18px;
  font-size: 14px;
}

.range {
  width: 100%;
  margin-top: 10px;
  accent-color: var(--green);
}

.market-view {
  min-width: 0;
  padding: 22px;
  overflow: auto;
}

.market-header {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
  text-transform: uppercase;
}

.market-header h2 {
  font-size: 34px;
  line-height: 1;
  overflow-wrap: anywhere;
}

.price-block {
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.price-block span {
  font-size: 32px;
  font-weight: 850;
  white-space: nowrap;
}

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

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

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

.signal-strip,
.trade-plan,
.scenario-board,
.chart-panel,
.advisor-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.signal-strip {
  display: grid;
  grid-template-columns: minmax(140px, 220px) minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  padding: 16px;
  margin-bottom: 14px;
}

.signal-strip strong {
  font-size: 22px;
}

.signal-strip p {
  margin: 0;
  color: #dce4ed;
  line-height: 1.55;
}

.signal-strip.good {
  border-color: rgba(50, 213, 131, 0.52);
}

.signal-strip.warn {
  border-color: rgba(247, 185, 85, 0.58);
}

.signal-strip.bad {
  border-color: rgba(255, 100, 124, 0.54);
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.insight-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.insight-card .section-heading {
  margin-bottom: 10px;
}

.insight-card .section-heading h2 {
  font-size: 16px;
}

.insight-card .section-heading span {
  font-size: 12px;
}

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

.insight-values div {
  min-height: 68px;
  padding: 10px;
  border: 1px solid rgba(48, 54, 64, 0.78);
  border-radius: 8px;
  background: #10141a;
}

.insight-values span,
.insight-values strong {
  display: block;
}

.insight-values span {
  color: var(--muted);
  font-size: 12px;
}

.insight-values strong {
  margin-top: 8px;
  font-size: 15px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.insight-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.trade-plan {
  padding: 16px;
  margin-bottom: 14px;
}

.plan-heading {
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.plan-heading h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.plan-badge {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: #12161c;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.plan-badge.good {
  color: var(--green);
  border-color: rgba(50, 213, 131, 0.5);
}

.plan-badge.bad {
  color: var(--red);
  border-color: rgba(255, 100, 124, 0.48);
}

.plan-badge.warn {
  color: var(--amber);
  border-color: rgba(247, 185, 85, 0.5);
}

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

.plan-cell {
  min-height: 76px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #12161c;
}

.plan-cell.wide {
  grid-column: span 2;
}

.plan-cell span,
.plan-cell strong {
  display: block;
}

.plan-cell span {
  color: var(--muted);
  font-size: 12px;
}

.plan-cell strong {
  margin-top: 8px;
  font-size: 17px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.plan-summary {
  margin: 12px 0 0;
  color: #e8edf4;
  line-height: 1.55;
}

.plan-rules {
  margin: 10px 0 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.55;
}

.plan-rules li + li {
  margin-top: 5px;
}

.scenario-board {
  padding: 16px;
  margin-bottom: 14px;
}

.scenario-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 8px;
}

.scenario-heading h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.scenario-updated {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid rgba(108, 183, 255, 0.42);
  color: var(--blue);
  background: #101822;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.scenario-copy {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.5;
}

.scenario-edge {
  min-height: 74px;
  display: grid;
  grid-template-columns: minmax(120px, 180px) minmax(100px, 140px) minmax(0, 1fr);
  gap: 10px;
  align-items: stretch;
  padding: 10px;
  margin-bottom: 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #10141a;
}

.scenario-edge.good {
  border-color: rgba(50, 213, 131, 0.52);
}

.scenario-edge.bad {
  border-color: rgba(255, 100, 124, 0.52);
}

.scenario-edge.warn {
  border-color: rgba(247, 185, 85, 0.52);
}

.scenario-edge div {
  min-width: 0;
  padding: 10px;
  border-radius: 8px;
  background: #171c24;
}

.scenario-edge span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.scenario-edge strong {
  display: block;
  margin-top: 7px;
  font-size: 18px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.scenario-edge.good strong {
  color: var(--green);
}

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

.scenario-edge.warn strong {
  color: var(--amber);
}

.scenario-edge p {
  margin: 0;
  padding: 10px;
  border-radius: 8px;
  background: #171c24;
  color: #dce4ed;
  line-height: 1.45;
}

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

.scenario-card {
  min-width: 0;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #12161c;
}

.scenario-card.good {
  border-color: rgba(50, 213, 131, 0.48);
}

.scenario-card.bad {
  border-color: rgba(255, 100, 124, 0.48);
}

.scenario-card.warn {
  border-color: rgba(247, 185, 85, 0.5);
}

.scenario-card.preferred {
  box-shadow: inset 0 0 0 1px rgba(108, 183, 255, 0.42), 0 14px 30px rgba(0, 0, 0, 0.18);
}

.scenario-card header {
  min-height: 74px;
  display: grid;
  gap: 4px;
  margin-bottom: 10px;
}

.scenario-card header span,
.scenario-values span {
  color: var(--muted);
  font-size: 12px;
}

.scenario-card header strong {
  font-size: 18px;
  line-height: 1.25;
}

.scenario-card header em {
  width: fit-content;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border-radius: 8px;
  background: #20242c;
  color: #dce4ed;
  font-style: normal;
  font-size: 12px;
  font-weight: 800;
}

.scenario-card.good header em {
  color: var(--green);
}

.scenario-card.bad header em {
  color: var(--red);
}

.scenario-card.warn header em {
  color: var(--amber);
}

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

.scenario-values div {
  min-height: 72px;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid rgba(48, 54, 64, 0.8);
  background: #0f1319;
}

.scenario-values strong {
  display: block;
  margin-top: 8px;
  color: #f5f7fa;
  font-size: 14px;
  line-height: 1.32;
  overflow-wrap: anywhere;
}

.scenario-card p {
  min-height: 48px;
  margin: 10px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: #dce4ed;
  line-height: 1.45;
}

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

.agent-terminal {
  padding: 16px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1117;
  box-shadow: var(--shadow);
}

.agent-stage-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.agent-stage {
  min-height: 58px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.stage-dot {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 3px solid var(--blue);
  background: transparent;
}

.agent-stage.done .stage-dot {
  border-color: var(--green);
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(50, 213, 131, 0.12);
}

.agent-stage.active .stage-dot {
  box-shadow: 0 0 0 5px rgba(108, 183, 255, 0.12);
}

.agent-stage.bad .stage-dot {
  border-color: var(--red);
  background: var(--red);
  box-shadow: 0 0 0 5px rgba(255, 100, 124, 0.12);
}

.agent-stage.bad {
  border-color: rgba(255, 100, 124, 0.42);
}

.agent-stage strong,
.agent-stage p {
  display: block;
  margin: 0;
}

.agent-stage strong {
  font-size: 14px;
}

.agent-stage p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.agent-diagnostics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.agent-diagnostics article,
.forecast-grid article,
.decision-card,
.tree-visual {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.agent-diagnostics article {
  min-height: 60px;
  padding: 10px;
}

.agent-diagnostics span,
.forecast-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.agent-diagnostics strong,
.forecast-grid strong {
  display: block;
  margin-top: 7px;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.agent-workbench {
  display: grid;
  grid-template-columns: minmax(360px, 0.34fr) minmax(0, 1fr);
  gap: 12px;
}

.agent-chart-panel,
.agent-analysis-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b1016;
}

.agent-chart-panel {
  padding: 14px;
}

#agentCandleChart {
  width: 100%;
  height: 560px;
  display: block;
}

.agent-analysis-panel {
  padding: 0;
  overflow: hidden;
}

.agent-tabs {
  display: flex;
  gap: 0;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
}

.agent-tabs button {
  min-height: 42px;
  padding: 0 14px;
  color: var(--muted);
  background: transparent;
  border-right: 1px solid var(--line);
  white-space: nowrap;
}

.agent-tabs button.active {
  color: var(--text);
  background: #121821;
  box-shadow: inset 0 -2px 0 var(--blue);
}

.agent-tab-panel {
  display: none;
  min-height: 516px;
  padding: 16px;
}

.agent-tab-panel.active {
  display: block;
}

.agent-tab-panel h3 {
  margin: 0 0 10px;
  font-size: 18px;
}

.agent-tab-panel p {
  margin: 0;
  line-height: 1.65;
}

.muted-copy {
  color: var(--muted);
  font-size: 13px;
}

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

.forecast-grid article {
  min-height: 62px;
  padding: 10px;
}

.forecast-grid strong {
  color: var(--green);
  text-align: center;
}

.agent-direction {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
  color: var(--green);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #121821;
  font-weight: 800;
}

.decision-card {
  padding: 14px;
  color: #e8edf4;
  line-height: 1.65;
}

.tree-visual {
  min-height: 220px;
  padding: 16px;
  display: grid;
  gap: 10px;
}

.tree-node {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #121821;
  color: #e8edf4;
}

.tree-node.good {
  border-color: rgba(50, 213, 131, 0.44);
}

.tree-node.warn {
  border-color: rgba(247, 185, 85, 0.48);
}

.tree-node.bad {
  border-color: rgba(255, 100, 124, 0.46);
}

#agentTreeList {
  margin: 0;
  padding-left: 20px;
  color: #e8edf4;
  line-height: 1.7;
}

#agentRawData,
#agentDebugData {
  min-height: 420px;
  max-height: 520px;
  margin: 0;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #070b10;
  color: #dce4ed;
  font-size: 12px;
  line-height: 1.55;
}

.metric {
  min-height: 82px;
  padding: 13px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric span,
.metric strong {
  display: block;
}

.metric strong {
  margin-top: 9px;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.chart-panel {
  padding: 16px;
  margin-bottom: 14px;
}

.chart-heading {
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
}

.chart-heading h3 {
  font-size: 17px;
}

.chart-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  font-size: 13px;
}

.chart-stats span {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  background: #12161c;
  border: 1px solid var(--line);
  border-radius: 8px;
}

#priceChart {
  width: 100%;
  height: 320px;
  display: block;
}

.advisor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  gap: 14px;
}

.advisor-panel {
  min-height: 220px;
  padding: 16px;
}

.advice-list {
  margin: 0;
  padding-left: 20px;
  color: #e8edf4;
  line-height: 1.65;
}

.advice-list li + li {
  margin-top: 7px;
}

.event-log {
  max-height: 180px;
  overflow: auto;
  display: grid;
  gap: 8px;
}

.event-log p {
  margin: 0;
  color: var(--muted);
}

.admin-shell {
  min-height: 100vh;
  background: var(--bg);
}

.admin-main {
  width: min(1180px, 100%);
  display: grid;
  gap: 14px;
  margin: 0 auto;
  padding: 20px;
}

.admin-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) 96px;
  gap: 10px;
  align-items: end;
}

.admin-form label {
  display: grid;
  gap: 6px;
}

.admin-form span {
  color: var(--muted);
  font-size: 13px;
}

.admin-form input {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #0f1319;
}

.admin-output {
  min-height: 120px;
  margin: 12px 0 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #dce4ed;
  background: #0f1319;
}

.admin-table-wrap {
  overflow: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

.admin-table th,
.admin-table td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.admin-table th {
  color: var(--muted);
  font-size: 13px;
}

.log-item {
  padding: 10px;
  border-radius: 8px;
  background: #12161c;
  border: 1px solid var(--line);
  color: #dce4ed;
  line-height: 1.4;
}

.log-item time {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.risk-note {
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  background: #0e1014;
  font-size: 13px;
  line-height: 1.55;
}

.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 10px;
  z-index: 40;
}

.toast {
  width: min(360px, calc(100vw - 36px));
  padding: 13px 14px;
  border-radius: 8px;
  background: #f5f7fa;
  color: #101216;
  box-shadow: var(--shadow);
  font-weight: 750;
}

.auth-locked .agent-toolbar,
.auth-locked .dashboard,
.auth-locked .risk-note {
  pointer-events: none;
  user-select: none;
  filter: blur(2px);
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(9, 11, 14, 0.78);
}

.auth-overlay.visible {
  display: flex;
}

.auth-card {
  width: min(460px, 100%);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #151a21;
  box-shadow: var(--shadow);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.auth-brand h2,
.auth-brand p,
.redeem-panel h3,
.redeem-panel p {
  margin: 0;
}

.auth-brand h2 {
  font-size: 22px;
}

.auth-brand p,
.redeem-panel p {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.45;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  padding: 4px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10141a;
}

.auth-tabs button {
  min-height: 36px;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.auth-tabs button.active {
  color: #07130d;
  background: var(--green);
}

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

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

.auth-form span {
  color: var(--muted);
  font-size: 13px;
}

.auth-form input,
.redeem-form input {
  min-height: 42px;
  width: 100%;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #0f1319;
}

.auth-form input:focus,
.redeem-form input:focus {
  outline: none;
  border-color: var(--blue);
}

.auth-submit {
  margin-top: 4px;
}

.auth-message {
  min-height: 22px;
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.45;
}

.auth-message.good {
  color: var(--green);
}

.auth-message.warn {
  color: var(--amber);
}

.auth-message.bad {
  color: var(--red);
}

.redeem-panel {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.redeem-panel[hidden],
.auth-tabs[hidden],
.auth-form[hidden],
.auth-nickname-row[hidden] {
  display: none;
}

.redeem-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 88px;
  gap: 8px;
}

@media (max-width: 980px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .agent-status-line {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .watch-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .agent-stage-grid,
  .agent-diagnostics,
  .insight-grid,
  .metric-grid,
  .plan-grid,
  .advisor-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

  #agentCandleChart {
    height: 420px;
  }

  .plan-cell.wide {
    grid-column: span 2;
  }
}

@media (max-width: 640px) {
  .topbar,
  .agent-toolbar,
  .market-view,
  .watch-panel {
    padding-left: 14px;
    padding-right: 14px;
  }

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

  .connection-pill,
  .member-pill,
  .updated-at {
    justify-content: center;
    min-width: 0;
    font-size: 12px;
  }

  .member-pill,
  .connection-pill {
    grid-column: span 2;
    max-width: none;
  }

  .header-auth-button,
  .icon-button {
    width: 100%;
  }

  .redeem-form {
    grid-template-columns: 1fr;
  }

  .admin-main {
    padding: 14px;
  }

  .admin-form {
    grid-template-columns: 1fr;
  }

  .watch-list,
  .agent-stage-grid,
  .agent-diagnostics,
  .forecast-grid,
  .insight-grid,
  .insight-values,
  .scenario-edge,
  .scenario-grid,
  .metric-grid,
  .advisor-grid,
  .plan-grid,
  .signal-strip {
    grid-template-columns: 1fr;
  }

  .scenario-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .scenario-values {
    grid-template-columns: 1fr;
  }

  .plan-cell.wide {
    grid-column: auto;
  }

  .market-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .price-block {
    align-items: flex-start;
  }

  .market-header h2,
  .price-block span {
    font-size: 28px;
  }

  #priceChart {
    height: 260px;
  }

  #agentCandleChart {
    height: 360px;
  }

  .agent-controls label:not(.switch-row) {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .agent-controls input,
  .agent-controls select,
  .agent-controls .primary-button,
  .agent-controls .ghost-button,
  .switch-row {
    width: 100%;
  }
}
