/* MoQuant · macOS 26 液态玻璃（Liquid Glass）深色主题 */
:root {
  /* 深色配色声明：原生控件（数字输入框上下箭头/滚动条/日期选择器等）
     自动使用深色样式——浅色系统下黑箭头不可见的问题由此根治 */
  color-scheme: dark;
  --bg0: #05070d;
  --bg1: #090d14;
  /* 玻璃面：上下通透渐变 + 边缘光 */
  --glass: rgba(255, 255, 255, 0.06);
  --glass-top: rgba(255, 255, 255, 0.08);   /* 玻璃顶部高光 */
  --glass-bot: rgba(255, 255, 255, 0.03);   /* 玻璃底部通透 */
  --glass-strong: rgba(255, 255, 255, 0.10);
  --stroke: rgba(255, 255, 255, 0.08);
  --stroke-strong: rgba(255, 255, 255, 0.16);
  --stroke-spec: rgba(255, 255, 255, 0.14); /* 玻璃顶部边缘高光 */
  --txt: #e8ecf4;
  --txt-dim: #aab3c6;    /* 次要文字 */
  --txt-faint: #8a94a8;  /* 弱提示/表头：提亮至 4.5:1（WCAG AA） */
  --up: #f5222d;
  --up-bg: rgba(245, 34, 45, 0.11);
  --down: #00b578;
  --down-bg: rgba(0, 181, 120, 0.11);
  --accent: #4f8cff;
  --accent2: #7c5cff;
  --accent-grad: linear-gradient(135deg, #4f8cff, #7c5cff);
  --amber: #f5a623;
  /* 液态玻璃圆角体系 */
  --radius-sm: 12px;
  --radius: 16px;
  --radius-lg: 20px;
  /* 分层阴影：近距投影 + 远距环境光 */
  --shadow: 0 6px 18px rgba(0, 0, 0, 0.30), 0 18px 48px rgba(0, 0, 0, 0.28);
  /* 弹簧缓动（液态玻璃的物理回弹感） */
  --ease: cubic-bezier(0.34, 1.56, 0.64, 1);
  --blur: blur(28px) saturate(175%);
  --line: var(--stroke);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Helvetica Neue", sans-serif;
  background:
    radial-gradient(1100px 600px at 85% -10%, rgba(124, 92, 255, 0.07), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(79, 140, 255, 0.06), transparent 60%),
    linear-gradient(160deg, var(--bg1), var(--bg0) 55%);
  color: var(--txt);
  font-size: 14px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.14); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

.hidden { display: none !important; }

/* ---------- 原生App透明模式（UA 标记 AQuantNative 时启用） ----------
   背景：窗口透明 + 系统 NSVisualEffectView 原生毛玻璃（透出壁纸）
   可读性：面板用半透明深色压底（而非白色），配合深色压暗层，
   保证亮色/白色桌面壁纸下浅色文字依然清晰可读。浏览器方式不受影响。 */
body.native {
  background: rgba(8, 11, 18, 0.58);   /* 压暗壁纸：纯白壁纸下裸文字对比度达标（原0.50偏临界） */
}
body.native .sidebar {
  background: rgba(10, 14, 22, 0.38);  /* 侧栏略压暗，与主区拉开层次 */
  padding-top: 42px;   /* 为融入标题栏的红绿灯留出空间 */
}
body.native .topbar {
  background: rgba(8, 11, 18, 0.42);
  padding-top: 18px;
}
/* 窗口拖动：顶栏与侧栏品牌区为可拖动区域（WebView 拦截鼠标，需 app-region） */
body.native .topbar {
  -webkit-app-region: drag;
}
body.native .topbar button,
body.native .topbar input,
body.native .topbar .switch-wrap,
body.native .topbar .seg {
  -webkit-app-region: no-drag;
}
body.native .sidebar .brand {
  -webkit-app-region: drag;
}
body.native .sidebar .nav,
body.native .sidebar .sidebar-foot {
  -webkit-app-region: no-drag;
}
body.native .glass,
body.native .card {
  /* native 模式：系统毛玻璃负责模糊；面板用半透明深色压底（亮壁纸下文字可读），保留液态玻璃高光边框 */
  background: linear-gradient(180deg, rgba(14, 19, 29, 0.62), rgba(10, 14, 22, 0.55));
  border-color: rgba(255, 255, 255, 0.10);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
body.native .glass::before,
body.native .card::before {
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.16) 25%, rgba(255,255,255,0.16) 75%, transparent);
}
/* 嵌套卡片（如回测结果卡内的交易明细卡）：深色略减，避免多层叠加过暗 */
.card .card { background: linear-gradient(180deg, rgba(255,255,255,0.045), rgba(255,255,255,0.02)); }
body.native .card .card { background: rgba(10, 14, 22, 0.42); }
body.native .index-pill,
body.native .quote-item,
body.native .metric,
body.native .strategy-item {
  background: rgba(12, 16, 25, 0.52);   /* 深色半透明压底，亮壁纸下文字可读 */
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
/* 图表/表格容器：无底色，K线直接绘制在背景上 */
body.native .chart-box,
body.native .chart-box-sm {
  background: transparent;
}
body.native .auth-overlay {
  background: transparent;
}
body.native .auth-card {
  background: rgba(13, 17, 25, 0.72);
}
body.native input,
body.native select,
body.native textarea {
  background: rgba(0, 0, 0, 0.25);
}
body.native .seg {
  background: rgba(0, 0, 0, 0.22);
}
body.native .seg button.active {
  background: rgba(255, 255, 255, 0.12);
}
body.native .tbl tbody tr:hover {
  background: rgba(255, 255, 255, 0.06);
}
body.native .fee-preview {
  background: rgba(0, 0, 0, 0.22);
}
body.native .tbl th {
  border-bottom-color: rgba(255, 255, 255, 0.1);
}
body.native .tbl td {
  border-bottom-color: rgba(255, 255, 255, 0.05);
}
/* 导航选中态：淡表面 + 左侧蓝色指示条 */
body.native .nav-item.active {
  background: rgba(255, 255, 255, 0.1);
  border-color: transparent;
  box-shadow: inset 3px 0 0 var(--accent);
  color: var(--txt);
}
/* 多选 chips 选中态：蓝字 + 蓝边框 */
body.native .chip-label input:checked + .chip {
  background: rgba(79, 140, 255, 0.14);
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------- 液态玻璃卡片：上下通透渐变 + 顶部内高光 + 分层阴影 ---------- */
.glass {
  position: relative;
  background: linear-gradient(180deg, var(--glass-top), var(--glass-bot));
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
/* 玻璃上缘反光：顶部内高光条 */
.glass::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: linear-gradient(90deg, transparent, var(--stroke-spec) 30%, var(--stroke-spec) 70%, transparent);
  pointer-events: none;
}

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid var(--stroke-strong);
  background: var(--glass-strong);
  color: var(--txt);
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--ease) 0.22s;
  backdrop-filter: blur(12px);
  font-family: inherit;
}
.btn:hover { border-color: rgba(255,255,255,0.3); background: rgba(255,255,255,0.14); }
.btn:active { transform: scale(0.96); }
.btn-primary { background: var(--accent-grad); border: none; color: #fff; font-weight: 600; }
.btn-primary:hover { filter: brightness(1.12); background: var(--accent-grad); }
.btn-danger { background: linear-gradient(135deg, #f5222d, #c41926); border: none; color: #fff; }
.btn-up { background: linear-gradient(135deg, #f5222d, #d81e29); border: none; color: #fff; }
.btn-down { background: linear-gradient(135deg, #00b578, #00986a); border: none; color: #fff; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 9px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.icon-btn {
  background: transparent; border: none; color: var(--txt-dim); cursor: pointer;
  font-size: 15px; padding: 4px 7px; border-radius: 8px; transition: all .15s;
}
.icon-btn:hover { background: rgba(255,255,255,0.1); color: var(--txt); }

/* ---------- 输入 ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--txt-dim); margin-bottom: 6px; }
input, select, textarea {
  width: 100%;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--stroke);
  color: var(--txt);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13px;
  outline: none;
  font-family: inherit;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238b93a7' fill='none' stroke-width='1.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; cursor: pointer; }
input[type="checkbox"] { width: auto; }
/* 深色主题下数字输入框的上下箭头：原生 spin 箭头在浅色系统下为黑色看不清。
   color-scheme: dark 已让多数原生控件变浅；此处再隐藏原生箭头（appearance:none 会
   移除整个伪元素，箭头无法再画在伪元素上），改在 input 自身右缘绘制浅色 SVG 双箭头。
   注意：隐藏后点击右缘不再步进，改用自绘 +/- 按钮实现步进（见 views.js 全局事件）。 */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  appearance: none;
}
input[type="number"] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='14' viewBox='0 0 12 14'%3E%3Cpath d='M6 1 L10.5 5.5 H1.5 Z' fill='%23b9c2d4'/%3E%3Cpath d='M6 13 L1.5 8.5 H10.5 Z' fill='%23b9c2d4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 7px center;
  background-size: 11px 13px;
  padding-right: 26px;
  cursor: text;
}
textarea { resize: vertical; min-height: 160px; font-family: "SF Mono", Menlo, monospace; font-size: 12px; line-height: 1.6; }

/* ---------- 登录 ---------- */
.auth-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(800px 500px at 30% 20%, rgba(124, 92, 255, 0.18), transparent 60%),
    radial-gradient(700px 500px at 75% 80%, rgba(79, 140, 255, 0.15), transparent 60%),
    var(--bg0);
}
.auth-card { width: 400px; padding: 34px 38px 30px; text-align: center; }
.auth-logo {
  width: 58px; height: 58px; margin: 0 auto 14px; border-radius: 17px;
  background: var(--accent-grad); display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 800; color: #fff; box-shadow: 0 8px 30px rgba(96, 110, 255, 0.45);
}
.auth-card h1 { font-size: 26px; letter-spacing: 1px; }
.auth-sub { color: var(--txt-dim); font-size: 12px; margin: 8px 0 24px; }
.auth-card form { text-align: left; }
.auth-card .btn { padding: 11px; font-size: 14px; margin-top: 6px; }
.auth-tip { text-align: center; font-size: 12px; color: var(--up); min-height: 18px; margin-top: 10px; }

/* ---------- 布局 ---------- */
.app { display: flex; height: 100vh; }
.sidebar {
  width: 210px; flex-shrink: 0; display: flex; flex-direction: column;
  padding: 22px 14px 16px;
  background: rgba(13, 17, 25, 0.55);
  backdrop-filter: blur(30px) saturate(160%);
  -webkit-backdrop-filter: blur(30px) saturate(160%);
  border-right: 1px solid var(--stroke);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 24px; min-width: 0; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px; background: var(--accent-grad);
  display: flex; align-items: center; justify-content: center; font-size: 17px; font-weight: 800; color: #fff;
  box-shadow: 0 6px 20px rgba(96, 110, 255, 0.4);
  flex-shrink: 0;   /* 防止品牌行变长时 LOGO 被压缩变形 */
}
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: 0.5px; white-space: nowrap; }
.brand-tag { font-size: 10px; color: var(--amber); background: rgba(245,166,35,0.15); padding: 2px 7px; border-radius: 20px; margin-left: 7px; vertical-align: 2px; }
.brand-ver { font-size: 10px; color: var(--txt-faint); text-align: center; padding: 6px 0 2px; font-variant-numeric: tabular-nums; letter-spacing: 0.5px; }
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%; padding: 11px 14px;
  background: transparent; border: 1px solid transparent; border-radius: 12px;
  color: var(--txt-dim); font-size: 13.5px; font-weight: 600; cursor: pointer; font-family: inherit;
  transition: all 0.16s; text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: var(--txt); }
.nav-item.active {
  background: linear-gradient(135deg, rgba(79,140,255,0.2), rgba(124,92,255,0.14));
  border-color: rgba(79,140,255,0.35); color: var(--txt); font-weight: 600;
}
.nav-ico { font-size: 16px; width: 22px; text-align: center; }
.sidebar-foot { border-top: 1px solid var(--stroke); padding-top: 14px; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--accent-grad);
  display: flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; flex-shrink: 0;
}
.user-meta { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-asset { font-size: 11px; color: var(--txt-dim); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 26px; border-bottom: 1px solid var(--stroke);
  background: rgba(13, 17, 25, 0.35);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}
.topbar-title { font-size: 17px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.market-clock { font-variant-numeric: tabular-nums; color: var(--txt-dim); font-size: 13px; }
.switch-wrap { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 12px; color: var(--txt-dim); user-select: none; }
/* 覆盖 .field label / .bt-form label 的通用样式，保证开关+文字同排对齐、不换行不重叠 */
.field label.switch-wrap,
.bt-form label.switch-wrap { display: inline-flex; align-items: center; gap: 8px; min-height: 0; margin-bottom: 0; flex-wrap: nowrap; }
.switch-wrap .switch-label { white-space: nowrap; }
.switch-wrap input { display: none; }
.switch {
  width: 36px; height: 20px; border-radius: 20px; background: rgba(255,255,255,0.14);
  position: relative; transition: background .2s;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; transition: transform .2s;
}
.switch-wrap input:checked + .switch { background: var(--accent); }
.switch-wrap input:checked + .switch::after { transform: translateX(16px); }

.content { flex: 1; overflow: hidden; }   /* 舞台：不滚动，由各视图面板滚动 */
.view-pane { height: 100%; overflow-y: auto; padding: 22px 26px 40px; }

/* ---------- 通用组件 ---------- */
.card { position: relative; padding: 18px 20px; margin-bottom: 16px; background: linear-gradient(180deg, var(--glass-top), var(--glass-bot)); border: 1px solid var(--stroke); border-radius: var(--radius-lg); }
.card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 1px; border-radius: var(--radius-lg) var(--radius-lg) 0 0; background: linear-gradient(90deg, transparent, var(--stroke-spec) 25%, var(--stroke-spec) 75%, transparent); pointer-events: none; }
.card-title { font-size: 13px; font-weight: 600; color: var(--txt-dim); margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; }
.card-title .sub { font-size: 11px; font-weight: 400; color: var(--txt-faint); }
.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: 1fr 1fr; }
/* 卡片间距统一 16px：grid/flex 容器内卡片间距由容器 gap 控制，
   .card 自带的 margin-bottom 在轨道内会与 gap 叠加（出现 32px 等异常），需归零；
   容器本身的 margin-bottom 保证与下一区块的 16px 间距 */
