:root {
  --bg: #f4f1ea;
  --bg-elevated: #fffdf8;
  --bg-soft: #ebe6db;
  --ink: #17231d;
  --ink-soft: #5b6a61;
  --line: #d7d0c2;
  --brand: #0f6b57;
  --brand-deep: #0a4639;
  --brand-soft: #d8efe7;
  --buy: #0c7a4d;
  --installment: #1f7a8c;
  --hold: #6b5b3e;
  --watch: #8a6d1f;
  --sell: #a33b2d;
  --up: #c0392b;
  --down: #0c7a4d;
  --shadow: 0 8px 24px rgba(23, 35, 29, 0.06);
  --shadow-soft: 0 4px 14px rgba(23, 35, 29, 0.04);
  --radius: 16px;
  --mono: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--mono);
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(15, 107, 87, 0.08), transparent 28%),
    radial-gradient(circle at top right, rgba(138, 109, 31, 0.08), transparent 24%),
    var(--bg);
  min-height: 100vh;
  overflow-x: clip;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
::selection { background: rgba(15, 107, 87, 0.18); color: var(--ink); }
:focus-visible {
  outline: 2px solid rgba(15, 107, 87, 0.45);
  outline-offset: 2px;
}

button, input, select { font: inherit; }
a { color: var(--brand); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

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

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}
.brand { display: flex; gap: 10px; align-items: center; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--brand), var(--brand-deep));
  color: #f7fff9; font-weight: 800; letter-spacing: 0.04em;
  font-size: 12px;
  box-shadow: 0 6px 16px rgba(23, 35, 29, 0.08);
}
.eyebrow {
  margin: 0;
  color: var(--brand);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
}
h1 { margin: 1px 0 0; font-size: clamp(18px, 2.2vw, 22px); letter-spacing: -0.02em; line-height: 1.15; }
.topbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.live-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px;
  background: var(--bg-elevated); border: 1px solid var(--line);
  color: var(--ink-soft); font-size: 12px;
}
.live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #9aa59e;
  box-shadow: 0 0 0 0 rgba(15,107,87,0.35);
}
.live-dot.on {
  background: #14a36f;
  animation: pulse 1.8s infinite;
}
.live-dot.warn { background: #c9a227; }
.live-dot.off { background: #9aa59e; animation: none; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(20,163,111,0.45); }
  70% { box-shadow: 0 0 0 10px rgba(20,163,111,0); }
  100% { box-shadow: 0 0 0 0 rgba(20,163,111,0); }
}

.btn {
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  color: var(--ink);
  border-radius: 10px;
  padding: 6px 11px;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: 0.15s ease;
}
.btn:hover { border-color: #b9b1a0; transform: translateY(-1px); }
.btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #f4fffa;
}
.btn.primary:hover { background: var(--brand-deep); }
.btn.ghost { background: transparent; }
.btn.text { border: none; background: transparent; color: var(--brand); padding: 8px 4px; }
.btn.icon {
  width: 36px; height: 36px; border-radius: 10px; padding: 0;
  font-size: 22px; line-height: 1;
}

.summary-band { margin-bottom: 8px; }
.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}
.metric {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
  box-shadow: 0 4px 14px rgba(23, 35, 29, 0.04);
  min-width: 0;
}
.metric-label { display: block; color: var(--ink-soft); font-size: 11px; margin-bottom: 2px; }
.metric-value { font-size: 18px; font-weight: 750; letter-spacing: -0.03em; color: var(--brand-deep); line-height: 1.1; }
.metric {
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.metric:hover {
  border-color: #c9c0ae;
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

.control-band {
  background: rgba(255,253,248,0.92);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  margin-bottom: 10px;
  position: sticky;
  top: 6px;
  z-index: 20;
  box-shadow: 0 6px 18px rgba(23, 35, 29, 0.05);
}
.search-box { position: relative; margin-bottom: 8px; }
.search-box input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 40px 9px 12px;
  background: #fff;
  outline: none;
  font-size: 13px;
}
.search-box input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15,107,87,0.12); }
.hint-key {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 6px; padding: 1px 6px; color: var(--ink-soft); background: var(--bg-soft);
  font-size: 11px;
}
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.advice-filter-row {
  align-items: center;
  padding-top: 6px;
  border-top: 1px solid #e6dfd3;
}
.filter-label {
  margin-right: 4px;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.04em;
}
.chip {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}
.chip:hover { border-color: #b9b1a0; }
.chip.active {
  background: var(--brand-soft);
  border-color: #9dcfbf;
  color: var(--brand-deep);
  font-weight: 700;
}
.chip.advice-conservative.active { background: #dff5ea; border-color: #9ed7bb; color: var(--buy); }
.chip.advice-balanced.active { background: #e4f4f7; border-color: #a8d5df; color: var(--installment); }
.chip.advice-aggressive.active { background: #f8f0d8; border-color: #e2cb85; color: var(--watch); }
.chip.advice-no.active { background: #f8e6e2; border-color: #e3b1a8; color: var(--sell); }
.chip.advice-unknown.active { background: #eef1ee; border-color: #cfd7d1; color: var(--ink-soft); }

.control-meta {
  display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center;
}
.sort-field { display: inline-flex; gap: 6px; align-items: center; color: var(--ink-soft); font-size: 12px; }
.sort-field select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 8px;
  background: #fff;
  font-size: 12px;
}
.data-status { margin: 0; color: var(--ink-soft); font-size: 12px; }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.workspace.detail-open {
  grid-template-columns: minmax(0, 1.15fr) minmax(420px, 1fr);
}

.table-panel, .detail-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 2px);
  box-shadow: var(--shadow);
}
.table-panel { overflow: hidden; }
.table-wrap { overflow: auto; max-height: calc(100vh - 220px); }
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 980px;
  font-size: 13.5px;
}
thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: linear-gradient(180deg, #f8f4eb, #f2ecdf);
  color: #52645a;
  font-weight: 750;
  font-size: 12px;
  letter-spacing: 0.02em;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td {
  padding: 13px 12px;
  border-bottom: 1px solid #ddd5c8;
  vertical-align: middle;
}
tbody tr {
  cursor: pointer;
  background: #fffefb;
  transition: background 0.12s ease, box-shadow 0.12s ease;
}
tbody tr:nth-child(even) { background: #fcfaf5; }
tbody tr:not(:first-child) td { border-top: 7px solid var(--bg-elevated); }
tbody tr:hover { background: #f3faf6; box-shadow: inset 4px 0 0 #80bca7; }
tbody tr.active {
  background: linear-gradient(90deg, #e7f5ef, #f3faf6 42%);
  box-shadow: inset 5px 0 0 var(--brand);
}
tbody tr:last-child td { border-bottom: none; }
.company-cell { min-width: 120px; }
.company-name { font-weight: 750; color: var(--ink); }
.company-meta { color: var(--ink-soft); font-size: 12px; margin-top: 3px; }
.ticker-code { font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }

.ticker-code {
  margin-top: 5px;
  color: var(--ink-soft);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.market-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid transparent;
}
.market-badge.mkt-a { background: #e8f4ef; color: #0f6b57; border-color: #b7d9cc; }
.market-badge.mkt-hk { background: #eef1fb; color: #3d4f8f; border-color: #c5cce8; }
.market-badge.mkt-us { background: #f4efe8; color: #6b5b3e; border-color: #d8c9a8; }
.market-badge.mkt-unknown { background: #f1ece3; color: #5b6a61; border-color: #d7d0c2; }
.cutoff-cell { white-space: nowrap; }
.cutoff-date {
  font-variant-numeric: tabular-nums;
  color: #2f4038;
  font-size: 12.5px;
}
.cutoff-pending {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f8f0d8;
  color: #8a6d1f;
  font-size: 11px;
  font-weight: 700;
}
.empty-state {
  display: grid;
  place-items: center;
  gap: 4px;
  padding: 48px 20px;
  text-align: center;
  color: var(--ink-soft);
}
.empty-state[hidden] { display: none !important; }
.empty-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center;
  background: #f1ece3;
  border: 1px solid var(--line);
  font-size: 18px;
  margin-bottom: 6px;
  color: #8a7d6a;
}
.empty-title {
  margin: 0;
  font-size: 15px;
  font-weight: 750;
  color: var(--ink);
}
.empty-desc { margin: 0; font-size: 12.5px; }
.table-hint kbd {
  display: inline-block;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0 5px;
  background: #fff;
  font-size: 11px;
  color: var(--ink-soft);
  font-family: inherit;
}


.decision {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11.5px;
  font-weight: 750;
  white-space: nowrap;
  border: 1px solid transparent;
}
.decision-buy { border-color: #9ed7bb; }
.decision-installment { border-color: #a8d5df; }
.decision-hold { border-color: #d8c9a8; }
.decision-watch { border-color: #e2cb85; }
.decision-sell { border-color: #e3b1a8; }
.decision-buy { background: #dff5ea; color: var(--buy); }
.decision-installment { background: #e4f4f7; color: var(--installment); }
.decision-hold { background: #f4efe4; color: var(--hold); }
.decision-watch { background: #f8f0d8; color: var(--watch); }
.decision-sell { background: #f8e6e2; color: var(--sell); }

.quote-block { min-width: 140px; }
.quote-price {
  font-size: 15px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.quote-change {
  font-size: 11.5px;
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
  opacity: 0.95;
}
.quote-change.up { color: var(--up); }
.quote-change.down { color: var(--down); }
.quote-change.flat { color: var(--ink-soft); }
.zone-badge {
  display: inline-flex;
  margin-top: 6px;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 700;
  background: var(--bg-soft);
  color: var(--ink-soft);
}
.zone-badge.buy-zone { background: #dff5ea; color: var(--buy); }
.zone-badge.hold-zone { background: #f4efe4; color: var(--hold); }
.zone-badge.watch-zone { background: #f8f0d8; color: var(--watch); }
.zone-badge.hot-zone { background: #f8e6e2; color: var(--sell); }
.zone-badge.unknown-zone { background: #eef1ee; color: var(--ink-soft); }

.stack-list { display: grid; gap: 4px; }
.stack-item {
  color: var(--ink);
  line-height: 1.35;
  font-size: 12.5px;
}
.stack-item strong { font-weight: 700; }
.muted { color: var(--ink-soft); }
.table-hint {
  margin: 0;
  padding: 10px 14px;
  color: var(--ink-soft);
  font-size: 12px;
  border-top: 1px solid var(--line);
  background: #fbf8f1;
}

.detail-panel {
  position: sticky;
  top: 72px;
  height: calc(100vh - 88px);
  max-height: calc(100vh - 88px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  animation: detail-in 0.18s ease;
}
.detail-panel[hidden] { display: none; }
@keyframes detail-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.detail-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fbf8f1, #fffdf8);
}
.detail-kicker {
  margin: 0;
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.detail-head h2 { margin: 4px 0 0; font-size: 22px; }
.detail-sub { margin: 6px 0 0; color: var(--ink-soft); font-size: 13px; }
.detail-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: #f7f3ea;
}
.tab {
  border: 1px solid transparent;
  background: transparent;
  border-radius: 999px;
  padding: 5px 11px;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 12.5px;
  transition: 0.12s ease;
}
.tab:hover { color: var(--ink); background: rgba(255,255,255,0.55); }
.tab.active {
  background: #fff;
  border-color: #cfc6b4;
  color: var(--brand-deep);
  font-weight: 750;
  box-shadow: 0 1px 2px rgba(23,35,29,0.05);
}
.detail-head,
.detail-tabs,
.detail-foot {
  flex: 0 0 auto;
}
.detail-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 12px 14px 20px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: grid;
  gap: 12px;
  align-content: start;
  -webkit-overflow-scrolling: touch;
}
.detail-foot {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: #fbf8f1;
  z-index: 2;
}
.card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: #fff;
}
.card h3 {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.kv-grid {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 6px 10px;
  font-size: 13px;
}
.kv-grid dt { color: var(--ink-soft); }
.kv-grid dd { margin: 0; font-weight: 600; }

.history-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #fbf8f1;
  display: grid;
  gap: 8px;
}
.history-card header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.valuation-col {
  min-width: 132px;
}
.valuation-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 1px solid transparent;
}
.valuation-chip.ready {
  color: var(--brand-deep);
  background: var(--brand-soft);
  border-color: #9dcfbf;
}
.valuation-chip.empty {
  color: var(--ink-soft);
  background: #f1ece3;
  border-color: var(--line);
}
.valuation-hint {
  display: block;
  margin-top: 5px;
  color: var(--ink-soft);
  font-size: 11px;
}
tbody tr:hover .valuation-chip.ready {
  background: #cfe9df;
}
tbody tr.active .valuation-chip.ready {
  background: #bfe0d3;
  border-color: #7fbfab;
}

.valuation-card {
  padding: 0;
  overflow: visible;
  min-width: 0;
  background: linear-gradient(180deg, #fffefb 0%, #fff 40%);
}
.valuation-card-head {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(15, 107, 87, 0.08), transparent 55%),
    #fbf8f1;
}
.valuation-card-head h3 {
  margin: 0;
  font-size: 15px;
  color: var(--brand-deep);
  letter-spacing: 0;
  text-transform: none;
  line-height: 1.35;
}
.valuation-markdown {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  padding: 14px 14px 22px;
  min-width: 0;
}
.valuation-markdown.compact {
  padding: 8px 0 0;
  gap: 10px;
  max-height: min(52vh, 480px);
  overflow: auto;
  min-height: 0;
}
.valuation-empty {
  padding: 18px;
  text-align: center;
  color: var(--ink-soft);
  background: #f7f3ea;
  border-radius: 12px;
  border: 1px dashed var(--line);
}
.valuation-h {
  margin: 4px 0 0;
  color: var(--brand-deep);
  line-height: 1.35;
}
.valuation-h2, .valuation-h3 {
  font-size: 14px;
  padding-bottom: 6px;
  border-bottom: 1px solid #ece5d7;
}
.valuation-h4 {
  font-size: 13px;
  color: #2f4a40;
}
.valuation-p {
  margin: 0;
  color: #24342c;
  font-size: 13px;
  line-height: 1.65;
}
.valuation-p strong, .valuation-list strong, .valuation-quote strong {
  color: var(--brand-deep);
  font-weight: 750;
}
.valuation-p code, .valuation-list code, .valuation-table code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
  background: #f1ebe0;
  border-radius: 5px;
  padding: 1px 5px;
}
.valuation-list {
  margin: 0;
  padding-left: 1.2em;
  display: grid;
  gap: 6px;
  color: #24342c;
  font-size: 13px;
  line-height: 1.55;
}
.valuation-quote {
  margin: 0;
  padding: 10px 12px;
  border-left: 3px solid var(--brand);
  background: #f3f8f5;
  border-radius: 0 10px 10px 0;
  color: #2f4a40;
  font-size: 12.5px;
  line-height: 1.55;
}
.valuation-table-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: visible;
  border: 1px solid #e4ddd0;
  border-radius: 12px;
  background: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.8);
  -webkit-overflow-scrolling: touch;
}
.valuation-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
  background: transparent;
  table-layout: auto;
}
.valuation-table th,
.valuation-table td {
  border-bottom: 1px solid #eee7da;
  border-right: 1px solid #f0eae0;
  padding: 9px 11px;
  text-align: left;
  vertical-align: top;
  line-height: 1.45;
  word-break: keep-all;
  overflow-wrap: break-word;
}
.valuation-table th:last-child,
.valuation-table td:last-child { border-right: none; }
.valuation-table tbody tr:last-child td { border-bottom: none; }
.valuation-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: linear-gradient(180deg, #f4efe4, #ebe4d5);
  color: #3d4f46;
  font-weight: 750;
  font-size: 12px;
  white-space: nowrap;
}
/* Keep short labels like 乐观/中性/悲观 on one line — prevent vertical char stacking */
.valuation-table th:first-child,
.valuation-table td:first-child {
  white-space: nowrap;
  min-width: 4.5em;
  width: 1%;
  font-weight: 700;
}
.valuation-table td.num,
.valuation-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  white-space: nowrap;
}
.valuation-table td.text {
  white-space: normal;
  min-width: 10em;
  max-width: 22em;
}
.valuation-table tbody tr:hover td {
  background: #fbf8f1;
}
.valuation-table tbody tr.tone-bull td {
  background: linear-gradient(90deg, rgba(12, 122, 77, 0.08), transparent 55%);
}
.valuation-table tbody tr.tone-base td {
  background: linear-gradient(90deg, rgba(107, 91, 62, 0.08), transparent 55%);
}
.valuation-table tbody tr.tone-bear td {
  background: linear-gradient(90deg, rgba(163, 59, 45, 0.08), transparent 55%);
}
.source-note {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 12px;
  font-style: normal;
  line-height: 1.45;
}
.history-card .valuation-markdown {
  padding: 0;
}
.history-card .valuation-table-wrap {
  border-radius: 10px;
}

.app-footer {
  margin-top: 18px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--brand-deep);
  color: #f4fffa;
  padding: 10px 16px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  z-index: 50;
  font-size: 13px;
}

@media (max-width: 1100px) {
  .workspace.detail-open { grid-template-columns: 1fr; }
  .detail-panel {
    position: fixed;
    inset: auto 0 0 0;
    top: auto;
    height: min(82vh, 780px);
    max-height: min(82vh, 780px);
    border-radius: 18px 18px 0 0;
    z-index: 40;
    box-shadow: 0 -12px 40px rgba(23,35,29,0.18);
  }
  .table-wrap { max-height: none; }
  .control-band { position: static; }
}

@media (max-width: 720px) {
  .app-shell { width: min(100% - 12px, 1440px); }
  .topbar { align-items: flex-start; flex-direction: column; }
  .advice-filter-row { gap: 5px; }
  .filter-label { width: 100%; margin-bottom: 1px; }
  thead th:nth-child(5),
  tbody td:nth-child(5) { max-width: 140px; }
}



@media (max-width: 900px) {
  .summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { align-items: flex-start; }
}

/* Scrollbars */
.table-wrap::-webkit-scrollbar,
.detail-body::-webkit-scrollbar,
.valuation-markdown.compact::-webkit-scrollbar,
.valuation-table-wrap::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
.table-wrap::-webkit-scrollbar-thumb,
.detail-body::-webkit-scrollbar-thumb,
.valuation-markdown.compact::-webkit-scrollbar-thumb,
.valuation-table-wrap::-webkit-scrollbar-thumb {
  background: #d5cdbd;
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.table-wrap::-webkit-scrollbar-track,
.detail-body::-webkit-scrollbar-track,
.valuation-markdown.compact::-webkit-scrollbar-track,
.valuation-table-wrap::-webkit-scrollbar-track {
  background: transparent;
}

.app-footer {
  opacity: 0.9;
}

.toast {
  backdrop-filter: blur(8px);
  letter-spacing: 0.01em;
}

.btn.primary {
  box-shadow: 0 4px 12px rgba(15, 107, 87, 0.18);
}
.btn.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(15, 107, 87, 0.22);
}

.control-band {
  transition: box-shadow 0.15s ease;
}


/* Layered investor-stance conclusions */
.conclusion-cell { min-width: 168px; max-width: 240px; }
.stance-stack {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.stance-stack-detail {
  gap: 10px;
  margin-top: 4px;
}
.stance-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}
.stance-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 2px 6px;
  font-size: 10.5px;
  font-weight: 750;
  line-height: 1.2;
  border: 1px solid transparent;
  white-space: nowrap;
  background: #f0f2f5;
  color: var(--ink-soft);
}
.stance-tag.decision-buy { background: #dff5ea; color: var(--buy); border-color: #9ed7bb; }
.stance-tag.decision-installment { background: #e4f4f7; color: var(--installment); border-color: #a8d5df; }
.stance-tag.decision-hold { background: #f4efe4; color: var(--hold); border-color: #d8c9a8; }
.stance-tag.decision-watch { background: #f8f0d8; color: var(--watch); border-color: #e2cb85; }
.stance-tag.decision-sell { background: #f8e6e2; color: var(--sell); border-color: #e3b1a8; }
.stance-body { min-width: 0; }
.stance-action {
  font-size: 11.5px;
  font-weight: 650;
  color: var(--ink);
  line-height: 1.35;
  word-break: break-word;
}
.stance-stack-detail .stance-action { font-size: 13px; }
.stance-price {
  margin-top: 1px;
  font-size: 11px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
}
.stance-stack-detail .stance-price { font-size: 12px; color: var(--ink); }
.history-stance {
  margin: 6px 0 8px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--ink-soft);
}


/* Current-price buy advice vs layered bands */
.buy-advice-cell {
  min-width: 132px;
  max-width: 180px;
}
.buy-advice {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}
.buy-advice-detail {
  font-size: 11px;
  line-height: 1.35;
  color: var(--ink-soft);
  word-break: break-word;
}
.buy-advice-detail-card {
  gap: 8px;
  margin-top: 4px;
}
.buy-advice-detail-card .source-note {
  margin: 0;
}
.zone-badge {
  max-width: 100%;
  white-space: normal;
  text-align: left;
  line-height: 1.25;
}

/* Phone layout: each company becomes a self-contained, touch-friendly card. */
@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 16px, 1440px);
    padding: 8px 0 calc(24px + env(safe-area-inset-bottom));
  }

  .topbar { gap: 10px; margin-bottom: 12px; }
  .brand { gap: 9px; }
  .brand-mark { width: 34px; height: 34px; }
  .topbar-actions { width: 100%; gap: 6px; }
  .live-pill {
    flex: 1 1 100%;
    min-height: 36px;
    padding: 7px 10px;
  }
  .topbar-actions .btn {
    flex: 1 1 0;
    min-height: 38px;
    padding: 7px 10px;
  }

  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .metric { min-height: 62px; padding: 9px 10px; }
  .metric-value { font-size: 17px; }

  .control-band { padding: 10px; margin-bottom: 8px; border-radius: 12px; }
  .search-box { margin-bottom: 9px; }
  .search-box input { min-height: 42px; padding: 10px 42px 10px 11px; font-size: 14px; }
  .hint-key { display: none; }
  .chip-row { gap: 6px; margin-bottom: 8px; }
  .advice-filter-row { gap: 6px; padding-top: 8px; }
  .filter-label { width: 100%; margin: 0 0 1px; }
  .chip { min-height: 34px; padding: 6px 10px; font-size: 12px; }
  .control-meta { gap: 8px; justify-content: space-between; }
  .sort-field { flex: 1 1 160px; min-height: 36px; }
  .sort-field select { flex: 1 1 auto; min-height: 36px; font-size: 13px; }
  .control-meta .btn { min-height: 36px; }
  .data-status { width: 100%; font-size: 11.5px; }

  .table-panel { overflow: visible; border-radius: 14px; }
  .table-wrap { overflow: visible; max-height: none; }
  .table-wrap > table { display: block; min-width: 0; }
  .table-wrap thead { display: none; }
  .table-wrap tbody {
    display: grid;
    gap: 10px;
    padding: 10px;
  }
  .table-wrap tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fffefb;
    box-shadow: 0 2px 7px rgba(23, 35, 29, 0.035);
  }
  .table-wrap tbody tr:nth-child(even) { background: #fffefb; }
  .table-wrap tbody tr:not(:first-child) td { border-top: 0; }
  .table-wrap tbody tr:hover { box-shadow: inset 3px 0 0 #80bca7, 0 2px 7px rgba(23, 35, 29, 0.035); }
  .table-wrap tbody tr.active { box-shadow: inset 4px 0 0 var(--brand), 0 3px 10px rgba(15, 107, 87, 0.09); }
  .table-wrap tbody td {
    min-width: 0;
    padding: 10px;
    border: 0;
    vertical-align: top;
  }
  .table-wrap tbody td:nth-child(1) { grid-column: 1; }
  .table-wrap tbody td:nth-child(2) { grid-column: 2; text-align: right; }
  .table-wrap tbody td:nth-child(3) {
    grid-column: 1 / -1;
    padding-top: 9px;
    border-top: 1px solid #e8e1d6;
    border-bottom: 1px solid #e8e1d6;
    background: rgba(247, 243, 234, 0.65);
  }
  .table-wrap tbody td:nth-child(4),
  .table-wrap tbody td:nth-child(5) { padding-top: 10px; }
  .table-wrap tbody td:nth-child(6),
  .table-wrap tbody td:nth-child(7) {
    padding-top: 8px;
    border-top: 1px solid #eee7dc;
  }
  .table-wrap tbody td:nth-child(4)::before,
  .table-wrap tbody td:nth-child(5)::before,
  .table-wrap tbody td:nth-child(6)::before,
  .table-wrap tbody td:nth-child(7)::before {
    display: block;
    margin-bottom: 4px;
    color: var(--ink-soft);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.04em;
  }
  .table-wrap tbody td:nth-child(4)::before { content: "实时行情"; }
  .table-wrap tbody td:nth-child(5)::before { content: "现价建议"; }
  .table-wrap tbody td:nth-child(6)::before { content: "估值材料"; }
  .table-wrap tbody td:nth-child(7)::before { content: "研报截止"; }
  .company-cell { min-width: 0; }
  .company-name { font-size: 15px; }
  .company-meta { font-size: 11px; }
  .market-badge { margin-top: 1px; }
  .ticker-code { margin-top: 4px; font-size: 11.5px; }
  .conclusion-cell { min-width: 0; max-width: none; }
  .stance-row { grid-template-columns: 42px minmax(0, 1fr); }
  .stance-action { font-size: 12px; }
  .quote-block, .buy-advice-cell { min-width: 0; max-width: none; }
  .quote-price { font-size: 16px; }
  .buy-advice-detail { font-size: 10.5px; }
  .valuation-col { min-width: 0; }
  .valuation-chip { padding: 4px 8px; font-size: 11px; }
  .valuation-hint { font-size: 10.5px; }
  .cutoff-cell { white-space: normal; }
  .cutoff-date { font-size: 11.5px; }
  .table-hint { display: none; }

  .detail-panel {
    height: min(88vh, 760px);
    height: min(88dvh, 760px);
    max-height: min(88vh, 760px);
    max-height: min(88dvh, 760px);
    border-radius: 16px 16px 0 0;
  }
  .detail-head { gap: 8px; padding: 12px 12px 9px; }
  .detail-head h2 { font-size: 20px; overflow-wrap: anywhere; }
  .detail-sub { font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
  .detail-head .btn.icon { flex: 0 0 36px; }
  .detail-tabs {
    gap: 6px;
    padding: 7px 10px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }
  .tab { flex: 0 0 auto; min-height: 34px; padding: 6px 11px; }
  .detail-body { padding: 10px 10px 16px; gap: 10px; }
  .detail-foot {
    gap: 8px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  }
  .detail-foot .btn { flex: 1 1 0; min-width: 0; min-height: 42px; padding: 8px; }
  .card { border-radius: 12px; padding: 10px; }
  .valuation-card-head { padding: 12px 12px 9px; }
  .valuation-markdown { gap: 10px; padding: 12px 10px 16px; }
  .valuation-markdown.compact { max-height: min(48dvh, 430px); }
  .valuation-table-wrap { border-radius: 10px; }
  .valuation-table { font-size: 12px; }
  .valuation-table th, .valuation-table td { padding: 8px 9px; }
  .valuation-p, .valuation-list { font-size: 12.5px; }
  .kv-grid { grid-template-columns: 84px minmax(0, 1fr); gap: 6px 8px; font-size: 12px; }

  .app-footer { margin-top: 14px; padding: 0 8px; font-size: 11.5px; }
  .toast {
    bottom: calc(12px + env(safe-area-inset-bottom));
    width: max-content;
    max-width: calc(100% - 24px);
    text-align: center;
  }
}
