/* =========================================================================
   Consulta de Placas — interface web
   ========================================================================= */
:root {
  --bg: #f3f5fb;
  --bg-2: #e7ecf8;
  --surface: #ffffff;
  --surface-2: #f6f8fd;
  --border: #e2e7f2;
  --text: #0e1730;
  --muted: #5d6886;
  --primary: #1f4fd8;
  --primary-2: #3a6bff;
  --primary-ink: #ffffff;
  --accent: #ff7a1a;
  --success: #12a46b;
  --danger: #d93a3a;
  --danger-bg: #fff1f1;
  --plate-blue: #133a9c;
  --shadow-sm: 0 1px 2px rgba(14, 23, 48, .06);
  --shadow: 0 1px 2px rgba(14, 23, 48, .05), 0 12px 32px -12px rgba(14, 23, 48, .18);
  --radius: 20px;
  --radius-sm: 12px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "FE-Font", "DIN Condensed", "Arial Narrow", ui-sans-serif, system-ui, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #070d1c;
    --bg-2: #0d1730;
    --surface: #101a33;
    --surface-2: #142042;
    --border: #22305a;
    --text: #eaf0ff;
    --muted: #9aa8cc;
    --primary: #4b7bff;
    --primary-2: #6d93ff;
    --danger: #ff6b6b;
    --danger-bg: #2a1420;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 18px 40px -16px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 480px at 85% -10%, color-mix(in srgb, var(--primary) 22%, transparent), transparent 70%),
    radial-gradient(700px 420px at -10% 10%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 70%),
    linear-gradient(180deg, var(--bg-2), var(--bg) 420px);
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent); outline-offset: 2px; }

/* ---------- Topo ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1040px, 100%);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 20px 8px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -.01em;
}
.brand__mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 6px 16px -6px var(--primary);
}
.brand__name b { color: var(--primary); font-weight: 800; }

/* ---------- Layout ---------- */
.wrap {
  flex: 1;
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 12px 20px 40px;
}

/* ---------- Hero ---------- */
.hero { text-align: center; padding: 28px 0 8px; }
.hero__title {
  margin: 0;
  font-size: clamp(30px, 6.4vw, 48px);
  line-height: 1.05;
  letter-spacing: -.035em;
  font-weight: 800;
}
.hero__sub {
  max-width: 460px;
  margin: 14px auto 28px;
  color: var(--muted);
  font-size: clamp(15px, 2.6vw, 17px);
}
.is-compact .hero { padding-top: 8px; }
.is-compact .hero__title,
.is-compact .hero__sub { display: none; }

/* ---------- Busca / placa ---------- */
.search {
  display: grid;
  justify-items: center;
  gap: 14px;
}
.plate {
  display: block;
  width: min(440px, 100%);
  border-radius: 16px;
  padding: 6px;
  background: #fff;
  border: 2px solid #1b1f2a;
  box-shadow: var(--shadow), 0 0 0 6px color-mix(in srgb, var(--primary) 0%, transparent);
  transition: box-shadow .2s, transform .2s;
  cursor: text;
}
.plate:focus-within {
  box-shadow: var(--shadow), 0 0 0 6px color-mix(in srgb, var(--primary) 28%, transparent);
}
.plate.is-invalid {
  animation: shake .35s;
  box-shadow: var(--shadow), 0 0 0 6px color-mix(in srgb, var(--danger) 30%, transparent);
}
.plate__band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 30px;
  padding: 0 12px;
  border-radius: 10px 10px 4px 4px;
  background: linear-gradient(180deg, #1a48bd, var(--plate-blue));
  color: #fff;
}
.plate__merc { font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; opacity: .85; }
.plate__country { font-size: 14px; font-weight: 800; letter-spacing: .5em; margin-right: -.5em; }
.plate__flag { width: 26px; height: 18px; flex: none; }
.plate__body {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 2px;
}
.plate__br {
  font-weight: 800;
  font-size: 13px;
  color: #1b1f2a;
  padding: 2px 4px;
  border: 1.5px solid #1b1f2a;
  border-radius: 4px;
}
.plate__input {
  flex: 1;
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: #11151f;
  text-align: center;
  text-transform: uppercase;
  font-family: var(--mono);
  font-weight: 800;
  font-size: clamp(40px, 12vw, 64px);
  letter-spacing: .06em;
  line-height: 1.15;
  padding: 0;
}
.plate__input::placeholder { color: #c7ccd8; }
.search__help { margin: 0; font-size: 13px; color: var(--muted); }
.search__help.is-error { color: var(--danger); font-weight: 600; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 26px;
  border-radius: 14px;
  border: 0;
  font-weight: 700;
  font-size: 16px;
  transition: transform .12s, box-shadow .2s, background .2s, opacity .2s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn--primary {
  width: min(440px, 100%);
  color: var(--primary-ink);
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 10px 24px -10px var(--primary);
}
.btn--primary:hover { box-shadow: 0 14px 30px -10px var(--primary); }
.btn--primary:disabled { opacity: .6; cursor: progress; }
.btn--primary .btn__icon { transition: transform .2s; }
.btn--primary:hover .btn__icon { transform: translateX(3px); }
.btn--ghost {
  min-height: 44px;
  padding: 0 18px;
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, transparent);
}
.btn--ghost:hover { background: color-mix(in srgb, var(--primary) 16%, transparent); }
.link {
  border: 0;
  background: none;
  padding: 4px 6px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- Recentes ---------- */
.recent {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 22px;
}
.recent__label { font-size: 13px; color: var(--muted); }
.recent__list { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.recent__item {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .06em;
  box-shadow: var(--shadow-sm);
}
.recent__item:hover { border-color: var(--primary); color: var(--primary); }

/* ---------- Painéis ---------- */
.panel {
  margin-top: 24px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: rise .35s ease-out both;
}

/* Carregando */
.loading { text-align: center; }
.loading__plate {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 10px;
  border: 2px solid var(--text);
  font-family: var(--mono);
  font-weight: 800;
  font-size: 26px;
  letter-spacing: .08em;
}
.loading__bar {
  height: 6px;
  margin: 20px auto 18px;
  max-width: 360px;
  overflow: hidden;
  border-radius: 99px;
  background: var(--surface-2);
}
.loading__bar span {
  display: block;
  width: 40%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  animation: slide 1.4s ease-in-out infinite;
}
.steps {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  display: grid;
  gap: 10px;
  max-width: 300px;
  text-align: left;
}
.steps li {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 15px;
  transition: color .3s;
}
.steps li::before {
  content: "";
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border);
  transition: all .3s;
}
.steps li.is-active { color: var(--text); font-weight: 600; }
.steps li.is-active::before {
  border-color: var(--primary);
  border-right-color: transparent;
  animation: spin .8s linear infinite;
}
.steps li.is-done { color: var(--text); }
.steps li.is-done::before {
  border-color: var(--success);
  background: var(--success) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 12.5l4 4 8-9' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 12px no-repeat;
}
.loading__hint { margin: 18px 0 0; font-size: 13px; color: var(--muted); }

/* Erro */
.alert {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  background: var(--danger-bg);
  border-color: color-mix(in srgb, var(--danger) 30%, transparent);
}
.alert__icon { color: var(--danger); flex: none; margin-top: 2px; }
.alert__title { margin: 0 0 4px; font-size: 18px; }
.alert__text { margin: 0 0 14px; color: var(--muted); }

/* ---------- Resultado ---------- */
.vehicle__head { display: flex; gap: 16px; align-items: center; }
.avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 18px;
  font-size: 26px;
  font-weight: 800;
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--primary) 20%, transparent);
}
.vehicle__id { min-width: 0; }
.vehicle__brand {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--primary);
}
.vehicle__model {
  margin: 2px 0 0;
  font-size: clamp(26px, 6vw, 38px);
  line-height: 1.08;
  letter-spacing: -.03em;
  font-weight: 800;
  overflow-wrap: anywhere;
}
.vehicle__version { margin: 4px 0 0; color: var(--muted); }

