:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --line: #e4e8ee;
  --text: #1f2430;
  --muted: #7b8494;
  --brand: #185fa5;
  --brand-soft: #e8f0fe;
  --green: #1f9d55;
  --red: #d64545;
  --amber: #c98a12;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

[v-cloak] { display: none; }

h1, h2, h3 { margin: 0; font-weight: 600; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
code {
  font-family: "Cascadia Code", Consolas, "Courier New", monospace;
  background: #f0f2f6;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}
.muted { color: var(--muted); }
.sm { font-size: 12px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.ellipsis { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 18px; }
.brand p { margin: 0; }
.logo {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #185fa5, #2f88d8);
  color: #fff;
  font-weight: 700;
  letter-spacing: .5px;
}
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs button {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: .15s;
}
.tabs button:hover { background: #f0f2f6; color: var(--text); }
.tabs button.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

/* ---------------- 总览 ---------------- */
.overview {
  display: flex;
  align-items: center;
  gap: 28px;
  flex-wrap: wrap;
  padding: 14px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.stat { display: flex; flex-direction: column; }
.stat-num { font-size: 20px; font-weight: 700; color: var(--brand); }
.stat-label { font-size: 12px; color: var(--muted); }
.stat-path { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; }

/* ---------------- 布局 ---------------- */
main { padding: 20px 24px 60px; }
.pane { animation: fade .18s ease; }
@keyframes fade { from { opacity: .4; } to { opacity: 1; } }

.split { display: grid; grid-template-columns: 320px 1fr; gap: 18px; align-items: start; }
.split > .panel, .split > .content-panel { min-width: 0; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.panel + .panel { margin-top: 18px; }
.content-panel > .panel + .panel { margin-top: 18px; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.sub-head { margin: 18px 0 8px; color: var(--muted); font-size: 13px; }

/* ---------------- 表单 ---------------- */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: #414a5a; margin-bottom: 5px; }
input[type="text"], input[type="search"], input[type="date"], input[type="number"],
input[type="time"], input[type="month"], input[type="password"], select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: .15s;
}
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(24, 95, 165, .12); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.checks { display: flex; gap: 18px; margin: 6px 0 14px; }
.chk { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.check-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 10px;
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}
.check-grid .chk { justify-content: flex-start; }
.check-grid .chk span:last-child { margin-left: auto; }
.row-actions { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.hint { margin: 0 0 12px; }

/* ---------------- 按钮 ---------------- */
.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: .15s;
}
.btn:hover { border-color: #c7cedb; background: #f7f9fc; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #144f8a; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); }
.btn.sm { padding: 5px 12px; font-size: 12px; }
.btn.xs { padding: 3px 8px; font-size: 12px; }

/* ---------------- 标的列表 ---------------- */
.list-panel { position: sticky; top: 128px; }
.list-meta { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 8px; }
.ins-list { list-style: none; margin: 0; padding: 0; max-height: 62vh; overflow: auto; }
.ins-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: .12s;
}
.ins-list li:hover { background: #f5f7fa; }
.ins-list li.active { background: var(--brand-soft); }
.ins-list li.empty { color: var(--muted); justify-content: center; cursor: default; }
.ins-main { display: flex; flex-direction: column; min-width: 0; }
.ins-name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ins-code { font-size: 11px; color: var(--muted); }

.tag {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 20px;
  white-space: nowrap;
}
.tag-idx { background: #eaf6ee; color: var(--green); }
.tag-stock { background: #eef2f8; color: #5a6a86; }

/* ---------------- 图表 ---------------- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.chart { width: 100%; height: 460px; }
.loading { padding: 24px; text-align: center; color: var(--muted); }

.placeholder-panel { display: grid; place-items: center; min-height: 320px; }
.placeholder { text-align: center; }
.placeholder h3 { font-size: 16px; margin-bottom: 8px; }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow: auto; max-height: 420px; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  position: sticky;
  top: 0;
  background: #f7f9fc;
  text-align: left;
  padding: 9px 12px;
  font-weight: 600;
  color: #414a5a;
  border-bottom: 1px solid var(--line);
  z-index: 1;
}
tbody td { padding: 8px 12px; border-bottom: 1px solid #f0f2f6; }
tbody tr:hover { background: #fafbfd; }
.hist .ellipsis { max-width: 240px; }

/* ---------------- 日志 ---------------- */
.log-panel { min-width: 0; }
.log-box { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.log-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #f7f9fc;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.log-head code { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: transparent; }
.log {
  margin: 0;
  padding: 12px 14px;
  background: #10151f;
  color: #d5e0f0;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
.log.tall { max-height: 60vh; }

/* ---------------- 徽标 ---------------- */
.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 9px;
  border-radius: 20px;
  white-space: nowrap;
}
.badge-running { background: #fff4e0; color: var(--amber); }
.badge-success { background: #e7f6ec; color: var(--green); }
.badge-failed { background: #fdecec; color: var(--red); }
.badge-stopped { background: #eef2f8; color: var(--muted); }

/* ---------------- 帮助 ---------------- */
.help-panel { max-width: 900px; }
.help-panel h2 { margin-bottom: 14px; }
.help-panel h3 { margin: 20px 0 8px; color: var(--brand); }
.help-panel ol, .help-panel ul { margin: 0 0 8px; padding-left: 22px; }
.help-panel li { margin: 5px 0; }
.help-panel .badge { margin: 0 4px; }
.kv { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.kv th { width: 140px; text-align: left; background: #f7f9fc; padding: 8px 12px; font-weight: 600; }
.kv td { padding: 8px 12px; border-top: 1px solid var(--line); }

/* ---------------- 港股交易日 ---------------- */
.warn { color: var(--amber); font-size: 12px; }
.month-input { width: auto; }

.td-result {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafbfd;
}
.td-badge {
  flex: none;
  display: grid;
  place-items: center;
  min-width: 76px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
}
.td-badge.sm { min-width: 60px; padding: 3px 10px; font-size: 12px; }
.td-yes { background: var(--green); }
.td-no { background: var(--muted); }
.td-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.td-date { font-size: 15px; font-weight: 600; }
.td-online { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.td-inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.neighbor { display: flex; flex-direction: column; gap: 6px; }
.neighbor-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.neighbor-row > .muted { flex: none; width: 32px; }
.day-chip {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 20px;
  background: var(--brand-soft);
  color: var(--brand);
  font-family: "Cascadia Code", Consolas, monospace;
}

/* 交易日历 */
.cal-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.lg { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-trading { background: var(--green); }
.dot-weekend { background: #c7cedb; }
.dot-holiday { background: var(--red); }
.dot-half { background: var(--amber); }
.cal-stats { margin-bottom: 10px; }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding: 4px 0;
  font-weight: 600;
}
.cal-cell {
  position: relative;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  cursor: pointer;
  background: #fff;
  transition: .12s;
}
.cal-cell:hover { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(24, 95, 165, .1); }
.cal-blank { border: none; background: transparent; cursor: default; }
.cal-blank:hover { border: none; box-shadow: none; }
.cal-day { font-size: 13px; font-weight: 600; color: var(--text); }
.cal-cell.is-weekend .cal-day { color: #aab2c0; }
.cal-cell.is-trading { background: #f2fbf5; border-color: #cfe9d8; }
.cal-cell.is-holiday { background: #fdf1f1; border-color: #f2cfcf; }
.cal-cell.is-holiday .cal-day { color: var(--red); }
.cal-cell.is-half { background: #fff8ea; border-color: #f0dcb4; }
.cal-cell.is-today { box-shadow: inset 0 0 0 2px var(--brand); }
.cal-cell.is-picked { outline: 2px solid var(--brand); outline-offset: -1px; }
.cal-mark {
  position: absolute;
  right: 6px;
  bottom: 5px;
  font-size: 10px;
  padding: 0 4px;
  border-radius: 4px;
  background: var(--red);
  color: #fff;
}
.cal-mark.half { background: var(--amber); }

/* ---------------- 定时任务 ---------------- */
.switch-row { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.field label.switch-row { display: flex; margin-bottom: 0; }
.switch-row input { width: auto; }

/* 流水线阶段（数据获取 / 网页生成） */
.stage-list { display: flex; flex-direction: column; gap: 1px; background: var(--line); }
.stage-item {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 12px;
  background: #fff;
}
.stage-name { font-size: 13px; font-weight: 600; min-width: 62px; }

/* 手动补数：校验预览 */
.preview-box {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafbfd;
}
.preview-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.preview-box .warn { margin-top: 6px; }
.req { color: var(--red); }
.result-line { display: flex; flex-direction: column; gap: 4px; padding: 8px 12px; background: #f7f9fc; border-top: 1px solid var(--line); }

/* ---------------- 弹窗 ---------------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, .45);
  display: grid;
  place-items: center;
  z-index: 40;
  padding: 24px;
}
.modal-card {
  background: var(--panel);
  border-radius: var(--radius);
  width: min(880px, 100%);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  padding: 16px;
  box-shadow: 0 20px 50px rgba(16, 24, 40, .3);
}
.modal-meta { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.modal-card.wide { width: min(1040px, 100%); }
.modal-card .modal-body { overflow: auto; }
.modal-card .modal-foot { margin-top: 12px; display: flex; align-items: center; gap: 10px; }

/* ---------------- 提示 ---------------- */
.toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
}
.toast {
  padding: 10px 16px;
  border-radius: 8px;
  color: #fff;
  font-size: 13px;
  box-shadow: 0 6px 18px rgba(16, 24, 40, .2);
  animation: slide .2s ease;
  max-width: 380px;
}
@keyframes slide { from { transform: translateY(8px); opacity: 0; } }
.toast-success { background: var(--green); }
.toast-error { background: var(--red); }
.toast-info { background: #2b3550; }

/* ---------------- 登录页 ---------------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #eef3fb 0%, #f5f7fa 55%, #eef7f2 100%);
}
.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(16, 24, 40, .1);
  padding: 28px 26px;
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-brand h1 { font-size: 18px; }
.login-brand p { margin: 0; }
.login-loading { text-align: center; padding: 18px 0; }
.login-form .field { margin-bottom: 14px; }
.login-error {
  margin: 0 0 12px;
  padding: 8px 12px;
  border-radius: 8px;
  background: #fdecec;
  color: var(--red);
  font-size: 13px;
}
.login-tip { margin: 14px 0 0; text-align: center; }
.login-tip code { background: #f0f2f6; }
.btn.block { width: 100%; justify-content: center; padding: 10px 16px; font-size: 14px; }

/* ---------------- 顶栏用户区 ---------------- */
.user-area { display: flex; align-items: center; gap: 10px; }
.user-meta { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.3; }
.user-name { font-size: 13px; font-weight: 600; }

/* ---------------- 筛选 / 批量 / 分页 ---------------- */
.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.filter-bar select { width: auto; min-width: 120px; }
.filter-bar .search-sm { width: 260px; flex: none; }
.batch-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding: 8px 12px;
  border: 1px solid var(--brand-soft);
  background: #f4f8fe;
  border-radius: 8px;
}
.batch-bar select { width: auto; min-width: 130px; }
.col-check { width: 40px; text-align: center; }
.col-check input { width: auto; cursor: pointer; }
.pager { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.pager .muted { margin-right: auto; }

@media (max-width: 900px) {
  .split { grid-template-columns: 1fr; }
  .list-panel { position: static; }
  .stat-path { margin-left: 0; align-items: flex-start; }
  .filter-bar .search-sm { width: 100%; }
}