/* ============ Mini Site de Rifas ============ */
:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --text: #1f2328;
  --muted: #6b7078;
  --line: #e4e0d8;
  --primary: #0f766e;
  --primary-dark: #0b5e58;
  --primary-soft: #d9f0ec;
  --accent: #f59e0b;
  --danger: #b42318;
  --danger-soft: #fde7e4;
  --warn: #a15c07;
  --warn-soft: #fef3d6;
  --ok: #067647;
  --ok-soft: #dcf5e7;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.05);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 15px;
}
img { max-width: 100%; display: block; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
a { color: var(--primary); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.container { max-width: 1040px; margin: 0 auto; padding: 16px; }

/* ---------- Topbar ---------- */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar .container { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 10px; padding-bottom: 10px; }
.brand { font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 16px; }
.user { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.user img { width: 30px; height: 30px; border-radius: 50%; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2 { margin: 0; font-size: 18px; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 10px;
  padding: 10px 16px; font: inherit; font-weight: 600; cursor: pointer;
  background: var(--primary); color: #fff; text-decoration: none;
  transition: background .15s, opacity .15s;
}
.btn:hover { background: var(--primary-dark); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: var(--card); color: var(--text); border-color: var(--line); }
.btn.secondary:hover { background: #f1efe9; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #8f1c13; }
.btn.ok { background: var(--ok); }
.btn.ok:hover { background: #055c38; }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn.lg { padding: 14px 22px; font-size: 16px; }
.btn.block { width: 100%; }
.btn-google { background: #fff; color: #1f2328; border-color: var(--line); }
.btn-google:hover { background: #f5f5f5; }

/* ---------- Formulários ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=number], input[type=tel], select {
  width: 100%; padding: 10px 12px; font: inherit;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--text);
}
input:focus, select:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.switch { display: flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }
.switch input { width: 18px; height: 18px; accent-color: var(--primary); }

/* ---------- Prêmios (form admin) ---------- */
.premio-row {
  display: grid; grid-template-columns: 72px 1fr auto; gap: 12px; align-items: center;
  padding: 10px; border: 1px dashed var(--line); border-radius: 10px; margin-bottom: 10px;
}
.premio-thumb {
  width: 72px; height: 72px; border-radius: 8px; background: #f1efe9 center/cover no-repeat;
  display: grid; place-items: center; color: var(--muted); font-size: 11px; text-align: center;
  cursor: pointer; border: 1px solid var(--line); overflow: hidden;
}
.premio-row .ordem { font-size: 12px; color: var(--muted); font-weight: 600; }

/* ---------- Lista de rifas ---------- */
.rifa-list { display: grid; gap: 12px; }
.rifa-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.rifa-item h3 { margin: 0 0 4px; font-size: 17px; }
.rifa-item .acoes { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.pendente { background: var(--warn-soft); color: var(--warn); }
.badge.confirmado { background: var(--ok-soft); color: var(--ok); }
.badge.cancelado { background: #eee; color: var(--muted); }
.badge.ativa { background: var(--ok-soft); color: var(--ok); }
.badge.pausada { background: #eee; color: var(--muted); }

/* ---------- Estatísticas ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
@media (max-width: 720px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.stat .value { font-size: 22px; font-weight: 700; margin-top: 2px; }

/* ---------- Tabela de pedidos ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; cursor: pointer; font: inherit; font-size: 13px; font-weight: 600; }
.tab.active { background: var(--text); color: #fff; border-color: var(--text); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; }
td .nums { display: flex; flex-wrap: wrap; gap: 4px; max-width: 320px; }
td .nums span { background: #f1efe9; border-radius: 6px; padding: 1px 6px; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
td.acoes { white-space: nowrap; }
td.acoes .btn + .btn { margin-left: 6px; }

/* ---------- Grade de números ---------- */
.numeros {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 8px;
}
.num {
  border: 1px solid var(--line); background: #fff; border-radius: 10px;
  padding: 10px 0; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums;
  cursor: pointer; user-select: none; font: inherit; font-weight: 700; color: var(--text);
  transition: transform .08s, background .12s;
}
.num:hover { border-color: var(--primary); }
.num:active { transform: scale(.96); }
.num.sel { background: var(--primary); color: #fff; border-color: var(--primary); }
.num.reservado { background: var(--warn-soft); color: var(--warn); border-color: #f4d58d; cursor: default; }
.num.confirmado { background: var(--ok-soft); color: var(--ok); border-color: #a6e3c3; cursor: default; }
.num.livre-admin { cursor: default; }
.legenda { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.legenda i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; border: 1px solid var(--line); }

/* ---------- Página pública ---------- */
.hero { text-align: center; padding: 28px 16px 8px; }
.hero h1 { font-size: clamp(24px, 5vw, 36px); margin-bottom: 6px; }
.hero .preco { font-size: 16px; color: var(--muted); }
.hero .preco b { color: var(--primary); font-size: 20px; }
.premios { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.premio { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.premio .foto { aspect-ratio: 4/3; background: #f1efe9 center/cover no-repeat; }
.premio .info { padding: 10px 12px; }
.premio .pos { font-size: 12px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .05em; }
.premio .nome { font-weight: 600; }

.checkout-bar {
  position: sticky; bottom: 0; z-index: 15;
  background: var(--card); border-top: 1px solid var(--line);
  box-shadow: 0 -4px 16px rgba(0,0,0,.06);
}
.checkout-bar .container { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; padding-bottom: 12px; }
.checkout-bar .total { font-size: 14px; color: var(--muted); }
.checkout-bar .total b { display: block; font-size: 22px; color: var(--text); }

/* ---------- Modal ---------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(15, 20, 25, .55); z-index: 50;
  display: grid; place-items: center; padding: 16px;
}
.modal {
  background: var(--card); border-radius: 16px; width: 100%; max-width: 440px;
  padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.25); max-height: 92vh; overflow-y: auto;
}
.modal h3 { font-size: 20px; }
.modal .resumo { background: #f7f6f2; border-radius: 10px; padding: 12px; margin-bottom: 14px; font-size: 14px; }
.modal .acoes { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.pix-box { border: 2px dashed var(--primary); border-radius: 12px; padding: 14px; text-align: center; margin: 12px 0; background: var(--primary-soft); }
.pix-box .chave { font-size: 18px; font-weight: 700; word-break: break-all; margin: 6px 0 10px; }
.aviso { background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 10px 12px; font-weight: 600; font-size: 14px; }

/* ---------- Login ---------- */
.login-box { max-width: 380px; margin: 10vh auto; text-align: center; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px);
  background: #1f2328; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: all .2s; z-index: 100; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.erro { background: var(--danger); }

.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.loading { text-align: center; color: var(--muted); padding: 40px; }
