:root {
  color-scheme: light;
  --page: #f3f6f9;
  --paper: #ffffff;
  --paper-2: #fff9f6;
  --ink: #17202a;
  --muted: #667484;
  --line: #e4e9ef;
  --red: #d92d20;
  --red-deep: #9f1d18;
  --gold: #d6a12a;
  --teal: #0f766e;
  --blue: #2266c5;
  --green: #16885e;
  --shadow: 0 16px 36px rgba(39, 52, 69, 0.12);
  --soft-shadow: 0 8px 20px rgba(39, 52, 69, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--page);
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, #fff7f4 0, #f7fbfb 15rem, var(--page) 34rem),
    repeating-linear-gradient(135deg, rgba(217, 45, 32, 0.03) 0 1px, transparent 1px 18px);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

a {
  color: inherit;
}

.ui-icon {
  width: 1.05em;
  height: 1.05em;
  flex: 0 0 auto;
  vertical-align: -0.18em;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.app-shell {
  min-height: 100vh;
  padding-bottom: 5.8rem;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  overflow: hidden;
  border-bottom: 1px solid rgba(217, 45, 32, 0.1);
  background:
    linear-gradient(90deg, rgba(3, 35, 74, 0.04), rgba(3, 35, 74, 0.02)),
    url("/top-banner.png") center top / cover no-repeat,
    #0c6f9f;
  backdrop-filter: blur(16px);
}

.topbar::after {
  display: block;
  height: 3px;
  background: linear-gradient(90deg, var(--red), var(--gold), var(--teal), var(--blue));
  content: "";
}

.topbar-inner {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  width: min(1160px, 100%);
  margin: 0 auto;
  min-height: clamp(4.8rem, 18vw, 7.8rem);
  padding: 0.72rem 1rem;
}

.site-logo-link {
  position: absolute;
  inset: 0;
  display: block;
  text-decoration: none;
}

.site-logo {
  display: none;
  width: auto;
  max-width: calc(100vw - 5.2rem);
  height: clamp(2.8rem, 7vw, 4.35rem);
  border-radius: 8px;
  object-fit: contain;
  object-position: left center;
  box-shadow: var(--soft-shadow);
}

.brand-mark {
  position: relative;
  display: grid;
  flex: 0 0 auto;
  width: 2.65rem;
  height: 2.65rem;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--red) 0%, #ef6355 52%, var(--gold) 100%);
  color: white;
  box-shadow: 0 10px 20px rgba(217, 45, 32, 0.22);
  font-weight: 900;
  letter-spacing: 0;
}

.brand-mark::before {
  position: absolute;
  inset: 0.38rem;
  border: 1px solid rgba(255, 255, 255, 0.46);
  border-radius: 50%;
  content: "";
}

.brand-mark span {
  position: relative;
}

.brand-title {
  min-width: 0;
}

.brand-title h1 {
  margin: 0;
  font-size: 1.18rem;
  line-height: 1.1;
}

.brand-title p {
  margin: 0.25rem 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-link {
  display: inline-grid;
  position: relative;
  z-index: 2;
  flex: 0 0 2.45rem;
  height: 2.45rem;
  margin-left: auto;
  place-items: center;
  border: 1px solid rgba(217, 45, 32, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.93);
  color: var(--red);
  text-decoration: none;
  box-shadow: var(--soft-shadow);
}

.admin-link .ui-icon {
  width: 1.2rem;
  height: 1.2rem;
}

.lottery-tabs {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 0.52rem;
  width: min(1160px, 100%);
  margin: 0 auto;
  padding: 0.25rem 1rem 0.85rem;
  overflow-x: auto;
  scrollbar-width: none;
}

.lottery-tabs::-webkit-scrollbar {
  display: none;
}

.tab-button {
  position: relative;
  flex: 0 0 auto;
  min-width: 4.9rem;
  height: 2.22rem;
  padding: 0 0.9rem;
  border: 1px solid rgba(217, 45, 32, 0.12);
  border-radius: 8px;
  background: white;
  color: #5c6675;
  font-size: 0.86rem;
  font-weight: 750;
  box-shadow: 0 5px 14px rgba(39, 52, 69, 0.05);
}

.tab-button span {
  position: relative;
}

.tab-button.active {
  border-color: transparent;
  background: linear-gradient(135deg, var(--red), var(--red-deep));
  color: white;
  box-shadow: 0 10px 20px rgba(217, 45, 32, 0.24);
}

.tab-button.active::after {
  position: absolute;
  right: 0.65rem;
  bottom: -0.2rem;
  left: 0.65rem;
  height: 0.22rem;
  border-radius: 8px;
  background: var(--gold);
  content: "";
}

.content {
  width: min(1160px, 100%);
  margin: 0 auto;
  padding: 1rem;
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.22fr) minmax(18.5rem, 0.78fr);
  gap: 1rem;
  align-items: stretch;
}

.draw-board,
.side-panel,
.tool-panel,
.data-table-wrap,
.admin-panel,
.preview-panel {
  border: 1px solid rgba(27, 40, 56, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.draw-board {
  min-height: 20rem;
  overflow: hidden;
}

.draw-board-header {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 5.8rem;
  padding: 1.05rem;
  overflow: hidden;
  background:
    linear-gradient(135deg, var(--red) 0%, #bd251e 54%, var(--teal) 100%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.12) 0 1px, transparent 1px 14px);
  color: white;
}

.draw-heading {
  position: relative;
  z-index: 1;
}

.lottery-kicker,
.section-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--red);
  font-size: 0.74rem;
  font-weight: 800;
}

.lottery-kicker {
  margin-bottom: 0.25rem;
  padding: 0.18rem 0.45rem;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.14);
  color: #ffecc0;
}

.draw-board-header h2 {
  margin: 0;
  font-size: 1.55rem;
  line-height: 1.08;
}

.draw-board-header p {
  margin: 0.32rem 0 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.86rem;
}

.provider-badge {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  margin-left: auto;
  padding: 0.42rem 0.58rem;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.14);
  color: white;
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}

