:root {
  color-scheme: dark;
  --bg: #060807;
  --panel: #0d1210;
  --panel-2: #141a17;
  --line: #27322d;
  --line-soft: #1b241f;
  --text: #eef4ec;
  --muted: #93a197;
  --green: #2dd36f;
  --red: #ff5c5c;
  --amber: #f5b84b;
  --cyan: #5bc7e8;
  --ink: #050706;
  font-family: "IBM Plex Sans Condensed", "Aptos Narrow", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    var(--bg);
  background-size: 28px 28px;
  color: var(--text);
}

.terminal {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 48px auto auto auto 1fr;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(6, 8, 7, 0.96);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.brand span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 26px;
  border: 1px solid #52645b;
  background: var(--panel-2);
  font-weight: 900;
}

.run-meta,
.status-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.run-meta span,
.status-strip div {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 6px 9px;
}

.history-nav {
  display: grid;
  grid-template-columns: minmax(130px, 0.4fr) minmax(170px, 0.4fr);
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 14, 12, 0.82);
}

.history-title,
.progress-head,
.progress-meta,
.history-nav select {
  border: 1px solid var(--line);
  background: var(--panel);
}

.history-title {
  padding: 6px 9px;
}

.history-title span,
.progress-head span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.history-title strong {
  display: block;
  margin-top: 2px;
  color: var(--text);
  font-size: 14px;
}

.history-nav select {
  width: 100%;
  min-height: 34px;
  padding: 6px 8px;
  color: var(--text);
  font: inherit;
}

.progress-panel {
  display: grid;
  grid-template-columns: minmax(240px, 0.7fr) minmax(220px, 1fr) minmax(180px, 0.4fr);
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 11, 9, 0.92);
}

.progress-head {
  padding: 8px 10px;
}

.progress-head strong {
  display: block;
  margin: 3px 0;
  color: var(--text);
  font-size: 16px;
}

.progress-meter {
  height: 13px;
  border: 1px solid var(--line);
  background: #080c0a;
}

.progress-meter span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--green));
  transition: width 0.3s ease;
}

.progress-meta {
  display: grid;
  gap: 4px;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 12px;
}

.progress-panel[data-status="complete"] .progress-meter span {
  background: var(--green);
}

.progress-panel[data-status="failed"] .progress-meter span {
  background: var(--red);
}

.performance-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 12, 10, 0.9);
}

.performance-card {
  display: grid;
  min-width: 0;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 9px 10px;
}

.performance-card-head {
  display: flex;
  min-width: 0;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.performance-card-head span {
  display: block;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
}

.performance-card-head strong {
  display: block;
  flex: 0 0 auto;
  font-size: 14px;
  white-space: nowrap;
}

.performance-card.best .performance-card-head strong,
.performance-return.positive {
  color: var(--green);
}

.performance-card.worst .performance-card-head strong,
.performance-return.negative {
  color: var(--red);
}

.performance-list {
  display: grid;
  gap: 5px;
}

.performance-row {
  display: grid;
  grid-template-columns: 22px minmax(82px, 1fr) minmax(132px, 0.9fr) auto;
  min-width: 0;
  align-items: center;
  gap: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--line-soft);
}

