:root {
  --blue-950: #072352;
  --blue-900: #0a2f73;
  --blue-700: #0b4fb3;
  --blue-600: #0a62c8;
  --blue-500: #1e88e5;
  --blue-400: #1ea0e6;
  --blue-100: #dcebfb;
  --blue-50: #f1f7fe;
  --red: #e8334a;
  --green: #17a34a;
  --amber: #f59e0b;
  --ink: #0f1f3d;
  --muted: #5b6b86;
  --line: #d6e3f5;
  --radius: 16px;
  --shadow: 0 6px 20px rgba(10, 47, 115, 0.12);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Nunito', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--blue-50);
  color: var(--ink);
  line-height: 1.45;
}
img { max-width: 100%; display: block; }
button, input, textarea, select { font: inherit; color: inherit; }
select {
  border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fff; outline: none;
}
select:focus { border-color: var(--blue-500); }
button { cursor: pointer; }
.hidden { display: none !important; }

/* ---------- Header ---------- */
.header {
  background: linear-gradient(135deg, var(--blue-900), var(--blue-600) 60%, var(--blue-400));
  color: #fff;
  position: sticky; top: 0; z-index: 30;
  box-shadow: 0 3px 14px rgba(7, 35, 82, 0.35);
}
.header-in {
  max-width: 1100px; margin: 0 auto; padding: 8px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 900; letter-spacing: .4px; }