.draw-main {
  padding: 1rem;
}

.issue-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.84rem;
}

.issue-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.34rem;
  min-height: 1.85rem;
  padding: 0 0.62rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfc;
}

.draw-stage {
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid rgba(217, 45, 32, 0.12);
  border-radius: 8px;
  background:
    linear-gradient(180deg, #fffaf7, #fff2ee),
    repeating-linear-gradient(135deg, rgba(217, 45, 32, 0.04) 0 1px, transparent 1px 12px);
}

.next-draw-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.9rem;
  align-items: center;
  justify-content: center;
  margin-top: 0.75rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid rgba(217, 45, 32, 0.22);
  border-radius: 8px;
  background: #fff8f4;
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 750;
}

.next-draw-line strong {
  color: var(--red);
}

.stage-label {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.85rem;
}

.stage-label span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.stage-label strong {
  color: var(--red-deep);
  font-size: 1.05rem;
}

.balls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.featured-balls {
  gap: 0.65rem;
}

.ball {
  display: inline-grid;
  width: 2.55rem;
  height: 2.55rem;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.78);
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #ffb0a7, #e73f35 56%, #a81f18 100%);
  color: white;
  box-shadow: inset 0 -0.28rem 0.58rem rgba(63, 0, 0, 0.18), 0 0.42rem 0.95rem rgba(217, 45, 32, 0.22);
  font-weight: 900;
}

.featured-balls .ball {
  width: 3.1rem;
  height: 3.1rem;
  font-size: 1.18rem;
}

.lottery-kl8 .featured-balls .ball {
  width: 2.28rem;
  height: 2.28rem;
  font-size: 0.9rem;
}

