:root {
  --red: #C00000;
  --dark: #0B1F2A;
  --gray: #78909A;
  --light-gray: #9AAAB0;
  --line: #E4E9EB;
  --bg: #F7F9FA;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Microsoft YaHei", "PingFang SC", "Heiti TC", sans-serif;
  background: var(--bg);
  color: var(--dark);
}

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 14px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 6px; height: 40px; background: var(--red); border-radius: 2px; }
.brand h1 { font-size: 18px; font-weight: 700; }
.brand p { font-size: 11px; color: var(--gray); margin-top: 2px; }

.topbar nav { display: flex; gap: 6px; }
.topbar nav a {
  text-decoration: none;
  color: var(--gray);
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 6px;
}
.topbar nav a.active { color: var(--red); background: #FBEDED; font-weight: 700; }
.topbar nav a:hover { color: var(--red); }

main { max-width: 1280px; margin: 0 auto; padding: 24px 32px 40px; }

.hero { padding: 20px 0 12px; }
.hero h2 { font-size: 20px; font-weight: 700; }
.hero p { font-size: 12px; color: var(--gray); margin-top: 6px; }

.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 16px; }

.model-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px 22px 16px;
  text-decoration: none;
  color: inherit;
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.15s;
}
.model-card:hover { box-shadow: 0 4px 16px rgba(11, 31, 42, 0.08); }
.card-accent { position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--red); }
.model-card h3 { font-size: 16px; font-weight: 700; }
.model-card .sub { font-size: 11px; color: var(--gray); margin: 4px 0 10px; }
.mini-chart { height: 110px; }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.stat-row strong { display: block; font-size: 17px; font-weight: 700; }
.stat-row span { display: block; font-size: 10px; color: var(--gray); margin-top: 2px; }
.model-card .more { font-size: 12px; color: var(--red); margin-top: 12px; font-weight: 700; }

.page-head { padding: 12px 0 16px; }
.page-head h2 { font-size: 22px; font-weight: 700; }
.page-head .kicker { font-size: 12px; color: var(--gray); margin-top: 6px; }

.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 18px;
}
.panel-title { font-size: 14px; font-weight: 700; margin-bottom: 12px; }
.panel-head-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.panel-head-row .panel-title { margin-bottom: 0; }

.chart-lg { height: 420px; }
.signal-note { font-size: 11px; color: var(--gray); margin-top: 6px; }

.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
}
.metric strong { display: block; font-size: 22px; font-weight: 700; }
.metric span { display: block; font-size: 11px; color: var(--dark); font-weight: 700; margin-top: 4px; }
.metric em { display: block; font-size: 10px; color: var(--gray); font-style: normal; }

