/* Fidelidade Di Lidia — paleta inspirada na identidade da marca:
   preto profundo + dourado quente + acentos crus.
   Mobile-first: tamanhos crescem em viewports maiores. */
:root {
  /* Paleta Di Lidia: vinho/bordô aconchegante + creme da logo (anti-horror) */
  --bg: #0c0707;            /* preto morno, com sutil tom marrom */
  --bg-soft: #1a0d0d;
  --card: #1d100e;          /* "couro escuro" da poltrona */
  --card-2: #160a08;
  --line: #3a201c;          /* bordas terrosas, não vermelho-saturado */
  --gold: #a82828;          /* "vermelho-tijolo" — vinho amigável */
  --gold-soft: #7a1818;
  --gold-bright: #c44545;
  --cream: #f0e0c0;         /* creme da logo Di Lidia */
  --cream-soft: #d9c89c;
  --text: #ece0cc;          /* texto: creme-quente em vez de branco gritante */
  --text-mute: #a8927a;
  --danger: #e8a06b;        /* erro = âmbar/laranja, NÃO vermelho (não pra confundir com a marca) */
  --success: #8bc070;
  --radius: 14px;
  --shadow: 0 4px 24px rgba(0,0,0,.5);

  /* Espaçamentos: pequenos no mobile, crescem em telas maiores */
  --gap-xs: 6px;
  --gap-sm: 10px;
  --gap-md: 14px;
  --gap-lg: 18px;

  /* Hit target mínimo (Apple HIG / Material): 44px */
  --tap: 44px;

  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background:
    radial-gradient(ellipse 60% 50% at 50% 0%, #2a1410 0%, transparent 70%),
    radial-gradient(ellipse 80% 60% at 50% 100%, #1a0a08 0%, transparent 70%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh; /* respeita barra de URL no mobile */
  -webkit-font-smoothing: antialiased;
  /* Safe-area pra iPhones com notch */
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

a { color: var(--gold); }
a:hover { color: var(--gold-bright); }

/* Layout — mobile-first: padding lateral pequeno, expansão progressiva */
.shell {
  width: 100%;
  max-width: 540px;
  margin: 0 auto;
  /* Padding lateral usa env() pra evitar conteúdo embaixo do notch em landscape */
  padding:
    16px
    max(14px, env(safe-area-inset-right))
    32px
    max(14px, env(safe-area-inset-left));
}
.shell-wide { max-width: 960px; }

@media (min-width: 600px) {
  .shell { padding: 24px 24px 60px; }
}

header.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-bottom: 16px;
  padding-top: 8px;
}
header.brand img {
  width: 180px;
  max-width: 60%;
  height: auto;
  opacity: 0.95;
}
header.brand small {
  color: var(--text-mute);
  letter-spacing: 1px;
  font-size: 10px;
  text-align: center;
}
@media (min-width: 600px) {
  header.brand { margin-bottom: 20px; padding-top: 12px; }
  header.brand img { width: 220px; max-width: 70%; }
  header.brand small { font-size: 11px; }
}

h1, h2, h3 { font-weight: 600; letter-spacing: -0.01em; margin: 0 0 12px; }
h1 { font-size: 20px; line-height: 1.25; }
h2 { font-size: 17px; line-height: 1.3; color: var(--gold); }
@media (min-width: 600px) {
  h1 { font-size: 22px; }
  h2 { font-size: 18px; }
}
p { line-height: 1.5; margin: 0 0 8px; }

.muted { color: var(--text-mute); font-size: 14px; }
.muted.tight { font-size: 13px; }

/* Cards — padding mais apertado no mobile pra ganhar largura útil */
.card {
  background: linear-gradient(180deg, var(--card) 0%, var(--card-2) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 6px 18px rgba(0,0,0,.4);
}
.card.compact { padding: 12px; }
@media (min-width: 600px) {
  .card { padding: 22px; margin-bottom: 16px; }
  .card.compact { padding: 14px; }
}

/* Inputs / botões — todos com alvo de toque mínimo de 44px */
input, select, textarea, button {
  font: inherit;
  color: inherit;
  border-radius: 10px;
  outline: none;
}

label {
  display: block;
  font-size: 13px;
  color: var(--text-mute);
  margin: 12px 0 6px;
}

input[type="text"],
input[type="tel"],
input[type="number"],
input[type="password"],
input[type="email"],
select,
textarea {
  width: 100%;
  background: #100806;
  border: 1px solid var(--line);
  padding: 12px 14px;
  min-height: var(--tap);
  color: var(--text);
  /* 16px previne auto-zoom no iOS Safari */
  font-size: 16px;
  transition: border .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold-soft); }

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  min-height: var(--tap);
  background: linear-gradient(180deg, var(--gold-bright), var(--gold-soft));
  color: #ffffff;
  border: none;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
  transition: transform .08s, filter .15s;
  /* Remove tap highlight bizarro do iOS */
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button:hover, .btn:hover { filter: brightness(1.08); }
button:active, .btn:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.secondary, .btn.secondary {
  background: transparent;
  color: var(--gold);
  border: 1px solid var(--gold-soft);
}
button.danger { background: var(--danger); color: #fff; }
button.full { width: 100%; }
button.tight {
  padding: 8px 12px;
  min-height: 36px;
  font-size: 14px;
}

/* Mensagens */
.msg {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  margin: 10px 0;
  word-wrap: break-word;
}
.msg.error  { background: rgba(255,138,92,.12); color: #ffc8aa; border: 1px solid rgba(255,138,92,.4); }
.msg.success { background: rgba(109,177,90,.12); color: #c5e3b8; border: 1px solid rgba(109,177,90,.4); }
.msg.info { background: rgba(181,29,29,.10); color: var(--text); border: 1px solid var(--line); }

/* Cartão de carimbos (visual estilo "10 quadradinhos") */
.stamp-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin: 14px 0;
}
@media (min-width: 380px) { .stamp-grid { gap: 10px; } }
@media (min-width: 600px) { .stamp-grid { gap: 12px; margin: 18px 0; } }

.stamp {
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: #150a08;
  border: 2px dashed var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-mute);
  font-size: 16px;
  font-weight: 700;
  position: relative;
}
/* Carimbo "preenchido": parece tinta carimbada em papel — opaco, levemente
   torto, com sutil variação de tom (como tinta que pegou desigual). */
.stamp.filled {
  background:
    radial-gradient(circle at 35% 35%, rgba(255,255,255,.12), transparent 50%),
    var(--gold);
  border: 2px solid var(--gold-soft);
  color: var(--cream);
  box-shadow: inset 0 -2px 4px rgba(0,0,0,.25);
  transform: rotate(-6deg);
}
.stamp.filled::before {
  content: "★";
  font-size: 20px;
}
.stamp.filled span { display: none; }
@media (min-width: 600px) {
  .stamp { font-size: 18px; }
  .stamp.filled::before { font-size: 22px; }
}

.balance-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 10px 0;
  flex-wrap: wrap;
  gap: 8px;
}
.balance-line .big {
  font-size: 32px;
  font-weight: 700;
  color: var(--cream);
  line-height: 1;
}
@media (min-width: 600px) { .balance-line .big { font-size: 36px; } }

/* Tabelas — no mobile, força scroll horizontal e cells mais compactas */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -4px; /* compensa padding da td pra alinhar */
}
table {
  width: 100%;
  min-width: 480px; /* força scroll horizontal em telas pequenas */
  border-collapse: collapse;
  font-size: 14px;
}
th, td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
th {
  color: var(--gold);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  position: sticky;
  top: 0;
  background: var(--card);
}
tr:hover td { background: rgba(181,29,29,.07); }
@media (min-width: 600px) {
  th { font-size: 12px; }
}

/* Navegação por abas — no mobile vira scroll horizontal pra não quebrar */
.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  /* Some 'em' por baixo do scrollbar */
  padding-bottom: 4px;
  /* Esconde scrollbar mantendo funcionalidade */
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-soft);
  cursor: pointer;
  color: var(--text-mute);
  font-size: 13px;
  white-space: nowrap;
  flex-shrink: 0;
  min-height: 36px;
  -webkit-tap-highlight-color: transparent;
}
.tab.active { background: var(--gold); color: #ffffff; border-color: var(--gold); }
@media (min-width: 600px) {
  .tabs { flex-wrap: wrap; overflow-x: visible; margin-bottom: 16px; }
  .tab { font-size: 14px; }
}

/* Util */
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.nowrap { flex-wrap: nowrap; }
.spacer { flex: 1; }
.center { text-align: center; }
.hidden { display: none !important; }
.stack > * + * { margin-top: 12px; }
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  font-size: 11px;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.tag.gold { background: var(--gold); color: #ffffff; border-color: var(--gold); }

/* Footer */
footer {
  text-align: center;
  color: var(--text-mute);
  font-size: 12px;
  margin-top: 20px;
  padding: 0 4px;
}
footer a { color: var(--text-mute); }
footer p { margin: 4px 0; }

/* Telas muito pequenas (iPhone SE 1ª gen, etc) */
@media (max-width: 360px) {
  .shell { padding-left: 12px; padding-right: 12px; }
  .card { padding: 14px; }
  h1 { font-size: 18px; }
  .balance-line .big { font-size: 28px; }
  button, .btn { padding: 12px 14px; font-size: 14px; }
  .stamp-grid { gap: 6px; }
  .stamp.filled::before { font-size: 18px; }
}

/* Landscape mobile (altura curta) — encolhe verticais */
@media (max-height: 500px) and (max-width: 900px) {
  header.brand { margin-bottom: 10px; padding-top: 4px; }
  header.brand img { width: 140px; }
  .card { padding: 12px; margin-bottom: 10px; }
}