.ball.blue {
  background: radial-gradient(circle at 34% 28%, #91c0ff, #2266c5 58%, #15488f 100%);
  box-shadow: inset 0 -0.25rem 0.55rem rgba(0, 26, 72, 0.15), 0 0.4rem 0.9rem rgba(34, 102, 197, 0.18);
}

.ball.green {
  background: radial-gradient(circle at 34% 28%, #78e3bc, #16885e 58%, #0d6544 100%);
}

.ball.gold {
  background: radial-gradient(circle at 34% 28%, #ffe08a, #d6a12a 58%, #9a6d13 100%);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
  margin-top: 1rem;
}

.metric {
  min-width: 0;
  padding: 0.78rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  border-radius: 8px;
  background: linear-gradient(180deg, white, #fbfcfd);
}

.metric span {
  display: flex;
  align-items: center;
  gap: 0.32rem;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 720;
}

.metric strong {
  display: block;
  margin-top: 0.26rem;
  overflow: hidden;
  color: var(--ink);
  font-size: 1.06rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trial-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.8rem;
  padding: 0.65rem;
  border: 1px solid rgba(15, 118, 110, 0.15);
  border-radius: 8px;
  background: #f0faf8;
}

.trial-banner span,
.trial-banner strong,
.trial-banner small {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
}

.trial-banner span {
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 800;
}

.trial-banner small {
  color: var(--muted);
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.62rem;
  margin-top: 1rem;
}

.quick-action {
  display: grid;
  min-height: 4.55rem;
  align-content: center;
  justify-items: center;
  gap: 0.4rem;
  border: 1px solid rgba(217, 45, 32, 0.12);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  text-decoration: none;
  box-shadow: 0 5px 14px rgba(39, 52, 69, 0.05);
}

.quick-action span {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border-radius: 50%;
  background: #fff1eb;
  color: var(--red);
}

.quick-action strong {
  font-size: 0.82rem;
}

.quick-action:hover,
.tab-button:hover,
.bottom-link:hover,
.primary-button:hover,
.secondary-button:hover {
  filter: brightness(0.98);
}

.side-panel {
  padding: 1rem;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.panel-title h3 {
  margin: 0;
  font-size: 1rem;
}

.panel-title small {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.76rem;
}

.status-dot {
  width: 0.58rem;
  height: 0.58rem;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0.22rem rgba(22, 136, 94, 0.16);
}

.mini-list {
  display: grid;
  gap: 0.55rem;
}

.mini-row {
  display: grid;
  grid-template-columns: 5.6rem minmax(0, 1fr) auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.6rem;
  border: 1px solid #edf1f5;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
}

.mini-row small {
  color: var(--muted);
  font-size: 0.74rem;
}

.mini-balls {
  display: flex;
  gap: 0.25rem;
  min-width: 0;
  overflow: hidden;
}

.mini-ball {
  display: inline-grid;
  width: 1.48rem;
  height: 1.48rem;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #ef6355, var(--red));
  color: white;
  font-size: 0.72rem;
  font-weight: 850;
}

.section {
  margin-top: 1rem;
}

.section-header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.8rem;
}

.section-header h2 {
  margin: 0.18rem 0 0;
  font-size: 1.18rem;
  line-height: 1.2;
}

.insight-layout {
  display: grid;
  grid-template-columns: minmax(18rem, 0.84fr) minmax(0, 1.16fr);
  gap: 1rem;
  align-items: start;
}

.preview-panel {
  padding: 1rem;
}

.preview-head span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--red);
  font-size: 0.75rem;
  font-weight: 850;
}

.preview-head h3 {
  margin: 0.28rem 0 0;
  font-size: 1.05rem;
}

.preview-head p {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.6;
}

.sparkline {
  width: 100%;
  height: auto;
  margin-top: 0.75rem;
  border: 1px solid #edf1f5;
  border-radius: 8px;
  background:
    linear-gradient(180deg, #fffdfc, #f8fbfd),
    repeating-linear-gradient(0deg, transparent 0 33px, rgba(34, 102, 197, 0.06) 33px 34px);
}

.sparkline-line {
  fill: none;
  stroke: var(--red);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sparkline-dot {
  fill: white;
  stroke: var(--red);
  stroke-width: 3;
}

.sparkline-dot.last {
  fill: var(--gold);
  stroke: var(--red-deep);
}

.preview-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-top: 0.7rem;
}

.preview-stats span {
  padding: 0.55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--muted);
  font-size: 0.75rem;
}

.preview-stats strong {
  display: block;
  margin-top: 0.16rem;
  color: var(--ink);
  font-size: 1rem;
}

.segmented,
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.history-select {
  min-height: 2.15rem;
  border: 1px solid rgba(217, 45, 32, 0.18);
  border-radius: 8px;
  padding: 0 0.65rem;
  background: white;
  color: var(--red-deep);
  font-weight: 750;
}

.history-toolbar {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  justify-content: flex-end;
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.history-toolbar .secondary-button {
  min-height: 2.15rem;
}

.history-toolbar button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.segment,
.filter-button {
  min-height: 2.15rem;
  padding: 0 0.76rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.segment.active,
.filter-button.active {
  border-color: rgba(217, 45, 32, 0.22);
  background: #fff0ea;
  color: var(--red-deep);
}

.tool-panel {
  padding: 1rem;
}

.analysis-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.analysis-card {
  min-width: 0;
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #fbfcfd);
}

.analysis-card h3 {
  display: flex;
  align-items: center;
  gap: 0.38rem;
  margin: 0 0 0.65rem;
  font-size: 0.92rem;
}

.rank-list {
  display: grid;
  gap: 0.5rem;
}

.rank-item {
  display: grid;
  grid-template-columns: 2.1rem minmax(4rem, 1fr) 3.2rem;
  gap: 0.5rem;
  align-items: center;
}

.rank-item b {
  display: grid;
  width: 1.75rem;
  height: 1.75rem;
  place-items: center;
  border-radius: 50%;
  background: #fff0ea;
  color: var(--red);
  font-size: 0.76rem;
}

.rank-item span {
  height: 0.45rem;
  overflow: hidden;
  border-radius: 8px;
  background: #eef2f6;
}

.rank-item i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--red), var(--gold));
}

.rank-item em {
  color: var(--muted);
  font-size: 0.75rem;
  font-style: normal;
  text-align: right;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 1.65rem;
  padding: 0 0.5rem;
  border-radius: 8px;
  background: #fff0ea;
  color: var(--red-deep);
  font-size: 0.78rem;
}

.table-hint {
  margin: 0.8rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.trend-board {
  position: relative;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.trend-canvas {
  position: relative;
  width: var(--trend-width);
  min-height: var(--trend-height);
}

.trend-lines {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: var(--trend-width);
  height: var(--trend-height);
  pointer-events: none;
}

.trend-lines polyline {
  fill: none;
  stroke: rgba(217, 45, 32, 0.78);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.trend-table {
  position: relative;
  z-index: 3;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  width: var(--trend-width, 100%);
  min-width: var(--trend-width, 30rem);
}

.trend-table th,
.trend-table td {
  height: 34px;
  border-bottom: 1px solid #edf2f3;
  border-right: 1px solid #edf2f3;
  background: rgba(255, 255, 255, 0.56);
  text-align: center;
  font-size: 0.78rem;
}

.trend-col-issue {
  width: var(--issue-width, 72px);
}

.trend-col-prize {
  width: var(--prize-width, 48px);
}

.trend-col-sum {
  width: var(--sum-width, 36px);
}

.trend-col-metric {
  width: var(--metric-width, 40px);
}

.trend-col-digit {
  width: var(--digit-width, 28px);
}

.trend-table th {
  position: sticky;
  top: 0;
  z-index: 6;
  background: #fff8f4;
  color: #8b4b45;
  font-weight: 800;
}

.trend-table .issue-cell,
.trend-table .prize-cell,
.trend-table .sum-cell,
.trend-table .metric-cell {
  position: sticky;
  color: var(--muted);
  background: #fffdfc;
  z-index: 5;
}

.trend-table th.issue-cell,
.trend-table th.prize-cell,
.trend-table th.sum-cell,
.trend-table th.metric-cell {
  background: #fff1dd;
  color: #5c2d1d;
  z-index: 8;
}

.trend-table .issue-cell {
  left: 0;
}

.trend-table .prize-cell {
  left: var(--prize-left);
}

.trend-table .sum-cell {
  left: var(--sum-left);
}

.trend-table .metric-cell {
  left: var(--metric-left);
}

.trend-table .prize-cell strong {
  display: inline-flex;
  min-width: 2.4rem;
  justify-content: center;
  padding: 0.12rem 0.28rem;
  border-radius: 4px;
  background: #ffe5b7;
  color: #855015;
  font-size: 0.78rem;
}

.group-trend-table {
  min-width: 30rem;
  width: max-content;
}

.group-trend-table .loose-cell,
.group-trend-table th.loose-cell {
  position: static;
}

.trend-group-hit {
  display: inline-grid;
  width: 1.35rem;
  height: 1.35rem;
  place-items: center;
  border: 1px solid #6b7480;
  border-radius: 50%;
  background: white;
  color: #2f3742;
  font-size: 0.74rem;
  font-weight: 850;
}

.trend-hit {
  display: inline-grid;
  width: 1.55rem;
  height: 1.55rem;
  place-items: center;
  border: 2px solid white;
  border-radius: 50%;
  background: linear-gradient(135deg, #ef6355, var(--red));
  color: white;
  box-shadow: 0 4px 10px rgba(217, 45, 32, 0.2);
  font-weight: 850;
  position: relative;
  z-index: 4;
}

.trend-miss {
  color: #c2cdd1;
}

.tail-form-table {
  min-width: 36rem;
}

.form-chip {
  display: inline-flex;
  min-width: 1.6rem;
  justify-content: center;
  padding: 0.12rem 0.32rem;
  border-radius: 4px;
  color: white;
  font-size: 0.76rem;
  font-weight: 850;
}

.form-chip.red {
  background: var(--red);
}

.form-chip.blue {
  background: #78aeb9;
}

.form-chip.gold {
  background: var(--gold);
}

.distribution-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(2.25rem, 1fr));
  gap: 0.5rem;
}

.dist-cell {
  min-height: 3.8rem;
  padding: 0.45rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f8fbfd);
}

.dist-cell strong,
.dist-cell span {
  display: block;
}

.dist-cell strong {
  color: var(--red);
  font-size: 0.95rem;
}

.dist-cell span {
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.72rem;
}

.road-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.65rem;
}

.road-column {
  min-height: 12rem;
  padding: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f8fbfd);
}

