:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --panel-2: #f0f4f8;
  --text: #17202a;
  --muted: #667085;
  --line: #d8dee6;
  --blue: #2563eb;
  --green: #0f8b6f;
  --red: #c2413d;
  --amber: #b7791f;
  --ink: #111827;
  --shadow: 0 12px 30px rgba(19, 28, 45, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 1120px;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

/* ---- top sticky bar ---- */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(280px, 1fr) auto auto;
  gap: 18px;
  align-items: center;
  padding: 10px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
}

.top-brand .eyebrow {
  margin: 0;
  font-size: 10px;
  letter-spacing: 1px;
}

.top-brand h1 {
  font-size: 16px;
  line-height: 1.15;
  margin-top: 2px;
}

.top-search {
  position: relative;
}

.top-search input {
  width: 100%;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  outline: none;
  font-size: 13px;
  color: var(--text);
}

.top-search input:focus {
  background: var(--panel);
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.top-nav {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
}

.nav-arrow {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  border-radius: 999px;
  cursor: pointer;
}

.nav-arrow:hover {
  color: var(--ink);
  background: var(--panel);
}

.nav-arrow:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.current-symbol {
  min-width: 72px;
  text-align: center;
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
  letter-spacing: 0.5px;
}

.top-account {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.top-account .snapshot {
  flex: 0 0 auto;
  max-width: 112px;
  padding: 5px 8px;
  font-size: 11px;
}

.top-account .auth-button {
  width: auto;
  padding: 7px 14px;
}

/* ---- app shell below top bar ---- */
.app-shell {
  display: grid;
  grid-template-columns: 380px 1fr;
  min-height: calc(100vh - 60px);
}

.sidebar {
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr);
  gap: 12px;
  padding: 16px;
  border-right: 1px solid var(--line);
  background: #fbfcfa;
}

.brand {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

h1 {
  font-size: 24px;
  line-height: 1.15;
}

.snapshot {
  flex: 0 0 auto;
  max-width: 112px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
  background: var(--panel);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.segment {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.segment.active {
  color: var(--ink);
  font-weight: 750;
  background: var(--panel);
  box-shadow: 0 1px 8px rgba(16, 24, 40, 0.08);
}

.filters {
  display: grid;
  gap: 12px;
}

.search-box,
.filter-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.search-box input,
.filter-grid select,
.add-company input,
.ai-config input,
.ai-config select {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: var(--panel);
  color: var(--text);
}

.search-box input:focus,
.filter-grid select:focus,
.add-company input:focus,
.ai-config input:focus,
.ai-config select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: end;
}

.check-row {
  grid-column: 1 / -1;
  min-height: 40px;
  display: flex !important;
  align-items: center;
  gap: 8px !important;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.add-company,
.ai-config {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.add-company label,
.ai-config label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.primary-button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-weight: 750;
  cursor: pointer;
}

.primary-button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.add-company p,
.ai-config p {
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.ai-config summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.ai-config summary::marker {
  content: "";
}

.ai-config summary em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 650;
}

.ai-provider {
  display: grid;
  gap: 8px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}

.ai-provider-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--ink);
  font-size: 12px;
}

.ai-provider-head span {
  color: var(--muted);
  font-size: 11px;
}

.ai-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.sector-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}

.sector-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
}

.sector-chip strong {
  font-weight: 600;
}

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

.sector-chip:hover,
.sector-chip.active {
  border-color: rgba(37, 99, 235, 0.45);
  background: #f0f5ff;
}

.sector-chip.active {
  color: var(--blue);
}

.sector-chip.active strong {
  color: var(--blue);
}

.source-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 26px;
}

.source-pill {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--panel);
  font-size: 12px;
}

.source-pill.ok {
  color: var(--green);
  border-color: rgba(15, 139, 111, 0.25);
  background: rgba(15, 139, 111, 0.08);
}

