/* ── LIGHT theme (default) ── */
:root {
  /* Core surfaces */
  --bg:          #f5f7fa;
  --surface:     #ffffff;
  --surface-2:   #f0f3f8;
  --surface-3:   #e6ebf2;

  /* Text — `--dim` raised so 4.5:1 holds even on white; reserve --dim for
     truly tertiary text (timestamps, small foot meta). */
  --ink:         #1a2332;
  --muted:       #5a6478;
  --dim:         #6c7888;

  /* Borders */
  --grid:        #c8d1de;
  --grid-soft:   #dde3ec;

  /* Striping for tables (zebra rows) */
  --row-alt:     #f6f8fc;

  /* Accents — red toned down per UI rules; alpha utility values mirror it. */
  --accent:      #c0392b;
  --accent-soft: rgba(192, 57, 43, 0.10);
  --blue:        #0d6efd;
  --blue-soft:   rgba(13, 110, 253, 0.08);
  --green:       #1f9d55;
  --green-soft:  rgba(31, 157, 85, 0.10);
  --amber:       #c47f00;
  --amber-soft:  rgba(196, 127, 0, 0.10);
  --purple:      #7c3aed;
  --purple-soft: rgba(124, 58, 237, 0.10);

  /* Semantic */
  --hit:    #c0392b;
  --sum:    #0d6efd;
  --shadow: none;

  /* Type stacks — body uses sans, headlines/labels lean on a slightly
     stylish stack but stays within common UI fonts. Mono for digit columns. */
  --font-body:    "Fira Sans", "Inter", "Helvetica Neue", "Noto Sans SC", system-ui, -apple-system, sans-serif;
  --font-display: "Source Sans 3", "Fira Sans", "Inter", "Helvetica Neue", system-ui, sans-serif;
  --font-mono:    "Fira Code", "JetBrains Mono", "SF Mono", ui-monospace, monospace;
}

/* ── DARK theme (opt-in via body.dark) ── */
body.dark {
  --bg:          #0d1117;
  --surface:     #161b22;
  --surface-2:   #1c2333;
  --surface-3:   #21262d;

  --ink:         #e6edf3;
  --muted:       #8b949e;
  --dim:         #6b7480;

  --grid:        #30363d;
  --grid-soft:   #21262d;

  --row-alt:     #0f1520;

  --accent:      #ff5757;
  --accent-soft: rgba(255, 87, 87, 0.14);
  --blue:        #58a6ff;
  --blue-soft:   rgba(88, 166, 255, 0.12);
  --green:       #4ade80;
  --green-soft:  rgba(74, 222, 128, 0.14);
  --amber:       #fbbf24;
  --amber-soft:  rgba(251, 191, 36, 0.12);
  --purple:      #c084fc;
  --purple-soft: rgba(192, 132, 252, 0.12);

  --hit:    #ff5757;
  --sum:    #58a6ff;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
}

select, button { font: inherit; cursor: pointer; }

.page-shell {
  width: min(1760px, calc(100vw - 10px));
  margin: 6px auto 14px;
}

/* ── Cards ── flat panels separated by spacing + a single hairline; no elevation. */
.hero,
.controls,
.table-card,
.stats-card {
  background: var(--surface);
  border: 1px solid var(--grid);
  border-radius: 12px;
}

/* ── Hero ── */
.hero {
  padding: 10px 14px 8px;
}

.eyebrow {
  margin: 0 0 3px;
  font-family: var(--font-display);
  letter-spacing: 0.04em;
  color: var(--accent);
  font-size: 12px;
}

.hero h1 {
  margin: 0;
  font-size: clamp(1.1rem, 2vw, 1.45rem);
  line-height: 1;
  font-weight: 600;
  color: var(--ink);
}

/* ── Controls ── */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  padding: 8px 12px;
  align-items: end;
}

.controls label { display: grid; gap: 3px; }

.stats-label,
.controls span {
  font-size: 12px;
  color: var(--muted);
}

.controls select,
.controls button {
  min-height: 30px;
  border: 1px solid var(--grid);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--surface-3);
  color: var(--ink);
  font-size: 12px;
  transition: border-color 150ms;
}

.controls select:focus {
  outline: none;
  border-color: var(--blue);
}

.controls button {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
  font-weight: 600;
  padding: 0 20px;
  transition: opacity 150ms;
}

.controls button:hover { opacity: 0.82; }
.controls button:disabled { opacity: 0.5; cursor: wait; }

.controls button.secondary-btn {
  background: var(--surface-3);
  color: var(--ink);
  border: 1px solid var(--grid);
}

.controls button.secondary-btn:hover {
  border-color: var(--blue);
  color: var(--blue);
  opacity: 1;
}

/* 同步按钮: 用蓝色与"刷新数据"(红/accent) 视觉区分，强调"拉取新数据"的语义 */
.controls button.sync-btn {
  background: rgba(88, 166, 255, 0.12);
  color: rgb(88, 166, 255);
  border: 1px solid rgba(88, 166, 255, 0.45);
  font-weight: 500;
  padding: 0 14px;
}
.controls button.sync-btn:hover {
  background: rgba(88, 166, 255, 0.22);
  border-color: rgb(88, 166, 255);
  opacity: 1;
}

.controls-more {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: end;
}
.controls-more-toggle {
  display: none;
  background: var(--surface-3) !important;
  color: var(--ink) !important;
  border: 1px solid var(--grid) !important;
  font-weight: 500 !important;
  padding: 0 14px !important;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 2px;
}

/* ── Legend ── */
.legend {
  display: flex;
  gap: 14px;
  padding: 4px 2px;
  font-size: 12px;
  color: var(--muted);
  align-items: center;
  flex-wrap: wrap;
  margin: 4px 0;
}

.legend .ball {
  display: inline-block;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 3px;
}

.legend .ball.hit   { background: var(--hit);   box-shadow: 0 0 6px rgba(192,57,43,0.5); }
.legend .ball.hit-a { background: var(--accent); box-shadow: 0 0 6px rgba(192,57,43,0.5); }
.legend .ball.hit-b { background: var(--blue);   box-shadow: 0 0 6px rgba(88,166,255,0.5); }
.legend .ball.hit-c { background: var(--green);  box-shadow: 0 0 6px rgba(63,185,80,0.5); }
.legend .ball.miss  { background: var(--surface-3); border: 1px solid var(--grid); }
.legend .ball.sum   { background: var(--sum); }

/* ── View switch ── */
.view-switch {
  display: flex;
  gap: 6px;
  margin: 6px 0;
  flex-wrap: wrap;
  align-items: center;
}
.view-switch-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.view-select-mobile {
  display: none;
  flex: 1;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--grid);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
}

.view-switch-btn {
  min-height: 30px;
  padding: 0 14px;
  border: 1px solid var(--grid);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  transition: all 150ms;
}

.view-switch-btn:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.view-switch-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.hidden-view { display: none; }

/* ── Hecha summary chips ── */
.hecha-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  margin: 6px 0;
  padding: 10px 12px;
  align-items: center;
}

.stats-copy { flex: none; }
.stats-grid { display: flex; flex-wrap: wrap; gap: 6px; }

.stat-chip {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 8px;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 6px;
  background: var(--blue-soft);
  border: 1px solid rgba(88, 166, 255, 0.2);
}

.stat-chip span  { color: var(--muted); font-size: 12px; }
.stat-chip strong { color: var(--blue); font-size: 12px; font-family: var(--font-mono); }

/* ── Table card ── */
.table-card { overflow: hidden; margin-top: 6px; }
.hecha-card { margin-top: 8px; }

.table-wrap {
  position: relative;
  overflow: auto;
  max-height: calc(100vh - 90px);
}

/* Custom scrollbar */
.table-wrap::-webkit-scrollbar { width: 8px; height: 8px; }
.table-wrap::-webkit-scrollbar-track { background: var(--surface); }
.table-wrap::-webkit-scrollbar-thumb { background: var(--grid); border-radius: 4px; }
.table-wrap::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── Context bar ── */
.context-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 26px;
  padding: 0 10px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--grid);
  color: var(--muted);
  position: sticky;
  top: 0;
  z-index: 10;
  border-radius: 13px 13px 0 0;
}

.hecha-context { border-radius: 13px 13px 0 0; }

.context-label  { font-size: 12px; color: var(--muted); }
.context-bar strong { color: var(--blue); font-size: 12px; font-weight: 600; }
.context-divider { color: var(--dim); }

/* ── Table base ── */
table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  background: var(--bg);
  table-layout: auto;
}

thead th {
  background: var(--surface-2);
  color: var(--muted);
  vertical-align: middle;
  /* Sticky so column headers stay aligned with data as the user scrolls.
     Each row's `top` is the running sum of the context-bar + preceding
     header-row heights — keeps every row anchored without overlap.
     The user can opt out via the "表头固定" toggle (adds `.no-sticky-head`
     to body) — useful on small screens / image exports. */
  position: sticky;
  z-index: 9;
}
body.no-sticky-head thead th { position: static; }

thead tr:first-child th {
  height: 28px;
  background: var(--surface-3);
  font-size: 11px;
  letter-spacing: 0.04em;
  top: 0;               /* context-bar removed; row 1 sticks to top */
}

thead tr:nth-child(2) th {
  height: 26px;
  background: var(--surface-2);
  font-size: 11px;
  top: 28px;            /* below row 1 (28px) */
}

thead tr:nth-child(3) th {
  height: 26px;
  background: var(--surface);
  border-bottom: 1px solid var(--accent);
  top: 54px;            /* 28 (row 1) + 26 (row 2) */
}

/* 占位 cell for the info area (rowspan=2) — no visible chrome, just holds layout. */
thead th.info-empty {
  background: var(--surface);
  border-color: transparent;
}

/* 日期列已从渲染中移除 — 期号唯一标识每一期，日期冗余 */

thead tr:nth-child(3) th.single-subhead {
  background: var(--surface-2);
}

tbody td {
  background-color: var(--surface);
}

tbody tr:nth-child(even) td {
  background-color: var(--row-alt);
}

tbody tr:hover td {
  background-color: var(--blue-soft) !important;
  transition: background-color 80ms;
}

