:root {
  --bg: #f5f6fa;
  --card: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --line: #e6e8ef;
  --red: #d92f2f;
  --red-dark: #a91f1f;
  --red-soft: #fff0f0;
  --blue: #2f6fed;
  --blue-dark: #1c4fc0;
  --blue-soft: #eef4ff;
  --accent: #7c3aed;
  --shadow: 0 6px 24px rgba(31, 36, 48, 0.06);
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.container { width: min(1200px, calc(100% - 32px)); margin: 0 auto; }

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 0;
}

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

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: .5px;
  background: linear-gradient(135deg, #e04545, #b81f2f);
  box-shadow: 0 6px 16px rgba(217, 47, 47, .22);
}

.brand h1 { margin: 0; font-size: 21px; line-height: 1.25; }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; }

.data-badge {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}

main { padding: 24px 0 40px; }

.notice {
  display: flex;
  gap: 14px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 20px;
}

.notice-icon {
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #f59e0b;
  color: #fff;
  font-weight: 800;
  display: grid;
  place-items: center;
  margin-top: 2px;
}

.notice-body { flex: 1; font-size: 13px; color: #78350f; }
.notice-body strong { display: block; font-size: 14px; margin-bottom: 2px; }

.link-btn {
  border: 0;
  background: none;
  color: var(--blue);
  padding: 2px 0;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.math-panel { margin-top: 14px; }
.math-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.math-grid article { background: #fff; border: 1px solid #fde68a; border-radius: 12px; padding: 12px 14px; }
.math-grid h4 { margin: 0 0 6px; font-size: 13px; }
.math-grid code { display: block; color: #b45309; font-size: 12px; background: #fffbeb; padding: 4px 8px; border-radius: 6px; overflow-x: auto; }
.math-grid p { margin: 7px 0 0; font-size: 12px; color: #7c5a20; }

.layout { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, .92fr); gap: 20px; align-items: start; }
.right-col { display: grid; gap: 20px; }

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

.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 20px; }
.panel-head.compact { margin-bottom: 12px; align-items: center; }
.panel-head h2 { margin: 0; font-size: 17px; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }

.live-dot { color: #15803d; font-size: 12px; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.live-dot span { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px #dcfce7; }

.field { margin-bottom: 18px; }
.field-label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 9px; }

.mode-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }

.mode {
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 11px 13px;
  cursor: pointer;
  transition: .15s ease;
  font-family: inherit;
  color: var(--text);
}
.mode:hover { border-color: #f3b4b4; background: #fffafa; }
.mode.active { border-color: var(--red); background: var(--red-soft); box-shadow: inset 0 0 0 1px var(--red); }
.mode-name { display: block; font-weight: 700; font-size: 13.5px; }
.mode-desc { display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.mode.active .mode-name { color: var(--red-dark); }

.mode-hint { margin: 9px 0 0; font-size: 12px; color: var(--muted); }

.lcg-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.lcg-row input {
  width: 150px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: #fff;
}
.lcg-row input:focus { outline: 2px solid #bfdbfe; border-color: var(--blue); }
.param { background: #f3f4f6; color: #4b5563; border-radius: 6px; padding: 4px 8px; font-size: 11.5px; font-family: ui-monospace, Menlo, Consolas, monospace; }
.tiny { margin: 7px 0 0; font-size: 11.5px; color: var(--muted); }

.count-field label strong { color: var(--red); }
.count-field input[type="range"] { width: 100%; accent-color: var(--red); }
.range-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }

.actions { display: flex; gap: 10px; margin: 4px 0 20px; }
.primary-btn, .ghost-btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  border-radius: 11px;
  padding: 11px 22px;
  cursor: pointer;
  transition: .15s ease;
}
.primary-btn { flex: 1; border: 0; color: #fff; background: linear-gradient(135deg, #e04545, #bd2020); box-shadow: 0 6px 14px rgba(217,47,47,.2); }
.primary-btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
.primary-btn:active { transform: translateY(0); }
.ghost-btn { border: 1px solid var(--line); background: #fff; color: var(--text); }
.ghost-btn:hover:not(:disabled) { border-color: var(--blue); color: var(--blue); }
.ghost-btn:disabled { opacity: .5; cursor: not-allowed; }

.tickets { display: grid; gap: 12px; }
.empty-state { text-align: center; padding: 36px 12px; color: var(--muted); border: 1px dashed var(--line); border-radius: 14px; }
.empty-ball { width: 46px; height: 46px; border-radius: 50%; margin: 0 auto 10px; display: grid; place-items: center; color: var(--red); font-size: 20px; font-weight: 800; border: 2px dashed #f0a9a9; }
.empty-state p { margin: 0; font-weight: 600; color: var(--text); }
.empty-state span { font-size: 12px; }

.ticket { border: 1px solid var(--line); border-radius: 13px; padding: 13px 14px; background: #fcfcfd; animation: pop .25s ease both; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.ticket-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.ticket-title { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.tag { font-size: 11px; background: var(--blue-soft); color: var(--blue); padding: 3px 8px; border-radius: 999px; }
.tag.ent { background: #f3e8ff; color: #7e22ce; }
.balls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ball {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 800;
  color: #fff;
  font-variant-numeric: tabular-nums;
}
.ball.red { background: radial-gradient(circle at 32% 28%, #ff7b7b, var(--red) 58%, var(--red-dark)); box-shadow: 0 3px 8px rgba(217,47,47,.22); }
.ball.blue { background: radial-gradient(circle at 32% 28%, #7db0ff, var(--blue) 58%, var(--blue-dark)); box-shadow: 0 3px 8px rgba(47,111,237,.22); }
.ball-sep { color: var(--muted); font-size: 18px; margin: 0 2px; }
.ticket-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 10px; font-size: 11.5px; color: var(--muted); }
.ticket-foot .copy-one { border: 0; background: none; color: var(--blue); cursor: pointer; font-size: 11.5px; font-weight: 600; }
.ticket-foot .copy-one:hover { text-decoration: underline; }

.summary { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 18px; }
.sum-card { background: #f9fafb; border: 1px solid var(--line); border-radius: 11px; padding: 10px 12px; }
.sum-card .label { font-size: 11.5px; color: var(--muted); }
.sum-card .value { font-size: 16px; font-weight: 800; margin-top: 2px; }
.sum-card .value.red { color: var(--red); }
.sum-card .value.blue { color: var(--blue); }

.tabs { display: flex; gap: 6px; background: #f3f4f6; padding: 4px; border-radius: 10px; margin-bottom: 16px; }
.tab { flex: 1; border: 0; background: transparent; color: var(--muted); padding: 7px 4px; border-radius: 7px; cursor: pointer; font: inherit; font-size: 12px; font-weight: 600; }
.tab.active { background: #fff; color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.08); }

.chart { display: flex; align-items: flex-end; gap: 3px; height: 186px; padding: 8px 4px 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.bar-item { flex: 1 0 13px; min-width: 13px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; position: relative; }
.bar { width: 100%; max-width: 22px; border-radius: 4px 4px 0 0; background: linear-gradient(180deg, #ef6a6a, var(--red)); height: var(--h); min-height: 3px; transition: height .35s ease; }
.bar.blue { background: linear-gradient(180deg, #78a8ff, var(--blue)); }
.bar.omit { background: linear-gradient(180deg, #c4b5fd, #7c3aed); }
.bar-label { font-size: 10px; color: var(--muted); margin-top: 5px; font-variant-numeric: tabular-nums; }
.bar-value { position: absolute; top: -2px; font-size: 10px; color: var(--text); opacity: 0; transition: opacity .15s; background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 0 3px; z-index: 1; }
.bar-item:hover .bar-value { opacity: 1; }
.chart-note { margin: 9px 0 0; font-size: 11.5px; color: var(--muted); }

.table-wrap { max-height: 340px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
thead th { position: sticky; top: 0; background: #f9fafb; color: var(--muted); font-weight: 600; text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody td { padding: 8px 10px; border-bottom: 1px solid #f0f1f5; white-space: nowrap; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafafa; }
td .ball-num { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; color: #fff; font-size: 10.5px; font-weight: 700; margin-right: 3px; }
.ball-num.r { background: var(--red); }
.ball-num.b { background: var(--blue); }

footer { text-align: center; color: var(--muted); font-size: 11.5px; padding: 16px 0 0; }
footer p { margin: 4px 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  background: #1f2430;
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: .25s ease;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .math-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .container { width: calc(100% - 20px); }
  .topbar-inner { flex-direction: column; align-items: flex-start; }
  .panel { padding: 16px; }
  .mode-grid { grid-template-columns: 1fr; }
  .summary { grid-template-columns: 1fr 1fr; }
  .brand h1 { font-size: 18px; }
  .chart { height: 170px; }
}
