:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --border: #e5e9f2;
  --border-strong: #d3dae8;
  --text: #182230;
  --text-sub: #5b677a;
  --text-muted: #8491a5;
  --red: #e11d48;
  --red-dark: #be123c;
  --red-soft: #fff1f2;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-soft: #eff6ff;
  --gold: #d97706;
  --gold-soft: #fffbeb;
  --green: #059669;
  --green-soft: #ecfdf5;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, .06);
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ───────── 顶部栏 ───────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, #fb7185, #e11d48 65%, #9f1239);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 10px rgba(225, 29, 72, .28);
  flex-shrink: 0;
}

.brand b { display: block; font-size: 16px; line-height: 1.2; color: var(--text); }
.brand small { display: block; font-size: 11.5px; color: var(--text-muted); }

.tabs {
  display: flex;
  gap: 6px;
  background: var(--bg);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.tabs button {
  border: none;
  background: transparent;
  color: var(--text-sub);
  padding: 7px 16px;
  border-radius: 7px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: .15s;
}

.tabs button:hover { color: var(--text); }
.tabs button.active {
  background: var(--surface);
  color: var(--red);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--green);
  background: var(--green-soft);
  border: 1px solid #a7f3d0;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.status-pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
}

.status-pill.offline {
  color: var(--red);
  background: var(--red-soft);
  border-color: #fecdd3;
}
.status-pill.offline .dot { background: var(--red); }