th, td {
  height: 32px;
  padding: 0 3px;
  text-align: center;
  border: 1px solid var(--grid-soft);
  font-size: 11px;
  vertical-align: middle;
}

/* Column widths — info (期号 / 开奖号；日期列已移除) */
thead tr:nth-child(3) th:nth-child(1),
tbody td:nth-child(1) {
  width: 92px; min-width: 92px; max-width: 92px;
}

thead tr:nth-child(3) th:nth-child(2),
tbody td:nth-child(2) {
  width: 110px; min-width: 110px; max-width: 110px;
}

/* Column widths — digit cells (col 3-32 are now the 30 digit cells 0-9 ×3) */
thead tr:nth-child(3) th:nth-child(n+3):nth-child(-n+32),
tbody td:nth-child(n+3):nth-child(-n+32) {
  width: 30px; min-width: 30px; max-width: 30px;
  height: 32px; padding: 0;
}

/* Column widths — metric area (cols 33-47): keep them tight but readable */
#trend-table thead tr:nth-child(3) th:nth-child(n+33),
#trend-table tbody td:nth-child(n+33) {
  width: 38px; min-width: 38px;
  font-size: 11px; padding: 0 2px;
}
/* Form hit-cells (cols 36-40) — narrow uniform width */
#trend-table thead tr:nth-child(3) th:nth-child(n+36):nth-child(-n+40),
#trend-table tbody td:nth-child(n+36):nth-child(-n+40) {
  width: 40px; min-width: 40px; max-width: 40px;
  padding: 0;
}
/* 大中小比 (col 47) — needs more room for "1:2:0" */
#trend-table thead tr:nth-child(3) th:nth-child(47),
#trend-table tbody td:nth-child(47) {
  width: 46px; min-width: 46px;
}
/* 大小 / 奇偶 (cols 41, 42) — 3 Chinese chars per badge need wider cells */
#trend-table thead tr:nth-child(3) th:nth-child(41),
#trend-table tbody td:nth-child(41),
#trend-table thead tr:nth-child(3) th:nth-child(42),
#trend-table tbody td:nth-child(42) {
  width: 50px; min-width: 50px; max-width: 50px;
}
/* 012路 (col 43) — 3 digits, slight extra margin for the badge border */
#trend-table thead tr:nth-child(3) th:nth-child(43),
#trend-table tbody td:nth-child(43) {
  width: 44px; min-width: 44px;
}

/* ── Zone titles ── */
.zone-title {
  background: var(--surface-3);
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.digit-head {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  font-weight: 600;
  background: var(--surface);
  font-family: var(--font-mono);
}

.info-title   { text-align: center; }
.info-subtitle { background: var(--surface-2); }

.dist-title {
  background: rgba(88, 166, 255, 0.08);
  color: var(--blue) !important;
  border-bottom: 1px solid rgba(88, 166, 255, 0.25) !important;
}

.metric-title {
  background: rgba(63, 185, 80, 0.07);
  color: var(--green) !important;
}

.hecha-title {
  background: rgba(188, 140, 255, 0.08);
  color: var(--purple) !important;
}

.zone-subtitle {
  background: rgba(88, 166, 255, 0.05);
  color: rgba(88, 166, 255, 0.65);
}

.metric-subtitle {
  background: rgba(63, 185, 80, 0.05);
  color: rgba(63, 185, 80, 0.65);
}

.ratio-subtitle {
  background: var(--amber-soft);
  color: var(--amber);
}

.hecha-subtitle {
  background: rgba(188, 140, 255, 0.05);
  color: rgba(188, 140, 255, 0.65);
}

/* ── Data cells ── */
.issue-cell {
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  font-size: 12px;
  color: var(--muted);
}

.date-cell {
  white-space: nowrap;
  font-size: 11px;
  line-height: 1.3;
}

.date-cell strong {
  display: inline;
  color: var(--ink);
}

.date-cell span {
  display: inline;
  margin-left: 3px;
  color: var(--dim);
  font-size: 11px;
}

.open-cell strong {
  font-size: 14px;
  font-family: var(--font-mono);
  letter-spacing: 0.1em;
  color: var(--accent);
  font-weight: 600;
}

/* Pair-sum / pair-diff derived values — dedicated column right after 开奖号 in
   两码合 / 两码差 / 任意两码合 / 任意两码差. Blue mono so it reads as "derived". */
.grid-table thead th.open-extra-head,
.grid-table tbody td.open-extra-cell {
  width: 80px; min-width: 80px; max-width: 80px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--blue);
  letter-spacing: 0.08em;
  font-weight: 600;
  white-space: nowrap;
}
.grid-table thead th.open-extra-head { color: var(--muted); font-weight: 600; font-size: 11px; }

/* ── 走势图说明块 ── 卡片底部，告诉用户每列的含义 (AC值/五行/重邻等) */
.view-desc {
  padding: 10px 16px 12px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--muted);
  border-top: 1px solid var(--grid);
  background: var(--surface-2);
  border-radius: 0 0 12px 12px;
}
.view-desc strong {
  color: var(--ink);
  font-weight: 600;
  margin: 0 1px;
}
.view-desc-label {
  display: inline-block;
  padding: 1px 7px;
  margin-right: 6px;
  border-radius: 4px;
  background: var(--surface-3);
  color: var(--blue);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.trial-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(88, 166, 255, 0.10);
  border: 1px solid rgba(88, 166, 255, 0.22);
  color: var(--blue);
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  vertical-align: middle;
}

.open-cell, .group-cell, .issue-cell, .date-cell { font-weight: 600; }

/* ── Hit badge ── */
.hit-cell {
  position: relative;
  color: transparent;
}

/* 球(ball)样式 — 参考 17500: 径向渐变高光 + 强阴影，立体感更足
   - 顶部偏左 30%/30% 的白色高光点制造光泽
   - 主色作为底色，外发光 + 内描边一起做立体感 */
.hit-badge {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 28%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 60%),
    var(--hit);
  color: #fff;
  font-weight: 600;
  font-size: 11px;
  font-family: var(--font-mono);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.18),
    0 0 0 1px rgba(0, 0, 0, 0.05),
    inset 0 -2px 3px rgba(0, 0, 0, 0.18);
}

/* Per-zone hit ball variants — 17500.cn style: ball matches zone identity */
.hit-badge.zone-a {
  background:
    radial-gradient(circle at 30% 28%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 60%),
    var(--accent);
}
.hit-badge.zone-b {
  background:
    radial-gradient(circle at 30% 28%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 60%),
    var(--blue);
}
.hit-badge.zone-c {
  background:
    radial-gradient(circle at 30% 28%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 60%),
    var(--green);
}

/* ── Sum / span badge ── */
.sum-badge {
  display: inline-grid;
  min-width: 22px;
  min-height: 20px;
  padding: 0 4px;
  border-radius: 4px;
  place-items: center;
  background: rgba(88, 166, 255, 0.14);
  color: var(--blue);
  font-weight: 600;
  font-size: 11px;
  font-family: var(--font-mono);
  border: 1px solid rgba(88, 166, 255, 0.22);
}

/* ── Pattern tags ── */
.pattern-tag {
  display: inline-grid;
  min-height: 18px;
  padding: 0 5px;
  border-radius: 4px;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  border: 1px solid rgba(192, 57, 43, 0.2);
  white-space: nowrap;
  letter-spacing: 0;
}

.pattern-tag.neutral {
  background: var(--green-soft);
  color: var(--green);
  border-color: rgba(63, 185, 80, 0.2);
}

/* ── Ratio tags (奇偶比 / 大小比) ── */
.ratio-tag {
  display: inline-grid;
  min-height: 18px;
  padding: 0 6px;
  border-radius: 4px;
  place-items: center;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
  border: 1px solid rgba(227, 179, 65, 0.2);
  letter-spacing: 0.04em;
}

.ratio-tag.alt {
  background: var(--purple-soft);
  color: var(--purple);
  border-color: rgba(188, 140, 255, 0.2);
}

/* ── Omission values ── */
.omit {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
}

/* ── Group cell ── */
.group-cell {
  font-weight: 600;
  font-size: 11px;
  color: var(--amber);
  white-space: nowrap;
}