.grid > .card, .trade-left > .card, .chart-3col > .card, .strategy-grid > .card { margin-bottom: 0; }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3, .grid-2 { grid-template-columns: 1fr; } }

/* 数据卡片 */
.stat-card { padding: 16px 18px; }
.stat-label { font-size: 12px; color: var(--txt-dim); margin-bottom: 8px; }
.stat-value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 11px; color: var(--txt-faint); margin-top: 5px; }

/* 表格 */
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; font-weight: 500; color: var(--txt-faint); font-size: 11.5px;
  padding: 8px 10px; border-bottom: 1px solid var(--stroke); white-space: nowrap;
}
.tbl td { padding: 9px 10px; border-bottom: 1px solid rgba(255,255,255,0.045); font-variant-numeric: tabular-nums; white-space: nowrap; }
/* 交易原因列：完整显示，允许换行（自动交易理由较长，不再截断省略） */
.tbl td.reason-cell { white-space: normal; word-break: break-word; min-width: 140px; max-width: 260px; line-height: 1.5; }
/* 全局数字对齐：价格/数量/收益等数字列统一等宽数字，涨跌看板更易读 */
.num, .m-val, .stat-value, .tabular { font-variant-numeric: tabular-nums; }
/* 正文行高：数据阅读舒适 */
body { line-height: 1.55; }

