:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #111827;
  --muted: #64748b;
  --line: #d9dee7;
  --red: #d93025;
  --green: #17803b;
  --blue: #2563eb;
  --amber: #b45309;
  --soft-blue: #eaf1ff;
  --soft-red: #fff0f0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  line-height: 1.45;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 7px 13px;
  cursor: pointer;
}

button:hover {
  border-color: #aab4c3;
}

button.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

input,
select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 7px 10px;
}

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

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 28px 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

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

h1 {
  font-size: 24px;
  font-weight: 700;
}

h2 {
  font-size: 17px;
  font-weight: 700;
}

h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 8px;
}

#subtitle,
footer,
.small-note {
  color: var(--muted);
  font-size: 13px;
}

.toolbar,
.filters,
.stock-form,
.recommend-form,
.extreme-form,
.batch-form {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

main {
  width: min(1480px, calc(100vw - 32px));
  margin: 18px auto 28px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.tab {
  min-width: 92px;
}

.tab.active {
  border-color: var(--blue);
  background: var(--soft-blue);
  color: var(--blue);
}

.tab-panel {
  display: none;
}

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

.hidden {
  display: none !important;
}

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

.metric,
.plan-prices > div {
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px 14px;
  display: grid;
  align-content: center;
  gap: 4px;
}

.metric span,
.plan-prices span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong,
.plan-prices strong {
  font-size: 24px;
}

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

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

.status {
  min-height: 30px;
  color: var(--muted);
  font-size: 13px;
  padding: 5px 0;
}

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

.status.ok {
  color: var(--green);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 1320px;
  border-collapse: collapse;
  background: #fff;
  font-size: 13px;
}

#extremeTable {
  min-width: 1540px;
}

#aiRecommendTable {
  min-width: 1280px;
}

th,
td {
  border-bottom: 1px solid #edf0f5;
  padding: 9px 10px;
  text-align: left;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: #f9fbff;
}

.score-cell {
  display: grid;
  grid-template-columns: 36px minmax(74px, 1fr);
  align-items: center;
  gap: 8px;
}

.score-bar {
  height: 7px;
  border-radius: 99px;
  background: #e5e7eb;
  overflow: hidden;
}

.score-bar i {
  display: block;
  height: 100%;
  background: var(--blue);
}

.tag-strong {
  color: var(--red);
  font-weight: 700;
}

.tag-mid {
  color: var(--amber);
  font-weight: 700;
}

.tag-watch {
  color: var(--blue);
  font-weight: 700;
}

.analysis-grid {
  display: grid;
  grid-template-columns: minmax(0, 2.15fr) minmax(300px, 0.85fr);
  grid-template-areas:
    "chart side"
    "plan plan"
    "ai ai";
  gap: 14px;
}

.analysis-grid.hidden {
  display: none;
}

.chart-panel {
  grid-area: chart;
}

.side-panel {
  grid-area: side;
}

.plan-panel {
  grid-area: plan;
}

.ai-panel {
  grid-area: ai;
}

#klineCanvas {
  width: 100%;
  height: 520px;
  display: block;
  background: #fff;
  border: 1px solid #edf0f5;
  border-radius: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 99px;
  background: var(--soft-blue);
  color: var(--blue);
  padding: 0 10px;
  font-size: 13px;
  font-weight: 700;
}

.score-ring {
  width: 148px;
  height: 148px;
  border-radius: 50%;
  margin: 14px auto 18px;
  display: grid;
  place-items: center;
  color: var(--text);
  font-size: 34px;
  font-weight: 800;
  background:
    radial-gradient(circle at center, #fff 0 56%, transparent 57%),
    conic-gradient(var(--red) var(--score-deg, 0deg), #edf0f5 0);
}

.breakdown {
  display: grid;
  gap: 10px;
}

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

.breakdown-bar {
  height: 8px;
  border-radius: 99px;
  overflow: hidden;
  background: #edf0f5;
}

.breakdown-bar i {
  display: block;
  height: 100%;
  background: var(--blue);
}

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

ul {
  margin: 0;
  padding-left: 18px;
}

li {
  margin: 6px 0;
}

.risk-notes {
  margin-top: 12px;
  color: var(--amber);
  font-size: 13px;
}

.ai-result {
  display: grid;
  gap: 12px;
}

.ai-headline {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.ai-headline strong {
  font-size: 22px;
}

.ai-headline span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 9px;
  color: var(--muted);
  font-size: 13px;
}

#aiSummary {
  color: var(--text);
}

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

.ai-levels {
  display: grid;
  gap: 8px;
}

.ai-levels div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #edf0f5;
  padding-bottom: 7px;
}

.ai-levels span {
  color: var(--muted);
}

.ai-action {
  border-left: 3px solid var(--blue);
  background: var(--soft-blue);
  padding: 10px 12px;
  color: #1e3a8a;
  font-size: 13px;
}

#batchProgress,
#recommendProgress,
#aiRecommendProgress,
#extremeProgress {
  color: var(--muted);
  padding-bottom: 8px;
}

.extreme-form label {
  min-width: 116px;
}

.extreme-type {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-weight: 700;
}

.extreme-type.high {
  background: var(--soft-red);
  color: var(--red);
}

.extreme-type.low {
  background: #eaf8ef;
  color: var(--green);
}

footer {
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto 28px;
}

@media (max-width: 920px) {
  .app-header,
  .toolbar,
  .stock-form,
  .recommend-form,
  .extreme-form,
  .batch-form,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .metrics,
  .plan-prices,
  .plan-text,
  .ai-grid,
  .analysis-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "chart"
      "side"
      "plan"
      "ai";
  }

  .tabs {
    overflow-x: auto;
  }

  #klineCanvas {
    height: 430px;
  }
}