/* 5-way detail (豹子/组三/全顺/半顺/杂六) — distinct color per class */
.group-cell.gd-baozi    { color: #c0392b; font-weight: 600; }   /* 红，最罕见 */
.group-cell.gd-zusan    { color: #c47f00; }                      /* 琥珀 */
.group-cell.gd-quanshun { color: #7c3aed; }                      /* 紫，全顺较少见 */
.group-cell.gd-banshun  { color: #0d6efd; }                      /* 蓝 */
.group-cell.gd-zaliu    { color: #1f9d55; }                      /* 绿，最常见 */

/* ── Hecha badges ── */
.hecha-badge {
  display: inline-grid;
  min-width: 22px;
  height: 22px;
  padding: 0 3px;
  place-items: center;
  border-radius: 4px;
  background: var(--purple-soft);
  color: var(--purple);
  font-weight: 600;
  font-size: 11px;
  font-family: var(--font-mono);
  border: 1px solid rgba(188, 140, 255, 0.25);
}

.hecha-count-badge {
  display: inline-grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 600;
  font-size: 11px;
  font-family: var(--font-mono);
  border: 1px solid rgba(88, 166, 255, 0.25);
}

.hecha-open-cell strong {
  color: var(--purple);
  letter-spacing: 0.1em;
  font-family: var(--font-mono);
}

.hecha-path { stroke: rgba(188, 140, 255, 0.75); }

/* ── Zone separators (main trend table) ── 2px coloured rules at every zone
   boundary so the eye can pick the structure out at a glance.
   Indices shifted -1 after 日期 column removal (期号=1, 开奖号=2, digit 百位.0=3). */
#trend-table td:nth-child(3),  #trend-table th:nth-child(3)  { border-left: 2px solid rgba(192, 57, 43, 0.55) !important; }
#trend-table td:nth-child(13), #trend-table th:nth-child(13) { border-left: 2px solid rgba(13, 110, 253, 0.55) !important; }
#trend-table td:nth-child(23), #trend-table th:nth-child(23) { border-left: 2px solid rgba(31, 157, 85, 0.55) !important; }
#trend-table td:nth-child(33), #trend-table th:nth-child(33) { border-left: 2px solid rgba(148, 163, 184, 0.55) !important; }
#trend-table td:nth-child(36), #trend-table th:nth-child(36) { border-left: 2px solid rgba(196, 127, 0, 0.55) !important; }
#trend-table td:nth-child(41), #trend-table th:nth-child(41) { border-left: 2px solid rgba(124, 58, 237, 0.55) !important; }
#trend-table td:nth-child(44), #trend-table th:nth-child(44) { border-left: 2px solid rgba(245, 158, 11, 0.55) !important; }
#trend-table td:nth-child(48), #trend-table th:nth-child(48) { border-left: 2px solid rgba(56, 189, 248, 0.55) !important; }

/* ── Zone background tints (matches 17500.cn alternation; layered via bg-image) ── */
/* 百位 cols 3-12: red tint */
#trend-table tbody td:nth-child(n+3):nth-child(-n+12) {
  background-image: linear-gradient(rgba(192, 57, 43, 0.06), rgba(192, 57, 43, 0.06));
}
/* 十位 cols 13-22: blue tint */
#trend-table tbody td:nth-child(n+13):nth-child(-n+22) {
  background-image: linear-gradient(rgba(13, 110, 253, 0.07), rgba(13, 110, 253, 0.07));
}
/* 个位 cols 23-32: green tint */
#trend-table tbody td:nth-child(n+23):nth-child(-n+32) {
  background-image: linear-gradient(rgba(31, 157, 85, 0.07), rgba(31, 157, 85, 0.07));
}
/* Dark theme uses softer alpha for the same tints */
body.dark #trend-table tbody td:nth-child(n+3):nth-child(-n+12) {
  background-image: linear-gradient(rgba(192, 57, 43, 0.06), rgba(192, 57, 43, 0.06));
}
body.dark #trend-table tbody td:nth-child(n+13):nth-child(-n+22) {
  background-image: linear-gradient(rgba(88, 166, 255, 0.08), rgba(88, 166, 255, 0.08));
}
body.dark #trend-table tbody td:nth-child(n+23):nth-child(-n+32) {
  background-image: linear-gradient(rgba(63, 185, 80, 0.07), rgba(63, 185, 80, 0.07));
}

/* 形态 5-cell hit-track (cols 36-40): subtle amber tint */
#trend-table tbody td:nth-child(n+36):nth-child(-n+40) {
  background-image: linear-gradient(rgba(196, 127, 0, 0.05), rgba(196, 127, 0, 0.05));
}
body.dark #trend-table tbody td:nth-child(n+36):nth-child(-n+40) {
  background-image: linear-gradient(rgba(251, 191, 36, 0.06), rgba(251, 191, 36, 0.06));
}

/* Per-category hit badge color (cols 36=豹子, 37=组三, 38=全顺, 39=半顺, 40=杂六)
   球样式：径向高光 + 主色，跟主表 .hit-badge 同体系 */
#trend-table tbody td.hit-cell:nth-child(36) .hit-badge { background: radial-gradient(circle at 30% 28%, rgba(255,255,255,0.55), rgba(255,255,255,0) 60%), #c0392b; }
#trend-table tbody td.hit-cell:nth-child(37) .hit-badge { background: radial-gradient(circle at 30% 28%, rgba(255,255,255,0.55), rgba(255,255,255,0) 60%), #c47f00; }
#trend-table tbody td.hit-cell:nth-child(38) .hit-badge { background: radial-gradient(circle at 30% 28%, rgba(255,255,255,0.55), rgba(255,255,255,0) 60%), #7c3aed; }
#trend-table tbody td.hit-cell:nth-child(39) .hit-badge { background: radial-gradient(circle at 30% 28%, rgba(255,255,255,0.55), rgba(255,255,255,0) 60%), #0d6efd; }
#trend-table tbody td.hit-cell:nth-child(40) .hit-badge { background: radial-gradient(circle at 30% 28%, rgba(255,255,255,0.55), rgba(255,255,255,0) 60%), #1f9d55; }
#trend-table tbody td.form-cell .hit-badge {
  min-width: 28px; width: auto; height: 20px; padding: 0 5px;
  font-size: 11px; border-radius: 10px; color: #fff;
  white-space: nowrap;
}

/* Form column header colors */
#trend-table thead tr:nth-child(3) th:nth-child(37) { background: rgba(192, 57, 43, 0.07); color: #c0392b; }
#trend-table thead tr:nth-child(3) th:nth-child(38) { background: rgba(196, 127, 0, 0.07); color: #c47f00; }
#trend-table thead tr:nth-child(3) th:nth-child(39) { background: rgba(124, 58, 237, 0.07); color: #7c3aed; }
#trend-table thead tr:nth-child(3) th:nth-child(40) { background: rgba(13, 110, 253, 0.07); color: #0d6efd; }
#trend-table thead tr:nth-child(3) th:nth-child(41) { background: rgba(31, 157, 85, 0.07); color: #1f9d55; }

/* Form polyline — neutral grey so colored badges stay readable */
#line-form { stroke: rgba(100, 116, 139, 0.7); stroke-width: 1.4; }

/* Stats footer — keep cells flat (no zone tint) */
#trend-table tfoot td:nth-child(n+4):nth-child(-n+33),
#trend-table tfoot td:nth-child(n+37):nth-child(-n+41) {
  background-image: none;
}

/* Zone-specific header tints for the digit-row (3rd thead row) */
#trend-table thead tr:nth-child(3) th:nth-child(n+4):nth-child(-n+13) {
  background: var(--accent-soft);
  color: var(--accent);
}
#trend-table thead tr:nth-child(3) th:nth-child(n+14):nth-child(-n+23) {
  background: var(--blue-soft);
  color: var(--blue);
}
#trend-table thead tr:nth-child(3) th:nth-child(n+24):nth-child(-n+33) {
  background: var(--green-soft);
  color: var(--green);
}

/* Zone subtitle row tints (2nd thead row, 百/十/个 labels) */
#trend-table thead tr:nth-child(2) th:nth-child(2) {
  background: var(--accent-soft);
  color: var(--accent);
}
#trend-table thead tr:nth-child(2) th:nth-child(3) {
  background: var(--blue-soft);
  color: var(--blue);
}
#trend-table thead tr:nth-child(2) th:nth-child(4) {
  background: var(--green-soft);
  color: var(--green);
}

/* ── SVG trend overlays ── absolute-position covers BOTH main view's #trend-overlay
   AND every dynamically-mounted grid view (which gets `.grid-overlay`).
   Without `position: absolute` the SVG sits in normal flow AFTER the table, so
   polylines render below the data instead of overlaying it. */
#trend-overlay,
.grid-overlay {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  z-index: 1;
  overflow: visible;
}

.trend-path {
  fill: none;
  stroke-width: 1.8;
  stroke-linejoin: round;
  stroke-linecap: round;
  shape-rendering: geometricPrecision;
  vector-effect: non-scaling-stroke;
}

/* Three distinct colors for 百/十/个位 lines */
#line-a { stroke: rgba(229, 57,  53,  0.85); }
#line-b { stroke: rgba(88,  166, 255, 0.85); }
#line-c { stroke: rgba(63,  185, 80,  0.85); }

/* Grid view line colors: group-0 red, group-1 blue, group-2 green */
#span-line-0,
#heche-line-0,
#hecha-diff-line-0 { stroke: rgba(229, 57,  53,  0.85); }
#heche-line-1,
#hecha-diff-line-1 { stroke: rgba(88,  166, 255, 0.85); }
#heche-line-2,
#hecha-diff-line-2 { stroke: rgba(63,  185, 80,  0.85); }

/* ── Grid table column widths ── */
.grid-table thead tr:first-child th { height: 28px; }

/* Grid info cols (期号 / 开奖号；日期列已移除) */
.grid-table thead tr:nth-child(3) th:nth-child(1),
.grid-table tbody td:nth-child(1) {
  width: 92px; min-width: 92px; max-width: 92px;
}
.grid-table thead tr:nth-child(3) th:nth-child(2),
.grid-table tbody td:nth-child(2) {
  width: 62px; min-width: 62px; max-width: 62px;
}
.grid-table thead tr:nth-child(3) th:nth-child(n+3),
.grid-table tbody td:nth-child(n+3) {
  width: 32px; min-width: 32px; max-width: 32px;
}

/* Grid group separators / zone tints — one palette entry per group index.
   Cells in renderGridBody/buildGridHeader get a `grid-zone-N` class; the first
   cell of each group also gets `zone-start` for the 2px coloured rule. */
.grid-table tbody td.grid-zone-0 { background-image: linear-gradient(rgba(192, 57, 43, 0.06),  rgba(192, 57, 43, 0.06)); }
.grid-table tbody td.grid-zone-1 { background-image: linear-gradient(rgba(88, 166, 255, 0.06), rgba(88, 166, 255, 0.06)); }
.grid-table tbody td.grid-zone-2 { background-image: linear-gradient(rgba(63, 185, 80, 0.06),  rgba(63, 185, 80, 0.06)); }
.grid-table tbody td.grid-zone-3 { background-image: linear-gradient(rgba(196, 127, 0, 0.06),  rgba(196, 127, 0, 0.06)); }
/* zone 4-6 复用前 3 个颜色 — 移除紫/粉以保持视觉一致 */
.grid-table tbody td.grid-zone-4 { background-image: linear-gradient(rgba(192, 57, 43, 0.06),  rgba(192, 57, 43, 0.06)); }
.grid-table tbody td.grid-zone-5 { background-image: linear-gradient(rgba(88, 166, 255, 0.06), rgba(88, 166, 255, 0.06)); }
.grid-table tbody td.grid-zone-6 { background-image: linear-gradient(rgba(63, 185, 80, 0.06),  rgba(63, 185, 80, 0.06)); }