/* ---------- 关键信息摘要条（图表页/交易页合计） ---------- */
.summary-bar {
  display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap;
  padding: 10px 4px 14px;
}
.summary-bar .sb-main { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 0.3px; }
.summary-bar .sb-item { font-size: 13px; color: var(--txt-dim); font-variant-numeric: tabular-nums; }
.summary-bar .sb-item b { color: var(--txt); font-weight: 600; }
/* K线摘要条：股票名称+代码（图中上方） */
.summary-bar .sb-name { font-size: 16px; font-weight: 700; color: var(--txt); display: inline-flex; align-items: baseline; gap: 6px; }
.summary-bar .sb-code { font-size: 11.5px; font-weight: 500; color: var(--txt-faint); letter-spacing: 0.2px; }
/* 持仓合计行：表尾高亮 */
.tbl tr.tfoot td { font-weight: 700; border-top: 1px solid var(--stroke-strong); border-bottom: none; background: rgba(255,255,255,0.03); padding: 10px; font-variant-numeric: tabular-nums; }

/* ---------- 骨架屏（shimmer 加载占位） ---------- */
.skeleton { background: linear-gradient(90deg, rgba(255,255,255,0.05) 25%, rgba(255,255,255,0.12) 50%, rgba(255,255,255,0.05) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; display: inline-block; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
/* 减少动效偏好：关闭非必要动画（无障碍） */
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: rgba(255,255,255,0.04); }
.tbl tbody tr.row-hl { background: rgba(79,140,255,0.10); }
.tbl .num { text-align: right; }
.tbl th.num { text-align: right; }
.tbl .sym { font-family: "SF Mono", Menlo, monospace; font-size: 12px; color: var(--txt-dim); }
/* 持仓表操作列：买卖按钮强制一行平行，紧凑不折行 */
.pos-actions { white-space: nowrap; text-align: right; }  /* 不能用 display:flex——td 变 flex 容器后不再随表格行高拉伸，导致操作列与其他列底边框错位 */
.pos-actions .btn-sm { padding: 4px 9px; min-width: 0; margin-left: 6px; }
.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--txt-dim); }

