:root {
  --bg: #10091f;
  --panel: #22164b;
  --panel-2: #2a1d5c;
  --line: #4f2fa4;
  --text: #fff;
  --muted: #b9a3df;
  --pink: #e54298;
  --purple: #883ef0;
  --cyan: #089eb2;
  --blue: #234abc;
  --orange: #ffab00;
  --danger: #ef4444;
  --radius: 22px;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 25% 15%, rgba(115, 51, 236, .28), transparent 34rem),
    radial-gradient(circle at 82% 75%, rgba(229, 66, 152, .22), transparent 30rem),
    var(--bg);
  min-height: 100vh;
}
a { color: inherit; }
button, input, select { font: inherit; }

.public-hero {
  min-height: 154px;
  padding: 34px 18px 28px;
  text-align: center;
  position: relative;
  background:
    linear-gradient(105deg, rgba(128, 55, 239, .96), rgba(229, 66, 152, .96)),
    repeating-linear-gradient(90deg, transparent 0 40px, rgba(255,255,255,.12) 41px 43px);
  overflow: hidden;
}
.public-hero::after {
  content: "";
  inset: 0;
  position: absolute;
  background-image:
    linear-gradient(rgba(255,255,255,.12) 2px, transparent 2px),
    linear-gradient(90deg, rgba(255,255,255,.12) 2px, transparent 2px);
  background-size: 45px 45px;
  opacity: .25;
}
.brand {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 18px;
  font-size: clamp(1.65rem, 4vw, 2.35rem);
  font-weight: 900;
  letter-spacing: 4px;
  text-transform: uppercase;
  text-shadow: 0 3px 0 rgba(0,0,0,.18);
}
.brand-icon { font-size: 2.2rem; }
.lottery-icon {
  width: 48px;
  height: 48px;
  display: inline-grid;
  place-items: center;
  color: #fff;
  filter: drop-shadow(0 3px 0 rgba(0,0,0,.18));
}
.lottery-icon svg {
  width: 100%;
  height: 100%;
}
.lottery-icon .lottery-globe {
  fill: rgba(255,255,255,.2);
  stroke: #fff;
  stroke-width: 4;
}
.lottery-icon .lottery-base {
  fill: #ffab00;
}
.lottery-icon circle:not(.lottery-globe) {
  fill: #fff;
}
.public-hero p { position: relative; z-index: 1; margin: 14px 0 0; font-size: 1.2rem; }
.admin-link { position: absolute; z-index: 2; right: 18px; top: 18px; color: rgba(255,255,255,.75); text-decoration: none; font-weight: 800; }
.shell { width: min(1000px, calc(100% - 28px)); margin: 30px auto 70px; }
.hidden { display: none !important; }
.public-footer {
  width: min(1000px, calc(100% - 28px));
  margin: -42px auto 28px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  color: rgba(255,255,255,.72);
  font-size: .95rem;
  font-weight: 700;
}
.public-footer a {
  color: #fff;
  font-weight: 900;
  text-decoration: none;
}
.public-footer a:hover { color: var(--orange); }

