:root {
  --bg: #eef1f4;
  --surface: #f8fafb;
  --ink: #172026;
  --muted: #66737d;
  --line: #d7dde2;
  --accent: #0f8b8d;
  --accent-strong: #0a6768;
  --danger: #b84040;
  --warn: #a7651a;
  --buy: #157a55;
  --sell: #7b5aa6;
  --shadow: 0 18px 60px rgba(27, 40, 50, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  overflow: hidden;
}

.shell {
  display: grid;
  gap: 12px;
  grid-template-rows: auto auto minmax(0, 1fr);
  height: 100svh;
  overflow: hidden;
  padding: 16px;
}

.topbar {
  align-items: end;
  display: flex;
  justify-content: space-between;
  margin: 0 auto;
  max-width: 1420px;
  width: 100%;
}

.workspace-nav {
  background: rgba(248, 250, 251, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: flex;
  gap: 6px;
  margin: 0 auto;
  max-width: 1420px;
  overflow-x: auto;
  padding: 8px;
  position: relative;
  z-index: 5;
  width: 100%;
}

.nav-tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  flex: 0 0 auto;
  height: 36px;
  padding: 0 12px;
}

.nav-tab:hover,
.nav-tab.active {
  background: #fff;
  border-color: rgba(15, 139, 141, 0.28);
  color: var(--accent-strong);
  transform: none;
}

.workspace-view {
  display: none;
  height: 100%;
  margin: 0 auto;
  max-width: 1420px;
  min-height: 0;
  overflow: hidden;
  width: 100%;
}

.workspace-view.active {
  animation: viewEnter 180ms ease;
  display: block;
}

.workspace-view[hidden] {
  display: none !important;
}

@keyframes viewEnter {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.eyebrow {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  margin: 0 0 4px;
}

h1,
h2 {
  letter-spacing: 0;
  margin: 0;
}

h1 {
  font-size: clamp(24px, 2.8vw, 36px);
  line-height: 1;
}

h2 {
  font-size: 16px;
}

.status {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  min-width: 132px;
  padding: 10px 14px;
  text-align: center;
}

.status.loading {
  color: var(--accent-strong);
}

.status.error {
  color: var(--danger);
}

.workspace {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(250px, 300px) 1fr;
  height: 100%;
  margin: 0;
  max-width: none;
  min-height: 0;
}

.control-panel,
.report,
.detail-panel,
.decision-panel,
.flow-panel,
.score-strip {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.control-panel {
  align-self: start;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
  padding: 14px;
}

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

form label:nth-child(3),
form label:nth-child(8),
form .form-actions {
  grid-column: 1 / -1;
}

label {
  color: var(--muted);
  display: grid;
  font-size: 12px;
  gap: 5px;
}

input,
select,
textarea {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
  outline: none;
  padding: 0 12px;
}

input,
select {
  height: 32px;
}

textarea {
  min-height: 72px;
  padding: 10px 12px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 139, 141, 0.14);
}

button {
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  height: 34px;
  transition: transform 160ms ease, background 160ms ease;
}

button:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
  transform: none;
}

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

.secondary-action {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--accent-strong);
}

.secondary-action:hover {
  background: #eef6f6;
  border-color: rgba(15, 139, 141, 0.32);
  color: var(--accent-strong);
}

input:disabled {
  background: #edf1f3;
  color: var(--muted);
}

.meta-panel {
  border-top: 1px solid var(--line);
  min-height: 0;
  overflow: auto;
  padding-top: 12px;
}

dl {
  display: grid;
  gap: 7px;
  margin: 10px 0 0;
}

dl div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

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

dd {
  margin: 0;
  text-align: right;
}

.results {
  display: grid;
  gap: 12px;
  min-height: 0;
}

.score-strip {
  display: grid;
  gap: 1px;
  grid-template-columns: repeat(2, 1fr);
  overflow: hidden;
}

.score-strip div {
  align-items: center;
  background: #fff;
  display: flex;
  justify-content: space-between;
  min-height: 0;
  padding: 12px 16px;
}

.score-strip span {
  color: var(--muted);
}

.score-strip strong {
  color: var(--accent-strong);
  font-size: 28px;
  line-height: 1;
}

#analysis-view .results {
  grid-template-areas:
    "flow reports"
    "score reports"
    "chart reports"
    "decision reports";
  grid-template-columns: minmax(0, 0.95fr) minmax(520px, 1.05fr);
  grid-template-rows: 70px 56px minmax(0, 1fr) 190px;
}

#analysis-view .flow-panel {
  grid-area: flow;
}

#analysis-view .score-strip {
  grid-area: score;
}

#analysis-view .chart-panel {
  grid-area: chart;
}

#analysis-view .decision-panel {
  grid-area: decision;
}

#analysis-view .report-grid {
  grid-area: reports;
}

.flow-panel {
  overflow: hidden;
}

.flow-head {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 8px 12px;
}

.flow-head span {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.screener-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
  overflow: hidden;
}

