/* ============ TigerWeb 深色量化终端主题 ============ */
:root {
  --bg: #0d1117;
  --bg-card: #161b22;
  --bg-card2: #1c2330;
  --border: #2d3644;
  --border-light: #3d4a5c;
  --text: #e6edf3;
  --text-dim: #8b98a9;
  --accent: #4f8cff;
  --accent-dim: #2b4a80;
  --green: #3fb950;
  --red: #f85149;
  --yellow: #d29922;
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, "Courier New", monospace;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", -apple-system, sans-serif;
  font-size: 14px;
  min-height: 100vh;
}

/* ============ 整体布局：左侧导航 + 主内容 ============ */
.app-layout { display: flex; min-height: 100vh; }

/* ---------- 左侧导航栏 ---------- */
.sidebar {
  width: 200px; flex-shrink: 0;
  background: linear-gradient(180deg, #131820, #0f131a);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
}
.sidebar-brand .logo { color: var(--accent); font-size: 22px; }
.brand-name { font-size: 20px; display: block; }
.brand-name b { color: var(--accent); }
.brand-sub { font-size: 12.5px; color: var(--text-dim); display: block; margin-top: 2px; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 10px; }

/* 一级菜单（分组标题，可折叠） */
.menu-l1 {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 10px; border-radius: 6px;
  color: var(--text-dim); font-size: 15.6px; font-weight: 600;
  cursor: pointer; user-select: none; transition: all .15s;
}
.menu-l1:hover { color: var(--text); background: rgba(255, 255, 255, .03); }
.menu-l1 .menu-arrow { margin-left: auto; font-size: 13px; transition: transform .15s; }
.menu-l1.expanded .menu-arrow { transform: rotate(90deg); }
.menu-l1 svg { opacity: .7; }

/* 二级菜单 */
.menu-l2 {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px 8px 34px; margin: 1px 0;
  border-radius: 6px; color: var(--text-dim);
  font-size: 15.6px; cursor: pointer; transition: all .15s;
  position: relative;
}
.menu-l2::before {
  content: ""; position: absolute; left: 20px; top: 50%;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--border-light); transform: translateY(-50%);
  transition: background .15s;
}
.menu-l2:hover { color: var(--text); background: rgba(255, 255, 255, .03); }
.menu-l2.active { color: var(--accent); background: rgba(79, 140, 255, .1); }
.menu-l2.active::before { background: var(--accent); }

/* 独立一级菜单项（无子菜单） */
.menu-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 10px; margin: 1px 0; border-radius: 6px;
  color: var(--text-dim); font-size: 15.6px; font-weight: 600;
  cursor: pointer; transition: all .15s;
}
.menu-item:hover { color: var(--text); background: rgba(255, 255, 255, .03); }
.menu-item.active { color: var(--accent); background: rgba(79, 140, 255, .1); }

.menu-badge {
  background: var(--accent); color: #fff; border-radius: 11px;
  font-size: 13px; padding: 1px 8px; margin-left: auto;
  animation: pulse 1.5s infinite;
}
@keyframes pulse { 50% { opacity: .55; } }

.menu-children { overflow: hidden; }

.sidebar-footer {
  padding: 12px 14px; border-top: 1px solid var(--border);
}

/* ---------- 主内容区 ---------- */
.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.content-header {
  position: sticky; top: 0; z-index: 10;
  background: rgba(13, 17, 23, .92); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
  padding: 13px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.breadcrumb { font-size: 13px; color: var(--text-dim); }
.breadcrumb b { color: var(--text); font-weight: 600; }

.content { padding: 24px; max-width: 1400px; width: 100%; margin: 0 auto; }
.page { display: none; }
.page.active { display: block; animation: fadein .2s; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 900px) {
  .sidebar { width: 64px; }
  .brand-text, .menu-l1 span.title, .menu-item span.title, .menu-l2 span.title { display: none; }
  .menu-l1, .menu-item { justify-content: center; padding-left: 0; padding-right: 0; }
  .menu-l2 { padding-left: 22px; }
  .menu-l2::before { left: 10px; }
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; padding: 20px;
}
.card-title { font-size: 15px; margin-bottom: 16px; color: var(--text); }
.card-head-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; row-gap: 10px; margin-bottom: 16px; }
.card-head-row .card-title { margin-bottom: 0; }

.grid-2col { display: grid; grid-template-columns: 400px 1fr; gap: 20px; align-items: start; }
@media (max-width: 1000px) { .grid-2col { grid-template-columns: 1fr; } }