.admin-chip {
  font-size: 12px;
  color: var(--text-sub);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 999px;
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ───────── 主容器 ───────── */
main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.view { display: none; flex-direction: column; gap: 18px; }
.view.active { display: flex; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.card-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.sub { color: var(--text-sub); font-size: 13px; }
.muted { color: var(--text-muted); font-size: 12.5px; }

/* ───────── 球体样式 ───────── */
.balls { display: inline-flex; align-items: center; gap: 7px; flex-wrap: wrap; }

.ball {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  user-select: none;
}

.ball.r {
  background: radial-gradient(circle at 32% 28%, #fb7185, #e11d48 64%, #be123c);
  box-shadow: 0 3px 8px rgba(225, 29, 72, .25);
}

.ball.b {
  background: radial-gradient(circle at 32% 28%, #60a5fa, #2563eb 64%, #1d4ed8);
  box-shadow: 0 3px 8px rgba(37, 99, 235, .25);
}

.ball.lg { width: 42px; height: 42px; font-size: 16px; }
.ball.sm { width: 28px; height: 28px; font-size: 12px; }
.ball.dim { opacity: .28; box-shadow: none; }
.ball.hit-ring { box-shadow: 0 0 0 3px #fde047, 0 4px 10px rgba(225, 29, 72, .35); }
.ball-plus { color: var(--text-muted); font-weight: 700; margin: 0 2px; }

/* ───────── 按钮与表单 ───────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 9px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: .15s;
}
.btn:hover { background: var(--surface-soft); border-color: #b7c3d6; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn.primary {
  background: linear-gradient(180deg, #f43f5e, #e11d48);
  border-color: #be123c;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(225, 29, 72, .22);
}
.btn.primary:hover { filter: brightness(1.05); }
.btn.blue {
  background: linear-gradient(180deg, #3b82f6, #2563eb);
  border-color: #1d4ed8;
  color: #fff;
  font-weight: 600;
}
.btn.blue:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-sub); }
.btn.ghost:hover { background: var(--bg); color: var(--text); }

input, select {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 9px;
  font: inherit;
  font-size: 13.5px;
  outline: none;
  transition: .15s;
}
input:focus, select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

/* ───────── 最新开奖横幅 ───────── */
.hero-draw {
  background: linear-gradient(135deg, #ffffff 0%, #fff7f8 55%, #f4f8ff 100%);
  border: 1px solid #f2dbe0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.hero-left { display: flex; flex-direction: column; gap: 12px; }
.hero-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.issue-badge {
  background: var(--red);
  color: #fff;
  font-weight: 700;
  font-size: 12.5px;
  padding: 3px 10px;
  border-radius: 999px;
}

.hero-kpis {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  padding-top: 4px;
}
.hero-kpi { display: flex; flex-direction: column; }
.hero-kpi span { font-size: 12px; color: var(--text-muted); }
.hero-kpi strong { font-size: 16px; color: var(--text); font-family: var(--mono); }
.hero-kpi strong.gold { color: var(--gold); }

.hero-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.schedule-tip {
  font-size: 12.5px;
  color: var(--text-sub);
  background: rgba(255, 255, 255, .85);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 9px;
}

/* ───────── 选号主网格 ───────── */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: start;
}
@media (max-width: 960px) {
  .two-col { grid-template-columns: 1fr; }
  .hero-right { align-items: flex-start; }
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.mode-btn {
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  cursor: pointer;
  transition: .15s;
}
.mode-btn:hover { border-color: #fda4af; background: #fffafb; }
.mode-btn.active {
  border-color: var(--red);
  background: var(--red-soft);
  box-shadow: 0 0 0 2px rgba(225, 29, 72, .08);
}
.mode-btn strong { display: block; font-size: 13.5px; color: var(--text); }
.mode-btn span { display: block; font-size: 11.5px; color: var(--text-sub); margin-top: 2px; }

.pick-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.seg {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-soft);
}
.seg button {
  border: none;
  background: transparent;
  padding: 6px 12px;
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  color: var(--text-sub);
}
.seg button.active { background: var(--text); color: #fff; font-weight: 600; }

.ticket-list { display: flex; flex-direction: column; gap: 10px; }
.ticket-row {
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 12px 14px;
  background: var(--surface-soft);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ticket-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.ticket-tags {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-sub);
}
.chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text-sub);
}
.chip.ok { background: var(--green-soft); color: var(--green); border-color: #a7f3d0; }
.chip.warn { background: var(--gold-soft); color: var(--gold); border-color: #fde68a; }

/* ───────── 自选球盘 & 历史查重 ───────── */
.picker-section { margin-bottom: 14px; }
.picker-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
}
.ball-grid {
  display: grid;
  grid-template-columns: repeat(11, 1fr);
  gap: 6px;
}
.ball-grid.blue-grid { grid-template-columns: repeat(8, 1fr); }
@media (max-width: 560px) {
  .ball-grid { grid-template-columns: repeat(7, 1fr); }
  .ball-grid.blue-grid { grid-template-columns: repeat(8, 1fr); }
}

.pick-ball {
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: .12s;
  padding: 0;
}
.pick-ball.r:hover { border-color: var(--red); color: var(--red); background: var(--red-soft); }
.pick-ball.r.selected {
  background: radial-gradient(circle at 32% 28%, #fb7185, #e11d48 65%, #be123c);
  border-color: var(--red-dark);
  color: #fff;
  box-shadow: 0 3px 8px rgba(225, 29, 72, .3);
}
.pick-ball.b:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-soft); }
.pick-ball.b.selected {
  background: radial-gradient(circle at 32% 28%, #60a5fa, #2563eb 65%, #1d4ed8);
  border-color: var(--blue-dark);
  color: #fff;
  box-shadow: 0 3px 8px rgba(37, 99, 235, .3);
}

.check-result {
  margin-top: 14px;
  padding: 14px;
  border-radius: 11px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
}
.prize-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin: 10px 0 12px;
}
@media (max-width: 640px) { .prize-grid { grid-template-columns: repeat(3, 1fr); } }
.prize-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 6px;
  text-align: center;
}
.prize-box.has { border-color: #f59e0b; background: var(--gold-soft); }
.prize-box span { display: block; font-size: 11.5px; color: var(--text-sub); }
.prize-box strong { display: block; font-size: 17px; font-family: var(--mono); color: var(--text); margin-top: 2px; }
.prize-box.has strong { color: var(--gold); }

.hit-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.hit-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12.5px;
}

/* ───────── 小白说明与中奖规则 ───────── */
.guide-details {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px 20px;
}
.guide-details summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.guide-details summary::-webkit-details-marker { display: none; }
.guide-body { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 14px; }
.disclaimer {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 9px;
  background: var(--gold-soft);
  border: 1px solid #fde68a;
  color: #92400e;
  font-size: 12.5px;
}

/* ───────── 冷热走势 ───────── */
.insight-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
@media (max-width: 960px) { .insight-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 540px) { .insight-grid { grid-template-columns: 1fr; } }

.insight-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.insight-card h3 { margin: 0 0 4px; font-size: 14px; font-weight: 700; }
.insight-card .muted { display: block; margin-bottom: 12px; }
.mini-balls { display: flex; gap: 8px; flex-wrap: wrap; }
.mini-ball-col { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.mini-ball-col small { font-size: 11px; color: var(--text-sub); font-family: var(--mono); }

.bars {
  display: grid;
  grid-template-columns: repeat(33, 1fr);
  gap: 4px;
  align-items: end;
  height: 150px;
  padding-top: 14px;
}
.bars.blue-bars { grid-template-columns: repeat(16, 1fr); }
.bar {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  height: 100%;
  gap: 4px;
}
.bar .cnt { font-size: 9.5px; color: var(--text-muted); font-family: var(--mono); }
.bar .fill {
  width: 100%;
  min-height: 4px;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, #fb7185, #e11d48);
  transition: height .35s;
}
.bars.blue-bars .fill { background: linear-gradient(180deg, #60a5fa, #2563eb); }
.bar .lbl { font-family: var(--mono); font-size: 10px; color: var(--text-sub); font-weight: 600; }

.ratio-list { display: flex; flex-direction: column; gap: 12px; }
.ratio-row { display: flex; flex-direction: column; gap: 5px; }
.ratio-head { display: flex; justify-content: space-between; font-size: 13px; }
.ratio-track { height: 10px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.ratio-fill { height: 100%; background: linear-gradient(90deg, #f43f5e, #fb7185); border-radius: 999px; }
.ratio-fill.blue { background: linear-gradient(90deg, #2563eb, #60a5fa); }

/* ───────── 历史开奖 & 完整度 ───────── */
.audit-banner {
  background: var(--green-soft);
  border: 1px solid #a7f3d0;
  border-radius: var(--radius);
  padding: 14px 18px;
  color: #065f46;
}
.audit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.audit-years {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed #6ee7b7;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 6px;
}
.audit-yr {
  background: rgba(255, 255, 255, .82);
  border: 1px solid #a7f3d0;
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 12px;
  font-family: var(--mono);
  display: flex;
  justify-content: space-between;
}

.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.spacer { flex: 1; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: var(--surface-soft); color: var(--text-sub); font-weight: 600; font-size: 12.5px; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafcff; }
td.num, th.num { font-family: var(--mono); text-align: right; }

.pager {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 14px;
  flex-wrap: wrap;
}
.pager button {
  min-width: 34px;
  height: 32px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-sub);
  font-family: var(--mono);
  font-size: 12.5px;
  cursor: pointer;
}
.pager button.cur { background: var(--red); border-color: var(--red); color: #fff; font-weight: 700; }
.pager .info { color: var(--text-muted); font-size: 12.5px; margin-left: 6px; }

.foot {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  padding: 18px 20px 28px;
}

/* ───────── 管理员登录页 ───────── */
.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: radial-gradient(900px 500px at 15% 0%, #fff1f2 0%, transparent 55%),
              radial-gradient(900px 500px at 85% 100%, #eff6ff 0%, transparent 55%),
              var(--bg);
}
.login-shell { width: 100%; max-width: 410px; }
.login-card { padding: 30px 28px; box-shadow: var(--shadow-md); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.login-brand h1 { margin: 0; font-size: 20px; color: var(--text); }
.login-brand p { margin: 2px 0 0; font-size: 12.5px; color: var(--text-muted); }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-sub); }
.pwd-wrap { display: flex; gap: 8px; }
.pwd-wrap input { flex: 1; min-width: 0; }
.login-error {
  padding: 9px 12px;
  border-radius: 9px;
  font-size: 12.5px;
  color: var(--red-dark);
  background: var(--red-soft);
  border: 1px solid #fecdd3;
}
.login-submit { width: 100%; padding: 10px 16px; margin-top: 4px; font-size: 14px; }
.login-note { margin: 16px 0 0; text-align: center; font-size: 12px; color: var(--text-muted); }

/* Toast */
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 99;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  background: #182230;
  color: #fff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, .22);
}
.toast.bad { background: var(--red-dark); }
