/* ==========================================================
   Reset e tokens
   ========================================================== */
:root {
  /* paleta */
  --primary: #ff6b00;
  --primary-hover: #e85d00;
  --bg: #ffffff;
  --bg-soft: #f4f5f7;
  --bg-softer: #fafafa;
  --text: #1a1d23;
  --text-soft: #5a6270;
  --text-muted: #8a909a;
  --border: #e3e6eb;
  --border-strong: #cdd2da;
  --success: #16a34a;
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.12);
  --shadow-elev: 0 4px 16px rgba(0, 0, 0, 0.08);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: "Quicksand", system-ui, -apple-system, sans-serif;
  font-weight: 400;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select { font-family: inherit; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ==========================================================
   Mapa em tela cheia
   ========================================================== */
#map {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* ==========================================================
   Card flutuante
   ========================================================== */
.card-calculo {
  position: fixed;
  top: 24px;
  left: 24px;
  width: 380px;
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 48px);
  background: var(--bg);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  z-index: 10;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ==========================================================
   Branding (header)
   ========================================================== */
.card-calculo__header {
  padding: 20px 24px 12px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand__logo {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.brand__textos {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.brand__nome {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

.brand__sub {
  font-size: 12px;
  color: var(--text-muted);
}

/* ==========================================================
   Form
   ========================================================== */
.form-calculo {
  padding: 16px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

/* ==========================================================
   Scrollbar minimalista, consistente entre navegadores
   (track invisível + thumb cinza sutil + setinhas escondidas)
   Cobertura tripla:
   - propriedades padrão (Firefox + Chrome 121+) aplicadas em
     html/body/*;
   - pseudo-elementos ::-webkit-scrollbar* aplicados a todos os
     containers conhecidos (Chrome legacy / WebKit);
   - regras com !important para vencer o cascade do GTK/UA.
   ========================================================== */
html,
body,
* {
  scrollbar-width: thin !important;
  scrollbar-color: rgba(0, 0, 0, 0.2) transparent !important;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar,
div::-webkit-scrollbar,
section::-webkit-scrollbar,
aside::-webkit-scrollbar,
ul::-webkit-scrollbar,
ol::-webkit-scrollbar,
form::-webkit-scrollbar,
fieldset::-webkit-scrollbar,
input::-webkit-scrollbar,
textarea::-webkit-scrollbar,
*::-webkit-scrollbar {
  width: 4px !important;
  height: 4px !important;
  background: transparent !important;
}

html::-webkit-scrollbar-track,
body::-webkit-scrollbar-track,
div::-webkit-scrollbar-track,
section::-webkit-scrollbar-track,
aside::-webkit-scrollbar-track,
ul::-webkit-scrollbar-track,
ol::-webkit-scrollbar-track,
form::-webkit-scrollbar-track,
fieldset::-webkit-scrollbar-track,
input::-webkit-scrollbar-track,
textarea::-webkit-scrollbar-track,
*::-webkit-scrollbar-track {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

html::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb,
div::-webkit-scrollbar-thumb,
section::-webkit-scrollbar-thumb,
aside::-webkit-scrollbar-thumb,
ul::-webkit-scrollbar-thumb,
ol::-webkit-scrollbar-thumb,
form::-webkit-scrollbar-thumb,
fieldset::-webkit-scrollbar-thumb,
input::-webkit-scrollbar-thumb,
textarea::-webkit-scrollbar-thumb,
*::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.18) !important;
  border-radius: 999px !important;
  border: none !important;
}

html::-webkit-scrollbar-thumb:hover,
body::-webkit-scrollbar-thumb:hover,
div::-webkit-scrollbar-thumb:hover,
section::-webkit-scrollbar-thumb:hover,
aside::-webkit-scrollbar-thumb:hover,
ul::-webkit-scrollbar-thumb:hover,
ol::-webkit-scrollbar-thumb:hover,
form::-webkit-scrollbar-thumb:hover,
fieldset::-webkit-scrollbar-thumb:hover,
input::-webkit-scrollbar-thumb:hover,
textarea::-webkit-scrollbar-thumb:hover,
*::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.32) !important;
}

html::-webkit-scrollbar-corner,
body::-webkit-scrollbar-corner,
*::-webkit-scrollbar-corner {
  background: transparent !important;
}

/* Setinhas de avanço/retorno: escondidas em todos os sub-estados,
   listadas por tag explícita para evitar quirks do `*` em algumas
   versões do Chromium. */
html::-webkit-scrollbar-button,
body::-webkit-scrollbar-button,
div::-webkit-scrollbar-button,
section::-webkit-scrollbar-button,
aside::-webkit-scrollbar-button,
ul::-webkit-scrollbar-button,
ol::-webkit-scrollbar-button,
form::-webkit-scrollbar-button,
fieldset::-webkit-scrollbar-button,
input::-webkit-scrollbar-button,
textarea::-webkit-scrollbar-button,
*::-webkit-scrollbar-button,
*::-webkit-scrollbar-button:start,
*::-webkit-scrollbar-button:end,
*::-webkit-scrollbar-button:vertical,
*::-webkit-scrollbar-button:vertical:start,
*::-webkit-scrollbar-button:vertical:end,
*::-webkit-scrollbar-button:vertical:start:decrement,
*::-webkit-scrollbar-button:vertical:end:increment,
*::-webkit-scrollbar-button:vertical:start:increment,
*::-webkit-scrollbar-button:vertical:end:decrement,
*::-webkit-scrollbar-button:horizontal,
*::-webkit-scrollbar-button:horizontal:start,
*::-webkit-scrollbar-button:horizontal:end,
*::-webkit-scrollbar-button:single-button,
*::-webkit-scrollbar-button:double-button,
*::-webkit-scrollbar-button:no-button,
*::-webkit-scrollbar-button:start:decrement,
*::-webkit-scrollbar-button:end:increment {
  display: none !important;
  visibility: hidden !important;
  width: 0 !important;
  height: 0 !important;
  min-width: 0 !important;
  min-height: 0 !important;
  max-width: 0 !important;
  max-height: 0 !important;
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
  border: 0 !important;
  -webkit-appearance: none !important;
  appearance: none !important;
}

/* ==========================================================
   Inputs origem/destino
   ========================================================== */
.campos-rota {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.campo-rota {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
}

.campo-rota__bullet {
  flex-shrink: 0;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--text);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.campo-rota--origem .campo-rota__bullet {
  border-color: var(--success);
  color: var(--success);
}

.campo-rota--destino .campo-rota__bullet {
  border-color: var(--primary);
  color: var(--primary);
}

.campo-rota--parada .campo-rota__bullet {
  border-color: var(--text-soft);
  color: var(--text-soft);
}

.campo-rota:not(:last-of-type)::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 28px;
  bottom: -12px;
  width: 2px;
  background: repeating-linear-gradient(
    to bottom,
    var(--border-strong) 0 3px,
    transparent 3px 6px
  );
  z-index: 1;
}

.campo-rota__input-wrap { flex: 1; position: relative; }

.campo-rota__input {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.campo-rota__input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 107, 0, 0.15);
}

.campo-rota__input::placeholder { color: var(--text-muted); }

.campo-rota__action {
  flex-shrink: 0;
  width: 24px; height: 24px;
  font-size: 18px;
  color: var(--text-muted);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  visibility: hidden;
  transition: background 0.15s;
}

.campo-rota:hover .campo-rota__action,
.campo-rota__input:not(:placeholder-shown) ~ .campo-rota__action {
  visibility: visible;
}

.campo-rota__action:hover { background: var(--bg-soft); color: var(--text); }

/* ==========================================================
   Autocomplete
   ========================================================== */
.autocomplete-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-elev);
  list-style: none;
  max-height: 240px;
  overflow-y: auto;
  z-index: 20;
  display: none;
}

.autocomplete-list.aberto { display: block; }

.autocomplete-list li {
  padding: 10px 12px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

.autocomplete-list li:last-child { border-bottom: none; }
.autocomplete-list li:hover, .autocomplete-list li.ativo { background: var(--bg-soft); }
.autocomplete-list .ac-titulo { font-weight: 500; color: var(--text); }
.autocomplete-list .ac-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ==========================================================
   Botão de adicionar parada
   ========================================================== */
.btn-add-parada {
  align-self: flex-start;
  margin-left: 36px;
  margin-top: 4px;
  padding: 6px 10px;
  font-size: 13px;
  color: var(--text-soft);
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-add-parada:hover { background: var(--bg-soft); color: var(--primary); }
.btn-add-parada:disabled {
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.55;
}

.btn-add-parada:disabled:hover {
  background: transparent;
  color: var(--text-muted);
}

.btn-add-parada span { font-size: 16px; font-weight: 600; }

/* ==========================================================
   Ida e volta
   ========================================================== */
.ida-volta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-soft);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  cursor: pointer;
}

.ida-volta__texto {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.ida-volta__input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.ida-volta__switch {
  width: 42px;
  height: 24px;
  padding: 2px;
  border-radius: 999px;
  background: var(--border-strong);
  transition: background 0.18s ease;
  flex-shrink: 0;
}

.ida-volta__thumb {
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg);
  box-shadow: var(--shadow-elev);
  transition: transform 0.18s ease;
}

.ida-volta__input:checked + .ida-volta__switch,
.ida-volta__input[aria-checked="true"] + .ida-volta__switch {
  background: var(--primary);
}

.ida-volta__input:checked + .ida-volta__switch .ida-volta__thumb,
.ida-volta__input[aria-checked="true"] + .ida-volta__switch .ida-volta__thumb {
  transform: translateX(18px);
}

.ida-volta:focus-within {
  outline: 2px solid rgba(255, 107, 0, 0.24);
  outline-offset: 2px;
}

/* ==========================================================
   Tipo de rota (chips: Eficiente / Mais curta / Sem pedágio)
   ========================================================== */
.tipo-rota {
  border: none;
  background: var(--bg-soft);
  border-radius: var(--radius-md);
  padding: 4px;
}

.tipo-rota__opcoes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.tipo-rota__btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 6px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-soft);
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  text-align: center;
  min-width: 0;
}