.road-column h3 {
  margin: 0 0 0.6rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.beads {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.bead {
  display: inline-grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border: 1px solid rgba(217, 45, 32, 0.18);
  border-radius: 50%;
  background: #fff5ef;
  color: var(--red-deep);
  font-size: 0.75rem;
  font-weight: 850;
}

.data-table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  min-width: 44rem;
  border-collapse: separate;
  border-spacing: 0;
}

.data-table th,
.data-table td {
  padding: 0.78rem 0.7rem;
  border-bottom: 1px solid #edf2f3;
  text-align: left;
  font-size: 0.86rem;
  vertical-align: middle;
}

.data-table th {
  background: #fff8f4;
  color: #8b4b45;
  font-size: 0.78rem;
  font-weight: 850;
}

.data-table tr:hover td {
  background: #fffdfb;
}

.rule-page-section {
  padding: 0.25rem 0 1rem;
}

.rule-phone {
  width: min(430px, 100%);
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid rgba(27, 40, 56, 0.08);
  border-radius: 0;
  background: white;
  box-shadow: var(--shadow);
}

.rule-phone-head {
  display: grid;
  grid-template-columns: 4.6rem minmax(0, 1fr) 4.6rem;
  align-items: center;
  min-height: 3.15rem;
  padding: 0 0.85rem;
  background: #d61f18;
  color: white;
}

.rule-phone-head button {
  justify-self: start;
  padding: 0;
  background: transparent;
  color: white;
  font-size: 0.98rem;
  font-weight: 750;
}

.rule-phone-head strong {
  justify-self: center;
  font-size: 1rem;
  font-weight: 800;
}

.rule-phone-body {
  padding: 1.65rem 1.2rem 2rem;
}

.rule-phone-body h2 {
  margin: 0 0 0.85rem;
  color: #141414;
  font-size: 1.08rem;
  line-height: 1.35;
}

.rule-page-note {
  width: min(430px, 100%);
  margin: 0.75rem auto 0;
}

.rule-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.rule-source-panel {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.8rem;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(217, 45, 32, 0.12);
  border-radius: 8px;
  background: #fff8f4;
}

.rule-source-panel div {
  display: grid;
  gap: 0.2rem;
  min-width: 0;
}

.rule-source-panel span {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rule-box-wide {
  grid-column: 1 / -1;
}

.rule-text {
  max-height: 34rem;
  overflow: auto;
  padding-right: 0.4rem;
}

.rule-text-document {
  max-height: none;
  overflow: visible;
  padding-right: 0;
}

.rule-text h4 {
  margin: 0.92rem 0 0.45rem;
  color: #ff1010;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.45;
}

.rule-text p {
  margin: 0.48rem 0;
  color: #111;
  font-size: 0.88rem;
  line-height: 1.55;
}

.rule-text p strong {
  font-weight: 500;
}

.road-bead-section {
  display: grid;
  gap: 0.9rem;
}

.road-bead-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: var(--soft-shadow);
}

.road-bead-head {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
}

.road-bead-head span {
  color: var(--muted);
  font-size: 0.78rem;
}

.road-bead-head strong {
  color: var(--red);
  font-size: 0.82rem;
}

.road-bead-strip {
  display: grid;
  grid-auto-columns: minmax(1.75rem, 1fr);
  grid-auto-flow: column;
  min-height: 5.2rem;
  overflow-x: auto;
}

.road-bead-strip span {
  display: grid;
  align-content: start;
  justify-items: center;
  padding-top: 0.55rem;
  border-right: 1px solid #e6e9ee;
  background: #fafafa;
  color: #222;
  font-weight: 800;
  writing-mode: vertical-rl;
  text-orientation: upright;
}

.road-bead-strip span:nth-child(even) {
  background: #f1f1f1;
}

.road-bead-strip span.hot {
  color: var(--red);
}

.rule-box {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f9fbfc);
  box-shadow: var(--soft-shadow);
}