.panel {
  background: rgba(34, 22, 75, .95);
  border: 1px solid rgba(126, 70, 241, .45);
  border-radius: var(--radius);
  margin: 0 0 30px;
  overflow: hidden;
  box-shadow: 0 24px 70px rgba(0,0,0,.24);
}
.panel-title {
  padding: 24px 32px;
  font-size: 1.45rem;
  font-weight: 900;
  letter-spacing: 2px;
  text-transform: uppercase;
  background: linear-gradient(100deg, var(--purple), #6828c5);
}
.info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  padding: 30px;
}
.info-grid div {
  background: rgba(255,255,255,.04);
  border-radius: 12px;
  padding: 22px;
  text-align: center;
}
.info-grid span, th { color: var(--muted); text-transform: uppercase; letter-spacing: 2px; font-weight: 800; }
.info-grid strong { display: block; margin-top: 10px; color: var(--orange); font-size: 1.75rem; }
.info-grid small { display: block; margin-top: 8px; color: #eadcff; font-weight: 800; }
.notice {
  margin: 30px 30px 24px;
  padding: 16px;
  border-radius: 14px;
  text-align: center;
  font-weight: 800;
  color: #eadcff;
  background: linear-gradient(90deg, rgba(136,62,240,.28), rgba(229,66,152,.36));
  border: 1px solid rgba(204, 140, 255, .45);
}
.number-grid {
  margin: 0 30px 22px;
  padding: 24px;
  border-radius: 14px;
  display: grid;
  grid-template-columns: repeat(10, minmax(54px, 1fr));
  gap: 10px;
  background: linear-gradient(110deg, #8c3ff0, #e54298);
}
.number-btn {
  aspect-ratio: 1;
  min-width: 0;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,.34);
  color: #fff;
  background: rgba(255,255,255,.08);
  font-weight: 900;
  cursor: pointer;
}
.number-btn:hover:not(:disabled), .number-btn.selected {
  background: #fff;
  color: #8036e7;
  border-color: #111;
  outline: 3px solid rgba(255,255,255,.55);
}
.number-btn.locked {
  opacity: .28;
  cursor: not-allowed;
  color: rgba(255,255,255,.55);
  background: rgba(0,0,0,.28);
}
.number-btn.pending {
  opacity: .78;
  cursor: not-allowed;
  color: #1c1240;
  background: var(--orange);
  border-color: #fff;
}
.selection-strip { display: flex; justify-content: center; align-items: center; min-height: 58px; }
.pill {
  display: inline-grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: #fff;
  color: #7f38e9;
  font-weight: 900;
  font-size: 1.25rem;
}
.btn {
  border: 0;
  border-radius: 999px;
  padding: 16px 24px;
  color: #fff;
  font-weight: 900;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}
.btn-primary { background: linear-gradient(100deg, var(--purple), var(--pink)); }
.btn-cyan { background: var(--cyan); }
.btn-blue { background: var(--blue); }
.btn-danger { background: var(--danger); }
.btn-ghost { background: transparent; border: 3px solid var(--line); color: var(--muted); }
.icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  flex: 0 0 36px;
}
.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.btn-wide { width: calc(100% - 60px); margin: 0 30px 16px; font-size: 1.25rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: grayscale(.5); }
.progress-row { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 0 30px 28px; color: #bca8ff; }
.progress-row div { height: 10px; background: rgba(255,255,255,.12); border-radius: 999px; overflow: hidden; }
.progress-row i { display: block; height: 100%; background: linear-gradient(90deg, var(--purple), var(--pink)); }
.ticket-panel .panel-title, .winners-panel .panel-title { background: linear-gradient(90deg, #109a95, #0c9fc5); }
.winners-panel .panel-title { background: linear-gradient(90deg, #234abc, #2544ba); }
.empty-panel, .empty-state { padding: 80px 24px; text-align: center; color: var(--muted); font-size: 1.2rem; }
.ticket-list { display: grid; gap: 12px; padding: 20px; }
.ticket-box { padding: 8px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.ticket-box div { background: rgba(255,255,255,.04); padding: 18px; border-radius: 12px; }
.ticket-box span { color: var(--muted); display: block; margin-bottom: 6px; }
.ticket-total, .payment-summary {
  display: grid;
  gap: 8px;
  padding: 18px;
  border-radius: 12px;
  background: rgba(255,171,0,.12);
  border: 1px solid rgba(255,171,0,.32);
  color: #fff3cf;
  font-weight: 800;
}
.payment-summary { margin-bottom: 22px; }
.payment-summary strong, .ticket-total strong { color: var(--orange); }
.pix-copy-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.pix-copy-btn {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(255,171,0,.45);
  border-radius: 10px;
  background: rgba(255,255,255,.08);
  color: #fff3cf;
  cursor: pointer;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}
.pix-copy-btn:hover,
.pix-copy-btn.copied {
  background: var(--orange);
  color: #22164b;
  transform: translateY(-1px);
}
.pix-copy-btn:disabled {
  cursor: wait;
  opacity: .72;
}
.pix-copy-btn .icon {
  width: 19px;
  height: 19px;
}
.ticket-remove {
  display: inline-flex;
  margin-top: 10px;
  border: 0;
  background: transparent;
  color: #ffc2c2;
  padding: 0;
  font-weight: 900;
  cursor: pointer;
}
.btn-pay-now {
  justify-self: start;
  margin-top: 6px;
}
.rifa-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; padding: 30px; }
.rifa-card { background: rgba(255,255,255,.05); border-radius: 14px; padding: 20px; display: grid; gap: 10px; align-content: start; }
.rifa-select-btn {
  justify-self: end;
  width: auto;
  min-width: max-content;
  height: auto;
  padding: 12px 20px;
  flex-basis: auto;
  line-height: 1;
  white-space: nowrap;
}
.rifa-card em { color: var(--orange); font-style: normal; font-weight: 900; }
.previous-draw + .previous-draw { border-top: 1px solid rgba(126,70,241,.45); }
.previous-head { padding: 28px; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.draw-balls { display: flex; gap: 8px; }
.draw-balls b { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: #1c1240; background: #fff; }
.empty-state-compact { padding: 24px; border-top: 1px solid rgba(126,70,241,.3); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 24px; text-align: left; border-top: 1px solid rgba(126,70,241,.3); }
td { color: #f8f4ff; }
.rifas-table th, .rifas-table td { padding: 12px 18px; }
.rifas-table .actions { min-width: 84px; }
.winner-list {
  min-width: 190px;
  max-width: 260px;
  line-height: 1.35;
}
.winner-list span {
  display: block;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  padding: 20px;
  background: rgba(0,0,0,.72);
  z-index: 30;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.modal.open { display: grid; }
.modal-card {
  width: min(630px, 100%);
  max-height: calc(100dvh - 40px);
  background: #22164b;
  border: 1px solid rgba(126,70,241,.65);
  border-radius: 20px;
  box-shadow: 0 30px 90px rgba(0,0,0,.45);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.modal-head { padding: 28px 32px; font-size: 1.45rem; font-weight: 900; border-bottom: 1px solid rgba(126,70,241,.42); }
.modal form, .modal-card > p { padding: 28px 32px; margin: 0; color: var(--muted); font-size: 1.08rem; }
label { display: grid; gap: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 2px; font-weight: 900; margin-bottom: 22px; }
input, select {
  width: 100%;
  border: 3px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px;
  background: #2a1d5c;
  color: #fff;
  outline: 0;
}
.check { display: flex; align-items: center; gap: 10px; text-transform: none; letter-spacing: 0; font-weight: 700; }
.check input { width: auto; }
.check button { border: 0; background: transparent; color: #fff; font-weight: 900; text-decoration: underline; cursor: pointer; }
.form-msg { min-height: 24px; color: #ffc2c2; font-weight: 800; }
.modal-actions { display: flex; gap: 14px; justify-content: flex-end; margin-top: 24px; }
.confirm-card .modal-actions { padding: 0 32px 28px; margin-top: 0; }
.toast-area {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 80;
  display: grid;
  gap: 10px;
  width: min(380px, calc(100vw - 36px));
}
.toast {
  padding: 16px 18px;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(100deg, var(--purple), var(--pink));
  border: 1px solid rgba(255,255,255,.18);
  box-shadow: 0 18px 50px rgba(0,0,0,.35);
  font-weight: 900;
  opacity: 1;
  transform: translateY(0);
  transition: opacity .22s ease, transform .22s ease;
}
.toast-error { background: linear-gradient(100deg, #ef4444, #e54298); }
.toast-hide { opacity: 0; transform: translateY(-8px); }

.admin-page { display: grid; grid-template-columns: 270px 1fr; background: #140d2a; }
.sidebar { min-height: 100vh; background: #1f1546; border-right: 1px solid rgba(126,70,241,.36); padding: 26px; position: sticky; top: 0; }
.sidebar .brand { font-size: 1.25rem; letter-spacing: 1px; justify-content: flex-start; margin-bottom: 34px; }
.nav { display: grid; gap: 10px; }
.nav a { text-decoration: none; color: var(--muted); padding: 14px 16px; border-radius: 10px; font-weight: 800; }
.nav a.active, .nav a:hover { color: #fff; background: linear-gradient(100deg, var(--purple), var(--pink)); }
.admin-main { min-width: 0; }
.topbar { height: 74px; display: flex; align-items: center; justify-content: space-between; padding: 0 28px; border-bottom: 1px solid rgba(126,70,241,.32); background: rgba(31,21,70,.75); }
.content { padding: 28px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; }
.stat { background: #22164b; border: 1px solid rgba(126,70,241,.42); border-radius: 16px; padding: 22px; }
.stat span { color: var(--muted); }
.stat strong { display: block; color: var(--orange); font-size: 2rem; margin-top: 8px; }
.admin-auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 25% 30%, rgba(136,62,240,.28), transparent 28rem), var(--bg); }
.auth-card { width: min(570px, 100%); padding: 48px; background: #22164b; border: 1px solid rgba(126,70,241,.5); border-radius: 20px; }
.auth-logo { text-align: center; margin-bottom: 28px; color: #dd72e4; font-size: 2.2rem; font-weight: 900; }
.actions {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  align-items: center;
  white-space: nowrap;
}
.actions form { margin: 0; flex: 0 0 auto; }
.admin-toolbar { display: flex; justify-content: flex-end; margin-bottom: 18px; }
.admin-form { background: #22164b; border: 1px solid rgba(126,70,241,.42); border-radius: 16px; padding: 24px; margin-bottom: 24px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; align-items: end; }
.form-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.alert { padding: 14px 18px; border-radius: 12px; margin-bottom: 18px; background: rgba(16,158,178,.16); color: #c8fbff; }
.alert.error { background: rgba(239,68,68,.16); color: #ffd4d4; }
.badge { padding: 6px 10px; border-radius: 999px; background: rgba(16,158,178,.2); color: #b7fbff; font-weight: 900; }
.badge.closed { background: rgba(229,66,152,.18); color: #ffd1ed; }

@media (max-width: 760px) {
  .shell { width: min(100% - 16px, 1000px); margin-top: 16px; }
  .public-hero { min-height: 130px; }
  .brand { letter-spacing: 1px; gap: 10px; }
  .admin-link { display: none; }
  .public-footer { flex-wrap: wrap; margin-top: -34px; }
  .panel-title { padding: 20px; font-size: 1rem; }
  .info-grid, .ticket-box { grid-template-columns: 1fr; padding: 18px; }
  .number-grid { grid-template-columns: repeat(5, 1fr); margin: 0 14px 18px; padding: 14px; gap: 8px; }
  .btn-wide { width: calc(100% - 28px); margin-inline: 14px; }
  .progress-row { padding-inline: 14px; grid-template-columns: 1fr; }
  .modal {
    align-items: start;
    padding: 10px;
  }
  .modal-card {
    max-height: calc(100dvh - 20px);
    border-radius: 16px;
  }
  .modal-head { padding: 20px; font-size: 1.1rem; }
  .modal form, .modal-card > p { padding: 20px; }
  .modal-actions { flex-direction: column; }
  .admin-page { grid-template-columns: 1fr; }
  .sidebar { position: static; min-height: auto; }
  .nav { grid-template-columns: repeat(2, 1fr); }
  .content, .topbar { padding-inline: 16px; }
  .auth-card { padding: 28px 20px; }
}
