/* ======================
   RESET & VARIÁVEIS (mesma identidade do comparador)
====================== */
* {
  box-sizing: border-box;
}

:root {
  --primary: #30325e;
  --primary-dark: #1e2047;
  --primary-light: #6668a0;
  --accent: #c9a227;
  --accent-soft: rgba(201, 162, 39, 0.12);
  --primary-soft: rgba(48, 50, 94, 0.08);
  --success: #10b981;
  --danger: #ef4444;
  --bg-page: #f7f7fb;
  --card-bg: #ffffff;
  --text: #1a1b2e;
  --text-muted: #666a8c;
  --border: #e4e4f0;
  --radius: 16px;
  --shadow-sm: 0 4px 12px rgba(26, 27, 46, 0.04);
  --shadow-md: 0 10px 25px rgba(26, 27, 46, 0.09);
  --shadow-lg: 0 20px 40px rgba(26, 27, 46, 0.14);
}

body {
  margin: 0;
  font-family: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
  background-color: var(--bg-page);
  color: var(--text);
  padding-bottom: 40px;
  min-height: 100vh;
}

.bg-decor {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 10% 0%, rgba(48, 50, 94, 0.10), transparent 40%),
    radial-gradient(circle at 90% 10%, rgba(201, 162, 39, 0.08), transparent 40%),
    var(--bg-page);
}

.page-shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ======================
   HEADER
====================== */
.page-header {
  text-align: center;
  padding: 26px 0 18px;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  object-fit: contain;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
  background: #fff;
  padding: 5px;
}

.badge-live {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 5px 14px;
  border-radius: 999px;
  border: 1px solid rgba(48, 50, 94, 0.15);
  margin-bottom: 10px;
}

.badge-live::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.25);
}

.titulo {
  font-weight: 800;
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitulo {
  color: var(--text-muted);
  margin: 6px auto 0;
  max-width: 480px;
  font-size: 0.88rem;
  line-height: 1.5;
}

/* ======================
   LAYOUT (form + resultado)
====================== */
.layout {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}

/* ======================
   CARD DO FORMULÁRIO
====================== */
.card {
  position: relative;
  overflow: hidden;
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  transition: all 0.25s ease;
  border: 1px solid var(--border);
  flex: 1;
  min-width: 280px;
}

.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.card:hover {
  box-shadow: var(--shadow-md);
  border-color: rgba(48, 50, 94, 0.25);
}

.card-header {
  display: flex;
  align-items: center;
  border-bottom: 2px solid #f1f5f9;
  padding-bottom: 10px;
  margin-bottom: 12px;
}

.card-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  font-size: 0.82rem;
}

.form-group {
  margin-bottom: 10px;
}

label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  display: block;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

select {
  width: 100%;
  padding: 9px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background-color: #f8fafc;
  font-size: 0.88rem;
  font-family: inherit;
  color: var(--text);
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23666a8c'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 10.94l3.71-3.71a.75.75 0 111.06 1.06l-4.24 4.24a.75.75 0 01-1.06 0L5.21 8.29a.75.75 0 01.02-1.08z' clip-rule='evenodd'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  transition: all 0.2s ease;
}

select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(48, 50, 94, 0.12);
  background-color: #fff;
}

select:disabled {
  background-color: #f1f5f9;
  color: #94a3b8;
  cursor: not-allowed;
  opacity: 0.7;
}

/* Botão Consultar */
#search {
  width: 100%;
  margin-top: 6px;
  padding: 12px;
  border: none;
  border-radius: 10px;
  font-size: 0.94rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 6px 16px rgba(48, 50, 94, 0.25);
  transition: all 0.2s ease;
}

#search:hover:not(:disabled) {
  filter: brightness(1.06);
  box-shadow: 0 8px 22px rgba(48, 50, 94, 0.32);
  transform: translateY(-2px);
}

#search:disabled {
  background: #e2e8f0;
  color: #a0aec0;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* ======================
   CARD DE RESULTADO
====================== */
.relatorio-card {
  position: relative;
  overflow: hidden;
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  animation: aparecer 0.4s ease-out both;
  flex: 2;
  min-width: 300px;
}

.relatorio-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

@keyframes aparecer {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

.relatorio-header {
  text-align: center;
  margin-bottom: 16px;
}
.relatorio-header h3 { margin: 0; font-size: 1.15rem; font-weight: 800; }
.relatorio-header p { margin: 4px 0 0; color: var(--text-muted); font-size: 0.82rem; }

.veiculo-result {
  background: #f8fafc;
  border-radius: 14px;
  padding: 18px;
  border: 1px solid var(--border);
  text-align: center;
}

.tag-id {
  background: var(--primary-soft);
  color: var(--primary);
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.modelo-titulo {
  font-size: 1rem;
  color: var(--text);
  font-weight: 700;
  margin: 0 0 12px 0;
  line-height: 1.35;
}

.detalhes-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 14px;
  background: #fff;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.detalhe-item span { display: block; font-size: 0.68rem; color: var(--text-muted); font-weight: 600; }
.detalhe-item strong { display: block; font-size: 0.82rem; color: var(--text); font-weight: 700; }

.preco-display {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary-dark);
  background: #fff;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

/* Histórico / Gráfico */
.historico-box {
  margin-top: 16px;
  text-align: center;
}

.historico-label {
  display: block;
  margin-bottom: 6px;
  text-align: left;
}

#grafico {
  display: none;
  width: 100% !important;
  margin-top: 12px;
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 10px;
  box-shadow: var(--shadow-sm);
}

#sem_historico {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.86rem;
  margin-top: 12px;
}

/* Loading / Erro */
.loading-state {
  text-align: center;
  padding: 20px 10px;
}

.spinner-lg {
  display: inline-block;
  width: 30px;
  height: 30px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: girar 0.7s linear infinite;
  margin-bottom: 10px;
}

@keyframes girar {
  to { transform: rotate(360deg); }
}

.loading-state p {
  color: var(--text-muted);
  font-weight: 600;
  margin: 0;
}

.erro-msg {
  text-align: center;
  color: var(--danger);
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 12px;
  padding: 14px;
  font-weight: 600;
}

/* Botão Imprimir */
.btn-imprimir {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 20px;
  background-color: #ffffff;
  color: var(--text) !important;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 14px;
}

.btn-imprimir:hover {
  background-color: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-dark) !important;
}

/* ======================
   RESPONSIVO
====================== */
@media (min-width: 992px) {
  #form {
    position: sticky;
    top: 16px;
  }
}

@media (max-width: 991px) {
  .layout {
    flex-direction: column;
  }

  .card, .relatorio-card {
    min-width: 0;
    width: 100%;
  }

  .page-header { padding: 20px 0 14px; }
}

/* ======================
   IMPRESSÃO
====================== */
@media print {
  .bg-decor, .page-header, #form, .btn-imprimir, #historico, .historico-label {
    display: none !important;
  }

  body { background: #fff; padding: 0; }

  .layout { display: block; }

  .relatorio-card {
    box-shadow: none !important;
    border: 1px solid #ccc !important;
    margin: 0 !important;
    width: 100% !important;
  }

  .veiculo-result, .detalhes-grid, .preco-display {
    background: #fff !important;
    -webkit-print-color-adjust: exact;
  }

  /* O gráfico só sai na impressão se já estiver visível na tela
     (ou seja, se um ano foi selecionado no histórico) */
  #grafico {
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    background: #fff !important;
    page-break-inside: avoid;
  }
}