/* Rifas Hermanas Fierro */
:root {
  --pink: #e11d74;
  --violet: #9b2cf0;
  --teal: #12b5a5;
  --gold: #f5b301;
  --navy: #1e2a78;
  --red: #e11d48;
  --green: #16a34a;
  --amber: #f59e0b;
  --bg: #fff6fa;
  --card: #ffffff;
  --line: #f3dbe7;
  --field: #e8cfdc;
  --text: #2b1633;
  --muted: #7d6884;
  --radius: 18px;
  --shadow: 0 6px 22px rgba(150, 30, 90, .08);
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-tap-highlight-color: transparent;
}
body.noscroll { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0 0 6px; line-height: 1.2; }
h1 { font-size: 21px; font-weight: 900; }
h2 { font-size: 19px; font-weight: 800; }
h3 { font-size: 16px; font-weight: 800; margin-bottom: 10px; }
p { margin: 0 0 8px; }
a { color: var(--pink); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.top-gap { margin-top: 12px; }
.owed { color: var(--red); }
.ok { color: var(--green); }

/* Splash / auth */
.splash { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 8px; color: var(--muted); }
.splash img { animation: bob 1.4s ease-in-out infinite; }
.auth {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; position: relative; overflow: hidden;
  background: radial-gradient(circle at 15% 10%, #2ee6c8 0 90px, transparent 91px),
              radial-gradient(circle at 95% 20%, #ff4f9a 0 120px, transparent 121px),
              radial-gradient(circle at 85% 95%, #6d5cff 0 110px, transparent 111px),
              linear-gradient(160deg, #fff 0%, #ffeaf4 100%);
}
.auth-card {
  position: relative; z-index: 1; width: 100%; max-width: 380px; background: rgba(255, 255, 255, .94);
  border-radius: 26px; padding: 26px 22px; box-shadow: 0 20px 60px rgba(120, 20, 90, .18); backdrop-filter: blur(6px);
}
.auth-logo { display: block; width: 104px; height: 104px; margin: 0 auto 6px; filter: drop-shadow(0 8px 16px rgba(155, 44, 240, .3)); animation: bob 3s ease-in-out infinite; }
.wordmark { text-align: center; margin: 0 0 14px; line-height: 1; }
.wordmark span {
  display: block; font-size: 46px; font-weight: 900; letter-spacing: .5px;
  background: linear-gradient(180deg, #ffd84d, #ff8a00 60%, #e8590c); -webkit-background-clip: text; background-clip: text; color: transparent;
  -webkit-text-stroke: 1.5px #b3261e; filter: drop-shadow(0 3px 0 rgba(179, 38, 30, .25));
}
.wordmark small {
  display: inline-block; margin-top: 4px; padding: 4px 14px; border-radius: 999px; font-size: 15px; font-weight: 800; color: #fff;
  background: linear-gradient(90deg, var(--pink), var(--violet)); letter-spacing: .6px; text-transform: uppercase;
}
.confetti i { position: absolute; width: 12px; height: 6px; border-radius: 3px; opacity: .8; animation: fall 9s linear infinite; }
.confetti i:nth-child(3n) { background: var(--gold); }
.confetti i:nth-child(3n+1) { background: var(--pink); }
.confetti i:nth-child(3n+2) { background: var(--teal); }
.confetti i:nth-child(1) { left: 5%; animation-delay: -1s; } .confetti i:nth-child(2) { left: 12%; animation-delay: -5s; }
.confetti i:nth-child(3) { left: 20%; animation-delay: -3s; } .confetti i:nth-child(4) { left: 28%; animation-delay: -7s; }
.confetti i:nth-child(5) { left: 36%; animation-delay: -2s; } .confetti i:nth-child(6) { left: 44%; animation-delay: -6s; }
.confetti i:nth-child(7) { left: 52%; animation-delay: -4s; } .confetti i:nth-child(8) { left: 60%; animation-delay: -8s; }
.confetti i:nth-child(9) { left: 68%; animation-delay: -1.5s; } .confetti i:nth-child(10) { left: 76%; animation-delay: -5.5s; }
.confetti i:nth-child(11) { left: 84%; animation-delay: -3.5s; } .confetti i:nth-child(12) { left: 91%; animation-delay: -7.5s; }
.confetti i:nth-child(13) { left: 96%; animation-delay: -2.5s; } .confetti i:nth-child(14) { left: 2%; animation-delay: -6.5s; }

/* Barra superior y navegación */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: linear-gradient(115deg, var(--pink), var(--violet)); color: #fff; box-shadow: 0 2px 14px rgba(120, 20, 90, .25);
}
.topbar-logo { width: 38px; height: 38px; flex: none; }
.brand { display: flex; flex-direction: column; line-height: 1.05; min-width: 0; }
.brand b { font-size: 19px; font-weight: 900; }
.brand small { font-size: 12px; opacity: .92; white-space: nowrap; }
#raffle-select {
  margin-left: auto; max-width: 48vw; min-width: 0; background: rgba(255, 255, 255, .18); border: 1px solid rgba(255, 255, 255, .4);
  color: #fff; border-radius: 12px; padding: 7px 10px; font-weight: 700; font-size: 14px;
}
#raffle-select option { color: #000; }
.view { max-width: 760px; margin: 0 auto; padding: 14px 12px calc(100px + env(safe-area-inset-bottom)); }
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex; background: #fff;
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -4px 18px rgba(120, 20, 90, .06);
}
.bottomnav button {
  flex: 1; border: 0; background: none; padding: 8px 0 7px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--muted); font-size: 12px; cursor: pointer;
}
.bottomnav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.bottomnav button.on { color: var(--pink); font-weight: 800; }
.bottomnav button.on svg { stroke-width: 2.4; }

/* Tarjetas */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px; }
.card.empty { text-align: center; padding: 30px 18px; }
.big-emoji { font-size: 48px; line-height: 1; margin-bottom: 8px; }
.hero-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.price { flex: none; background: linear-gradient(135deg, #ffd84d, #ff9f1a); color: #5a2a00; font-weight: 900; border-radius: 12px; padding: 6px 10px; font-size: 15px; }
.progress { height: 10px; border-radius: 99px; background: #f6e3ed; overflow: hidden; margin: 12px 0; }
.progress span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--teal), var(--pink)); transition: width .4s; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats > div { background: #fff8fb; border: 1px solid var(--line); border-radius: 14px; padding: 8px 6px; text-align: center; min-width: 0; }
.stats b { display: block; font-size: 16px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats b small { font-size: 12px; color: var(--muted); font-weight: 700; }
.stats span { font-size: 12px; color: var(--muted); }
.stats .warn b { color: var(--red); }
.stats.mini { margin: 12px 0; }
.winner-banner { margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: linear-gradient(90deg, #fff4c2, #ffe08a); border: 1px solid #f5c84c; font-weight: 600; }
.note { background: #fff4d6; border: 1px solid #f7d98b; border-radius: 12px; padding: 10px 12px; font-size: 14px; }
.note.soft { background: #effbf9; border-color: #b7ebe4; }

/* Filtros */
.toolbar { display: flex; align-items: center; gap: 8px; margin: 4px 0 10px; }
.fchips { display: flex; gap: 6px; overflow-x: auto; flex: 1; scrollbar-width: none; padding: 2px 0; }
.fchips::-webkit-scrollbar { display: none; }
.fchip { flex: none; border: 1.5px solid var(--field); background: #fff; border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 700; cursor: pointer; color: var(--muted); }
.fchip.on { background: var(--text); border-color: var(--text); color: #fff; }
.lucky-btn { flex: none; }

/* Tablero */
.board { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.span-all { grid-column: 1 / -1; padding: 20px 0; }
.cell {
  aspect-ratio: 1; border: 2px solid #ecd6e2; background: #fff; border-radius: 10px; padding: 0; cursor: pointer;
  font-weight: 800; font-size: clamp(12px, 3.5vw, 17px); display: flex; align-items: center; justify-content: center;
  transition: transform .1s, background .15s; font-variant-numeric: tabular-nums; min-width: 0;
}
.cell:active { transform: scale(.9); }
.cell.st-pagado { background: var(--green); border-color: var(--green); color: #fff; }
.cell.st-abono { background: var(--amber); border-color: var(--amber); color: #fff; }
.cell.st-debe { background: var(--red); border-color: var(--red); color: #fff; }
.cell.sel { background: var(--navy); border-color: var(--navy); color: #fff; box-shadow: 0 0 0 3px rgba(30, 42, 120, .25); transform: scale(1.04); }
.cell.win { box-shadow: 0 0 0 3px var(--gold), 0 0 16px var(--gold); position: relative; z-index: 1; }
.cell.lucky { animation: pop .7s; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 12px; font-size: 12px; color: var(--muted); }
.dot { display: inline-block; width: 11px; height: 11px; border-radius: 4px; margin-right: 4px; vertical-align: -1px; }
.dot.libre { background: #fff; border: 2px solid #ecd6e2; }
.dot.pagado { background: var(--green); } .dot.abono { background: var(--amber); } .dot.debe { background: var(--red); }

/* Barra de selección */
.selbar {
  position: fixed; left: 8px; right: 8px; bottom: calc(66px + env(safe-area-inset-bottom)); z-index: 19; max-width: 744px; margin: 0 auto;
  display: flex; align-items: center; gap: 8px; background: #fff; border: 2px solid var(--navy); border-radius: 18px; padding: 8px 8px 8px 14px;
  box-shadow: 0 12px 30px rgba(30, 20, 70, .25); animation: up .2s ease-out;
}
.selinfo { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.selinfo small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 10px 16px;
  border: 1.5px solid var(--field); background: #fff; border-radius: 14px; font-weight: 800; cursor: pointer; text-decoration: none;
  color: var(--text); text-align: center; transition: transform .1s, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: linear-gradient(115deg, var(--pink), var(--violet)); border-color: transparent; color: #fff; box-shadow: 0 6px 16px rgba(225, 29, 116, .28); }
.btn.wa { background: #25d366; border-color: #25d366; color: #fff; }
.btn.wa-ghost { background: #fff; border-color: #25d366; color: #128c4a; }
.btn.danger { color: var(--red); border-color: #f6b9c7; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: 12px; }
.btn.big { min-height: 52px; font-size: 16px; }
.btn.block { width: 100%; }
.actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.actions-row { display: flex; gap: 8px; }
.actions-row > * { flex: 1; }

/* Hojas (ventanas) */
#sheet-root { position: fixed; inset: 0; z-index: 50; display: none; }
#sheet-root.open { display: block; }
.backdrop { position: absolute; inset: 0; background: rgba(35, 10, 45, .45); animation: fade .2s; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 620px; max-height: 92vh; overflow: auto; overscroll-behavior: contain;
  background: #fff; border-radius: 24px 24px 0 0; padding: 18px 16px calc(22px + env(safe-area-inset-bottom)); animation: up .25s ease-out;
}
.sheet.wide { max-width: 900px; }
.sheet-close {
  position: sticky; top: 0; float: right; z-index: 2; width: 36px; height: 36px; border-radius: 50%; border: 0;
  background: #f5e9f0; color: var(--muted); font-size: 16px; cursor: pointer; margin: -4px -4px 0 8px;
}
.sheet-body h2 { padding-right: 36px; }
@media (min-width: 700px) {
  .sheet { bottom: auto; top: 50%; transform: translateY(-50%); border-radius: 24px; max-height: 88vh; animation: fade .2s; }
}

/* Formularios */
.form { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.form label, .grid-form label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 700; color: #5d4566; }
input, select, textarea {
  width: 100%; border: 1.5px solid var(--field); border-radius: 12px; padding: 11px 12px; background: #fff; font-size: 16px; outline: none; font-weight: 500;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--pink); box-shadow: 0 0 0 3px rgba(225, 29, 116, .15); }
input:disabled { background: #f7f0f4; color: var(--muted); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 0.7fr; gap: 10px; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-size: 13px; font-weight: 700; color: #5d4566; margin-bottom: 6px; padding: 0; }
.pay { display: flex; flex-direction: column; gap: 10px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg label { flex: 1 1 0; min-width: 72px; position: relative; display: block; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.seg span {
  display: block; text-align: center; padding: 10px 6px; border: 1.5px solid var(--field); border-radius: 12px;
  font-weight: 800; font-size: 14px; cursor: pointer; color: var(--text); white-space: nowrap;
}
.seg input:checked + span { background: var(--text); border-color: var(--text); color: #fff; }
.seg input:focus-visible + span { box-shadow: 0 0 0 3px rgba(225, 29, 116, .3); }
.seg input:disabled + span { opacity: .55; cursor: default; }
.check { flex-direction: row !important; align-items: flex-start; gap: 10px !important; font-weight: 600 !important; cursor: pointer; }
.check input { width: 20px; height: 20px; flex: none; margin-top: 1px; accent-color: var(--pink); }
.check span { display: flex; flex-direction: column; }
.check small { font-weight: 500; color: var(--muted); }
.perms { display: flex; flex-direction: column; gap: 10px; background: #fff8fb; border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.bigfield { font-size: 34px !important; font-weight: 900; text-align: center; letter-spacing: 6px; }

/* Números (chips) */
.numchips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.numchips.center { justify-content: center; }
.numchips.small { gap: 4px; margin: 6px 0 0; }
.numchip {
  display: inline-flex; align-items: center; justify-content: center; min-width: 40px; padding: 6px 9px; border-radius: 10px;
  font-weight: 900; border: 0; background: #f1e6ec; color: var(--text); font-size: 15px; font-variant-numeric: tabular-nums; cursor: default;
}
button.numchip { cursor: pointer; }
.numchips.small .numchip { min-width: 30px; padding: 3px 6px; font-size: 12px; border-radius: 7px; }
.numchip.big { min-width: 52px; padding: 10px 12px; font-size: 18px; }
.numchip.st-sel { background: var(--navy); color: #fff; }
.numchip.st-pagado, .bignum.st-pagado, .pill.st-pagado { background: var(--green); color: #fff; }
.numchip.st-abono, .bignum.st-abono, .pill.st-abono { background: var(--amber); color: #fff; }
.numchip.st-debe, .bignum.st-debe, .pill.st-debe { background: var(--red); color: #fff; }

/* Detalle */
.ticket-head, .winner-card { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.winner-card { background: #fff8e0; border: 1px solid #f5d77a; border-radius: 16px; padding: 12px; }
.winner-card > div { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.bignum {
  flex: none; display: grid; place-items: center; width: 68px; height: 68px; border-radius: 18px; font-size: 28px; font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 800; }
.info { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 12px 0; padding: 12px; background: #fff8fb; border-radius: 14px; border: 1px solid var(--line); }
.info dt { color: var(--muted); font-size: 13px; font-weight: 700; }
.info dd { margin: 0; word-break: break-word; }
.done { text-align: center; padding: 6px 0; }

/* Compradores */
.searchbar input { border-radius: 14px; background: #fff; box-shadow: var(--shadow); }
.searchbar { margin-bottom: 10px; }
.list-head { margin: 0 4px 8px; }
.buyer {
  display: flex; width: 100%; gap: 10px; align-items: center; text-align: left; background: #fff; border: 1px solid var(--line);
  border-radius: 16px; padding: 12px 14px; margin-bottom: 8px; box-shadow: var(--shadow); cursor: pointer;
}
.buyer-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.buyer-main small { color: var(--muted); }
.buyer-amt { flex: none; text-align: right; display: flex; flex-direction: column; }
.buyer-amt small { font-weight: 700; }
.summary summary { cursor: pointer; font-weight: 800; }
.summary table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 14px; }
.summary th, .summary td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.summary th { color: var(--muted); font-size: 12px; }

/* Imagen */
.imgwrap { position: relative; border-radius: 14px; overflow: hidden; background: #f6eef2; min-height: 160px; }
.preview { display: block; width: 100%; height: auto; }
.imgload { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.swatches { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.swatch { width: 36px; height: 36px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1.5px var(--field); cursor: pointer; }
.swatch.on { box-shadow: 0 0 0 3px var(--text); }
.swatch:disabled { cursor: default; opacity: .6; }
.freelist { font-weight: 700; letter-spacing: .5px; word-spacing: 2px; color: #3f2a47; font-variant-numeric: tabular-nums; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }

/* Más */
.me { display: flex; align-items: center; gap: 12px; }
.me img { width: 56px; height: 56px; }
.menu { display: flex; flex-direction: column; gap: 8px; }
.menu-item, .user-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: #fff; border: 1px solid var(--line);
  border-radius: 16px; padding: 12px 14px; cursor: pointer; box-shadow: var(--shadow);
}
.mi-icon { font-size: 22px; width: 32px; text-align: center; flex: none; }
.mi-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.mi-text small { color: var(--muted); }
.chev { color: var(--muted); font-size: 22px; }
.foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 18px; }
.user-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.user-item.off { opacity: .55; }
.avatar {
  flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; color: #fff;
  background: linear-gradient(135deg, var(--teal), var(--violet));
}
.perm-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.perm-tags i { font-style: normal; font-size: 11px; font-weight: 700; background: #f4e8ef; color: #6b4a73; padding: 2px 7px; border-radius: 99px; }
.log { list-style: none; padding: 0; margin: 10px 0 0; }
.log li { padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.log small { display: block; color: var(--muted); }
.log-at { display: block; font-size: 12px; color: var(--muted); }
.steps { padding-left: 20px; line-height: 1.7; }

/* Avisos */
#toasts { position: fixed; top: max(12px, env(safe-area-inset-top)); left: 0; right: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; padding: 0 12px; }
.toast {
  max-width: 460px; background: #23142b; color: #fff; padding: 11px 16px; border-radius: 14px; font-weight: 600; font-size: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25); animation: drop .25s ease-out; transition: opacity .35s, transform .35s;
}
.toast.err { background: var(--red); }
.toast.out { opacity: 0; transform: translateY(-8px); }

@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes drop { from { transform: translateY(-14px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pop { 0% { transform: scale(1); } 35% { transform: scale(1.35) rotate(-8deg); } 70% { transform: scale(.95); } 100% { transform: scale(1.04); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes fall { from { top: -10px; transform: rotate(0); } to { top: 105%; transform: rotate(540deg); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media (max-width: 380px) {
  .row2 { grid-template-columns: 1fr; }
  .board { gap: 3px; }
  .cell { border-radius: 8px; border-width: 1.5px; }
}