/* ---------- 表单 ---------- */
.field { display: block; margin-bottom: 18px; }
.field-label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 8px; }

input[type="date"], input[type="number"], input[type="text"], input[type="password"], input[type="email"] {
  background: var(--bg-card2); border: 1px solid var(--border-light);
  color: var(--text); border-radius: 6px; padding: 8px 10px;
  font-size: 14px; outline: none; width: 100%;
  color-scheme: dark;
}
input:focus { border-color: var(--accent); }

.date-range { display: flex; align-items: center; gap: 8px; }
.date-range .tilde { color: var(--text-dim); }

.quick-dates { display: flex; gap: 6px; margin-top: 8px; }
.quick-dates button {
  background: var(--bg-card2); border: 1px solid var(--border-light); color: var(--text-dim);
  border-radius: 4px; padding: 3px 10px; font-size: 12px; cursor: pointer; transition: all .15s;
}
.quick-dates button:hover { color: var(--accent); border-color: var(--accent); }

.mode-group { display: flex; flex-direction: column; gap: 8px; }
.mode-option {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--bg-card2); border: 1px solid var(--border-light);
  border-radius: 8px; padding: 10px 12px; cursor: pointer; transition: all .15s;
}
.mode-option:has(input:checked) { border-color: var(--accent); background: #1a2536; }
.mode-option input { margin-top: 3px; accent-color: var(--accent); }
.mode-option b { font-size: 13px; display: block; }
.mode-option small { font-size: 12px; color: var(--text-dim); }

.adv-toggle {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  font-size: 13px; padding: 0;
}
.adv-toggle:hover { color: var(--accent); }
.adv-panel {
  margin-top: 10px; padding: 14px; background: var(--bg-card2);
  border: 1px solid var(--border); border-radius: 8px;
  display: flex; flex-direction: column; gap: 12px;
}
.field-inline { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.field-inline span { font-size: 13px; color: var(--text-dim); white-space: nowrap; }
.field-inline input { width: 200px; }

.btn-primary {
  width: 100%; background: var(--accent); color: #fff; border: none;
  border-radius: 8px; padding: 11px; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: all .15s; margin-top: 6px;
}
.btn-primary:hover { background: #6ba1ff; }
.btn-primary:disabled { background: var(--accent-dim); cursor: not-allowed; }

.btn-danger {
  width: 100%; background: transparent; color: var(--red);
  border: 1px solid var(--red); border-radius: 8px; padding: 9px;
  font-size: 14px; cursor: pointer; transition: all .15s; margin-top: 14px;
}
.btn-danger:hover { background: rgba(248, 81, 73, .12); }

.form-error {
  margin-top: 10px; color: var(--red); font-size: 13px;
  background: rgba(248, 81, 73, .08); border: 1px solid rgba(248, 81, 73, .3);
  border-radius: 6px; padding: 8px 12px;
}

/* ---------- 监控卡片 ---------- */
.monitor-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.monitor-head .card-title { margin-bottom: 0; }
.task-id-label { color: var(--text-dim); font-size: 13px; font-weight: normal; }

.status-badge {
  font-family: var(--mono); font-size: 12px; font-weight: 700;
  padding: 3px 12px; border-radius: 4px; letter-spacing: 1px;
}
.status-badge.running { background: rgba(79, 140, 255, .15); color: var(--accent); animation: pulse 1.5s infinite; }
.status-badge.success { background: rgba(63, 185, 80, .15); color: var(--green); }
.status-badge.failed { background: rgba(248, 81, 73, .15); color: var(--red); }
.status-badge.cancelled { background: rgba(139, 152, 169, .15); color: var(--text-dim); }
.status-badge.pending { background: rgba(210, 153, 34, .15); color: var(--yellow); }

.progress-block { margin-bottom: 14px; }
.progress-info { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
.progress-info #monitor-count { font-family: var(--mono); color: var(--text); }
.progress-bar {
  height: 8px; background: var(--bg-card2); border-radius: 4px; overflow: hidden;
  border: 1px solid var(--border);
}
.progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), #7ab8ff);
  transition: width .5s ease; border-radius: 4px;
}
.progress-stats { display: flex; gap: 18px; margin-top: 8px; font-size: 12px; color: var(--text-dim); }
.progress-stats b { font-family: var(--mono); color: var(--text); margin-left: 2px; }
.stat.ok b { color: var(--green); }
.stat.bad b { color: var(--red); }

/* ---------- 终端 ---------- */
.terminal-wrap { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.terminal-head {
  display: flex; align-items: center; gap: 6px;
  background: #1a2029; padding: 7px 12px; border-bottom: 1px solid var(--border);
}
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.red { background: #ff5f57; } .dot.yellow { background: #febc2e; } .dot.green { background: #28c840; }
.terminal-title { font-size: 12px; color: var(--text-dim); margin-left: 6px; flex: 1; }
.autoscroll-label { font-size: 12px; color: var(--text-dim); display: flex; align-items: center; gap: 4px; cursor: pointer; }
.autoscroll-label input { accent-color: var(--accent); }

.terminal {
  background: #0a0e14; color: #b8c4d4;
  font-family: var(--mono); font-size: 12px; line-height: 1.55;
  padding: 12px; height: 420px; overflow-y: auto;
  white-space: pre-wrap; word-break: break-all;
}
.terminal .ln-ok { color: var(--green); }
.terminal .ln-err { color: var(--red); }
.terminal .ln-warn { color: var(--yellow); }
.terminal .ln-info { color: #7ab8ff; }

/* ---------- 空状态 ---------- */
.empty-card { display: flex; align-items: center; justify-content: center; min-height: 400px; }
.empty-hint { text-align: center; color: var(--text-dim); }
.empty-icon { font-size: 42px; color: var(--border-light); margin-bottom: 14px; }
.dim { color: var(--text-dim); }
.small { font-size: 12px; }

/* ---------- 历史表格 ---------- */
.table-wrap { overflow-x: auto; }
.task-table { width: 100%; border-collapse: collapse; font-size: 13px; }
/* 回测结果页 */
.head-actions { display: flex; align-items: center; gap: 10px; }
.btn-mini { padding: 4px 10px; font-size: 12px; flex: none; }
.btn-danger-mini {
  padding: 4px 10px; font-size: 12px; flex: none;
  background: transparent; color: var(--red);
  border: 1px solid var(--red); border-radius: 6px; cursor: pointer;
}
.btn-danger-mini:hover { background: rgba(248, 81, 73, .12); }
.btn-danger-mini:disabled { opacity: .45; cursor: not-allowed; }
.file-link { color: var(--accent); text-decoration: none; word-break: break-all; }
.file-link:hover { text-decoration: underline; }
.task-table th {
  text-align: left; color: var(--text-dim); font-weight: normal; font-size: 12px;
  padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.task-table td { padding: 10px 12px; border-bottom: 1px solid #212836; white-space: nowrap; }
.task-table tr:hover td { background: rgba(79, 140, 255, .04); }
.table-empty { text-align: center; color: var(--text-dim); padding: 30px 0 !important; }
.cell-mono { font-family: var(--mono); font-size: 12px; }

.filter-group { display: flex; gap: 6px; }

/* ---------- 综合信息查询 ---------- */
.query-bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.query-fields { display: flex; gap: 12px; align-items: center; flex-wrap: nowrap; }
.query-field { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.query-label { color: var(--text-dim); font-size: 13px; white-space: nowrap; }
/* 查询按钮（综合信息/指标查询页） */
.query-bar .btn {
  padding: 10px 30px; border: none; border-radius: 8px; cursor: pointer;
  font-size: 15px; font-weight: 600; letter-spacing: 2px;
  color: #fff; background: linear-gradient(135deg, #4f8cff, #3667d8);
  box-shadow: 0 2px 8px rgba(79, 140, 255, .35);
  transition: all .15s;
}
.query-bar .btn:hover { filter: brightness(1.12); box-shadow: 0 4px 14px rgba(79, 140, 255, .5); }
.query-bar .btn:active { transform: translateY(1px); box-shadow: 0 1px 4px rgba(79, 140, 255, .3); }
.query-code-input { width: 200px; }
.query-date-input { width: 150px; }
.query-hint { color: var(--text-dim); font-size: 12px; margin: 8px 0 14px; }
.query-placeholder {
  text-align: center; color: var(--text-dim); padding: 50px 0;
  border: 1px dashed var(--border); border-radius: 8px;
}
.query-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.query-tab {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-card2); border: 1px solid var(--border-light); color: var(--text-dim);
  border-radius: 6px; padding: 6px 14px; font-size: 13px; cursor: pointer;
}
.query-tab:hover { color: var(--text-main); border-color: var(--accent); }
.query-tab.active {
  color: #fff; background: var(--accent); border-color: var(--accent);
}
.query-tab-badge {
  font-size: 11px; padding: 1px 7px; border-radius: 9px;
  background: rgba(0, 0, 0, .22); color: #fff;
}
.query-tab:not(.active) .query-tab-badge { background: rgba(79, 140, 255, .14); color: var(--accent); }
.query-meta { color: var(--text-dim); font-size: 12px; margin-bottom: 8px; }
.report-files { display: flex; flex-direction: column; gap: 10px; }
.report-file-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-card2); border: 1px solid var(--border-light); border-radius: 8px;
  padding: 12px 16px;
}
.report-file-info { flex: 1; min-width: 0; }
.report-file-name {
  font-size: 13px; color: var(--text-main);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.filter-btn {
  background: var(--bg-card2); border: 1px solid var(--border-light); color: var(--text-dim);
  border-radius: 4px; padding: 4px 12px; font-size: 12px; cursor: pointer;
}
.filter-btn.active { color: var(--accent); border-color: var(--accent); }

.link-btn { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 13px; padding: 0; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--red); margin-left: 10px; }

.mini-progress { display: inline-flex; align-items: center; gap: 8px; }
.mini-progress .bar { width: 80px; height: 5px; background: var(--bg-card2); border-radius: 3px; overflow: hidden; }
.mini-progress .fill { height: 100%; background: var(--accent); }
.mini-progress span { font-family: var(--mono); font-size: 11px; color: var(--text-dim); }

/* ---------- 配置页 ---------- */
.env-meta-card { margin-bottom: 20px; }
.env-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 10px; font-size: 13px; }
.env-meta .meta-item {
  background: var(--bg-card2); border: 1px solid var(--border); border-radius: 6px;
  padding: 9px 12px; display: flex; gap: 10px; align-items: center;
}
.env-meta .meta-item .k { color: var(--text-dim); white-space: nowrap; }
.env-meta .meta-item .v { font-family: var(--mono); font-size: 12px; word-break: break-all; }
.env-meta .ok-tag { color: var(--green); } .env-meta .bad-tag { color: var(--red); }

.config-fields { display: flex; flex-direction: column; gap: 14px; max-width: 640px; }
.config-field label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; font-family: var(--mono); }
.config-field select {
  width: 100%; padding: 9px 12px; border-radius: 6px;
  border: 1px solid var(--border-light); background-color: var(--bg-card2);
  color: var(--text); font-size: 13px; font-family: var(--mono);
}
/* 下拉选项列表：明确深色底 + 浅色文字，避免浏览器默认浅底配浅字看不清 */
select option { background-color: var(--bg-card2); color: var(--text); }
select:focus { outline: none; border-color: var(--accent); }
.config-field-desc { margin-top: 5px; line-height: 1.5; }
.config-actions { display: flex; align-items: center; gap: 16px; margin-top: 20px; }
.config-actions .btn-primary { width: auto; padding: 9px 28px; }
.config-msg { font-size: 13px; }
.config-msg.ok { color: var(--green); }
.config-msg.err { color: var(--red); }

/* ============ 模块说明文档 ============ */
.doc-content { font-size: 14px; line-height: 1.75; max-width: 920px; }
.doc-content h1 { font-size: 20px; margin: 4px 0 14px; }
.doc-content h2 { font-size: 17px; margin: 22px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border-light); }
.doc-content h3 { font-size: 15px; margin: 16px 0 8px; }
.doc-content p { margin: 8px 0; }
.doc-content ul, .doc-content ol { margin: 8px 0; padding-left: 22px; }
.doc-content li { margin: 4px 0; }
.doc-content code {
  font-family: var(--mono); font-size: 12.5px; background: var(--bg-side);
  padding: 2px 6px; border-radius: 4px; border: 1px solid var(--border-light);
}
.doc-content pre {
  background: var(--bg-side); border: 1px solid var(--border-light); border-radius: 8px;
  padding: 12px 14px; overflow-x: auto; margin: 10px 0; line-height: 1.5;
}
.doc-content pre code { background: none; border: none; padding: 0; font-size: 12.5px; }
.doc-content table { border-collapse: collapse; margin: 10px 0; width: 100%; }
.doc-content th, .doc-content td {
  border: 1px solid var(--border-light); padding: 7px 12px; font-size: 13px; text-align: left;
}
.doc-content th { background: var(--bg-side); }
.doc-content blockquote {
  border-left: 3px solid var(--accent); margin: 10px 0; padding: 4px 14px;
  color: var(--text-dim); background: var(--bg-side);
}

/* ============ 三级菜单 ============ */
.menu-group-l2 { margin-top: 2px; }
.menu-l2.menu-subgroup-toggle { cursor: pointer; }
.menu-l2.menu-subgroup-toggle .menu-arrow {
  margin-left: auto; font-size: 11px; color: var(--text-dim);
  transition: transform .18s; display: inline-block;
}
.menu-l2.menu-subgroup-toggle.expanded .menu-arrow { transform: rotate(90deg); }
.menu-children-l3 { padding-left: 26px; }
.menu-l3 {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 10px 6px 16px; border-radius: 7px; cursor: pointer;
  color: var(--text-dim); font-size: 14px; position: relative;
  transition: background .15s, color .15s;
}
.menu-l3::before {
  content: ""; position: absolute; left: 4px; top: 50%;
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--border-light); transform: translateY(-50%);
  transition: background .15s;
}
.menu-l3:hover { background: var(--bg-hover); color: var(--text); }
.menu-l3.active { background: var(--bg-hover); color: var(--accent); }
.menu-l3.active::before { background: var(--accent); }
.menu-l3 svg { width: 17px; height: 17px; flex-shrink: 0; }

/* ============ 策略执行页 ============ */
.ma-exec-layout { display: flex; gap: 18px; align-items: stretch; }
/* 页面高度撑满：布局区至少占满视口剩余空间（策略执行页扣除顶部策略参数卡片） */
#page-ma-exec .ma-exec-layout { min-height: max(480px, calc(100vh - 400px)); }
/* 战法页/回测结果页：锁定视口高度，正文在框内滚动（滚动条），页面不随内容变长 */
#page-ma-tactics .ma-exec-layout, #page-ma-results .ma-exec-layout { height: calc(100vh - 170px); min-height: 480px; }
#page-ma-tactics .ma-exec-layout > .card, #page-ma-results .ma-exec-layout > .card { display: flex; flex-direction: column; overflow: hidden; }
#page-ma-tactics .tactics-list, #page-ma-results .tactics-list { flex: 1; overflow-y: auto; min-height: 0; }
/* 指标计算页：锁定视口高度，参数字段多时左卡框内滚动，页面不随内容变长 */
#page-calcindicator .ma-exec-layout { height: calc(100vh - 170px); min-height: 480px; }
#page-calcindicator .ma-exec-layout > .card:first-child { display: flex; flex-direction: column; overflow: hidden; }
/* 下载页（基本信息/预测/资金流/账龄/坏账/综合）：两栏布局锁定视口高度，
   日志终端撑满可用空间并在框内滚动，不随日志行数拉长页面 */
#page-dailybasic .ma-exec-layout, #page-forecast .ma-exec-layout,
#page-moneyflow .ma-exec-layout, #page-reportaging .ma-exec-layout,
#page-reportbaddebt .ma-exec-layout, #page-tsmain .ma-exec-layout {
  height: calc(100vh - 170px); min-height: 480px;
}
#page-dailybasic .ma-exec-layout > .card:first-child,
#page-forecast .ma-exec-layout > .card:first-child,
#page-moneyflow .ma-exec-layout > .card:first-child,
#page-reportaging .ma-exec-layout > .card:first-child,
#page-reportbaddebt .ma-exec-layout > .card:first-child,
#page-tsmain .ma-exec-layout > .card:first-child {
  display: flex; flex-direction: column; overflow-y: auto;
}
/* 新接入下载页（基准指数/指标数据/行业日行情/沪深300/期货/基金/财报/申万二级）：同上两栏锁高规则 */
#page-benchmark .ma-exec-layout, #page-tsindicator .ma-exec-layout,
#page-industrydaily .ma-exec-layout, #page-hs300 .ma-exec-layout,
#page-future .ma-exec-layout, #page-fundnav .ma-exec-layout,
#page-fundposition .ma-exec-layout, #page-finreport .ma-exec-layout,
#page-swl2 .ma-exec-layout {
  height: calc(100vh - 170px); min-height: 480px;
}
#page-benchmark .ma-exec-layout > .card:first-child,
#page-tsindicator .ma-exec-layout > .card:first-child,
#page-industrydaily .ma-exec-layout > .card:first-child,
#page-hs300 .ma-exec-layout > .card:first-child,
#page-future .ma-exec-layout > .card:first-child,
#page-fundnav .ma-exec-layout > .card:first-child,
#page-fundposition .ma-exec-layout > .card:first-child,
#page-finreport .ma-exec-layout > .card:first-child,
#page-swl2 .ma-exec-layout > .card:first-child {
  display: flex; flex-direction: column; overflow-y: auto;
}
#page-calcindicator .config-fields { flex: 1; overflow-y: auto; min-height: 0; }
#page-calcindicator .config-actions { position: sticky; bottom: 0; background: var(--bg-card); padding: 10px 0 2px; }
/* 回测结果查看器 */
.output-viewer { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: auto; }
.output-viewer .output-img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }
.output-viewer pre.tactic-viewer { align-self: stretch; }
.ma-exec-layout > .card:first-child { flex: 0 0 360px; }
.ma-monitor-col { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
/* 右列卡片撑满可用高度：日志终端/战法正文随视口拉伸 */
.ma-monitor-col > .card { flex: 1; min-height: 0; }
.ma-monitor-col .monitor-card { display: flex; flex-direction: column; }
.ma-monitor-col .terminal-wrap { flex: 1; display: flex; flex-direction: column; min-height: 0; }
/* min-height:0 必不可少：否则日志行数多时 pre 被内容撑开（百万像素高），
   溢出右列裁剪区，底部"取消任务"按钮被推出可视范围且无法滚动 */
.ma-monitor-col .terminal { flex: 1; height: auto; min-height: 0; max-height: calc(100vh - 300px); overflow-y: auto; }
/* 战法正文：框内滚动（不撑开页面），卡片高度跟随视口 */
.ma-monitor-col .tactic-viewer {
  flex: 1; height: auto; min-height: 0; max-height: none;
  overflow-y: auto; overscroll-behavior: contain;
}
/* 策略参数：全宽独立卡片位于页面顶部，多列自适应网格（均线策略与自定义策略执行页共用）
   参数多时限高内部滚动，避免页面被拉长 */
.strategy-params-panel { margin-bottom: 18px; }
.strategy-params-panel .config-fields {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px 18px; max-width: none;
  max-height: 300px; overflow-y: auto;
}
.ma-exec-actions { display: flex; gap: 12px; margin-top: 16px; }
.ma-exec-actions .btn-primary, .ma-exec-actions .btn-secondary { flex: 1; }
/* 回测区：起止日期并排一行 */
.ma-backtest-fields {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px;
  margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--border-light);
}
.ma-backtest-fields .field { margin-bottom: 12px; }
.ma-exec-fields {
  margin-top: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px;
}
.ma-exec-fields .config-field { margin: 0; }
.ma-exec-fields .config-field label { font-size: 12px; margin-bottom: 4px; }
.ma-exec-fields .config-field input, .ma-exec-fields .config-field select { padding: 7px 10px; font-size: 13px; }
.btn-secondary {
  padding: 10px 0; border-radius: 7px; border: 1px solid var(--accent);
  background: transparent; color: var(--accent); font-size: 14px; cursor: pointer;
  transition: background .15s;
}
.btn-secondary:hover { background: var(--bg-hover); }
.ma-monitor-col .empty-card { border: none; box-shadow: none; }
.ma-monitor-col .monitor-card { border: none; box-shadow: none; }