/* Zone-start: 2px coloured divider at the first column of each group. */
.grid-table .zone-start.grid-zone-0 { border-left: 2px solid rgba(192, 57, 43, 0.55) !important; }
.grid-table .zone-start.grid-zone-1 { border-left: 2px solid rgba(88, 166, 255, 0.55) !important; }
.grid-table .zone-start.grid-zone-2 { border-left: 2px solid rgba(63, 185, 80, 0.55) !important; }
.grid-table .zone-start.grid-zone-3 { border-left: 2px solid rgba(196, 127, 0, 0.55) !important; }
.grid-table .zone-start.grid-zone-4 { border-left: 2px solid rgba(192, 57, 43, 0.55) !important; }
.grid-table .zone-start.grid-zone-5 { border-left: 2px solid rgba(88, 166, 255, 0.55) !important; }
.grid-table .zone-start.grid-zone-6 { border-left: 2px solid rgba(63, 185, 80, 0.55) !important; }

/* Grid group title in header — keep the existing soft blue tint as default
   but the per-zone colour scheme tints individual group titles below. */
.grid-group-title {
  background: rgba(88, 166, 255, 0.06);
  color: rgba(88, 166, 255, 0.65);
}
.grid-table thead .grid-group-title.grid-zone-0 { background: rgba(192, 57, 43, 0.10);  color: rgba(192, 57, 43, 0.85); }
.grid-table thead .grid-group-title.grid-zone-1 { background: rgba(88, 166, 255, 0.10); color: rgba(88, 166, 255, 0.85); }
.grid-table thead .grid-group-title.grid-zone-2 { background: rgba(63, 185, 80, 0.10);  color: rgba(63, 185, 80, 0.85); }
.grid-table thead .grid-group-title.grid-zone-3 { background: rgba(196, 127, 0, 0.10);  color: rgba(196, 127, 0, 0.85); }
.grid-table thead .grid-group-title.grid-zone-4 { background: rgba(192, 57, 43, 0.10);  color: rgba(192, 57, 43, 0.85); }
.grid-table thead .grid-group-title.grid-zone-5 { background: rgba(88, 166, 255, 0.10); color: rgba(88, 166, 255, 0.85); }
.grid-table thead .grid-group-title.grid-zone-6 { background: rgba(63, 185, 80, 0.10);  color: rgba(63, 185, 80, 0.85); }


/* ═══ 组选分析图 (zxfx) custom layout ═══════════════════════ */
/* Columns: info(4) + 左延伸(5) + 组选号码(10) + 右延伸(5) + 组选分布(3) + 升降序(5) = 32 */
/* Children indices: 1..4 info | 5..9 左延伸 | 10..19 组选号码 | 20..24 右延伸 | 25..27 组选分布 | 28..32 升降序 */

/* Lock every trend table to natural width — prevent base `min-width: 100%`
   from stretching columns and ignoring per-cell max-width when viewport is
   wider than the table (the cause of large blank gaps on wide displays). */
#trend-table, #zxfx-table, .grid-table {
  table-layout: fixed;
  width: max-content;
  min-width: 0;
}

/* Zxfx info cols — 2 cols only after 日期 and 试机号 removal: 期号 + 奖号 */
#zxfx-table thead tr:nth-child(3) th:nth-child(1),
#zxfx-table tbody td:nth-child(1) {
  width: 78px; min-width: 78px; max-width: 78px;
}
#zxfx-table thead tr:nth-child(3) th:nth-child(2),
#zxfx-table tbody td:nth-child(2) {
  width: 62px; min-width: 62px; max-width: 62px;
}
/* Digit cells: 左延伸(3..7), 组选号码(8..17), 右延伸(18..22) */
#zxfx-table thead tr:nth-child(3) th:nth-child(n+3):nth-child(-n+22),
#zxfx-table tbody td:nth-child(n+3):nth-child(-n+22) {
  width: 30px; min-width: 30px; max-width: 30px;
  padding: 0;
}
/* 组选分布 (23..25) */
#zxfx-table thead tr:nth-child(3) th:nth-child(n+23):nth-child(-n+25),
#zxfx-table tbody td:nth-child(n+23):nth-child(-n+25) {
  width: 40px; min-width: 40px; max-width: 40px;
  padding: 0;
}
/* 升降序 (26..30) — 2-char labels (上山/下山) need a slightly wider cell */
#zxfx-table thead tr:nth-child(3) th:nth-child(n+26):nth-child(-n+30),
#zxfx-table tbody td:nth-child(n+26):nth-child(-n+30) {
  width: 40px; min-width: 40px; max-width: 40px;
  padding: 0;
}
/* 数值指标 (31..33: 和值/和尾/跨度) */
#zxfx-table thead tr:nth-child(3) th:nth-child(n+31):nth-child(-n+33),
#zxfx-table tbody td:nth-child(n+31):nth-child(-n+33) {
  width: 38px; min-width: 38px; max-width: 38px;
  padding: 0 2px;
}
/* 形态指标 (34..38: 豹子/组三/全顺/半顺/杂六) */
#zxfx-table thead tr:nth-child(3) th:nth-child(n+34):nth-child(-n+38),
#zxfx-table tbody td:nth-child(n+34):nth-child(-n+38) {
  width: 40px; min-width: 40px; max-width: 40px;
  padding: 0;
}

/* Zone background tints — each conceptual block uses its own tinted backdrop
   so it's distinguishable even with default row striping. */
#zxfx-table tbody td:nth-child(n+3):nth-child(-n+7),
#zxfx-table tbody td:nth-child(n+18):nth-child(-n+22) {
  background-image: linear-gradient(rgba(148, 163, 184, 0.12), rgba(148, 163, 184, 0.12));
}
#zxfx-table tbody td:nth-child(n+8):nth-child(-n+17) {
  background-image: linear-gradient(rgba(192, 57, 43, 0.07), rgba(192, 57, 43, 0.07));
}
#zxfx-table tbody td:nth-child(n+23):nth-child(-n+25) {
  background-image: linear-gradient(rgba(196, 127, 0, 0.08), rgba(196, 127, 0, 0.08));
}
#zxfx-table tbody td:nth-child(n+26):nth-child(-n+30) {
  background-image: linear-gradient(rgba(124, 58, 237, 0.08), rgba(124, 58, 237, 0.08));
}
#zxfx-table tbody td:nth-child(n+31):nth-child(-n+33) {
  background-image: linear-gradient(rgba(31, 157, 85, 0.06), rgba(31, 157, 85, 0.06));
}
#zxfx-table tbody td:nth-child(n+34):nth-child(-n+38) {
  background-image: linear-gradient(rgba(196, 127, 0, 0.06), rgba(196, 127, 0, 0.06));
}

/* Zone dividers — thick coloured rules where one concept hands off to the next.
   Indices shifted by -2 after dropping 试机号 & 日期: info now spans cols 1-2. */
#zxfx-table td:nth-child(3),  #zxfx-table th:nth-child(3)  { border-left: 2px solid rgba(148, 163, 184, 0.55) !important; }
#zxfx-table td:nth-child(8),  #zxfx-table th:nth-child(8)  { border-left: 3px double rgba(192, 57, 43, 0.7) !important; }
#zxfx-table td:nth-child(18), #zxfx-table th:nth-child(18) { border-left: 3px double rgba(192, 57, 43, 0.7) !important; }
#zxfx-table td:nth-child(23), #zxfx-table th:nth-child(23) { border-left: 2px solid rgba(196, 127, 0, 0.55) !important; }
#zxfx-table td:nth-child(26), #zxfx-table th:nth-child(26) { border-left: 2px solid rgba(124, 58, 237, 0.55) !important; }
#zxfx-table td:nth-child(31), #zxfx-table th:nth-child(31) { border-left: 2px solid rgba(31, 157, 85, 0.55) !important; }
#zxfx-table td:nth-child(34), #zxfx-table th:nth-child(34) { border-left: 2px solid rgba(196, 127, 0, 0.55) !important; }

/* Top-row zone-title tints */
#zxfx-table .zxfx-ext-title   { background: rgba(148, 163, 184, 0.10); color: var(--dim) !important; border-bottom: 1px solid rgba(148, 163, 184, 0.3) !important; }
#zxfx-table .zxfx-mid-title   { background: rgba(192, 57, 43, 0.10);  color: var(--accent) !important; border-bottom: 1px solid rgba(192, 57, 43, 0.3) !important; }
#zxfx-table .zxfx-dist-title  { background: rgba(196, 127, 0, 0.12);  color: #c47f00 !important;       border-bottom: 1px solid rgba(196, 127, 0, 0.35) !important; }
#zxfx-table .zxfx-shape-title { background: rgba(124, 58, 237, 0.10); color: #7c3aed !important;       border-bottom: 1px solid rgba(124, 58, 237, 0.3) !important; }
#zxfx-table .zxfx-form-title  { background: rgba(196, 127, 0, 0.12);  color: #c47f00 !important;       border-bottom: 1px solid rgba(196, 127, 0, 0.35) !important; }
#zxfx-table .zxfx-gd-title    { background: rgba(196, 127, 0, 0.10);  color: #c47f00 !important;       border-bottom: 1px solid rgba(196, 127, 0, 0.3) !important; }

/* Sub-header label tints */
#zxfx-table thead tr:nth-child(3) th.zxfx-ext-head   { background: rgba(148, 163, 184, 0.05); color: rgba(148, 163, 184, 0.85); }
#zxfx-table thead tr:nth-child(3) th.zxfx-mid-head   { background: rgba(192, 57, 43, 0.06);   color: rgba(192, 57, 43, 0.85); }
#zxfx-table thead tr:nth-child(3) th.zxfx-dist-0-head  { color: #c47f00; font-weight: 600; }
#zxfx-table thead tr:nth-child(3) th.zxfx-dist-1-head  { color: #0d6efd; font-weight: 600; }
#zxfx-table thead tr:nth-child(3) th.zxfx-dist-2-head  { color: #c0392b; font-weight: 600; }
#zxfx-table thead tr:nth-child(3) th.zxfx-shape-0-head { color: #c0392b; font-weight: 600; }
#zxfx-table thead tr:nth-child(3) th.zxfx-shape-1-head { color: #1f9d55; font-weight: 600; }
#zxfx-table thead tr:nth-child(3) th.zxfx-shape-2-head { color: #c47f00; font-weight: 600; }
#zxfx-table thead tr:nth-child(3) th.zxfx-shape-3-head { color: #7c3aed; font-weight: 600; }
#zxfx-table thead tr:nth-child(3) th.zxfx-shape-4-head { color: #0d6efd; font-weight: 600; }
#zxfx-table thead tr:nth-child(3) th.zxfx-gd-0-head { color: #c0392b; font-weight: 600; }
#zxfx-table thead tr:nth-child(3) th.zxfx-gd-1-head { color: #c47f00; font-weight: 600; }
#zxfx-table thead tr:nth-child(3) th.zxfx-gd-2-head { color: #7c3aed; font-weight: 600; }
#zxfx-table thead tr:nth-child(3) th.zxfx-gd-3-head { color: #0d6efd; font-weight: 600; }
#zxfx-table thead tr:nth-child(3) th.zxfx-gd-4-head { color: #1f9d55; font-weight: 600; }