.performance-rank {
  display: inline-grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.performance-identity,
.performance-basis {
  min-width: 0;
}

.performance-identity b,
.performance-identity small,
.performance-basis {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.performance-identity b {
  color: var(--text);
  font-size: 13px;
}

.performance-identity small,
.performance-basis,
.performance-empty {
  color: var(--muted);
  font-size: 11px;
}

.performance-return {
  justify-self: end;
  font-size: 13px;
  white-space: nowrap;
}

.strategy-panel {
  display: grid;
  grid-template-columns: minmax(220px, 0.72fr) repeat(2, minmax(260px, 1fr));
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 12, 10, 0.9);
}

.strategy-head,
.strategy-card {
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 9px 10px;
}

.strategy-head span,
.strategy-card > strong {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.strategy-head strong {
  display: block;
  margin: 4px 0;
  color: var(--text);
  font-size: 15px;
}

.strategy-head small {
  color: var(--muted);
  line-height: 1.45;
}

.strategy-list {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.strategy-item {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) auto;
  min-width: 0;
  align-items: start;
  gap: 4px 8px;
  padding-top: 6px;
  border-top: 1px solid var(--line-soft);
}

.strategy-item span,
.strategy-item small {
  min-width: 0;
  overflow-wrap: anywhere;
}

.strategy-item span {
  color: var(--text);
  font-weight: 800;
}

.strategy-item small {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 11px;
}

.strategy-item b {
  padding: 2px 6px;
  border: 1px solid var(--line-soft);
  font-size: 11px;
  white-space: nowrap;
}

.strategy-item b.needed {
  color: var(--yellow);
}

.strategy-item b.partial {
  color: var(--cyan);
}

.watchlist-panel,
.memory-panel {
  display: grid;
  grid-template-columns: minmax(240px, 0.55fr) minmax(320px, 1.45fr);
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 12, 10, 0.9);
}

.panel-head,
.watchlist-editor,
.memory-browser {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 9px 10px;
}

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

.panel-head strong {
  display: block;
  margin: 4px 0;
  font-size: 15px;
}

.watchlist-editor {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 8px;
}

.watchlist-editor textarea,
.memory-browser select {
  width: 100%;
  border: 1px solid var(--line);
  background: #080c0a;
  color: var(--text);
  font: inherit;
}

.watchlist-editor textarea {
  min-height: 86px;
  resize: vertical;
  padding: 8px;
}

.watchlist-actions {
  display: grid;
  align-content: start;
  gap: 7px;
}

.watchlist-actions button {
  min-width: 84px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 7px 9px;
  font: inherit;
  font-weight: 800;
}

.memory-browser {
  display: grid;
  gap: 8px;
}

.memory-browser select {
  min-height: 34px;
  padding: 6px 8px;
}

.memory-records {
  display: grid;
  max-height: 220px;
  overflow: auto;
  gap: 7px;
}

.memory-record {
  border: 1px solid var(--line-soft);
  background: rgba(20, 26, 23, 0.62);
  padding: 8px;
}

.memory-record strong {
  display: block;
  margin-bottom: 4px;
}

.memory-record p {
  margin: 4px 0;
  color: var(--text);
  white-space: normal;
}

.decision-panel {
  display: grid;
  grid-template-columns: minmax(280px, 1.2fr) minmax(320px, 2fr);
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(9, 13, 11, 0.9);
}

.decision-panel > div {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 9px 10px;
}

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

.decision-panel strong {
  display: block;
  margin: 4px 0;
  color: var(--text);
  font-size: 15px;
}

.factor-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}

.factor {
  border-left: 3px solid var(--muted);
}

.factor b {
  display: block;
  color: var(--text);
}

.factor.supportive {
  border-left-color: var(--green);
}

.factor.risk {
  border-left-color: var(--red);
}

.factor.neutral {
  border-left-color: var(--amber);
}

.theme-panel {
  display: grid;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 10, 9, 0.88);
}

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

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

.theme-head strong {
  color: var(--green);
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 10px;
}

.theme-card {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  background: rgba(13, 18, 16, 0.78);
  padding: 10px;
}

.theme-card header strong {
  display: block;
  margin-top: 3px;
  color: var(--text);
  font-size: 15px;
}

.theme-card p,
.theme-card ul {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}

.theme-judgment {
  border-left: 3px solid var(--green);
  padding-left: 8px;
}

.theme-card ul {
  padding-left: 18px;
  color: var(--muted);
}

.theme-links {
  display: grid;
  gap: 6px;
}

.theme-links a,
.theme-blocked {
  display: block;
  border: 1px solid var(--line-soft);
  background: rgba(20, 26, 23, 0.62);
  padding: 7px 8px;
  overflow-wrap: anywhere;
}

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

.theme-empty {
  color: var(--amber);
}