/* ============ 战法页 ============ */
.tactics-list { display: flex; flex-direction: column; gap: 4px; }
.tactic-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 7px; cursor: pointer;
  color: var(--text-dim); transition: background .15s, color .15s;
}
.tactic-item .title { flex: 1; font-size: 14px; word-break: break-all; }
.tactic-item:hover { background: var(--bg-hover); color: var(--text); }
.tactic-item.active { background: var(--bg-hover); color: var(--accent); }
.tactic-viewer {
  min-height: 560px; max-height: 72vh; white-space: pre-wrap; overflow-y: auto;
  font-size: 13px; line-height: 1.7; color: var(--text);
}
.ma-exec-layout .card:first-child { align-self: stretch; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .6);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
  background: var(--bg-card); border: 1px solid var(--border-light);
  border-radius: 10px; width: min(960px, 92vw); max-height: 86vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px; border-bottom: 1px solid var(--border); font-size: 14px;
}
.modal-head b { color: var(--accent); font-family: var(--mono); }
.modal-close { background: none; border: none; color: var(--text-dim); font-size: 22px; cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-terminal { flex: 1; height: 68vh; border-radius: 0; }

/* ============ AI 模块：AI问诊 / 指标解释 ============ */
.ai-loading {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  color: var(--text-dim); padding: 60px 0; font-size: 14px;
}
.ai-spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid var(--accent-dim); border-top-color: var(--accent);
  animation: ai-spin .8s linear infinite;
}
@keyframes ai-spin { to { transform: rotate(360deg); } }