.tipo-rota__btn:hover:not(:disabled):not(.ativo) {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text);
}

.tipo-rota__btn.ativo {
  background: var(--bg);
  color: var(--primary);
  box-shadow: var(--shadow-elev);
}

.tipo-rota__btn:disabled,
.tipo-rota__btn--desabilitado {
  opacity: 0.45;
  cursor: not-allowed;
}

.tipo-rota__titulo {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.tipo-rota__sub {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.tipo-rota__btn.ativo .tipo-rota__sub {
  color: var(--primary);
  opacity: 0.85;
}

/* ==========================================================
   Veículo (estilo Qualp: ícones + chevron eixos na mesma linha)
   ========================================================== */
.veiculo {
  border: none;
  background: var(--bg-soft);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}

.veiculo__linha {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}

.veiculo__opcoes {
  display: flex;
  gap: 4px;
}

.veiculo__btn {
  width: 40px; height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: transparent;
  transition: all 0.15s;
  position: relative;
  filter: grayscale(1) opacity(0.45);
}

.veiculo__btn img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  pointer-events: none;
}

.veiculo__btn:hover {
  background: rgba(0, 0, 0, 0.04);
  filter: grayscale(0.5) opacity(0.75);
}

.veiculo__btn.ativo {
  background: rgba(255, 107, 0, 0.12);
  filter: none;
}

.veiculo__btn.ativo::after {
  content: "";
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 2px;
  background: var(--primary);
  border-radius: 2px;
}

/* Eixos inline (chevrons + valor) */
.eixos-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 8px;
}