.review-panel,
.alert-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  height: 100%;
  overflow: hidden;
}

.review-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.alert-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) minmax(90px, 0.34fr);
}

.screener-head {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 10px 14px;
}

.review-head,
.alert-head {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 10px 14px;
}

.review-actions {
  display: flex;
  gap: 10px;
}

.screener-head span {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

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

.screener-sidebar {
  background: #fff;
  display: grid;
  grid-template-rows: auto auto auto minmax(110px, 0.7fr) minmax(100px, 0.65fr);
  min-height: 0;
  overflow: auto;
}

.screener-results {
  background: #fff;
  display: grid;
  grid-template-rows: minmax(0, 1fr) minmax(130px, 0.32fr);
  min-height: 0;
  overflow: hidden;
}

.screener-tools,
.watchlist-tools {
  align-items: stretch;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
  padding: 12px;
}

.watchlist-tools {
  grid-template-columns: 1fr 1fr;
}

.watchlist-tools button {
  grid-column: 1 / -1;
}

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

.custom-universe {
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 12px;
}

.custom-universe textarea {
  min-height: 86px;
}

.alert-tools {
  align-items: end;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(140px, 1fr) minmax(130px, 0.9fr) minmax(100px, 0.7fr) minmax(140px, 1fr) minmax(100px, 0.7fr);
  padding: 10px 12px;
}

.review-grid {
  display: grid;
  gap: 1px;
  height: 100%;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-height: 0;
}

.review-grid > div {
  background: #fff;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.review-grid h3 {
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  margin: 0;
  padding: 12px 14px;
}

.watchlist {
  align-items: center;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 0;
  overflow: auto;
  padding: 10px 12px;
}

.industry-list {
  align-content: start;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-height: 0;
  overflow: auto;
  padding: 10px 12px;
}

.industry-chip {
  align-items: center;
  background: #f4f7f8;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  font-size: 12px;
  gap: 5px;
  height: 28px;
  padding: 0 7px;
}

.industry-chip:hover,
.industry-chip.active {
  border-color: rgba(15, 139, 141, 0.34);
  color: var(--accent-strong);
}

.industry-chip small {
  color: var(--muted);
}

.watch-chip {
  align-items: center;
  background: #f4f7f8;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  display: inline-flex;
  gap: 7px;
  height: 34px;
  padding: 0 8px;
}

.watch-chip small {
  color: var(--muted);
}

.watch-chip b {
  color: var(--danger);
  font-size: 16px;
  line-height: 1;
}

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

.screen-table-wrap {
  min-height: 0;
  overflow: auto;
}

.mini-table-wrap {
  height: 100%;
  min-height: 0;
  overflow: auto;
}

.screen-table-wrap table {
  min-width: 960px;
}

.link-button {
  background: transparent;
  border: 0;
  color: var(--accent-strong);
  font-weight: 700;
  height: auto;
  padding: 0;
  text-align: left;
}

.link-button:hover {
  background: transparent;
  transform: none;
}

.link-button small {
  color: var(--muted);
  font-weight: 500;
}

.screen-ai-summary {
  border-top: 1px solid var(--line);
  max-height: none;
  min-height: 0;
}

.mini-button {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--accent-strong);
  font-size: 12px;
  height: 30px;
  margin-left: 6px;
  padding: 0 8px;
}

.mini-button:hover {
  background: #eef6f6;
  transform: none;
}

.flow-graph {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 8px 10px;
}

.flow-node {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  flex: 0 0 210px;
  gap: 8px;
  grid-template-columns: auto 1fr;
  min-height: 58px;
  padding: 8px;
  position: relative;
}

.flow-node:not(:last-child)::after {
  background: var(--line);
  content: "";
  height: 2px;
  position: absolute;
  right: -15px;
  top: 50%;
  width: 15px;
}

.flow-index {
  align-items: center;
  background: #eef3f4;
  border-radius: 999px;
  color: var(--muted);
  display: flex;
  font-size: 12px;
  font-weight: 700;
  height: 24px;
  justify-content: center;
  width: 24px;
}

.flow-title {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.flow-title strong {
  font-size: 13px;
  line-height: 1.35;
}

.flow-title span {
  border-radius: 999px;
  font-size: 12px;
  padding: 3px 7px;
}

.flow-body p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  margin: 3px 0 0;
  word-break: break-word;
}

.flow-node.success {
  border-color: rgba(21, 122, 85, 0.45);
}

.flow-node.success .flow-index,
.flow-node.success .flow-title span {
  background: rgba(21, 122, 85, 0.12);
  color: var(--buy);
}

.flow-node.error {
  border-color: rgba(184, 64, 64, 0.5);
}

.flow-node.error .flow-index,
.flow-node.error .flow-title span {
  background: rgba(184, 64, 64, 0.12);
  color: var(--danger);
}

.flow-node.warn {
  border-color: rgba(167, 101, 26, 0.5);
}

.flow-node.warn .flow-index,
.flow-node.warn .flow-title span {
  background: rgba(167, 101, 26, 0.13);
  color: var(--warn);
}