.ai-meta {
  color: var(--text-dim); font-size: 12px; font-family: var(--mono);
  background: var(--bg-card2); border: 1px solid var(--border-light);
  border-radius: 6px; padding: 8px 12px; margin-bottom: 12px;
  word-break: break-all;
}
.ind-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.ind-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-card2); border: 1px solid var(--border-light);
  border-radius: 14px; padding: 4px 12px; font-size: 12px; color: var(--text-dim);
}
.ind-chip b { color: var(--accent); font-weight: 600; font-family: var(--mono); }
.ai-analysis {
  border: 1px solid var(--border-light); border-radius: 8px;
  background: var(--bg-card2); padding: 18px 22px; line-height: 1.75;
}
.ai-analysis h3, .ai-analysis h4, .ai-analysis h5 {
  color: var(--accent); margin: 16px 0 8px; font-size: 15px;
}
.ai-analysis h3:first-child, .ai-analysis h4:first-child { margin-top: 0; }
.ai-analysis p { margin: 6px 0; color: var(--text); }
.ai-analysis ul { margin: 6px 0 6px 20px; }
.ai-analysis li { margin: 4px 0; color: var(--text); }
.ai-analysis b { color: var(--text); }

.ai-disclaimer {
  margin-top: 14px; padding: 10px 14px;
  border-left: 3px solid var(--yellow); border-radius: 0 6px 6px 0;
  background: rgba(210, 153, 34, .08);
  color: var(--text-dim); font-size: 12.5px; line-height: 1.6;
}