/* 组选分布 badges */
#zxfx-table .zxfx-dist-0-cell .hit-badge { background: radial-gradient(circle at 30% 28%, rgba(255,255,255,0.55), rgba(255,255,255,0) 60%), #c47f00; }
#zxfx-table .zxfx-dist-1-cell .hit-badge { background: radial-gradient(circle at 30% 28%, rgba(255,255,255,0.55), rgba(255,255,255,0) 60%), #0d6efd; }
#zxfx-table .zxfx-dist-2-cell .hit-badge { background: radial-gradient(circle at 30% 28%, rgba(255,255,255,0.55), rgba(255,255,255,0) 60%), #c0392b; }
#zxfx-table .zxfx-dist-cell .hit-badge {
  min-width: 28px; width: auto; height: 20px; padding: 0 6px;
  font-size: 11px; border-radius: 10px; color: #fff;
  white-space: nowrap;
}

/* 升降序 badges */
#zxfx-table .zxfx-shape-0-cell .hit-badge { background: radial-gradient(circle at 30% 28%, rgba(255,255,255,0.55), rgba(255,255,255,0) 60%), #c0392b; }
#zxfx-table .zxfx-shape-1-cell .hit-badge { background: radial-gradient(circle at 30% 28%, rgba(255,255,255,0.55), rgba(255,255,255,0) 60%), #1f9d55; }
#zxfx-table .zxfx-shape-2-cell .hit-badge { background: radial-gradient(circle at 30% 28%, rgba(255,255,255,0.55), rgba(255,255,255,0) 60%), #c47f00; }
#zxfx-table .zxfx-shape-3-cell .hit-badge { background: radial-gradient(circle at 30% 28%, rgba(255,255,255,0.55), rgba(255,255,255,0) 60%), #7c3aed; }
#zxfx-table .zxfx-shape-4-cell .hit-badge { background: radial-gradient(circle at 30% 28%, rgba(255,255,255,0.55), rgba(255,255,255,0) 60%), #0d6efd; }
#zxfx-table .zxfx-shape-cell .hit-badge {
  min-width: 28px; width: auto; height: 20px; padding: 0 5px;
  font-size: 11px; border-radius: 10px; color: #fff;
  white-space: nowrap;
}

/* 形态指标 badges (5-way 豹子/组三/全顺/半顺/杂六) — match basic-trend palette */
#zxfx-table .zxfx-gd-0-cell .hit-badge { background: #c0392b; box-shadow: 0 0 6px rgba(192,57,43,0.45); }
#zxfx-table .zxfx-gd-1-cell .hit-badge { background: #c47f00; box-shadow: 0 0 6px rgba(196,127,0,0.40); }
#zxfx-table .zxfx-gd-2-cell .hit-badge { background: #7c3aed; box-shadow: 0 0 6px rgba(124,58,237,0.45); }
#zxfx-table .zxfx-gd-3-cell .hit-badge { background: #0d6efd; box-shadow: 0 0 6px rgba(13,110,253,0.45); }
#zxfx-table .zxfx-gd-4-cell .hit-badge { background: #1f9d55; box-shadow: 0 0 6px rgba(31,157,85,0.45); }
#zxfx-table .zxfx-gd-cell .hit-badge {
  min-width: 28px; width: auto; height: 20px; padding: 0 5px;
  font-size: 11px; border-radius: 10px; color: #fff;
  white-space: nowrap;
}

/* 试机号 cell — mono, dim */
#zxfx-table .trial-cell {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--dim);
  text-align: center;
}

/* Flat stats footer (no zone tint) */
#zxfx-table tfoot td:nth-child(n+5):nth-child(-n+40) {
  background-image: none;
}

/* ── Stats footer ── */
.stat-foot .stat-section-row td {
  background: var(--surface-3);
  text-align: center;
  font-size: 12px;
  font-weight: 500;
  color: var(--amber);
  height: 24px;
  letter-spacing: 0.02em;
  border-top: 1px solid var(--amber);
  font-family: var(--font-display);
}

.stat-foot .stat-row td { height: 26px; }

.stat-foot .stat-row-count td       { background: rgba(63, 185, 80,  0.05); }
.stat-foot .stat-row-currentOmit td { background: var(--bg); }
.stat-foot .stat-row-avgOmit td     { background: rgba(88,  166, 255, 0.04); }
.stat-foot .stat-row-maxOmit td     { background: rgba(229, 57,  53,  0.04); }

.stat-foot .stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  text-align: right;
  padding-right: 8px;
  white-space: nowrap;
  background: var(--surface-2) !important;
  border-right: 1px solid var(--grid);
}

.stat-foot .stat-empty {
  background: var(--surface-2) !important;
}

.stat-foot .stat-val {
  font-size: 11px;
  font-family: var(--font-mono);
}

.stat-foot .stat-count       { color: var(--green); font-weight: 600; }
.stat-foot .stat-currentOmit { color: var(--muted); }
.stat-foot .stat-avgOmit     { color: var(--muted); }
.stat-foot .stat-maxOmit     { color: rgba(192, 57, 43, 0.65); }

.stat-foot .stat-omit-fresh {
  background: rgba(63, 185, 80, 0.2) !important;
  color: var(--green) !important;
  font-weight: 600;
}

.stat-foot .stat-omit-due {
  background: rgba(192, 57, 43, 0.18) !important;
  color: #c0392b !important;
  font-weight: 600;
}

/* 最大连出 / 欲出几率 */
.stat-foot .stat-maxConsec { color: var(--muted); }
.stat-foot .stat-consec-hot {
  color: var(--amber) !important;
  font-weight: 600;
}
.stat-foot .stat-dueRatio { color: var(--muted); }
.stat-foot .stat-due-mild {
  color: var(--blue) !important;
  font-weight: 600;
}
.stat-foot .stat-due-strong {
  background: rgba(13, 110, 253, 0.16) !important;
  color: var(--blue) !important;
  font-weight: 600;
}

/* ════════════════════════════════════════════════════════════
   ▼ NEW · 顶部导航 / 智能洞察面板 / 新增视图样式
   ════════════════════════════════════════════════════════════ */

/* ── Top nav ── */
.topnav {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--grid);
  border-radius: 12px;
  margin-top: 6px;
}

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

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--accent);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  font-family: var(--font-display);
  letter-spacing: 0.04em;
}

.brand-copy { display: grid; line-height: 1.2; }
.brand-copy strong { font-size: 14px; color: var(--ink); font-weight: 600; }
.brand-copy .brand-sub {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
  font-family: var(--font-mono);
}

.topnav-links {
  display: flex;
  gap: 4px;
  justify-self: center;
}

.topnav-link {
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  transition: all 150ms;
  border: 1px solid transparent;
}

.topnav-link:hover {
  background: var(--surface-3);
  color: var(--blue);
  border-color: var(--grid);
}

.topnav-link.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(192, 57, 43, 0.3);
}

.topnav-right {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-self: end;
}

.topnav-status {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--green-soft);
  border: 1px solid var(--green);
  color: var(--green);
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-body);
}

.theme-toggle {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--grid);
  background: var(--surface-3);
  color: var(--ink);
  font-size: 14px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 150ms;
}

.theme-toggle:hover {
  border-color: var(--blue);
  color: var(--blue);
  transform: scale(1.05);
}

.theme-icon-sun, .theme-icon-moon { display: none; }
body:not(.dark) .theme-icon-moon { display: inline; }
body.dark .theme-icon-sun { display: inline; }

/* status-dot removed per UI rules — `.topnav-status` carries the label alone. */

/* ── Repeat / adj badges (main row) ── */
.repeat-mark, .adj-mark {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
  background: rgba(192, 57, 43, 0.15);
  color: var(--accent);
  border: 1px solid rgba(192, 57, 43, 0.3);
}

.adj-mark {
  background: rgba(227, 179, 65, 0.15);
  color: var(--amber);
  border-color: rgba(227, 179, 65, 0.3);
}

.legend .repeat-mark { width: 16px; height: 16px; font-size: 11px; }

.dim { color: var(--dim); font-size: 11px; }

/* ── Repeat row highlight ── */
/* Combination of a thin red left-edge on the issue cell + a small numeric
   circle showing the actual repeat count (1-3). Severity scales the circle
   shade. The 重号 column (col 46) is still the canonical numeric source. */
.repeat-row td.issue-cell {
  box-shadow: inset 3px 0 0 var(--accent);
}

.repeat-row td.open-cell strong {
  color: var(--accent);
}

.issue-cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 0 6px;
}

.issue-cell .issue-num {
  flex: 1 1 auto;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
}

.repeat-circle {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
  line-height: 1;
  box-shadow: 0 0 0 1px rgba(192, 57, 43, 0.18);
}