.rule-box h3 {
  margin: 0 0 0.45rem;
  font-size: 0.95rem;
}

.rule-box p,
.rule-box li {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.7;
}

.rule-box ul {
  margin: 0;
  padding-left: 1.1rem;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(18rem, 0.8fr) minmax(0, 1.2fr);
  gap: 1rem;
}

.admin-panel {
  padding: 1rem;
}

.admin-panel-head {
  display: grid;
  gap: 0.25rem;
  padding: 0.8rem;
  border-radius: 8px;
  background: linear-gradient(135deg, #fff1eb, #f0faf8);
}

.admin-panel-head strong {
  color: var(--ink);
}

.admin-panel-head span {
  color: var(--muted);
  font-size: 0.78rem;
}

.form-grid {
  display: grid;
  gap: 0.75rem;
}

.field {
  display: grid;
  gap: 0.35rem;
}

.field label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 2.55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.58rem 0.7rem;
  background: #fbfcfd;
  color: var(--ink);
  outline: none;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: rgba(217, 45, 32, 0.46);
  box-shadow: 0 0 0 3px rgba(217, 45, 32, 0.1);
}

.field textarea {
  min-height: 5.4rem;
  resize: vertical;
}

.primary-button,
.secondary-button,
.danger-button {
  display: inline-flex;
  min-height: 2.5rem;
  align-items: center;
  justify-content: center;
  gap: 0.36rem;
  padding: 0 0.95rem;
  border-radius: 8px;
  font-weight: 800;
  text-decoration: none;
}

