:root {
  --azul: #0c1e6e;
  --azul-claro: #e9edfb;
  --texto: #171a22;
  --suave: #5d6577;
  --linha: #dfe3ec;
  --fundo: #f4f6fa;
  --erro: #b3261e;
  --ok: #1b7f4b;
  --raio: 14px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--fundo);
  color: var(--texto);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topo {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--azul);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  padding-top: max(8px, env(safe-area-inset-top));
}

.topo img {
  border-radius: 8px;
  display: block;
}

.topo-nome {
  font-weight: 600;
  flex: 1;
}

.topo-pedido {
  text-align: right;
  line-height: 1.15;
}

.topo-pedido span {
  display: block;
  font-size: 11px;
  opacity: 0.75;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.topo-pedido strong {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

main {
  flex: 1;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 20px 16px calc(28px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

main.largo {
  max-width: 640px;
}

h1 {
  font-size: 24px;
  line-height: 1.2;
  margin: 0;
  text-wrap: balance;
}

h2 {
  font-size: 15px;
  margin: 0 0 4px;
}

p {
  margin: 0;
}

.sub {
  color: var(--suave);
}

.etapa {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--azul);
}

.progresso {
  height: 4px;
  background: var(--linha);
  border-radius: 2px;
  overflow: hidden;
}

.progresso i {
  display: block;
  height: 100%;
  background: var(--azul);
  transition: width 0.25s;
}

.cartao {
  background: #fff;
  border: 1px solid var(--linha);
  border-radius: var(--raio);
  padding: 4px 16px;
}

.cartao.folga {
  padding: 16px;
}

.obs {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 15px;
}

.linha {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid var(--linha);
}

.linha:last-child {
  border-bottom: 0;
}

.linha dt {
  color: var(--suave);
  flex-shrink: 0;
}

.linha dd {
  margin: 0;
  text-align: right;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.linha.total dd {
  font-size: 20px;
  font-weight: 700;
  color: var(--azul);
  font-variant-numeric: tabular-nums;
}

dl {
  margin: 0;
}

details {
  background: #fff;
  border: 1px solid var(--linha);
  border-radius: var(--raio);
  padding: 0 16px;
}

summary {
  padding: 14px 0;
  font-weight: 600;
  color: var(--azul);
  cursor: pointer;
}

.item {
  padding: 10px 0;
  border-top: 1px solid var(--linha);
  font-size: 14px;
}

.item b {
  display: block;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.item div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--suave);
  font-variant-numeric: tabular-nums;
}

.item div span:last-child {
  color: var(--texto);
  font-weight: 600;
}

.botao {
  appearance: none;
  border: 0;
  border-radius: 12px;
  background: var(--azul);
  color: #fff;
  font: inherit;
  font-weight: 600;
  padding: 15px 18px;
  width: 100%;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: block;
  min-height: 52px;
}

.botao:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.botao.secundario {
  background: #fff;
  color: var(--azul);
  border: 1.5px solid var(--azul);
}

.botao.discreto {
  background: none;
  color: var(--azul);
  width: auto;
  min-height: 0;
  padding: 6px 4px;
}

.botao:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 3px solid #7d93f0;
  outline-offset: 2px;
}

.acoes {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 8px;
}

label.campo {
  display: block;
  font-size: 14px;
  font-weight: 600;
}

label.campo small {
  display: block;
  font-weight: 400;
  color: var(--suave);
}

input[type="text"],
input[type="tel"] {
  width: 100%;
  margin-top: 6px;
  padding: 14px;
  font: inherit;
  border: 1.5px solid var(--linha);
  border-radius: 12px;
  background: #fff;
  color: var(--texto);
}

.termo {
  background: #fff;
  border: 1px solid var(--linha);
  border-radius: var(--raio);
  padding: 4px 16px 12px;
  max-height: 46dvh;
  overflow-y: auto;
  font-size: 14px;
}

.termo h2 {
  margin-top: 14px;
}

.marcar {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: #fff;
  border: 1.5px solid var(--linha);
  border-radius: 12px;
  padding: 13px 14px;
  font-size: 14px;
  cursor: pointer;
}

.marcar:has(input:checked) {
  border-color: var(--azul);
  background: var(--azul-claro);
}

.marcar input {
  width: 22px;
  height: 22px;
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--azul);
}

.quadro {
  position: relative;
  background: #fff;
  border: 1.5px dashed #aab2c5;
  border-radius: var(--raio);
  overflow: hidden;
}

.quadro canvas {
  display: block;
  width: 100%;
  height: 220px;
  touch-action: none;
}

.quadro::after {
  content: "";
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 52px;
  border-bottom: 1px solid #c5cbdb;
  pointer-events: none;
}

.quadro .botao {
  position: absolute;
  right: 8px;
  bottom: 6px;
}

.camera {
  position: relative;
  background: #10131c;
  border-radius: var(--raio);
  overflow: hidden;
  aspect-ratio: 3 / 4;
  max-height: 52dvh;
  margin: 0 auto;
  width: 100%;
}

.camera video,
.camera img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.camera video {
  transform: scaleX(-1);
}

.camera .contorno {
  position: absolute;
  inset: 12% 18% 18%;
  border: 3px solid rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  pointer-events: none;
}

.aviso {
  background: #fdecea;
  color: var(--erro);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
}

.aviso.ok {
  background: #e6f4ec;
  color: var(--ok);
}

.aviso.neutro {
  background: var(--azul-claro);
  color: var(--azul);
}

.centro {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 14px;
  padding: 24px 0;
}

.centro > .cartao,
.centro > .botao {
  width: 100%;
  text-align: left;
}

.centro > .botao {
  text-align: center;
}

.selo {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--ok);
  color: #fff;
  font-size: 38px;
  line-height: 72px;
}

.selo.erro {
  background: var(--erro);
}

.girando {
  width: 38px;
  height: 38px;
  border: 4px solid var(--linha);
  border-top-color: var(--azul);
  border-radius: 50%;
  animation: girar 0.8s linear infinite;
}

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

.qr {
  background: #fff;
  border: 1px solid var(--linha);
  border-radius: var(--raio);
  padding: 14px;
  width: 240px;
  max-width: 100%;
}

.qr svg {
  display: block;
  width: 100%;
  height: auto;
}

.mono {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}

@media (prefers-reduced-motion: reduce) {
  .girando {
    animation-duration: 2.4s;
  }
  .progresso i {
    transition: none;
  }
}
