:root {
  --bg: #0d1117;
  --bg-2: #161b22;
  --bg-3: #1c2230;
  --line: #2a3140;
  --text: #e6edf3;
  --text-dim: #9aa7b4;
  --accent: #3b82f6;
  --accent-2: #22d3ee;
  --up: #ef4444;     /* 涨=红（A股惯例） */
  --down: #22c55e;   /* 跌=绿 */
  --warn: #f59e0b;
  --radius: 12px;
  --shadow: 0 6px 24px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 600px at 80% -10%, #15233b 0%, var(--bg) 55%);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100dvh;
}

/* 顶栏 */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(13,17,23,.7);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center;
  font-size: 22px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: var(--shadow);
}
.topbar h1 { font-size: 18px; margin: 0; letter-spacing: .5px; }
.topbar .sub { margin: 2px 0 0; color: var(--text-dim); font-size: 12px; }
.top-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.mstatus { color: var(--text-dim); font-size: 12px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 20px; }

/* 大盘指数芯片 */
.index-chips { display: flex; gap: 8px; }
.idx-chip {
  display: inline-flex; align-items: baseline; gap: 6px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 18px;
  padding: 4px 10px; font-size: 11px; color: var(--text-dim); white-space: nowrap;
}
.idx-chip b { color: var(--text); font-weight: 600; }
.idx-chip em { font-style: normal; color: var(--text); }
.idx-chip i { font-style: normal; font-weight: 700; }

/* 布局 */
.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 18px;
  padding: 18px 22px;
  align-items: start;
}
.panel {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.panel h2 { font-size: 15px; margin: 0 0 14px; }
.panel h3 { font-size: 13px; color: var(--text-dim); margin: 16px 0 8px; }

/* 表单 */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; margin-bottom: 6px; color: var(--text-dim); font-size: 12px; }
select, input[type="number"] {
  width: 100%; background: var(--bg-3); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px;
  font-size: 13px; outline: none;
}
select:focus, input:focus { border-color: var(--accent); }

.weights .wrow { margin-bottom: 10px; }
.weights label { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-dim); margin-bottom: 4px; }
.weights label b { color: var(--accent-2); }
input[type="range"] { width: 100%; accent-color: var(--accent); }

.filters .check { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-dim); margin-bottom: 8px; }
.filters .num { width: 64px; padding: 5px 6px; }
input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; }

/* 按钮 */
.btn {
  cursor: pointer; border: none; border-radius: 9px; padding: 10px 16px;
  font-size: 13px; font-weight: 600; transition: transform .06s, filter .15s;
}
.btn:active { transform: translateY(1px); }
.btn.primary { width: 100%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; margin-top: 6px; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: var(--bg-3); color: var(--text); border: 1px solid var(--line); }
.btn.ghost:hover { border-color: var(--accent); }
.hint { font-size: 11px; color: var(--text-dim); margin-top: 10px; }

/* 结果表 */
.result-head { display: flex; align-items: baseline; justify-content: space-between; }
.meta { font-size: 12px; color: var(--text-dim); }
.table-wrap { overflow-x: auto; margin-top: 6px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: right; padding: 10px 8px; color: var(--text-dim);
  font-weight: 600; border-bottom: 1px solid var(--line); white-space: nowrap;
}
thead th:nth-child(2) { text-align: left; }
thead th.sortable { cursor: pointer; user-select: none; transition: color .12s; }
thead th.sortable:hover { color: var(--text); }
thead th.sorted { color: var(--accent-2); }
.arr { font-size: 10px; opacity: .75; margin-left: 2px; }
tbody td { padding: 11px 8px; text-align: right; border-bottom: 1px solid rgba(42,49,64,.5); white-space: nowrap; }
tbody td:nth-child(2) { text-align: left; }
tbody tr:hover { background: rgba(59,130,246,.07); }
.empty { text-align: center; color: var(--text-dim); padding: 28px 0; }
.name-cell b { font-size: 13px; }
.name-cell span { display: block; color: var(--text-dim); font-size: 11px; }

.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--text-dim); }

.score-pill {
  display: inline-block; min-width: 38px; padding: 3px 8px; border-radius: 7px;
  font-weight: 700; font-size: 12px;
}
.score-pill.s-high { background: rgba(239,68,68,.16); color: #ff8585; }
.score-pill.s-mid  { background: rgba(245,158,11,.16); color: #ffc861; }
.score-pill.s-low  { background: rgba(154,167,180,.16); color: #aab6c2; }

.mini-pill { display: inline-block; min-width: 30px; padding: 2px 6px; border-radius: 6px; font-size: 11px; font-weight: 600; }
.mini-pill.h { background: rgba(239,68,68,.14); color: #ff8585; }
.mini-pill.m { background: rgba(245,158,11,.14); color: #ffc861; }
.mini-pill.l { background: rgba(154,167,180,.14); color: #aab6c2; }

.link-btn { color: var(--accent-2); cursor: pointer; text-decoration: none; font-weight: 600; }
.link-btn:hover { text-decoration: underline; }

.disclaimer { margin-top: 14px; font-size: 11px; color: var(--text-dim); border-top: 1px dashed var(--line); padding-top: 10px; }

/* 抽屉 */
.drawer { position: fixed; inset: 0; z-index: 40; }
.drawer.hidden { display: none; }
.drawer-mask { position: absolute; inset: 0; background: rgba(0,0,0,.55); }
.drawer-panel {
  position: absolute; right: 0; top: 0; bottom: 0; width: min(960px, 94vw);
  background: var(--bg); border-left: 1px solid var(--line);
  overflow-y: auto; padding: 20px 24px; box-shadow: -8px 0 30px rgba(0,0,0,.5);
  animation: slideIn .22s ease;
}
@keyframes slideIn { from { transform: translateX(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; }
.drawer-head h2 { margin: 0; font-size: 20px; }
.drawer-head .code { color: var(--text-dim); font-size: 13px; }

.score-cards { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin: 16px 0; }
.sc-card { background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; text-align: center; }
.sc-card .label { font-size: 11px; color: var(--text-dim); }
.sc-card .val { font-size: 26px; font-weight: 800; margin: 6px 0 2px; }
.sc-card .bar { height: 6px; border-radius: 4px; background: var(--bg-3); overflow: hidden; }
.sc-card .bar > i { display: block; height: 100%; border-radius: 4px; }

.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.chart-box { background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.chart-box h3 { margin: 0 0 8px; font-size: 13px; color: var(--text); }
.chart { width: 100%; height: 320px; }

.indicators { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.tag { background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 12px; color: var(--text-dim); }
.tag b { color: var(--text); }

.commentary { background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.commentary h3 { margin: 0 0 10px; }
.comment { font-size: 13px; line-height: 1.8; color: var(--text); }
.comment .blk { margin-bottom: 10px; }
.comment .blk b { color: var(--accent-2); }

.loading { color: var(--text-dim); padding: 20px; text-align: center; }
.err { color: var(--up); }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .charts { grid-template-columns: 1fr; }
  .score-cards { grid-template-columns: repeat(2, 1fr); }
}