.primary-button {
  background: linear-gradient(135deg, var(--red), var(--red-deep));
  color: white;
  box-shadow: 0 10px 20px rgba(217, 45, 32, 0.18);
}

.secondary-button {
  border: 1px solid rgba(217, 45, 32, 0.16);
  background: white;
  color: var(--red-deep);
}

.danger-button {
  background: #fff0ee;
  color: #bd3225;
}

.empty,
.loading,
.error {
  padding: 1rem;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  text-align: center;
}

.error {
  border-color: rgba(217, 45, 32, 0.32);
  color: #bd3225;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  border-top: 1px solid rgba(27, 40, 56, 0.08);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 -10px 24px rgba(39, 52, 69, 0.08);
  backdrop-filter: blur(16px);
}

.bottom-nav-inner {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  width: min(720px, 100%);
  margin: 0 auto;
}

.bottom-link {
  display: grid;
  min-height: 4.25rem;
  place-items: center;
  align-content: center;
  gap: 0.26rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.74rem;
}

.bottom-link b {
  display: grid;
  width: 1.7rem;
  height: 1.7rem;
  place-items: center;
  border-radius: 50%;
  background: #f1f4f7;
  color: var(--muted);
}

.bottom-link.active {
  color: var(--red-deep);
  font-weight: 800;
}

