:root {
  --bg: #0a1320;
  --bg-soft: #16273a;
  --surface: #16202e;
  --surface-2: #0f1825;
  --ink: #e9eef4;
  --ink-soft: #93a3b6;
  --line: #263442;
  --brand: #2b8aff;
  --brand-dark: #1f6fd6;
  --accent: #16c784;
  --danger: #ef5a5f;
  --warn: #f5a524;
  --radius: 16px;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--surface-2);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}

.hidden { display: none !important; }

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  color: #fff;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-logo { font-size: 22px; }
.brand-name { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; }

.vehicle-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-soft);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  text-align: left;
}
.vehicle-chip-icon { font-size: 16px; }
.vehicle-chip.set { background: var(--brand); border-color: transparent; }

/* Views */
.view { padding: 16px; display: flex; flex-direction: column; gap: 18px; }

.section-title {
  font-size: 16px;
  font-weight: 700;
  margin: 4px 0;
}
.muted { color: var(--ink-soft); font-size: 13px; }

/* Banner compatibilidade */
.compat-banner {
  background: linear-gradient(135deg, #16c784, #0fa968);
  color: #fff;
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
}
.compat-banner.warn { background: linear-gradient(135deg, #1f7aec, #1560c4); }
.compat-banner .big { font-size: 28px; }
.compat-banner h3 { margin: 0 0 2px; font-size: 15px; }
.compat-banner p { margin: 0; font-size: 12.5px; opacity: 0.92; }

/* Categorias */
.cats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.cat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  text-align: center;
}
.cat .cat-ico { font-size: 24px; }
.cat.active { border-color: var(--brand); background: rgba(43, 138, 255, 0.16); }

/* Lista de pecas */
.parts-grid { display: flex; flex-direction: column; gap: 12px; }
.part-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  gap: 12px;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.part-thumb {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  font-size: 30px;
  flex-shrink: 0;
}
.part-info { flex: 1; min-width: 0; }
.part-name { font-size: 14px; font-weight: 700; line-height: 1.25; margin: 0 0 4px; }
.part-meta { font-size: 12px; color: var(--ink-soft); margin: 0 0 6px; }
.part-bottom { display: flex; align-items: center; justify-content: space-between; }
.part-price { font-size: 16px; font-weight: 800; color: var(--ink); }

.badge {
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.badge.ok { background: rgba(22, 199, 132, 0.16); color: #2fe0a3; }
.badge.no { background: rgba(239, 90, 95, 0.16); color: #ff8589; }
.badge.neutral { background: rgba(147, 163, 182, 0.14); color: var(--ink-soft); }
.badge.atacado { background: rgba(245, 165, 36, 0.16); color: #f7c069; }

.part-card.incompat { opacity: 0.55; }

/* Busca */
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 16px;
  box-shadow: var(--shadow);
}
.search-box input {
  border: none;
  outline: none;
  font-size: 15px;
  flex: 1;
  background: transparent;
  color: var(--ink);
}
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-toggle {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  color: var(--ink-soft);
}
.chip-toggle.on { background: var(--brand); color: #fff; border-color: transparent; }

/* Empty */
.empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--ink-soft);
}
.empty .emoji { font-size: 44px; display: block; margin-bottom: 10px; }

/* Buttons */
.btn {
  border: none;
  border-radius: 12px;
  padding: 13px 16px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:disabled { background: #2c3a4a; color: var(--ink-soft); cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--ink-soft); }
.btn.block { width: 100%; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.whats { background: #25d366; color: #07321c; margin-top: 8px; }

.icon-btn {
  background: transparent;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--ink-soft);
  padding: 4px 8px;
}

/* Bottom nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border-top: 1px solid var(--line);
  display: flex;
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
  z-index: 30;
}
.nav-btn {
  flex: 1;
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  position: relative;
  padding: 4px 0;
}
.nav-btn .nav-ico { font-size: 20px; }
.nav-btn.active { color: var(--brand); }
.cart-badge {
  position: absolute;
  top: -2px;
  right: 50%;
  margin-right: -22px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  padding: 0 4px;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(13, 27, 42, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}
.modal-card {
  background: var(--surface);
  width: 100%;
  max-width: 520px;
  border-radius: 20px 20px 0 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.22s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-sub { color: var(--ink-soft); font-size: 13px; margin: 6px 0 16px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field span { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.field select {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  font-size: 15px;
  background: var(--surface-2);
  color: var(--ink);
}
.field select:disabled { opacity: 0.5; }

/* Consulta por placa */
.plate-row { display: flex; gap: 8px; }
.plate-input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-align: center;
  background: var(--surface-2);
  color: var(--ink);
  outline: none;
}
.plate-input:focus { border-color: var(--brand); }
.plate-row .btn { padding: 13px 18px; white-space: nowrap; }
.plate-msg { display: block; min-height: 16px; margin-top: 6px; font-size: 12.5px; font-weight: 600; }
.plate-msg.ok { color: var(--accent); }
.plate-msg.err { color: var(--danger); }
.plate-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 16px 0 14px; color: var(--ink-soft); font-size: 12px;
}
.plate-divider::before, .plate-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--line);
}
.modal-actions { display: flex; gap: 10px; margin-top: 8px; }
.modal-actions .btn { flex: 1; }

/* Detalhe peca */
.pd-hero {
  background: var(--surface-2);
  border-radius: 14px;
  height: 140px;
  display: grid;
  place-items: center;
  font-size: 64px;
  margin-bottom: 14px;
}
.pd-name { font-size: 18px; font-weight: 800; margin: 0 0 4px; }
.pd-meta { color: var(--ink-soft); font-size: 13px; margin: 0 0 12px; }
.pd-price { font-size: 24px; font-weight: 900; margin: 8px 0; }
.pd-seller {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface-2); border-radius: 12px; padding: 12px; margin: 12px 0;
  font-size: 13px;
}
.pd-compat-list { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.pd-compat-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; padding: 8px 10px; background: var(--surface-2); border-radius: 10px;
}
.qty {
  display: flex; align-items: center; gap: 14px; justify-content: center;
  margin: 10px 0;
}
.qty button {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); font-size: 20px; cursor: pointer;
}
.qty span { font-size: 18px; font-weight: 700; min-width: 28px; text-align: center; }

/* Carrinho */
.cart-item {
  display: flex; gap: 12px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px;
}
.cart-item .part-thumb { width: 52px; height: 52px; font-size: 24px; }
.cart-qty { display: flex; align-items: center; gap: 8px; }
.cart-qty button {
  width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-size: 16px;
}
.cart-summary {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.cart-line { display: flex; justify-content: space-between; font-size: 14px; }
.cart-line.total { font-size: 18px; font-weight: 800; border-top: 1px solid var(--line); padding-top: 10px; }

/* Perfil */
.profile-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px;
}
.profile-card h3 { margin: 0 0 4px; }
.seg {
  display: flex; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px;
}
.seg button {
  flex: 1; border: none; background: transparent; padding: 10px; border-radius: 9px;
  font-size: 13px; font-weight: 700; color: var(--ink-soft); cursor: pointer;
}
.seg button.on { background: var(--brand); color: #fff; }

/* Toast */
.toast {
  position: fixed;
  bottom: calc(86px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: #1f2c3b;
  color: #fff;
  border: 1px solid var(--line);
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  z-index: 60;
  box-shadow: var(--shadow);
  animation: fadeUp 0.2s ease;
}
@keyframes fadeUp { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }
