:root {
  --bg: #0f172a;
  --bg2: #1e293b;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --brand: #16a34a;
  --brand-dark: #15803d;
  --accent: #f59e0b;
  --danger: #dc2626;
  --line: #e2e8f0;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(2, 6, 23, 0.12);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  background: #f1f5f9;
  color: var(--ink);
}
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }

/* Header */
.topbar { background: var(--bg); color: #fff; position: sticky; top: 0; z-index: 50; }
.topbar-inner { display: flex; gap: 12px; align-items: center; padding: 12px 16px; flex-wrap: wrap; justify-content: space-between; }
.logo { color: #fff; text-decoration: none; font-weight: 800; font-size: 1.25rem; white-space: nowrap; }
.logo span { color: #4ade80; }
.searchbox { flex: 1; min-width: 180px; }
.searchbox input {
  width: 100%; padding: 10px 14px; border-radius: 999px; border: 0; outline: none; font-size: 0.95rem;
}
.nav { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-left: auto; }
.nav-btn {
  background: transparent; color: #cbd5e1; border: 1px solid #334155;
  border-radius: 999px; padding: 8px 12px; cursor: pointer; font-size: 0.85rem;
}
.nav-btn.active, .nav-btn:hover { background: #22c55e; border-color: #22c55e; color: #052e16; font-weight: 700; }
.pill { background: #334155; color: #fff; border-radius: 999px; padding: 1px 8px; font-size: 0.75rem; }
.nav-btn.active .pill { background: #052e16; color: #bbf7d0; }

/* Buttons */
.btn { border: 0; border-radius: 10px; padding: 10px 16px; cursor: pointer; font-weight: 700; font-size: 0.9rem; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.ghost { background: #e2e8f0; color: var(--ink); }
.btn.small { padding: 8px 12px; font-size: 0.82rem; }
.btn.big { font-size: 1rem; padding: 12px 20px; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.whats { background: #25d366; color: #052e16; }

/* Hero */
.hero { background: linear-gradient(135deg, #052e16, #166534 55%, #ca8a04); color: #fff; }
.hero-inner { display: flex; justify-content: center; gap: 24px; padding: 36px 16px; align-items: center; flex-wrap: wrap; }
.hero-inner > div:first-child { flex: 1 1 320px; max-width: 640px; }
.hero h1 { margin: 0 0 8px; font-size: 2rem; }
.hero p { margin: 0 0 16px; color: #dcfce7; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.hero-stats { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.stat { background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.25); border-radius: var(--radius); padding: 14px 20px; text-align: center; min-width: 100px; }
.stat strong { display: block; font-size: 1.6rem; }
.stat span { font-size: 0.8rem; color: #e9fccf; }

/* Filters */
.filters { display: flex; gap: 10px; align-items: center; margin: 18px 0; flex-wrap: wrap; }
.filters select, .filters input {
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: #fff; font-size: 0.9rem;
}
.result-count { margin-left: auto; color: var(--muted); font-size: 0.85rem; }

/* Grid & cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; padding-bottom: 30px; }
.card { background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; position: relative; }
.card.mine { outline: 2px dashed var(--brand); }
.photo { height: 205px; display: flex; align-items: center; justify-content: center; font-size: 4rem; color: #fff; position: relative; overflow: hidden; }
.photo img { width: 100%; height: 100%; object-fit: cover; }
.photo-count { position: absolute; right: 8px; bottom: 8px; background: rgba(2,6,23,.7); color: #fff; font-size: 0.75rem; font-weight: 800; padding: 3px 9px; border-radius: 999px; }
.legacy-warn { font-size: 0.78rem; margin: 4px 0 0; }
.counter { font-size: 0.82rem; }

/* Upload: grid do rascunho */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); gap: 10px; margin: 8px 0 12px; }
.thumb { position: relative; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #f8fafc; }
.thumb img { width: 100%; height: 80px; object-fit: cover; display: block; }
.thumb .thumb-nav { display: flex; gap: 4px; padding: 4px; justify-content: center; }
.thumb .thumb-nav button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 3px 8px; cursor: pointer; font-weight: 800; }
.thumb .thumb-nav button:disabled { opacity: 0.35; cursor: default; }
.capa-tag { position: absolute; top: 4px; left: 4px; background: #16a34a; color: #fff; font-size: 0.68rem; font-weight: 800; padding: 2px 8px; border-radius: 999px; }
.capa-tag.mini { font-size: 0.6rem; top: 2px; left: 2px; }
#btnSubmitPublish:disabled { opacity: 0.5; cursor: not-allowed; }

/* Detalhe: main + thumbs clicáveis */
.detail-main img { width: 100%; max-height: 380px; object-fit: cover; border-radius: 12px; display: block; background: #0f172a; }
.detail-thumbs { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.detail-thumb { position: relative; border: 2px solid transparent; border-radius: 8px; padding: 0; cursor: pointer; background: none; }
.detail-thumb img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; display: block; }
.detail-thumb.active { border-color: var(--brand); }
.card .fav { position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,.45); border: 0; border-radius: 50%; width: 36px; height: 36px; font-size: 1.1rem; cursor: pointer; color: #fff; }
.card .fav:hover { background: #ef4444; }
.badges { position: absolute; top: 8px; left: 8px; display: flex; gap: 6px; }
.badge { font-size: 0.7rem; font-weight: 800; padding: 4px 8px; border-radius: 999px; background: #0f172a; color: #fff; }
.badge.troca { background: #2563eb; } .badge.venda { background: #16a34a; } .badge.ambos { background: #7c3aed; }
.badge.estado { background: #f59e0b; color: #451a03; }
.badge.nf { background: #16a34a; color: #fef9c3; }
.badge.nf.missing { background: #fee2e2; color: #991b1b; }
.badge.deal { background: #111; }
.card-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-body h3 { margin: 0; font-size: 1rem; line-height: 1.3; }
.price { font-weight: 800; color: var(--brand-dark); font-size: 1.1rem; }
.city, .swap { font-size: 0.83rem; color: var(--muted); }
.swap strong { color: var(--ink); }
.card-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 8px; }
.card-actions .btn { flex: 1; padding: 9px 6px; font-size: 0.82rem; }

/* Detail */
.detail-photo { height: 260px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 5rem; color: #fff; overflow: hidden; margin-bottom: 12px; }
.detail-photo img { width: 100%; height: 100%; object-fit: cover; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; margin: 12px 0; }
.detail-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.owner-tag { display: inline-block; background: #dcfce7; color: #166534; font-weight: 800; font-size: 0.78rem; padding: 4px 10px; border-radius: 999px; margin-left: 8px; }

/* Selo verificado WhatsApp */
.seal { display: inline-flex; align-items: center; gap: 5px; font-size: 0.7rem; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: #dcfce7; color: #166534; margin-left: 6px; vertical-align: middle; white-space: nowrap; }
.seal.no { background: #fee2e2; color: #991b1b; }
.seal.big { font-size: 0.8rem; padding: 5px 12px; }
.seal svg { width: 12px; height: 12px; flex: 0 0 auto; }
.seal.big svg { width: 15px; height: 15px; }
.card-body .city { line-height: 1.8; }
.similar-row .card-body .city { font-size: 0.78rem; }

/* Chips de categoria + ordenação */
.chips { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; flex-basis: 100%; margin-top: 2px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 12px; cursor: pointer; font-size: 0.82rem; font-weight: 700; color: var(--ink); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.chip:hover { border-color: var(--brand); }
.chip.active { background: var(--bg); color: #fff; border-color: var(--bg); }
.chip .count { background: #e2e8f0; color: var(--ink); border-radius: 999px; padding: 1px 8px; font-size: 0.72rem; font-weight: 800; }
.chip.active .count { background: #22c55e; color: #052e16; }

/* Detalhe Pro — layout 2 blocos */
.detail-layout { display: grid; grid-template-columns: 1.1fr 1fr; gap: 16px; align-items: start; }
.detail-media .detail-photo { aspect-ratio: 4 / 3; height: auto; min-height: 180px; margin-bottom: 0; }
.detail-info h2 { margin: 0 0 4px; font-size: 1.25rem; line-height: 1.3; }
.detail-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.detail-meta { color: var(--muted); font-size: 0.88rem; margin: 4px 0; }
.detail-price { font-size: 1.6rem; font-weight: 800; color: var(--brand-dark); margin: 6px 0; }
.trust-box { background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 12px; padding: 10px 12px; margin: 10px 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 0.88rem; }
.troca-destaque { background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 12px; padding: 10px 12px; margin: 10px 0; font-size: 0.9rem; }
.desc-pre { white-space: pre-wrap; word-break: break-word; line-height: 1.5; }
.safety-mini { font-size: 0.82rem; color: #92400e; background: #fffbeb; border: 1px solid #fde68a; border-radius: 12px; padding: 8px 12px 8px 30px; margin: 10px 0; }
.safety-mini li { margin: 2px 0; }
.detail-actions { position: sticky; bottom: 0; background: #fff; padding: 10px 0; border-top: 1px solid var(--line); }
.similar-title { margin: 16px 0 8px; font-size: 1rem; }
.similar-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.similar-row .photo { height: 100px; font-size: 2.2rem; }
.similar-row .card-actions .btn { font-size: 0.75rem; }

/* Acessibilidade: anel de foco verde 3px */
:focus-visible { outline: 3px solid #22c55e; outline-offset: 2px; }

/* Modals */
.modal-backdrop { position: fixed; inset: 0; background: rgba(2,6,23,.6); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 100; }
.modal-backdrop[hidden] { display: none; }
.modal { background: #fff; border-radius: 16px; max-width: 620px; width: 100%; max-height: 90vh; overflow: auto; padding: 22px; position: relative; }
.modal-close { position: absolute; top: 12px; right: 12px; border: 0; background: #f1f5f9; border-radius: 50%; width: 32px; height: 32px; cursor: pointer; }
.modal h2 small { color: var(--muted); font-size: 0.8rem; }
.wizard-progress { height: 8px; background: #e2e8f0; border-radius: 999px; margin: 8px 0 16px; overflow: hidden; }
.wizard-progress div { height: 100%; width: 50%; background: var(--brand); transition: width .25s; }
form label { display: block; font-size: 0.88rem; font-weight: 600; margin-bottom: 12px; }
form input, form select, form textarea {
  width: 100%; margin-top: 4px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); font-size: 0.92rem; font-family: inherit;
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.wizard-nav { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* Offers */
.subtabs { display: flex; gap: 8px; margin: 18px 0; }
.subtab { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 9px 16px; cursor: pointer; font-weight: 700; }
.subtab.active { background: var(--bg); color: #fff; }
.offers { display: flex; flex-direction: column; gap: 12px; padding-bottom: 30px; }
.offer { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.offer-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; flex-wrap: wrap; }
.status { font-size: 0.75rem; font-weight: 800; padding: 4px 10px; border-radius: 999px; }
.status.pendente { background: #fef3c7; color: #92400e; }
.status.contraproposta { background: #dbeafe; color: #1e40af; }
.status.aceita { background: #dcfce7; color: #166534; }
.status.recusada { background: #fee2e2; color: #991b1b; }
.status.expirada { background: #e2e8f0; color: #475569; }
.timeline { display: flex; gap: 8px; align-items: center; margin: 8px 0; font-size: 0.82rem; font-weight: 700; }
.round-dot { width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; border: 2px solid var(--line); background: #fff; color: var(--muted); }
.round-dot.done { background: var(--brand); border-color: var(--brand); color: #fff; }
.round-dot.now { border-color: var(--brand); color: var(--brand-dark); }
.volta-hist { margin: 8px 0; padding-left: 18px; font-size: 0.83rem; color: var(--muted); }
.volta-hist li { margin: 2px 0; }
.expira { font-size: 0.82rem; color: #92400e; font-weight: 700; }
.counter-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.counter-row input { max-width: 160px; }
.offer-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* Chat por proposta (local, sem bot) */
.chat-aviso { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; border-radius: 12px; padding: 8px 12px; font-size: 0.82rem; margin: 0 0 10px; }
.chat-list { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; padding: 10px; background: #f8fafc; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; }
.bubble { max-width: 82%; border-radius: 14px; padding: 8px 12px; font-size: 0.9rem; line-height: 1.4; word-break: break-word; }
.bubble p { margin: 2px 0; white-space: pre-wrap; }
.bubble-who { display: block; font-size: 0.7rem; font-weight: 800; opacity: 0.7; }
.bubble-time { display: block; font-size: 0.7rem; color: var(--muted); margin-top: 2px; }
.bubble-eu { align-self: flex-end; background: #dcfce7; border: 1px solid #bbf7d0; text-align: right; }
.bubble-outro { align-self: flex-start; background: #fff; border: 1px solid var(--line); }
.bubble-sistema { align-self: center; background: #e2e8f0; color: #475569; font-size: 0.8rem; text-align: center; max-width: 95%; }
#chatForm .chat-label { margin-bottom: 8px; }
#chatSend:disabled, #chatInput:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.has-unread { outline: 2px solid var(--accent); }

/* Toast / empty / footer */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--bg); color: #fff; padding: 12px 20px; border-radius: 999px;
  opacity: 0; pointer-events: none; transition: all .3s; z-index: 200; font-size: 0.9rem;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.empty { text-align: center; padding: 40px 10px; color: var(--muted); }
.footer { background: var(--bg); color: #e2e8f0; margin-top: 20px; }
.footer-inner { display: grid; grid-template-columns: 1fr 1.4fr; gap: 24px; padding: 28px 16px; }
.footer ul { margin: 8px 0; padding-left: 18px; font-size: 0.88rem; }
.footer p { font-size: 0.88rem; }

@media (max-width: 1024px) {
  .hero-inner { flex-direction: column; text-align: center; }
  .hero-actions, .hero-stats { justify-content: center; }
}

/* Auth conta tradicional + mascaramento */
.blur-contact { filter: blur(4px); user-select: none; pointer-events: none; }
.reveal-row { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.reset-inbox { background: #fffbeb; border: 1px dashed #f59e0b; border-radius: 12px; padding: 10px 12px; margin-top: 12px; }
.reset-code { font-size: 1.6rem; font-weight: 800; letter-spacing: 6px; margin: 4px 0 0; }
#resetCode { font-size: 1.4rem; font-weight: 800; letter-spacing: 6px; text-align: center; }
.field-error { color: var(--danger); font-size: 0.82rem; font-weight: 700; margin: -6px 0 10px; }
.pass-row { display: flex; gap: 8px; align-items: center; }
.pass-row input { flex: 1; }
.pass-toggle { flex: 0 0 auto; }
input.invalid { border-color: var(--danger); }
#authModal .subtab { flex: 1; }

@media (max-width: 720px) {
  .chat-list { max-height: 46vh; }
  .bubble { max-width: 92%; font-size: 0.88rem; }
  #chatForm .wizard-nav { flex-direction: column; align-items: stretch; }
  #chatForm .wizard-nav .btn { width: 100%; }
  .hero h1 { font-size: 1.5rem; }
  .row, .detail-grid, .footer-inner, .detail-layout { grid-template-columns: 1fr; }
  .topbar-inner { align-items: stretch; justify-content: center; text-align: center; }
  .nav { justify-content: center; margin-left: 0; }
  .searchbox { order: 3; flex-basis: 100%; }
  .hero-inner { flex-direction: column; text-align: center; }
  .hero-actions, .hero-stats { justify-content: center; }
  .stat { min-width: 86px; padding: 10px 12px; }
  .detail-actions { flex-direction: column; align-items: stretch; }
  .detail-actions .btn, .detail-actions a.btn { flex: 1 1 100%; width: 100%; text-align: center; }
  .chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x mandatory; scrollbar-width: none; -ms-overflow-style: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chips .chip { flex: 0 0 auto; scroll-snap-align: start; }
}