.bottom-link.active b {
  background: linear-gradient(135deg, var(--red), var(--red-deep));
  color: white;
}

.back-top {
  position: fixed;
  right: 1rem;
  bottom: 5.15rem;
  z-index: 40;
  display: grid;
  width: 3.05rem;
  height: 3.05rem;
  place-items: center;
  align-content: center;
  gap: 0.08rem;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  background: rgba(37, 38, 42, 0.88);
  color: white;
  box-shadow: 0 10px 22px rgba(27, 34, 45, 0.22);
}

.back-top span {
  display: block;
  height: 1rem;
  font-size: 1.12rem;
  font-weight: 900;
  line-height: 0.9;
}

.back-top strong {
  display: block;
  font-size: 0.66rem;
  font-weight: 800;
  line-height: 1;
}

.source-note {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.6;
}

.source-note a {
  color: var(--red-deep);
  font-weight: 750;
}

@media (max-width: 920px) {
  .hero-panel,
  .admin-layout,
  .rule-grid,
  .insight-layout {
    grid-template-columns: 1fr;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quick-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .analysis-grid {
    grid-template-columns: 1fr;
  }

  .road-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .distribution-grid {
    grid-template-columns: repeat(5, minmax(2.25rem, 1fr));
  }
}

@media (max-width: 520px) {
  .content {
    padding: 0.75rem;
  }

  .topbar-inner {
    padding-right: 0.75rem;
    padding-left: 0.75rem;
  }

  .brand-mark {
    width: 2.35rem;
    height: 2.35rem;
  }

  .site-logo {
    height: clamp(2.65rem, 11vw, 3.45rem);
  }

  .brand-title h1 {
    font-size: 1.02rem;
  }

  .brand-title p {
    max-width: 13rem;
  }

  .draw-board-header {
    align-items: flex-start;
    min-height: 5.5rem;
  }

  .draw-board-header h2 {
    font-size: 1.34rem;
  }

  .provider-badge {
    max-width: 7.4rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .draw-stage {
    padding: 0.85rem;
  }

  .featured-balls .ball {
    width: 2.62rem;
    height: 2.62rem;
  }

  .lottery-kl8 .featured-balls .ball {
    width: 2.03rem;
    height: 2.03rem;
    font-size: 0.82rem;
  }

  .metric {
    padding: 0.68rem;
  }

  .metric strong {
    font-size: 0.95rem;
  }

  .mini-row {
    grid-template-columns: 4.75rem minmax(0, 1fr);
  }

  .mini-row small:last-child,
  .mini-row .danger-button {
    grid-column: 1 / -1;
  }

  .road-grid {
    grid-template-columns: 1fr;
  }

  .bottom-link {
    min-height: 3.9rem;
    font-size: 0.68rem;
  }

  .rule-source-panel,
  .history-toolbar {
    align-items: stretch;
    flex-direction: column;
  }
}