/* 徽章 */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-buy { background: var(--up-bg); color: var(--up); }
.badge-sell { background: var(--down-bg); color: var(--down); }
.badge-pending { background: rgba(245,166,35,0.16); color: var(--amber); }
.badge-done { background: rgba(255,255,255,0.09); color: var(--txt-dim); }
.badge-info { background: rgba(79,140,255,0.16); color: var(--accent); }
.badge-err { background: var(--down-bg); color: var(--down); }
.badge-live { background: rgba(52,199,89,0.15); color: #34c789; }
.badge-closed { background: rgba(255,255,255,0.09); color: var(--txt-dim); }

/* 分页/分段控件 */
.seg { display: inline-flex; background: rgba(0,0,0,0.25); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button {
  padding: 5px 13px; border: none; background: transparent; color: var(--txt-dim);
  border-radius: 8px; cursor: pointer; font-size: 12px; font-family: inherit; transition: all .15s;
}
.seg button.active { background: var(--glass-strong); color: var(--txt); font-weight: 600; }

.fb-tag { display: inline-block; margin-left: 4px; padding: 0 4px; font-size: 10px; line-height: 14px;
  color: var(--txt-dim); background: rgba(127,127,127,0.15); border-radius: 4px; vertical-align: middle; }

/* Toast */
#toast-wrap { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 999; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: rgba(20, 26, 38, 0.85); backdrop-filter: blur(20px);
  border: 1px solid var(--stroke-strong); color: var(--txt);
  padding: 10px 20px; border-radius: 12px; font-size: 13px;
  box-shadow: var(--shadow); animation: toastIn .25s ease; max-width: 460px;
}
.toast.err { border-color: rgba(245,34,45,0.5); color: #ff8a8f; }
.toast.ok { border-color: rgba(0,181,120,0.5); color: #5ad6ae; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }

/* 模态确认 */
.modal-mask { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,0.5); backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; }
.modal-card { width: 380px; padding: 26px; }
.modal-card h3 { font-size: 16px; margin-bottom: 10px; }
.modal-card p { color: var(--txt-dim); font-size: 13px; line-height: 1.7; margin-bottom: 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* 行情页 */
.index-strip { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 4px; }
.index-pill {
  flex-shrink: 0; padding: 10px 16px; border-radius: 13px; cursor: pointer;
  background: var(--glass); border: 1px solid var(--stroke); transition: all .15s;
  backdrop-filter: blur(16px);
}
.index-pill:hover { border-color: var(--stroke-strong); background: rgba(255, 255, 255, 0.07); }
.index-pill .i-name { font-size: 11px; color: var(--txt-dim); }
.index-pill .i-val { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 3px; }
.index-pill .i-pct { font-size: 11px; margin-top: 2px; }
.search-row { display: flex; gap: 10px; margin-bottom: 16px; }
.search-row input { max-width: 300px; }

/* 图表页 */
.chart-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.chart-toolbar .grow { flex: 1; }
.chart-3col { display: grid; grid-template-columns: 200px minmax(0, 1fr) 190px; gap: 16px; align-items: start; }
@media (max-width: 1280px) { .chart-3col { grid-template-columns: 190px minmax(0, 1fr); } .ob-panel { grid-column: 1 / -1; } }
@media (max-width: 1000px) {
  .chart-3col { grid-template-columns: 1fr; }
  /* 窄视口不整块隐藏报价/盘口（信息无替代入口），改为单列堆叠 */
  .chart-3col .quote-panel, .chart-3col .ob-panel { display: flex; }
  .chart-3col .quote-panel { flex-direction: row; flex-wrap: wrap; }
  .chart-3col .quote-item { flex: 1 1 150px; }
}
.chart-main { min-width: 0; }
.quote-panel { display: flex; flex-direction: column; gap: 16px; }
#ch-fnd { display: flex; flex-direction: column; gap: 16px; }
.quote-item { background: var(--glass); border: 1px solid var(--stroke); border-radius: 12px; padding: 10px 14px; backdrop-filter: blur(14px); }
.quote-item .q-label { font-size: 11px; color: var(--txt-faint); }
.quote-item .q-val { font-size: 14px; font-weight: 600; margin-top: 3px; font-variant-numeric: tabular-nums; }
.quote-item .q-val.fs-12 { font-size: 12px; }
.quote-item.qhead .q-name { font-size: 12px; color: var(--txt-dim); }
.quote-item.qhead .q-big { font-size: 26px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.quote-item.qhead .q-chg { font-size: 12px; margin-top: 3px; font-variant-numeric: tabular-nums; }
.quote-item.fnd-head { background: rgba(255,255,255,0.03); }
.ob-panel { padding: 16px 18px; }
.ob-table td { padding: 5px 6px; }
.ob-table .ob-head td { padding: 2px 6px 7px; font-size: 11px; border-bottom: 1px solid var(--stroke); }
.ob-table .ob-cur td { padding: 8px 6px; border-top: 1px solid var(--stroke); border-bottom: 1px solid var(--stroke); text-align: center; }
.ob-meta { margin-top: 10px; border-top: 1px solid var(--stroke); padding-top: 4px; }
/* 盘口底部信息区：每行一个「标签 + 值」，行间距统一（窄面板下外盘/内盘等不再挤一行重叠） */
.ob-meta-row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  font-size: 11.5px; color: var(--txt-dim); padding: 5px 0; line-height: 1.4;
}
/* 标签/值都不压缩不换行：窄面板下长值（如更新时间）不会再挤压标签导致竖排 */
.ob-meta-row span { flex-shrink: 0; white-space: nowrap; }
.ob-meta-row .num { color: var(--txt); font-variant-numeric: tabular-nums; text-align: right; }
.chart-box { height: 460px; width: 100%; }
.chart-box-sm { height: 220px; width: 100%; }
.chart-empty { height: 100%; display: flex; align-items: center; justify-content: center; color: var(--txt-faint); font-size: 13px; }

/* 历史回测表单：输入控件底部对齐一条线 */
.bt-form { align-items: flex-start; flex-wrap: wrap; }
.bt-form .field { display: flex; flex-direction: column; }
.bt-form label { min-height: 24px; display: flex; align-items: baseline; gap: 6px; margin-bottom: 4px; }
.bt-form #st-sym-name { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bt-form input, .bt-form select { height: 38px; min-height: 38px; box-sizing: border-box; }
.bt-form .seg { height: 38px; margin-top: 0; flex-wrap: wrap; }
.bt-form .seg button { display: inline-flex; align-items: center; justify-content: center; padding: 0 8px; font-size: 11.5px; box-sizing: border-box; }
.bt-form #st-run { height: 38px; min-height: 38px; box-sizing: border-box; }

/* 快捷仓位按钮 */
.qk-btns { display: flex; gap: 6px; margin-bottom: 8px; }
.qk-btns button {
  flex: 1; padding: 6px 0; border-radius: 8px; font-size: 12px; font-family: inherit;
  background: var(--glass); border: 1px solid var(--stroke); color: var(--txt-dim); cursor: pointer; transition: all .15s;
}
.qk-btns button:hover { border-color: var(--accent); color: var(--txt); }

/* 交易页 */
/* 左列 = 今日盈亏 + 模拟下单 + 自动交易实时信号（信号表列宽按内容分配，480px 可容纳） */
.trade-grid { display: grid; grid-template-columns: 480px minmax(0, 1fr); gap: 16px; }
.trade-left { display: flex; flex-direction: column; gap: 16px; }
/* 搜索建议中的自选标识 */
.watch-star { color: var(--amber, #f5a623); font-weight: 700; margin-right: 2px; }
/* 筛选/操作工具条：与数据区域视觉区分 */
.filter-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: rgba(255,255,255,0.045); border: 1px solid rgba(255,255,255,0.07);
  border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; }
.filter-bar .lbl { font-size: 12px; color: var(--txt-dim); }
/* 因子筛选字段：提示词外置于输入框左侧（填写后依然可见），单位缀于右侧 */
.mf-field { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--txt-dim); white-space: nowrap; }
.mf-field input { max-width: 72px; }
.mf-field .mf-unit { color: var(--txt-faint); font-size: 11px; }

/* 表格区固定高度（JS 按"表头+10行"精确覆盖，此处为兜底下限）：
   无论该页 1 条还是 10 条记录，表格区高度不变 → 翻页按钮/其它区划位置稳定；
   高度恰好容下 10 行 → 不出现纵向滚动条（横向滚动保留） */
.tbl-min-h { height: 396px; min-height: 396px; overflow-y: auto; }
.tbl-min-h table { width: 100%; }

tr.clickable { cursor: pointer; }
tr.clickable:hover { background: rgba(79,140,255,0.06); }
/* 今日盈亏卡片（交易页左上角） */
.day-pnl-card { margin: 0; }
.day-pnl-num { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 4px; }
.day-pnl-num.up { color: var(--up); }
.day-pnl-num.down { color: var(--down); }
@media (max-width: 1100px) { .trade-grid { grid-template-columns: minmax(0, 1fr); } .trade-grid > * { min-width: 0; } }
.order-form .side-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.side-tab { flex: 1; padding: 9px; border-radius: 10px; border: 1px solid var(--stroke); background: var(--glass); color: var(--txt-dim); cursor: pointer; font-size: 13px; font-weight: 600; font-family: inherit; transition: all .15s; }
.side-tab.buy.active { background: var(--up-bg); border-color: rgba(245,34,45,0.5); color: var(--up); }
.side-tab.sell.active { background: var(--down-bg); border-color: rgba(0,181,120,0.5); color: var(--down); }
.fee-preview { background: rgba(0,0,0,0.22); border: 1px dashed var(--stroke-strong); border-radius: 10px; padding: 10px 12px; font-size: 12px; color: var(--txt-dim); line-height: 1.9; margin-bottom: 12px; }
.fee-preview b { color: var(--txt); font-variant-numeric: tabular-nums; }

/* 资产页 */
.pnl-bar-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1100px) { .pnl-bar-row { grid-template-columns: minmax(0, 1fr); } .pnl-bar-row > * { min-width: 0; } }

/* 策略页 */
.strategy-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; }
/* grid 子项允许收缩：否则窄轨/单列时内容 min-content（如策略描述中的英文词）
   会把 1fr 轨道撑破，卡片横向溢出窗口 */
.strategy-grid > * { min-width: 0; }
@media (max-width: 1100px) { .strategy-grid { grid-template-columns: minmax(0, 1fr); } }
.strategy-item { padding: 14px 16px; border-radius: 13px; border: 1px solid var(--stroke); background: var(--glass); cursor: pointer; margin-bottom: 10px; transition: all .15s; backdrop-filter: blur(14px); }
.strategy-item:hover { border-color: var(--stroke-strong); }
.strategy-item.active { border-color: var(--accent); background: rgba(79,140,255,0.10); box-shadow: inset 3px 0 0 var(--accent); }
.strategy-item .s-name { font-weight: 600; font-size: 13.5px; display: flex; align-items: center; gap: 8px; }
.strategy-item .s-desc { font-size: 11.5px; color: var(--txt-dim); margin-top: 5px; line-height: 1.6; }
/* 策略库列表：默认显示约 5 条，多余滚动查看 */
.st-list-scroll { max-height: 468px; overflow-y: auto; padding-right: 4px; }
.src-tag { font-size: 10px; padding: 1px 7px; border-radius: 20px; background: rgba(124,92,255,0.18); color: #b7a6ff; }
.src-tag.builtin { background: rgba(79,140,255,0.15); color: #7fb0ff; }
.src-tag.config { background: rgba(245,166,35,0.15); color: var(--amber); }
/* 策略库自定义策略条目：✎ 编辑代码 按钮（右侧） */
.s-edit-code {
  margin-left: auto; font-size: 11px; padding: 2px 10px; border-radius: 20px;
  border: 1px solid var(--stroke); background: var(--glass); color: var(--txt-dim);
  cursor: pointer; white-space: nowrap; flex-shrink: 0; transition: all .15s;
}
.s-edit-code:hover { border-color: var(--accent); color: var(--txt); }
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
@media (max-width: 1100px) { .metric-grid { grid-template-columns: repeat(2, 1fr); } }
.bt-hint { grid-column: 1 / -1; background: rgba(245,166,35,0.08); border: 1px solid rgba(245,166,35,0.25); color: var(--amber); border-radius: 10px; padding: 10px 14px; font-size: 12px; line-height: 1.7; }
.bt-no-tag { font-size: 10px; padding: 0 6px; border-radius: 8px; background: rgba(128,128,128,0.16); color: var(--txt-faint); margin-left: 4px; white-space: nowrap; }
.metric { background: var(--glass); border: 1px solid var(--stroke); border-radius: 12px; padding: 12px 14px; backdrop-filter: blur(14px); }
.metric .m-label { font-size: 11px; color: var(--txt-faint); }
.metric .m-sub { font-size: 11px; margin-top: 3px; font-variant-numeric: tabular-nums; }
.metric .m-val { font-size: 18px; font-weight: 700; margin-top: 5px; font-variant-numeric: tabular-nums; }
.signal-badge { padding: 3px 11px; border-radius: 8px; font-size: 12px; font-weight: 700; }
.signal-buy { background: var(--up-bg); color: var(--up); }
.signal-sell { background: var(--down-bg); color: var(--down); }
.signal-hold { background: rgba(255,255,255,0.08); color: var(--txt-dim); }

/* 设置页 */
.setting-row { display: flex; align-items: center; justify-content: space-between; padding: 13px 4px; border-bottom: 1px solid rgba(255,255,255,0.05); }
.setting-row:last-child { border-bottom: none; }
.setting-row .s-label { font-size: 13px; }
.setting-row .s-desc { font-size: 11px; color: var(--txt-faint); margin-top: 3px; }
.setting-row .s-input { width: 180px; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.status-ok { background: var(--down); box-shadow: 0 0 8px rgba(0,181,120,0.7); }
.status-bad { background: var(--up); box-shadow: 0 0 8px rgba(245,34,45,0.7); }

.mono { font-family: "SF Mono", Menlo, monospace; }

/* 多选 chips */
.chip-label { display: inline-flex; align-items: center; cursor: pointer; }
.chip-label input { display: none; }
/* 自动交易标的：紧凑排布（chip 自带 margin，去掉 .row 的 gap 避免间距过大） */
.at-syms { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 10px; }
.chip {
  display: inline-block; padding: 5px 13px; margin: 3px 4px 3px 0;
  border-radius: 20px; font-size: 12px; color: var(--txt-dim);
  background: var(--glass); border: 1px solid var(--stroke);
  transition: all .15s; user-select: none;
}
.chip-label input:checked + .chip {
  color: var(--txt); border-color: var(--accent);
  background: rgba(79, 140, 255, 0.18); font-weight: 600;
}
.chip-label:hover .chip { border-color: var(--stroke-strong); }
/* 回测「执行策略」行：chips 与「多策略同时生效」开关严格同一水平线。
   默认 .chip 有上下 3px margin、.bt-form label 有 margin-bottom，会把 chips 容器撑高，
   导致开关（按容器中心对齐）比胶囊视觉中心低约 2px。此处归零后容器高度=胶囊高度，
   开关与胶囊中心完全重合（换行行距由 flex row-gap 提供，不粘连）。 */
#st-bt-strategies .chip-label,
#pf-strategies .chip-label { margin-bottom: 0; }
#st-bt-strategies .chip,
#pf-strategies .chip { margin: 0 4px 0 0; }
.text-dim { color: var(--txt-dim); }
/* 缺失工具类补齐（views.js 多处引用，此前未定义导致样式静默失效） */
.mb-8 { margin-bottom: 8px; }
.fs-13 { font-size: 13px; }
.fw-700 { font-weight: 700; }
.text-faint { color: var(--txt-faint); }
.text-up { color: var(--up); }
.text-down { color: var(--down); }
.fs-11 { font-size: 11px; } .fs-12 { font-size: 12px; } .fs-16 { font-size: 16px; } .fs-20 { font-size: 20px; }
.fw-600 { font-weight: 600; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; }
.mb-12 { margin-bottom: 12px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.tabular { font-variant-numeric: tabular-nums; }
.empty-tip { text-align: center; color: var(--txt-faint); padding: 40px 0; font-size: 13px; }

/* ---------- 空状态统一组件：图标 + 标题 + 引导 + 可选操作 ---------- */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 52px 24px; text-align: center; color: var(--txt-faint);
}
.empty-state .es-icon {
  font-size: 42px; margin-bottom: 16px; opacity: 0.45; line-height: 1;
}
.empty-state .es-title { font-size: 15px; font-weight: 600; color: var(--txt-dim); margin-bottom: 7px; }
.empty-state .es-desc { font-size: 12.5px; line-height: 1.65; max-width: 340px; }
.empty-state .es-action { margin-top: 18px; }

/* 实时信号理由列：过长省略号截断（hover 见完整） */
.sig-reason { max-width: 150px; white-space: normal; word-break: break-word; line-height: 1.5; }

/* ---------- 每日盈亏日历 ---------- */
.cal-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.cal-nav-title { font-size: 14px; font-weight: 600; min-width: 86px; text-align: center; font-variant-numeric: tabular-nums; }
.cal-wrap { padding: 4px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-head { text-align: center; font-size: 11px; color: var(--txt-faint); padding: 4px 0 8px; }
.cal-head.cal-we { color: rgba(245,166,35,0.78); }
.cal-cell {
  position: relative; min-height: 58px; border-radius: 10px; padding: 6px 8px;
  background: rgba(255,255,255,0.035); border: 1px solid transparent;
  cursor: pointer; transition: all .15s; display: flex; flex-direction: column; align-items: flex-end;
}
.cal-cell:hover { background: rgba(255,255,255,0.08); }
.cal-cell.cal-empty { background: transparent; cursor: default; pointer-events: none; }
.cal-cell.cal-weekend { background: rgba(255,255,255,0.015); }
.cal-cell.cal-has { border-color: rgba(255,255,255,0.12); }
.cal-cell.cal-today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal-day { font-size: 11.5px; color: var(--txt-dim); font-variant-numeric: tabular-nums; }
.cal-pnl { font-size: 11px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-pnl.cal-none { color: var(--txt-faint); font-weight: 400; }
.cal-pnl.up { color: var(--up); }
.cal-pnl.down { color: var(--down); }

/* ---------- 盈亏情况汇总条 ---------- */
.pnl-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px; }
.pnl-sum-item {
  background: rgba(255,255,255,0.04); border: 1px solid var(--stroke); border-radius: 12px;
  padding: 10px 14px; text-align: center;
}
.pnl-sum-label { font-size: 11px; color: var(--txt-faint); margin-bottom: 5px; }
.pnl-sum-val { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
@media (max-width: 1100px) {
  .pnl-summary { grid-template-columns: repeat(2, 1fr); }
  .pnl-sum-val { font-size: 15px; }
}

/* 多策略组合回测：策略名前的色点标识（与净值曲线颜色对应） */
.pf-legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 7px; vertical-align: middle; }

/* ---------- 窄窗口响应式（<900px：压缩侧栏与内边距，表格仍可横向滚动） ---------- */
@media (max-width: 900px) {
  .sidebar { width: 64px; }
  .sidebar .brand span, .sidebar .nav-item span, .sidebar .sidebar-foot span,
  .sidebar .nav-item .badge { display: none; }
  .sidebar .nav-item { justify-content: center; font-size: 15px; padding: 10px 0; }
  .sidebar .brand { justify-content: center; }
  .view-pane { padding: 14px 12px 30px; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-toolbar { flex-wrap: wrap; gap: 6px; }
}
@media (max-width: 560px) {
  .metric-grid { grid-template-columns: 1fr; }
  .pnl-summary { grid-template-columns: 1fr 1fr; }
  .topbar { padding: 0 8px; }
}

/* 终止日期快捷预设：紧凑胶囊（与上方字段同行不撑破布局） */
#pf-end-options .chip { padding: 3px 9px; font-size: 11.5px; margin: 0; }
#pf-end-options .chip-label { margin-bottom: 0; }
#pf-end-hint { margin-left: 6px; }

/* 自动交易实时信号：多策略合并行内的策略小标（买/卖/观）——
   固定两列网格：所有单元格同构（每列 chips 顶部严格对齐），
   不再继承 .sig-reason 的 break-word（否则芯片文字被折断、排列错位） */
.sig-drivers {
  display: grid;
  grid-template-columns: repeat(2, max-content);
  gap: 3px 8px;
  justify-content: start;
}
.sig-driver {
  display: inline-flex;
  align-items: center;
  padding: 0 5px;
  border: 1px solid var(--stroke);
  border-radius: 3px;
  font-size: 11px;
  line-height: 17px;
  white-space: nowrap;
  color: var(--txt-dim);
}
.sig-driver-buy { border-color: rgba(255,107,107,0.55); color: var(--up); }
.sig-driver-sell { border-color: rgba(76,217,100,0.55); color: var(--down); }
