/* Referência visual: placas de rodovia. Verde de sinalização, amarelo de faixa e asfalto. */
:root {
  --verde: #00573f;
  --verde-escuro: #003f2e;
  --verde-claro: #e3efea;
  --amarelo: #ffc20e;
  --asfalto: #23282b;
  --cinza: #5a6662;
  --linha: #cfd8d4;
  --fundo: #eef2f0;
  --papel: #fff;
  --erro: #a8201a;
  --raio: 10px;
  color-scheme: light;
}

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

body {
  margin: 0;
  background: var(--fundo);
  color: var(--asfalto);
  font: 400 1rem/1.5 'Overpass Variable', system-ui, sans-serif;
}

h1, h2, p, ul { margin: 0; }
h1, h2 { line-height: 1.2; text-wrap: balance; }
h2 { font-size: 1.15rem; font-weight: 750; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 3px solid var(--amarelo); outline-offset: 2px; box-shadow: 0 0 0 2px var(--asfalto); }

/* ---- Peças ---- */
.botao {
  min-height: 46px;
  padding: 0.5rem 1.25rem;
  border: 2px solid var(--verde);
  border-radius: var(--raio);
  background: var(--verde);
  color: #fff;
  font-weight: 700;
}
.botao:hover:not(:disabled) { background: var(--verde-escuro); border-color: var(--verde-escuro); }
.botao:disabled { background: #dde4e1; border-color: #dde4e1; color: var(--cinza); }
.botao-claro { min-height: 40px; padding: 0.3rem 0.9rem; background: var(--papel); color: var(--verde); white-space: nowrap; }
.botao-claro:hover:not(:disabled) { color: #fff; }

.campo { display: grid; gap: 0.3rem; position: relative; }
.campo > label, .campo > span { font-weight: 650; font-size: 0.95rem; }
input:not([type=checkbox]), select {
  width: 100%;
  min-height: 46px;
  padding: 0.5rem 0.8rem;
  border: 1.5px solid #84918c;
  border-radius: var(--raio);
  background: var(--papel);
}
input::placeholder { color: #6b7773; }
input.escolhido { border-color: var(--verde); background: var(--verde-claro); }
.marcar { display: flex; align-items: center; gap: 0.6rem; min-height: 32px; }
.marcar input { width: 20px; height: 20px; accent-color: var(--verde); }
.erro { color: var(--erro); font-weight: 600; }
.erro:empty { display: none; }
.vazio { padding: 2rem; border: 2px dashed var(--linha); border-radius: var(--raio); color: var(--cinza); text-align: center; }
.vazio a { color: var(--verde); font-weight: 700; }

.placa {
  display: inline-block;
  padding: 0.1rem 0.5rem 0;
  border: 2px solid var(--asfalto);
  border-top: 6px solid #1c3f94;
  border-radius: 5px;
  background: #fff;
  color: var(--asfalto);
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  line-height: 1.5;
}

#avisos { position: fixed; z-index: 2000; right: 1rem; bottom: 1rem; left: 1rem; display: grid; gap: 0.5rem; justify-items: end; pointer-events: none; }
.aviso { max-width: 26rem; padding: 0.8rem 1.1rem; border-radius: var(--raio); background: var(--asfalto); color: #fff; font-weight: 600; }
.aviso-erro { background: var(--erro); }

/* ---- Login ---- */
.login { min-height: 100dvh; display: grid; grid-template-columns: 1.1fr 1fr; padding: 1rem; gap: 1rem; }
.login-placa {
  display: grid; align-content: end; gap: 1rem;
  padding: clamp(1.5rem, 5vw, 4rem);
  border-radius: 22px;
  outline: 4px solid #fff; outline-offset: -16px;
  background: var(--verde); color: #fff;
}
.login-placa img { width: 72px; height: 72px; border: 3px solid #fff; border-radius: 18px; }
.login-placa h1 { font-size: clamp(2.2rem, 5vw, 4rem); font-weight: 800; letter-spacing: -0.02em; line-height: 1.02; }
.login-placa p { max-width: 32ch; font-size: 1.15rem; }
.login form { display: grid; gap: 1.1rem; align-content: center; width: min(100%, 24rem); margin: auto; padding: 1rem; }
.login h2 { font-size: 1.7rem; }

/* ---- Topo ---- */
.topo { display: flex; align-items: center; gap: 0.5rem 2rem; flex-wrap: wrap; padding: 0.6rem 1.5rem; background: var(--verde); color: #fff; }
.topo a { color: inherit; text-decoration: none; }
.marca { display: flex; align-items: center; gap: 0.6rem; font-weight: 800; font-size: 1.25rem; }
.marca img { border: 2px solid #fff; border-radius: 9px; }
.topo nav { display: flex; gap: 0.25rem; flex: 1; overflow-x: auto; }
.topo nav a { padding: 0.5rem 0.8rem; border-bottom: 3px solid transparent; font-weight: 650; white-space: nowrap; }
.topo nav a:hover { border-color: #ffffff80; }
.topo nav a[aria-current] { border-color: var(--amarelo); }
.conta { display: flex; align-items: center; gap: 1rem; }
.conta span { font-weight: 700; }
.conta button { padding: 0.4rem 0; border: 0; background: none; color: #fff; text-decoration: underline; text-underline-offset: 3px; }

/* ---- Retirada ---- */
.retirada { display: grid; grid-template-columns: minmax(0, 34rem) minmax(0, 1fr); align-items: start; }
.conversa { display: grid; gap: 1rem; padding: 1.5rem; }
.mapa { position: sticky; top: 0; height: calc(100dvh - 62px); min-height: 420px; background: #dbe4e0; z-index: 0; }
.mapa .leaflet-tooltip { font: 700 0.85rem 'Overpass Variable', sans-serif; color: var(--asfalto); }

.robo { display: grid; grid-template-columns: 104px 1fr; gap: 1.1rem; align-items: center; }
.robo svg { display: block; width: 100%; }
.robo-antena { stroke: var(--asfalto); stroke-width: 4; }
.robo-luz { fill: var(--amarelo); stroke: var(--asfalto); stroke-width: 3; }
.robo-vidro { fill: #bcd9ce; stroke: var(--asfalto); stroke-width: 4; stroke-linejoin: round; }
.robo-lataria { fill: var(--verde); stroke: var(--asfalto); stroke-width: 4; }
.robo-roda { fill: var(--asfalto); }
.robo-olhos { fill: #fff; stroke: var(--asfalto); stroke-width: 3; }
.robo-pupila { fill: var(--asfalto); }
.robo-boca { fill: none; stroke: #fff; stroke-width: 4; stroke-linecap: round; }
.balao { position: relative; min-height: 104px; padding: 1rem 1.2rem; border-radius: 16px; background: var(--papel); align-content: center; }
.balao::before { content: ''; position: absolute; left: -11px; top: 50%; width: 24px; height: 24px; background: inherit; transform: translateY(-50%) rotate(45deg); border-radius: 4px; }
.balao > * { position: relative; }
.balao h1 { font-size: 1.55rem; font-weight: 800; letter-spacing: -0.01em; }
.balao p { margin-top: 0.2rem; }
.pensando .robo-olhos { fill: var(--amarelo); }

@media (prefers-reduced-motion: no-preference) {
  .pensando .robo-luz { animation: piscar 0.7s steps(2, jump-none) infinite; }
  .pensando .robo-corpo { animation: motor 0.18s linear infinite alternate; }
  @keyframes piscar { to { fill: #fff; } }
  @keyframes motor { to { transform: translateY(1.5px); } }
}

.etapa { display: grid; gap: 1rem; padding: 1.25rem; border-radius: 16px; background: var(--papel); }

.sugestoes {
  position: absolute; z-index: 10; top: calc(100% + 4px); left: 0; right: 0;
  max-height: 320px; overflow-y: auto; padding: 0.3rem; list-style: none;
  border: 1.5px solid var(--asfalto); border-radius: var(--raio); background: var(--papel);
  box-shadow: 0 10px 24px #23282b33;
}
.sugestoes li { display: grid; padding: 0.55rem 0.7rem; border-radius: 6px; line-height: 1.3; }
.sugestoes li[role=option] { cursor: pointer; }
.sugestoes li[role=option]:hover, .sugestoes li[aria-selected=true] { background: var(--verde-claro); }
.sugestoes span, .sugestao-vazia { color: var(--cinza); font-size: 0.9rem; }

/* Cada rota é uma placa de rodovia */
.rotas { display: grid; gap: 0.6rem; }
.rota {
  display: grid; gap: 0.15rem; padding: 0.9rem 1.1rem; text-align: left;
  border: 2px solid var(--linha); border-radius: 12px; background: var(--papel);
}
.rota:hover { border-color: var(--verde); }
.rota-nome { font-weight: 650; }
.rota-numeros { display: flex; justify-content: space-between; gap: 1rem; font-size: 1.25rem; }
.rota-detalhe { color: var(--cinza); font-size: 0.95rem; }
.rota[aria-pressed=true] { border-color: var(--verde); background: var(--verde); color: #fff; outline: 2px solid #fff; outline-offset: -7px; padding: 1.1rem 1.3rem; }
.rota[aria-pressed=true] .rota-numeros { font-size: 1.75rem; line-height: 1.2; }
.rota[aria-pressed=true] .rota-detalhe { color: #fff; }

.veiculos { display: grid; gap: 0.6rem; }
.veiculo {
  display: flex; align-items: center; flex-wrap: wrap; gap: 0.3rem 0.8rem; min-height: 56px; padding: 0.6rem 1rem; text-align: left;
  border: 2px solid var(--linha); border-radius: 12px; background: var(--papel);
}
.veiculo-nome { flex: 1; font-weight: 700; }
.veiculo-uso { flex-basis: 100%; color: var(--cinza); font-size: 0.9rem; }
.veiculo:hover:not(:disabled) { border-color: var(--verde); }
.veiculo[aria-pressed=true] { border-color: var(--verde); background: var(--verde-claro); }
.veiculo:disabled { background: var(--fundo); color: var(--cinza); }
.veiculo:disabled .placa { border-color: #84918c; color: var(--cinza); }

.confirmacao { display: grid; gap: 1rem; }
.combustiveis { display: flex; gap: 0.6rem; }
.combustivel { flex: 1; display: grid; padding: 0.8rem 1rem; text-align: left; border: 2px solid var(--linha); border-radius: 12px; background: var(--papel); }
.combustivel strong { font-size: 1.6rem; line-height: 1.2; }
.combustivel[aria-pressed=true] { border-color: var(--asfalto); background: var(--amarelo); }

.bloco-fotos { display: grid; gap: 0.5rem; }
.bloco-fotos h3 { margin: 0; font-size: 1.05rem; }
.fotos { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.foto {
  position: relative; display: grid; align-content: end; min-height: 124px; padding: 0.7rem 0.8rem; overflow: hidden;
  border: 2px dashed #84918c; border-radius: 12px; line-height: 1.3; cursor: pointer;
}
.foto:hover { border-color: var(--verde); }
.foto:focus-within { outline: 3px solid var(--amarelo); outline-offset: 2px; }
.foto input { position: absolute; inset: 0; opacity: 0; min-height: 0; cursor: pointer; }
.foto img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.foto-estado { color: var(--verde); font-size: 0.9rem; font-weight: 650; text-decoration: underline; text-underline-offset: 3px; }
.foto-pronta { border: 2px solid var(--verde); background: var(--verde); align-content: start; padding: 0; }
.foto-pronta strong, .foto-pronta .foto-estado { position: relative; padding: 0 0.7rem; background: var(--verde); color: #fff; pointer-events: none; }
.foto-pronta strong { padding-top: 0.35rem; font-size: 0.9rem; }
.foto-pronta .foto-estado { padding-bottom: 0.35rem; }
.foto-erro { border-color: var(--erro); }
.foto-erro .foto-estado { color: var(--erro); }
.foto-pronta.foto-erro .foto-estado { background: var(--erro); color: #fff; }

.janela-fotos { width: min(56rem, calc(100vw - 2rem)); }
.galeria { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr)); gap: 1rem; margin: 1rem 0; }
.galeria figure { margin: 0; }
.galeria a { display: block; }
.galeria img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--raio); background: var(--fundo); }
.galeria figcaption { margin-top: 0.3rem; font-size: 0.9rem; }

.antes-depois { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.antes-depois h3 { margin: 0; font-size: 1.05rem; }
.sem-foto { display: grid; align-self: start; place-items: center; aspect-ratio: 4 / 3; border: 2px dashed var(--linha); border-radius: var(--raio); color: var(--cinza); }
.devolucao { display: grid; gap: 1rem; }

.em-aberto { display: grid; gap: 0.6rem; }
.em-aberto:empty { display: none; }
.aberta { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; flex-wrap: wrap; padding: 0.9rem 1.2rem; border-radius: 16px; background: var(--amarelo); }
.aberta p { flex: 1 1 14rem; display: flex; align-items: center; flex-wrap: wrap; gap: 0.2rem 0.6rem; }

/* ---- Listas ---- */
.lista { width: min(100%, 78rem); margin: 0 auto; padding: 1.5rem; display: grid; gap: 1.25rem; }
.lista header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 46px; }
.lista h1 { font-size: 1.8rem; font-weight: 800; }
.tabela { overflow-x: auto; border-radius: 16px; background: var(--papel); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.8rem 1rem; text-align: left; vertical-align: middle; }
th { border-bottom: 2px solid var(--asfalto); font-size: 0.9rem; font-weight: 700; white-space: nowrap; }
tbody tr + tr td { border-top: 1px solid var(--linha); }
td { font-variant-numeric: tabular-nums; }
.linha { display: block; }
.celula-veiculo { display: inline-grid; gap: 0.2rem; justify-items: start; }

/* ---- Janelas ---- */
dialog { width: min(30rem, calc(100vw - 2rem)); padding: 1.5rem; border: 0; border-radius: 16px; color: inherit; }
dialog::backdrop { background: #23282b99; }
dialog form { display: grid; gap: 1rem; }
dialog h2 { font-size: 1.35rem; }
.dica { color: var(--cinza); font-size: 0.9rem; }
dialog .sugestoes { position: static; max-height: 260px; box-shadow: none; }
.acoes { display: flex; justify-content: flex-end; gap: 0.6rem; }
.acoes .botao { min-height: 46px; }

@media (max-width: 900px) {
  .retirada { grid-template-columns: minmax(0, 1fr); }
  .conversa { padding: 1rem; }
  .mapa { position: relative; height: 60dvh; min-height: 320px; }
  .topo { padding: 0.6rem 1rem; }
  .topo nav { order: 3; flex-basis: 100%; }
  .conta { margin-left: auto; }
}

@media (max-width: 700px) {
  .login { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .login-placa { padding: 2.2rem; }
  .topo nav { gap: 0; justify-content: space-between; }
  .topo nav a { padding: 0.5rem 0.2rem; font-size: 0.95rem; }
  .etapa { scroll-margin-top: 0.75rem; }
  .robo { grid-template-columns: 76px 1fr; gap: 0.9rem; }
  .lista { padding: 1rem; }
  /* Cada linha da tabela vira um bloco */
  thead { display: none; }
  table, tbody, tr, td { display: block; }
  tr { padding: 0.8rem 1rem; }
  tbody tr + tr { border-top: 1px solid var(--linha); }
  tbody tr + tr td { border-top: 0; }
  td { display: grid; grid-template-columns: 7.5rem 1fr; gap: 0.6rem; align-items: center; justify-items: start; padding: 0.25rem 0; }
  td::before { content: attr(data-coluna); color: var(--cinza); font-size: 0.9rem; }
}
