:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --ink: #1c2430;
  --muted: #728094;
  --line: #e6eaf0;
  --red: #d92b2b;
  --red-soft: #fff0f0;
  --green: #128a5a;
  --blue: #2a5bd7;
  --blue-soft: #eef3ff;
  --shadow: 0 2px 12px rgba(25, 42, 70, 0.05);
}

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app { max-width: 1400px; margin: 0 auto; padding: 18px 20px 36px; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 16px 20px; box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 13px; }
.logo {
  width: 42px; height: 42px; display: grid; place-items: center;
  border-radius: 12px; background: var(--red); color: #fff;
  font-size: 21px; font-weight: 700;
}
.topbar h1 { margin: 0; font-size: 20px; letter-spacing: .5px; }
.subtitle { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.status-area { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.chip-date, .chip-live {
  display: flex; align-items: center; gap: 8px;
  background: #f8fafc; border: 1px solid var(--line);
  border-radius: 9px; padding: 8px 12px; font-size: 12px;
}
.chip-date span:first-child { color: var(--muted); }
.chip-date strong { font-size: 14px; font-variant-numeric: tabular-nums; }
.badge { padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge.live { background: var(--red-soft); color: var(--red); }
.badge.past { background: #eef1f5; color: var(--muted); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #2fb37a; }

/* ---------- 概览 ---------- */
.overview { margin-top: 14px; }
.metric-grid {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px;
}
.metric {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 15px; box-shadow: var(--shadow);
}
.metric .label { color: var(--muted); font-size: 12px; }
.metric .value { margin-top: 3px; font-size: 24px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.metric .hint { color: var(--muted); font-size: 11px; margin-top: 2px; }
.metric.accent .value { color: var(--red); }
.metric.green .value { color: var(--green); }

.dist-fold {
  margin-top: 10px; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow);
}
.dist-fold summary {
  padding: 10px 15px; cursor: pointer; font-size: 12px; color: var(--muted);
  list-style: none; display: flex; justify-content: space-between;
}
.dist-fold summary::-webkit-details-marker { display: none; }
.dist-fold[open] summary { border-bottom: 1px solid var(--line); }
.dist-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; padding: 14px 16px; }
.dist-card h3 { margin: 0 0 9px; font-size: 12px; }
.dist-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 11px; }
.dist-row .key { width: 66px; flex: none; color: var(--muted); }
.dist-row .track { flex: 1; height: 7px; border-radius: 999px; background: #eef1f5; overflow: hidden; }
.dist-row .fill { display: block; height: 100%; border-radius: 999px; background: var(--red); }
.dist-row.blue .fill { background: var(--blue); }
.dist-row .val { width: 30px; flex: none; text-align: right; font-variant-numeric: tabular-nums; }
.dist-empty { color: var(--muted); font-size: 12px; }

/* ---------- 看板 ---------- */
.board {
  margin-top: 16px; background: var(--card);
  border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); overflow: hidden;
}
.board-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; padding: 0 16px;
  border-bottom: 1px solid var(--line);
}
.tabs { display: flex; gap: 4px; }
.tab {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  padding: 14px 14px 12px; font-size: 15px; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab.active { color: var(--red); border-bottom-color: var(--red); }
.tab span { font-size: 11px; font-weight: 400; }
.tools { display: flex; align-items: center; gap: 7px; padding: 7px 0; }
.tools input, .tools select, .dir-btn {
  height: 32px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--ink); font-size: 12px;
  padding: 0 9px; outline: none;
}
.tools input { width: 200px; }
.tools input:focus, .tools select:focus { border-color: #9db4e8; }
.dir-btn { cursor: pointer; color: var(--blue); background: var(--blue-soft); border-color: #d8e2fb; white-space: nowrap; }

.filters { display: flex; gap: 7px; flex-wrap: wrap; padding: 12px 16px 8px; }
.chip {
  appearance: none; border: 1px solid var(--line); background: #fff;
  color: var(--muted); border-radius: 999px; padding: 5px 12px;
  font-size: 12px; cursor: pointer; white-space: nowrap;
}
.chip:hover { border-color: #cbd4e2; color: var(--ink); }
.chip.active { background: var(--red-soft); border-color: #f5c7c7; color: var(--red); font-weight: 600; }
.hint {
  margin: 0 16px 10px; padding: 8px 11px; border-radius: 8px;
  background: var(--blue-soft); color: #37508b; font-size: 11px;
}
.strategy-note {
  margin: 0 16px 8px; padding: 9px 11px; border-radius: 8px;
  background: #f8fafc; border: 1px solid var(--line);
  font-size: 11px; color: #4a5768; line-height: 1.7;
}
.strategy-note strong { color: var(--ink); }
.risk-disclaimer {
  margin: 0 16px 12px; padding: 9px 11px; border-radius: 8px;
  background: #fff8f0; border: 1px solid #f4dcc2;
  font-size: 11px; color: #8a5a22; line-height: 1.7;
}
.score-badge {
  display: inline-block; min-width: 42px; text-align: center;
  padding: 3px 8px; border-radius: 7px; font-weight: 700;
  background: var(--red-soft); color: var(--red);
}
.score-badge.mid { background: #fff5e6; color: #b46a00; }
.score-badge.low { background: #eef1f5; color: var(--muted); }
.risk-pill { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; }
.risk-pill.low { background: #eaf6f0; color: #128a5a; }
.risk-pill.mid { background: var(--blue-soft); color: var(--blue); }
.risk-pill.high { background: #fff5e6; color: #b46a00; }
.risk-pill.extreme { background: var(--red-soft); color: var(--red); }
.reason-list { margin: 0; padding-left: 15px; font-size: 11px; line-height: 1.55; white-space: normal; max-width: 420px; }
.reason-list li { margin-bottom: 2px; }
.invalidation { white-space: normal; font-size: 11px; color: #8a5a22; max-width: 260px; }

/* ---------- 可排序列表 ---------- */
.list-shell { overflow-x: auto; }
.list-head, .row {
  display: grid; align-items: center; gap: 0;
  grid-template-columns: var(--cols);
  min-width: var(--minw, 900px);
}
.list-head {
  position: sticky; top: 0; z-index: 2;
  background: #f8fafc; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.col {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  text-align: left; padding: 10px 12px; font-size: 12px; font-weight: 600;
  color: var(--muted); white-space: nowrap; font-family: inherit;
}
.col.sortable:hover { color: var(--ink); }
.col.active-sort { color: var(--red); }
.col .arrow { margin-left: 3px; font-size: 10px; opacity: .45; }
.col.active-sort .arrow { opacity: 1; }
.col.plain { cursor: default; }
.rows .row {
  border-bottom: 1px solid #f0f2f6; padding: 9px 0; font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.rows .row:last-child { border-bottom: 0; }
.rows .row:hover { background: #fafbfe; }
.cell { padding: 3px 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stock-name { display: block; font-weight: 600; font-size: 13px; }
.stock-code { display: block; color: var(--muted); font-size: 11px; }
.up { color: var(--red) !important; font-weight: 600; }
.down { color: var(--green) !important; font-weight: 600; }
.pill {
  display: inline-block; padding: 2px 8px; border-radius: 6px;
  font-size: 11px; font-weight: 600; background: var(--red-soft); color: var(--red);
}
.pill.gray { background: #f1f3f7; color: var(--muted); }
.pill.blue { background: var(--blue-soft); color: var(--blue); }
.pill.combo { background: #fff5e6; color: #b46a00; }
.board-tag { color: #3d4a5c; }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }

/* ---------- 页脚 ---------- */
.footer {
  margin-top: 18px; padding: 12px 4px 0;
  border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; line-height: 1.8;
}
.footer a { color: var(--blue); text-decoration: none; }
.footer a:hover { text-decoration: underline; }
.disclaimer { color: #8b95a5; margin-top: 4px; }

/* ---------- 手机 ---------- */
@media (max-width: 1000px) {
  .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dist-grid { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .app { padding: 12px 10px 26px; }
  .topbar { padding: 13px; }
  .logo { width: 36px; height: 36px; font-size: 18px; }
  .topbar h1 { font-size: 17px; }
  .subtitle { font-size: 10px; }
  .status-area { width: 100%; }
  .chip-date, .chip-live { flex: 1; justify-content: center; font-size: 11px; padding: 7px 8px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .metric { padding: 10px 12px; }
  .metric .value { font-size: 21px; }
  .board-bar { padding: 0 10px; }
  .tab { flex: 1; padding: 12px 6px 10px; }
  .tools { width: 100%; padding-bottom: 9px; }
  .tools input { flex: 1; width: auto; min-width: 0; }
  .filters { flex-wrap: nowrap; overflow-x: auto; padding: 10px 10px 6px; }
  .hint { margin: 0 10px 10px; font-size: 10px; }

  .list-shell { overflow: visible; }
  .list-head { display: none; }
  .rows .row {
    display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px;
    margin: 0 10px 10px; padding: 11px 12px;
    border: 1px solid var(--line); border-radius: 11px; background: #fff;
    box-shadow: var(--shadow); min-width: 0;
  }
  .rows .cell {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px; padding: 4px 0; white-space: normal; text-align: right;
  }
  .rows .cell::before {
    content: attr(data-label); color: var(--muted); font-size: 11px;
    flex: none; font-weight: 400;
  }
  .rows .cell:first-child {
    grid-column: 1 / -1; display: block; text-align: left;
    border-bottom: 1px solid #f0f2f6; padding-bottom: 7px; margin-bottom: 3px;
  }
  .rows .cell:first-child::before { display: none; }
  .stock-name { font-size: 15px; }
}