.eixos-inline.oculto {
  visibility: hidden;
}

.eixos-inline__btn {
  width: 22px; height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text-soft);
  transition: all 0.15s;
}

.eixos-inline__btn svg {
  width: 18px;
  height: 18px;
}

.eixos-inline__btn:hover:not(:disabled) {
  background: var(--bg-soft);
  color: var(--primary);
}

.eixos-inline__btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.eixos-inline__valor {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  min-width: 56px;
  text-align: center;
}

/* ==========================================================
   Combustível (consumo + preço lado a lado)
   ========================================================== */
.combustivel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.combustivel__campo {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.combustivel__label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.combustivel__input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg-soft);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 8px 10px;
  transition: all 0.15s;
}

.combustivel__input-wrap:focus-within {
  background: var(--bg);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 107, 0, 0.15);
}

.combustivel__input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  width: 100%;
  outline: none;
  /* -moz-appearance: textfield; */
}

.combustivel__input::-webkit-outer-spin-button,
.combustivel__input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.combustivel__unidade {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  margin-left: 6px;
}

/* ==========================================================
   Botão calcular
   ========================================================== */
.btn-calcular {
  width: 100%;
  padding: 14px;
  background: var(--primary);
  color: white;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-md);
  transition: background 0.15s, transform 0.05s;
}