.brand img { height: 55px; width: auto; display: block; }
.brand small { display: block; font-weight: 700; font-size: 11px; opacity: .85; letter-spacing: 1.4px; }
.nav { display: flex; gap: 6px; }
.nav button {
  background: rgba(255, 255, 255, .15); color: #fff; border: 0; border-radius: 999px;
  padding: 8px 14px; font-weight: 800; font-size: 14px;
}
.nav-toggle {
  display: none; background: rgba(255,255,255,.15); color: #fff; border: 0; border-radius: 10px;
  width: 40px; height: 40px; font-size: 20px; line-height: 1; flex: none;
}
.nav button:hover, .nav button.on { background: #fff; color: var(--blue-700); }

/* ---------- Layout ---------- */
.wrap { max-width: 1100px; margin: 0 auto; padding: 18px 16px 120px; }
.hero {
  display: grid; grid-template-columns: 1fr 150px; gap: 20px; align-items: center;
  background: linear-gradient(135deg, var(--blue-700), var(--blue-500));
  color: #fff; border-radius: 24px; padding: 18px 24px; box-shadow: var(--shadow); overflow: hidden;
  position: relative;
}
.hero h1 { margin: 0 0 6px; font-size: clamp(20px, 3.6vw, 30px); line-height: 1.18; font-weight: 900; text-shadow: 0 2px 0 rgba(0,0,0,.12); }
.hero h1 .accent { color: #ffe169; }
.hero .desc { margin: 0; opacity: .97; font-weight: 700; font-size: clamp(13px, 1.6vw, 15px); line-height: 1.4; }
.hero .sub { margin: 8px 0 0; opacity: .8; font-weight: 600; font-size: 13px; line-height: 1.4; }
.hero img { width: 150px; justify-self: end; border-radius: 22%; background: #fff; border: 3px solid #fff; box-shadow: 0 8px 22px rgba(0,0,0,.25); }
.pill { display: inline-block; background: rgba(255,255,255,.2); border-radius: 999px; padding: 3px 12px; font-size: 11px; font-weight: 800; letter-spacing: .8px; margin-bottom: 8px; }
.section-title { font-size: 13px; letter-spacing: 1.6px; color: var(--blue-700); font-weight: 900; margin: 26px 0 10px; text-transform: uppercase; }

/* ---------- Cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.card {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
  border: 1px solid var(--line); display: flex; flex-direction: column;
}
.cover { aspect-ratio: 16/10; background: var(--blue-100); position: relative; border-radius: var(--radius); overflow: hidden; }
.card .cover { border-radius: 0; }
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover .ph { height: 100%; display: grid; place-items: center; font-size: 54px; }
.card .badge { position: absolute; top: 10px; left: 10px; background: var(--red); color: #fff; font-weight: 900; font-size: 12px; padding: 4px 10px; border-radius: 999px; }
.card .body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card h3 { margin: 0; font-size: 19px; font-weight: 900; color: var(--blue-900); }
.card .desc { color: var(--muted); font-size: 14px; margin: 0; }
.prize-list { margin: 0; padding: 0; list-style: none; font-size: 14px; font-weight: 700; }
.prize-list li { padding: 2px 0; }
.progress { height: 10px; background: var(--blue-100); border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--blue-500), var(--blue-400)); border-radius: 999px; }
.meta { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; color: var(--muted); font-weight: 700; }
.price { font-size: 22px; font-weight: 900; color: var(--blue-700); }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 900; font-size: 15px;
  background: linear-gradient(180deg, var(--blue-500), var(--blue-600)); color: #fff;
  box-shadow: 0 4px 0 var(--blue-900); transition: transform .08s, box-shadow .08s;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--blue-900); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.red { background: linear-gradient(180deg, #f2566a, var(--red)); box-shadow: 0 4px 0 #9d1c2e; }
.btn.green { background: linear-gradient(180deg, #22c55e, var(--green)); box-shadow: 0 4px 0 #0f6b30; }
.btn.ghost { background: #fff; color: var(--blue-700); border: 2px solid var(--blue-100); box-shadow: none; }
.btn.ghost:active { transform: none; }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 9px; box-shadow: 0 3px 0 var(--blue-900); }
.btn.small.ghost { box-shadow: none; }
.btn.block { width: 100%; }
.link { background: none; border: 0; color: var(--blue-700); font-weight: 800; padding: 0; text-decoration: underline; }

/* ---------- Detalle de rifa ---------- */
.back { margin-bottom: 12px; }
.detail-head { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; align-items: start; min-width: 0; }
.detail-head > * { min-width: 0; }
.detail-cover { aspect-ratio: 4/3; }
.box { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.numbers-box { margin-top: 16px; }
.prize-grid { display: grid; gap: 8px; }
.info-list { margin: 12px 0; padding-left: 20px; font-weight: 700; color: var(--blue-900); }
.info-list li { padding: 2px 0; }
.prize-chip { display: flex; align-items: center; gap: 10px; background: var(--blue-50); border: 1px solid var(--blue-100); border-radius: 12px; padding: 8px 12px; }
.prize-chip .medal { font-size: 22px; line-height: 1; flex: none; }
.prize-chip .prize-label { font-size: 11px; font-weight: 900; letter-spacing: .4px; color: var(--blue-700); text-transform: uppercase; }
.prize-chip .prize-name { font-weight: 800; color: var(--blue-900); font-size: 14px; }
.raffle-progress-top { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 800; color: var(--blue-900); margin-bottom: 5px; }
.raffle-progress-top .pct { color: var(--blue-600); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; font-weight: 800; color: var(--muted); margin: 10px 0; }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; margin-right: 5px; }
.numbers { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 8px; }
.num {
  aspect-ratio: 1 / 1; border-radius: 12px; border: 2px solid var(--blue-100); background: #fff;
  font-weight: 900; font-size: 16px; color: var(--blue-700); transition: transform .08s, box-shadow .08s, border-color .08s;
  display: grid; place-items: center; padding: 0;
}
.num:hover:not(:disabled) { border-color: var(--blue-500); transform: translateY(-2px); box-shadow: 0 4px 10px rgba(10,47,115,.18); }
.num.sel { background: linear-gradient(180deg, var(--blue-500), var(--blue-600)); color: #fff; border-color: var(--blue-900); box-shadow: 0 3px 0 var(--blue-900); transform: scale(1.06); }
.num.sold { background: #e4e9f2; color: #9aa7bd; border-color: #e4e9f2; text-decoration: line-through; cursor: not-allowed; }
.num.held { background: #fff4d6; color: #b57a00; border-color: #fde7a6; cursor: not-allowed; }
.legend .a { background: #fff; border: 2px solid var(--blue-100); }
.legend .s { background: var(--blue-600); }
.legend .h { background: #fde7a6; }
.legend .x { background: #e4e9f2; }

.cartbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: #fff; border-top: 3px solid var(--blue-500); box-shadow: 0 -6px 20px rgba(10,47,115,.18);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
.cartbar-in { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cartbar b { font-size: 20px; color: var(--blue-700); }
.cb-unit { font-size: 12px; font-weight: 700; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; max-height: 54px; overflow: auto; }
.chip { background: var(--blue-100); color: var(--blue-900); border-radius: 999px; padding: 1px 9px; font-weight: 900; font-size: 12px; }
.quick { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(7,35,82,.6); z-index: 60; display: grid; place-items: center; padding: 14px; overflow: auto; }
.modal { background: #fff; border-radius: 20px; width: 100%; max-width: 520px; padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.4); max-height: 94vh; overflow: auto; }
.modal.wide { max-width: 760px; }
.modal h2 { margin: 0 0 4px; color: var(--blue-900); font-weight: 900; }
.field { display: block; margin: 12px 0; }
.field > span { display: block; font-size: 13px; font-weight: 800; color: var(--blue-900); margin-bottom: 4px; }
.field input, .field textarea, .field select {
  width: 100%; border: 2px solid var(--line); border-radius: 12px; padding: 11px 12px; background: #fff; outline: none;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--blue-500); }
.field small { color: var(--muted); }
.pay { display: grid; gap: 8px; margin: 10px 0; }
.pay label { display: flex; gap: 10px; align-items: center; border: 2px solid var(--line); border-radius: 12px; padding: 11px 12px; cursor: pointer; font-weight: 800; }
.pay label:has(input:checked) { border-color: var(--blue-500); background: var(--blue-50); }
.summary { background: var(--blue-50); border-radius: 12px; padding: 12px; font-weight: 700; }
.summary .row { display: flex; justify-content: space-between; }
.error { background: #ffe4e8; color: #a3122a; border-radius: 10px; padding: 10px 12px; font-weight: 700; margin: 10px 0; }
.ok { background: #dcfce7; color: #14532d; border-radius: 10px; padding: 10px 12px; font-weight: 700; margin: 10px 0; }
.bank { white-space: pre-wrap; background: var(--blue-50); border: 2px dashed var(--blue-500); border-radius: 12px; padding: 12px; font-weight: 700; }

/* ---------- Ganadores ---------- */
.winner { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.winner:last-child { border: 0; }
.winner .n { width: 56px; height: 56px; border-radius: 14px; background: linear-gradient(180deg, var(--blue-500), var(--blue-600)); color: #fff; font-weight: 900; font-size: 22px; display: grid; place-items: center; flex: none; box-shadow: 0 3px 0 var(--blue-900); }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); font-weight: 700; }
.empty img { width: 130px; margin: 0 auto 10px; border-radius: 22%; }
.empty-title { color: var(--blue-900); font-weight: 900; font-size: 17px; margin-bottom: 4px; }
.empty-sub { color: var(--muted); font-weight: 700; font-size: 14px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 90px; background: var(--blue-950); color: #fff; padding: 10px 16px; border-radius: 12px; font-weight: 800; z-index: 90; box-shadow: var(--shadow); }
.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 18px; }

/* ---------- Admin ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { border: 2px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 16px; font-weight: 900; color: var(--blue-700); }
.tabs button.on { background: var(--blue-600); color: #fff; border-color: var(--blue-600); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 10px 0 14px; }
.stat { background: var(--blue-50); border-radius: 12px; padding: 10px 12px; }
.stat b { display: block; font-size: 20px; color: var(--blue-700); }
.stat span { font-size: 12px; font-weight: 800; color: var(--muted); }
.row-flex { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 900; }
.tag.paid { background: #dcfce7; color: #14532d; }
.tag.pending { background: #fff4d6; color: #8a5a00; }
.tag.cancelled { background: #e4e9f2; color: #5b6b86; }
.tag.review { background: #ffe4e8; color: #a3122a; }
.tag.on { background: #dcfce7; color: #14532d; }
.tag.off { background: #e4e9f2; color: #5b6b86; }
.tag.drawn { background: var(--blue-100); color: var(--blue-700); }
.table-wrap { overflow: auto; border-radius: 12px; border: 1px solid var(--line); background: #fff; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--blue-50); font-size: 12px; letter-spacing: .6px; text-transform: uppercase; color: var(--blue-900); white-space: nowrap; }
.prize-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.map { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 5px; }
.map span { text-align: center; border-radius: 8px; padding: 6px 0; font-size: 12px; font-weight: 900; background: #fff; border: 1px solid var(--line); color: var(--blue-700); }
.map span.paid { background: var(--green); color: #fff; border-color: var(--green); }
.map span.pending, .map span.review { background: #fde7a6; color: #8a5a00; border-color: #fde7a6; }
.login { max-width: 380px; margin: 60px auto; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; min-width: 0; }
.settings-grid > * { min-width: 0; }

/* Banner principal (hero) en móviles: la mascota se oculta y el banner se compacta.
   Breakpoint propio (768px) para no afectar el resto de reglas mobile (720px). */
@media (max-width: 768px) {
  .hero { grid-template-columns: 1fr; text-align: center; gap: 4px; padding: 16px 18px; }
  .hero img { display: none; }
  .hero .pill { margin-bottom: 6px; }
  .hero h1 { margin-bottom: 4px; }
  .hero .sub { margin-top: 3px; }
  .empty-raffles img { width: 104px; margin-bottom: 6px; }
}

@media (max-width: 720px) {
  .nav button { padding: 7px 11px; font-size: 13px; }
  .brand small { display: none; }
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; order: -1; }
  .header-in { position: relative; }
  #brand { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
  #brand img { height: 50px; }
  #nav {
    display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: 29;
    flex-direction: column; gap: 8px; background: var(--blue-700); padding: 12px 16px;
    box-shadow: 0 10px 20px rgba(7,35,82,.3);
  }
  #nav.open { display: flex; }
  #nav button { width: 100%; padding: 10px; font-size: 15px; }
  .numbers { grid-template-columns: repeat(5, 1fr); gap: 8px; }
  .detail-head { grid-template-columns: 1fr; }
  .detail-cover { display: none; }
  .settings-grid { grid-template-columns: 1fr; }
}