.repeat-circle.r1 { background: #f59e0b; box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.2); }
.repeat-circle.r2 { background: #c0392b; box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.2); }
.repeat-circle.r3 { background: #9a2a20; box-shadow: 0 0 0 2px rgba(185, 28, 28, 0.25); }

/* ── AC value badge ── */
.ac-badge {
  display: inline-grid;
  min-width: 22px;
  min-height: 18px;
  padding: 0 5px;
  place-items: center;
  border-radius: 4px;
  background: var(--purple-soft);
  color: var(--purple);
  font-weight: 600;
  font-size: 11px;
  font-family: var(--font-mono);
  border: 1px solid rgba(188, 140, 255, 0.25);
}

/* ── New ratio variants ── */
.ratio-tag.prime {
  background: rgba(255, 107, 107, 0.10);
  color: #d9745f;
  border-color: rgba(255, 107, 107, 0.25);
}

.ratio-tag.triple {
  background: rgba(56, 189, 248, 0.10);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.25);
  font-size: 11px;
  letter-spacing: 0;
}

/* ── New header subtitle ── */
.extra-subtitle {
  background: rgba(188, 140, 255, 0.06);
  color: rgba(188, 140, 255, 0.7);
}

/* ── Grid view: per-cfg cell width via CSS var ── */
.grid-table { --cell-w: 32px; }

.grid-table thead tr:nth-child(3) th:nth-child(n+4),
.grid-table tbody td:nth-child(n+4) {
  width: var(--cell-w);
  min-width: var(--cell-w);
  max-width: var(--cell-w);
}

/* Soft striping for grid views (alternating zone tints) */
.grid-table tbody tr:nth-child(even) td { background-color: var(--row-alt); }

/* hit badge for narrow grid cells (e.g. 质合, 大中小, 012路) */
.hit-badge.grid-hit {
  background:
    radial-gradient(circle at 30% 28%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 60%),
    var(--accent);
  min-width: 20px;
  width: auto;
  height: 20px;
  padding: 0 4px;
  font-size: 11px;
  border-radius: 10px;
  white-space: nowrap;
}

/* 所有 grid 视图按 zone 索引分色 (对齐主走势图 百/十/个 红蓝绿)，
   循环复用 4 色 (红/蓝/绿/琥珀) — 跳过紫色。 */
.grid-table tbody td.hit-cell.grid-zone-0 .hit-badge,
.grid-table tbody td.hit-cell.grid-zone-4 .hit-badge {
  background:
    radial-gradient(circle at 30% 28%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 60%),
    rgb(192, 57, 43);
  box-shadow: 0 0 5px rgba(192, 57, 43, 0.4);
}
.grid-table tbody td.hit-cell.grid-zone-1 .hit-badge,
.grid-table tbody td.hit-cell.grid-zone-5 .hit-badge {
  background:
    radial-gradient(circle at 30% 28%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 60%),
    rgb(88, 166, 255);
  box-shadow: 0 0 5px rgba(88, 166, 255, 0.4);
}
.grid-table tbody td.hit-cell.grid-zone-2 .hit-badge,
.grid-table tbody td.hit-cell.grid-zone-6 .hit-badge {
  background:
    radial-gradient(circle at 30% 28%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 60%),
    rgb(63, 185, 80);
  box-shadow: 0 0 5px rgba(63, 185, 80, 0.4);
}
.grid-table tbody td.hit-cell.grid-zone-3 .hit-badge {
  background:
    radial-gradient(circle at 30% 28%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 60%),
    rgb(196, 127, 0);
  box-shadow: 0 0 5px rgba(196, 127, 0, 0.4);
}

/* Grid trend path colors per group index — 红/蓝/绿/琥珀 循环，跳过紫色 */
.trend-path.trend-path-0 { stroke: rgba(192, 57, 43, 0.85); }
.trend-path.trend-path-1 { stroke: rgba(88, 166, 255, 0.85); }
.trend-path.trend-path-2 { stroke: rgba(63, 185, 80, 0.85); }
.trend-path.trend-path-3 { stroke: rgba(196, 127, 0, 0.85); }
.trend-path.trend-path-4 { stroke: rgba(192, 57, 43, 0.85); }
.trend-path.trend-path-5 { stroke: rgba(88, 166, 255, 0.85); }
.trend-path.trend-path-6 { stroke: rgba(63, 185, 80, 0.85); }

/* Single-group views (跨度, 和值, 和尾) — 统一红折线 */
#span-line-0  { stroke: rgba(192, 57, 43, 0.85); }
#hezhi-line-0 { stroke: rgba(192, 57, 43, 0.85); }
#hewei-line-0 { stroke: rgba(192, 57, 43, 0.85); }

/* Wider info/header section for 和值 (28-cell track gets cramped otherwise) */
#hezhi-table .digit-head { font-size: 11px; }
#hezhi-table .hit-badge { font-size: 11px; }

/* Page foot */
.page-foot {
  display: flex;
  justify-content: space-between;
  margin: 16px 4px 4px;
  padding: 8px 14px;
  font-size: 11px;
  color: var(--dim);
  border-top: 1px dashed var(--grid);
}

.page-foot span { font-family: var(--font-mono); }

.view-switch {
  flex-wrap: wrap;
}

/* ── Responsive ── */
@media (max-width: 980px) {
  .page-shell {
    width: calc(100vw - 12px);
    margin: 6px auto 24px;
  }

  .hero { padding: 8px 10px 6px; }

  .controls {
    gap: 6px;
    padding: 6px 8px;
  }

  .controls label { min-width: calc(50% - 6px); }
  .toggle { min-width: auto; }

  th, td {
    height: 28px;
    padding: 0 1px;
    font-size: 11px;
  }

  thead tr:nth-child(3) th:nth-child(n+4):nth-child(-n+33),
  tbody td:nth-child(n+4):nth-child(-n+33) {
    width: 26px; min-width: 26px; max-width: 26px;
    height: 28px; padding: 0;
  }

  .hit-badge { width: 18px; height: 18px; font-size: 11px; }
  .context-bar { min-height: 22px; padding: 0 6px; }

  .topnav { grid-template-columns: 1fr; gap: 8px; padding: 8px 10px; }
  .topnav-links { justify-self: stretch; flex-wrap: wrap; }
  .topnav-link { padding: 4px 10px; font-size: 11px; }
  .topnav-status { justify-self: end; }
}

/* ── 手机端 (≤768px) ── 主要瞄准嵌入 APP 后的浏览体验：
   • Tab 横滑 + snap，14 个 tab 都能触达
   • 期号列 sticky-left，横向滑数字时锚定
   • Insights 单列堆叠
   • 顶 nav / 控制条 全部压缩，腾出表格空间 */
@media (max-width: 768px) {
  body { -webkit-text-size-adjust: 100%; }
  .page-shell { width: calc(100vw - 4px); margin: 2px auto 12px; }

  /* 视图切换：用 <select> 替代横向滚动的 13 个 tab，单手好操作 */
  .view-select-mobile { display: block; }
  .view-switch-pills { display: none; }
  /* 视图切换条 sticky 到顶部，方便切换 */
  .view-switch {
    position: sticky;
    top: 0;
    z-index: 30;
    background: var(--bg);
    padding: 6px 0;
    margin: 0 -2px 6px;
  }

  /* 控制条「更多」按钮：手机收起 5 个 toggle + 下载按钮 */
  .controls-more-toggle { display: inline-flex; align-items: center; }
  .controls-more {
    display: none;
    flex-basis: 100%;
    padding: 6px 0 0;
    border-top: 1px dashed var(--grid-soft);
    margin-top: 4px;
  }
  .controls-more.expanded { display: flex; }

  /* Topnav: 双行布局，brand 左 / 状态右 / 链接整行 */
  .topnav {
    grid-template-columns: auto 1fr auto;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 10px;
  }
  .brand-mark { width: 30px; height: 30px; font-size: 12px; border-radius: 7px; }
  .brand-copy strong { font-size: 13px; }
  .brand-copy .brand-sub { display: none; }
  .topnav-links { display: none; }
  .topnav-status { font-size: 11px; padding: 3px 8px; }
  .theme-toggle { width: 28px; height: 28px; font-size: 13px; }

  /* 控制条: 紧凑、保持触控可用 */
  .controls { padding: 6px; gap: 4px 6px; border-radius: 10px; }
  .controls label { min-width: auto; }
  .controls select, .controls button {
    min-height: 34px; padding: 0 10px; font-size: 12px;
  }

  /* 图例: 横向滚动，不换行 */
  .legend {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 2px 2px 4px;
    gap: 10px;
    font-size: 11px;
  }
  .legend::-webkit-scrollbar { display: none; }
  .legend > * { flex-shrink: 0; }

  /* Tab 切换: 横向滚动 + snap */
  .view-switch {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
    padding-bottom: 4px;
    margin: 4px -2px;
  }
  .view-switch::-webkit-scrollbar { display: none; }
  .view-switch-btn {
    flex-shrink: 0;
    scroll-snap-align: start;
    min-height: 34px;
    padding: 0 12px;
    font-size: 12px;
    border-radius: 7px;
  }

  /* 表格容器: 占满屏幕；iOS 平滑滚动 */
  .table-card { border-radius: 10px; margin-top: 4px; }
  .table-wrap {
    max-height: calc(100vh - 200px);
    -webkit-overflow-scrolling: touch;
  }
  .context-bar {
    min-height: 24px;
    padding: 0 8px;
    font-size: 11px;
    border-radius: 9px 9px 0 0;
    gap: 6px;
  }

  /* 期号 (col 1) sticky-left — 横滑数字时锚定。仿 17500: 仅 期号 sticky，开奖号随表滚走。
     注意必须精确选第 1 行的 rowspan=2 占位 cell 和第 3 行的 期号 cell，绝不能用
     `thead th:first-child` —— 那会把 row 2 的第一个 super 子标题 (跨度/百位/和尾…)
     也变成 sticky-left，横滑时它跟着期号一起赖在最左边。 */
  .table-wrap thead tr:first-child > th:first-child,
  .table-wrap thead tr:nth-child(3) > th:first-child,
  .table-wrap tbody td:first-child,
  .table-wrap tfoot td:first-child {
    position: sticky;
    left: 0;
    z-index: 6;
    box-shadow: 1px 0 0 var(--grid);
  }
  /* 保险一道: row 2 强制非 sticky，避免任何继承/兜底规则把 super 子标题钉在左侧 */
  .table-wrap thead tr:nth-child(2) > th {
    position: sticky;
    left: auto !important;
  }
  /* 期号列 — 缩到 17500 同等 64px */
  #trend-table thead tr:nth-child(3) th:nth-child(1),
  #trend-table tbody td:nth-child(1),
  .grid-table thead tr:nth-child(3) th:nth-child(1),
  .grid-table tbody td:nth-child(1),
  #zxfx-table thead tr:nth-child(3) th:nth-child(1),
  #zxfx-table tbody td:nth-child(1) {
    width: 64px; min-width: 64px; max-width: 64px;
  }
  /* 开奖号列 — 17500 同等 52px (3 位数字 12px×3 + 留白) */
  #trend-table thead tr:nth-child(3) th:nth-child(2),
  #trend-table tbody td:nth-child(2),
  .grid-table thead tr:nth-child(3) th:nth-child(2),
  .grid-table tbody td:nth-child(2),
  #zxfx-table thead tr:nth-child(3) th:nth-child(2),
  #zxfx-table tbody td:nth-child(2) {
    width: 52px; min-width: 52px; max-width: 52px;
  }
  /* 数字列 — 索引已 -1，对齐 17500 同等的 24px (用 table id 提高特异性，覆盖 desktop 规则) */
  #trend-table thead tr:nth-child(3) th:nth-child(n+3):nth-child(-n+32),
  #trend-table tbody td:nth-child(n+3):nth-child(-n+32),
  .grid-table thead tr:nth-child(3) th:nth-child(n+3),
  .grid-table tbody td:nth-child(n+3),
  #zxfx-table thead tr:nth-child(3) th:nth-child(n+3),
  #zxfx-table tbody td:nth-child(n+3) {
    width: 24px !important; min-width: 24px !important; max-width: 24px !important;
  }
  /* 行高紧凑 — 17500 同等约 26px */
  table th, table td { height: 26px !important; }
  table tbody td, table tfoot td { font-size: 11px; }
  .hit-badge { width: 18px; height: 18px; font-size: 10px; }
  table thead tr:first-child th { height: 22px !important; font-size: 10px; letter-spacing: 0; }
  table thead tr:nth-child(2) th { height: 22px !important; font-size: 10px; }
  table thead tr:nth-child(3) th { height: 22px !important; font-size: 10px; }

  /* 开奖号字号略缩，更挤得下 */
  .open-cell strong { font-size: 12px; letter-spacing: 0.05em; }
  .issue-cell { font-size: 11px; padding: 0 4px; }
  .date-cell { font-size: 10px; }

  /* sticky-top 偏移同步缩小 (与紧凑表头高度匹配) */
  thead tr:nth-child(2) th { top: 22px; }
  thead tr:nth-child(3) th { top: 44px; }

  /* 派生列宽缩水 */
  .grid-table thead th.open-extra-head,
  .grid-table tbody td.open-extra-cell {
    width: 64px; min-width: 64px; max-width: 64px;
    font-size: 11px; letter-spacing: 0.06em;
  }

  /* 说明块: 更紧凑 */
  .view-desc {
    padding: 8px 10px 10px;
    font-size: 11px;
    line-height: 1.55;
  }
  .view-desc-label { font-size: 10px; padding: 1px 6px; }

  /* 统计页脚字号 */
  .stat-foot .stat-label { font-size: 10px; padding-right: 4px; }
  .stat-foot .stat-val { font-size: 10px; }
}