.btn-calcular:hover:not(:disabled) { background: var(--primary-hover); }
.btn-calcular:active:not(:disabled) { transform: translateY(1px); }
.btn-calcular:disabled { background: var(--border-strong); color: var(--text-muted); cursor: not-allowed; }

/* ==========================================================
   Resultado
   ========================================================== */
.resultado {
  padding: 0 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.resultado[hidden] { display: none; }

.resultado__cabecalho {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  margin: 16px 0 12px;
}

.resultado__eyebrow {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
}

.resultado__escopo {
  align-self: flex-end;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.resultado__total-card {
  position: relative;
  width: 100%;
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: white;
  padding: 18px 18px 22px;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.resultado__total-info {
  display: flex;
  flex-direction: column;
}

.resultado__total-label {
  font-size: 12px;
  opacity: 0.9;
  letter-spacing: 0.05em;
  font-weight: 500;
}

.resultado__total-valor {
  font-size: 28px;
  font-weight: 700;
}

.resultado__total-meta {
  display: flex;
  gap: 14px;
  font-size: 13px;
  opacity: 0.9;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.resultado__total-aviso {
  position: absolute;
  right: 12px;
  bottom: 8px;
  font-size: 10px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
  letter-spacing: 0.02em;
  cursor: help;
  user-select: none;
}

/* Breakdown (linhas colapsáveis) */
.breakdown {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.breakdown__item {
  width: 100%;
  background: var(--bg-soft);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.breakdown__header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: transparent;
  text-align: left;
  transition: background 0.15s;
}

.breakdown__item--colapsavel .breakdown__header { cursor: pointer; }
.breakdown__item--colapsavel .breakdown__header:hover { background: rgba(0, 0, 0, 0.03); }

.breakdown__header--estatico { cursor: default; }

.breakdown__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  text-align: center;
}

.breakdown__icon img {
  display: block;
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.breakdown__main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.breakdown__label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.breakdown__count {
  font-size: 11px;
  color: var(--text-muted);
}

.breakdown__valor {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.breakdown__chevron {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.breakdown__header[aria-expanded="true"] .breakdown__chevron {
  transform: rotate(180deg);
}

.breakdown__lista {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border);
  max-height: 288px;
  overflow-y: auto;
}

.breakdown__lista[hidden] { display: none; }

.breakdown__lista li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg-softer);
  font-size: 12px;
  gap: 8px;
}

.breakdown__lista li > div {
  flex: 1;
  min-width: 0;
}

.breakdown__lista li strong {
  display: block;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.breakdown__lista li small {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.breakdown__lista li .valor {
  color: var(--primary);
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
}

.breakdown__lista .vazio {
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  padding: 16px;
  background: var(--bg-softer);
}

.btn-voltar {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--text-soft);
  transition: all 0.15s;
}

.btn-voltar:hover { border-color: var(--text-soft); color: var(--text); }

/* ==========================================================
   Loading
   ========================================================== */
.loading {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 100;
}

.loading[hidden] { display: none; }

.loading__spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading p { font-size: 14px; color: var(--text-soft); }

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

/* ==========================================================
   Modal
   ========================================================== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal[hidden] { display: none; }

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.18);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.modal__conteudo {
  position: relative;
  background: var(--bg);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 400px;
  width: 100%;
  box-shadow: var(--shadow-card);
  text-align: center;
}

.modal__brand {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}

.modal__brand img {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
}

.modal__conteudo h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
}

.modal__desc {
  font-size: 13px;
  color: var(--text-soft);
  margin-bottom: 20px;
}

.form-lead {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
}

.form-lead__campo {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-lead__campo span {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}

.form-lead__campo input {
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-lead__campo input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 107, 0, 0.15);
}

/* Tamanho da frota — checkboxes em forma de cartões */
.form-lead__frota {
  border: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-lead__frota legend {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  padding: 0;
  margin-bottom: 2px;
}

.form-lead__frota-opcoes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 1%;
}

.form-lead__check {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 8px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--text-soft);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, box-shadow 0.15s;
  user-select: none;
  text-align: center;
}

/* Checkbox nativo escondido — o chip é o próprio controle.
   Permanece no DOM para receber foco via teclado e ser lido por leitores de tela. */
.form-lead__check input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  margin: 0;
}

.form-lead__check:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.form-lead__check:has(input:checked) {
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

.form-lead__check:has(input:checked):hover {
  border-color: var(--primary);
}

.form-lead__check:focus-within {
  box-shadow: 0 0 0 3px rgba(255, 107, 0, 0.15);
}

.form-lead button[type="submit"] { margin-top: 4px; }

/* ==========================================================
   Popup (balão) — segue o design system do card
   ========================================================== */
.mapboxgl-popup {
  font-family: "Quicksand", system-ui, -apple-system, sans-serif;
  z-index: 30;
}

.mapboxgl-popup-content {
  padding: 0 !important;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.mapboxgl-popup-anchor-top .mapboxgl-popup-tip,
.mapboxgl-popup-anchor-top-left .mapboxgl-popup-tip,
.mapboxgl-popup-anchor-top-right .mapboxgl-popup-tip {
  border-bottom-color: var(--bg);
}

.mapboxgl-popup-anchor-bottom .mapboxgl-popup-tip,
.mapboxgl-popup-anchor-bottom-left .mapboxgl-popup-tip,
.mapboxgl-popup-anchor-bottom-right .mapboxgl-popup-tip {
  border-top-color: var(--bg);
}

.mapboxgl-popup-anchor-left .mapboxgl-popup-tip {
  border-right-color: var(--bg);
}

.mapboxgl-popup-anchor-right .mapboxgl-popup-tip {
  border-left-color: var(--bg);
}

/* Popup de praça de pedágio */
.popup-praca {
  width: 244px;
  display: flex;
  flex-direction: column;
}

.popup-praca__header {
  padding: 12px 14px 10px;
  background: linear-gradient(135deg, rgba(255, 107, 0, 0.08), rgba(255, 107, 0, 0.02));
  border-bottom: 1px solid var(--border);
}

.popup-praca__eyebrow {
  display: block;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
  font-weight: 700;
  margin-bottom: 3px;
}

.popup-praca__nome {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.popup-praca__meta {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.popup-praca__linha {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.popup-praca__rotulo {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.popup-praca__valor {
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
  line-height: 1.35;
  word-break: break-word;
}

.popup-praca__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg-soft);
  border-top: 1px solid var(--border);
  gap: 12px;
}

.popup-praca__footer .popup-praca__rotulo {
  color: var(--text-soft);
}

.popup-praca__tarifa {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
}

/* Popup de origem/destino */
.popup-ponto {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  min-width: 160px;
  max-width: 220px;
}

.popup-ponto__eyebrow {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--text-muted);
}

.popup-ponto--origem .popup-ponto__eyebrow { color: var(--success); }
.popup-ponto--destino .popup-ponto__eyebrow { color: var(--primary); }

.popup-ponto__nome {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}

/* ==========================================================
   Marker do mapa
   ========================================================== */
.marker-praca {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--primary);
  border: 3px solid white;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  cursor: pointer;
}

.marker-origem, .marker-destino, .marker-parada {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 3px solid white;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: white;
}

.marker-origem { background: var(--success); }
.marker-destino { background: var(--primary); }
.marker-parada { background: var(--text-soft); }

/* ==========================================================
   Bottom-sheet handle (desktop: oculto; mobile: revelado via JS)
   ========================================================== */
.card-calculo__handle {
  display: none;
  flex-shrink: 0;
  width: 100%;
  padding: 10px 0 6px;
  justify-content: center;
  align-items: center;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  background: transparent;
}

.card-calculo__handle:active { cursor: grabbing; }

.card-calculo__handle-bar {
  display: block;
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: var(--border-strong);
  transition: background 0.15s, width 0.15s;
}

.card-calculo__handle:active .card-calculo__handle-bar,
.card-calculo--dragging .card-calculo__handle-bar {
  background: var(--text-soft);
  width: 56px;
}

/* ==========================================================
   Responsivo — tablet/mobile (bottom-sheet com snap-points)
   ========================================================== */
@media (max-width: 768px) {
  html, body { height: 100dvh; }
  #map { height: 100dvh; }

  /* Inputs com 16px para evitar zoom automático no iOS */
  .campo-rota__input,
  .combustivel__input,
  .form-lead__campo input,
  .form-lead__campo textarea {
    font-size: 16px;
  }

  /* Card vira bottom-sheet */
  .card-calculo {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: none;
    max-height: 95dvh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.18);
  }

  /* Mostra handle só quando JS aplicou modo sheet */
  .card-calculo--sheet .card-calculo__handle { display: flex; }

  /* Estados de snap controlados via JS */
  .card-calculo--sheet {
    height: 55dvh;
    transition: height 0.28s cubic-bezier(0.32, 0.72, 0, 1);
    will-change: height;
  }
  .card-calculo--sheet.snap-peek { height: 76px; }
  /* Em peek mostramos só o handle + linha da logo; remove o traço inferior do header */
  .card-calculo--sheet.snap-peek .card-calculo__header { border-bottom: none; }
  .card-calculo--sheet.snap-mid  { height: 55dvh; }
  .card-calculo--sheet.snap-full { height: 92dvh; }
  .card-calculo--dragging { transition: none !important; }

  /* Header mais compacto */
  .card-calculo__header {
    padding: 0 20px 12px;
    border-bottom: 1px solid var(--border);
  }
  .brand__logo { width: 36px; height: 36px; }
  .brand__nome { font-size: 16px; }
  .brand__sub { font-size: 11px; }

  /* Form respira melhor e respeita safe-area */
  .form-calculo {
    padding: 14px 16px 24px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
    gap: 14px;
  }

  /* Inputs maiores e touch targets ≥36px */
  .campo-rota__input { padding: 12px 14px; }
  /* No mobile o X é sempre visível: hover não existe em touch,
     e o seletor de irmão do desktop não bate por causa do .campo-rota__input-wrap */
  .campo-rota__action {
    width: 36px;
    height: 36px;
    visibility: visible;
    opacity: 1;
    color: var(--text-soft);
    background: var(--bg-soft);
  }
  .campo-rota__action:active { background: var(--border); color: var(--text); }

  /* Eixos: alvos maiores */
  .eixos-inline { padding: 4px 10px; }
  .eixos-inline__btn { width: 32px; height: 32px; }
  .eixos-inline__btn svg { width: 22px; height: 22px; }

  /* Veículo: ícones maiores */
  .veiculo { padding: 10px 14px; }
  .veiculo__btn { width: 44px; height: 44px; }
  .veiculo__btn img { width: 30px; height: 30px; }

  /* Botão calcular maior */
  .btn-calcular { padding: 16px; font-size: 16px; }

  /* Autocomplete adaptado */
  .autocomplete-list { max-height: 220px; }
  .autocomplete-list li { padding: 12px 14px; font-size: 14px; }

  /* Resultado com respiração + safe-area */
  .resultado {
    padding: 0 16px 24px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
  }
  .resultado__total-valor { font-size: 26px; }

  /* Lista de praças usa toda a altura disponível */
  .breakdown__lista { max-height: none; }

  /* Modal de lead em tela cheia */
  .modal { padding: 0; align-items: stretch; justify-content: stretch; }
  .modal__conteudo {
    max-width: none;
    width: 100%;
    height: 100dvh;
    border-radius: 0;
    padding: 32px 20px;
    padding-top: calc(32px + env(safe-area-inset-top));
    padding-bottom: calc(32px + env(safe-area-inset-bottom));
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  .modal__conteudo h2 { font-size: 22px; }
}

@media (max-width: 480px) {
  /* Combustível empilhado em telas estreitas */
  .combustivel { grid-template-columns: 1fr; }

  /* Veículo + eixos: mantém na mesma linha (igual desktop), só comprime */
  .veiculo { padding: 8px 10px; }
  .veiculo__linha { gap: 8px; }
  .veiculo__opcoes { gap: 2px; }
  .veiculo__btn { width: 38px; height: 38px; }
  .veiculo__btn img { width: 26px; height: 26px; }
  .eixos-inline { padding: 3px 8px; gap: 4px; }
  .eixos-inline__btn { width: 28px; height: 28px; }
  .eixos-inline__btn svg { width: 18px; height: 18px; }
  .eixos-inline__valor { font-size: 12px; min-width: 48px; }

  /* Tipo de rota: textos menores */
  .tipo-rota__titulo { font-size: 11px; }
  .tipo-rota__sub { font-size: 9px; }

  /* Frota: 3 colunas mais apertadas */
  .form-lead__frota-opcoes { gap: 6px; }
  .form-lead__check { padding: 12px 4px; font-size: 12px; }
}

/* ==========================================================
   Toast (feedback discreto de envio em background)
   ========================================================== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%) translateY(8px);
  z-index: 250;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: rgba(26, 29, 35, 0.92);
  color: #fff;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast:not([hidden]) {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast[hidden] { display: none; }

.toast__spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.toast--sucesso { background: rgba(34, 132, 73, 0.95); }
.toast--sucesso .toast__spinner { display: none; }

.toast--erro { background: rgba(180, 50, 50, 0.95); }
.toast--erro .toast__spinner { display: none; }

/* Em dispositivos sem hover (touch), não dependa de :hover */
@media (hover: none) {
  .tipo-rota__btn:hover:not(:disabled):not(.ativo) { background: transparent; color: var(--text-soft); }
  .breakdown__item--colapsavel .breakdown__header:hover { background: transparent; }
  .veiculo__btn:hover { background: transparent; filter: grayscale(1) opacity(0.45); }
  .veiculo__btn.ativo:hover { background: rgba(255, 107, 0, 0.12); filter: none; }
  .btn-add-parada:hover { background: transparent; color: var(--text-soft); }
}

/* ==========================================================
   Frete mínimo (ANTT) — estados: pedágio | formulário | consolidado
   ========================================================== */
/* Garante que [hidden] esconda mesmo com display: definido na classe
   (mesmo padrão de .resultado[hidden], .modal[hidden] etc.). */
.frete-form,
.frete-consolidado { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.frete-form[hidden],
.frete-consolidado[hidden],
.frete-result[hidden] { display: none; }


/* Linha tipo de carga (principal) + eixos (somente leitura, da pesquisa) */
.frete-form__linha { display: flex; gap: 10px; align-items: flex-end; }
.frete-campo--principal { flex: 1; min-width: 0; }
.frete-campo--eixos { width: 78px; flex-shrink: 0; }
.frete-eixos {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

/* Lista colapsável de origem/destino/distância no consolidado */
.frete-trajeto__lista { padding: 2px 14px 8px; }

.frete-campo { display: flex; flex-direction: column; gap: 6px; }
.frete-campo__label { font-size: 12px; font-weight: 600; color: var(--text-muted); }

/* Select no mesmo padrão dos campos do sistema (.campo-rota__input) + chevron */
.frete-select {
  width: 100%;
  padding: 10px 32px 10px 12px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background-color: var(--bg);
  color: var(--text);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%238a909a'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.frete-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 107, 0, 0.15);
}

/* Lista aberta do select (options) no padrão do sistema */
.frete-select option {
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  background: var(--bg);
  padding: 8px 12px;
}

.frete-seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: var(--bg-soft);
  border-radius: var(--radius-md);
  padding: 4px;
}
.frete-seg__btn {
  padding: 9px 6px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.frete-seg__btn.is-ativa {
  background: var(--bg);
  color: var(--primary);
  box-shadow: var(--shadow-elev);
}

.frete-switch { cursor: pointer; }

.frete-form__erro {
  font-size: 13px;
  font-weight: 600;
  color: #b91c1c;
  background: #fef2f2;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}


.frete-result { list-style: none; display: flex; flex-direction: column; }
.frete-result__grupo {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 0 2px;
  padding: 9px 12px;
  background: var(--bg-soft);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
}
.frete-result__grupo img { width: 18px; height: 18px; object-fit: contain; flex-shrink: 0; }
.frete-result__linha {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 2px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-soft);
}
.frete-result__linha strong { color: var(--text); font-weight: 700; text-align: right; }
.frete-result__linha--destaque strong { color: var(--primary); }
.frete-result__linha--total {
  border-bottom: none;
  margin-top: 4px;
  padding-top: 12px;
  font-size: 15px;
}
.frete-result__linha--total span { font-weight: 700; color: var(--text); }
.frete-result__linha--total strong { color: var(--primary); font-size: 18px; }
.frete-result__fonte {
  padding: 10px 2px 0;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-muted);
}
.frete-badge {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #fff7ed;
  color: #b45309;
  font-weight: 700;
  font-size: 10px;
}


/* Ícone de ajuda (tooltip) ao lado de CCD / CC */
.frete-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  margin-left: 5px;
  border-radius: 50%;
  background: var(--border-strong);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  font-style: normal;
  line-height: 1;
  cursor: help;
  position: relative;
  vertical-align: middle;
}
.frete-info::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 210px;
  max-width: 60vw;
  background: var(--text);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s;
  z-index: 6;
  box-shadow: var(--shadow-elev);
  pointer-events: none;
}
.frete-info:hover::after,
.frete-info:focus::after { opacity: 1; visibility: visible; }