.status-strip {
  flex-wrap: wrap;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.status-strip div {
  min-width: 150px;
}

.status-strip span,
small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.table-shell {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line-soft);
  padding: 9px 10px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #0a0e0c;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

td {
  background: rgba(13, 18, 16, 0.72);
  font-size: 13px;
}

td:nth-child(3),
td:nth-child(10),
td:nth-child(11),
td:nth-child(12),
td:nth-child(13) {
  max-width: 420px;
  white-space: normal;
}

td.stock-info-cell {
  min-width: 190px;
}

.stock-name {
  display: block;
  margin-top: 3px;
  color: var(--text);
  font-weight: 700;
}

.stock-description {
  display: block;
  max-width: 300px;
  margin-top: 4px;
  line-height: 1.45;
  white-space: normal;
}

.trade-opinion-cell {
  min-width: 280px;
  max-width: 440px;
  white-space: normal;
}

.trade-opinion-cell span {
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.trade-opinion-cell span:first-child {
  margin-top: 0;
}

.trade-opinion-cell p {
  margin: 2px 0 0;
  line-height: 1.5;
}

td.summary-cell {
  min-width: 520px;
  max-width: 760px;
  white-space: normal;
  line-height: 1.55;
}

a {
  color: var(--cyan);
  text-decoration: none;
}

.badge {
  display: inline-flex;
  min-width: 64px;
  justify-content: center;
  border: 1px solid var(--line);
  padding: 3px 7px;
  background: #101612;
  color: var(--text);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

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

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

.badge.neutral {
  color: var(--amber);
}

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

.selection-reason {
  margin-top: 3px;
}

.watchlist-flag {
  display: inline-flex;
  margin-top: 5px;
  border: 1px solid #3d7b57;
  padding: 2px 6px;
  color: var(--green);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.valuation-list {
  display: grid;
  gap: 3px;
  min-width: 150px;
  color: var(--text);
}

.valuation-list span {
  display: block;
  font-variant-numeric: tabular-nums;
}

.valuation-list small {
  margin-top: 2px;
}

.evidence-list {
  display: grid;
  gap: 8px;
  min-width: 320px;
  max-width: 520px;
}

.evidence-item {
  padding: 7px 8px;
  border: 1px solid var(--line-soft);
  background: rgba(20, 26, 23, 0.62);
}

.evidence-item summary,
.evidence-item p {
  overflow-wrap: anywhere;
  white-space: normal;
}

.evidence-item summary {
  cursor: pointer;
  color: var(--text);
}

.evidence-item summary span {
  margin-right: 6px;
  color: var(--muted);
  font-weight: 800;
}

.evidence-item p {
  margin: 7px 0 5px;
  color: var(--text);
  line-height: 1.5;
}

.evidence-item a {
  font-weight: 800;
}

.history-list {
  min-width: 170px;
}

.history-list summary {
  cursor: pointer;
  color: var(--cyan);
  font-weight: 800;
}

.history-list ul {
  margin: 6px 0 0;
  padding-left: 16px;
  color: var(--text);
}

.history-list li {
  margin: 3px 0;
}

.sparkline {
  width: 118px;
  height: 34px;
}

.sparkline polyline {
  fill: none;
  stroke: var(--cyan);
  stroke-width: 2;
}

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

  .run-meta {
    flex-wrap: wrap;
  }

  .history-nav,
  .progress-panel,
  .performance-panel,
  .strategy-panel,
  .watchlist-panel,
  .memory-panel,
  .watchlist-editor {
    grid-template-columns: 1fr;
  }

  .decision-panel {
    grid-template-columns: 1fr;
  }

  .performance-card-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }

  .performance-row {
    grid-template-columns: 22px minmax(0, 1fr) auto;
  }

  .performance-basis {
    grid-column: 2 / -1;
  }

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

  .strategy-item small {
    grid-column: 1;
  }

  .strategy-item b {
    justify-self: start;
  }

  th,
  td {
    padding: 8px 7px;
  }
}
