:root {
  --bg: #0f1216; --card: #1a1f27; --card2: #232a34; --linha: #2d3542;
  --txt: #e7ecf3; --sub: #9aa7b8; --azul: #3d8bfd; --verde: #22c55e;
  --vermelho: #ef4444; --amarelo: #f5c451; --raio: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { overscroll-behavior-y: none; }
body {
  margin: 0; background: var(--bg); color: var(--txt);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.oculto { display: none !important; }
button, select, input { font: inherit; color: inherit; }
img { max-width: 100%; }

/* ---------- telas de acesso ---------- */
.tela { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.cartao-auth {
  width: 100%; max-width: 360px; background: var(--card); border: 1px solid var(--linha);
  border-radius: var(--raio); padding: 28px 24px; text-align: center;
}
.marca { font-size: 30px; margin: 0 0 4px; letter-spacing: -.5px; }
.marca span, .marca-mini span { color: var(--azul); }
.sub { color: var(--sub); margin: 0 0 20px; }
.campo {
  width: 100%; padding: 13px 14px; margin: 6px 0; background: var(--bg);
  border: 1px solid var(--linha); border-radius: 10px;
}
.campo:focus { outline: none; border-color: var(--azul); }
.botao {
  width: 100%; padding: 13px; margin-top: 10px; border: 1px solid var(--linha);
  background: var(--card2); border-radius: 10px; cursor: pointer; text-decoration: none;
  display: block; text-align: center;
}
.botao.primario { background: var(--azul); border-color: var(--azul); font-weight: 600; color: #fff; }
.botao:active { transform: translateY(1px); }
.troca { color: var(--sub); margin-top: 16px; font-size: 14px; }
.troca a { color: var(--azul); text-decoration: none; }
.erro { background: #3a1d22; color: #ffb4b4; border: 1px solid #5b2a30;
  border-radius: 10px; padding: 10px; margin-bottom: 12px; font-size: 14px; }

/* ---------- topo / abas / filtros ---------- */
.topo {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--linha); position: sticky; top: 0; background: var(--bg); z-index: 20;
}
.topo-esq { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.marca-mini { font-size: 17px; white-space: nowrap; }
.frescor { color: var(--sub); font-size: 11.5px; white-space: nowrap; }
.acoes-topo { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.acoes-topo a { color: var(--sub); text-decoration: none; font-size: 18px; }
.link { background: none; border: none; color: var(--sub); cursor: pointer; text-decoration: underline; }
.banner { background: #3a331a; color: var(--amarelo); text-align: center; padding: 6px; font-size: 13px; }
.abas { display: flex; gap: 4px; padding: 8px 10px 0; position: sticky; top: 0; }
.aba { flex: 1; padding: 10px; background: none; border: none; color: var(--sub);
  border-bottom: 2px solid transparent; cursor: pointer; position: relative; }
.aba.ativa { color: var(--txt); border-bottom-color: var(--azul); font-weight: 600; }
.badge { background: var(--verde); color: #04210f; border-radius: 999px; font-size: 11px;
  padding: 1px 6px; font-weight: 700; }
.filtros { display: flex; gap: 8px; padding: 10px; overflow-x: auto; scrollbar-width: none; }
.filtros::-webkit-scrollbar { display: none; }
.fchip {
  padding: 9px 11px; background: var(--card); border: 1px solid var(--linha);
  border-radius: 10px; min-width: fit-content; flex: 0 0 auto;
}
#f-preco-max { width: 108px; }
main { max-width: 620px; margin: 0 auto; padding: 8px 12px calc(120px + var(--safe-b)); }

/* ---------- DECK de swipe ---------- */
.deck { position: relative; height: 68vh; min-height: 420px; margin-top: 4px; }
.card {
  position: absolute; inset: 0; background: var(--card); border: 1px solid var(--linha);
  border-radius: var(--raio); overflow: hidden; display: flex; flex-direction: column;
  will-change: transform; touch-action: pan-y;
  box-shadow: 0 8px 30px rgba(0,0,0,.35);
}
.card.atras { transform: scale(.94) translateY(14px); filter: brightness(.8); }
.card.saindo { transition: transform .32s cubic-bezier(.2,.7,.3,1), opacity .32s; }
.card .foto-wrap { position: relative; flex: 1 1 auto; min-height: 0; background: var(--card2); }
.card .foto { width: 100%; height: 100%; object-fit: cover; display: block; }
.sem-foto { width: 100%; height: 100%; display: grid; place-items: center; color: var(--sub);
  font-size: 13px; background: repeating-linear-gradient(45deg, #1e2530, #1e2530 12px, #222a35 12px, #222a35 24px); }
.card .corpo { padding: 12px 16px 14px; flex: 0 0 auto; }
.selo-linha { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.badge-desc { background: var(--verde); color: #04210f; font-weight: 700; padding: 2px 9px;
  border-radius: 999px; font-size: 12.5px; }
.badge-queda { background: #3a2030; color: #ff9ec2; font-weight: 600; padding: 2px 8px;
  border-radius: 999px; font-size: 11.5px; }
.preco { font-size: 23px; font-weight: 700; margin: 2px 0; letter-spacing: -.5px; }
.aval { color: var(--sub); font-size: 13px; }
.aval s { opacity: .8; }
.tipo-cidade { color: var(--sub); margin: 6px 0 2px; font-size: 13.5px; }
.endereco { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tags { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.tag { background: var(--card2); border: 1px solid var(--linha); border-radius: 8px;
  padding: 2px 8px; font-size: 12px; color: var(--sub); }

/* overlays QUERO / PASSO durante o arraste */
.overlay { position: absolute; top: 22px; padding: 6px 14px; border-radius: 10px;
  font-weight: 800; font-size: 22px; letter-spacing: 1px; opacity: 0; border: 3px solid;
  pointer-events: none; }
.overlay.quero { left: 18px; color: var(--verde); border-color: var(--verde); transform: rotate(-12deg); }
.overlay.passo { right: 18px; color: var(--vermelho); border-color: var(--vermelho); transform: rotate(12deg); }

/* ---------- controles (zona do polegar) ---------- */
.controles {
  position: fixed; left: 0; right: 0; bottom: calc(12px + var(--safe-b));
  display: flex; justify-content: center; gap: 16px; z-index: 15;
}
.round {
  width: 62px; height: 62px; border-radius: 50%; border: 1px solid var(--linha);
  background: var(--card); font-size: 23px; cursor: pointer; display: grid; place-items: center;
  box-shadow: 0 6px 18px rgba(0,0,0,.4);
}
.round.favoritar { color: var(--verde); border-color: #2c5a3a; }
.round.descartar { color: var(--vermelho); border-color: #5b2a30; }
.round.undo, .round.detalhe { width: 48px; height: 48px; font-size: 18px; color: var(--sub); align-self: center; }
.round:active { transform: scale(.9); }

/* ---------- skeleton ---------- */
.skeleton-card, .skeleton-tile { position: relative; overflow: hidden; background: var(--card);
  border: 1px solid var(--linha); border-radius: var(--raio); }
.skeleton-card { position: absolute; inset: 0; }
.skeleton-tile { aspect-ratio: 3/4; }
.skeleton-card::after, .skeleton-tile::after { content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.05), transparent);
  transform: translateX(-100%); animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }

.vazio { position: absolute; inset: 0; display: grid; place-content: center; text-align: center;
  color: var(--sub); padding: 30px; gap: 12px; }
.vazio b { color: var(--txt); font-size: 17px; }

/* ---------- grade (explorar/favoritos) ---------- */
.ordenar { display: flex; align-items: center; gap: 8px; margin: 6px 0 10px; color: var(--sub); font-size: 13px; }
.total { margin-left: auto; }
.grade { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mini { background: var(--card); border: 1px solid var(--linha); border-radius: 12px;
  overflow: hidden; cursor: pointer; }
.mini.decidido { opacity: .55; }
.mini .foto-wrap { aspect-ratio: 4/3; position: relative; }
.mini .corpo { padding: 9px 10px 11px; }
.mini .preco { font-size: 16px; margin: 3px 0 0; }
.mini small { color: var(--sub); font-size: 12px; display: block; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.selo-mini { position: absolute; top: 6px; left: 6px; }
.prazo { color: var(--amarelo); font-size: 12px; margin-top: 4px; }
.prazo.encerrado { color: var(--sub); }
.sentinela { height: 40px; }
@media (min-width: 560px) { .grade { grid-template-columns: 1fr 1fr 1fr; } }

/* ---------- bottom sheet de detalhe ---------- */
.sheet-fundo { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 40; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; background: var(--card);
  border-radius: 20px 20px 0 0; max-height: 92dvh; overflow-y: auto;
  padding: 10px 0 calc(24px + var(--safe-b)); transform: translateY(0);
  animation: subir .28s cubic-bezier(.2,.7,.3,1); }
@keyframes subir { from { transform: translateY(100%); } }
.sheet-alca { width: 42px; height: 5px; background: var(--linha); border-radius: 3px; margin: 6px auto 12px; }
.sheet-conteudo { padding: 0 18px; }
.galeria { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory;
  margin: 0 -18px 12px; padding: 0 18px; scrollbar-width: none; }
.galeria::-webkit-scrollbar { display: none; }
.galeria img, .galeria .sem-foto { flex: 0 0 82%; scroll-snap-align: center; border-radius: 12px;
  aspect-ratio: 4/3; object-fit: cover; }
.sheet h2 { font-size: 21px; margin: 4px 0 2px; }
.sheet .desc { color: var(--sub); font-size: 14px; white-space: pre-wrap; margin: 10px 0; }
.sheet .linhas { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin: 12px 0; }
.sheet .linhas div { font-size: 13px; }
.sheet .linhas span { color: var(--sub); display: block; font-size: 11.5px; }
.sheet textarea { width: 100%; min-height: 66px; background: var(--bg); border: 1px solid var(--linha);
  border-radius: 10px; padding: 10px; resize: vertical; margin-top: 6px; }
.sheet-links { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.sheet-links a { background: var(--card2); border: 1px solid var(--linha); border-radius: 10px;
  padding: 9px 12px; font-size: 13px; color: var(--azul); text-decoration: none; }
.sheet-acoes { display: flex; gap: 12px; margin-top: 14px; }
.sheet-acoes button { flex: 1; padding: 13px; border-radius: 12px; border: 1px solid var(--linha);
  background: var(--card2); font-weight: 600; cursor: pointer; }
.sheet-acoes .fav { background: var(--verde); border-color: var(--verde); color: #04210f; }
.sheet-acoes .desc-btn { color: var(--vermelho); border-color: #5b2a30; }

/* ---------- onboarding ---------- */
.onboarding { position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 50; display: grid; place-items: center; padding: 24px; }
.onb-card { background: var(--card); border: 1px solid var(--linha); border-radius: var(--raio); padding: 24px; max-width: 340px; }
.onb-card h2 { margin: 0 0 14px; }
.onb-card ul { padding-left: 18px; margin: 0 0 18px; color: var(--sub); line-height: 1.9; font-size: 14px; }
.onb-card b { color: var(--txt); }

/* ---------- toasts ---------- */
.toasts { position: fixed; left: 0; right: 0; bottom: calc(90px + var(--safe-b)); z-index: 60;
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { background: #2a3340; border: 1px solid var(--linha); color: var(--txt); padding: 10px 16px;
  border-radius: 999px; font-size: 13.5px; box-shadow: 0 6px 18px rgba(0,0,0,.4);
  animation: toastIn .2s; max-width: 90vw; }
.toast.erro { background: #3a1d22; border-color: #5b2a30; }
.toast button { pointer-events: auto; background: none; border: none; color: var(--azul);
  text-decoration: underline; cursor: pointer; margin-left: 8px; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }
