:root {
  color-scheme: light;
  --ink: #17201d;
  --muted: #66706b;
  --line: #d8ddd9;
  --paper: #ffffff;
  --canvas: #eef1ed;
  --coral: #ef5b4c;
  --coral-dark: #cd4135;
  --green: #13866f;
  --amber: #f3b63f;
  --blue: #3478c9;
  --danger: #b52e2e;
  --shadow: 0 18px 50px rgba(23, 32, 29, 0.12);
  --radius: 8px;
  font-family: "Segoe UI", "Microsoft YaHei UI", "PingFang SC", sans-serif;
  font-synthesis: none;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--canvas);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--canvas);
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button,
summary {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(52, 120, 201, 0.28);
  outline-offset: 2px;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

[hidden] {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 72px;
  padding: 12px clamp(18px, 4vw, 56px);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  width: max-content;
  color: var(--ink);
  text-decoration: none;
}

.brand img {
  border-radius: 7px;
}

.brand span {
  display: grid;
  gap: 1px;
}

.brand strong {
  font-size: 16px;
  line-height: 1.1;
}

.brand small {
  color: var(--muted);
  font-size: 11px;
}

.view-switcher {
  display: inline-flex;
  padding: 3px;
  background: #e8ece8;
  border: 1px solid #dce1dd;
  border-radius: 7px;
}

.view-tab {
  min-width: 94px;
  min-height: 36px;
  padding: 7px 15px;
  border: 0;
  border-radius: 5px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 650;
}

.view-tab.is-active {
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 1px 5px rgba(23, 32, 29, 0.1);
}

.header-batch {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 260px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9ba39f;
  box-shadow: 0 0 0 4px rgba(155, 163, 159, 0.15);
}

.status-dot[data-status="active"] {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(19, 134, 111, 0.15);
}

.status-dot[data-status="paused"] {
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(243, 182, 63, 0.18);
}

.status-dot[data-status="completed"] {
  background: var(--blue);
  box-shadow: 0 0 0 4px rgba(52, 120, 201, 0.15);
}

main {
  width: 100%;
  max-width: 1500px;
  margin: 0 auto;
  padding: clamp(18px, 3.2vw, 48px);
  flex: 1;
}

.view {
  min-width: 0;
}

.lottery-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.32fr) minmax(340px, 0.68fr);
  min-height: min(760px, calc(100vh - 150px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.wheel-stage {
  min-width: 0;
  padding: clamp(24px, 3.4vw, 50px);
  display: flex;
  flex-direction: column;
  background: var(--ink);
  color: #fff;
  overflow: hidden;
}

.section-heading,
.section-toolbar,
.subheading-row,
.admin-titlebar,
.tier-editor-heading,
.meter-copy,
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.section-heading h1,
.admin-titlebar h1,
.admin-login h1 {
  margin: 2px 0 0;
  font-size: clamp(25px, 2.5vw, 38px);
  line-height: 1.15;
  font-weight: 760;
}

.eyebrow {
  margin: 0;
  color: var(--coral);
  font-size: 11px;
  line-height: 1.3;
  font-weight: 800;
  text-transform: uppercase;
}

.wheel-stage .eyebrow {
  color: #f9c65d;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 10px;
  border: 1px solid #cbd2cd;
  border-radius: 999px;
  color: #57615c;
  background: #f6f8f6;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.wheel-stage .status-badge {
  color: #e8edea;
  border-color: #44504b;
  background: #29332f;
}

.status-badge[data-status="active"]::before,
.status-badge[data-status="paused"]::before,
.status-badge[data-status="completed"]::before {
  content: "";
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--green);
}

.status-badge[data-status="paused"]::before {
  background: var(--amber);
}

.status-badge[data-status="completed"]::before {
  background: var(--blue);
}

.status-badge[data-status="closed"]::before {
  content: "";
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--danger);
}

.wheel-zone {
  width: min(100%, 600px);
  aspect-ratio: 1;
  margin: auto;
  position: relative;
  display: grid;
  place-items: center;
}

.wheel-ambient {
  position: absolute;
  inset: 5%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  box-shadow: 0 0 0 18px rgba(255, 255, 255, 0.025), 0 0 0 42px rgba(255, 255, 255, 0.018);
}

.wheel-frame {
  width: 84%;
  aspect-ratio: 1;
  position: relative;
  display: grid;
  place-items: center;
  border: 9px solid #f6f1e4;
  border-radius: 50%;
  background: #f6f1e4;
  box-shadow: 0 0 0 4px #a9b1ab, 0 18px 40px rgba(0, 0, 0, 0.3);
}

