:root {
  --accent: #663398;
  --accent-soft: rgba(102, 51, 152, 0.12);
  --ink: #1d1626;
  --muted: #6b6478;
  --bg: #f7f5fa;
  --card: #ffffff;
  --ok: #2e9e5b;
  --radius: 20px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }
body {
  font-family: -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.quiz-shell {
  min-height: 100vh;
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 20px 48px;
  display: flex;
  flex-direction: column;
}

.loading { margin: auto; color: var(--muted); font-size: 1.2rem; }

/* ---------- telas ---------- */
.screen { display: flex; flex-direction: column; gap: 20px; animation: fade .25s ease; flex: 1; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.hero { text-align: center; padding-top: 6vh; display: flex; flex-direction: column; gap: 16px; align-items: center; }
.hero .logo { max-width: 240px; max-height: 120px; object-fit: contain; }
.hero .logo-fallback {
  width: 120px; height: 120px; border-radius: 28px; background: var(--accent);
  display: flex; align-items: center; justify-content: center; color: #fff;
  font-size: 3rem; font-weight: 800;
}
.hero h1 { font-size: clamp(1.9rem, 6vw, 2.6rem); line-height: 1.15; }
.hero p.sub { color: var(--muted); font-size: 1.15rem; }
.hero .dates { display: inline-block; background: var(--accent-soft); color: var(--accent); font-weight: 700; padding: 8px 18px; border-radius: 999px; font-size: .95rem; }

/* botões grandes (tablet) */
.btn {
  display: block; width: 100%; border: 0; cursor: pointer;
  background: var(--accent); color: #fff;
  font-size: 1.35rem; font-weight: 700;
  padding: 22px 28px; border-radius: var(--radius);
  transition: transform .08s ease, filter .15s ease;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: transparent; color: var(--accent); border: 2px solid var(--accent); font-size: 1.05rem; padding: 14px 20px; }
.btn.big-cta { max-width: 420px; margin: 12px auto 0; }

/* formulário */
.card { background: var(--card); border-radius: var(--radius); padding: 28px 24px; box-shadow: 0 6px 24px rgba(29, 22, 38, .07); display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-weight: 700; font-size: 1.05rem; }
.field input {
  font-size: 1.3rem; padding: 18px 16px; border: 2px solid #e3deec; border-radius: 14px;
  background: #fbfaff; color: var(--ink); outline: none; width: 100%;
}
.field input:focus { border-color: var(--accent); background: #fff; }
.field .hint { color: var(--ok); font-size: .95rem; font-weight: 600; }
.field .err { color: #d33; font-size: .95rem; font-weight: 600; }
.card h2 { font-size: 1.5rem; }

/* progresso */
.progress { display: flex; align-items: center; gap: 12px; }
.progress .bar { flex: 1; height: 10px; background: #e7e2f0; border-radius: 999px; overflow: hidden; }
.progress .bar i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s ease; }
.progress span { font-weight: 700; color: var(--muted); font-size: .95rem; white-space: nowrap; }

/* pergunta */
.q-text { font-size: clamp(1.5rem, 5vw, 2rem); font-weight: 800; line-height: 1.25; }
.options { display: flex; flex-direction: column; gap: 14px; }
.option {
  text-align: left; border: 2px solid #e3deec; background: var(--card);
  border-radius: var(--radius); padding: 22px 20px; font-size: 1.25rem; font-weight: 600;
  cursor: pointer; color: var(--ink); transition: transform .08s ease, border-color .15s ease;
  display: flex; gap: 14px; align-items: center; line-height: 1.3;
}
.option:active { transform: scale(.98); }
.option .letter {
  flex: none; width: 44px; height: 44px; border-radius: 12px; background: var(--accent-soft);
  color: var(--accent); font-weight: 800; display: flex; align-items: center; justify-content: center; font-size: 1.2rem;
}
.option.selected { border-color: var(--accent); background: var(--accent-soft); }

/* resultado */
.result { text-align: center; padding-top: 5vh; display: flex; flex-direction: column; gap: 18px; align-items: center; }
.result .score { font-size: clamp(3rem, 12vw, 4.5rem); font-weight: 800; color: var(--accent); line-height: 1; }
.result .score small { font-size: .45em; color: var(--muted); }
.result .profile-tag { background: var(--accent-soft); color: var(--accent); font-weight: 800; padding: 10px 24px; border-radius: 999px; font-size: 1.15rem; }
.gift {
  background: var(--card); border: 2px dashed var(--accent); border-radius: var(--radius);
  padding: 24px; font-size: 1.2rem; line-height: 1.5; text-align: center; color: var(--ink);
}
.result h2 { font-size: 1.8rem; }

.footer-note { text-align: center; color: var(--muted); font-size: .85rem; margin-top: auto; padding-top: 24px; }

/* ---------- admin ---------- */
.admin-shell { max-width: 1100px; }
.admin-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 18px 0; }
.admin-top h1 { font-size: 1.5rem; }
.admin-top .actions { display: flex; gap: 10px; flex-wrap: wrap; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 20px; }
.tabs button {
  border: 0; background: #e9e4f2; color: var(--ink); font-weight: 700; font-size: .95rem;
  padding: 10px 18px; border-radius: 999px; cursor: pointer;
}
.tabs button.active { background: var(--accent); color: #fff; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 22px; }
.kpi { background: var(--card); border-radius: 16px; padding: 18px; box-shadow: 0 4px 14px rgba(29,22,38,.06); }
.kpi .v { font-size: 2rem; font-weight: 800; color: var(--accent); }
.kpi .l { color: var(--muted); font-size: .9rem; font-weight: 600; }

table.data { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 14px; overflow: hidden; box-shadow: 0 4px 14px rgba(29,22,38,.06); }
table.data th, table.data td { text-align: left; padding: 12px 14px; border-bottom: 1px solid #efeaf6; font-size: .95rem; vertical-align: top; }
table.data th { background: #faf8fd; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
table.data tr:last-child td { border-bottom: 0; }
.tag-pill { display: inline-block; background: var(--accent-soft); color: var(--accent); font-weight: 700; padding: 4px 12px; border-radius: 999px; font-size: .85rem; }

.bars { display: flex; align-items: flex-end; gap: 10px; height: 140px; background: var(--card); border-radius: 14px; padding: 16px; box-shadow: 0 4px 14px rgba(29,22,38,.06); }
.bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .col i { display: block; width: 100%; max-width: 70px; background: var(--accent); border-radius: 8px 8px 0 0; min-height: 4px; }
.bars .col span { font-size: .8rem; color: var(--muted); font-weight: 700; }

.admin-form .field input, .admin-form .field textarea, .admin-form .field select {
  font-size: 1rem; padding: 12px 14px; border: 2px solid #e3deec; border-radius: 12px; background: #fbfaff; width: 100%; font-family: inherit;
}
.admin-form .field textarea { min-height: 90px; resize: vertical; }
.admin-form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.btn.admin-btn { font-size: 1rem; padding: 13px 22px; width: auto; display: inline-block; }
.btn.small { font-size: .85rem; padding: 8px 14px; border-radius: 10px; width: auto; display: inline-block; }
.btn.danger { background: #d33; }

.q-item { background: var(--card); border-radius: 14px; padding: 16px 18px; box-shadow: 0 4px 14px rgba(29,22,38,.06); margin-bottom: 12px; display: flex; flex-direction: column; gap: 10px; }
.q-item .q-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.q-item .q-head b { font-size: 1.05rem; }
.q-item .q-opts { color: var(--muted); font-size: .92rem; }
.q-item .q-opts .ok { color: var(--ok); font-weight: 700; }
.q-item .q-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.inactive { opacity: .55; }

.login-box { max-width: 420px; margin: 12vh auto 0; }
.msg { padding: 12px 16px; border-radius: 12px; font-weight: 600; }
.msg.ok { background: #e6f6ec; color: var(--ok); }
.msg.err { background: #fdeaea; color: #d33; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filters input, .filters select { font-size: .95rem; padding: 10px 12px; border: 2px solid #e3deec; border-radius: 10px; background: #fff; }
h3.section { margin: 22px 0 10px; font-size: 1.15rem; }

/* scroll horizontal pra tabelas largas no mobile */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap table.data { min-width: 560px; }

/* linhas de regra de perfil (mobile) */
.rule-row { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.rule-row .lbl { font-size: .9rem; color: var(--muted); white-space: nowrap; }
.rule-row input[type="number"] { width: 88px; padding: 10px; border: 2px solid #e3deec; border-radius: 10px; font-size: 1rem; }
.rule-row .rl-name { flex: 1; min-width: 150px; padding: 10px; border: 2px solid #e3deec; border-radius: 10px; font-size: 1rem; }

@media (max-width: 640px) {
  .admin-form .row { grid-template-columns: 1fr; }
  table.data th, table.data td { font-size: .82rem; padding: 9px 10px; }
  .kpis { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .q-item .q-head { align-items: flex-start; }
}

@media (max-width: 480px) {
  .quiz-shell { padding: 16px 14px 32px; }
  .hero { padding-top: 3vh; gap: 12px; }
  .hero h1 { font-size: 1.7rem; }
  .btn { font-size: 1.15rem; padding: 18px 20px; }
  .btn.big-cta { margin-top: 4px; }
  .card { padding: 20px 16px; gap: 14px; }
  .field input { font-size: 1.1rem; padding: 15px 14px; }
  .q-text { font-size: 1.35rem; }
  .option { font-size: 1.02rem; padding: 15px 13px; gap: 10px; }
  .option .letter { width: 36px; height: 36px; font-size: 1rem; border-radius: 10px; }
  .result { padding-top: 2vh; gap: 14px; }
  .result .score { font-size: 3rem; }
  .result h2 { font-size: 1.5rem; }
  .gift { font-size: 1.02rem; padding: 18px; }
  .progress span { font-size: .85rem; }
  .admin-top h1 { font-size: 1.2rem; }
  .tabs button { padding: 8px 13px; font-size: .85rem; }
  .filters { gap: 8px; }
  .filters input, .filters select { font-size: .85rem; padding: 9px 10px; }
  .btn.admin-btn { font-size: .95rem; padding: 11px 16px; }
  .kpi { padding: 14px; }
  .kpi .v { font-size: 1.6rem; }
}