.explain-search-input { width: 260px; }
.explain-head {
  color: var(--accent); font-family: var(--mono); font-size: 13px;
  background: var(--bg-card2); border: 1px solid var(--border-light);
  border-radius: 6px; padding: 12px 14px; margin-bottom: 12px;
  white-space: pre-wrap; word-break: break-all;
}
.explain-count { color: var(--text-dim); font-size: 12px; margin-bottom: 10px; }
.explain-item {
  font-family: var(--mono); font-size: 12.5px; color: var(--text);
  background: var(--bg-card2); border: 1px solid var(--border);
  border-left: 3px solid var(--accent-dim); border-radius: 6px;
  padding: 10px 14px; margin-bottom: 8px;
  white-space: pre-wrap; word-break: break-word;
}

/* ============ 登录认证（登录遮罩 / 顶栏用户区 / 修改密码弹窗） ============ */
.login-mask {
  position: fixed; inset: 0; z-index: 200; /* 高于任务日志弹窗(100) */
  background: rgba(13, 17, 23, .97);
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  width: 360px; background: var(--bg-card);
  border: 1px solid var(--border-light); border-radius: 12px;
  padding: 34px 32px 28px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, .5);
}
.login-brand { font-size: 24px; margin-bottom: 4px; }
.login-brand .logo { color: var(--accent); margin-right: 6px; }
.login-brand b { color: var(--accent); }
.login-sub { color: var(--text-dim); font-size: 13px; margin-bottom: 22px; }
.login-switch { margin-top: 14px; text-align: center; font-size: 12px; color: var(--text-dim); }
.login-switch a { color: var(--accent); cursor: pointer; text-decoration: none; }