.source-pill.fail {
  color: var(--red);
  border-color: rgba(194, 65, 61, 0.25);
  background: rgba(194, 65, 61, 0.08);
}

.company-list {
  overflow-y: auto;
  display: grid;
  align-content: start;
  gap: 8px;
  padding-right: 4px;
}

.company-row {
  width: 100%;
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 66px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.company-row:hover,
.company-row.active {
  border-color: rgba(37, 99, 235, 0.45);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.08);
}

.rank {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #e7eefc;
  color: var(--blue);
  font-weight: 800;
  font-size: 12px;
  text-align: center;
}

.company-name {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.company-name strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.company-name span,
.company-meta {
  color: var(--muted);
  font-size: 12px;
}

.company-name span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.company-meta {
  text-align: right;
  white-space: nowrap;
}

.workspace {
  min-width: 0;
  padding: 20px;
  max-width: 1320px;
  margin: 0 auto;
}

.hero-section {
  min-height: 188px;
  display: grid;
  gap: 18px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hero-top {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}

.hero-title {
  display: grid;
  gap: 8px;
}

.hero-title h2 {
  font-size: 32px;
  line-height: 1.12;
}

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

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: #f9fafb;
  font-size: 12px;
  font-weight: 650;
}

.tag.blue {
  color: var(--blue);
  border-color: rgba(37, 99, 235, 0.25);
  background: rgba(37, 99, 235, 0.08);
}

.tag.green {
  color: var(--green);
  border-color: rgba(15, 139, 111, 0.25);
  background: rgba(15, 139, 111, 0.08);
}

.tag.red {
  color: var(--red);
  border-color: rgba(194, 65, 61, 0.25);
  background: rgba(194, 65, 61, 0.08);
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 10px;
}

.metric {
  min-height: 74px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric em {
  display: block;
  margin: 3px 0 8px;
  color: #7b8798;
  font-size: 11px;
  line-height: 1.25;
  font-style: normal;
}

.metric strong {
  display: block;
  font-size: 20px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

/* Legacy 2-column wrapper kept as a no-op for any cached HTML. The new
   layout stacks every section vertically inside .workspace. */
.content-grid {
  display: contents;
}

.main-column,
.side-column {
  display: contents;
}

/* Horizontal strip used to put a 风险等级 + 发展前景 row right under the
   portfolio block so the user sees the qualitative summary without
   scrolling to a side panel. */
.dual-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}

.dual-card {
  margin: 0 !important;
}

.workspace > * {
  margin-bottom: 14px;
}

.workspace > *:last-child {
  margin-bottom: 0;
}

.section-block {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

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

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

.section-note {
  color: var(--muted);
  font-size: 12px;
}

.mini-select {
  min-height: 32px;
  max-width: 220px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-size: 12px;
}

.body-text {
  color: #344054;
  font-size: 14px;
  line-height: 1.75;
}

.data-warning {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid rgba(194, 65, 61, 0.22);
  border-radius: 8px;
  background: #fff7f6;
  color: #8f2f2b;
  font-size: 13px;
  line-height: 1.6;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.portfolio-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.holding-form {
  display: grid;
  grid-template-columns: 1fr 120px 120px auto auto auto;
  gap: 8px;
  margin-bottom: 12px;
}

.holding-form input[type="hidden"] {
  display: none;
}

.holding-form input {
  min-width: 0;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.portfolio-status {
  min-height: 18px;
  margin: -2px 0 12px;
  color: var(--muted);
  font-size: 12px;
}

.ib-import {
  margin-bottom: 14px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
}

.ib-import summary {
  cursor: pointer;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.ib-import textarea {
  width: 100%;
  min-height: 92px;
  margin: 10px 0;
  padding: 10px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.portfolio-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}

.portfolio-grid h4,
.ai-portfolio h4 {
  margin: 0 0 10px;
  font-size: 15px;
}

.portfolio-table table {
  min-width: 900px;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--red);
  font-weight: 800;
  cursor: pointer;
}

.pos {
  color: var(--green);
  font-weight: 800;
}

.neg {
  color: var(--red);
  font-weight: 800;
}

.portfolio-side {
  display: grid;
  gap: 12px;
}

.sector-mini {
  display: grid;
  gap: 7px;
}

.sector-mini div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
}

.sector-mini strong {
  color: var(--ink);
}

.ai-portfolio {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid rgba(37, 99, 235, 0.22);
  border-radius: 8px;
  background: #f6f9ff;
}

.ai-portfolio p {
  margin-bottom: 12px;
  color: #344054;
  line-height: 1.6;
}

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

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

.scenario-tab {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
  font-weight: 750;
  cursor: pointer;
}

.scenario-tab.active {
  border-color: rgba(37, 99, 235, 0.45);
  background: #eff6ff;
  color: var(--blue);
}

.valuation-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.model-controls {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
}

.control-group-title {
  padding-top: 4px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 850;
}

.model-control {
  display: grid;
  gap: 6px;
}

.model-control span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.model-control em {
  color: #7b8798;
  font-size: 11px;
  font-style: normal;
  font-weight: 600;
}

.control-pair {
  display: grid;
  grid-template-columns: minmax(80px, 1fr) 74px 22px;
  gap: 8px;
  align-items: center;
}

.control-pair input[type="range"] {
  min-width: 0;
  accent-color: var(--blue);
}

.control-pair input[type="number"] {
  width: 100%;
  min-height: 32px;
  padding: 6px 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
}

.control-pair b {
  color: var(--muted);
  font-size: 12px;
}

.model-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.model-status {
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
}

.valuation-output {
  min-width: 0;
  display: grid;
  gap: 14px;
}

.valuation-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.metric.signal.green strong {
  color: var(--green);
}

.metric.signal.red strong {
  color: var(--red);
}

.valuation-table table {
  min-width: 880px;
}

.valuation-table th:first-child,
.valuation-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: #f7f9fb;
}

.valuation-table .blue-row th,
.valuation-table .blue-row td {
  background: #e9f4ff;
  font-weight: 800;
}

.valuation-table .yellow-row th,
.valuation-table .yellow-row td {
  background: #fff3bf;
  font-weight: 800;
}

.valuation-methods {
  display: grid;
  gap: 8px;
}

.section-head.small {
  margin-bottom: 0;
}

.method-table table {
  min-width: 720px;
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
}

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

th,
td {
  padding: 10px 9px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  font-size: 13px;
  white-space: nowrap;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  background: #f7f9fb;
}

.quarter-bars {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.bar-row {
  display: grid;
  grid-template-columns: 98px 1fr 96px;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

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

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue), var(--green));
}

.bullet-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.bullet-list li {
  padding-left: 14px;
  border-left: 3px solid var(--line);
  color: #344054;
  font-size: 14px;
  line-height: 1.55;
}

.risk-score {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px;
  border-radius: 8px;
  background: #fff7ed;
  border: 1px solid rgba(183, 121, 31, 0.22);
}

.risk-score strong {
  font-size: 22px;
  color: var(--amber);
}

.sec-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.sec-table table {
  min-width: 680px;
}

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

.news-item {
  display: grid;
  gap: 7px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.news-item:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.news-title {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
  text-decoration: none;
  font-weight: 760;
}

.news-title:hover {
  color: var(--blue);
}

.news-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.news-summary {
  color: #485467;
  font-size: 13px;
  line-height: 1.55;
}

.toolbar-button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.toolbar-button:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.empty {
  padding: 22px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 980px) {
  body {
    min-width: 0;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .company-list {
    max-height: 440px;
  }

  .workspace {
    padding: 16px;
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .valuation-layout {
    grid-template-columns: 1fr;
  }

  .hero-metrics,
  .metric-grid,
  .valuation-cards,
  .portfolio-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .holding-form,
  .portfolio-grid,
  .ai-columns {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .sidebar {
    gap: 10px;
    padding: 14px;
  }

  .brand {
    align-items: center;
  }

  .eyebrow {
    margin-bottom: 4px;
    font-size: 10px;
  }

  h1 {
    font-size: 21px;
  }

  .snapshot {
    max-width: 96px;
    padding: 5px 7px;
    font-size: 11px;
  }

  .segmented {
    min-height: 44px;
  }

  .segment {
    min-height: 36px;
    font-weight: 700;
  }

  .filter-grid {
    grid-template-columns: 1fr;
  }

  .check-row {
    grid-column: auto;
  }

  .check-row {
    min-height: 38px;
  }

  .sector-strip {
    grid-auto-flow: column;
    grid-auto-columns: minmax(136px, 42vw);
    grid-template-columns: none;
    margin: 0 -14px;
    padding: 0 14px 2px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .sector-strip::-webkit-scrollbar {
    display: none;
  }

  .sector-chip {
    min-height: 50px;
  }

  .source-strip {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .source-strip::-webkit-scrollbar,
  .company-list::-webkit-scrollbar {
    display: none;
  }

  .source-pill {
    flex: 0 0 auto;
  }

  .company-list {
    grid-auto-flow: column;
    grid-auto-columns: minmax(236px, 76vw);
    max-height: none;
    margin: 0 -14px;
    padding: 0 14px 6px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
  }

  .company-row {
    min-height: 78px;
    grid-template-columns: 38px minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-content: center;
    scroll-snap-align: start;
  }

  .rank {
    grid-row: 1 / 3;
    width: 36px;
    height: 36px;
  }

  .company-meta {
    grid-column: 2;
    display: flex;
    gap: 6px;
    justify-content: flex-start;
    text-align: left;
  }

  .workspace {
    padding: 12px 12px 22px;
  }

  .hero-section {
    min-height: 0;
    gap: 14px;
    padding: 16px;
  }

  .hero-top {
    flex-direction: column;
    gap: 12px;
  }

  .hero-title h2 {
    font-size: 26px;
  }

  .tags {
    gap: 6px;
  }

  .tag {
    min-height: 24px;
    padding: 3px 7px;
    font-size: 11px;
  }

  .toolbar-button {
    width: 100%;
    min-height: 40px;
  }

  .mini-select {
    width: 100%;
    max-width: none;
  }

  .hero-metrics,
  .metric-grid,
  .valuation-cards,
  .report-grid,
  .portfolio-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .holding-form {
    grid-template-columns: 1fr;
  }

  .metric {
    min-height: 66px;
    padding: 10px;
  }

  .metric span {
    font-size: 11px;
  }

  .metric em {
    margin-bottom: 6px;
    font-size: 10px;
  }

  .metric strong {
    font-size: 18px;
  }

  .content-grid {
    gap: 12px;
    margin-top: 12px;
  }

  .main-column,
  .side-column {
    gap: 12px;
  }

  .section-block {
    padding: 16px;
  }

  .section-head {
    align-items: flex-start;
    margin-bottom: 12px;
  }

  .section-head h3 {
    font-size: 17px;
  }

  .body-text,
  .bullet-list li,
  .news-title {
    font-size: 13px;
  }

  .table-wrap {
    margin: 0 -16px;
    padding: 0 16px;
  }

  table {
    min-width: 680px;
  }

  th,
  td {
    padding: 9px 8px;
    font-size: 12px;
  }

  .bar-row {
    grid-template-columns: 82px 1fr 72px;
    gap: 8px;
  }

  .scenario-tabs,
  .model-actions {
    grid-template-columns: 1fr;
  }

  .control-pair {
    grid-template-columns: minmax(72px, 1fr) 68px 18px;
  }
}

@media (max-width: 430px) {
  .hero-title h2 {
    font-size: 24px;
  }

  .metric strong {
    font-size: 17px;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  #financialBlock .metric-grid,
  .valuation-cards,
  .report-grid,
  .portfolio-summary {
    grid-template-columns: 1fr;
  }
}

/* ---- auth: login button + modal ---- */
.auth-bar {
  margin: 12px 0 4px;
}

.auth-button {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 14px;
  background: rgba(94, 154, 255, 0.12);
  border: 1px solid rgba(94, 154, 255, 0.35);
  color: #5e9aff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: background 120ms ease;
}

.auth-button:hover {
  background: rgba(94, 154, 255, 0.22);
}

.auth-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.auth-modal.open {
  display: flex;
}

.auth-modal-inner {
  background: #1a1d24;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 22px 24px;
  width: min(420px, 92vw);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.auth-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.auth-tab {
  padding: 8px 14px;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  font-size: 13px;
  border-bottom: 2px solid transparent;
}

.auth-tab.active {
  color: #fff;
  border-bottom-color: #5e9aff;
}

.auth-form label {
  display: block;
  margin-bottom: 12px;
}

.auth-form label span {
  display: block;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 4px;
}

.auth-form input {
  width: 100%;
  padding: 9px 11px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: #fff;
  font-size: 13px;
}

.auth-status {
  min-height: 18px;
  margin: 6px 0 10px;
  color: #ff7466;
  font-size: 12px;
}

.auth-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.auth-hint {
  margin-top: 12px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
  line-height: 1.5;
}

.auth-hint a {
  color: #5e9aff;
  text-decoration: none;
}

/* ---- compact sidebar ---- */
.add-company-wrap {
  margin: 4px 0;
}

.add-company-wrap > summary {
  list-style: none;
  cursor: pointer;
  font-size: 12px;
  color: var(--blue);
  padding: 6px 0;
  user-select: none;
}

.add-company-wrap > summary::-webkit-details-marker {
  display: none;
}

.add-company-wrap > summary:hover {
  opacity: 0.85;
}

.add-company-wrap[open] > summary {
  margin-bottom: 6px;
}

/* Tighten company rows so more fit in the sidebar viewport */
.company-row {
  min-height: 54px;
  padding: 8px 10px;
  gap: 8px;
}

.company-row .rank {
  width: 34px;
  height: 34px;
  font-size: 11px;
}

.company-name strong {
  font-size: 13px;
}

.company-name span,
.company-meta {
  font-size: 11px;
}

/* Hero action group (refresh news + watchlist toggle) */
.hero-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.watchlist-toggle.active {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.45);
  color: #b45309;
}

.add-company-status {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
  min-height: 14px;
}

/* ---- price chart ---- */
.price-chart-wrap {
  position: relative;
  height: 240px;
  margin-top: 8px;
}

.price-chart-meta {
  display: flex;
  gap: 18px;
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
  flex-wrap: wrap;
}

.chart-period-bar {
  display: inline-flex;
  gap: 4px;
}

.chart-period {
  padding: 3px 8px;
  font-size: 11px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  cursor: pointer;
}

.chart-period:hover {
  color: var(--ink);
}

.chart-period.active {
  background: rgba(37, 99, 235, 0.12);
  border-color: rgba(37, 99, 235, 0.45);
  color: var(--blue);
}

/* link-style inline button (used for "重新同步 IB" and "完整组合" link) */
.link-button {
  background: none;
  border: none;
  padding: 0;
  font-size: 12px;
  color: var(--blue);
  cursor: pointer;
  text-decoration: none;
}

.link-button:hover {
  text-decoration: underline;
}

/* one-pager 研报 KPI strip */
.report-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 12px 0 14px;
}

.kpi-card {
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.kpi-card strong {
  font-size: 19px;
  font-weight: 750;
  color: var(--ink);
  letter-spacing: -0.5px;
}

.kpi-card span {
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.kpi-card em {
  font-style: normal;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}

/* ---- DCF estimator ---- */
.dcf-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 10px 0 14px;
}

.dcf-summary .kpi-card.kpi-pos strong { color: var(--green); }
.dcf-summary .kpi-card.kpi-neg strong { color: var(--red); }

.dcf-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  margin-bottom: 14px;
}

.dcf-slider label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.dcf-slider label em {
  font-style: normal;
  font-weight: 750;
  color: var(--ink);
  font-size: 13px;
}

.dcf-slider input[type="range"] {
  width: 100%;
  accent-color: var(--blue);
}

.dcf-years {
  margin-top: 6px;
}

.dcf-years h4 {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--ink);
}

.dcf-years table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.dcf-years th,
.dcf-years td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
}

.dcf-years th:first-child,
.dcf-years td:first-child {
  text-align: left;
  color: var(--muted);
}

.dcf-terminal-row td {
  color: var(--muted);
  font-style: italic;
}

.dcf-total-row td {
  font-weight: 750;
  color: var(--ink);
  border-bottom: 0;
  border-top: 2px solid var(--line);
}

/* ---- Peer comparison table ---- */
.peer-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.peer-table th,
.peer-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
}

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

.peer-table th {
  color: var(--muted);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.peer-row .peer-name {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}

.peer-row.peer-target {
  background: rgba(37, 99, 235, 0.06);
}

.peer-row.peer-target td:first-child strong {
  color: var(--blue);
}

/* ---- DCF style presets ---- */
.dcf-preset-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0 10px;
  flex-wrap: wrap;
}

.dcf-preset-label {
  font-size: 12px;
  color: var(--muted);
}

.dcf-preset {
  padding: 4px 12px;
  font-size: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 999px;
  cursor: pointer;
}

.dcf-preset:hover {
  border-color: rgba(37, 99, 235, 0.45);
}

.dcf-preset.active {
  background: rgba(37, 99, 235, 0.12);
  border-color: rgba(37, 99, 235, 0.45);
  color: var(--blue);
  font-weight: 700;
}

.dcf-preset-custom {
  font-size: 11px;
  color: var(--muted);
  margin-left: 4px;
}

/* ---- skeleton loaders ---- */
@keyframes skeleton-shimmer {
  0%   { background-position: -160px 0; }
  100% { background-position: 240px 0; }
}

.skeleton-block,
.skeleton span {
  display: block;
  background: linear-gradient(90deg, rgba(0,0,0,0.04) 0%, rgba(0,0,0,0.08) 50%, rgba(0,0,0,0.04) 100%);
  background-size: 400px 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
  border-radius: 6px;
}

.skeleton {
  display: grid;
  gap: 8px;
}

.skeleton span {
  height: 14px;
  width: 100%;
}

.skeleton span:nth-child(2n) {
  width: 75%;
}

.skeleton-title {
  height: 28px;
  width: 50%;
  margin-bottom: 10px;
}

.skeleton-tags {
  height: 18px;
  width: 70%;
}

.skeleton-metric .skeleton-block {
  height: 38px;
}

.skeleton-chart {
  height: 220px;
}

/* ---- manual holding fallback form (in symbol-positions empty state) ---- */
.manual-hint {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--text);
}

.manual-hint-sub {
  margin-top: 10px;
  font-size: 11px;
  color: var(--muted);
}

.manual-hint-sub a {
  color: var(--blue);
  text-decoration: none;
}

.manual-holding-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 10px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
}

.manual-holding-form label {
  display: grid;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
}

.manual-holding-form input {
  width: 100%;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  outline: none;
}

.manual-holding-form input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.manual-status {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 11px;
  color: var(--muted);
  min-height: 14px;
}

.opt-expiry {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}

.pnl-pos { color: var(--green); font-weight: 700; }
.pnl-neg { color: var(--red); font-weight: 700; }
