:root {
  --bg: #fcfcfb;
  --card: #ffffff;
  --border: #e5e4de;
  --grid: #e8e7e1;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #6f6e68;
  --series: #2a78d6;
  --series-ink: #1f66bc;
  --series-wash: rgba(42, 120, 214, 0.1);
  --good: #0a7a0a;
  --good-wash: rgba(12, 163, 12, 0.09);
  --critical: #c03434;
  --critical-wash: rgba(208, 59, 59, 0.09);
  --ball-red: #c0392b;
  --ball-blue: #2670c8;
  --shadow: 0 8px 28px rgba(15, 15, 15, 0.07);
  --focus: #2a78d6;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #141413;
  --card: #1d1d1c;
  --border: #33332f;
  --grid: #34342f;
  --text: #f0efec;
  --text-2: #c3c2b7;
  --muted: #96948b;
  --series: #3987e5;
  --series-ink: #7fb1ee;
  --series-wash: rgba(57, 135, 229, 0.14);
  --good: #5bd65b;
  --good-wash: rgba(91, 214, 91, 0.1);
  --critical: #ff8a8a;
  --critical-wash: rgba(255, 138, 138, 0.1);
  --ball-red: #c8433a;
  --ball-blue: #2f6fbf;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  --focus: #3987e5;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

h1, h2, p, ol, ul, figure {
  margin: 0;
}

ol, ul {
  padding: 0;
  list-style: none;
}

button {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- 顶栏 ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px max(16px, env(safe-area-inset-left)) 12px max(16px, env(safe-area-inset-right));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.brand-mark {
  position: relative;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--text);
  flex: none;
}

.brand-dot {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.brand-dot-red {
  left: 5px;
  top: 5px;
  background: #e05a4e;
}

.brand-dot-blue {
  right: 5px;
  bottom: 5px;
  background: #5a9cf0;
}

.brand-text {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.sim-badge {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 9px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--card);
  cursor: pointer;
}

.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-sun {
  display: none;
}

.icon-moon {
  fill: currentColor;
  stroke: none;
}

[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

/* ---------- 布局 ---------- */

.page {
  width: min(100%, 720px);
  margin: 0 auto;
  padding: 16px max(16px, env(safe-area-inset-left)) 40px max(16px, env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
}

.banner {
  border: 1px solid color-mix(in srgb, var(--critical) 35%, var(--border));
  background: var(--critical-wash);
  color: var(--text);
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 13px;
}

.eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.09em;
  color: var(--muted);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-head h2 {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin-top: 1px;
}

/* ---------- 权益 ---------- */

.hero {
  padding: 20px 18px 16px;
  background:
    radial-gradient(120% 150% at 100% 0%, var(--series-wash), transparent 55%),
    var(--card);
}

.hero-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.hero-date {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.hero-value {
  margin-top: 6px;
  font-size: clamp(38px, 12vw, 52px);
  font-weight: 650;
  letter-spacing: -0.035em;
  line-height: 1.08;
}

.hero-delta-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  margin-top: 10px;
}

.delta {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 650;
  border-radius: 999px;
  padding: 4px 10px;
  background: var(--good-wash);
  color: var(--good);
}

.delta.is-loss {
  background: var(--critical-wash);
  color: var(--critical);
}

.delta.is-flat {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
}

.delta-arrow {
  font-size: 9px;
  line-height: 1;
}

.hero-roi {
  font-size: 13px;
  color: var(--muted);
}

.hero-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}

/* ---------- 今日报表 ---------- */

.today-card {
  padding: 16px 18px;
}

.today-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.today-head h2 {
  margin-top: 1px;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.status-badge {
  flex: none;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 650;
  color: var(--text-2);
  white-space: nowrap;
}

.status-badge.is-wait {
  color: var(--series-ink);
  background: var(--series-wash);
  border-color: transparent;
}

.status-badge.is-gain {
  color: var(--good);
  background: var(--good-wash);
  border-color: transparent;
}

.status-badge.is-loss {
  color: var(--critical);
  background: var(--critical-wash);
  border-color: transparent;
}

.today-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.today-metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.today-label {
  font-size: 11.5px;
  color: var(--muted);
}

.today-value {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.today-value.is-gain { color: var(--good); }
.today-value.is-loss { color: var(--critical); }
.today-value.is-flat { color: var(--text-2); }

.today-note {
  margin-top: 10px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted);
}

/* ---------- KPI ---------- */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.kpi {
  padding: 14px;
  border-radius: 14px;
}

.kpi-label {
  font-size: 12px;
  color: var(--muted);
}

.kpi-value {
  margin-top: 3px;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.kpi-sub {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--muted);
}

/* ---------- 购买意图 ---------- */

.issue-badge {
  flex: none;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.03em;
  color: var(--series-ink);
  background: var(--series-wash);
  border-radius: 999px;
  padding: 5px 11px;
}

.plan-meta {
  font-size: 13px;
  color: var(--text-2);
  margin-top: -6px;
  margin-bottom: 12px;
}

.tickets {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.ticket {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ticket-main {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ticket-reason {
  margin-left: 30px;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--muted);
}

.ticket-rank {
  flex: none;
  width: 20px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.ticket-balls {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: nowrap;
}

.ball {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: #fff;
  flex: none;
}

.ball-red { background: var(--ball-red); }
.ball-blue { background: var(--ball-blue); }

.ball-plus {
  color: var(--muted);
  font-size: 12px;
  margin: 0 1px;
}

.plan-note {
  margin-top: 14px;
  padding-top: 11px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}

.plan-empty {
  padding: 18px 0 6px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- 购买思路 ---------- */

.why-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  counter-reset: why;
}

.why-list li {
  position: relative;
  padding-left: 22px;
  font-size: 13px;
  line-height: 1.62;
  color: var(--text-2);
}

.why-list li::before {
  counter-increment: why;
  content: counter(why);
  position: absolute;
  left: 0;
  top: 3px;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--series-wash);
  color: var(--series-ink);
  font-size: 10px;
  font-weight: 650;
}

.pool-block {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.pool-label {
  margin-bottom: 8px;
  font-size: 11.5px;
  color: var(--muted);
}

.pool {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
}

.pool-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.pool-num {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: #fff;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.pool-num-red { background: var(--ball-red); }
.pool-num-blue { background: var(--ball-blue); }

.pool-gap {
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
}

/* ---------- 图表 ---------- */

.chart-total {
  font-size: 14px;
  font-weight: 650;
  white-space: nowrap;
}

.chart-total.is-loss { color: var(--critical); }
.chart-total.is-gain { color: var(--good); }

.chart-figure {
  position: relative;
  margin: 0 -4px;
}

.chart-body {
  min-height: 120px;
}

.chart-body svg {
  display: block;
  width: 100%;
  height: auto;
  touch-action: pan-y;
}

.chart-body svg:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

.axis-text {
  fill: var(--muted);
  font-size: 10.5px;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
}

.grid-line {
  stroke: var(--grid);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.zero-line {
  stroke: var(--muted);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  opacity: 0.7;
  shape-rendering: crispEdges;
}

.series-line {
  fill: none;
  stroke: var(--series);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.series-area {
  fill: var(--series-wash);
  stroke: none;
}

.end-dot {
  fill: var(--series);
  stroke: var(--card);
  stroke-width: 2;
}

.crosshair {
  stroke: var(--muted);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  opacity: 0.75;
}

.hover-dot {
  fill: var(--series);
  stroke: var(--card);
  stroke-width: 2;
}

.hover-dot-ring {
  fill: var(--series);
  opacity: 0.18;
}

.tooltip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  min-width: 150px;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--shadow);
  font-size: 12px;
  transform: translate(-50%, calc(-100% - 12px));
}

.tooltip.is-below {
  transform: translate(-50%, 12px);
}

.tt-issue {
  font-weight: 650;
  margin-bottom: 3px;
}

.tt-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: var(--muted);
  white-space: nowrap;
}

.tt-row strong {
  color: var(--text);
  font-weight: 600;
}

.tt-row strong.is-loss { color: var(--critical); }
.tt-row strong.is-gain { color: var(--good); }

.chart-hint {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--muted);
  text-align: center;
}

.empty {
  padding: 26px 8px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.data-details {
  margin-top: 10px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.data-details summary {
  cursor: pointer;
  font-size: 12.5px;
  color: var(--series-ink);
  width: fit-content;
  padding: 2px 0;
}

.table-scroll {
  max-height: 300px;
  overflow: auto;
  margin-top: 8px;
}

.data-details table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.data-details th,
.data-details td {
  padding: 7px 6px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-details th {
  position: sticky;
  top: 0;
  background: var(--card);
  color: var(--muted);
  font-weight: 600;
  font-size: 11.5px;
}

.data-details .num {
  text-align: right;
}

.data-details .is-loss { color: var(--critical); }
.data-details .is-gain { color: var(--good); }

/* ---------- 最近结算 ---------- */

.recent-list {
  display: flex;
  flex-direction: column;
}

.settle-item {
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.settle-item:first-child {
  border-top: 0;
  padding-top: 0;
}

.settle-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.settle-issue {
  font-size: 14px;
  font-weight: 650;
}

.settle-pnl {
  font-size: 14px;
  font-weight: 650;
}

.settle-pnl.is-loss { color: var(--critical); }
.settle-pnl.is-gain { color: var(--good); }
.settle-pnl.is-flat { color: var(--text-2); }

.settle-sub {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}

.settle-draw {
  font-variant-numeric: tabular-nums;
}

.settle-details {
  margin-top: 6px;
}

.settle-details summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--series-ink);
  width: fit-content;
  padding: 2px 0;
}

.ticket-detail {
  padding: 5px 0 0 12px;
  font-size: 12px;
  color: var(--text-2);
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.mini-rank {
  color: var(--muted);
  font-size: 11px;
  width: 18px;
  flex: none;
}

.mini-nums {
  font-variant-numeric: tabular-nums;
}

.mini-prize {
  margin-left: auto;
  color: var(--muted);
  white-space: nowrap;
}

.mini-prize.is-win {
  color: var(--good);
  font-weight: 600;
}

/* ---------- 页脚 ---------- */

.footer {
  margin-top: 8px;
  padding: 0 4px;
  font-size: 11.5px;
  line-height: 1.65;
  color: var(--muted);
}

.footer p + p {
  margin-top: 5px;
}

.footer strong {
  color: var(--text-2);
}

.footer-meta {
  opacity: 0.8;
}

.noscript {
  margin: 20px;
  text-align: center;
}

/* ---------- 宽屏 ---------- */

@media (min-width: 640px) {
  .page {
    padding-top: 22px;
    gap: 16px;
  }

  .kpi-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .card {
    padding: 20px;
  }

  .hero {
    padding: 24px 22px 18px;
  }

  .ball {
    width: 32px;
    height: 32px;
    font-size: 13px;
  }

  .ticket-balls {
    gap: 7px;
  }

  .ticket-main {
    gap: 14px;
  }

  .ticket-rank {
    width: 26px;
    font-size: 12px;
  }

  .ticket-reason {
    margin-left: 40px;
    font-size: 12px;
  }

  .today-row {
    gap: 18px;
  }
}

@media (max-width: 359px) {
  .ball {
    width: 25px;
    height: 25px;
    font-size: 11px;
  }

  .ticket-balls {
    gap: 4px;
  }

  .card {
    padding: 15px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}