#wheel-canvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 50%;
}

.wheel-pointer {
  position: absolute;
  z-index: 5;
  top: 3.5%;
  left: 50%;
  width: 0;
  height: 0;
  transform: translateX(-50%);
  border-left: 18px solid transparent;
  border-right: 18px solid transparent;
  border-top: 40px solid #f7f3e8;
  filter: drop-shadow(0 5px 2px rgba(0, 0, 0, 0.22));
}

.wheel-hub {
  position: absolute;
  width: 24%;
  aspect-ratio: 1;
  display: grid;
  place-content: center;
  text-align: center;
  border: 7px solid #f6f1e4;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 5px 18px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

.wheel-hub strong {
  font-size: clamp(25px, 4vw, 42px);
  line-height: 1;
}

.wheel-hub span {
  margin-top: 4px;
  color: #bfc8c3;
  font-size: 11px;
}

.pool-meter {
  width: min(100%, 620px);
  margin: 4px auto 0;
}

.meter-copy {
  margin-bottom: 9px;
  color: #c9d0cc;
  font-size: 12px;
}

.meter-copy strong {
  color: #fff;
}

.progress-track {
  height: 6px;
  border-radius: 3px;
  background: #38433e;
  overflow: hidden;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--coral);
  transition: width 350ms ease;
}

.draw-console {
  min-width: 0;
  padding: clamp(26px, 3.6vw, 52px);
  background: var(--paper);
  overflow: auto;
}

.console-intro h2 {
  margin: 8px 0 10px;
  font-size: clamp(24px, 2.2vw, 34px);
  line-height: 1.18;
}

.console-intro > p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.75;
}

.draw-form {
  margin-top: 30px;
}

label {
  display: grid;
  gap: 7px;
  color: #39433e;
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #cbd2cd;
  border-radius: 5px;
  color: var(--ink);
  background: #fff;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #aeb7b1;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(52, 120, 201, 0.11);
  outline: 0;
}

textarea {
  resize: vertical;
  line-height: 1.55;
}

select {
  cursor: pointer;
}

.username-field {
  position: relative;
  margin-top: 7px;
}

.draw-code-field {
  margin-top: 14px;
}

.code-symbol {
  background: var(--blue);
}

.username-field input {
  height: 52px;
  padding-left: 49px;
  font-size: 16px;
}

.user-symbol {
  position: absolute;
  z-index: 1;
  left: 12px;
  top: 50%;
  width: 27px;
  height: 27px;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--green);
  font-size: 11px;
  font-weight: 800;
}

