:root {
  color-scheme: light;
  --bg: #f3f5f8;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #667085;
  --line: #dbe1ea;
  --soft: #f8fafc;
  --red: #d63b3b;
  --green: #168a63;
  --blue: #2458d3;
  --amber: #b7791f;
  --shadow: 0 12px 34px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 22px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: end;
  margin-bottom: 14px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  letter-spacing: 0;
}

.topbar p,
.section-head p,
.data-note,
footer,
small {
  color: var(--muted);
}

.search-form {
  display: flex;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.stock-input {
  width: 220px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  font-weight: 800;
  outline: none;
}

.analyze-btn,
.period-tabs button,
.chip {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.analyze-btn {
  min-width: 78px;
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.analyze-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.market-tabs {
  display: inline-flex;
  gap: 6px;
  margin-bottom: 14px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.market-tabs button {
  height: 34px;
  min-width: 70px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 900;
}

.market-tabs button.active {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

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

.beginner-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  margin-bottom: 14px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff7ed;
  color: #7c2d12;
  font-size: 13px;
}

.beginner-panel b {
  color: #431407;
}

.quick-title {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.quick-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  padding: 0 12px;
}

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

.watch-panel {
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.watch-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.watch-head b {
  display: block;
  margin-bottom: 3px;
}

.watch-head span,
.empty-hint {
  color: var(--muted);
  font-size: 12px;
}

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

.watch-chip {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.watch-chip button {
  min-height: 36px;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.watch-chip button:first-child {
  padding: 0 10px;
}

.watch-chip button:last-child {
  width: 34px;
  border-left: 1px solid var(--line);
  color: var(--muted);
  font-size: 18px;
}

.watch-chip small {
  margin-left: 6px;
}

.watch-toggle {
  height: 34px;
  min-width: 86px;
  border: 1px solid var(--blue);
  border-radius: 6px;
  background: #eef3ff;
  color: var(--blue);
  cursor: pointer;
  font-weight: 900;
}

.watch-toggle.active {
  border-color: var(--amber);
  background: #fff7ed;
  color: var(--amber);
}

.watch-toggle:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

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

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1.25fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.selected-panel,
.best-panel,
.action-panel,
.rank-panel,
.table-panel,
.bottom-grid .panel {
  padding: 16px;
}

.eyebrow {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.selected-title,
.best-name,
.buy-status {
  font-size: 22px;
}

.selected-heading {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.watch-toggle-inline {
  flex: 0 0 auto;
}

.selected-subtitle {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.current-score-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  align-items: center;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #c7d2fe;
  border-radius: 8px;
  background: #eef3ff;
}

.current-score-card span,
.current-score-card small {
  color: #475467;
  font-size: 12px;
}

.current-score-card b {
  grid-row: span 2;
  color: var(--blue);
  font-size: 34px;
  line-height: 1;
}

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

.metric-grid div {
  min-height: 70px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--soft);
}

.metric-grid span,
.prob-line span,
.score-breakdown span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}

.return-head {
  display: flex !important;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.return-window {
  height: 24px;
  max-width: 76px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.metric-grid b {
  font-size: 18px;
}

.data-note {
  margin-top: 10px;
  min-height: 18px;
  font-size: 12px;
}

.best-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.score-pill {
  display: grid;
  place-items: center;
  width: 92px;
  height: 72px;
  border-radius: 8px;
  background: #eef3ff;
  color: var(--blue);
}

.score-pill b {
  font-size: 32px;
  line-height: 1;
}

.score-pill span {
  font-size: 12px;
  font-weight: 800;
}

.prob-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 13px 0 8px;
  padding: 10px;
  border-radius: 8px;
  background: var(--soft);
}

.prob-line b {
  font-size: 22px;
}

.best-reason,
.buy-message {
  color: #344054;
  font-size: 14px;
  line-height: 1.55;
}

.score-breakdown {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-top: 12px;
}

.score-breakdown div {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.score-breakdown b {
  font-size: 18px;
}

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

.glossary-card {
  padding: 14px;
  background: #fbfcfe;
}

.glossary-card b {
  display: block;
  margin-bottom: 7px;
  font-size: 14px;
}

.glossary-card p {
  color: #475467;
  font-size: 13px;
  line-height: 1.55;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.55fr);
  gap: 14px;
  margin-bottom: 14px;
}

.chart-panel {
  padding: 14px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.section-head h2 {
  font-size: 18px;
}

.period-tabs {
  display: flex;
  gap: 7px;
}

.period-tabs button {
  height: 34px;
  padding: 0 12px;
}

.period-tabs button.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.kline-canvas {
  display: block;
  width: 100%;
  height: 430px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.bar-list {
  display: grid;
  gap: 10px;
}

.rank-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 62px;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}

.rank-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf4;
}

.rank-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.rank-track .positive {
  background: var(--red);
}

.rank-track .negative {
  background: var(--green);
}

.rank-row b {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

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

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

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

td b,
td small {
  display: block;
}

td small {
  margin-top: 4px;
  font-size: 11px;
}

.best-row {
  background: #fff7ed;
}

.selected-row {
  outline: 2px solid rgba(37, 99, 235, 0.45);
  outline-offset: -2px;
}

.bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.evidence-list {
  display: grid;
  gap: 10px;
}

.evidence-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--soft);
}

.evidence-card.risk {
  background: #fff7ed;
}

.evidence-card div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
}

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

.evidence-card p,
.risk-list {
  color: #344054;
  font-size: 13px;
  line-height: 1.55;
}

.risk-list {
  margin: 0;
  padding-left: 18px;
}

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

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

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

footer {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 2px 0;
  font-size: 12px;
}

@media (max-width: 1100px) {
  .topbar,
  .summary-grid,
  .main-grid,
  .bottom-grid,
  .glossary-grid {
    grid-template-columns: 1fr;
  }

  .search-form {
    width: 100%;
  }

  .stock-input {
    width: 100%;
  }

  .market-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
  }
}

@media (max-width: 680px) {
  .app-shell {
    padding: 14px;
  }

  h1 {
    font-size: 22px;
  }

  .search-form,
  .watch-head,
  .selected-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .market-tabs button {
    min-width: 0;
    padding: 0 6px;
  }

  .metric-grid,
  .score-breakdown {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .current-score-card {
    grid-template-columns: 1fr;
  }

  .current-score-card b {
    grid-row: auto;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .kline-canvas {
    height: 360px;
  }

  footer {
    flex-direction: column;
  }
}