/* ── 小屏 (≤420px) — 微调更激进 ── */
@media (max-width: 420px) {
  thead tr:nth-child(3) th:nth-child(n+3):nth-child(-n+32),
  tbody td:nth-child(n+3):nth-child(-n+32) {
    width: 22px; min-width: 22px; max-width: 22px;
  }
  .hit-badge { width: 16px; height: 16px; font-size: 9px; }
  .controls select, .controls button { font-size: 11px; padding: 0 8px; }
}

/* ════════════════════════════════════════════════════════════
   预选区 (位于最新一期下方) — 用户在此点击数字组合预测，可多行。
   ──────────────────────────────────────────────────────────── */
.sel-row > td {
  background: linear-gradient(rgba(13, 110, 253, 0.07), rgba(13, 110, 253, 0.07)) !important;
  background-color: var(--surface) !important;
  height: 32px;
}
.sel-row:first-of-type > td {
  border-top: 2px solid var(--blue) !important;
}
body.dark .sel-row > td {
  background: linear-gradient(rgba(88, 166, 255, 0.12), rgba(88, 166, 255, 0.12)) !important;
}
.sel-row .sel-label {
  font-weight: 600;
  color: var(--blue);
  font-size: 11px;
  letter-spacing: 0.04em;
  white-space: nowrap;
  position: sticky;
  left: 0;
  z-index: 6;
}
.sel-row .sel-cell { position: relative; cursor: pointer; }
.sel-row .sel-hit .hit-badge { opacity: 0.95; }
.sel-row .sel-cell.pickable:hover {
  background: rgba(13, 110, 253, 0.16) !important;
  box-shadow: inset 0 0 0 2px rgba(13, 110, 253, 0.45);
}
.sel-row .sel-actions {
  position: sticky;
  right: 0;
  background: var(--surface) !important;
  z-index: 5;
  padding: 0 4px !important;
  border-left: 1px solid var(--grid-soft);
}
.sel-del-btn {
  background: transparent;
  border: 1px solid var(--grid);
  color: var(--muted);
  width: 22px; height: 22px;
  border-radius: 50%;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.12s;
}
.sel-del-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(192, 57, 43, 0.08);
}
/* + 添加一行预测 — 跨整行的按钮带；按钮 sticky-left 保证视口内一直可见 */
.sel-add-row > td.sel-add-cell {
  padding: 0 !important;
  background: linear-gradient(rgba(13, 110, 253, 0.04), rgba(13, 110, 253, 0.04)) !important;
  border-bottom: 2px solid var(--blue) !important;
  height: 28px;
  text-align: left;
}
.sel-add-btn {
  position: sticky;
  left: 8px;
  background: transparent;
  border: 1px dashed rgba(13, 110, 253, 0.5);
  color: var(--blue);
  border-radius: 12px;
  padding: 3px 14px;
  font-size: 12px;
  margin-left: 8px;
  cursor: pointer;
  transition: all 0.15s;
  z-index: 5;
}
.sel-add-btn:hover {
  background: rgba(13, 110, 253, 0.12);
  border-style: solid;
}
@media (max-width: 768px) {
  .sel-row > td { height: 26px !important; }
  .sel-row .sel-label { font-size: 10px; }
  .sel-del-btn { width: 18px; height: 18px; font-size: 11px; }
  .sel-add-btn { padding: 2px 10px; font-size: 11px; }
}

/* ════════════════════════════════════════════════════════════
   模拟选号 (Pick-to-Bet)
   ──────────────────────────────────────────────────────────── */

/* 可点击 cell：默认仅鼠标手势变化，hover 加蓝环 + 微抬 */
td.pickable { cursor: pointer; user-select: none; transition: box-shadow 0.12s; }
td.pickable:hover {
  background: rgba(13, 110, 253, 0.10);
  box-shadow: inset 0 0 0 2px rgba(13, 110, 253, 0.45);
}
body.dark td.pickable:hover {
  background: rgba(88, 166, 255, 0.14);
  box-shadow: inset 0 0 0 2px rgba(88, 166, 255, 0.55);
}

td.cell-picked {
  position: relative;
  background: rgba(13, 110, 253, 0.10);
  box-shadow: inset 0 0 0 2px rgba(13, 110, 253, 0.55);
}
body.dark td.cell-picked {
  background: rgba(88, 166, 255, 0.14);
  box-shadow: inset 0 0 0 2px rgba(88, 166, 255, 0.65);
}
td.cell-picked::after {
  content: "✓";
  position: absolute;
  top: 0; right: 1px;
  font-size: 9px;
  color: var(--blue);
  font-weight: 600;
  pointer-events: none;
}
td.cell-picked.hit-cell { box-shadow: inset 0 0 0 2px var(--blue); }

/* 每个视图卡片顶部的选号面板 — 醒目蓝条引导，让用户立刻明白要点表格 */
.select-panel {
  border-bottom: 1px solid var(--grid-soft);
  padding: 10px 14px;
  background: linear-gradient(180deg, rgba(13, 110, 253, 0.08), rgba(13, 110, 253, 0.02));
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
}
body.dark .select-panel {
  background: linear-gradient(180deg, rgba(88, 166, 255, 0.10), rgba(88, 166, 255, 0.02));
}
.select-panel.active {
  background: linear-gradient(180deg, rgba(13, 110, 253, 0.12), rgba(13, 110, 253, 0.04));
}
.select-empty {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}
.select-empty-icon { font-size: 18px; }
.select-empty-text { display: inline-flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.select-empty-text strong {
  color: var(--blue);
  font-weight: 600;
}

.select-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.select-slot {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--grid-soft);
  border-radius: 8px;
  padding: 4px 8px;
  flex-wrap: wrap;
}
.select-slot-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  margin-right: 2px;
}
.select-slot-chips { display: inline-flex; flex-wrap: wrap; gap: 4px; }

.pick-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 6px 2px 8px;
  border-radius: 12px;
  border: 1px solid var(--blue);
  background: rgba(13, 110, 253, 0.10);
  color: var(--blue);
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.pick-chip:hover { background: rgba(13, 110, 253, 0.18); }
.pick-chip-x {
  font-size: 11px;
  opacity: 0.65;
  margin-left: 2px;
}
.pick-chip-static {
  cursor: default;
  border-color: var(--grid);
  color: var(--ink);
  background: var(--surface-2);
}
.pick-chip-static:hover { background: var(--surface-2); }

.select-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.select-summary {
  font-size: 13px;
  color: var(--ink);
}
.select-summary strong { color: var(--blue); font-family: var(--font-mono); }
.select-clear {
  background: transparent;
  border: 1px solid var(--grid);
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 12px;
  color: var(--muted);
}
.select-clear:hover { background: var(--surface-3); color: var(--ink); }

/* 悬浮"我的选号"按钮 */
.picks-fab {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 80;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  height: 48px;
  border-radius: 24px;
  border: 1px solid var(--grid);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  transition: transform 0.15s, box-shadow 0.15s;
}
.picks-fab:hover { transform: translateY(-2px); }
.picks-fab.has-picks {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}
.picks-fab-icon { font-size: 18px; }
.picks-fab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.25);
  font-family: var(--font-mono);
  font-size: 12px;
}
.picks-fab:not(.has-picks) .picks-fab-count {
  background: var(--surface-3);
  color: var(--muted);
}

