:root {
  --paper: #f2e8cd;
  --paper-deep: #e6d6a8;
  --surface: #fffdf6;
  --ink: #221c12;
  --muted: #796e52;
  --line: #d9c89a;
  --brand: #0b4a36;
  --brand-ink: #f2e8cd;
  --gold: #f0b429;
  --accent: #c0392b;
  --reserved: #ecc568;
  --sold: #c3b78d;
  --danger: #a3241b;
  --radius: 4px;
  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-mono: "Space Mono", ui-monospace, Menlo, monospace;
  --font-body: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 var(--font-body);
}

main { max-width: 960px; margin: 0 auto; padding: 16px; }

h1, h2, h3 { font-family: var(--font-display); font-weight: 700; line-height: 1.2; margin: 0 0 8px; }

/* Ticket: a torn-stub hero instead of a generic rounded card */
.ticket { border: 1px solid var(--paper-deep); border-radius: var(--radius); overflow: hidden; margin-bottom: 28px; }
.ticket-face { position: relative; background: var(--brand); color: var(--brand-ink); padding: 26px 20px 30px; }
.ticket-face h1 { font-size: clamp(1.5rem, 5vw, 2.1rem); }
.ticket-label { font-size: .95rem; opacity: .85; }
.ticket-face p { margin: 4px 0 0; opacity: .95; }
.ticket-face::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: 0; height: 14px;
  background-image: radial-gradient(circle at 7px 7px, var(--paper-deep) 6px, transparent 6.5px);
  background-size: 14px 14px;
  background-repeat: repeat-x;
}
.prize { font: 700 clamp(2.1rem, 8vw, 3.2rem)/1.1 var(--font-mono); color: var(--gold); margin: 2px 0 10px; }

.ticket-stub.facts {
  background: var(--paper-deep);
  margin: 0;
  padding: 18px 20px 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
}
.fact { color: var(--ink); font-size: .95rem; }
.fact b { display: block; font: 700 1.05rem/1.3 var(--font-mono); margin-top: 2px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 20px;
}

.status-line { padding: 12px 2px 18px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }

.progress { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 10px 0 2px; }
.progress > div { height: 100%; background: var(--brand); }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs button {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 99px;
  padding: 6px 14px;
  font: 600 .95rem var(--font-body);
  cursor: pointer;
  color: var(--ink);
}
.tabs button[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }

.grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.num {
  font: 700 .85rem/1 var(--font-mono);
  padding: 10px 0;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--ink);
}
.num:hover:not(:disabled) { border-color: var(--brand); }
.num.reservado { background: var(--reserved); cursor: not-allowed; }
.num.vendido { background: var(--sold); color: var(--muted); text-decoration: line-through; cursor: not-allowed; }
.num.selected { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.num.partner { outline: 2px dashed var(--brand); outline-offset: -2px; }

.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: .85rem; color: var(--muted); margin-top: 8px; }
.legend span::before {
  content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 3px;
  margin-right: 4px; vertical-align: -1px; border: 1px solid var(--line);
}
.legend .l-free::before { background: var(--surface); }
.legend .l-res::before { background: var(--reserved); }
.legend .l-sold::before { background: var(--sold); }
.legend .l-sel::before { background: var(--brand); }

.chips { display: flex; gap: 8px; margin: 8px 0; min-height: 40px; align-items: center; }
.chip {
  font: 700 1.3rem/1 var(--font-mono);
  background: var(--brand); color: var(--brand-ink);
  padding: 8px 14px; border-radius: var(--radius);
}
.chip.empty { background: transparent; color: var(--muted); border: 2px dashed var(--line); }

label { display: block; font-weight: 600; margin: 12px 0 4px; }
input {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

.btn {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
  padding: 12px 18px;
  border-radius: var(--radius);
  border: 0;
  background: var(--brand);
  color: var(--brand-ink);
  cursor: pointer;
  text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: var(--danger); }
.btn.small { padding: 6px 10px; font-size: .85rem; }
.btn.block { width: 100%; margin-top: 16px; }

.error { color: var(--danger); font-weight: 600; min-height: 1.5em; margin-top: 8px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

.winner { border: 3px solid var(--accent); background: var(--surface); transform: rotate(-1deg); }
.winner h2 { color: var(--accent); }
.winner .big { font: 700 3rem/1 var(--font-mono); color: var(--brand); }

/* Admin */
.stats { display: flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 16px; }
.stat { flex: 1 1 150px; background: var(--surface); padding: 12px 16px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat b { display: block; font: 700 1.15rem/1.3 var(--font-mono); overflow-wrap: anywhere; margin-top: 2px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input { flex: 1 1 200px; width: auto; }
.toolbar-title { flex: 1 1 200px; margin: 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-family: var(--font-display); }
td.nums { font: 700 1rem var(--font-mono); }
.badge { padding: 2px 8px; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.badge.pendiente { background: var(--reserved); }
.badge.pagado { background: #cfe6da; color: var(--brand); }
.badge.vencido, .badge.cancelado { background: var(--line); color: var(--muted); }
.row-actions { display: flex; gap: 6px; }

/* Verification Code Card */
.code-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.code-box-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.code-display {
  font: 700 1.9rem/1 var(--font-mono);
  letter-spacing: 4px;
  background: var(--brand);
  color: var(--gold);
  padding: 8px 16px;
  border-radius: var(--radius);
  user-select: all;
}
.code-meta {
  margin-top: 10px;
  font-size: .85rem;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.code-feedback {
  color: var(--brand);
  font-weight: 700;
}

@media (max-width: 480px) {
  .toolbar-title { flex-basis: 100%; }
  .grid { grid-template-columns: repeat(5, 1fr); gap: 6px; }
  .num { padding: 12px 0; font-size: .85rem; }
}