.tags { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 20px; }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
}
.tag--plate {
  color: #fff;
  background: var(--plate-blue);
  border-color: transparent;
  letter-spacing: .08em;
}
.tag--color { color: var(--text); text-transform: capitalize; }
.swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--swatch, #9aa3b5);
  box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--text) 40%, transparent);
}

.facts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 0;
}
.fact {
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.fact dt {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.fact dt svg, .fipe__label svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.fact dd {
  margin: 6px 0 0;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -.01em;
  overflow-wrap: anywhere;
}

.fipe {
  position: relative;
  overflow: hidden;
  color: #fff;
  border: 0;
  background:
    radial-gradient(600px 220px at 110% -20%, rgba(255, 255, 255, .18), transparent 60%),
    linear-gradient(135deg, #0f2a78, #1f4fd8 60%, #3a6bff);
}
.fipe__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.fipe__label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  opacity: .9;
}
.fipe__value {
  margin: 10px 0 4px;
  font-size: clamp(38px, 10vw, 56px);
  line-height: 1;
  font-weight: 800;
  letter-spacing: -.035em;
}
.fipe__meta { margin: 0; font-size: 14px; opacity: .85; }
.fipe__meta b { font-weight: 700; }
.chip-btn {
  border: 1px solid rgba(255, 255, 255, .35);
  background: rgba(255, 255, 255, .12);
  color: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.chip-btn:hover { background: rgba(255, 255, 255, .22); }

.result__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
}
.result__time { margin: 0; font-size: 13px; color: var(--muted); }

/* ---------- Rodapé / toast ---------- */
.foot {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 16px 20px max(24px, env(safe-area-inset-bottom));
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}
.foot p { margin: 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow);
  animation: rise .25s ease-out both;
}

/* ---------- Animações ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes slide { 0% { transform: translateX(-110%); } 100% { transform: translateX(260%); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shake {
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}

/* ---------- Mobile ---------- */
@media (max-width: 560px) {
  .wrap { padding: 4px 14px 28px; }
  .hero { padding-top: 14px; }
  .panel { padding: 18px; border-radius: 18px; }
  .facts { grid-template-columns: 1fr 1fr; }
  .fact:last-child { grid-column: 1 / -1; }
  .avatar { width: 52px; height: 52px; font-size: 22px; border-radius: 15px; }
  .result__footer { flex-direction: column-reverse; align-items: stretch; text-align: center; }
  .result__footer .btn { width: 100%; }
  .plate__band { height: 26px; }
  .plate__country { font-size: 12px; letter-spacing: .4em; }
}