/* 全局选号弹层 */
.picks-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
}
.picks-modal.open { display: block; }
.picks-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}
body.dark .picks-modal-backdrop { background: rgba(0, 0, 0, 0.6); }
.picks-modal-panel {
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: min(440px, calc(100vw - 32px));
  max-height: min(720px, calc(100vh - 32px));
  background: var(--surface);
  border-radius: 14px;
  border: 1px solid var(--grid);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.18);
}
.picks-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--grid-soft);
}
.picks-modal-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}
.picks-modal-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 16px;
  padding: 4px 8px;
}
.picks-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.picks-modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--grid-soft);
}

.ghost-btn {
  background: transparent;
  border: 1px solid var(--grid);
  color: var(--muted);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 12px;
}
.ghost-btn:hover { background: var(--surface-3); color: var(--ink); }
.primary-btn {
  background: var(--blue);
  border: 1px solid var(--blue);
  color: #fff;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 13px;
}
.primary-btn:hover { opacity: 0.9; }

.mp-empty {
  color: var(--dim);
  font-size: 13px;
  text-align: center;
  padding: 36px 0;
}
.mp-view {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--grid-soft);
}
.mp-view:last-child { border-bottom: none; padding-bottom: 0; }
.mp-view-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
}
.mp-view-head strong { color: var(--ink); font-weight: 600; }
.mp-dim { color: var(--dim); font-size: 12px; }
.mp-slots {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.mp-slot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 12px;
}
.mp-slot-label {
  color: var(--muted);
  margin-right: 4px;
}
.mp-summary {
  font-size: 12px;
  color: var(--ink);
}
.mp-summary strong { color: var(--blue); font-family: var(--font-mono); }
.mp-pool { background: var(--surface-2); margin: -4px -4px 8px; padding: 10px 12px; border-radius: 8px; border-bottom: 1px solid var(--grid-soft); }
.mp-pool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
  gap: 4px;
  margin-top: 4px;
}
.pool-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 0;
  background: var(--surface);
  border: 1px solid var(--grid-soft);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink);
}

/* 手机端：选号面板贴底部 sticky，FAB 缩小，弹层全屏 */
@media (max-width: 768px) {
  .picks-fab {
    bottom: 12px;
    right: 12px;
    height: 44px;
    padding: 0 14px;
    font-size: 13px;
  }
  .picks-modal-panel {
    right: 0;
    bottom: 0;
    width: 100vw;
    max-height: 90vh;
    border-radius: 14px 14px 0 0;
  }
  .select-panel {
    padding: 4px 8px;
    font-size: 11px;
  }
  .select-slot { padding: 2px 5px; }
  .select-slot-label { font-size: 11px; }
  .pick-chip { font-size: 11px; padding: 1px 5px 1px 6px; }
  .pool-num { font-size: 11px; }
  /* 空闲态精简成一行 — 不占首屏空间 */
  .select-panel:not(.active) .select-empty {
    font-size: 11px;
    gap: 6px;
  }
  .select-panel:not(.active) .select-empty-icon { font-size: 13px; }
  .select-panel:not(.active) .select-empty-text {
    flex-wrap: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .select-panel:not(.active) .select-empty-text strong { font-size: 11px; }
}
@media (max-width: 420px) {
  .picks-fab span:not(.picks-fab-icon):not(.picks-fab-count) { display: none; }
  .picks-fab { padding: 0 12px; }
}

/* ─────────────────────────────────────────────────────────────
   下期条件推荐 (reco-card)
   ───────────────────────────────────────────────────────────── */
.reco-card {
  margin: 12px 0 16px;
  border: 1px solid var(--grid);
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
}
.reco-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-bottom: 1px solid var(--grid-soft);
  background: var(--surface-2);
}
.reco-title { display: flex; flex-direction: column; gap: 2px; }
.reco-title strong { font-size: 15px; font-weight: 600; color: var(--ink); }
.reco-sub { font-size: 12px; color: var(--dim); }
.reco-controls { display: flex; align-items: center; gap: 8px; }
.reco-window { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--dim); }
.reco-window select {
  border: 1px solid var(--grid);
  background: var(--surface);
  color: var(--ink);
  border-radius: 7px;
  padding: 4px 8px;
  font-size: 12px;
}
.reco-mini-btn {
  border: 1px solid var(--grid);
  background: var(--surface);
  color: var(--ink);
  border-radius: 7px;
  padding: 5px 11px;
  font-size: 12px;
  cursor: pointer;
}
.reco-mini-btn:hover { border-color: var(--blue); color: var(--blue); }

.reco-body {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 2px;
  background: var(--grid-soft);
}
.reco-card.collapsed .reco-body { display: none; }

.reco-block {
  padding: 12px 16px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.reco-block-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.reco-block-title { font-size: 13px; font-weight: 600; color: var(--ink); }
.reco-block-hint { font-size: 11px; color: var(--dim); }
.reco-chips { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }

.reco-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  min-width: 22px;
  justify-content: center;
  padding: 3px 7px;
  border-radius: 7px;
  border: 1px solid var(--grid);
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink);
  line-height: 1.1;
}
.reco-chip .reco-freq { font-size: 10px; color: var(--dim); }
/* recommended (kept) — blue accent */
.reco-chip.reco-on {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: var(--blue);
}
.reco-chip.reco-on .reco-freq { color: var(--blue); opacity: 0.75; }
/* hot key digit — red accent */
.reco-chip.reco-hot {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}
.reco-chip.reco-hot .reco-freq { color: var(--accent); opacity: 0.75; }
/* kill / cold — dimmed + strike */
.reco-chip.reco-kill {
  border-style: dashed;
  color: var(--dim);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
  opacity: 0.7;
}

.reco-range {
  font-family: var(--font-mono);
  font-size: 18px;
  color: var(--ink);
}
.reco-range .reco-range-core { color: var(--blue); }
.reco-pill-row { display: flex; flex-wrap: wrap; gap: 6px; }
.reco-pill {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--grid);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-mono);
}
.reco-pill .reco-freq { color: var(--dim); font-size: 10px; margin-left: 3px; }
.reco-pill.reco-on { border-color: var(--blue); background: var(--blue-soft); color: var(--blue); }
.reco-pill.reco-on .reco-freq { color: var(--blue); opacity: 0.75; }

.reco-note { font-size: 11px; color: var(--dim); line-height: 1.5; }
.reco-pos-row { display: flex; align-items: center; gap: 8px; }
.reco-pos-label {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--dim);
  width: 34px;
}

/* ─────────────────────────────────────────────────────────────
   自然语言查询 (nlq-card)
   ───────────────────────────────────────────────────────────── */
.nlq-card {
  margin: 0 0 16px;
  border: 1px solid var(--grid);
  border-radius: 12px;
  background: var(--surface);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.nlq-title { display: flex; flex-direction: column; gap: 2px; }
.nlq-title strong { font-size: 15px; font-weight: 600; color: var(--ink); }
.nlq-sub { font-size: 12px; color: var(--dim); }
.nlq-input-row { display: flex; gap: 8px; }
.nlq-input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--grid);
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
}
.nlq-input:focus { outline: none; border-color: var(--blue); }
.nlq-run {
  flex: 0 0 auto;
  border: 1px solid var(--blue);
  background: var(--blue);
  color: #fff;
  border-radius: 8px;
  padding: 9px 20px;
  font-size: 14px;
  cursor: pointer;
}
.nlq-run:disabled { opacity: 0.55; cursor: default; }
.nlq-examples { display: flex; flex-wrap: wrap; gap: 6px; }
.nlq-example {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px dashed var(--grid);
  background: var(--surface);
  color: var(--dim);
  cursor: pointer;
}
.nlq-example:hover { border-style: solid; border-color: var(--blue); color: var(--blue); }

.nlq-result { display: none; flex-direction: column; gap: 12px; }
.nlq-result.show { display: flex; }
.nlq-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--grid-soft);
}
.nlq-engine {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--grid);
  color: var(--dim);
}
.nlq-engine.rules { border-color: var(--green); color: var(--green); background: var(--green-soft); }
.nlq-engine.llm { border-color: var(--blue); color: var(--blue); background: var(--blue-soft); }
.nlq-engine.none { border-color: var(--amber); color: var(--amber); background: var(--amber-soft); }
.nlq-cond {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 7px;
  background: var(--blue-soft);
  border: 1px solid var(--blue);
  color: var(--blue);
  font-family: var(--font-mono);
}
.nlq-count { font-size: 13px; color: var(--ink); }
.nlq-count strong { color: var(--accent); font-family: var(--font-mono); font-size: 15px; }
.nlq-msg { font-size: 12px; color: var(--dim); }

.nlq-stats { display: flex; flex-wrap: wrap; gap: 18px; font-size: 12px; }
.nlq-stat-group { display: flex; flex-direction: column; gap: 4px; }
.nlq-stat-label { font-size: 11px; color: var(--dim); }
.nlq-stat-val { font-family: var(--font-mono); font-size: 13px; color: var(--ink); }
.nlq-stat-val .hot { color: var(--accent); }

.nlq-list-wrap { max-height: 320px; overflow-y: auto; border: 1px solid var(--grid-soft); border-radius: 8px; }
.nlq-list { width: 100%; border-collapse: collapse; font-size: 13px; }
.nlq-list th, .nlq-list td { padding: 6px 10px; text-align: center; border-bottom: 1px solid var(--grid-soft); }
.nlq-list th { position: sticky; top: 0; background: var(--surface-2); color: var(--dim); font-weight: 500; font-size: 12px; }
.nlq-list td { font-family: var(--font-mono); color: var(--ink); }
.nlq-list td.nlq-code { letter-spacing: 2px; color: var(--accent); }
.nlq-list tr:last-child td { border-bottom: none; }
.nlq-more { font-size: 11px; color: var(--dim); text-align: center; padding: 8px; }

/* 自然语言查询 — 枚举/缺失结果网格 */
.nlq-miss-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
  padding: 2px;
}
.nlq-miss {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 1px;
  padding: 4px 9px;
  border-radius: 7px;
  border: 1px solid var(--grid);
  background: var(--surface-2);
  color: var(--ink);
}
