* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0f1420; --panel: #171d2b; --panel2: #1d2434; --border: #2a3348;
  --text: #e6e9f0; --muted: #8b93a7; --up: #ff4d4f; --down: #16c784; --accent: #3b82f6;
  /* 三档梯度：最差=绿(--bad) / 中等·好=红(--good) / 最好=金(--best)。数字涨跌沿用 --up红/--down绿，语义一致 */
  --good: var(--up); --best: #ffcf33; --bad: var(--down);
}
body.theme-light {
  --bg: #f2f4f7; --panel: #ffffff; --panel2: #eef1f6; --border: #dbe1ea;
  --text: #1b2330; --muted: #6b7482; --up: #e02e2e; --down: #0f9d6b; --accent: #2563eb;
  --good: var(--up); --best: #b8860b; --bad: var(--down);
}
body {
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg); color: var(--text); height: 100vh; display: flex; flex-direction: column; overflow: hidden;
}
.update-time { font-size: 12px; color: var(--muted); }
.btn { border: none; border-radius: 8px; padding: 7px 14px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.btn-ghost { background: var(--panel2); color: var(--text); font-size: 16px; line-height: 1; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-danger { background: transparent; color: var(--up); border: 1px solid var(--border); }

.btn-preset { background: var(--panel2); color: #f7c948; border: 1px solid var(--border); }
.btn-preset:hover { border-color: #f7c948; }
.btn-forecast { background: var(--panel2); color: #7aa2ff; border: 1px solid var(--border); }
.btn-forecast:hover { border-color: var(--accent); }
.auto { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; cursor: pointer; }

/* 大盘指数条 */
.index-bar { display: flex; gap: 10px; padding: 10px 22px; background: var(--panel); border-bottom: 1px solid var(--border); }
.index-bar.hidden { display: none; }
.idx { flex: 1; min-width: 0; background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; }
.idx-name { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.idx-price { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.idx-chg { font-size: 12px; font-variant-numeric: tabular-nums; margin-top: 1px; white-space: nowrap; }

.list { flex: 1; overflow-y: auto; padding: 12px 22px 22px; }
.placeholder { color: var(--muted); text-align: center; padding: 50px; }
/* 选股进度：流程慢，必须看得见走到第几步、失败几只 */
.prog-box { padding: 30px 18px; max-width: 560px; margin: 0 auto; }
.prog-bar { height: 8px; border-radius: 4px; background: var(--panel2); border: 1px solid var(--border); overflow: hidden; }
.prog-bar > i { display: block; height: 100%; width: 2%; background: var(--accent); transition: width .3s ease; }
.prog-msg { margin-top: 10px; font-size: 13px; color: var(--text); text-align: center; font-variant-numeric: tabular-nums; }
.prog-steps { margin-top: 10px; font-size: 11px; line-height: 1.7; color: var(--muted); }
/* 选股页的进度条常驻在榜单上方（边算边出时两者同时可见），所以要紧凑，别占掉半屏 */
#pick-prog:empty { display: none; }
#pick-prog .prog-box { padding: 8px 16px 10px; max-width: none; }
#pick-prog .prog-msg { margin-top: 6px; font-size: 12px; text-align: left; }
#pick-prog .prog-steps { margin-top: 4px; line-height: 1.45; max-height: 32px; overflow: hidden; }
.row {
  display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; margin-bottom: 8px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px; cursor: pointer;
  transition: border-color 0.15s;
}
.row:hover { border-color: var(--accent); }
.row-top { display: flex; align-items: flex-start; gap: 12px; }
.row .main { flex: 1; min-width: 0; }
.row .name { font-size: 15px; font-weight: 600; line-height: 1.35; }
.row .code { font-size: 12px; color: var(--muted); margin-top: 3px; }
.row-nums { flex-shrink: 0; text-align: right; }
.row-quote { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.row .price { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.row .chg { text-align: right; font-size: 14px; font-variant-numeric: tabular-nums; width: 88px; }
.row .pct { text-align: center; font-size: 13px; font-weight: 600; padding: 2px 7px; border-radius: 6px; }
.up { color: var(--up); } .down { color: var(--down); } .flat { color: var(--muted); }
.good { color: var(--good); } .best { color: var(--best); } .bad { color: var(--bad); }
.pill-up { background: rgba(255,77,79,0.15); color: var(--up); }
.pill-down { background: rgba(22,199,132,0.15); color: var(--down); }
.pill-flat { background: var(--panel2); color: var(--muted); }
.row .del { background: transparent; border: none; color: var(--muted); font-size: 16px; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.row .del:hover { background: var(--panel2); color: var(--up); }
.invalid { color: var(--muted); font-style: italic; }

/* 新手说明页 */
.help-body { line-height: 1.7; }
.help-h { font-size: 16px; font-weight: 800; margin: 18px 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.help-h:first-child { margin-top: 0; }
.help-sub { font-size: 14px; font-weight: 700; color: var(--accent); margin: 12px 0 6px; }
.help-p { font-size: 14px; margin: 6px 0; color: var(--text); }
.help-term { font-size: 13px; padding: 5px 0; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.help-term b { color: var(--text); }
.tag-good, .tag-bad, .tag-mid { flex-shrink: 0; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 5px; }
.tag-good { color: var(--good); background: rgba(255,77,79,0.14); }
.tag-bad { color: var(--down); background: rgba(22,199,132,0.14); }
.tag-mid { color: #f7c948; background: rgba(247,201,72,0.14); }
.help-good-box, .help-bad-box { font-size: 13px; border-radius: 10px; padding: 12px 14px; margin: 8px 0; border: 1px solid var(--border); }
.help-good-box { background: rgba(255,77,79,0.06); }
.help-bad-box { background: rgba(22,199,132,0.06); }
.help-box-title { font-weight: 800; margin-bottom: 6px; }
.help-eg { display: block; margin-top: 8px; color: var(--muted); font-size: 12px; }

/* 首页 tab：持仓 / 关注 */
.home-tabs { display: flex; gap: 6px; padding: 10px 22px 0; }
.home-tabs button { background: transparent; color: var(--muted); border: none; border-bottom: 2px solid transparent; padding: 8px 14px; font-size: 15px; font-weight: 600; cursor: pointer; }
.home-tabs button:hover { color: var(--text); }
.home-tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.home-auto { margin-left: auto; align-self: center; display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; }
.home-auto input { cursor: pointer; margin: 0; }
.home-auto-sec { font-size: 11px; opacity: 0.7; }
.section-empty { color: var(--muted); font-size: 13px; padding: 30px 8px; text-align: center; }

/* 首页汇总条 */
.home-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 22px; background: var(--panel); border-bottom: 1px solid var(--border); }
.home-summary.hidden { display: none; }
.hs-info { font-size: 13px; color: var(--muted); }
.hs-info b { font-variant-numeric: tabular-nums; }
.hs-btns { display: flex; gap: 8px; flex-shrink: 0; }
/* 统一行的持仓盈亏列 + 基金标签 */
.row-flags { display: flex; flex-wrap: wrap; gap: 4px; }
.row-risk { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-risk b { font-variant-numeric: tabular-nums; }
.row-hold { margin-top: 3px; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.row-hold-pct { font-size: 11px; font-weight: 600; margin-left: 5px; }
.row-tag { display: inline-block; font-size: 10px; background: var(--panel2); border: 1px solid var(--border); color: var(--muted); border-radius: 4px; padding: 0 4px; margin-right: 5px; vertical-align: middle; }
/* 详情页信号标签 */
.signal-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.signal-tags:empty { display: none; }
.sig-chip { font-size: 12px; padding: 2px 9px; border-radius: 6px; font-weight: 600; }
.sig-chip.good { color: var(--good); background: rgba(255,77,79,0.14); }
.sig-chip.bad { color: var(--down); background: rgba(22,199,132,0.14); }
/* 综合建议徽章：可关注/观望/回避 */
.row-verdict { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 5px; vertical-align: middle; }
.row-verdict.up { color: var(--good); background: rgba(255,77,79,0.15); }
.row-verdict.down { color: var(--down); background: rgba(22,199,132,0.15); }
.row-verdict.flat { color: var(--muted); background: var(--panel2); }
/* 添加弹窗 */
.add-type { margin-bottom: 12px; }
#add-code { width: 100%; background: var(--panel2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-size: 14px; outline: none; }
#add-code:focus { border-color: var(--accent); }
#add-modal .btn-primary { margin-top: 12px; width: 100%; }

.detail-sub { font-size: 13px; color: var(--muted); margin-top: 3px; }
.chart-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.chart-label { font-size: 14px; color: var(--muted); }
.range-btns { display: flex; gap: 6px; }
.range-btns button { background: var(--panel2); color: var(--muted); border: 1px solid var(--border); border-radius: 6px; padding: 4px 10px; font-size: 12px; cursor: pointer; }
.range-btns button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
#chart { width: 100%; height: 240px; background: var(--panel2); border-radius: 10px; }
.chart-readout { font-size: 11px; color: var(--muted); padding: 3px 6px 5px; line-height: 1.6; min-height: 34px; font-variant-numeric: tabular-nums; }
.chart-readout .ro-date { color: var(--text); font-weight: 700; margin-right: 5px; }
.chart-readout b { font-variant-numeric: tabular-nums; }
.chart-stats { display: flex; gap: 18px; margin: 10px 0; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.chart-stats b { color: var(--text); font-variant-numeric: tabular-nums; }
.kv-list { margin: 4px 0 8px; }
.ai-section { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 14px; }
.ai-result { margin-top: 12px; font-size: 14px; line-height: 1.65; }
.ai-result:empty { display: none; }
.ai-result h2 { font-size: 15px; margin: 12px 0 6px; color: var(--accent); }
.ai-result p { margin: 6px 0; }
.ai-result ul, .ai-result ol { margin: 6px 0; padding-left: 1.7em; }
.ai-result li { margin: 3px 0; }
.ai-result.loading { color: var(--muted); }
.field-label { font-size: 14px; font-weight: 600; display: block; }
.field-hint { font-size: 12px; color: var(--muted); margin: 6px 0 10px; }
#key-input { width: 100%; background: var(--panel2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; font-size: 13px; outline: none; margin-bottom: 8px; }
.key-status { font-size: 12px; margin-bottom: 12px; }
.settings-divider { height: 1px; background: var(--border); margin: 18px 0; }
.kv { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--muted); } .kv .v { font-variant-numeric: tabular-nums; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #000; color: #fff; padding: 11px 18px; border-radius: 8px; font-size: 14px; z-index: 200; }
.toast.hidden { display: none; }

/* 工具栏新按钮 */
.btn-flow { background: var(--panel2); color: #f7c948; border: 1px solid var(--border); }
.btn-flow:hover { border-color: #f7c948; }
.btn-news { background: var(--panel2); color: #6ee7b7; border: 1px solid var(--border); }
.btn-news:hover { border-color: #6ee7b7; }
.btn-recommend { background: linear-gradient(90deg, #f59e0b, #ef4444); color: #fff; font-weight: 600; }
.btn-recommend:hover { filter: brightness(1.08); }
.btn-recommend:disabled { opacity: 0.6; cursor: default; }
.btn-lg { padding: 11px 22px; font-size: 15px; margin-top: 14px; }

/* 持仓 / 提醒 按钮 */
.btn-hold { background: var(--panel2); color: #f7c948; border: 1px solid var(--border); }
.btn-hold:hover { border-color: #f7c948; }
.btn-alert { background: var(--panel2); color: #7aa2ff; border: 1px solid var(--border); }
.btn-alert:hover { border-color: var(--accent); }

/* 行内持仓徽标 */
.hold-badge { display: inline-block; margin-top: 5px; font-size: 12px; padding: 1px 8px; border-radius: 6px; background: var(--panel2); font-variant-numeric: tabular-nums; }

/* 详情弹窗内的持仓/提醒区 */
.position-section { display: flex; gap: 14px; margin: 6px 0 4px; flex-wrap: wrap; }
.pos-block { flex: 1; min-width: 240px; background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.pos-title { font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.pos-form { display: flex; gap: 8px; flex-wrap: wrap; }
.pos-form input, .pos-form select { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 7px 9px; font-size: 13px; outline: none; width: 92px; }
.pos-form select { width: 78px; }
.pos-form input:focus, .pos-form select:focus { border-color: var(--accent); }
.pos-form .btn { padding: 7px 12px; }
.pos-pnl { margin-top: 10px; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.pos-empty { color: var(--muted); font-size: 13px; margin-top: 8px; }
.alert-list { margin-top: 8px; }
.alert-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid var(--border); font-size: 13px; font-variant-numeric: tabular-nums; }
.alert-state { color: var(--muted); font-size: 12px; margin-left: auto; }
.mini-del { background: transparent; border: none; color: var(--muted); cursor: pointer; font-size: 13px; padding: 2px 6px; border-radius: 5px; }
.mini-del:hover { color: var(--up); background: var(--panel); }

/* 持仓总览 / 提醒管理 列表 */
.hold-row { display: flex; align-items: center; gap: 12px; padding: 12px 6px; border-bottom: 1px solid var(--border); }
.hold-main { flex: 1; min-width: 0; }
.hold-name { font-size: 15px; font-weight: 600; }
.hold-code { font-size: 12px; color: var(--muted); margin-top: 2px; }
.hold-quote { width: 96px; text-align: right; }
.hold-now { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.hold-day { font-size: 12px; font-variant-numeric: tabular-nums; margin-top: 2px; }
.hold-oc { width: 108px; display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.hold-gain { width: 150px; text-align: right; }
.hold-today { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.hold-pnl { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.hold-pct { font-size: 12px; font-weight: 600; margin-top: 2px; }
.hold-auto { color: var(--muted); }
.hold-row .del { background: transparent; border: none; color: var(--muted); font-size: 15px; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.hold-row .del:hover { color: var(--up); background: var(--panel2); }

@media (max-width: 640px) {
  .hold-row { gap: 8px; flex-wrap: wrap; }
  .hold-oc { display: none; }
  .hold-gain { width: 130px; }
}

/* 技术信号面板 */
.tech-panel { background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin: 4px 0 8px; }
.tech-panel:empty { display: none; }
.tech-title { font-size: 14px; font-weight: 700; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.tech-verdict { font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 6px; }
.tech-verdict.up { background: rgba(255,77,79,0.15); color: var(--good); }
.tech-verdict.down { background: rgba(22,199,132,0.15); color: var(--down); }
.tech-verdict.flat { background: var(--panel); color: var(--muted); }
.tech-ma-row { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 8px; }
.tech-ma { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; font-variant-numeric: tabular-nums; }
.tech-ma i { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }
.tech-kv { display: flex; justify-content: space-between; padding: 5px 0; border-top: 1px solid var(--border); font-size: 13px; }
.tech-kv span { color: var(--muted); } .tech-kv b { font-variant-numeric: tabular-nums; }
.tech-note { font-size: 11px; color: var(--muted); margin-top: 8px; line-height: 1.5; }
.risk-warn { font-size: 12px; color: var(--bad); margin-top: 6px; }
.mf-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 8px 0; }
.mf-cell { text-align: center; font-size: 12px; }
.mf-cell span { color: var(--muted); display: block; margin-bottom: 2px; }
.mf-cell b { font-variant-numeric: tabular-nums; }
/* 回测 */
.bt-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px; }
.bt-card { background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; padding: 10px; text-align: center; }
.bt-card span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.bt-card b { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.bt-subtitle { font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
.bt-list { display: flex; flex-direction: column; }
.bt-trade { display: flex; justify-content: space-between; padding: 7px 4px; border-bottom: 1px solid var(--border); font-size: 13px; font-variant-numeric: tabular-nums; }
.bt-trade i { color: var(--muted); font-style: normal; font-size: 11px; margin-left: 4px; }
@media (max-width: 640px) { .bt-cards { grid-template-columns: repeat(2, 1fr); } }

/* 策略擂台 */
.battle-champ-tip { background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; font-size: 14px; margin-bottom: 12px; }
.battle-row { display: flex; align-items: center; gap: 12px; padding: 12px 8px; border-bottom: 1px solid var(--border); }
.battle-row.champ { background: rgba(255,217,102,0.08); border-radius: 8px; }
.battle-rank { width: 28px; text-align: center; font-size: 16px; font-weight: 700; color: var(--muted); flex-shrink: 0; }
.battle-main { flex: 1; min-width: 0; }
.battle-name { font-size: 15px; font-weight: 600; }
.battle-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.battle-stats { display: flex; gap: 14px; font-size: 12px; color: var(--muted); flex-shrink: 0; }
.battle-stats b { font-variant-numeric: tabular-nums; }
@media (max-width: 640px) { .battle-stats { flex-direction: column; gap: 2px; text-align: right; } }

/* 选股 */
.btn-pick { background: var(--panel2); color: #ffd966; border: 1px solid var(--border); }
.btn-pick:hover { border-color: #ffd966; }
/* 顶部只留本次的动态状态，最多两行（警告排在最前，不会被截掉）；说明全文在「❓选股逻辑」里 */
.pick-hint {
  padding: 8px 16px 4px; font-size: 12px; color: var(--muted); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.pick-hint:empty { display: none; }
/* 说明弹层里的成段文字：不能用 .help-term(它是 flex，<br> 会失效) */
.help-p { font-size: 13px; line-height: 1.75; color: var(--muted); }
.help-p b { color: var(--text); }
/* 两行卡片：第一行"名称·行业·涨幅·分数"，第二行标签占满整行。
   不要再用"左侧内容+右侧报价栏"的横向布局——标签会被挤在半边、右边留一大块空白，一屏放不下几只 */
.pick-row { padding: 9px 10px; border-bottom: 1px solid var(--border); cursor: pointer; }
.pick-row:hover { background: var(--panel2); }
.pick-head { display: flex; align-items: baseline; gap: 6px; }
.pick-rank { width: 17px; text-align: center; color: var(--muted); font-size: 12px; font-weight: 700; flex-shrink: 0; }
/* 名字最多占 46%，超长(如"金 螳 螂"带空格)截断而不是把行业挤到下一行 */
.pick-name { font-size: 15px; font-weight: 600; flex: 0 0 auto; max-width: 46%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick-ind { flex: 1 1 auto; min-width: 0; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick-pct { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.pick-score { min-width: 30px; text-align: right; font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.pick-flags { margin-top: 4px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.pick-flag { font-size: 11px; color: var(--good); background: rgba(255,77,79,0.12); padding: 1px 7px; border-radius: 5px; }
.pick-flag.warn { color: var(--bad); background: rgba(22,199,132,0.14); }
.pick-flag.mid { color: var(--muted); background: var(--panel2); }
.pick-flag.tech { color: var(--good); background: rgba(255,77,79,0.14); }
.pick-spark { flex-shrink: 0; display: block; opacity: .85; }
.pick-quote2 { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
/* 「能不能买」的直白结论：放在分数后面，做成实心药丸让它最显眼。配色沿用三档：最好金/中等红/最差绿 */
.pick-buy {
  flex-shrink: 0; font-size: 12px; font-weight: 800; padding: 3px 8px; border-radius: 6px;
  white-space: nowrap; letter-spacing: .5px;
}
.pick-buy.yes-best { color: #3a2a00; background: var(--best); }
.pick-buy.yes { color: #fff; background: var(--good); }
.pick-buy.wait { color: var(--muted); background: var(--panel2); border: 1px solid var(--border); }
.pick-buy.no { color: #fff; background: var(--bad); }

/* 龙虎榜 / 体检 按钮 */
.btn-dt { background: var(--panel2); color: #ff9d5c; border: 1px solid var(--border); }
.btn-dt:hover { border-color: #ff9d5c; }

/* 龙虎榜列表 */
.dt-row { display: flex; align-items: center; gap: 14px; padding: 11px 6px; border-bottom: 1px solid var(--border); }
.dt-pct { font-size: 12px; margin-left: 6px; }
.dt-net { text-align: right; font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.dt-bs { font-size: 11px; color: var(--muted); font-weight: 400; margin-top: 2px; }

/* 同板块联动 */
.peers-block { background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin: 6px 0 4px; }
.board-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.board-chip { font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--panel); border: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.peer-list { display: flex; flex-direction: column; gap: 2px; }
.peer-row { display: flex; align-items: center; gap: 12px; padding: 6px 4px; border-top: 1px solid var(--border); font-size: 13px; }
.peer-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.peer-price { font-variant-numeric: tabular-nums; width: 70px; text-align: right; }
.peer-pct { font-variant-numeric: tabular-nums; width: 66px; text-align: right; font-weight: 600; }
.peer-add { background: transparent; border: 1px solid var(--border); color: var(--accent); border-radius: 6px; padding: 2px 8px; font-size: 12px; cursor: pointer; }
.peer-add:hover { background: var(--accent); color: #fff; }

/* 定投计算器 */
.dca-form { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.dca-form label { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 5px; }
.dca-form input, .dca-form select { background: var(--panel2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 13px; outline: none; width: 120px; }
.dca-form input:focus, .dca-form select:focus { border-color: var(--accent); }
.dca-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 24px; }
.dca-kv { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.dca-kv span { color: var(--muted); } .dca-kv b { font-variant-numeric: tabular-nums; }

/* AI 结果弹窗置于所有弹窗之上；小号按钮；可点击的持仓行 */
#ai-popup { z-index: 340; }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.modal-subbar { padding: 10px 20px 0; }
.holdings-subbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.holdings-subbar .detail-sub { flex: 1; min-width: 0; margin-top: 0; }
.holdings-subbar .btn { flex-shrink: 0; }
/* 详情弹窗的 AI分析按钮离关闭键远一点，避免误触 */
#ai-btn { margin-right: 16px; }
.hold-clickable { cursor: pointer; transition: background 0.12s; }
.hold-clickable:hover { background: var(--panel2); }

/* ===== iOS 安全区（刘海/灵动岛/底部横条）；非刘海设备 env()=0，不影响安卓/桌面 ===== */
html, body { background: var(--bg); }
/* 横屏时避开摄像头挖孔/刘海（左右安全区）；竖屏/无挖孔时 =0 */
body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }

/* ===== 手机竖屏适配 ===== */
@media (max-width: 640px) {
  .web-wrap { padding-bottom: env(safe-area-inset-bottom); }
  body { -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
  input, textarea, select, .ai-result, .news-title, .news-sum, .dt-row { -webkit-user-select: text; user-select: text; }

  /* iOS 聚焦输入不放大：字号 ≥16px */
  input, select, textarea { font-size: 16px; }
  .home-tabs { padding: 8px 12px 0; }
  .home-summary { padding: 8px 12px; flex-wrap: wrap; gap: 8px; }
  .hs-info { font-size: 12px; }
  .row { padding: 12px 14px; }
  .row-top { gap: 10px; }
  .row .name { font-size: 14px; }
  .row .price { font-size: 17px; }
  .row-hold { font-size: 12px; }
  .index-bar { padding: 8px 12px; gap: 6px; }
  .idx { padding: 6px 9px; }
  .idx-price { font-size: 16px; }
  .idx-name, .idx-chg { font-size: 11px; }
  .btn { padding: 8px 12px; }
  .auto { flex: 0 0 auto; white-space: nowrap; }

  .list { padding: 10px 12px 20px; }
  .row { gap: 8px; padding: 12px; }
  .row .price { font-size: 16px; width: 82px; }
  .row .chg { display: none; }
  .row .pct { width: 64px; }

  /* 资金流向：图在上、榜单在下 */
  .flow-body { flex-direction: column; padding: 12px; }
  #flow-chart { height: 50vh; }
  .flow-rank { width: 100%; max-height: 34vh; }

  #chart { height: 200px; }
  .chart-tip { font-size: 13px; }
  .dca-form { gap: 10px; }
  .dca-grid { grid-template-columns: 1fr; gap: 2px; }
}

/* 今日推荐 */
.recommend-intro p { font-size: 14px; line-height: 1.7; color: var(--text); }
.recommend-intro .field-hint { margin-top: 8px; }
.recommend-meta { font-size: 12px; color: var(--muted); background: var(--panel2); padding: 8px 12px; border-radius: 8px; margin-bottom: 14px; line-height: 1.6; }
.ai-result h2 { border-left: 3px solid var(--accent); padding-left: 8px; }

/* 走势图 hover 气泡 */
.chart-tip {
  position: fixed; z-index: 300; pointer-events: none;
  background: rgba(15,20,32,0.95); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px; font-size: 12px; line-height: 1.5; box-shadow: 0 4px 14px rgba(0,0,0,0.4);
}
.chart-tip.hidden { display: none; }
.chart-tip .tip-date { color: var(--muted); }
.chart-tip .tip-val { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }

/* 资金流向 */
.flow-body { display: flex; gap: 16px; padding: 16px 20px; }
.flow-chart-wrap { position: relative; flex: 1; min-width: 0; }
#flow-chart { width: 100%; height: 64vh; min-height: 360px; max-height: 760px; background: var(--panel2); border-radius: 10px; }
.flow-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 14px; text-align: center; padding: 0 20px; }
.flow-rank { width: 240px; flex-shrink: 0; overflow-y: auto; max-height: 64vh; min-height: 360px; }
.flow-rank-row { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-bottom: 1px solid var(--border); font-size: 13px; }
.flow-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.flow-rank-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flow-rank-val { font-variant-numeric: tabular-nums; font-weight: 600; }

/* 资讯列表 */
.news-item { padding: 12px 14px; border-radius: 10px; cursor: pointer; border: 1px solid transparent; }
.news-item:hover { background: var(--panel2); border-color: var(--border); }
.news-top { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; flex-wrap: wrap; }
.news-time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.news-stock { font-size: 11px; color: #7aa2ff; background: rgba(122,162,255,0.12); padding: 1px 7px; border-radius: 5px; }
.news-title { font-size: 14px; font-weight: 600; line-height: 1.5; }
.news-sum { font-size: 13px; color: var(--muted); line-height: 1.55; margin-top: 4px; }

/* 内嵌浏览器 */
.web-wrap { flex: 1; min-height: 0; overflow: hidden; }
#web-view { width: 100%; height: 100%; border: none; background: #fff; }

/* ================= App 外壳：底部导航 + 页面栈 + 每页顶栏 ================= */
#app { flex: 1; position: relative; overflow: hidden; }

/* 每个 tab 是一张整页，绝对铺满 #app，仅 .active 显示；底部留出导航栏高度 */
.tab-page {
  position: absolute; inset: 0; display: none; flex-direction: column;
  padding-bottom: calc(56px + env(safe-area-inset-bottom));
}
.tab-page.active { display: flex; }
.tab-page > .app-bar,
.tab-page > .index-bar,
.tab-page > .home-tabs,
.tab-page > .home-summary,
.tab-page > .modal-subbar,
.tab-page > .sub-bar,
.tab-page > .pick-hint { flex-shrink: 0; }
.page.pushed > .app-bar,
.page.pushed > .modal-subbar { flex-shrink: 0; }

/* 资讯/内嵌浏览器在整页语境下铺满，不再受弹窗高度限制 */
.page.pushed > .news-body { max-height: none; padding: 8px 12px calc(12px + env(safe-area-inset-bottom)); }
.web-modal-inner .web-wrap { flex: 1; min-height: 0; overflow: hidden; }
.web-modal-inner #web-view { width: 100%; height: 100%; }

/* 可入栈整页：详情/回测/AI，盖住底部导航（原生 App 手感）*/
.page.pushed {
  position: fixed; inset: 0; z-index: 300; display: flex; flex-direction: column;
  background: var(--bg); animation: pageSlideIn 0.22s ease;
}
.page.pushed.hidden { display: none; }
.page.pushed > .page-body { padding: 16px 20px calc(20px + env(safe-area-inset-bottom)); }
@keyframes pageSlideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

/* 页面可滚动主体 */
.page-body { flex: 1; overflow-y: auto; min-height: 0; }
#pick-list { padding: 6px 14px 16px; }

/* 每页顶栏 */
.app-bar {
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--panel); border-bottom: 1px solid var(--border); min-height: 52px;
}
.ab-title { font-size: 17px; font-weight: 700; }
.ab-titlewrap { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ab-titlewrap .detail-sub { margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ab-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.btn.fav-on { color: var(--best); border: 1px solid var(--best); }
.ab-actions .update-time { font-size: 11px; }
.ab-icon { width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; padding: 0; }
/* 返回键：≥44px 点击区 */
.page-back {
  background: transparent; border: none; color: var(--text); font-size: 30px; line-height: 1;
  cursor: pointer; width: 44px; height: 44px; margin-left: -8px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}
.page-back:hover { background: var(--panel2); }

/* 底部导航栏 */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 250; display: flex;
  background: var(--panel); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1; background: transparent; border: none; color: var(--muted); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 0 7px;
}
.tabbar button.active { color: var(--accent); }
.tb-icon { font-size: 20px; line-height: 1; }
.tb-label { font-size: 11px; }

/* 着陆页（市场 / AI / 我的）大按钮 */
.landing { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.landing-item {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; cursor: pointer;
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 18px 16px; color: var(--text);
}
.landing-item:hover { border-color: var(--accent); }
.li-icon { font-size: 26px; flex-shrink: 0; }
.li-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.li-text b { font-size: 16px; font-weight: 700; }
.li-text small { font-size: 12px; color: var(--muted); }
.li-arrow { color: var(--muted); font-size: 22px; flex-shrink: 0; }

/* ===== 首页：图标宫格（一行 5 个）+ 资讯 ===== */
.home-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px 0;
  padding: 16px 8px 10px; flex-shrink: 0;
}
.grid-item {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  background: transparent; border: none; cursor: pointer; color: var(--text);
  padding: 8px 2px; border-radius: 12px;
}
.grid-item:hover .gi-icon { border-color: var(--accent); }
.gi-icon {
  width: 46px; height: 46px; border-radius: 14px; background: var(--panel2);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; font-size: 23px;
}
.gi-label { font-size: 12px; color: var(--muted); white-space: nowrap; }
.home-news-head {
  font-size: 15px; font-weight: 700; padding: 12px 16px 6px; flex-shrink: 0;
  border-top: 1px solid var(--border); margin-top: 4px;
}
.home-news { padding: 0 12px 12px; }

/* ===== 统一 sub-bar（选股池子 / 回测策略 等 app-bar 下方的分段栏）===== */
.sub-bar {
  flex-shrink: 0; padding: 10px 12px; background: var(--panel);
  border-bottom: 1px solid var(--border);
}
/* 6 个池子在手机上放不下：改成横向滑动的分段栏（滑动只发生在这条栏里，不会让整页左右晃） */
.pick-pool-btns { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.pick-pool-btns::-webkit-scrollbar { display: none; }
.pick-pool-btns button {
  flex: 1 0 auto; padding: 11px 10px; font-size: 14px; font-weight: 600; border-radius: 10px; white-space: nowrap;
}
/* 主题选股的关键词输入行 */
.theme-bar { flex-shrink: 0; display: flex; gap: 8px; padding: 10px 12px; background: var(--panel); border-bottom: 1px solid var(--border); }
.theme-bar.hidden { display: none; }
.theme-bar input {
  flex: 1; min-width: 0; background: var(--panel2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 12px; font-size: 14px; outline: none;
}
.theme-bar input:focus { border-color: var(--accent); }
.theme-suggest { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 12px; }
.theme-suggest button {
  background: var(--panel2); color: var(--accent); border: 1px solid var(--border);
  border-radius: 14px; padding: 6px 12px; font-size: 12px; cursor: pointer;
}

/* ===== 设置：分块 ===== */
.settings-block {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; margin: 12px 16px 0;
}
.settings-block:first-of-type { margin-top: 12px; }
/* 宽度必须减掉左右 margin：基础规则是 width:100%，叠上 margin 会比容器宽 32px 让整页能左右滑；
   而 button 的 width:auto 是"按文字收缩"(不像 div 会填满)，会让三行宽度参差不齐。
   所以显式 calc，跟下面 .settings-block 的实际宽度对齐 */
#page-settings .landing-item { margin: 12px 16px 0; width: calc(100% - 32px); }

/* 层级修正：提示/toast 必须盖住底部导航栏 */
#ai-popup { z-index: 300; }
.chart-tip { z-index: 400; }
.toast { z-index: 500; }

/* ===== 手机竖屏：宫格保持一行 5 个（截图风格），图标略缩 ===== */
@media (max-width: 480px) {
  .home-grid { gap: 8px 0; padding: 12px 4px 4px; }
  .gi-icon { width: 40px; height: 40px; font-size: 20px; }
  .gi-label { font-size: 11px; }
  .pick-pool-btns button { font-size: 12px; padding: 10px 3px; }
  /* 顶栏按钮多了以后窄屏只留图标，否则会把标题挤没/撑破 */
  #pick-modal .ab-actions .btn-label,
  #detail-modal .ab-actions .btn-label { display: none; }
  #pick-modal .ab-actions .btn,
  #detail-modal .ab-actions .btn { padding: 7px 9px; }
  #detail-modal .ab-actions { gap: 6px; }
}
