:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-soft: #eef3ef;
  --ink: #1f2933;
  --muted: #65717c;
  --line: #d9e0dc;
  --teal: #18776f;
  --teal-dark: #0f504b;
  --amber: #b46b19;
  --rose: #a94442;
  --shadow: 0 18px 42px rgba(31, 41, 51, 0.12);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 48px);
  background: rgba(246, 247, 244, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
  text-align: left;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  color: #fff;
  background: var(--teal);
  border-radius: 8px;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
  white-space: nowrap;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.topnav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.nav-button,
.text-button,
.secondary-action,
.quick-actions button,
.conversion-grid button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

.nav-button {
  flex: 0 0 auto;
  padding: 9px 12px;
}

.nav-button.active {
  border-color: var(--teal);
  color: #fff;
  background: var(--teal);
}

main {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 72px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}

.search-panel,
.report-main,
.checkout-panel,
.conversion-grid article,
.library-item,
.modal form {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.search-panel {
  padding: clamp(22px, 5vw, 44px);
}

.eyebrow,
.tag {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 5px 9px;
  border-radius: 999px;
  background: #e8f3f1;
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 700;
}

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

h1 {
  max-width: 740px;
  margin-bottom: 14px;
  font-size: clamp(30px, 5vw, 48px);
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 10px;
  font-size: 22px;
  line-height: 1.25;
}

h3 {
  margin-bottom: 8px;
  font-size: 17px;
}

.lede {
  max-width: 680px;
  color: var(--muted);
  line-height: 1.8;
}

.search-box {
  margin-top: 30px;
}

.search-box label,
.modal label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 8px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 13px;
  background: #fbfcfa;
  color: var(--ink);
}

.search-row button,
.primary-action,
.quick-actions button:last-child,
.conversion-grid button {
  border: 1px solid var(--teal);
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  font-weight: 700;
}

.search-row button {
  padding: 0 18px;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.quick-actions button {
  padding: 11px 14px;
}

.sample-row {
  margin-top: 18px;
}

.sample-row button {
  padding: 12px 26px;
  font-size: 15px;
}

dt {
  color: var(--muted);
  font-size: 12px;
}

dd {
  margin: 4px 0 0;
  font-weight: 800;
}

.section-block {
  margin-top: 30px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.section-heading p {
  margin-bottom: 2px;
  color: var(--muted);
}

.report-grid,
.feature-grid,
.conversion-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.report-card,
.feature-grid article {
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.report-card {
  display: grid;
  gap: 12px;
  min-height: 220px;
}

.report-card .meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.report-card .score {
  width: fit-content;
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--teal-dark);
  background: #e8f3f1;
  font-weight: 800;
}

.report-card p,
.feature-grid span,
.checkout-panel p,
.conversion-grid p {
  color: var(--muted);
  line-height: 1.65;
}

.report-card button {
  align-self: end;
  border: 1px solid var(--teal);
  border-radius: 8px;
  padding: 10px 12px;
  background: transparent;
  color: var(--teal-dark);
  font-weight: 700;
}

.report-card.report-card-matched {
  border-color: #0f8577;
  box-shadow: 0 0 0 3px rgba(24, 119, 111, 0.18);
  animation: matched-card-pop 600ms ease;
}

@keyframes matched-card-pop {
  0% {
    transform: translateY(0);
  }
  35% {
    transform: translateY(-3px);
  }
  100% {
    transform: translateY(0);
  }
}

.feature-grid article {
  display: grid;
  gap: 8px;
  min-height: 104px;
}

.report-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  margin-top: 14px;
}

.report-main,
.checkout-panel {
  padding: clamp(18px, 4vw, 32px);
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 18px 0;
}

.summary-strip div {
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-soft);
}

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

.summary-strip strong {
  display: block;
  margin-top: 4px;
}

.preview-chart {
  margin: 18px 0 24px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.preview-chart canvas {
  width: 100%;
  height: auto;
  display: block;
}

.toc-list {
  display: grid;
  gap: 8px;
  padding-left: 22px;
  color: var(--muted);
}

.locked-section {
  margin-top: 24px;
  padding: 18px;
  border-radius: 8px;
  background: #fff7e8;
  border: 1px solid #ebd7af;
}

.full-report {
  display: none;
  margin-top: 24px;
}

.full-report.unlocked {
  display: grid;
  gap: 16px;
}

.full-report.preview-analysis {
  display: grid;
  gap: 16px;
}

.full-report article {
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.report-section h2 {
  margin-bottom: 12px;
  color: var(--ink);
}

.report-body {
  display: grid;
  gap: 12px;
  color: #2f3b45;
  font-size: 15px;
  line-height: 1.9;
}

.report-body p,
.report-body ul {
  margin: 0;
}

.report-body h3 {
  margin: 8px 0 0;
  padding-left: 10px;
  border-left: 3px solid var(--teal);
  color: var(--ink);
  font-size: 16px;
}

.report-body ul {
  display: grid;
  gap: 6px;
  padding-left: 20px;
}

.report-body strong {
  color: var(--teal-dark);
}

.report-body code {
  padding: 1px 5px;
  border-radius: 6px;
  background: var(--surface-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.92em;
}

.summary-preview-section {
  display: grid;
  gap: 12px;
}

.summary-preview-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.summary-preview-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.summary-preview-frame {
  width: 100%;
  min-height: 280px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.summary-preview-link {
  width: fit-content;
  text-decoration: none;
}

.report-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid #d8dee4;
  border-radius: 4px;
  background: white;
}

.report-table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  color: #20262d;
  font-size: 15px;
  line-height: 1.55;
}

.report-table th,
.report-table td {
  padding: 10px 12px;
  border-right: 1px solid #d8dee4;
  border-bottom: 1px solid #d8dee4;
  text-align: left;
  vertical-align: top;
}

.report-table th:last-child,
.report-table td:last-child {
  border-right: 0;
}

.report-table tbody tr:last-child td {
  border-bottom: 0;
}

.report-table th {
  background: #eef2f6;
  color: #20262d;
  font-weight: 700;
}

.financial-analysis-section {
  display: grid;
  gap: 16px;
}

.financial-analysis-grid {
  display: grid;
  gap: 18px;
}

.financial-module {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.financial-module-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.financial-module-head h3 {
  margin-bottom: 0;
  color: var(--teal-dark);
}

.financial-module-head span {
  color: var(--muted);
  font-size: 14px;
}

.financial-table-wrap {
  background: #fff;
}

.financial-table {
  min-width: 720px;
  font-size: 14px;
}

.financial-table td:not(:first-child),
.financial-table th:not(:first-child) {
  text-align: right;
}

.financial-chart {
  margin: 0;
  background: #fff;
}

.report-visual {
  display: grid;
  gap: 10px;
  margin: 12px 0 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.report-visual-head,
.report-visual-legend {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.report-visual-head span {
  color: var(--muted);
  font-size: 13px;
}

.report-line-chart {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 640 / 220;
}

.report-visual-legend {
  justify-content: flex-start;
  color: var(--muted);
  font-size: 13px;
}

.report-visual-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.report-visual-legend i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.checkout-panel {
  position: sticky;
  top: 84px;
  align-self: start;
  display: grid;
  gap: 12px;
}

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

.price-box span {
  color: var(--muted);
}

.price-box strong {
  color: var(--amber);
  font-size: 28px;
}

.primary-action,
.secondary-action,
.text-button,
.conversion-grid button {
  padding: 11px 13px;
}

.wechat-login-button {
  padding: 12px 13px;
  border: 1px solid #07c160;
  border-radius: 8px;
  color: #fff;
  background: #07c160;
  font-weight: 700;
}

.wechat-login-button:disabled {
  border-color: #b8c3c2;
  background: #d7dddc;
  color: #5f6f6d;
  cursor: not-allowed;
}

.text-button {
  margin-bottom: 14px;
  background: transparent;
}

.library-list {
  display: grid;
  gap: 12px;
}

.library-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 18px;
}

.library-item p {
  margin-bottom: 0;
  color: var(--muted);
}

.library-item button {
  border: 1px solid var(--teal);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--teal);
  color: #fff;
}

.conversion-grid article {
  padding: 22px;
}

.conversion-grid button {
  margin-top: 8px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 20;
  transform: translateX(-50%) translateY(140%);
  max-width: min(460px, calc(100% - 32px));
  padding: 12px 16px;
  border-radius: 8px;
  color: #fff;
  background: rgba(31, 41, 51, 0.94);
  transition: transform 180ms ease;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.modal {
  width: min(440px, calc(100% - 32px));
  border: 0;
  padding: 0;
  background: transparent;
}

.modal::backdrop {
  background: rgba(31, 41, 51, 0.38);
}

.modal form {
  position: relative;
  display: grid;
  gap: 14px;
  padding: 24px;
}

.modal-copy {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.65;
}

.qr-pay-card {
  display: grid;
  place-items: center;
  padding: 16px;
  border: 1px solid #bfe8d0;
  border-radius: 8px;
  background: #f1fff6;
}

.qr-pay-card img {
  display: block;
  width: min(280px, 100%);
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
}

.auth-sheet {
  width: min(560px, 100%);
  max-width: 100%;
  margin: auto auto 0;
}

.auth-sheet form {
  border-radius: 16px 16px 0 0;
  padding: 22px 18px calc(22px + env(safe-area-inset-bottom, 0px));
}

.auth-sheet .secondary-action {
  border-color: #b8d6d2;
  background: #f5fbfa;
}

.search-sync-modal {
  width: min(460px, calc(100% - 32px));
}

.search-sync-modal form {
  justify-items: center;
  text-align: center;
  gap: 10px;
  padding: 28px;
}

.search-sync-spinner {
  width: 46px;
  height: 46px;
  border: 4px solid #c9dfda;
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: search-sync-spin 900ms linear infinite;
}

@keyframes search-sync-spin {
  to {
    transform: rotate(360deg);
  }
}

.poster-modal {
  width: min(360px, calc(100% - 32px));
}

.poster-form {
  justify-items: center;
  text-align: center;
  gap: 12px;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom, 0px));
}

.poster-title {
  margin: 0;
  font-size: 17px;
}

.poster-canvas-wrap {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 120px;
}

.poster-image {
  display: block;
  width: min(300px, 100%);
  height: auto;
  border-radius: 14px;
  box-shadow: var(--shadow);
}

#poster-canvas {
  display: none;
}

.poster-loading {
  position: absolute;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.poster-hint {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
}

@media (max-width: 880px) {
  .topbar,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .topnav {
    width: 100%;
  }

  .workbench,
  .report-layout,
  .report-grid,
  .feature-grid,
  .conversion-grid {
    grid-template-columns: 1fr;
  }

  .checkout-panel {
    position: static;
  }

  .summary-strip {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 540px) {
  main {
    width: min(100% - 20px, 1160px);
    padding-top: 18px;
  }

  .search-row,
  .library-item {
    grid-template-columns: 1fr;
  }

  .search-row button {
    min-height: 46px;
  }

  .summary-strip {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 30px;
  }

  .auth-sheet {
    width: 100%;
  }
}

@media print {
  .topbar,
  .checkout-panel,
  .text-button,
  .toast,
  .modal {
    display: none !important;
  }

  body {
    background: #fff;
  }

  main,
  .report-layout {
    width: 100%;
    display: block;
    padding: 0;
  }

  .report-main {
    border: 0;
    box-shadow: none;
  }
}

/* ---- 搜索框模糊建议下拉（数据=服务端本地目录缓存，三市场 3 万余标的） ---- */
.search-box { position: relative; }
.search-suggest {
  position: absolute; left: 0; right: 0; top: 100%; margin-top: 6px; z-index: 40;
  background: #fff; border: 1px solid #d8dee6; border-radius: 10px;
  box-shadow: 0 10px 28px rgba(15, 40, 68, 0.14); overflow: hidden;
}
.search-suggest-item {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  width: 100%; padding: 10px 14px; border: 0; background: #fff; cursor: pointer;
  font-size: 14px; text-align: left;
}
.search-suggest-item + .search-suggest-item { border-top: 1px solid #f0f3f6; }
.search-suggest-item:hover { background: #f2f7fb; }
.search-suggest-item .ss-name { font-weight: 600; color: #17324d; }
.search-suggest-item .ss-meta { color: #7b8a9a; font-size: 12px; white-space: nowrap; }

/* R17：主行动按钮未选中标的时置灰 */
.quick-actions button[disabled] {
  border-color: var(--line);
  background: #cfd6dd;
  color: #7d8791;
  font-weight: 600;
  cursor: not-allowed;
}

/* R19：财务报表多维分析报告视图 */
.full-gen-button { width: 100%; margin: 14px 0; }
/* 多维视图无侧栏：单列布局；min-width:0 让宽表在卡片内横向滚动而非撑破页面 */
#view-multidim .report-layout { grid-template-columns: 1fr; }
.multidim-body { display: grid; gap: 14px; min-width: 0; }
.multidim-card { min-width: 0; }
.multidim-card {
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
  padding: 14px 14px 12px;
}
.multidim-card h2 { margin: 0 0 10px; font-size: 16px; }
.multidim-tablewrap { overflow-x: auto; }
.multidim-tablewrap table {
  border-collapse: collapse; width: 100%; font-size: 12px; white-space: nowrap;
}
.multidim-tablewrap th, .multidim-tablewrap td {
  border: 1px solid var(--line); padding: 5px 8px; text-align: right;
}
.multidim-tablewrap th:first-child, .multidim-tablewrap td:first-child { text-align: left; }
.multidim-tablewrap th { background: #f0f6f3; }
.multidim-summary { margin-top: 9px; font-size: 13px; font-weight: 700; color: var(--teal); }
.multidim-foot { font-size: 11px; color: #8a97a3; line-height: 1.7; margin-top: 7px; }
.multidim-range { color: #5a6875; font-size: 13px; margin: 4px 0 0; }
