:root {
  --ink: #17201f;
  --muted: #677270;
  --line: #d7dddc;
  --surface: #ffffff;
  --canvas: #f4f7f6;
  --green: #176653;
  --green-soft: #e3f0eb;
  --blue: #315f92;
  --blue-soft: #e9f0f7;
  --red: #a94747;
  --red-soft: #f8eaea;
  --amber: #96641d;
  --amber-soft: #f7efdf;
  --shadow: 0 12px 28px rgba(19, 38, 34, 0.08);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--canvas); }

body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
  line-height: 1.55;
}

button, input { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 68px;
  color: #fff;
  background: #162421;
  border-bottom: 3px solid var(--green);
}

.topbar-inner,
.control-inner,
.watchlist-inner,
.workspace,
footer p {
  width: min(1380px, calc(100% - 40px));
  margin: 0 auto;
}

.topbar-inner {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand-block { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.36);
  color: #d8efe7;
  font: 700 20px/1 Georgia, serif;
}
.brand-kicker { margin: 0; color: #9bb8af; font: 700 10px/1.2 Georgia, serif; }
.brand-block h1 { margin: 3px 0 0; font: 600 20px/1.2 "Songti SC", STSong, serif; }

.runtime-status { display: flex; align-items: center; gap: 9px; color: #d4dfdc; font-size: 13px; white-space: nowrap; }
.runtime-status time { color: #8fa09b; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); }
.status-dot.is-ready { background: #4db08d; box-shadow: 0 0 0 4px rgba(77, 176, 141, 0.12); }

.control-band { background: var(--surface); border-bottom: 1px solid var(--line); }
.control-inner {
  min-height: 88px;
  display: grid;
  grid-template-columns: auto minmax(300px, 1fr);
  align-items: center;
  gap: 34px;
}

.mode-tabs { display: inline-flex; height: 40px; border: 1px solid #bdc8c5; background: #f8faf9; }
.mode-tab {
  min-width: 94px;
  padding: 0 18px;
  border: 0;
  border-right: 1px solid #d6dddb;
  color: #53615e;
  background: transparent;
  font-weight: 650;
}
.mode-tab:last-child { border-right: 0; }
.mode-tab.is-active { color: #fff; background: var(--green); }
.mode-tab:focus-visible, .run-button:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 3px solid rgba(49, 95, 146, 0.25);
  outline-offset: 2px;
}

.research-form { display: flex; align-items: end; justify-content: flex-end; gap: 12px; min-width: 0; }
.stock-fields { flex: 1; display: grid; grid-template-columns: repeat(2, minmax(180px, 1fr)); gap: 12px; }
.field { min-width: 0; display: grid; gap: 5px; }
.field > label { color: var(--muted); font-size: 12px; font-weight: 650; }
.stock-input-wrap { position: relative; min-width: 0; }
.field input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid #b9c4c1;
  border-radius: 4px;
  color: var(--ink);
  background: #fff;
}
.field input::placeholder { color: #9aa5a2; }
.field input.is-selected { border-color: var(--green); box-shadow: inset 3px 0 0 var(--green); }
.suggestion-menu { position: absolute; z-index: 30; top: calc(100% + 5px); left: 0; width: 100%; max-height: 286px; overflow-y: auto; border: 1px solid #aebbb7; border-radius: 4px; background: #fff; box-shadow: 0 12px 24px rgba(19, 38, 34, 0.14); }
.suggestion-item { width: 100%; min-height: 47px; padding: 7px 10px; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 10px; text-align: left; border: 0; border-bottom: 1px solid var(--line); color: var(--ink); background: #fff; }
.suggestion-item:last-child { border-bottom: 0; }
.suggestion-item:hover, .suggestion-item:focus-visible { outline: 0; background: var(--green-soft); }
.suggestion-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 700; }
.suggestion-code { color: var(--ink); font: 600 12px/1 Georgia, serif; }
.suggestion-market { min-width: 34px; padding: 2px 4px; text-align: center; border: 1px solid #b8c5c1; border-radius: 2px; color: var(--muted); font-size: 10px; font-weight: 700; }
.suggestion-message { min-height: 47px; margin: 0; padding: 13px 10px; color: var(--muted); font-size: 12px; }
.run-button {
  flex: 0 0 auto;
  height: 42px;
  min-width: 128px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid #101b19;
  border-radius: 4px;
  color: #fff;
  background: #172421;
  font-weight: 700;
}
.run-button:hover { background: var(--green); border-color: var(--green); }
.run-button:disabled { cursor: wait; opacity: 0.65; }
.run-symbol { font-size: 10px; }

.watchlist-bar { border-top: 1px solid var(--line); background: #f8faf9; }
.watchlist-inner { min-height: 46px; display: flex; align-items: center; gap: 14px; }
.watchlist-label { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; color: var(--green); font-size: 12px; font-weight: 700; }
.watchlist-items { min-width: 0; padding: 7px 0; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: thin; }
.watch-item { flex: 0 0 auto; display: flex; min-height: 30px; overflow: hidden; border: 1px solid #c4cecb; border-radius: 3px; background: #fff; }
.watch-select { padding: 4px 8px; display: flex; align-items: center; gap: 7px; border: 0; color: var(--ink); background: transparent; }
.watch-select:hover { background: var(--green-soft); }
.watch-name { font-size: 13px; font-weight: 700; }
.watch-code, .watch-market { color: var(--muted); font: 600 11px/1 Georgia, serif; }
.watch-remove { width: 28px; padding: 0; border: 0; border-left: 1px solid var(--line); color: var(--muted); background: #f7f9f8; font-size: 17px; line-height: 1; }
.watch-remove:hover { color: var(--red); background: var(--red-soft); }
.watch-select:focus-visible, .watch-remove:focus-visible, .watch-toggle:focus-visible {
  position: relative;
  z-index: 1;
  outline: 3px solid rgba(49, 95, 146, 0.25);
  outline-offset: -2px;
}

.workspace { min-height: calc(100vh - 213px); padding: 34px 0 64px; }
.empty-state, .loading-state, .error-state {
  min-height: 360px;
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
}
.empty-code, .error-label { margin: 0 0 8px; color: var(--green); font: 700 12px/1 Georgia, serif; }
.empty-state h2, .error-state h2 { margin: 0; font: 600 34px/1.25 "Songti SC", STSong, serif; }
.empty-state p:last-child, .error-state p:last-child { color: var(--muted); }
.error-label { color: var(--red); }
.error-state { color: var(--red); }
.loading-state p { color: var(--muted); }
.loading-line { width: min(460px, 80vw); height: 3px; overflow: hidden; background: #dce3e1; }
.loading-line span { display: block; width: 42%; height: 100%; background: var(--green); animation: progress 1.4s ease-in-out infinite; }
@keyframes progress { from { transform: translateX(-105%); } to { transform: translateX(345%); } }
@media (prefers-reduced-motion: reduce) { .loading-line span { animation: none; width: 70%; } }

.result-view { background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.result-header {
  min-height: 108px;
  padding: 24px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  border-bottom: 1px solid var(--line);
}
.result-kicker { margin: 0 0 4px; color: var(--green); font: 700 12px/1.2 Georgia, serif; }
.result-header h2 { margin: 0; font: 600 30px/1.25 "Songti SC", STSong, serif; }
.result-meta { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: 13px; }
.meta-badge { display: inline-flex; min-height: 24px; padding: 2px 8px; align-items: center; border: 1px solid #aabbb6; border-radius: 3px; color: var(--green); background: var(--green-soft); font-size: 12px; }
.meta-badge.warning { color: var(--amber); border-color: #d1b77e; background: var(--amber-soft); }

.quote-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); border-bottom: 1px solid var(--line); }
.quote-item { min-height: 136px; padding: 22px 28px; border-right: 1px solid var(--line); }
.quote-item:last-child { border-right: 0; }
.quote-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.quote-identity { min-width: 0; display: flex; align-items: baseline; gap: 12px; }
.quote-title h3 { margin: 0; font-size: 17px; }
.quote-code { color: var(--muted); font: 600 12px/1 Georgia, serif; }
.watch-toggle { flex: 0 0 32px; width: 32px; height: 32px; padding: 0; border: 1px solid #c4cecb; border-radius: 3px; color: var(--amber); background: #fff; font-size: 19px; line-height: 1; }
.watch-toggle:hover, .watch-toggle.is-watched { border-color: #c8a765; background: var(--amber-soft); }
.quote-price { margin: 10px 0 12px; display: flex; align-items: baseline; gap: 12px; }
.quote-price strong { font: 700 30px/1 Georgia, "Times New Roman", serif; }
.quote-price em { font-style: normal; font-weight: 700; }
.is-up { color: var(--red); }
.is-down { color: var(--green); }
.quote-detail { margin: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); font-size: 12px; }

.verdict-band { padding: 28px; display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 34px; background: #eef3f2; border-bottom: 1px solid var(--line); }
.verdict-label-wrap { display: flex; align-items: baseline; gap: 12px; color: var(--muted); }
.verdict-label-wrap p { margin: 0; font-weight: 700; }
.section-index { color: var(--green); font: 700 12px/1 Georgia, serif; }
.verdict-copy strong { color: var(--green); font: 600 22px/1.3 "Songti SC", STSong, serif; }
.verdict-copy p { margin: 8px 0 0; max-width: 960px; color: #35413f; }
.evidence-refs { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 5px; }
.evidence-ref { padding: 0; border: 0; color: var(--blue); background: transparent; font: 700 11px/1 Georgia, serif; }
.evidence-ref:hover { text-decoration: underline; }

.content-section { padding: 28px; border-bottom: 1px solid var(--line); }
.section-heading { margin-bottom: 22px; display: flex; align-items: baseline; justify-content: space-between; gap: 20px; }
.section-heading > div { display: flex; align-items: baseline; gap: 12px; }
.section-heading h3 { margin: 0; font: 600 22px/1.3 "Songti SC", STSong, serif; }
.section-heading > strong { color: var(--green); font: 700 20px/1 Georgia, serif; }

.score-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border: 1px solid var(--line); }
.score-item { min-height: 142px; padding: 16px; border-right: 1px solid var(--line); }
.score-item:last-child { border-right: 0; }
.score-top { display: flex; justify-content: space-between; gap: 8px; }
.score-top strong { font-size: 14px; }
.score-top span { color: var(--green); font: 700 15px/1 Georgia, serif; white-space: nowrap; }
.score-track { width: 100%; height: 4px; margin: 13px 0; display: block; appearance: none; border: 0; background: #e1e6e5; }
.score-track::-webkit-progress-bar { background: #e1e6e5; }
.score-track::-webkit-progress-value { background: var(--blue); }
.score-track::-moz-progress-bar { background: var(--blue); }
.score-item p { margin: 0; color: var(--muted); font-size: 12px; }

.analysis-sections { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 48px; }
.analysis-block { padding: 18px 0; border-top: 1px solid var(--line); }
.analysis-block h4 { margin: 0 0 10px; color: var(--blue); font-size: 15px; }
.analysis-block ul { margin: 0; padding: 0; list-style: none; }
.analysis-block li { position: relative; margin: 0 0 9px; padding-left: 17px; color: #384441; }
.analysis-block li::before { content: ""; position: absolute; left: 1px; top: 0.68em; width: 5px; height: 5px; background: var(--green); }

.condition-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--line); }
.condition-column { min-height: 150px; padding: 18px; border-right: 1px solid var(--line); }
.condition-column:last-child { border-right: 0; }
.condition-column h4 { margin: 0 0 12px; font-size: 14px; }
.condition-column.confirm h4 { color: var(--red); }
.condition-column.observe h4 { color: var(--blue); }
.condition-column.invalidate h4 { color: var(--green); }
.condition-column ul { margin: 0; padding-left: 18px; }
.condition-column li { margin: 0 0 8px; color: var(--muted); font-size: 13px; }

.risk-list { margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 36px; list-style: none; counter-reset: risk; }
.risk-list li { counter-increment: risk; padding: 13px 0 13px 42px; position: relative; border-top: 1px solid var(--line); }
.risk-list li::before { content: counter(risk, decimal-leading-zero); position: absolute; left: 0; top: 16px; color: var(--red); font: 700 11px/1 Georgia, serif; }

.evidence-section { padding: 0 28px 30px; }
.evidence-section summary { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 18px; font-weight: 700; cursor: pointer; }
.evidence-list { border-top: 1px solid var(--line); }
.evidence-item { padding: 20px 0; border-bottom: 1px solid var(--line); scroll-margin-top: 84px; }
.evidence-item:last-child { border-bottom: 0; }
.evidence-item.is-targeted { background: var(--blue-soft); }
.evidence-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.evidence-head h4 { margin: 0; font-size: 14px; }
.evidence-id { color: var(--blue); font: 700 12px/1 Georgia, serif; }
.evidence-query { margin: 6px 0 12px; color: var(--muted); font-size: 12px; }
.evidence-error { color: var(--red); }
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { min-width: 110px; padding: 9px 10px; text-align: left; vertical-align: top; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); white-space: normal; overflow-wrap: anywhere; }
th { color: #34413e; background: #edf2f1; font-weight: 700; }
tr:last-child td { border-bottom: 0; }
th:last-child, td:last-child { border-right: 0; }

footer { min-height: 57px; display: flex; align-items: center; color: var(--muted); border-top: 1px solid var(--line); font-size: 12px; }
footer p { margin-top: 0; margin-bottom: 0; }

@media (max-width: 960px) {
  .control-inner { padding: 16px 0; grid-template-columns: 1fr; gap: 14px; }
  .mode-tabs { width: 100%; }
  .mode-tab { flex: 1; min-width: 0; padding: 0 10px; }
  .research-form { width: 100%; }
  .score-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .score-item { border-bottom: 1px solid var(--line); }
  .analysis-sections { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .topbar-inner, .control-inner, .watchlist-inner, .workspace, footer p { width: min(100% - 24px, 1380px); }
  .topbar-inner { min-height: 74px; }
  .brand-block h1 { font-size: 18px; }
  .runtime-status time { display: none; }
  .research-form { align-items: stretch; flex-direction: column; }
  .stock-fields { grid-template-columns: 1fr; }
  .run-button { width: 100%; }
  .watchlist-inner { align-items: flex-start; gap: 10px; }
  .watchlist-label { min-height: 44px; }
  .watch-market { display: none; }
  .workspace { padding-top: 18px; }
  .result-header { align-items: flex-start; flex-direction: column; padding: 20px; }
  .result-header h2 { font-size: 25px; }
  .result-meta { justify-content: flex-start; }
  .quote-strip { grid-template-columns: 1fr; }
  .quote-item { border-right: 0; border-bottom: 1px solid var(--line); padding: 20px; }
  .quote-item:last-child { border-bottom: 0; }
  .verdict-band { grid-template-columns: 1fr; gap: 12px; padding: 22px 20px; }
  .content-section { padding: 24px 20px; }
  .score-grid, .condition-grid { grid-template-columns: 1fr; }
  .score-item, .condition-column { min-height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .score-item:last-child, .condition-column:last-child { border-bottom: 0; }
  .risk-list { grid-template-columns: 1fr; }
  .evidence-section { padding: 0 20px 24px; }
  th, td { min-width: 92px; }
}
