:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --line: #e3e6ea;
  --text: #1f2329;
  --muted: #8a9099;
  --accent: #2563eb;
  --error: #e5484d;
  --info: #8a9099;
  --up: #d94838;
  --down: #1a9e5c;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, sans-serif;
  font-size: 13px;
}

header {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand { font-size: 16px; font-weight: 700; }
.brand-sub { color: var(--muted); font-size: 12px; }

.nav-toggle {
  width: 32px;
  height: 30px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  font-size: 15px;
  line-height: 1;
  color: #4a5058;
  cursor: pointer;
}
.nav-toggle:hover { background: #eef2f7; }

.resizer {
  flex: 0 0 5px;
  cursor: col-resize;
  position: relative;
  background: transparent;
}
.resizer::before {
  content: "";
  position: absolute;
  inset: 0 2px;
  background: var(--line);
}
.resizer:hover::before, .resizer.dragging::before { background: var(--accent); }

body.nav-collapsed .sidebar {
  width: 0 !important;
  flex: 0 0 0 !important;
  padding: 0;
  border: none;
  overflow: hidden;
}
body.nav-collapsed .resizer { display: none; }

.layout { display: flex; height: calc(100vh - 46px); }

.sidebar {
  width: 250px;
  flex: 0 0 250px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: 10px;
}

.side-title {
  font-weight: 600;
  color: #4a5058;
  padding: 6px 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
}

.chev { display: none; color: var(--muted); font-size: 11px; }

.sym-list { display: flex; flex-direction: column; gap: 2px; }

.market-head {
  color: var(--muted);
  font-size: 11px;
  padding: 8px 4px 2px;
  letter-spacing: 1px;
}

.sym {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
}
.sym:hover { background: #eef2f7; }
.sym.active { background: #e6efff; border-color: #bcd3ff; }
.sym .s-name { font-weight: 500; }
.sym .s-code { color: var(--muted); font-size: 11px; }
.sym .s-badge {
  font-size: 10px;
  color: #fff;
  background: var(--error);
  border-radius: 9px;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
}
.sym .s-badge.zero { background: #cbd2da; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; padding: 10px 14px; overflow-y: auto; }
/* 列向 flex 的子项默认会被压缩: 固定各区块高度, 让 .main 滚动而不是把图表挤成一条线 */
.main > * { flex: 0 0 auto; }

.toolbar { display: flex; align-items: center; gap: 14px; padding-bottom: 8px; }
.cur { display: flex; align-items: baseline; gap: 8px; }
#cur-name { font-size: 15px; font-weight: 700; }
.cur-code { color: var(--muted); font-size: 12px; }
.spacer { flex: 1; }
.ctl { display: flex; align-items: center; gap: 5px; color: #4a5058; }
.ctl select { padding: 3px 6px; border: 1px solid var(--line); border-radius: 5px; background: #fff; }
.btn {
  padding: 5px 12px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
}
.btn:hover { background: #eef2f7; }
.btn:disabled { opacity: 0.5; cursor: default; }

.summary { color: var(--muted); font-size: 12px; padding: 2px 0 8px; }
.summary b { color: var(--text); }

.chart-wrap { position: relative; width: 100%; flex: 0 0 auto; }
.chart {
  width: 100%; height: 620px; min-height: 200px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
}
.chart-loading {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.55);
  backdrop-filter: blur(1px);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.chart-loading.show { display: flex; }
.chart-loading-inner { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: #fff; border: 1px solid var(--line); border-radius: 999px; box-shadow: 0 10px 40px rgba(15,23,42,0.08); }
.chart-spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid #d8dee9; border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
.chart-loading-text { color: #4a5058; font-size: 13px; }
@keyframes spin { to { transform: rotate(360deg); } }
/* 图表高度拖拽条 (双击恢复默认高度) */
.chart-resizer {
  flex: 0 0 12px;
  cursor: row-resize;
  position: relative;
  touch-action: none;
}
.chart-resizer::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 5px;
  width: 56px;
  height: 4px;
  margin-left: -28px;
  border-radius: 2px;
  background: #d5dae1;
}
.chart-resizer:hover::before, .chart-resizer.dragging::before { background: var(--accent); }

.bin-result { font-size: 12px; padding: 8px 0; }
.bin-result .ok { color: var(--down); }
.bin-result .bad { color: var(--error); }
.bin-result table { border-collapse: collapse; margin-top: 4px; }
.bin-result td, .bin-result th { border: 1px solid var(--line); padding: 3px 10px; text-align: left; }

.anom-wrap { margin-top: 14px; }
.anom-wrap .side-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.anom-filters { display: flex; align-items: center; gap: 10px; margin-left: auto; font-weight: 400; font-size: 12px; }
.ctl.small { font-size: 12px; }
.mini { padding: 2px 6px; border: 1px solid var(--line); border-radius: 5px; background: #fff; font-size: 12px; }
.anom-table { max-height: 320px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.anom-table table { width: 100%; border-collapse: collapse; }
.anom-table th, .anom-table td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.anom-table th { position: sticky; top: 0; background: #f0f2f5; font-weight: 600; }
.anom-table tr:last-child td { border-bottom: none; }
.anom-table td.date { font-variant-numeric: tabular-nums; white-space: nowrap; }
.anom-table .empty { color: var(--muted); padding: 14px; text-align: center; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 9px; color: #fff; }
.tag.error { background: var(--error); }
.tag.warn { background: #e08a1e; }
.tag.signal { background: #3b7dd8; }
.tag.signal-warn { background: #9b59b6; }
.tag.info { background: var(--info); }

.bt-wrap { margin-top: 14px; }
.bt-wrap .side-title { font-weight: 600; }
.bt-wrap .side-title .muted { font-weight: 400; font-size: 12px; }
.bt-table { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.bt-table table { width: 100%; border-collapse: collapse; }
.bt-table th, .bt-table td { padding: 6px 10px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); text-align: center; white-space: nowrap; }
.bt-table th:first-child, .bt-table td:first-child { text-align: left; }
.bt-table th:last-child, .bt-table td:last-child { border-right: none; }
.bt-table th { background: #f0f2f5; font-weight: 600; }
.bt-table td b { font-variant-numeric: tabular-nums; }
.bt-table .bt-sub { display: block; color: var(--muted); font-size: 11px; margin-top: 1px; }
.bt-table .bt-good { background: rgba(26,158,92,0.10); color: #157a46; }
.bt-table .bt-bad { background: rgba(217,72,56,0.10); color: #b23a2b; }
.bt-table .bt-empty { color: var(--muted); }
.bt-dir { font-size: 11px; padding: 1px 7px; border-radius: 9px; color: #fff; }
.bt-dir.up { background: var(--error); }
.bt-dir.down { background: #1a9e5c; }

.hold-wrap { margin-top: 14px; }
.hold-wrap .side-title { font-weight: 600; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.hold-wrap .side-title .muted { font-weight: 400; font-size: 12px; }
.hold-table { max-height: 380px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.hold-table table, .hold-detail table { width: 100%; border-collapse: collapse; }
.hold-table th, .hold-table td, .hold-detail th, .hold-detail td {
  padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top;
}
.hold-table th { position: sticky; top: 0; background: #f0f2f5; font-weight: 600; }
.hold-detail th { background: #f0f2f5; font-weight: 600; }
.hold-table tr:last-child td, .hold-detail tr:last-child td { border-bottom: none; }
.hold-table td.num, .hold-detail td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hold-table td.rank { color: var(--muted); }
.hold-table .empty, .hold-detail .empty { color: var(--muted); padding: 14px; text-align: center; }
.hk-name { cursor: pointer; border-bottom: 1px dashed #9db8ef; }
.hk-name:hover { color: var(--accent); }
.hk-name[data-sym] { border-bottom-color: #1a9e5c; }
.htag { font-size: 10px; padding: 0 5px; border-radius: 7px; margin-left: 4px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.htag.org { color: #3b7dd8; border-color: #bcd0f2; }
.htag.person { color: #9b59b6; border-color: #dcc7e8; }
.htag.sp { color: #b23a2b; border-color: #eec4bd; background: #fdf0ee; }
.hdir { font-size: 11px; padding: 1px 7px; border-radius: 9px; color: #fff; background: var(--info); white-space: nowrap; }
.hdir.up { background: var(--error); }
.hdir.down { background: #1a9e5c; }
.hchg { margin-left: 6px; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.hold-detail { margin-top: 10px; overflow-x: auto; }
.hold-dhead { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; font-size: 13px; }
.hold-dhead .muted { font-weight: 400; }
.mini-btn { margin-left: auto; font-size: 12px; padding: 2px 10px; border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; }
.mini-btn:hover { background: #eef2f7; }
.hold-loading { color: var(--muted); font-size: 12px; padding: 10px; }
.hold-note { font-size: 12px; color: var(--muted); padding: 4px 0; }
.hold-note.warn { color: #b23a2b; }
.code { font-size: 12px; color: var(--muted); }
.code.in-pool { color: #1a9e5c; font-weight: 600; }

.muted { color: var(--muted); font-weight: 400; }

.legend { display: flex; gap: 20px; color: var(--muted); font-size: 12px; padding: 10px 2px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; }
.dot-error { background: var(--error); }
.dot-info { background: var(--info); }
.dot-buy { background: #d94838; }
.dot-sell { background: #1a9e5c; }

/* ---------------- 添加股票弹窗 ---------------- */
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: #1d4fd7; }
.btn-primary:disabled { background: #9db8ef; border-color: #9db8ef; }

.hidden { display: none !important; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 30, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 6vh;
  z-index: 100;
}
.modal {
  width: 620px;
  max-width: 94vw;
  background: var(--panel);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  font-weight: 700;
  border-bottom: 1px solid var(--line);
}
.modal-x {
  border: none;
  background: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}
.modal-body { padding: 16px; }

.field-row { display: flex; gap: 8px; }
.field-row input {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
}

.add-results { margin-top: 10px; max-height: 200px; overflow-y: auto; }
.add-results .res {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-bottom: 6px;
  cursor: pointer;
}
.add-results .res:hover { background: #eef2f7; border-color: #bcd3ff; }
.add-results .res .r-name { font-weight: 600; }
.add-results .res .r-meta { color: var(--muted); font-size: 12px; }
.add-results .none { color: var(--muted); padding: 8px 2px; }

.add-form { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
.add-title { font-weight: 600; margin-bottom: 8px; }
.add-form table { border-collapse: collapse; width: 100%; margin-bottom: 10px; }
.add-form td { padding: 4px 6px; }
.add-form td:first-child { color: var(--muted); width: 78px; }
.add-form input {
  width: 100%;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
}
.hint { color: var(--muted); font-size: 12px; margin-left: 10px; }

.add-log {
  margin-top: 12px;
  background: #1c2128;
  color: #d6e0ea;
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 12px;
  border-radius: 8px;
  padding: 10px 12px;
  max-height: 220px;
  overflow-y: auto;
  white-space: pre-wrap;
  display: none;
}
.add-log.show { display: block; }
.add-log .ok { color: #7ee787; }
.add-log .err { color: #ff7b72; }

/* ---------------- 移动端适配 ---------------- */
@media (max-width: 760px) {
  header { padding: 10px 12px; gap: 8px; }
  .brand { font-size: 15px; }
  .brand-sub { display: none; }
  .resizer, .nav-toggle { display: none; }

  .layout { flex-direction: column; height: auto; }
  .sidebar {
    width: 100%;
    flex: none;
    border-right: none;
    border-bottom: 1px solid var(--line);
    max-height: 40vh;
    overflow-y: auto;
  }
  .side-title { cursor: pointer; display: flex; align-items: center; justify-content: space-between; }
  .chev { display: inline-block; transition: transform 0.15s; }
  .sidebar.collapsed .sym-list { display: none; }
  .sidebar.collapsed .chev { transform: rotate(-90deg); }

  .main { overflow: visible; padding: 10px; }
  .toolbar { flex-wrap: wrap; gap: 8px 10px; }
  .spacer { display: none; }
  .cur { width: 100%; }
  .btn { padding: 7px 12px; }
  .ctl select { padding: 6px 8px; }

  .chart { height: 68vh; min-height: 360px; }
  .anom-table { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .anom-table table { min-width: 520px; }
  .legend { flex-wrap: wrap; gap: 6px 16px; }

  .modal { width: 100%; max-width: 100%; border-radius: 0; }
  .modal-backdrop { padding-top: 0; align-items: flex-start; }
  .modal-body { max-height: calc(100vh - 49px); overflow-y: auto; }
  .add-form td:first-child { width: 64px; }
}

/* 矮屏(多为手机横屏): 图表占满可视高度, 避免只剩顶部一截 */
@media (min-width: 761px) and (max-height: 620px) {
  header { padding: 8px 14px; }
  .main { padding: 8px 12px; }
  .chart { height: calc(100vh - 118px); min-height: 220px; }
  .anom-wrap { margin-top: 8px; }
  .anom-table { max-height: 30vh; }
  .legend { padding: 6px 2px; }
}

/* ------------------------------------------------------------ 因子实验室 */
.fact-wrap { margin-top: 18px; }
.fact-status { display: flex; align-items: center; gap: 8px; min-height: 20px; }
.fact-status .chart-spinner { width: 14px; height: 14px; flex: 0 0 auto; }
.fact-wrap .side-title { font-weight: 600; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fact-wrap .side-title .muted { font-weight: 400; font-size: 12px; }
.fact-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 8px 0 6px; }
.fact-expr {
  flex: 1 1 340px;
  min-width: 200px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-family: ui-monospace, Consolas, "Courier New", monospace;
  font-size: 13px;
  color: var(--text);
}
.fact-expr:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12); }
.fact-hint { font-size: 12px; color: var(--muted); line-height: 1.7; margin-bottom: 8px; }
.fact-hint strong { color: #4a5058; font-weight: 600; }
.fact-short {
  margin: 8px 0;
  padding: 9px 12px;
  border: 1px solid #f0d9a8;
  border-left: 4px solid #e08a1e;
  border-radius: 8px;
  background: #fff8e6;
  color: #7a4d00;
  font-size: 12.5px;
  line-height: 1.7;
}
.fact-signal {
  border: 1px solid var(--line);
  border-left: 4px solid var(--info);
  border-radius: 10px;
  background: var(--panel);
  padding: 12px 14px;
  margin: 10px 0;
}
.fact-signal.bullish { border-left-color: var(--up); }
.fact-signal.bearish { border-left-color: var(--down); }
.fact-signal.neutral { border-left-color: var(--info); }
.fs-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fs-badge {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  padding: 2px 12px;
  border-radius: 999px;
  background: var(--info);
}
.fact-signal.bullish .fs-badge { background: var(--up); }
.fact-signal.bearish .fs-badge { background: var(--down); }
.fs-conf {
  font-size: 12px;
  color: #4a5058;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 9px;
}
.fs-meta { font-size: 12px; color: var(--muted); }
.fs-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 8px;
  margin: 10px 0;
}
.fs-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}
.fs-stat span { font-size: 11px; color: var(--muted); }
.fs-stat b { font-size: 14px; font-variant-numeric: tabular-nums; }
.fs-stat b.pos { color: var(--up); }
.fs-stat b.neg { color: var(--down); }
.fs-reasons { margin: 6px 0; padding-left: 18px; font-size: 12.5px; line-height: 1.7; color: #374151; }
.fs-reasons li { margin: 2px 0; }
.fs-invalidate {
  font-size: 12px;
  line-height: 1.6;
  color: #8a5a00;
  background: #fff8e6;
  border: 1px solid #f0d9a8;
  border-radius: 6px;
  padding: 6px 9px;
}
.fs-note { font-size: 11px; color: var(--muted); margin-top: 6px; }
.fact-current {
  border: 1px solid var(--line);
  border-left: 4px solid var(--info);
  border-radius: 8px;
  background: var(--panel);
  padding: 10px 12px;
  margin: 8px 0;
  line-height: 1.75;
}
.fact-current.up { border-left-color: var(--up); }
.fact-current.down { border-left-color: var(--down); }
.fact-current .fc-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; font-weight: 600; }
.fact-current .fc-head .tag { font-weight: 400; }
.fact-ic { display: flex; gap: 18px; flex-wrap: wrap; margin: 6px 0 8px; font-size: 13px; color: #4a5058; }
.fact-ic b { font-variant-numeric: tabular-nums; }
.fact-ic .pos { color: var(--up); }
.fact-ic .neg { color: var(--down); }
.fact-chart {
  width: 100%;
  height: 300px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 8px;
}
.fact-bucket-chart {
  width: 100%;
  height: 220px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 8px;
}
.fact-wrap .bt-table { margin-top: 0; }
.fact-wrap tr.fact-cur-row td { background: #fff7e6; font-weight: 600; }

/* ------------------------------------------------------------ 持仓账本 */
.pos-wrap { margin-top: 18px; }
.pos-wrap .side-title { font-weight: 600; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.pos-wrap .side-title .muted { font-weight: 400; font-size: 12px; }
.pos-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 8px 0 6px; }
.pos-status { display: flex; align-items: center; gap: 7px; min-height: 20px; font-size: 12px; }
.pos-status.busy { color: var(--accent); }
.pos-status .chart-spinner { width: 14px; height: 14px; flex: 0 0 auto; }
.pos-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 8px; margin: 8px 0; }
.pos-sum-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.pos-sum-card > span:first-child { font-size: 11px; color: var(--muted); }
.pos-sum-card > b { font-size: 17px; font-variant-numeric: tabular-nums; }
.pos-sum-card .muted { font-size: 11px; line-height: 1.6; }
.pos-sum-card b.pos { color: var(--up); }
.pos-sum-card b.neg { color: var(--down); }

.pos-alerts { display: flex; flex-direction: column; gap: 6px; margin: 0 0 10px; }
.pos-alert {
  border: 1px solid var(--line);
  border-left: 4px solid var(--info);
  border-radius: 8px;
  background: var(--panel);
  padding: 7px 10px;
  cursor: pointer;
}
.pos-alert.danger { border-left-color: var(--error); background: #fff2f1; }
.pos-alert.warn { border-left-color: #e08a1e; background: #fff8e6; }
.pos-alert.info { border-left-color: #3b7dd8; background: #f3f7ff; }
.pos-alert.ok { border-left-color: var(--down); background: #f1fbf5; cursor: default; }
.pos-alert .pa-title { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.pos-alert .pa-title span { color: var(--muted); font-size: 11px; }
.pos-alert .pa-msg { margin-top: 2px; font-size: 12px; line-height: 1.6; color: #374151; }

.pos-form {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 10px 12px;
  margin: 8px 0 12px;
}
.pos-form-title { font-weight: 600; margin-bottom: 8px; }
.pos-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 8px 12px; }
.pos-field { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--muted); }
.pos-field-wide { grid-column: span 2; }
.pos-field input, .pos-field select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 12.5px;
}
.pos-field input:focus, .pos-field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.10);
}
.pos-settings-fields { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.pos-form-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.pos-hint { font-size: 11px; color: var(--muted); line-height: 1.6; margin-top: 6px; }
.pos-hint strong { color: #4a5058; }

.pos-table { margin-top: 4px; }
.pos-table table { min-width: 980px; }
.pos-table th, .pos-table td { vertical-align: top; }
.pos-table td:nth-child(1), .pos-table td:nth-child(7) { text-align: left; }
.pos-table td:nth-child(7) { min-width: 130px; white-space: normal; }
.pos-row.danger td:first-child { box-shadow: inset 3px 0 0 var(--error); }
.pos-row.warn td:first-child { box-shadow: inset 3px 0 0 #e08a1e; }
.pos-row.info td:first-child { box-shadow: inset 3px 0 0 #3b7dd8; }
.pos-row.pos-flash td { background: #fff7d6; }

.pos-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 9px;
  color: #fff;
  font-size: 11px;
  background: var(--info);
}
.pos-badge.bull { background: var(--up); }
.pos-badge.bear { background: var(--down); }
.pos-badge.neu { background: #8a9099; }
.pos-badge.unk { background: #b8bdc5; }
.pos-alert-cell b { font-size: 12px; }
.pos-alert-cell.danger b { color: var(--error); }
.pos-alert-cell.warn b { color: #b36b00; }
.pos-alert-cell.info b { color: #3b7dd8; }
.pos-alert-cell.ok b { color: var(--down); }

.pos-actions { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; }
.pos-action {
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: #4a5058;
  font-size: 11px;
  cursor: pointer;
}
.pos-action:hover { background: #eef2f7; }
.pos-action.danger { color: var(--error); border-color: #f0c4c1; }
.pos-action.danger:hover { background: #fff2f1; }
.pos-lots { margin-top: 3px; text-align: left; white-space: normal; }
.pos-lots summary { cursor: pointer; color: var(--accent); font-size: 11px; }
.pos-lot {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  max-width: 290px;
  padding: 2px 0;
  border-top: 1px dashed var(--line);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: normal;
}
.pos-lot .muted { font-size: 10px; }
.pos-mini {
  width: 18px;
  height: 18px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--error);
  font-size: 12px;
  line-height: 16px;
  cursor: pointer;
}
.pos-mini:hover { background: #fff2f1; }
.pos-empty { padding: 18px; color: var(--muted); line-height: 1.8; text-align: center; }

@media (max-width: 760px) {
  .pos-summary { grid-template-columns: 1fr 1fr; }
  .pos-form-grid { grid-template-columns: 1fr 1fr; }
  .pos-field-wide { grid-column: 1 / -1; }
  .pos-bar .btn { padding: 5px 9px; font-size: 12px; }
  .pos-status { flex-basis: 100%; }
  .pos-table table { min-width: 880px; }
}
@media (max-width: 480px) {
  .pos-summary { grid-template-columns: 1fr; }
  .pos-form-grid { grid-template-columns: 1fr; }
  .pos-field-wide { grid-column: auto; }
  .pos-actions { flex-wrap: nowrap; }
}

/* ------------------------------------------------------------ 模拟交易（Alpaca Paper） */
.broker-wrap { margin-top: 18px; }
.broker-wrap .side-title { font-weight: 600; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.broker-wrap .side-title .muted { font-weight: 400; font-size: 12px; }
.broker-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 8px 0 6px; }
.broker-account { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin: 6px 0 10px; }
.broker-card { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); padding: 7px 10px; display: flex; flex-direction: column; gap: 2px; }
.broker-card span { font-size: 11px; color: var(--muted); }
.broker-card b { font-variant-numeric: tabular-nums; }
.broker-form { border: 1px solid var(--line); border-radius: 8px; background: #fbfcfe; padding: 10px 12px; }
.broker-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px 10px; }
.broker-field { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--muted); }
.broker-field input, .broker-field select { width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--text); font-size: 12.5px; }
.broker-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.broker-preview { margin-top: 10px; padding: 9px 12px; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px; background: var(--panel); line-height: 1.8; }
.broker-preview.hidden { display: none; }
.broker-lists { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin-top: 12px; }
.broker-list-title { font-weight: 600; margin-bottom: 6px; }
.broker-table { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); overflow-x: auto; }
.broker-table table { width: 100%; border-collapse: collapse; min-width: 240px; }
.broker-table th, .broker-table td { padding: 5px 8px; border-bottom: 1px solid var(--line); text-align: left; font-size: 12px; font-variant-numeric: tabular-nums; }
.broker-table th { background: #f7f8fa; color: #4a5058; font-weight: 600; }
.broker-table td.right, .broker-table th.right { text-align: right; }
.broker-table .empty { padding: 10px; color: var(--muted); text-align: center; }
.broker-note { margin-top: 8px; font-size: 11px; }
@media (max-width: 760px) {
  .broker-grid { grid-template-columns: 1fr 1fr; }
  .broker-lists { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------- 多用户 P0 */
.user-box {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
}
.user-email {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-link { color: var(--accent); text-decoration: none; }
.user-link:hover { text-decoration: underline; }
.etf-entry { font-weight: 600; }
.role-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 999px;
  background: #eef2f7;
  color: #4a5058;
  font-size: 10px;
  line-height: 16px;
}
.role-badge.admin { background: #fff3d6; color: #8a5a00; }

#side-toggle { display: flex; align-items: center; gap: 6px; cursor: pointer; }
#side-toggle .side-manage {
  margin-left: auto;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: #4a5058;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}
#side-toggle .side-manage:hover { background: #eef2f7; }
.sym-main { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sym-del {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #b6bcc5;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  visibility: hidden;
}
.sym:hover .sym-del { visibility: visible; }
.sym-del:hover { background: #fde8e8; color: var(--error); }
.sym-empty { padding: 14px 8px; color: var(--muted); line-height: 2; text-align: center; }

.watch-modal { width: min(620px, calc(100vw - 28px)); }
.watch-hint { padding: 8px 2px; font-size: 12px; }
.watch-list {
  max-height: min(56vh, 520px);
  overflow-y: auto;
  border-top: 1px solid var(--line);
  margin-top: 4px;
}
.watch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 4px;
  border-bottom: 1px solid #f0f2f5;
}
.watch-row .btn.mini { min-width: 52px; }
.btn.danger { color: var(--error); border-color: #f3c1c3; }
.btn.danger:hover { background: #fde8e8; }

/* 登录 / 邀请码 */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at 20% 0%, #e8efff 0, var(--bg) 46%);
}
.auth-card {
  width: min(520px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px 30px 26px;
  box-shadow: 0 18px 50px rgba(31, 35, 41, 0.08);
}
.auth-brand { color: var(--accent); font-weight: 700; font-size: 13px; letter-spacing: 0.04em; }
.auth-card h1 { margin: 8px 0 14px; font-size: 22px; }
.auth-text { color: #4a5058; line-height: 1.8; margin: 0 0 14px; }
.auth-hint { color: var(--muted); font-size: 12px; line-height: 1.7; margin: 14px 0 0; }
.auth-warn {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff7e6;
  color: #8a5a00;
  font-size: 12px;
  line-height: 1.7;
}
.auth-form { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }
.auth-form label { color: #4a5058; font-weight: 600; }
.auth-form input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 16px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: Consolas, "Courier New", monospace;
}
.auth-form input:focus { outline: 2px solid #bcd3ff; border-color: var(--accent); }
.auth-form .btn { margin-top: 6px; padding: 10px 14px; }
.auth-error { color: var(--error); min-height: 18px; margin-top: 10px; font-size: 12px; }
.auth-actions { margin-top: 18px; }

/* 管理后台 */
.admin-body { min-height: 100vh; background: var(--bg); }
.admin-body header { flex-wrap: wrap; }
.admin-back { color: var(--accent); text-decoration: none; font-size: 13px; }
.admin-back:hover { text-decoration: underline; }
.admin-main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.admin-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
}
.admin-card-title { font-weight: 700; font-size: 14px; margin-bottom: 12px; }
.admin-form { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.admin-form label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; }
.admin-form input, .admin-form select {
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
}
.admin-form input { width: 110px; }
.admin-note { color: var(--muted); font-size: 12px; line-height: 1.7; margin-top: 10px; }
.invite-result {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px dashed #bcd3ff;
  border-radius: 10px;
  background: #f7faff;
}
.invite-code { font-size: 20px; font-weight: 700; letter-spacing: 0.08em; color: var(--accent); }
.invite-link { display: flex; gap: 8px; margin-top: 8px; }
.invite-link input {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
}
.admin-table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.admin-table th, .admin-table td { padding: 7px 8px; border-bottom: 1px solid #eef0f3; text-align: left; white-space: nowrap; }
.admin-table th { color: var(--muted); font-weight: 600; background: #fafbfc; }
.admin-table tr:hover td { background: #fafbfc; }
.admin-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.admin-actions .btn.mini { padding: 2px 8px; }
.admin-empty { padding: 16px; text-align: center; color: var(--muted); }
.mono { font-family: Consolas, "Courier New", monospace; }
.settings-card { max-width: 760px; width: 100%; margin: 0 auto; }
.settings-status {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafbfc;
  font-size: 13px;
  line-height: 1.8;
  margin-bottom: 14px;
}
.settings-form { display: flex; flex-direction: column; gap: 12px; }
.settings-form label { display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: 12px; }
.settings-form input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
  color: var(--text);
}
.settings-form input[readonly] { background: #f5f6f8; color: var(--muted); }
.settings-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.settings-message { min-height: 18px; font-size: 12px; line-height: 1.7; }
.settings-message.ok { color: #167a45; }
.settings-message.error { color: var(--error); }
.status-pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; }
.status-pill.ok { background: #e7f7ee; color: #167a45; }
.status-pill.muted { background: #eef0f3; color: #6b7280; }
.status-pill.warn { background: #fff3d6; color: #8a5a00; }

@media (max-width: 760px) {
  .user-email { max-width: 120px; }
  .brand-sub { display: none; }
  .admin-main { padding: 12px; }
  .admin-form { align-items: stretch; }
}
