*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --brand: #7c3aed;
  --brand-dark: #5b21b6;
  --brand-light: #ede9fe;
  --success: #059669;
  --error: #dc2626;
  --text: #1e1b4b;
  --muted: #6b7280;
  --border: #e5e7eb;
  --bg: #f5f3ff;
  --card: #ffffff;
  --radius: 12px;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 2rem 1rem;
}

main {
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

header {
  text-align: center;
}

header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--brand);
}

header .subtitle {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1.1rem;
}

label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}

.optional {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.8rem;
}

select, input[type="number"] {
  padding: 0.6rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

select:focus, input[type="number"]:focus {
  border-color: var(--brand);
}

button[type="submit"] {
  width: 100%;
  padding: 0.75rem;
  background: var(--brand);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 0.25rem;
}

button[type="submit"]:hover {
  background: var(--brand-dark);
}

button[type="submit"]:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Resultado */
.resultado {
  margin-top: 1.25rem;
  border-top: 1px solid var(--border);
  padding-top: 1.25rem;
}

.cashback-final {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--brand-light);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

.cashback-final .label {
  font-weight: 600;
  color: var(--brand-dark);
}

.cashback-final .valor {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--success);
}

details summary {
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--muted);
  user-select: none;
}

details[open] summary {
  margin-bottom: 0.75rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

table tr:not(:last-child) td {
  border-bottom: 1px solid var(--border);
}

table td {
  padding: 0.4rem 0.25rem;
  color: var(--text);
}

table td:last-child {
  text-align: right;
  font-weight: 500;
}

/* Erro */
.erro {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: #fef2f2;
  color: var(--error);
  border-radius: 8px;
  font-size: 0.875rem;
}

/* Histórico */
#historico-section h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.historico-info {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

.loading {
  color: var(--muted);
  font-size: 0.875rem;
}

.historico-vazio {
  color: var(--muted);
  font-size: 0.875rem;
}

.historico-tabela {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.historico-tabela th {
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  padding: 0.4rem 0.25rem;
  border-bottom: 2px solid var(--border);
}

.historico-tabela td {
  padding: 0.5rem 0.25rem;
  border-bottom: 1px solid var(--border);
}

.historico-tabela td:nth-child(3),
.historico-tabela td:nth-child(4) {
  text-align: right;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-vip {
  background: var(--brand-light);
  color: var(--brand-dark);
}

.badge-comum {
  background: #f3f4f6;
  color: var(--muted);
}

.hidden {
  display: none;
}