.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th {
  text-align: left; padding: 8px 10px; border-bottom: 2px solid var(--dark);
  font-weight: 700; color: var(--dark);
}
.data-table td { padding: 7px 10px; border-bottom: 1px solid var(--line); }
.data-table tr:hover td { background: #FAFBFC; }
.data-table.compact { font-size: 11px; }
.data-table.compact td, .data-table.compact th { padding: 5px 8px; }

.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.segmented button {
  border: none; background: #fff; padding: 6px 14px; font-size: 12px; color: var(--gray); cursor: pointer;
}
.segmented button.active { background: var(--red); color: #fff; font-weight: 700; }

.period-select { font-size: 12px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 6px; }

.factor-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.factor-cell { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.factor-name { font-size: 12px; font-weight: 700; margin-bottom: 6px; }
.factor-chart { height: 90px; }

.footnote { font-size: 11px; color: var(--gray); text-align: center; padding: 18px 0 6px; }

@media (max-width: 900px) {
  .cards { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .factor-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ===== 刷新按钮 ===== */
.refresh-btn {
  margin-left: 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--dark);
  font-size: 12px;
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
}
.refresh-btn:hover { border-color: var(--red); color: var(--red); }

/* ===== 持仓行点击 ===== */
.stock-row { cursor: pointer; }
.stock-row:hover td { background: #F0F5FB !important; }
.stock-link { color: #2458A6; font-weight: 700; text-decoration: underline; text-decoration-color: rgba(36,88,166,0.35); }

/* ===== 个股详情弹窗 ===== */
.modal-mask {
  position: fixed; inset: 0; background: rgba(11,31,42,0.35);
  display: none; align-items: center; justify-content: center; z-index: 100;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; border-radius: 12px; width: 720px; max-width: 96vw;
  height: 80vh; max-height: 92vh; padding: 20px 24px;
  box-shadow: 0 12px 40px rgba(11,31,42,0.18);
  position: relative; min-width: 420px; min-height: 300px;
  display: flex; flex-direction: column; overflow: hidden;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.modal-head strong { font-size: 18px; }
.modal-code { font-size: 12px; color: var(--gray); margin-left: 10px; }
.modal-close { border: none; background: none; font-size: 16px; color: var(--gray); cursor: pointer; }
.modal-close:hover { color: var(--red); }
.modal-body { padding-top: 14px; flex: 1; overflow-y: auto; }
.modal-empty { font-size: 12px; color: var(--gray); padding: 20px 0; text-align: center; }

.detail-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.detail-metrics div { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.detail-metrics strong { display: block; font-size: 17px; }
.detail-metrics span { font-size: 10px; color: var(--gray); }
.detail-block { margin-bottom: 14px; }
.detail-title { font-size: 12px; font-weight: 700; margin-bottom: 6px; }
.detail-chart { height: 150px; border: 1px solid var(--line); border-radius: 8px; }

/* ===== 面板质感 ===== */
.panel { box-shadow: 0 1px 3px rgba(11,31,42,0.04); }
.metric strong { font-variant-numeric: tabular-nums; }
.data-table td, .data-table th { font-variant-numeric: tabular-nums; }

/* ===== 五因子得分条 ===== */
.score-row { display: flex; align-items: center; gap: 10px; margin-bottom: 7px; }
.score-label { width: 60px; font-size: 11px; color: var(--dark); }
.score-track { flex: 1; height: 8px; background: #EEF1F2; border-radius: 4px; overflow: hidden; }
.score-fill { height: 100%; background: #2458A6; border-radius: 4px; }
.score-val { width: 34px; text-align: right; font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ===== 一页通叙事块 ===== */
.one-pager {
  border: 1px solid var(--line); border-radius: 8px;
  padding: 14px 16px; max-height: 320px; overflow-y: auto;
  font-size: 12px; line-height: 1.75; color: var(--dark);
}
.one-pager h4 { font-size: 13px; margin: 12px 0 6px; color: var(--red); }
.one-pager h5 { font-size: 12px; margin: 10px 0 4px; }
.one-pager strong { color: var(--dark); }

/* ===== 一页通内嵌表格 ===== */
.one-pager .md-table { width: 100%; border-collapse: collapse; font-size: 11px; margin: 8px 0 12px; }
.one-pager .md-table th {
  text-align: left; padding: 6px 8px; background: #F0F5FB;
  border: 1px solid var(--line); font-weight: 700; white-space: nowrap;
}
.one-pager .md-table td { padding: 6px 8px; border: 1px solid var(--line); vertical-align: top; }
.one-pager .md-table tr:nth-child(even) td { background: #FAFBFC; }

/* ===== 总览：大迷你图 / 对比表 / 事件条 ===== */
.mini-chart-lg { height: 160px; }
.card-accent.blue { background: #2458A6; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.table-note { font-size: 11px; color: var(--gray); margin-top: 8px; }
.event-panel .event-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.event-item { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.event-label { display: block; font-size: 11px; color: var(--gray); margin-bottom: 4px; }
.event-item strong { font-size: 14px; }

/* ===== 择时：收益分解卡 / 逐年图 ===== */
.split-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.split-card { border: 1px solid var(--line); border-radius: 8px; padding: 16px; text-align: center; }
.split-card strong { display: block; font-size: 24px; font-weight: 700; }
.split-card.on strong { color: #C00000; }
.split-card.off strong { color: #78909A; }
.split-card span { font-size: 11px; color: var(--gray); }
.chart-md { height: 300px; }

/* ===== 选股：区间小灰字 / 年度卡片 / 持仓宽松化 / sticky 弹窗头 ===== */
.range-sub { font-size: 11px; color: var(--gray); margin: 2px 0 10px; }

.year-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.year-card { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.year-card.win { border-top: 3px solid #2CA02C; }
.year-card.lose { border-top: 3px solid #C00000; }
.year-num { font-size: 12px; color: var(--gray); font-weight: 700; }
.year-excess { font-size: 22px; font-weight: 700; margin: 4px 0 10px; font-variant-numeric: tabular-nums; }
.year-card.win .year-excess { color: #2CA02C; }
.year-card.lose .year-excess { color: #C00000; }
.ybar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.ybar-row span { width: 30px; font-size: 10px; color: var(--gray); }
.ybar-track { flex: 1; height: 7px; background: #EEF1F2; border-radius: 4px; overflow: hidden; }
.ybar-fill { height: 100%; border-radius: 4px; }
.ybar-fill.blue { background: #2458A6; }
.ybar-fill.gray { background: #9AAAB0; }
.ybar-row b { width: 52px; text-align: right; font-size: 10px; font-variant-numeric: tabular-nums; }
.year-mdd { font-size: 10px; color: var(--gray); margin-top: 8px; }

.data-table.holdings { font-size: 11px; max-width: 760px; }
.data-table.holdings td, .data-table.holdings th { padding: 3px 8px; }
.data-table.holdings tbody tr:nth-child(even) td { background: #FAFBFC; }
.weight-cell { display: flex; align-items: center; gap: 8px; }
.wbar-track { width: 40px; height: 6px; background: #EEF1F2; border-radius: 3px; overflow: hidden; }
.wbar-fill { height: 100%; background: #2458A6; border-radius: 3px; }
.tier-line td { padding: 0 !important; border-bottom: 2px solid var(--dark) !important; }

.modal-head.sticky {
  background: #fff; z-index: 5; flex-shrink: 0;
}

/* 自定义缩放手柄（贴合圆角，固定于右下角） */
.modal-grip {
  position: absolute;
  right: 5px; bottom: 5px;
  width: 18px; height: 18px;
  cursor: nwse-resize;
  z-index: 10;
  background: linear-gradient(135deg, transparent 50%, #78909A 50%);
  border-radius: 0 0 8px 0;
  opacity: 0.6;
}
.modal-grip:hover { opacity: 1; }

/* 持仓两栏布局 */
.holdings-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.holdings-cols .data-table.holdings { max-width: none; }


/* ===== 复盘面板 ===== */
.data-table.review td, .data-table.review th { padding: 6px 10px; }
.review-row { cursor: pointer; }
.review-row:hover td, .review-row.active td { background: #F0F5FB; }
.pos { color: #2CA02C; font-weight: 700; }
.neg { color: #C00000; font-weight: 700; }
.attrib-cols { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; margin-top: 14px; border-top: 1px solid var(--line); padding-top: 14px; }
.attrib-title { font-size: 12px; font-weight: 700; margin-bottom: 8px; }
.attrib-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.attrib-name { width: 110px; font-size: 11px; }
.attrib-name em { font-style: normal; color: var(--gray); margin-left: 4px; font-size: 10px; }
.attrib-track { flex: 1; height: 8px; background: #EEF1F2; border-radius: 4px; overflow: hidden; }
.attrib-fill { height: 100%; border-radius: 4px; }
.pos-fill { background: #2CA02C; }
.neg-fill { background: #C00000; }
.attrib-row b { min-width: 56px; text-align: right; font-size: 11px; font-variant-numeric: tabular-nums; }
