/* =====================================================================
 * 胡大股票分析系统 — 全局样式（简洁现代，移动优先，无 Bootstrap 依赖）
 * 布局语言：topbar 导航 / page-title + page-sub / card 分块 /
 *           stat 指标格 / chip 紧凑标签 / table.data 数据表
 * 股市配色：红涨 #e0453e、绿跌 #18a058（中国习惯）
 * ===================================================================== */

:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #2f54eb;
  --brand-dark: #1d39c4;
  --brand-soft: #eef2ff;
  --buy: #e0453e;        /* 涨 / 买入：红 */
  --sell: #18a058;       /* 跌 / 卖出：绿 */
  --watch: #9ca3af;
  --warn: #f59e0b;
  --danger: #dc2626;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
  --radius: 12px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.6 "Microsoft YaHei", "PingFang SC", -apple-system, Arial, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4, h5, h6 { line-height: 1.35; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  background: linear-gradient(120deg, #1d39c4, #2f54eb);
  color: #fff; padding: 0;
  display: flex; flex-direction: column;
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 2px 8px rgba(29, 57, 196, .25);
}
/* 第一行：标题（左）+ 切换/用户/后台数据库（右） */
.topbar .top-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 8px 12px; min-height: 44px;
}
.topbar .logo {
  font-size: 16px; font-weight: 700; color: #fff;
  white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
}
.topbar .logo:hover { text-decoration: none; }
/* 第二行：功能菜单横向滚动，手机好操作 */
.topbar .nav-scroll {
  display: flex; align-items: center; gap: 2px;
  overflow-x: auto; scrollbar-width: none;
  padding: 0 8px 8px; width: 100%;
}
.topbar .nav-scroll::-webkit-scrollbar { display: none; }
.topbar a.nav {
  color: rgba(255,255,255,.82); padding: 7px 12px; border-radius: 8px;
  font-size: 14px; white-space: nowrap;
}
.topbar a.nav:hover { background: rgba(255,255,255,.14); color: #fff; text-decoration: none; }
.topbar a.nav.active { background: rgba(255,255,255,.2); color: #fff; font-weight: 600; }
.topbar .spacer { flex: 0 0 4px; }
.topbar .user { font-size: 13px; opacity: .92; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.topbar .user a { color: #fff; }
.topbar .user .uname { opacity: .85; }
.avatar-circle {
  width: 30px; height: 30px; border-radius: 50%; object-fit: cover;
  background: #fff; color: var(--brand-dark);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; overflow: hidden; flex: 0 0 auto;
}
.role-tag { background: rgba(255,255,255,.22); color: #fff; padding: 2px 8px;
  border-radius: 999px; font-size: 11px; }

/* ---------------- 容器 / 页标题 ---------------- */
.container { max-width: 1200px; margin: 20px auto; padding: 0 14px; }
.page-title { font-size: 20px; font-weight: 700; margin: 0 0 6px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page-sub { margin: 0 0 18px; font-size: 13px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page-sub .muted-txt { color: var(--muted); }

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 16px;
}
.card > h3 { margin: 0 0 12px; font-size: 15px; display: flex;
  align-items: center; gap: 8px; flex-wrap: wrap; }
.card > h3 .tip { font-weight: 400; color: var(--muted); font-size: 12px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap; margin-bottom: 12px;
}
.card-head h3 { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 8px; }

/* ---------------- 网格 / 指标格 ---------------- */
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-6 { grid-template-columns: repeat(6, 1fr); }
.layout-2col { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; align-items: start; }
.layout-7-5 { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }
.layout-7-5 > .col-main { grid-column: span 7; }
.layout-7-5 > .col-side { grid-column: span 5; }
@media (max-width: 960px) {
  .grid-3, .grid-4, .grid-6 { grid-template-columns: repeat(2, 1fr); }
  .layout-2col, .layout-7-5 { grid-template-columns: 1fr; }
  .layout-7-5 > .col-main, .layout-7-5 > .col-side { grid-column: span 1; }
}
.stat { background: #f8fafc; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; }
.stat .k { color: var(--muted); font-size: 12px; }
.stat .v { font-size: 20px; font-weight: 700; margin-top: 2px; }
.stat .v.small { font-size: 16px; }
.up { color: var(--buy); }
.down { color: var(--sell); }
.muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------- 徽标 ---------------- */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; line-height: 1.7; white-space: nowrap; }
.badge.buy, .badge.regime-up, .badge.type-holding { background: #fde8e7; color: var(--buy); }
.badge.sell, .badge.regime-down { background: #e5f6ec; color: var(--sell); }
.badge.watch, .badge.regime-range, .badge.type-watch { background: #eef2ff; color: var(--brand); }
.badge.gray { background: #f0f1f3; color: #6b7280; }
.badge.emerg { background: #fff3e0; color: #d97706; }
.badge.traded { background: var(--danger); color: #fff; }
.badge.ok { background: #e9f8ef; color: #157347; }
.badge.warn { background: #fff8e6; color: #9a6700; }
.badge.bad { background: #fdecea; color: #b02a37; }
/* 板块“待补充”等可点击徽标 */
button.badge { border: none; cursor: pointer; font-size: 12px; }
button.badge:hover { filter: brightness(0.94); }
.ind-edit { padding: 1px 6px !important; }

/* ---------------- 表格 ---------------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
/* 全站数据表统一网格线：单元格四周浅灰细线，表头底线略深以分层 */
table.data th, table.data td { border: 1px solid #e3e7ee; }
table.data th { background: #f8fafc; color: var(--muted); font-weight: 600;
  text-align: left; padding: 9px 10px; border-bottom: 1px solid #d9dfe8;
  white-space: nowrap; }
table.data td { padding: 9px 10px; vertical-align: middle; }
/* 对齐语义（表头与内容同向）：默认左=文本列，.num=右（数字列），.ctr=中（徽章/操作/序号）
   注意必须提高到 table.data th 级别，否则会被上面的 th 左对齐覆盖 */
table.data th.num, table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data th.ctr, table.data td.ctr { text-align: center; }
table.data tbody tr:hover td { background: #ffeb3b; }
table.data tfoot td { font-weight: 700; background: #f8fafc; }

/* 首页股票列表：表头加粗、行状态底色（对齐跟随语义类，表头与内容同向） */
table.stock-table th { font-size: 14px; font-weight: 800; color: #111827;
  padding: 11px 10px; }
table.stock-table tbody tr.row-watch td { background: #f8faff; }
table.stock-table tbody tr.row-holding td { background: #fff9f8; }
table.stock-table tbody tr:hover td { background: #ffeb3b; }

/* 操作单元格 */
.action-cell { white-space: nowrap; text-align: center !important; }
.action-cell .btn, .action-cell form { margin: 0 2px; }
form.inline { display: inline; }

/* 手机端：宽表转卡片（单元格需带 data-label） */
@media (max-width: 767.98px) {
  table.card-table thead { display: none; }
  table.card-table, table.card-table tbody,
  table.card-table tr, table.card-table td { display: block; width: 100%; }
  table.card-table tr {
    border: 1px solid var(--line); border-radius: 10px;
    margin-bottom: 10px; padding: 4px 8px; background: #fff;
  }
  table.card-table tbody tr:hover td { background: transparent; }
  table.card-table td {
    display: flex; justify-content: space-between; gap: 12px;
    border: none; border-bottom: 1px dashed #eef2f6;
    padding: 7px 4px; white-space: normal; text-align: right;
  }
  table.card-table td::before {
    content: attr(data-label); font-weight: 600; color: var(--muted);
    text-align: left; flex: 0 0 auto;
  }
  table.card-table td:last-child { border-bottom: none; }
  .action-cell { text-align: right !important; }
}

/* ---------------- 表单 ---------------- */
label.fld { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 3px; }
input[type=text], input[type=password], input[type=email], input[type=number],
input[type=date], input[type=time], input[type=file], select, textarea {
  border: 1px solid #d4d9e2; border-radius: 8px; padding: 8px 10px; font-size: 14px;
  width: 100%; background: #fff; color: var(--ink); font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(47,84,235,.12);
}
/* 输入框宽度约束：小字段不拉满整行（数字 10 字符以内足够，约 160px） */
input[type=number] { max-width: 160px; }
input[type=date] { max-width: 175px; }
input[type=time] { max-width: 135px; }
input[type=text] { max-width: 300px; }
input[type=email], input[type=password] { max-width: 320px; }
select { max-width: 220px; }
/* 登录/注册窄卡片、工作台弹窗内不限宽，保持满宽观感 */
.login-wrap input, .login-wrap select { max-width: 100%; }
.swal2-popup input, .swal2-popup select { max-width: 100%; }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; vertical-align: middle; }
.field-error { color: #b02a37; font-size: 12px; margin-top: 3px; }
.field-hint { color: var(--muted); font-size: 12px; margin-top: 3px; }
/* 字段行：各字段按内容宽紧挨排列、自动换行，不再平均拉满整行 */
.form-row { display: flex; gap: 14px 22px; flex-wrap: wrap; align-items: flex-start; }
.form-row > div { flex: 0 1 auto; }
/* 三列等宽：交易表单等需要所有输入框同宽对齐的场景 */
.form-row.eq3 > div { flex: 1 1 0; min-width: 0; }
/* eq3 内输入框强制满宽填满等宽 div，覆盖各类型 max-width 差异（select 220/date 175/number 160/text 300），保证两行 6 个输入框完全同宽 */
.form-row.eq3 input, .form-row.eq3 select, .form-row.eq3 textarea {
  width: 100%; max-width: 100%; box-sizing: border-box;
}
/* 二列等宽：投资计划页单输入框行与双输入框行同宽左对齐 */
.form-row.eq2 > div { flex: 1 1 0; min-width: 0; }
.form-row.eq2 input, .form-row.eq2 select, .form-row.eq2 textarea {
  width: 100%; max-width: 100%; box-sizing: border-box;
}
/* 投资计划表单：4个输入框单列堆叠、等宽满行、左边缘对齐 */
.plan-form .form-row > div { flex: 1 1 100%; min-width: 0; }
.plan-form input { width: 100%; max-width: 100%; box-sizing: border-box; }

/* 输入框 + 单位后缀（% / 元）：盒子限宽紧贴输入框，单位贴右不脱离 */
.input-suffix { position: relative; display: flex; align-items: center; max-width: 170px; }
.input-suffix input { padding-right: 38px; max-width: 100%; }
.input-suffix > span {
  position: absolute; right: 10px; color: var(--muted); font-size: 13px;
  pointer-events: none; font-weight: 600;
}
/* 参数编辑区统一视觉：输入框等高加粗；下拉框与数字框统一 170px，避免一宽一窄 */
.params-form input[type=number], .params-form input[type=text],
.params-form select {
  width: 100%; max-width: 170px; padding: 9px 42px 9px 12px;
  font-size: 15px; font-weight: 600;
}
.params-form .input-suffix input { padding-right: 38px; }

/* 台账费用明细面板 */
.fee-panel {
  margin-top: 14px; padding: 12px 14px; background: #f8fafc;
  border: 1px solid #e8ecf3; border-radius: 10px;
}
.fee-panel-head { display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 6px; gap: 8px; flex-wrap: wrap; }
.fee-table { width: 100%; font-size: 13px; }
.fee-table td { padding: 5px 4px; border-bottom: 1px dashed #e4e8f0; }
.fee-table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fee-table tr.fee-total td { border-top: 2px solid #d4d9e2; border-bottom: none;
  font-weight: 700; padding-top: 8px; }
.fee-hint { margin-top: 8px; font-size: 12px; line-height: 1.6; color: #9a6700; }
.fee-hint:empty { display: none; }

/* 添加股票行：一个输入框 + 按钮 */
.add-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.add-bar .code-input { flex: 0 1 200px; max-width: 240px; }
.add-bar .spacer { flex: 1 1 auto; }
@media (max-width: 767.98px) {
  .add-bar .code-input { flex: 1 1 100%; max-width: none; }
  input, select { font-size: 16px; }
}

/* ---------------- 按钮 ----------------
 * 默认蓝 = 主提交/导航；绿(.act) = 执行操作；橙(.update) = 更新行情；
 * 红(.danger) = 删除/高危；浅蓝(.info) = 返回/次级；灰 = 禁用。 */
.btn {
  display: inline-block; border: none; border-radius: 8px; padding: 8px 18px;
  font-size: 14px; cursor: pointer; background: var(--brand); color: #fff;
  transition: background .15s; text-decoration: none; line-height: 1.4;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; color: #fff; }
.btn.info { background: #e8f0fe; color: #1d39c4; border: 1px solid #c5d5f7; }
.btn.info:hover { background: #d6e4fc; color: #1d39c4; }
.btn.act { background: var(--sell); }
.btn.act:hover { background: #138a4b; }
.btn.update { background: #d97706; }
.btn.update:hover { background: #b45309; }
.btn.danger { background: var(--danger); border: 1px solid var(--danger); }
.btn.danger:hover { background: #b91c1c; }
.btn.sm { padding: 5px 12px; font-size: 13px; }
.btn.ghost { background: #f3f4f6; color: #374151; border: 1px solid #e5e7eb; }
.btn.ghost:hover { background: #e5e7eb; }
.btn:disabled, .btn.gray { background: #eef0f4 !important; color: #9ca3af !important;
  cursor: not-allowed; border-color: transparent; }
.btn-block { width: 100%; }
@media (max-width: 767.98px) {
  .btn { min-height: 42px; }
  .btn.sm { min-height: 34px; }
  .btn-block-sm { width: 100%; }
}

/* ---------------- 消息条 ---------------- */
ul.msgs { list-style: none; padding: 0; margin: 0 0 16px; }
ul.msgs li { padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; font-size: 13px; }
ul.msgs li.success { background: #e9f8ef; border: 1px solid #b7e4c7; color: #157347; }
ul.msgs li.error { background: #fdecea; border: 1px solid #f5c6c2; color: #b02a37; }
ul.msgs li.warning { background: #fff8e6; border: 1px solid #f7e1a5; color: #9a6700; }
ul.msgs li.info { background: #eef2ff; border: 1px solid #c7d2fe; color: #3749a8; }

/* ---------------- 空状态 / 折叠 ---------------- */
.empty { text-align: center; color: var(--muted); padding: 36px 20px;
  background: #fff; border: 1px dashed #d4d9e2; border-radius: var(--radius); }
details.fold { border: 1px solid var(--line); border-radius: 10px;
  background: #fff; padding: 10px 14px; margin-bottom: 16px; }
details.fold > summary { cursor: pointer; font-weight: 600; font-size: 14px;
  user-select: none; list-style: none; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold[open] > summary { margin-bottom: 10px; border-bottom: 1px dashed var(--line);
  padding-bottom: 8px; }

/* ---------------- 进度条 ---------------- */
.progress { height: 10px; background: #e9edf3; border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--brand); border-radius: 999px;
  transition: width .3s; }
.progress > div.over { background: var(--danger); }

/* ---------------- 紧凑标签 chip ---------------- */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.chip-row:last-child { margin-bottom: 0; }
.chip-row-title { flex: 0 0 44px; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--brand);
  background: var(--brand-soft); border-radius: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px;
  background: #f8fafc; border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 12px; min-width: 96px; }
.chip.wide { min-width: 170px; }
.chip .ck { font-size: 12px; color: var(--muted); white-space: nowrap; }
.chip .cv { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums;
  white-space: nowrap; }

/* ---------------- 建议面板 / 工作台卡片 ---------------- */
.suggest-card { border: 1px solid var(--line); border-radius: 12px;
  background: #fff; box-shadow: var(--shadow); display: flex;
  flex-direction: column; overflow: hidden; }
.suggest-card .sc-head { display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 12px 14px; border-bottom: 1px solid #f1f3f7; background: #fafbfe; }
.suggest-card .sc-body { padding: 12px 14px; flex: 1; }
.suggest-card .sc-foot { display: flex; gap: 8px; flex-wrap: wrap; padding: 10px 14px;
  border-top: 1px solid #f1f3f7; background: #fafbfe; }
.suggest-card .sc-foot .btn { flex: 1; }
.suggest-card.s-buy { border-color: #f5c6c2; }
.suggest-card.s-sell { border-color: #b7e4c7; }
.suggest-card.s-watch { border-color: #e5e7eb; }
.sug-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0; }
.sug-grid .sg { background: #f8fafc; border: 1px solid var(--line); border-radius: 8px;
  text-align: center; padding: 8px 4px; }
.sug-grid .sg .k { font-size: 12px; color: var(--muted); }
.sug-grid .sg .v { font-weight: 700; }
.cards-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 960px) { .cards-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .cards-grid { grid-template-columns: 1fr; } .sug-grid { grid-template-columns: repeat(3,1fr); } }

/* 工作台分区标题 */
.section-title { font-size: 16px; margin: 16px 0 10px; }
/* 建议详细理由：完整展示，灰底卡片，方便逐只读懂为什么这么建议 */
.sug-reason { margin-top: 8px; padding: 8px 10px; background: #f8fafc;
  border-left: 3px solid var(--brand); border-radius: 6px;
  font-size: 13px; line-height: 1.7; color: #334155; word-break: break-word; }
.suggest-card.s-watch .sug-reason { border-left-color: #94a3b8; }
/* 演算明细折叠区 */
.sug-detail { margin-top: 8px; }
.sug-detail > summary { cursor: pointer; font-size: 12px; color: var(--brand);
  user-select: none; padding: 4px 0; }
.detail-table { width: 100%; margin-top: 6px; font-size: 12px; }
.detail-table td { padding: 4px 8px; border-bottom: 1px dashed #eef1f5; }
.detail-table td.dk { color: var(--muted); width: 55%; }
.detail-table td.dv { text-align: right; font-weight: 600; white-space: nowrap; }
/* 观望/无建议折叠区 */
.watch-fold { background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); padding: 4px 14px; }
.watch-fold > summary { cursor: pointer; font-size: 15px; font-weight: 700;
  padding: 12px 0; user-select: none; }
.watch-fold[open] > summary { border-bottom: 1px solid #f1f3f7; margin-bottom: 12px; }
.watch-fold .cards-grid { margin-bottom: 14px; }

/* ---------------- 策略参数（只读 + 编辑共用） ---------------- */
.param-group { font-size: 13px; font-weight: 700; margin: 14px 0 8px;
  padding-bottom: 6px; border-bottom: 1px solid var(--line); color: var(--brand-dark); }
.param-group:first-child { margin-top: 0; }
.params-view { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.params-view .param-row { background: #f8fafc; border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; }
.params-view .param-row .pk { font-size: 12px; color: var(--muted); }
.params-view .param-row .pv { font-size: 14px; font-weight: 700;
  font-variant-numeric: tabular-nums; }
.params-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px 20px; }
.params-form .pf-item { margin-bottom: 8px; }
@media (max-width: 640px) {
  .params-view, .params-form { grid-template-columns: 1fr; }
}

/* ---------------- 登录/注册/结果页 ---------------- */
.login-wrap { max-width: 380px; margin: 7vh auto; padding: 0 14px; }
.login-wrap.wide { max-width: 520px; }
.login-wrap .card { padding: 26px 26px; }
.login-wrap h2 { margin: 0 0 18px; text-align: center; font-size: 19px; }
.login-wrap .btn[type=submit], .login-wrap .btn.submit { width: 100%; padding: 10px; }
.result-wrap { max-width: 520px; margin: 7vh auto; padding: 0 14px; text-align: center; }
.result-wrap .big { font-size: 44px; margin-bottom: 8px; }

/* ---------------- 图表 ---------------- */
.chart { width: 100%; height: 400px; }
.chart-main { width: 100%; height: 460px; }
.chart-sub { width: 100%; height: 320px; }
.chart-half { width: 100%; height: 300px; }
.chart-mini { width: 100%; height: 260px; }
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 960px) { .chart-grid { grid-template-columns: 1fr; } }
@media (max-width: 767.98px) {
  .chart-main { height: 60vh; min-height: 340px; }
  .chart-sub { height: 260px; }
}

/* ---------------- 底部拇指快捷栏（手机） ---------------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: #fff; border-top: 1px solid var(--line);
  display: none; padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a {
  flex: 1; text-align: center; color: #6b7280; font-size: 12px;
  height: 54px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1px;
}
.bottom-nav a .bn-ico { font-size: 17px; line-height: 1.2; }
.bottom-nav a.active { color: var(--brand); font-weight: 700; }
body.has-bottom-nav { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }
@media (max-width: 767.98px) { .bottom-nav { display: flex; } }

/* ---------------- 提交遮罩 ---------------- */
.loading-mask {
  position: fixed; inset: 0; background: rgba(31, 41, 55, .45);
  display: none; align-items: center; justify-content: center; z-index: 9999;
}
.loading-mask.show { display: flex; }
.loading-mask .box {
  background: #fff; border-radius: 12px; padding: 24px 34px; text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,.25); font-size: 15px;
}
.loading-mask .spin {
  display: inline-block; width: 34px; height: 34px; margin-bottom: 12px;
  border: 4px solid #dbe5f8; border-top-color: var(--brand);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- 使用指南 / 速查 ---------------- */
.guide-layout { display: grid; grid-template-columns: 240px 1fr; gap: 18px; align-items: start; }
.guide-toc { position: sticky; top: 72px; }
.guide-toc a { display: block; padding: 7px 12px; border-radius: 8px;
  font-size: 13px; color: var(--ink); }
.guide-toc a:hover { background: var(--brand-soft); text-decoration: none; color: var(--brand-dark); }
.guide-toc a.danger { color: var(--danger); }
.guide-card { border-left: 4px solid var(--brand); background: #fff;
  border-radius: 0 10px 10px 0; padding: 14px 18px; margin-bottom: 14px;
  box-shadow: var(--shadow); scroll-margin-top: 72px; }
.guide-card.guide-red { border-left-color: var(--danger); background: #fef6f5; }
.guide-card.guide-green { border-left-color: var(--sell); background: #f3faf6; }
.guide-card.guide-orange { border-left-color: var(--warn); background: #fffaf0; }
.guide-card h5 { margin: 0 0 8px; font-size: 15px; }
.guide-card .box-note { border-radius: 8px; padding: 8px 12px; margin: 8px 0; }
.guide-card .guide-green.box-note { background: #e9f8ef; }
.guide-card .guide-red.box-note { background: #fdecea; }
.guide-card .guide-orange.box-note { background: #fff8e6; }
.guide-mobile-toc { display: none; margin-bottom: 14px; }
@media (max-width: 960px) {
  .guide-layout { grid-template-columns: 1fr; }
  .guide-toc { display: none; }
  .guide-mobile-toc { display: block; }
}
.guide-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.guide-table caption { text-align: left; font-weight: 700; padding: 8px 0; color: var(--brand-dark); }

/* ---------------- 杂项 ---------------- */
.text-center { text-align: center; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 14px; } .mt-4 { margin-top: 20px; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 14px; }
.small { font-size: 12px; }
.fw-bold { font-weight: 700; }
.d-flex { display: flex; } .flex-wrap { flex-wrap: wrap; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.align-center { align-items: center; } .justify-between { justify-content: space-between; }
.flex-fill { flex: 1; }
.w-100 { width: 100%; }
code { background: #f3f4f6; padding: 1px 6px; border-radius: 5px;
  font-size: 12px; font-family: Consolas, monospace; }
.switch-line { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.switch-line label { margin: 0; font-size: 14px; }
.hr-soft { border: none; border-top: 1px solid var(--line); margin: 14px 0; }

/* 涨跌数字加粗（颜色仍由 .up/.down 控制：红涨绿跌） */
.updown { font-weight: 700; font-variant-numeric: tabular-nums; }
/* 首页股票链接：深色文字，hover 变品牌蓝 */
a.stock-link { color: #111827; }
a.stock-link:hover { color: var(--brand); }
/* 行内小号下拉（如首页分组切换） */
select.mini-select { width: auto; padding: 4px 8px; font-size: 13px; }
/* 页面标题旁/卡片标题中的小标签 */
.page-title .badge { font-size: 12px; vertical-align: middle; margin-left: 6px; }

/* =====================================================================
 * 顶栏：使用指南下拉子菜单 + 手机/电脑适配切换按钮
 * ===================================================================== */
.nav-menu { position: relative; margin: 0; }
.nav-menu > summary.nav {
  display: inline-block; list-style: none; cursor: pointer; user-select: none;
}
.nav-menu > summary.nav::-webkit-details-marker { display: none; }
.nav-menu > summary .caret { font-size: 10px; opacity: .8; margin-left: 2px; }
.nav-sub {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 60;
  min-width: 172px; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 8px 24px rgba(16,24,40,.18);
  padding: 6px;
}
.nav-sub a {
  display: block; padding: 8px 12px; border-radius: 8px; color: var(--ink);
  font-size: 13px; white-space: nowrap;
}
.nav-sub a:hover { background: var(--brand-soft); color: var(--brand-dark); text-decoration: none; }
/* 子菜单展开期间放开横滚容器的裁切（overflow-x:auto 会裁掉绝对定位面板） */
.nav-scroll:has(.nav-menu[open]) { overflow: visible; }

/* 设备适配切换按钮（用户名前方） */
.layout-btn {
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.35);
  color: #fff; border-radius: 999px; padding: 4px 10px; font-size: 14px;
  cursor: pointer; line-height: 1.3; white-space: nowrap;
}
.layout-btn:hover { background: rgba(255,255,255,.24); }
@media (max-width: 640px) {
  .topbar .logo { font-size: 14px; }
  .layout-btn { padding: 3px 8px; font-size: 13px; }
}

/* =====================================================================
 * 手动设备显示模式（data-layout 由 app.js 写入 <html>）
 *   phone：无视真实屏宽强制手机排版；pc：窄屏也保持桌面排版
 * ===================================================================== */

/* ---------- 强制手机模式 ---------- */
:root[data-layout="phone"] .container { max-width: 480px; }
:root[data-layout="phone"] .grid-3,
:root[data-layout="phone"] .grid-4,
:root[data-layout="phone"] .grid-6 { grid-template-columns: repeat(2, 1fr); }
:root[data-layout="phone"] .layout-2col,
:root[data-layout="phone"] .layout-7-5,
:root[data-layout="phone"] .chart-grid { grid-template-columns: 1fr; }
:root[data-layout="phone"] .layout-7-5 > .col-main,
:root[data-layout="phone"] .layout-7-5 > .col-side { grid-column: span 1; }
:root[data-layout="phone"] .cards-grid { grid-template-columns: 1fr; }
:root[data-layout="phone"] .params-view,
:root[data-layout="phone"] .params-form { grid-template-columns: 1fr; }
:root[data-layout="phone"] .bottom-nav { display: flex; }
:root[data-layout="phone"] .chart-main { height: 60vh; min-height: 340px; }
:root[data-layout="phone"] .chart-sub { height: 260px; }
:root[data-layout="phone"] .add-bar .code-input { flex: 1 1 100%; max-width: none; }
:root[data-layout="phone"] .topbar .logo { font-size: 14px; }
/* 强制手机模式：宽表转卡片（与 768px 媒体查询同源，单元格需带 data-label） */
:root[data-layout="phone"] table.card-table thead { display: none; }
:root[data-layout="phone"] table.card-table,
:root[data-layout="phone"] table.card-table tbody,
:root[data-layout="phone"] table.card-table tr,
:root[data-layout="phone"] table.card-table td { display: block; width: 100%; }
:root[data-layout="phone"] table.card-table tr {
  border: 1px solid var(--line); border-radius: 10px;
  margin-bottom: 10px; padding: 4px 8px; background: #fff;
}
:root[data-layout="phone"] table.card-table tbody tr:hover td { background: transparent; }
:root[data-layout="phone"] table.card-table td {
  display: flex; justify-content: space-between; gap: 12px;
  border: none; border-bottom: 1px dashed #eef2f6;
  padding: 7px 4px; white-space: normal; text-align: right;
}
:root[data-layout="phone"] table.card-table td::before {
  content: attr(data-label); font-weight: 600; color: var(--muted);
  text-align: left; flex: 0 0 auto;
}
:root[data-layout="phone"] table.card-table td:last-child { border-bottom: none; }
:root[data-layout="phone"] .action-cell { text-align: right !important; }

/* ---------- 强制电脑模式：窄屏下也保持桌面排版（页面可横向滚动） ---------- */
@media (max-width: 960px) {
  :root[data-layout="pc"] .grid-3 { grid-template-columns: repeat(3, 1fr); }
  :root[data-layout="pc"] .grid-4 { grid-template-columns: repeat(4, 1fr); }
  :root[data-layout="pc"] .grid-6 { grid-template-columns: repeat(6, 1fr); }
  :root[data-layout="pc"] .layout-2col { grid-template-columns: 2fr 1fr; }
  :root[data-layout="pc"] .layout-7-5 { grid-template-columns: repeat(12, 1fr); }
  :root[data-layout="pc"] .layout-7-5 > .col-main { grid-column: span 7; }
  :root[data-layout="pc"] .layout-7-5 > .col-side { grid-column: span 5; }
  :root[data-layout="pc"] .chart-grid { grid-template-columns: 1fr 1fr; }
  :root[data-layout="pc"] .cards-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 767.98px) {
  :root[data-layout="pc"] .container { max-width: 1200px; min-width: 820px; }
  :root[data-layout="pc"] .bottom-nav { display: none; }
  :root[data-layout="pc"] .chart-main { height: 460px; min-height: 0; }
  :root[data-layout="pc"] .chart-sub { height: 320px; }
  :root[data-layout="pc"] .params-view,
  :root[data-layout="pc"] .params-form { grid-template-columns: repeat(2, 1fr); }
  :root[data-layout="pc"] .add-bar .code-input { flex: 0 1 200px; max-width: 240px; }
  :root[data-layout="pc"] table.card-table thead { display: table-header-group; }
  :root[data-layout="pc"] table.card-table,
  :root[data-layout="pc"] table.card-table tbody { display: table; }
  :root[data-layout="pc"] table.card-table tr { display: table-row; border: none;
    border-radius: 0; margin: 0; padding: 0; background: transparent; }
  :root[data-layout="pc"] table.card-table td {
    display: table-cell; width: auto; border-bottom: 1px solid var(--line);
    padding: 9px 10px; text-align: inherit; white-space: nowrap;
  }
  :root[data-layout="pc"] table.card-table td::before { content: none; }
  :root[data-layout="pc"] .action-cell { text-align: inherit !important; }
}

/* ---------------- 弹窗与下钻卡片 ---------------- */
/* 板块编辑弹窗：卡片中间居中、约占卡片六成宽，手机端放宽到 92% */
.swal2-popup.ind-popup { width: 60% !important; max-width: 640px; }
/* 板块编辑输入框：占卡片80%居中，border-box 防溢出（第三次修正，彻底解决） */
.swal2-popup.ind-popup .swal2-input {
    width: 80% !important;
    box-sizing: border-box !important;
    margin-left: auto !important;
    margin-right: auto !important;
}
@media (max-width: 767.98px) { .swal2-popup.ind-popup { width: 92% !important; } }

/* 持仓明细下钻：独立卡片页，交易记录用全站统一表格样式（table.data） */
tr.row-drill { cursor: pointer; }
