:root {
  --blue: #0c4c96;
  --blue-deep: #020940;
  --ink: #071433;
  --card: #f3f6fb;
  --gold: #ffe082;
  --line: rgba(255, 255, 255, 0.28);
  --ok: #1b7f3a;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
  font-family: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  color: white;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.16), transparent 32%),
    linear-gradient(160deg, var(--blue) 0%, var(--blue-deep) 72%);
}
button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: var(--gold); }

.top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 16px 22px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.brand-mark {
  width: 64px;
  height: 36px;
  object-fit: contain;
  flex: 0 0 auto;
}
.brand small { display: block; font-size: 13px; font-weight: 600; opacity: 0.85; }
.home-logo {
  display: block;
  width: min(340px, 78%);
  margin: 0 auto 18px;
  object-fit: contain;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.35));
}
.login-card .home-logo { width: min(280px, 86%); margin-bottom: 12px; }
.login-card h2 { text-align: center; }
.login-card > .muted:first-of-type { text-align: center; }
.links { display: flex; gap: 10px; flex-wrap: wrap; }
.links a, .ghost {
  color: white;
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  background: transparent;
}
.card .ghost { color: var(--ink); border-color: #c9d4e6; }

.home {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.home-card {
  width: min(720px, 100%);
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 32px;
  box-shadow: var(--shadow);
}
.home-card h1 { margin: 0 0 8px; font-size: 42px; text-align: center; }
.home-card > p { text-align: center; }
.grid-links { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 22px; }
.grid-links a {
  display: block;
  background: var(--card);
  color: var(--ink);
  text-decoration: none;
  border-radius: 16px;
  padding: 18px;
  font-weight: 800;
}
.grid-links a span { display: block; font-weight: 600; color: #3e5270; margin-top: 4px; }

.board {
  height: 100vh;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 210px 1fr 250px;
  gap: 14px;
  padding: 14px;
}
.board > .panel:nth-child(2) { display: flex; flex-direction: column; }
.board .cards { flex: 1; }
.board .pay-card {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.panel {
  background: rgba(0, 0, 0, 0.16);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px;
}
.panel h2 { margin: 0 0 10px; font-size: 14px; letter-spacing: 0.12em; }
.clock-box { text-align: center; }
.clock-box .count {
  font-size: 72px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.clock-box .phase { color: var(--gold); font-weight: 800; letter-spacing: 0.08em; }
.hash { word-break: break-all; font-size: 12px; opacity: 0.85; margin-top: 10px; }
#draw-video { display: flex; align-items: center; }
#draw-video .live-draw { width: 280px; height: 86px; background: #111; border-radius: 10px; }
.board .live-draw, .card .live-draw { width: 100%; max-height: 62vh; background: #020940; border-radius: 18px; }
body.cinema { background: #000; overflow: hidden; }
body.cinema .board {
  display: block;
  height: 100vh;
  padding: 0;
  background: #000;
}
body.cinema .board > .panel:not(#stage) { display: none; }
body.cinema #stage {
  display: block;
  position: fixed;
  inset: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #000;
}
body.cinema .live-draw {
  width: 100vw;
  height: 100vh;
  max-height: none;
  object-fit: contain;
  border-radius: 0;
  background: #000;
}
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.pay-card {
  background: var(--card);
  color: var(--ink);
  border-radius: 18px;
  padding: 16px;
  min-height: 280px;
}
.pay-card h3 { margin: 0 0 12px; color: var(--blue); letter-spacing: 0.14em; }
.tiers { display: flex; justify-content: space-between; gap: 8px; text-align: center; }
.tiers b { display: block; font-size: 28px; color: var(--blue); }
.tiers span { font-size: 13px; }
.positions { display: flex; justify-content: space-between; margin-top: 18px; text-align: center; }
.ball {
  width: 62px; height: 62px; border-radius: 50%;
  display: grid; place-items: center; margin: 0 auto 6px;
  background: radial-gradient(circle at 35% 30%, #fff, #d5e4f8 55%, #8eb4e0);
  color: var(--blue-deep); font-weight: 800; font-size: 20px;
  box-shadow: inset -6px -8px 12px rgba(2, 9, 64, 0.18), 0 6px 10px rgba(0, 0, 0, 0.18);
}
.ball.sm { width: 36px; height: 36px; font-size: 13px; }
.result-row { display: flex; gap: 4px; align-items: center; margin-bottom: 8px; }
.result-row em { font-style: normal; width: 28px; font-size: 12px; opacity: 0.8; }
.closed, .cages-wrap { min-height: 62vh; display: grid; place-items: center; text-align: center; }
.closed p { letter-spacing: 0.18em; font-size: 28px; margin: 0; }
.closed .big { font-size: 120px; font-weight: 800; line-height: 1; }
.cages { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.cage {
  width: 120px; min-height: 210px; border-radius: 18px;
  border: 2px solid rgba(255,255,255,0.7);
  background: linear-gradient(180deg, rgba(255,255,255,0.2), rgba(255,255,255,0.05));
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  padding: 12px;
}
.drop { animation: drop 0.7s ease both; }
@keyframes drop { from { transform: translateY(-90px); opacity: 0; } to { transform: none; opacity: 1; } }

.shell { padding: 12px 16px 24px; }
.login-wrap { min-height: calc(100vh - 80px); display: grid; place-items: center; }
.card {
  background: var(--card); color: var(--ink); border-radius: 18px; padding: 18px; box-shadow: var(--shadow);
}
.login-wrap .card { width: min(420px, 100%); }
label { display: block; font-size: 13px; font-weight: 700; margin: 10px 0 4px; }
input, select {
  width: 100%; border: 1px solid #c9d4e6; border-radius: 10px; padding: 10px 12px; background: white; color: var(--ink);
}
select.list { min-height: 9.5rem; }
table input, table select { width: auto; min-width: 4.5rem; }
.primary, .warn, .good {
  border: 0; border-radius: 12px; padding: 12px 14px; font-weight: 800; color: white;
}
.primary { background: var(--blue-deep); }
.warn { background: #8d6e00; }
.good { background: var(--ok); }
.full { width: 100%; }

.pos {
  display: grid;
  grid-template-columns: 300px minmax(280px, 1fr) 280px;
  gap: 12px;
  align-items: start;
}
.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.modes button, .amounts button, .keys button {
  border: 0; border-radius: 12px; background: #fff; color: var(--ink); font-weight: 800; padding: 12px;
}
.modes button.on, .amounts button.on { background: var(--blue-deep); color: white; }
.display {
  margin: 12px 0; background: white; color: var(--ink); border-radius: 14px; padding: 12px; text-align: center;
}
.display strong { font-size: 40px; letter-spacing: 0.12em; }
.keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.keys button { font-size: 22px; min-height: 58px; }
.amounts { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.line, button.line {
  display: flex; justify-content: space-between; gap: 8px; padding: 8px 0;
  border: 0; border-bottom: 1px solid #d5e0ef; width: 100%;
  background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.muted { color: #3e5270; font-size: 13px; }
.banner {
  background: #020940; color: var(--gold); border-radius: 12px; padding: 10px 12px; font-weight: 800; margin-bottom: 10px;
}
.lock-mark {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.lock-mark[hidden] { display: none; }
.lock-mark.on { opacity: 1; }
.lock-mark img {
  width: min(58vw, 480px);
  max-height: 52vh;
  object-fit: contain;
  opacity: 0.22;
  transform: rotate(-8deg);
  filter: drop-shadow(0 2px 10px rgba(0, 0, 0, 0.18));
  user-select: none;
}
.ticket-preview { margin-top: 10px; }
.slip {
  margin: 0;
  font-family: "Courier New", Courier, monospace;
  font-size: 13px;
  line-height: 1.25;
  white-space: pre;
  color: #111;
  background: white;
}
.qr { display: block; width: 168px; height: 168px; margin: 8px auto 0; background: white; image-rendering: pixelated; }
#print-root { display: none; }
.barcode-box { display: flex; justify-content: center; margin-top: 8px; }
.barcode { display: block; background: white; }
.actions { display: grid; gap: 8px; }
.mini { font-size: 13px; padding: 6px 8px; border-radius: 8px; border: 0; background: #d7e3f5; color: var(--ink); }
.modal {
  position: fixed; inset: 0; z-index: 40;
  display: grid; place-items: center;
  background: rgba(2, 9, 64, 0.55);
  padding: 16px;
}
.modal[hidden] { display: none; }
.modal-card {
  width: min(420px, 100%);
  background: var(--card); color: var(--ink);
  border-radius: 18px; padding: 22px; box-shadow: var(--shadow);
}
.pay-amount {
  font-size: 42px; font-weight: 800; margin: 8px 0 18px;
  font-variant-numeric: tabular-nums;
}

.desk {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.menu { display: flex; flex-direction: column; gap: 8px; position: sticky; top: 12px; }
.menu button {
  text-align: left;
  color: white;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  font-weight: 800;
}
.menu button.on { background: var(--card); color: var(--ink); }
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.stat { background: white; color: var(--ink); border-radius: 12px; padding: 10px; }
.stat b { display: block; font-size: 22px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 6px 4px; border-bottom: 1px solid #d5e0ef; vertical-align: top; }
.row-2 { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 12px; }
.pay-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px 16px; align-items: end; }
.pay-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pay-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.field label { margin-top: 0; }
table.form { min-width: 520px; }
table.form td { vertical-align: middle; }
table.form input.amt { width: 7rem; min-width: 7rem; }
table.form select { width: auto; min-width: 9rem; }
.sheet, #finance, #commissions, #group-caps, #box-caps, #terminals, #sales { overflow-x: auto; }
table.nums th.right, table.nums td.right { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

@media (max-width: 980px) {
  .board, .pos, .grid-links, .cards, .stats, .row-2, .pay-grid, .pay-grid.cols-3, .pay-grid.cols-4, .desk { grid-template-columns: 1fr; }
  .menu { flex-direction: row; flex-wrap: wrap; position: static; }
  .menu button { flex: 1 1 auto; }
  .clock-box .count, .closed .big { font-size: 72px; }
}

/* ---- Ticket ganador ---- */
.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 100; pointer-events: none; }
.winner-banner {
  margin: 14px 0; padding: 18px 14px; border-radius: 16px; text-align: center; color: #3b2600;
  background: linear-gradient(110deg, #ffd54f, #fff6c2, #ffca28, #fff6c2, #ffd54f);
  background-size: 250% 100%;
  box-shadow: 0 0 0 2px rgba(255, 213, 79, 0.7), 0 10px 34px rgba(255, 193, 7, 0.45);
  animation: win-shimmer 2.6s linear infinite, win-pop 0.7s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.winner-banner h2 { margin: 0; font-size: 26px; letter-spacing: 0.06em; font-weight: 900; }
.winner-banner .amount { font-size: 46px; font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1.15; }
.winner-banner small { display: block; font-weight: 700; opacity: 0.8; }
.modal-card.win {
  animation: win-pop 0.6s cubic-bezier(0.2, 1.4, 0.4, 1) both, win-glow 1.5s ease-in-out 0.6s infinite alternate;
}
.modal-card.win h2 { color: #8a5a00; letter-spacing: 0.04em; }
.modal-card.win .pay-amount { color: #8a5a00; text-shadow: 0 0 18px rgba(255, 193, 7, 0.55); }
.win-toast {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 90;
  padding: 12px 30px; border-radius: 18px; font-weight: 900; color: #3b2600; text-align: center;
  max-width: calc(100vw - 24px); white-space: nowrap;
  background: linear-gradient(110deg, #ffd54f, #fff6c2, #ffca28);
  box-shadow: 0 0 0 2px rgba(255, 213, 79, 0.8), 0 10px 30px rgba(0, 0, 0, 0.35);
  animation: win-drop 0.6s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.win-toast[hidden] { display: none; }
.win-toast small { display: block; font-weight: 700; opacity: 0.8; }
@keyframes win-shimmer { to { background-position: -250% 0; } }
@keyframes win-pop { from { transform: scale(0.6); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes win-drop { from { transform: translate(-50%, -140%); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
@keyframes win-glow {
  from { box-shadow: 0 0 0 3px rgba(255, 213, 79, 0.45), 0 0 22px rgba(255, 193, 7, 0.35); }
  to { box-shadow: 0 0 0 3px rgba(255, 213, 79, 0.95), 0 0 58px rgba(255, 193, 7, 0.85); }
}
@media (prefers-reduced-motion: reduce) {
  .winner-banner, .modal-card.win, .win-toast { animation: none !important; }
}
@media print {
  html, body {
    margin: 0 !important; padding: 0 !important;
    height: auto !important; min-height: 0 !important;
    background: white !important; color: black !important;
  }
  body > *:not(#print-root) { display: none !important; }
  #print-root {
    display: block; position: static; width: 72mm;
    color: black; background: white;
    break-inside: avoid; page-break-inside: avoid;
  }
  #print-root .slip { font-size: 12px; color: black; background: white; }
  #print-root .qr { width: 32mm; height: 32mm; }
  #print-root .barcode-box { margin-top: 3mm; }
  #print-root .barcode { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  @page { size: 80mm auto; margin: 3mm; }
}
