:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --line: #e6e8eb;
  --text: #1f2329;
  --muted: #8a9099;
  --up: #d9304a;   /* 涨 → 红 */
  --down: #0a9b53; /* 跌 → 绿 */
  --flat: #6b7280;
  --accent: #2f6fed;
  --port: #e8632a;
  --bench: #6b7280;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}
.wrap { max-width: 1680px; margin: 0 auto; padding: 18px 20px 40px; }

/* header */
.hd { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.hd-left { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 40px; height: 40px; flex: 0 0 40px; border-radius: 10px;
  background: linear-gradient(135deg, #2f6fed 0%, #7a4ff2 100%);
  color: #fff; font-size: 22px; font-weight: 700; letter-spacing: 0;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(47,111,237,.32); user-select: none;
}
.hd h1 { margin: 0; font-size: 21px; letter-spacing: .5px; }
.sub { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; }
.hd-right { display: flex; align-items: center; gap: 12px; font-size: 12.5px; color: var(--muted); }
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 5px 14px; border-radius: 6px; cursor: pointer; font-size: 13px;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.add { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.add:hover { opacity: .88; color: #fff; }
.auto { display: flex; align-items: center; gap: 4px; cursor: pointer; }

/* alerts */
.alerts {
  display: none; background: #fff8f8; border: 1px solid #f3c9c9; border-left: 4px solid var(--up);
  border-radius: 8px; padding: 10px 14px; margin-bottom: 14px;
}
.al-head { font-size: 12.5px; font-weight: 600; color: var(--up); margin-bottom: 6px; letter-spacing: .5px; }
.al-list { display: flex; flex-direction: column; gap: 5px; }
.al-item { font-size: 13px; padding: 5px 10px; border-radius: 5px; background: #fff; border: 1px solid #f0dede; }
.al-item b { font-weight: 600; }
.al-today { border-left: 3px solid var(--up); }
.al-soon  { border-left: 3px solid #e8a33c; }
.al-up    { border-left: 3px solid var(--up); }
.al-down  { border-left: 3px solid var(--down); background: #f4fbf7; border-color: #c9e8d6; }
.al-up b { color: var(--up); }
.al-down b { color: var(--down); }
.al-today b { color: var(--up); }
.al-soon b { color: #c47f1a; }

/* 仓位控件：标签 + 输入框 + 百分号 */
.wt-box { display: inline-flex; align-items: center; gap: 6px; }
.wt-lab { font-size: 12.5px; color: var(--muted); }
.wt-pct { font-size: 13px; color: var(--muted); }

/* 可编辑单元格（调入价 / 仓位） */
td.ed, td.ed-w { cursor: pointer; position: relative; }
td.ed:hover, td.ed-w:hover { background: #f2f7ff; }
td.ed:hover::after, td.ed-w:hover::after {
  content: '✎'; position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  color: var(--accent); font-size: 11px;
}
td.ed input {
  width: 74px; padding: 2px 4px; font-size: 13px; text-align: right;
  border: 1px solid var(--accent); border-radius: 4px; font-variant-numeric: tabular-nums;
}

/* 剩余仓位 */
.remain {
  margin-left: 10px; font-size: 12.5px; font-weight: 500; color: var(--muted);
  background: #f2f4f7; border-radius: 4px; padding: 2px 8px; vertical-align: 2px;
}
.remain.rm-has { color: #b06a2c; background: #fdf3e6; }
.remain.rm-metric { color: #6d3fd4; background: #f3eeff; cursor: pointer; }
.remain.rm-metric:hover { background: #e9dffc; }

/* 平均指标历史走势弹窗 */
.mpop {
  position: fixed; display: none; background: #fff; border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.12); padding: 10px 12px 8px;
  z-index: 98; font-size: 12px; color: var(--text); width: 264px;
}
.mp-title { font-size: 12.5px; font-weight: 600; margin-bottom: 4px; }
.mp-cur { font-weight: 500; color: #6d3fd4; margin-left: 6px; font-variant-numeric: tabular-nums; }
.mp-svg { width: 100%; height: auto; display: block; }
.mp-note { font-size: 11px; color: var(--muted); margin-top: 4px; }
.mp-empty { font-size: 12px; color: var(--muted); padding: 16px 0; text-align: center; }

/* badges */
.badge { display: inline-block; font-size: 11px; padding: 0 5px; border-radius: 3px; margin-left: 3px; line-height: 16px; vertical-align: 1px; }
.b-today { background: var(--up); color: #fff; }
.b-soon  { background: #fdf0dc; color: #c47f1a; border: 1px solid #f0d3a4; }
.b-lim-up { background: var(--up); color: #fff; }
.b-lim-down { background: var(--down); color: #fff; }
.dim { color: #b6bbc2; }

/* cards */
.cards { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 16px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 16px; position: relative; box-shadow: 0 1px 2px rgba(0,0,0,.03);
}
.ct { font-size: 12.5px; color: var(--muted); }
.cv { font-size: 24px; font-weight: 600; margin-top: 6px; font-variant-numeric: tabular-nums; }
.cs { position: absolute; top: 10px; right: 12px; font-size: 11px; color: var(--muted);
      background: #f0f2f5; border-radius: 4px; padding: 1px 6px; }
@media (max-width: 1200px) { .cards { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px)  { .cards { grid-template-columns: repeat(2, 1fr); } }

/* charts */
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 16px; }
@media (max-width: 980px) { .charts { grid-template-columns: 1fr; } }
.chart-box { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.ch-hd { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.ch-hd h2 { margin: 0; font-size: 15px; font-weight: 600; }
.mdd { font-size: 12.5px; color: var(--down); font-variant-numeric: tabular-nums; }
.chart { width: 100%; }
.chart svg { width: 100%; height: auto; display: block; }

/* tables */
.tbl-sec { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 16px; }
.th-hd { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.th-hd h2 { margin: 0; font-size: 15px; font-weight: 600; }
.add-form { display: flex; align-items: center; gap: 8px; position: relative; }
.add-form input[type=text] { width: 210px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; }
.add-form input[type=number] { width: 62px; padding: 5px 6px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; }
.sugg { position: absolute; top: 34px; left: 0; width: 260px; background: #fff; border: 1px solid var(--line);
        border-radius: 6px; box-shadow: 0 4px 14px rgba(0,0,0,.08); z-index: 20; display: none; max-height: 220px; overflow: auto; }
.sugg div { padding: 6px 10px; cursor: pointer; font-size: 13px; }
.sugg div:hover { background: #f0f4ff; }
.tbl-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; white-space: nowrap; }
th, td { padding: 8px 10px; text-align: right; border-bottom: 1px solid #f0f1f3; font-variant-numeric: tabular-nums; }
th { color: var(--muted); font-weight: 500; background: #fafbfc; position: sticky; top: 0; }
th:nth-child(-n+2), td:nth-child(-n+2) { text-align: left; }
td.name { font-weight: 500; }
td .code { color: var(--muted); font-size: 11.5px; margin-left: 4px; }
.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--flat); }
td.op button { border: none; background: none; color: var(--accent); cursor: pointer; font-size: 12.5px; padding: 0; }
td.op button:hover { text-decoration: underline; }
.empty { text-align: center; color: var(--muted); padding: 22px 0; }

.ft { color: var(--muted); font-size: 12px; margin-top: 6px; }
.ft p { margin: 4px 0; }
.ft .note { color: #b06a2c; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%);
  background: rgba(31,35,41,.92); color: #fff; padding: 9px 18px; border-radius: 6px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 99;
}
.toast.show { opacity: 1; }