.field-help,
.form-message {
  min-height: 18px;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.field-help.is-error,
.form-message.is-error {
  color: var(--danger);
}

.primary-button,
.secondary-button,
.danger-button,
.icon-button,
.text-button {
  border: 0;
  cursor: pointer;
  font-weight: 700;
}

.primary-button,
.danger-button {
  min-height: 44px;
  padding: 11px 18px;
  border-radius: 5px;
  color: #fff;
  background: var(--coral);
}

.primary-button:hover:not(:disabled) {
  background: var(--coral-dark);
}

.draw-button {
  width: 100%;
  min-height: 54px;
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-inline: 20px;
  font-size: 16px;
}

.draw-button.is-loading .button-label::after {
  content: "中…";
}

.draw-button.is-loading .button-label {
  font-size: 0;
}

.draw-button.is-loading .button-label::after {
  font-size: 16px;
}

.button-arrow {
  font-size: 22px;
  font-weight: 400;
}

.secondary-button {
  min-height: 38px;
  padding: 8px 13px;
  border: 1px solid #cbd2cd;
  border-radius: 5px;
  color: #38423d;
  background: #fff;
}

.secondary-button:hover:not(:disabled) {
  border-color: #98a39c;
  background: #f6f8f6;
}

.secondary-button.compact {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
}

.danger-button {
  background: var(--danger);
}

.danger-button:hover:not(:disabled) {
  background: #982525;
}

.admin-close-button {
  min-height: 38px;
  padding: 8px 13px;
  white-space: nowrap;
}

.icon-button {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid #cbd2cd;
  border-radius: 5px;
  background: #fff;
  font-size: 18px;
}

.icon-button.small {
  width: 32px;
  height: 32px;
  font-size: 14px;
}

.text-button {
  padding: 4px;
  color: var(--blue);
  background: transparent;
  font-size: 12px;
}

.full-width {
  width: 100%;
}

.quick-stats {
  margin: 28px 0 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-block: 1px solid var(--line);
}

.quick-stats > div {
  min-width: 0;
  padding: 18px 10px;
  text-align: center;
}

.quick-stats > div + div {
  border-left: 1px solid var(--line);
}

.quick-stats dt {
  color: var(--muted);
  font-size: 11px;
}

.quick-stats dd {
  margin: 5px 0 0;
  overflow: hidden;
  color: var(--ink);
  font-size: clamp(15px, 1.5vw, 20px);
  font-weight: 780;
  text-overflow: ellipsis;
}

.odds-section {
  margin-top: 24px;
}

.subheading-row h3 {
  margin: 0;
  font-size: 15px;
}

.odds-list {
  margin-top: 14px;
  display: grid;
  gap: 12px;
}

.odds-item {
  display: grid;
  grid-template-columns: minmax(76px, 1fr) 65px 52px;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.odds-name {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-swatch {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 2px;
  background: var(--swatch);
}

.odds-name strong {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.odds-stock {
  color: var(--muted);
  text-align: right;
}

.odds-percent {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.rules-disclosure {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.rules-disclosure summary {
  width: max-content;
  color: #404a45;
  cursor: pointer;
  font-weight: 700;
}

.rules-disclosure ol {
  margin: 12px 0 0;
  padding-left: 20px;
  line-height: 1.8;
}

footer {
  min-height: 46px;
  padding: 12px clamp(18px, 4vw, 56px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: #6f7973;
  border-top: 1px solid var(--line);
  background: #e9ede9;
  font-size: 11px;
}

.admin-login {
  width: min(430px, 100%);
  margin: clamp(30px, 8vh, 110px) auto;
  padding: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
  text-align: center;
}

.login-mark {
  width: 48px;
  height: 48px;
  margin: 0 auto 20px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: #fff;
  background: var(--ink);
  font-weight: 800;
}

.admin-login h1 {
  margin-top: 8px;
}

.admin-login > p:not(.eyebrow) {
  margin: 10px 0 26px;
  color: var(--muted);
  font-size: 14px;
}

.admin-login form {
  display: grid;
  gap: 12px;
  text-align: left;
}

.admin-login form .primary-button {
  margin-top: 4px;
}

.admin-login small {
  display: block;
  margin-top: 18px;
  color: #7d8681;
  font-size: 11px;
}

.admin-login code {
  color: #46504a;
  background: #eef1ee;
  padding: 1px 4px;
  border-radius: 3px;
}

.admin-dashboard {
  width: 100%;
}

.admin-titlebar {
  margin-bottom: 20px;
}

.admin-actions,
.table-tools,
.dialog-actions,
.pagination > div {
  display: flex;
  align-items: center;
  gap: 9px;
}

.admin-kpis {
  margin: 0 0 20px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
}

.admin-kpis > div {
  min-width: 0;
  padding: 18px 20px;
}

.admin-kpis > div + div {
  border-left: 1px solid var(--line);
}

.admin-kpis dt {
  color: var(--muted);
  font-size: 12px;
}

.admin-kpis dd {
  margin: 7px 0 4px;
  color: var(--ink);
  font-size: clamp(20px, 2vw, 28px);
  font-weight: 780;
  font-variant-numeric: tabular-nums;
}

.admin-kpis span {
  display: block;
  overflow: hidden;
  color: #89918d;
  font-size: 11px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.7fr);
  gap: 18px;
}

.admin-section {
  min-width: 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.winner-section,
.config-section {
  grid-column: 1 / -1;
}

.section-toolbar {
  margin-bottom: 18px;
}

.section-toolbar h2 {
  margin: 4px 0 0;
  font-size: 19px;
}

.search-field {
  width: min(260px, 32vw);
  display: flex;
  align-items: center;
  gap: 7px;
  padding-left: 10px;
  border: 1px solid #cbd2cd;
  border-radius: 5px;
  background: #fff;
}

.search-field:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(52, 120, 201, 0.11);
}

.search-field span {
  color: var(--muted);
  font-size: 18px;
}

.search-field input {
  min-height: 36px;
  padding: 7px 8px 7px 0;
  border: 0;
  box-shadow: none;
  font-size: 12px;
}

.compact-select {
  min-height: 38px;
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 7px;
  padding-left: 10px;
  border: 1px solid #cbd2cd;
  border-radius: 5px;
  color: var(--muted);
  background: #fff;
  font-size: 11px;
  white-space: nowrap;
}

.compact-select select {
  width: auto;
  min-height: 36px;
  padding: 6px 28px 6px 3px;
  border: 0;
  box-shadow: none;
  color: var(--ink);
  font-size: 12px;
}

.claim-badge,
.count-badge,
.mode-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  color: #5f6863;
  background: #edf0ed;
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

.claim-badge[data-status="claimed"] {
  color: #0e6b58;
  background: #dff1eb;
}

.claim-badge[data-status="void"] {
  color: #93453d;
  background: #f8e7e4;
}

.claim-action {
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid #cbd2cd;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
}

.table-wrap {
  min-height: 260px;
  overflow-x: auto;
  border: 1px solid var(--line);
}

table {
  width: 100%;
  min-width: 700px;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  height: 48px;
  padding: 10px 14px;
  border-bottom: 1px solid #e6eae7;
  text-align: left;
  white-space: nowrap;
}

th {
  height: 42px;
  color: #6d7671;
  background: #f5f7f5;
  font-size: 11px;
  font-weight: 700;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: #fafbfa;
}

.table-prize {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
}

.empty-state {
  min-height: 215px;
  display: grid;
  place-content: center;
  gap: 6px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.empty-state strong {
  color: #4a544f;
  font-size: 14px;
}

.pagination {
  margin-top: 13px;
  color: var(--muted);
  font-size: 12px;
}

.form-grid {
  display: grid;
  gap: 14px;
}

.three-columns {
  grid-template-columns: 1.3fr 0.7fr 0.8fr;
}

.config-mode-row {
  margin-bottom: 18px;
  display: flex;
  align-items: flex-end;
  gap: 24px;
  flex-wrap: wrap;
}

.segmented-fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.segmented-fieldset legend {
  margin-bottom: 7px;
  color: #39433e;
  font-size: 13px;
  font-weight: 700;
}

.segmented-control {
  display: inline-flex;
  padding: 3px;
  border: 1px solid #d3d9d4;
  border-radius: 6px;
  background: #edf0ed;
}

.segmented-control label {
  display: block;
  cursor: pointer;
}

.segmented-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.segmented-control span {
  min-width: 92px;
  min-height: 32px;
  padding: 7px 12px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  color: #69736d;
  font-size: 12px;
  font-weight: 750;
}

.segmented-control input:checked + span {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 1px 3px rgba(23, 32, 29, 0.12);
}

.segmented-control input:focus-visible + span {
  outline: 3px solid rgba(52, 120, 201, 0.28);
}

.roster-editor {
  margin-top: 16px;
  padding: 15px;
  border: 1px solid #d9dfda;
  border-radius: 6px;
  background: #f7f9f7;
}

.roster-copy {
  margin-bottom: 10px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.roster-copy > div {
  display: grid;
  gap: 3px;
}

.roster-copy strong {
  font-size: 13px;
}

.roster-copy span,
.roster-preview {
  color: var(--muted);
  font-size: 11px;
}

.roster-preview {
  margin-top: 9px;
  min-height: 18px;
}

.roster-preview.is-invalid {
  color: var(--danger);
}

.tier-editor-heading {
  margin: 24px 0 10px;
  font-size: 13px;
  font-weight: 780;
}

.tier-editor-labels,
.tier-row {
  display: grid;
  grid-template-columns: 38px minmax(150px, 1fr) 100px 130px 100px 36px;
  gap: 10px;
  align-items: center;
}

.tier-editor-labels {
  padding: 0 3px 7px;
  color: #77807b;
  font-size: 11px;
}

.tier-editor {
  display: grid;
  gap: 8px;
  overflow-x: auto;
}

.tier-row {
  min-width: 650px;
  padding: 9px;
  border: 1px solid #e0e4e1;
  border-radius: 6px;
  background: #fafbfa;
}

.tier-row input {
  min-height: 38px;
  padding: 7px 9px;
  font-size: 12px;
}

.tier-color {
  width: 32px;
  height: 32px;
  padding: 2px;
  border: 1px solid #cbd2cd;
  border-radius: 5px;
  background: #fff;
  cursor: pointer;
}

.tier-probability {
  color: #3f4944;
  font-size: 12px;
  font-weight: 750;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.tier-remove {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 5px;
  color: #8c4a44;
  background: transparent;
  cursor: pointer;
  font-size: 18px;
}

.tier-remove:hover:not(:disabled) {
  background: #f7e8e6;
}

.mobile-tier-label {
  display: none;
}

.balance-policy-panel {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid #d7ddd9;
  border-radius: 7px;
  background: #f7f9f7;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.balance-policy-panel.is-active {
  border-color: rgba(19, 134, 111, 0.48);
  background: #f2faf7;
  box-shadow: inset 3px 0 0 var(--green);
}

.balance-policy-panel.is-invalid {
  border-color: rgba(173, 68, 57, 0.42);
  background: #fdf7f6;
}

.balance-policy-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.balance-switch {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
  cursor: pointer;
}

.balance-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.balance-switch-track {
  position: relative;
  width: 39px;
  height: 22px;
  flex: 0 0 auto;
  border: 1px solid #bfc7c1;
  border-radius: 999px;
  background: #dfe4e0;
  transition: border-color 160ms ease, background 160ms ease;
}

.balance-switch-track > span {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(24, 34, 29, 0.25);
  transition: transform 160ms ease;
}

.balance-switch input:checked + .balance-switch-track {
  border-color: var(--green);
  background: var(--green);
}

.balance-switch input:checked + .balance-switch-track > span {
  transform: translateX(17px);
}

.balance-switch input:focus-visible + .balance-switch-track {
  outline: 3px solid rgba(52, 120, 201, 0.28);
  outline-offset: 2px;
}

.balance-switch-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.balance-switch-copy strong {
  color: var(--ink);
  font-size: 13px;
}

.balance-switch-copy small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.balance-policy-status {
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 999px;
  color: #68716c;
  background: #e8ece9;
  font-size: 10px;
  font-weight: 800;
}

.balance-policy-panel.is-active .balance-policy-status {
  color: #0e6b58;
  background: #dcefe9;
}

.balance-policy-panel.is-invalid .balance-policy-status {
  color: #93453d;
  background: #f5e3e0;
}

.balance-preview {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e0e5e1;
}

.balance-preview-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 11px;
}

.balance-preview-summary strong {
  color: #46504b;
  font-size: 11px;
}

.balance-preview-tiers {
  margin-top: 9px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.balance-preview-tier {
  min-width: 0;
  padding: 9px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  border: 1px dashed #c8d1ca;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.78);
  font-size: 11px;
}

.balance-preview-tier span {
  min-width: 0;
  overflow: hidden;
  color: #626c66;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.balance-preview-tier strong {
  flex: 0 0 auto;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.balance-preview-message {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.balance-policy-panel.is-invalid .balance-preview-message {
  color: var(--danger);
}

.config-checks {
  margin: 16px 0 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7f9f7;
}

.config-checks > div {
  min-width: 0;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.config-checks > div + div {
  border-left: 1px solid var(--line);
}

.config-checks strong {
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.config-checks strong.is-valid {
  color: var(--green);
}

.config-checks strong.is-invalid {
  color: var(--danger);
}

.form-message {
  min-height: 20px;
  margin: 10px 0;
}

.pool-table {
  display: grid;
  gap: 2px;
}

.pool-row {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) 90px 90px 68px;
  gap: 10px;
  align-items: center;
  min-height: 45px;
  padding: 8px 4px;
  border-bottom: 1px solid #e8ebe9;
  font-size: 12px;
}

.pool-row:last-child {
  border-bottom: 0;
}

.pool-row > span:not(.pool-name) {
  color: var(--muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.pool-name {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.pool-name span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.generated-tier-badge {
  margin-left: 5px;
  padding: 2px 5px;
  border-radius: 999px;
  color: #52605a;
  background: #e4e9e5;
  font-size: 9px;
  font-weight: 800;
  vertical-align: 1px;
}

.archive-list {
  max-height: 430px;
  display: grid;
  gap: 9px;
  overflow: auto;
}

.archive-item {
  min-width: 0;
  padding: 12px 13px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px 14px;
  border: 1px solid #e0e4e1;
  border-radius: 6px;
}

.archive-item-button {
  width: 100%;
  padding: 12px 13px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px 14px;
  border: 1px solid #e0e4e1;
  border-radius: 6px;
  color: inherit;
  background: #fff;
  cursor: pointer;
  text-align: left;
}

.archive-item-button:hover {
  border-color: #aeb7b1;
  background: #f8faf8;
}

.archive-item-button strong,
.archive-item-button span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.archive-item-button span,
.archive-item-button small {
  color: var(--muted);
  font-size: 11px;
}

.participant-summary {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
}

.participant-list {
  display: grid;
  border-top: 1px solid #e1e5e2;
}

.participant-row {
  min-width: 0;
  min-height: 42px;
  padding: 7px 2px;
  display: grid;
  grid-template-columns: minmax(90px, 1fr) minmax(100px, 1fr) auto;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid #e8ebe9;
  font-size: 12px;
}

.participant-row code {
  overflow: hidden;
  color: #56615b;
  font-family: Consolas, monospace;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.participant-row span:last-child {
  color: var(--muted);
  font-size: 11px;
}

.participant-pagination {
  margin-top: 10px;
}

.alert-section,
.audit-section {
  grid-column: 1 / -1;
}

.activity-list {
  display: grid;
  gap: 8px;
}

.activity-empty {
  padding: 16px 0;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.activity-item {
  min-width: 0;
  padding: 11px 12px;
  display: grid;
  grid-template-columns: minmax(120px, 0.3fr) minmax(0, 1fr) auto;
  gap: 5px 12px;
  border-left: 3px solid #c9d0cb;
  background: #f7f9f7;
}

.activity-item.is-alert {
  border-left-color: var(--coral);
  background: #fff6f4;
}

.activity-item strong {
  grid-column: 1;
  grid-row: 1;
  font-size: 12px;
}

.activity-item p {
  grid-column: 2;
  grid-row: 1 / 3;
  min-width: 0;
  margin: 0;
  color: #58625c;
  font-size: 12px;
  line-height: 1.5;
}

.activity-item time {
  grid-column: 1;
  grid-row: 2;
  color: #858d88;
  font-size: 10px;
  white-space: nowrap;
}

.activity-item .secondary-button {
  grid-column: 3;
  grid-row: 1 / 3;
  align-self: center;
  min-height: 30px;
  padding: 5px 9px;
  font-size: 11px;
}

.archive-item strong,
.archive-item span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.archive-item span,
.archive-item small {
  color: var(--muted);
  font-size: 11px;
}

.archive-empty {
  padding: 24px 0;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

dialog {
  width: min(430px, calc(100vw - 30px));
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  color: var(--ink);
  background: #fff;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.32);
}

dialog::backdrop {
  background: rgba(11, 16, 14, 0.7);
}

.manage-dialog {
  width: min(520px, calc(100vw - 30px));
  padding: 26px;
}

.manage-dialog form {
  display: grid;
  gap: 16px;
}

.dialog-heading {
  min-height: 38px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.dialog-heading h2 {
  margin: 4px 0 0;
  font-size: 21px;
}

.dialog-heading .dialog-close {
  position: static;
}

.dialog-context {
  margin: 0;
  padding: 10px 12px;
  color: #515b55;
  background: #f2f5f2;
  font-size: 12px;
}

.manage-dialog .dialog-actions {
  margin-top: 2px;
  justify-content: flex-end;
}

.danger-dialog {
  width: min(570px, calc(100vw - 30px));
}

.close-batch-context {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid #ead6d3;
  border-radius: 6px;
  background: #fffafa;
}

.close-batch-context > div {
  min-width: 0;
  padding: 11px 12px;
}

.close-batch-context > div + div {
  border-left: 1px solid #ead6d3;
}

.close-batch-context span,
.close-batch-context strong {
  display: block;
}

.close-batch-context span {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 10px;
}

.close-batch-context strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.danger-notice {
  margin: 0;
  padding: 11px 12px;
  border-left: 3px solid var(--danger);
  color: #7e332d;
  background: #fdf2f1;
  font-size: 12px;
  line-height: 1.6;
}

.danger-notice strong {
  margin-right: 4px;
}

.history-dialog {
  width: min(980px, calc(100vw - 30px));
  max-height: min(820px, calc(100vh - 30px));
  overflow: auto;
}

.history-summary {
  margin: 18px 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
}

.history-summary > div {
  min-width: 0;
  padding: 12px;
}

.history-summary > div + div {
  border-left: 1px solid var(--line);
}

.history-summary span,
.history-summary strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-summary span {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 10px;
}

.history-summary strong {
  font-size: 14px;
}

.history-closure {
  margin: -7px 0 18px;
  padding: 14px;
  border: 1px solid #ead6d3;
  border-radius: 6px;
  background: #fffafa;
}

.history-closure-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.history-closure-heading > div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.history-closure-heading > div > strong {
  color: #7e332d;
}

.history-closure-heading span {
  color: var(--muted);
  font-size: 11px;
}

.history-closure-heading > strong {
  flex: 0 0 auto;
  color: var(--danger);
  font-size: 12px;
}

.history-closure > p {
  margin: 10px 0 0;
  padding: 8px 10px;
  color: #6d4541;
  background: #f8e9e7;
  font-size: 11px;
}

.history-remaining-list {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.history-remaining-list > div {
  min-width: 0;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px dashed #ddc5c1;
  border-radius: 5px;
  background: #fff;
  font-size: 11px;
}

.history-remaining-list span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-remaining-list strong {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}

.history-remaining-list > p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.history-toolbar {
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.compact-table {
  min-height: 210px;
}

.compact-table .empty-state {
  min-height: 170px;
}

.result-dialog {
  padding: 36px;
  text-align: center;
  overflow: hidden;
}

.dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  color: #67706b;
  background: #f0f2f0;
  cursor: pointer;
  font-size: 20px;
}

.result-dialog h2 {
  margin: 8px 0 24px;
  font-size: 24px;
}

.prize-medallion {
  width: 190px;
  aspect-ratio: 1;
  margin: 0 auto 20px;
  display: grid;
  place-content: center;
  gap: 7px;
  border: 9px solid #f5f0e5;
  border-radius: 50%;
  color: #fff;
  background: var(--medallion, var(--coral));
  box-shadow: 0 0 0 2px var(--medallion, var(--coral));
}

.prize-medallion span {
  font-size: 15px;
  font-weight: 750;
}

.prize-medallion strong {
  font-size: 32px;
}

.result-dialog > p:not(.eyebrow) {
  color: var(--muted);
  font-size: 13px;
}

.result-dialog .primary-button {
  width: 100%;
  margin-top: 8px;
}

.result-confetti i {
  position: absolute;
  width: 7px;
  height: 17px;
  background: var(--amber);
  transform: rotate(20deg);
}

.result-confetti i:nth-child(1) { left: 12%; top: 13%; background: var(--coral); transform: rotate(30deg); }
.result-confetti i:nth-child(2) { left: 23%; top: 5%; background: var(--blue); transform: rotate(-20deg); }
.result-confetti i:nth-child(3) { right: 21%; top: 8%; background: var(--green); transform: rotate(48deg); }
.result-confetti i:nth-child(4) { right: 10%; top: 23%; background: var(--amber); transform: rotate(-38deg); }
.result-confetti i:nth-child(5) { left: 7%; top: 40%; background: var(--green); transform: rotate(70deg); }
.result-confetti i:nth-child(6) { right: 6%; top: 44%; background: var(--coral); transform: rotate(15deg); }

.toast-region {
  position: fixed;
  z-index: 100;
  right: 20px;
  bottom: 20px;
  width: min(360px, calc(100vw - 40px));
  display: grid;
  gap: 8px;
}

.toast {
  padding: 12px 14px;
  border-left: 4px solid var(--green);
  border-radius: 5px;
  color: #fff;
  background: #25302b;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
  font-size: 13px;
  animation: toast-in 180ms ease-out;
}

.toast.is-error {
  border-left-color: var(--coral);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 980px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }

  .header-batch {
    display: none;
  }

  .lottery-layout {
    grid-template-columns: 1fr;
  }

  .wheel-stage {
    min-height: 680px;
  }

  .wheel-zone {
    max-width: 560px;
  }

  .draw-console {
    overflow: visible;
  }

  .admin-kpis {
    grid-template-columns: repeat(2, 1fr);
  }

  .admin-kpis > div:nth-child(3) {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .admin-kpis > div:nth-child(4) {
    border-top: 1px solid var(--line);
  }

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

  .winner-section,
  .config-section {
    grid-column: auto;
  }
}

@media (max-width: 680px) {
  .topbar {
    min-height: 112px;
    padding: 10px 14px;
    grid-template-columns: 1fr;
    justify-items: stretch;
    gap: 8px;
  }

  .brand {
    margin: 0 auto;
  }

  .view-switcher {
    width: 100%;
  }

  .view-tab {
    flex: 1;
  }

  main {
    padding: 12px;
  }

  .lottery-layout {
    min-height: 0;
  }

  .wheel-stage {
    min-height: 520px;
    padding: 22px 16px 26px;
  }

  .section-heading h1 {
    max-width: 220px;
    font-size: 23px;
  }

  .wheel-zone {
    width: 100%;
  }

  .wheel-frame {
    width: 88%;
    border-width: 6px;
  }

  .wheel-pointer {
    top: 2.7%;
    border-left-width: 13px;
    border-right-width: 13px;
    border-top-width: 31px;
  }

  .wheel-hub {
    border-width: 5px;
  }

  .draw-console {
    padding: 28px 20px;
  }

  .quick-stats > div {
    padding-inline: 5px;
  }

  footer {
    justify-content: center;
    text-align: center;
  }

  footer span:last-child {
    display: none;
  }

  .admin-titlebar,
  .section-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-actions,
  .table-tools {
    width: 100%;
  }

  .admin-actions {
    flex-wrap: wrap;
  }

  .table-tools {
    flex-wrap: wrap;
  }

  .compact-select {
    flex: 1;
  }

  .search-field {
    width: 100%;
  }

  .admin-kpis {
    grid-template-columns: 1fr;
  }

  .admin-kpis > div + div,
  .admin-kpis > div:nth-child(3) {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .admin-section {
    padding: 17px;
  }

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

  .config-mode-row,
  .segmented-fieldset,
  .segmented-control {
    width: 100%;
  }

  .segmented-control label {
    flex: 1;
  }

  .segmented-control span {
    min-width: 0;
  }

  .roster-copy {
    align-items: flex-start;
  }

  .tier-editor-labels {
    display: none;
  }

  .tier-editor {
    padding-bottom: 5px;
    overflow: visible;
  }

  .tier-row {
    min-width: 0;
    grid-template-columns: 34px minmax(60px, 0.9fr) minmax(84px, 1.2fr) 56px 28px;
    grid-template-rows: 38px 16px 38px;
    grid-template-areas:
      "color name name name remove"
      ". quantity-label amount-label probability-label ."
      ". quantity amount probability .";
    gap: 5px 7px;
  }

  .tier-row .tier-color {
    grid-area: color;
  }

  .tier-row [data-field="name"] {
    grid-area: name;
  }

  .tier-row [data-field="quantity"],
  .tier-row [data-field="percentage"] {
    grid-area: quantity;
  }

  .tier-row [data-field="amount"] {
    grid-area: amount;
  }

  .tier-row [data-probability] {
    grid-area: probability;
    align-self: center;
  }

  .tier-row [data-remove-tier] {
    grid-area: remove;
  }

  .mobile-tier-label {
    display: block;
    align-self: end;
    color: #77807b;
    font-size: 10px;
  }

  .quantity-label {
    grid-area: quantity-label;
  }

  .amount-label {
    grid-area: amount-label;
  }

  .probability-label {
    grid-area: probability-label;
    text-align: right;
  }

  .balance-policy-heading,
  .balance-preview-summary {
    align-items: flex-start;
  }

  .balance-policy-heading {
    gap: 10px;
  }

  .balance-preview-summary {
    display: grid;
    gap: 4px;
  }

  .balance-preview-tiers {
    grid-template-columns: 1fr;
  }

  .config-checks {
    grid-template-columns: 1fr;
  }

  .config-checks > div + div {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .pool-row {
    grid-template-columns: minmax(80px, 1fr) 72px 72px;
  }

  .pool-row > span:nth-child(3) {
    display: none;
  }

  .participant-row {
    grid-template-columns: minmax(70px, 1fr) minmax(80px, 1fr);
  }

  .participant-row span:last-child {
    grid-column: 1 / -1;
  }

  .activity-item {
    grid-template-columns: 1fr;
  }

  .activity-item .secondary-button {
    grid-column: 1;
    grid-row: auto;
    justify-self: start;
  }

  .activity-item strong,
  .activity-item p,
  .activity-item time {
    grid-column: 1;
    grid-row: auto;
  }

  .manage-dialog {
    padding: 22px 17px;
  }

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

  .history-summary > div:nth-child(3) {
    border-left: 0;
  }

  .history-summary > div:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }

  .history-toolbar {
    flex-direction: column;
  }

  .history-toolbar .search-field {
    width: 100%;
  }

  .close-batch-context,
  .history-remaining-list {
    grid-template-columns: 1fr;
  }

  .close-batch-context > div + div {
    border-left: 0;
    border-top: 1px solid #ead6d3;
  }

  .history-closure-heading {
    display: grid;
  }

  .admin-login {
    margin: 16px auto;
    padding: 28px 20px;
  }

  .result-dialog {
    padding: 32px 22px 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
