:root {
  --bg: #f6f2ec;
  --card: #ffffff;
  --ink: #23201c;
  --muted: #6f675e;
  --line: #e4ddd3;
  --brick: #b5482a;
  --brick-dark: #8f3820;
  --brick-soft: #f6e3dc;
  --green: #2f7d4f;
  --green-soft: #e1f1e7;
  --amber: #a86b00;
  --amber-soft: #fbeed3;
  --red: #b3261e;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(35, 32, 28, .06), 0 4px 16px rgba(35, 32, 28, .06);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; line-height: 1.5; font-size: 16px; }
a { color: var(--brick); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.8rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }
.hidden { display: none !important; }
.mt { margin-top: 16px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.wrap { max-width: 960px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 460px; }

/* Barra superior */
.topbar { background: var(--ink); color: #fff; }
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; }
.brand { font-weight: 800; letter-spacing: .2px; color: #fff; text-decoration: none; display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 30px; height: 30px; border-radius: 6px; background: var(--brick); display: grid; place-items: center; }
.brand-mark span { display: block; width: 16px; height: 10px; border: 2px solid #fff; border-radius: 2px; position: relative; }
.topbar a.link { color: #fff; text-decoration: none; font-weight: 600; opacity: .9; }

/* Botones */
.btn { appearance: none; border: 0; border-radius: 10px; padding: 12px 18px; font: inherit; font-weight: 700; cursor: pointer;
  background: var(--brick); color: #fff; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn:hover { background: var(--brick-dark); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.secondary:hover { background: #faf7f3; }
.btn.ghost { background: transparent; color: var(--brick); padding: 8px 10px; }
.btn.green { background: var(--green); }
.btn.small { padding: 8px 12px; font-size: .9rem; }
.btn.block { width: 100%; }
.btn.danger { background: #fff; color: var(--red); border: 1px solid #e8c4c1; }

/* Tarjetas */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
@media (min-width: 720px) { .grid.two { grid-template-columns: 1fr 1fr; } .grid.three { grid-template-columns: repeat(3, 1fr); } }

/* Formularios */
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 4px; }
input, textarea, select { width: 100%; font: inherit; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--brick-soft); border-color: var(--brick); }
textarea { min-height: 90px; resize: vertical; }
.field { margin-bottom: 14px; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 600; }
.check input { width: 20px; height: 20px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1; min-width: 160px; }
.error { color: var(--red); font-weight: 600; min-height: 1.2em; margin: 8px 0 0; }

/* Portada */
.hero { background: var(--ink); color: #fff; padding: 48px 0 56px; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; inset: auto 0 0 0; height: 14px;
  background: repeating-linear-gradient(90deg, var(--brick) 0 46px, var(--ink) 46px 50px); opacity: .9; }
.hero h1 { font-size: 2.2rem; max-width: 640px; }
.hero p { color: #d8d1c7; max-width: 560px; font-size: 1.1rem; }
.hero .row { margin-top: 20px; }
.ref-banner { background: var(--amber-soft); color: #5c3c00; border-radius: 12px; padding: 14px 16px; font-weight: 600; margin-top: 18px; max-width: 560px; }
.section { padding-top: 36px; padding-bottom: 36px; }
.services { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); padding: 0; list-style: none; margin: 0; }
.services li { background: #fff; border-radius: 10px; padding: 14px 16px; box-shadow: var(--shadow); font-weight: 600; border-left: 4px solid var(--brick); }
.steps { counter-reset: s; display: grid; gap: 14px; }
@media (min-width: 720px) { .steps { grid-template-columns: repeat(3, 1fr); } }
.step { background: #fff; border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.step::before { counter-increment: s; content: counter(s); display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: var(--brick); color: #fff; font-weight: 800; margin-bottom: 10px; }
.footer { padding: 28px 0 40px; color: var(--muted); font-size: .9rem; text-align: center; }

/* Panel cliente */
.hello { padding: 24px 0 8px; }
.balance-card { background: var(--ink); color: #fff; }
.balance-card .label { color: #cfc7bc; font-weight: 600; }
.balance-amount { font-size: 2.4rem; font-weight: 800; letter-spacing: -.5px; margin: 4px 0 2px; }
.progress { background: rgba(255,255,255,.15); border-radius: 99px; height: 14px; overflow: hidden; margin: 14px 0 8px; }
.card .progress.light { background: #efe9e1; }
.progress > div { height: 100%; background: var(--brick); border-radius: 99px; width: 0; transition: width .6s ease; }
.progress.done > div { background: var(--green); }
.next-text { color: #e9e3da; }
.reward { display: flex; gap: 14px; align-items: flex-start; padding: 14px 0; border-top: 1px solid var(--line); }
.reward:first-of-type { border-top: 0; }
.reward .info { flex: 1; }
.reward .goal { font-weight: 700; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: .8rem; font-weight: 700; background: #efe9e1; color: var(--muted); white-space: nowrap; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: #f8e1df; color: var(--red); }
.badge.brick { background: var(--brick-soft); color: var(--brick-dark); }
.share-box { display: flex; gap: 8px; }
.share-box input { font-family: ui-monospace, Menlo, monospace; font-size: .9rem; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); align-items: center; }
.list li:first-child { border-top: 0; }
.amount-pos { color: var(--green); font-weight: 700; white-space: nowrap; }
.amount-neg { color: var(--red); font-weight: 700; white-space: nowrap; }
.empty { color: var(--muted); padding: 8px 0; }

/* Admin */
.tabs { display: flex; gap: 4px; overflow-x: auto; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.tabs button { appearance: none; border: 0; background: none; font: inherit; font-weight: 700; padding: 14px 16px; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs button.active { color: var(--brick); border-bottom-color: var(--brick); }
.tabs .count { background: var(--brick); color: #fff; border-radius: 99px; padding: 0 7px; font-size: .75rem; margin-left: 4px; }
.stat { background: #fff; border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat .n { font-size: 1.6rem; font-weight: 800; }
.stat.secret { border: 2px dashed var(--brick); }
.secret-tag { font-size: .72rem; font-weight: 800; color: var(--brick); text-transform: uppercase; letter-spacing: .5px; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; color: var(--muted); letter-spacing: .4px; }
td.num, th.num { text-align: right; white-space: nowrap; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #faf7f3; }
.table-wrap { overflow-x: auto; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input { max-width: 320px; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(20, 18, 15, .55); display: flex; align-items: flex-end; justify-content: center; z-index: 50; }
@media (min-width: 720px) { .modal-bg { align-items: center; } }
.modal { background: #fff; width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; border-radius: 18px 18px 0 0; padding: 22px; }
@media (min-width: 720px) { .modal { border-radius: 18px; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.x { appearance: none; border: 0; background: #f1ece5; width: 36px; height: 36px; border-radius: 50%; font-size: 1.2rem; cursor: pointer; }
.hint { background: #faf7f3; border-radius: 10px; padding: 10px 12px; font-size: .9rem; color: var(--muted); margin-bottom: 14px; }
.hint strong { color: var(--ink); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; font-weight: 600; z-index: 100; box-shadow: var(--shadow); }

/* Selector de pestañas (registro / ingreso) */
.auth { background: var(--card); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; }
.auth .card { box-shadow: none; margin: 0; border-radius: 0; padding-top: 22px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--line); background: #faf7f3; }
.seg button { appearance: none; border: 0; background: none; font: inherit; font-weight: 700; font-size: 1rem; padding: 16px 10px;
  color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1px; transition: color .15s, border-color .15s, background .15s; }
.seg button:hover { color: var(--ink); }
.seg button.active { color: var(--brick); border-bottom-color: var(--brick); background: var(--card); }
.auth-foot { text-align: center; padding: 0 20px 20px; }

/* Lista de clientes del admin */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { appearance: none; border: 1px solid var(--line); background: #fff; font: inherit; font-size: .9rem; font-weight: 700; padding: 7px 12px; border-radius: 99px; cursor: pointer; color: var(--muted); }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.cell-progress { min-width: 200px; }
.cell-progress .progress { margin: 6px 0 4px; height: 8px; }
td .sub { font-size: .82rem; color: var(--muted); }
.mini-stats { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); margin-bottom: 16px; }
@media (min-width: 720px) { .mini-stats { grid-template-columns: repeat(4, 1fr); } }
.mini-stats .stat { padding: 12px 14px; }
.mini-stats .n { font-size: 1.3rem; }
.toolbar > input, .toolbar > select { flex: 1 1 220px; width: auto; max-width: none; }
.toolbar > .btn { flex: 0 0 auto; }

/* ---------- Comunes nuevos ---------- */
.sub { font-size: .82rem; color: var(--muted); }
.click { cursor: pointer; }

/* ---------- Contabilidad / gráficos ---------- */
.acc-tiles .stat .n { font-size: 1.5rem; }
.acc-head { align-items: center; }
.acc-head select { width: auto; }
.chart-wrap { position: relative; overflow-x: auto; }
.bar-chart { display: block; }
.bar-chart .grid { stroke: #ece6dd; stroke-width: 1; }
.bar-chart .grid.base { stroke: #cfc6b9; }
.bar-chart .tick { font-size: 11px; fill: var(--muted); font-family: inherit; }
.bar-chart .bar { fill: var(--brick); transition: fill .12s; }
.bar-chart .bar.hl { fill: var(--brick-dark); }
.bar-chart .bar.hover { fill: var(--ink); }
.bar-chart .hit { fill: transparent; cursor: pointer; }
.chart-tip { position: absolute; transform: translate(-50%, -100%); background: var(--ink); color: #fff; padding: 8px 10px; border-radius: 8px;
  font-size: .82rem; line-height: 1.4; pointer-events: none; white-space: nowrap; box-shadow: var(--shadow); z-index: 2; }
.chart-tip .tip-total { margin-top: 4px; padding-top: 4px; border-top: 1px solid rgba(255,255,255,.25); font-weight: 700; }

/* ---------- Rifas ---------- */
.raffle-card:hover { box-shadow: 0 2px 4px rgba(35,32,28,.08), 0 8px 24px rgba(35,32,28,.1); }
.list li.entry { align-items: flex-start; }
.receipt-thumb { appearance: none; border: 1px solid var(--line); border-radius: 8px; padding: 0; margin-top: 8px; background: #fff; cursor: zoom-in; display: block; }
.receipt-thumb img { display: block; width: 120px; height: 90px; object-fit: cover; border-radius: 7px; }
.receipt-view { align-items: center; z-index: 80; cursor: zoom-out; padding: 16px; }
.receipt-view img { max-width: 100%; max-height: 92vh; border-radius: 10px; background: #fff; }
.wheel-overlay { position: fixed; inset: 0; background: rgba(20,18,15,.85); z-index: 90; display: flex; align-items: center; justify-content: center; padding: 12px; overflow-y: auto; }
.wheel-box { background: #fff; border-radius: 20px; padding: 22px; width: 100%; max-width: 520px; text-align: center; position: relative; }
.wheel-x { position: absolute; top: 14px; right: 14px; }
.wheel-stage { margin: 12px auto; max-width: 420px; }
.wheel-svg { width: 100%; height: auto; display: block; }
.wheel-label { fill: #fff; font-weight: 800; font-family: inherit; }
.wheel-label.dark { fill: var(--ink); }
.wheel-result { min-height: 1.6em; font-size: 1.15rem; margin: 8px 0 12px; }
.wheel-result.pop { animation: pop .5s ease; }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.08); } 100% { transform: scale(1); opacity: 1; } }
.wheel-btn { font-size: 1.15rem; padding: 14px 28px; }

/* Rifa en el panel del cliente */
.raffle { border-top: 1px solid var(--line); padding: 16px 0; }
.raffle:first-of-type { border-top: 0; padding-top: 4px; }
.pay-box { background: #faf7f3; border-radius: 12px; padding: 14px; margin-top: 10px; }
.pay-box ol { margin: 0 0 10px; padding-left: 20px; }
.pay-box li { margin-bottom: 6px; }
.alias-row { display: flex; gap: 8px; align-items: center; margin: 6px 0; }
.alias-row code { flex: 1; background: #fff; border: 1px dashed var(--brick); border-radius: 8px; padding: 9px 10px; font-size: 1rem; font-weight: 700; overflow-wrap: anywhere; }
.file-pick { display: block; border: 2px dashed var(--line); border-radius: 10px; padding: 14px; text-align: center; cursor: pointer; font-weight: 600; color: var(--muted); margin-bottom: 10px; }
.file-pick.has { border-color: var(--green); color: var(--green); }
.file-pick input { display: none; }
.winner-box { background: var(--amber-soft); border-radius: 12px; padding: 12px 14px; margin-top: 10px; font-weight: 600; }
.qty-row { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 12px; background: #fff; overflow: hidden; }
.qty button { appearance: none; border: 0; background: none; width: 44px; height: 44px; font-size: 1.4rem; font-weight: 700; color: var(--brick); cursor: pointer; }
.qty button:disabled { color: #cfc6b9; cursor: default; }
.qty span { min-width: 34px; text-align: center; font-weight: 800; font-size: 1.15rem; }

/* ---------- Grilla de números ---------- */
.mb { margin-bottom: 10px; }
.num-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.num { display: inline-flex; align-items: center; justify-content: center; min-height: 34px; border-radius: 7px; border: 1px solid var(--line);
  background: #fff; font-weight: 700; font-size: .9rem; font-variant-numeric: tabular-nums; color: var(--ink); }
.num.res { background: var(--amber-soft); border-color: #ecd29d; color: #6b4a00; }
.num.sold { background: var(--brick); border-color: var(--brick); color: #fff; }
.num.win { background: var(--green); border-color: var(--green); color: #fff; box-shadow: 0 0 0 3px var(--green-soft); }
.num-legend { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin-top: 8px; }
.num-legend .num { min-height: 14px; width: 18px; padding: 0; }
.result-box { border: 2px solid var(--green-soft); }
.result-box select { width: auto; }

/* Cliente: botones de la grilla */
.pick-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px; }
.pick-grid button { appearance: none; border: 1px solid var(--line); background: #fff; border-radius: 8px; min-height: 40px; font: inherit;
  font-weight: 800; font-size: .95rem; font-variant-numeric: tabular-nums; color: var(--ink); cursor: pointer; padding: 0; }
.pick-grid button:hover:not(:disabled) { border-color: var(--brick); }
.pick-grid button.sel { background: var(--brick); border-color: var(--brick); color: #fff; }
.pick-grid button.mine { background: var(--green); border-color: var(--green); color: #fff; cursor: default; }
.pick-grid button.minepend { background: var(--amber-soft); border-color: #ecd29d; color: #6b4a00; cursor: default; }
.pick-grid button:disabled:not(.mine):not(.minepend) { background: #ece7e0; color: #b9b0a4; border-color: #ece7e0; text-decoration: line-through; cursor: not-allowed; }
@media (max-width: 380px) { .pick-grid button { min-height: 34px; font-size: .82rem; } }
.pick-head { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin: 4px 0 10px; flex-wrap: wrap; }
.pick-sel { display: flex; flex-wrap: wrap; gap: 6px; min-height: 30px; align-items: center; margin: 10px 0; }
.pick-sel .tag { background: var(--brick); color: #fff; border-radius: 99px; padding: 3px 10px; font-weight: 800; font-size: .9rem; }
.pick-find { display: flex; gap: 8px; margin-bottom: 10px; }
.pick-find input { max-width: 140px; }
.lottery-note { background: #f1f6fb; border-radius: 10px; padding: 10px 12px; font-size: .88rem; margin: 8px 0; }