.flow-node.pending .flow-index,
.flow-node.pending .flow-title span {
  background: rgba(15, 139, 141, 0.1);
  color: var(--accent-strong);
}

.flow-empty {
  color: var(--muted);
  padding: 8px 2px;
}

.chart-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.chart-head {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 10px 14px;
}

.chart-head span {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.chart-wrap {
  background: #fff;
  height: calc(100% - 45px);
  min-height: 0;
  padding: 10px;
}

#kline-chart {
  display: block;
  height: 100%;
  width: 100%;
}

.decision-panel {
  overflow: hidden;
}

.decision-head {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 10px 14px;
}

.decision-head span {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.decision-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
  height: calc(100% - 45px);
  min-height: 0;
  overflow: auto;
  padding: 12px;
}

.decision-engine {
  background: #fff;
  border: 1px solid rgba(15, 139, 141, 0.22);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  padding: 10px;
}

.engine-main {
  align-items: baseline;
  display: grid;
  gap: 6px;
  grid-template-columns: 1fr auto auto;
}

.engine-main span {
  color: var(--accent-strong);
  font-weight: 800;
}

.engine-main strong {
  color: var(--accent-strong);
  font-size: 24px;
  line-height: 1;
}

.engine-main small {
  color: var(--muted);
}

.engine-metrics {
  display: grid;
  gap: 1px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  overflow: hidden;
}

.engine-metrics div {
  background: #f4f7f8;
  display: grid;
  gap: 3px;
  padding: 6px 7px;
}

.engine-metrics span,
.engine-factors span {
  color: var(--muted);
  font-size: 12px;
}

.engine-metrics strong {
  font-size: 15px;
}

.engine-factors {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.factor {
  background: #f4f7f8;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 7px;
}

.factor-buy {
  border-color: rgba(21, 122, 85, 0.32);
  color: var(--buy);
}

.factor-risk {
  border-color: rgba(184, 64, 64, 0.34);
  color: var(--danger);
}

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

.decision-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 139, 141, 0.14);
}

.decision-card-head {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.decision-card h3 {
  font-size: 15px;
  margin: 0;
}

.decision-card-head span {
  background: rgba(15, 139, 141, 0.1);
  border-radius: 999px;
  color: var(--accent-strong);
  font-size: 12px;
  padding: 4px 8px;
}

.decision-primary,
.decision-stance {
  margin: 0;
}

.decision-primary {
  color: var(--ink);
  font-weight: 700;
}

.decision-stance {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

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

.level {
  background: #f4f7f8;
  border-left: 3px solid var(--line);
  border-radius: 6px;
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 6px 8px;
}

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

.level strong {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
}

.level-buy {
  border-left-color: var(--buy);
}

.level-sell {
  border-left-color: var(--sell);
}

.level-risk {
  border-left-color: var(--danger);
}

.level-watch {
  border-left-color: var(--warn);
}

.empty-state {
  color: var(--muted);
  padding: 8px 2px;
}

.report-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
  grid-template-rows: repeat(2, minmax(0, 1fr));
  min-height: 0;
}

.report {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
  overflow: hidden;
}

.report-head {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 9px 12px;
}

.report-head span {
  background: rgba(15, 139, 141, 0.1);
  border-radius: 999px;
  color: var(--accent-strong);
  font-size: 13px;
  max-width: 52%;
  overflow: hidden;
  padding: 6px 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

pre {
  color: #25313a;
  font-family: "SFMono-Regular", Consolas, "Microsoft YaHei", monospace;
  font-size: 14px;
  line-height: 1.65;
  margin: 0;
  overflow: auto;
  padding: 14px 16px;
  white-space: pre-wrap;
}

.detail-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.detail-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: minmax(0, 1fr) minmax(0, 0.86fr);
  height: 100%;
  min-height: 0;
}

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

.detail-panel h2 {
  border-bottom: 1px solid var(--line);
  padding: 10px 14px;
}

.table-wrap {
  height: 100%;
  min-height: 0;
  overflow: auto;
}

table {
  border-collapse: collapse;
  min-width: 720px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
  text-align: right;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

tr:last-child td {
  border-bottom: 0;
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .shell {
    height: auto;
    min-height: 100vh;
    overflow: visible;
    padding: 18px;
  }

  .workspace-view,
  .workspace,
  .screener-panel,
  .review-panel,
  .alert-panel,
  .detail-grid {
    height: auto;
    overflow: visible;
  }

  #analysis-view .results {
    grid-template-areas:
      "flow"
      "score"
      "decision"
      "chart"
      "reports";
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .topbar,
  .workspace,
  .detail-grid,
  .report-grid,
  .decision-grid,
  .screener-tools,
  .watchlist-tools,
  .alert-tools,
  .review-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: start;
    display: grid;
    gap: 14px;
  }

  .control-panel {
    position: static;
  }
}

@media (max-width: 620px) {
  .score-strip {
    grid-template-columns: 1fr;
  }
}