/* 找回密码：验证码输入行 */
.code-row { display: flex; gap: 8px; }
.code-row input { flex: 1; min-width: 0; }
.btn-send-code {
  flex: none; background: var(--bg-card2); color: var(--accent);
  border: 1px solid var(--border-light); border-radius: 6px;
  padding: 0 14px; font-size: 13px; cursor: pointer; transition: all .15s;
}
.btn-send-code:hover:not(:disabled) { border-color: var(--accent); }
.btn-send-code:disabled { color: var(--text-dim); cursor: not-allowed; }

.user-box { display: flex; align-items: center; gap: 10px; flex: none; }
.user-box .user-name { font-size: 13px; font-weight: 600; }
.user-box .user-role {
  font-size: 12px; color: var(--accent);
  background: rgba(79, 140, 255, .12); border: 1px solid rgba(79, 140, 255, .35);
  border-radius: 10px; padding: 1px 10px;
}

.pwd-modal { width: min(400px, 92vw); max-height: none; }
.pwd-form { padding: 20px 22px; }

/* ============ 用户管理页 ============ */
.field select {
  width: 100%; padding: 8px 10px; border-radius: 6px;
  border: 1px solid var(--border-light); background-color: var(--bg-card2);
  color: var(--text); font-size: 14px; color-scheme: dark;
}
.user-create-form { max-width: 420px; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td {
  padding: 10px 12px; text-align: left;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.data-table th { color: var(--text-dim); font-weight: 600; }
.data-table td { color: var(--text); }
.data-table tr:hover td { background: rgba(255, 255, 255, .02); }
.user-actions { display: flex; gap: 6px; }

/* ============ 操作日志页 ============ */
.oplog-terminal { height: 520px; }
.explain-item:first-line { color: var(--accent); font-weight: 600; }

/* prompts 编辑器（AI中心 → prompts） */
.prompt-textarea {
  width: 100%; min-height: 420px; resize: vertical;
  background: var(--bg-card2); color: var(--text);
  border: 1px solid var(--border-light); border-radius: 8px;
  font-family: var(--mono); font-size: 13px; line-height: 1.7;
  padding: 14px 16px; outline: none; white-space: pre-wrap;
}
.prompt-textarea:focus { border-color: var(--accent); }

/* 滚动条 */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #4d5c72; }

/* ============ 数据导入（我的数据）============ */
.data-file-picker { display:flex; flex-wrap:wrap; gap:8px; }
.data-file-item { display:inline-flex; align-items:center; gap:6px; padding:5px 12px;
  border:1px solid var(--border-light); border-radius:6px; background:var(--bg-card2);
  color:var(--text); font-size:13px; cursor:pointer; max-width:280px; }
.data-file-item:hover { border-color: var(--accent); }
.data-file-item span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.data-file-item input { margin:0; accent-color: var(--accent); }

/* 数据来源三选一 + 我的数据下拉多选（AI问股 / 策略生成页） */
.data-mode-row { display:flex; flex-wrap:wrap; gap:8px; margin-bottom:8px; }
.data-mode-opt { display:inline-flex; align-items:center; gap:6px; padding:6px 14px;
  border:1px solid var(--border-light); border-radius:6px; background:var(--bg-card2);
  color:var(--text); font-size:13px; cursor:pointer; }
.data-mode-opt:hover { border-color: var(--accent); }
.data-mode-opt:has(input:checked) { border-color:var(--accent); background:var(--accent-dim); color:#fff; }
.data-mode-opt input { margin:0; accent-color: var(--accent); }
.mydata-select { margin-bottom:8px; }
.mydata-dd { position:relative; display:inline-block; }
.mydata-dd-btn { padding:6px 14px; font-size:13px; color:var(--text);
  background:var(--bg-card2); border:1px solid var(--border-light); border-radius:6px; cursor:pointer; }
.mydata-dd-btn:hover { border-color: var(--accent); }
.mydata-dd-panel { display:none; position:absolute; top:calc(100% + 6px); left:0; z-index:60;
  min-width:320px; max-width:420px; max-height:260px; overflow-y:auto;
  background:var(--bg-card); border:1px solid var(--border-light); border-radius:8px;
  padding:10px; box-shadow:0 8px 24px rgba(0,0,0,.45); }
.mydata-dd-panel .data-file-item { display:flex; max-width:none; margin-bottom:6px; }

/* 使用指南页 */
.guide-grid { display:grid; grid-template-columns:repeat(auto-fit, minmax(340px, 1fr)); gap:14px; margin-top:14px; }
.guide-card { background:var(--bg-card2); border:1px solid var(--border-light); border-radius:10px; padding:16px 18px; }
.guide-title { font-size:15px; color:var(--text); margin-bottom:12px; padding-bottom:8px;
  border-bottom:1px solid var(--border); }
.guide-steps { list-style:none; counter-reset:step; }
.guide-steps li { position:relative; padding-left:30px; margin-bottom:10px; font-size:13.5px;
  color:var(--text); line-height:1.65; counter-increment:step; }
.guide-steps li::before { content:counter(step); position:absolute; left:0; top:1px;
  width:20px; height:20px; border-radius:50%; background:var(--accent-dim); color:#fff;
  font-size:12px; display:flex; align-items:center; justify-content:center; }

/* 我的数据页：系统本地数据清单 */
.local-data-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 4px 28px; margin-top: 4px; }
.local-data-item { display: flex; align-items: baseline; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.local-data-item code { color: var(--accent); font-family: Consolas, "Courier New", monospace; white-space: nowrap; }
.local-data-item span { color: var(--text-dim); }
