/* 双色球数据分析台 · 设计系统
   取舍：数据密集型工具用浅色底、克制的强调色；所有图表用 SVG 自绘，
   不引外部图表库——断网环境下页面必须完整可用。 */

:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #16202b;
  --ink-2: #4a5a6a;
  --ink-3: #8794a3;
  --line: #e3e8ee;
  --line-strong: #cfd8e3;
  --brand: #1a3a6b;
  --brand-soft: #eaf0f9;
  --red: #d93b30;
  --red-soft: #fdeceb;
  --blue: #1a73e8;
  --blue-soft: #e8f1fe;
  --green: #157f4b;
  --amber: #b26a00;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(22, 32, 43, .06), 0 8px 24px -12px rgba(22, 32, 43, .12);
  --mono: "SF Mono", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------------------------- 顶栏 */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  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; }

.logo {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), #2d5fa8);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: .5px;
  flex: none;
}

.brand h1 { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: .2px; }
.brand .sub { margin: 1px 0 0; font-size: 12px; color: var(--ink-3); }

.topmeta { display: flex; align-items: center; gap: 10px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 12px;
  font-weight: 550;
  white-space: nowrap;
}
.pill.warn { background: #fdf3e3; color: var(--amber); }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------------------------------------------------------------- 标签页 */
.tabs {
  display: flex;
  gap: 2px;
  padding: 0 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tabs button {
  appearance: none;
  border: 0;
  background: none;
  padding: 11px 15px 10px;
  font-size: 14px;
  font-family: inherit;
  color: var(--ink-2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color .12s;
}
.tabs button:hover { color: var(--ink); }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

/* ---------------------------------------------------------------- 布局 */
main { padding: 22px 24px 60px; max-width: 1240px; margin: 0 auto; }

.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 900px) {
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  main { padding: 16px 14px 48px; }
  .topbar { padding: 12px 14px; }
  .tabs { padding: 0 14px; }
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.card h2 {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: .2px;
}
.card .desc { margin: 0 0 14px; font-size: 12.5px; color: var(--ink-3); line-height: 1.55; }
.card.flush { padding-bottom: 8px; }

.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- 指标卡 */
.stat { padding: 15px 17px; }
.stat .k { font-size: 12px; color: var(--ink-3); margin-bottom: 5px; }
.stat .v {
  font-size: 25px;
  font-weight: 650;
  letter-spacing: -.4px;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.stat .n { font-size: 11.5px; color: var(--ink-3); margin-top: 4px; }
.stat .v.good { color: var(--green); }
.stat .v.warn { color: var(--amber); }
.stat .v.blue { color: var(--brand); }

/* ---------------------------------------------------------------- 号码球 */
.ball {
  display: inline-grid;
  place-items: center;
  width: 32px; height: 32px;
  border-radius: 50%;
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: radial-gradient(circle at 32% 28%, #f0705f, var(--red) 62%);
  box-shadow: inset 0 -2px 4px rgba(0, 0, 0, .18), 0 1px 2px rgba(0, 0, 0, .1);
  flex: none;
}
.ball.blue { background: radial-gradient(circle at 32% 28%, #62a0f5, var(--blue) 62%); }
.ball.sm { width: 26px; height: 26px; font-size: 12px; }
.ball.lg { width: 42px; height: 42px; font-size: 17px; }
.balls { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }

/* ---------------------------------------------------------------- 表格 */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  font-weight: 600;
  font-size: 11.5px;
  letter-spacing: .3px;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}
td { padding: 8px 10px; border-bottom: 1px solid var(--line); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfc; }
td.num, th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; margin: 0 -4px; }

.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.7;
}
.tag.s { background: #fff2d6; color: #8a5a00; }
.tag.a { background: var(--blue-soft); color: var(--blue); }
.tag.b { background: #eef1f4; color: var(--ink-2); }
.tag.c { background: #f2f4f6; color: var(--ink-3); }

/* ---------------------------------------------------------------- 表单 */
label.field { display: block; margin-bottom: 12px; }
label.field .lab {
  display: block;
  font-size: 12px;
  color: var(--ink-2);
  margin-bottom: 5px;
  font-weight: 550;
}
input[type="text"], input[type="number"], select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  font-size: 13px;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(26, 58, 107, .1);
}

.btn {
  appearance: none;
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
  padding: 8px 16px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 550;
  font-family: inherit;
  cursor: pointer;
  transition: filter .12s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.1); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--ink-2); border-color: var(--line-strong); }
.btn.ghost:hover { border-color: var(--brand); color: var(--brand); filter: none; }
.btn.sm { padding: 5px 11px; font-size: 12px; }

/* ---------------------------------------------------------------- 提示条 */
.note {
  padding: 11px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.6;
  border-left: 3px solid var(--brand);
  background: var(--brand-soft);
  color: #23405f;
}
.note.warn { background: #fdf6e9; border-left-color: var(--amber); color: #6d4a00; }
.note.red { background: var(--red-soft); border-left-color: var(--red); color: #7d211a; }
.note.good { background: #eaf6ef; border-left-color: var(--green); color: #10573a; }
.note b { font-weight: 650; }

/* ---------------------------------------------------------------- 图表 */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); margin-top: 8px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }

.hm-scroll { overflow-x: auto; padding-bottom: 6px; }
.hm-scroll svg { display: block; }

/* ---------------------------------------------------------------- 排行榜 */
.rank-no {
  display: inline-grid;
  place-items: center;
  width: 22px; height: 22px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  background: #f0f2f5;
  color: var(--ink-2);
}
.rank-no.top { background: var(--brand); color: #fff; }
.me-row { background: #f7fbff; }
.me-row td { border-bottom-color: #d8e6f8; }

/* ---------------------------------------------------------------- 其他 */
.countdown {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 650;
  color: var(--brand);
}

.empty {
  padding: 34px 16px;
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
}

.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

footer {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 24px 40px;
  font-size: 11.5px;
  color: var(--ink-3);
  line-height: 1.7;
}
footer b { color: var(--ink-2); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(12px);
  background: #16202b;
  color: #fff;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 100;
  max-width: 90vw;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: #a3281e; }

/* ---------------------------------------------------------------- AI 对话 */
.chat-box {
  max-height: 460px;
  overflow-y: auto;
  padding: 4px 2px 8px;
  scroll-behavior: smooth;
}
.msg { display: flex; gap: 10px; margin-bottom: 14px; align-items: flex-start; flex-wrap: wrap; }
/* 折叠块/脚注/元信息是追加到 .msg 上的附加节点，必须独占一行并与正文左对齐，
   否则会被 flex 排到正文右侧 */
.msg .evidence, .msg .footer-note, .msg > .note, .msg > .small {
  flex-basis: 100%;
  width: 100%;
  margin-left: 36px;
  box-sizing: border-box;
}
.msg .who {
  flex: none;
  width: 26px; height: 26px;
  border-radius: 8px;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700;
  color: #fff;
  background: var(--brand);
  margin-top: 2px;
}
.msg.user .who { background: #5f6b7a; }
.msg .body {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  line-height: 1.72;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.user .body {
  background: var(--brand-soft);
  border-radius: 8px;
  padding: 9px 12px;
  color: #23405f;
}
.msg .body strong { font-weight: 650; }
.msg.assistant .body::after {
  content: "";
}
.msg.typing .body::after {
  content: "▍";
  color: var(--brand);
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.evidence {
  margin-top: 10px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 9px 12px;
  background: #fbfcfd;
  font-size: 12px;
  color: var(--ink-2);
}
.evidence > summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--ink-2);
  list-style: none;
  user-select: none;
}
.evidence > summary::-webkit-details-marker { display: none; }
.evidence > summary::before { content: "▸ "; color: var(--ink-3); }
.evidence[open] > summary::before { content: "▾ "; }
.evidence ul { margin: 8px 0 0; padding-left: 18px; }
.evidence li { margin-bottom: 4px; line-height: 1.6; }
.evidence .src { color: var(--ink-3); font-size: 11px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 2px 0 12px; }
.chip {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink-2);
  font-size: 12px;
  font-family: inherit;
  padding: 5px 11px;
  border-radius: 999px;
  cursor: pointer;
  transition: all .12s;
}
.chip:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }

.chat-input { display: flex; gap: 8px; align-items: flex-end; }
.chat-input textarea {
  flex: 1;
  min-height: 42px;
  max-height: 120px;
  resize: vertical;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink);
  background: #fff;
}
.chat-input textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(26, 58, 107, .1);
}
.footer-note {
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px dashed var(--line);
  font-size: 11.5px;
  color: var(--ink-3);
  line-height: 1.6;
}
.mode-tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
  background: #eef1f4; color: var(--ink-2);
}
.mode-tag.llm { background: #eaf6ef; color: var(--green); }

/* ---------------------------------------------------------------- 预测页 */
.strat-row {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px; margin-bottom: 12px;
}
.strat {
  text-align: left; padding: 11px 12px; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); transition: border-color .15s, box-shadow .15s;
  font-family: inherit; color: inherit;
}
.strat:hover { border-color: var(--line-strong); }
.strat.on { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(26, 58, 107, .08); }
.strat .n { font-weight: 650; font-size: 13.5px; display: flex; align-items: center; gap: 6px; }
.strat .s { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; line-height: 1.45; }
.strat .top { display: flex; gap: 3px; margin-top: 8px; }
.strat .top i {
  width: 16px; height: 16px; border-radius: 50%; font-style: normal;
  font-size: 9px; display: grid; place-items: center; color: #fff;
  background: var(--red); font-family: var(--mono);
}
@media (max-width: 980px) { .strat-row { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 620px) { .strat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.pick-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.pick-row:last-child { border-bottom: none; }
.crowd { font-size: 11px; padding: 1px 7px; border-radius: 5px; background: #eaf6ef; color: #10603f; }
.crowd.mid { background: #fdf3e3; color: #8a5a00; }
.crowd.high { background: var(--red-soft); color: #7d211a; }

.score-box { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px 14px; }
.score-item { display: flex; align-items: center; gap: 7px; font-size: 12px; }
.score-item .num {
  width: 22px; height: 18px; border-radius: 4px; text-align: center;
  font-family: var(--mono); font-size: 11px; line-height: 18px;
  background: #eef1f4; color: var(--ink-2); flex: none;
}
.score-item.hot .num { background: var(--red); color: #fff; }
.score-item .bar { flex: 1; height: 7px; border-radius: 4px; background: #eef1f4; overflow: hidden; }
.score-item .bar i { display: block; height: 100%; background: #c3cedb; border-radius: 4px; }
.score-item.hot .bar i { background: var(--red); }
.score-item.cold .num { color: var(--ink-3); }
@media (max-width: 900px) { .score-box { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.mini-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.mini-table th, .mini-table td { padding: 8px 9px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.mini-table th { font-size: 11.5px; color: var(--ink-3); font-weight: 600; background: #fafbfc; }
.mini-table td.mono, .mini-table th.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.mini-table tr.on td { background: #f7f9fc; }
