:root {
  --bg: #f4f5f9;
  --card: #ffffff;
  --text: #1c1f2a;
  --muted: #6b7183;
  --line: #e2e5ee;
  --brand: #6d28d9;
  --brand-2: #8b5cf6;
  --brand-soft: #ede9fe;
  --ok: #059669;
  --ok-soft: #d1fae5;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --bad: #dc2626;
  --bad-soft: #fee2e2;
  --wa: #25d366;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 20, 40, .06), 0 4px 16px rgba(20, 20, 40, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hidden { display: none !important; }

/* ---------- Layout ---------- */
.topbar {
  background: linear-gradient(120deg, var(--brand), var(--brand-2));
  color: #fff;
  padding: 14px 16px;
}
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.topbar a { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.15rem; }
.topbar .badge { background: rgba(255, 255, 255, .2); color: #fff; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 20px; padding-bottom: 120px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.grid-cards { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

/* ---------- Buttons & inputs ---------- */
.btn {
  appearance: none; border: 0; cursor: pointer;
  background: var(--brand); color: #fff;
  padding: 10px 16px; border-radius: 10px;
  font: inherit; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  text-decoration: none;
  transition: filter .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: var(--brand-soft); color: var(--brand); }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn.ok { background: var(--ok); }
.btn.bad { background: var(--bad); }
.btn.wa { background: var(--wa); color: #fff; }
.btn.sm { padding: 6px 10px; font-size: .85rem; border-radius: 8px; }
.btn.block { width: 100%; }

label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 4px; }
input, select, textarea {
  width: 100%; font: inherit;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-2); outline-offset: 0; border-color: transparent; }
textarea { min-height: 80px; resize: vertical; }
.field { margin-bottom: 14px; }
.field .hint { font-size: .8rem; color: var(--muted); margin-top: 3px; }
.row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.check input { width: auto; }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: .78rem; font-weight: 700;
  background: var(--brand-soft); color: var(--brand);
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.gray { background: #eef0f4; color: var(--muted); }

/* ---------- Raffle cards (lista pública) ---------- */
.raffle-card { overflow: hidden; padding: 0; display: flex; flex-direction: column; text-decoration: none; color: inherit; }
.raffle-card .img { aspect-ratio: 16 / 10; background: var(--brand-soft) center / cover no-repeat; display: grid; place-items: center; font-size: 3rem; }
.raffle-card .body { padding: 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.raffle-card .badge { align-self: flex-start; }
.raffle-card .price { font-size: 1.25rem; font-weight: 800; color: var(--brand); }
.progress { height: 8px; background: #eceef4; border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }

/* ---------- Raffle page ---------- */
.hero { display: grid; gap: 18px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .hero { grid-template-columns: 340px 1fr; } }
.hero .img { border-radius: var(--radius); aspect-ratio: 1 / 1; background: var(--brand-soft) center / cover no-repeat; display: grid; place-items: center; font-size: 4rem; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 12px 0; }
.stat { background: var(--bg); border-radius: 10px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 1.2rem; }
.stat span { font-size: .78rem; color: var(--muted); }
.packages { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.pre { white-space: pre-wrap; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 14px; }
.toolbar .field { margin: 0; }
.toolbar .grow { flex: 1 1 180px; }

.tickets {
  display: grid; gap: 6px;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
}
.tk {
  border: 1px solid var(--line); background: #fff; color: var(--text);
  border-radius: 8px; padding: 8px 0; font: inherit; font-weight: 700; font-size: .9rem;
  cursor: pointer; font-variant-numeric: tabular-nums;
}
.tk:hover { border-color: var(--brand-2); color: var(--brand); }
.tk.sel { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager { display: flex; gap: 8px; justify-content: center; align-items: center; margin-top: 14px; flex-wrap: wrap; }

.cart {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: #fff; border-top: 1px solid var(--line);
  box-shadow: 0 -6px 24px rgba(20, 20, 40, .1);
  padding: 12px 0;
}
.cart .wrap { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; max-height: 64px; overflow: auto; flex: 1 1 200px; }
.chip { background: var(--brand-soft); color: var(--brand); border: 0; border-radius: 999px; padding: 3px 10px; font: inherit; font-weight: 700; font-size: .85rem; cursor: pointer; }
.chip:hover { background: var(--bad-soft); color: var(--bad); }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 15, 30, .55); z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal { background: #fff; border-radius: var(--radius); width: 100%; max-width: 480px; max-height: 92vh; overflow: auto; padding: 22px; }
.modal h2 { margin-bottom: 12px; }
.summary { background: var(--bg); border-radius: 10px; padding: 12px; margin-bottom: 14px; font-size: .9rem; max-height: 180px; overflow: auto; }
.big-folio { font-size: 2rem; font-weight: 800; letter-spacing: 2px; color: var(--brand); text-align: center; margin: 8px 0; }

/* ---------- Toast ---------- */
#toasts { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; width: min(92vw, 420px); }
.toast { background: #1c1f2a; color: #fff; padding: 12px 14px; border-radius: 10px; box-shadow: var(--shadow); font-size: .92rem; animation: pop .2s ease-out; }
.toast.bad { background: var(--bad); }
.toast.ok { background: var(--ok); }
@keyframes pop { from { opacity: 0; transform: translateY(-6px); } }

/* ---------- Admin ---------- */
.admin { display: grid; gap: 18px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .admin { grid-template-columns: 260px 1fr; } }
.side-list { display: grid; gap: 6px; }
.side-item { text-align: left; background: transparent; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; font: inherit; color: var(--text); }
.side-item.active { border-color: var(--brand); background: var(--brand-soft); }
.side-item b { display: block; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tab { background: none; border: 0; padding: 10px 14px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; }
.tab.active { color: var(--brand); border-color: var(--brand); }
.kpis { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); margin-bottom: 16px; }
.kpi { background: var(--bg); border-radius: 10px; padding: 12px; }
.kpi b { display: block; font-size: 1.3rem; }
.kpi span { font-size: .8rem; color: var(--muted); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; color: var(--muted); letter-spacing: .4px; }
td .nums { max-width: 260px; font-variant-numeric: tabular-nums; word-break: break-word; }
td .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.demo-banner { background: var(--warn-soft); color: #7c4a03; padding: 8px 16px; font-size: .85rem; text-align: center; }
.empty { text-align: center; padding: 40px 10px; color: var(--muted); }
