:root {
  --red: #ea1d2c;
  --red-press: #c8101e;
  --c99: #ffc700;
  --c99-press: #e6b300;
  --red-soft: #fdeced;
  --green: #0a9c50;
  --green-soft: #e6f6ee;
  --amber: #b45309;
  --bg: #ffffff;
  --surface: #f5f5f7;
  --fg: #3e3e3e;
  --title: #151515;
  --muted: #717171;
  --line: #ececee;
  --shadow-sheet: 0 -8px 32px rgba(0, 0, 0, .10);
  --shadow-float: 0 4px 16px rgba(0, 0, 0, .12);
  --radius: 12px;
  --font: "Geist", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --tracking: -0.04em; /* espaçamento entre letras do app todo */
  /* Movimento: saída rápida para UI e curva de gaveta (painéis que sobem de baixo) */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --press: transform 160ms var(--ease-out);
}
@media (prefers-color-scheme: dark) {
  :root {
    --red-soft: #3a1518;
    --green-soft: #0f2c1d;
    --amber: #f59e0b;
    --bg: #18181b;
    --surface: #232327;
    --fg: #d6d6da;
    --title: #fafafa;
    --muted: #9b9ba3;
    --line: #2e2e33;
    --shadow-sheet: 0 -8px 32px rgba(0, 0, 0, .5);
    --shadow-float: 0 4px 16px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* App, não página: sem zoom da página (pinça e toque duplo), sem seleção de
   texto e sem o menu de toque longo. O mapa tem os próprios gestos (o
   Leaflet usa touch-action: none nele) e os campos continuam editáveis. */
html, body {
  touch-action: pan-x pan-y;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
}
input, textarea, select { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
button, a, label, .tile, .tool { touch-action: manipulation; }
[hidden] { display: none !important; }
:focus:not(:focus-visible) { outline: none; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
html, body { margin: 0; height: 100%; }
body {
  font: 500 15px/1.45 var(--font);
  letter-spacing: var(--tracking);
  color: var(--fg);
  background: var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { color: var(--title); margin: 0; }
/* Campos e botões não herdam o espaçamento sozinhos */
button, input, textarea, select { letter-spacing: inherit; }
p { margin: 0; }
.grow { flex: 1; }
.muted { color: var(--muted); }

.i {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- mapa e elementos flutuantes ---------- */
#map { position: fixed; inset: 0; z-index: 0; background: var(--surface); }
/* Crédito do mapa (obrigatório pela licença): mínimo e discreto */
.map-credit {
  position: absolute; left: 12px; bottom: calc(100% + 4px);
  font: 500 9px/1.2 var(--font); color: rgba(0, 0, 0, .45); text-decoration: none;
  pointer-events: auto;
}
@media (prefers-color-scheme: dark) { .map-credit { color: rgba(255, 255, 255, .45); } }
/* Marcadores: o MapLibre controla o transform do elemento de fora */
.pin-wrap { width: 34px; height: 40px; display: flex; align-items: flex-start; justify-content: center; cursor: pointer; }
.me-marker { width: 18px; height: 18px; pointer-events: none; }

.fab-sm {
  width: 44px; height: 44px; border-radius: 50%;
  border: 0; background: var(--bg); color: var(--title);
  display: grid; place-items: center;
  box-shadow: var(--shadow-float); cursor: pointer;
}
.fab-sm { transition: var(--press); }
.fab-sm:active { transform: scale(.94); }
/* Seguindo o motoboy no modo entrega */
.fab-sm.on { color: var(--red); }
.map-tools {
  position: fixed; z-index: 2; right: 16px; top: calc(env(safe-area-inset-top) + 12px);
  display: flex; flex-direction: column; gap: 10px;
}
.compass .i { color: var(--red); transition: transform .1s linear; width: 22px; height: 22px; }

/* ---------- painel inferior ---------- */
/* O painel desliza por deslocamento (transform: feito pela placa de vídeo, não
   recalcula a tela a cada quadro). A parte que desliza (.slide: alça +
   conteúdo) passa por trás dos botões de baixo, que ficam fixos por cima. */
.sheet {
  position: fixed; z-index: 3; left: 0; right: 0; bottom: 0;
  max-height: 64dvh;
  display: flex; flex-direction: column;
  pointer-events: none; /* a área acima da parte que desliza é do mapa */
}
.sheet > * { pointer-events: auto; }
.slide {
  position: relative; flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column;
  background: var(--bg);
  border-radius: 24px 24px 0 0;
  box-shadow: var(--shadow-sheet);
  /* sem will-change: a camada fixa deixava uma faixa sem mapa no topo da tela
     (o deslocamento já é feito pela placa de vídeo durante a animação) */
}
.sheet.animating .slide { transition: transform .32s var(--ease-drawer); }
/* Troca entre a lista e o modo entrega: o painel novo sobe de baixo */
@keyframes sheet-in { from { transform: translateY(100%); } }
.sheet.entering .slide, .sheet.entering .sheet-footer { animation: sheet-in .34s var(--ease-drawer); }

/* Enquanto o mapa carrega */
.map-loading {
  position: fixed; z-index: 1; left: 50%; top: calc(env(safe-area-inset-top) + 18px); transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg); color: var(--muted); box-shadow: var(--shadow-float);
  padding: 8px 14px; border-radius: 999px; font-weight: 700; font-size: 13px;
  transition: opacity .3s var(--ease-out);
}
.map-loading.out { opacity: 0; pointer-events: none; }
.map-loading.fail { color: var(--fg); cursor: pointer; max-width: calc(100vw - 32px); }
.map-loading.fail .spinner { animation: none; }
.map-loading .i { width: 16px; height: 16px; }
#delivery { max-height: 82dvh; }
.sheet[hidden] { display: none; }
.grab {
  flex: none; display: block; width: 100%;
  padding: 10px 0 6px; border: 0; background: none;
  cursor: grab; touch-action: none;
}
.handle { display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto; transition: background .15s, width .15s; }
.grab:active .handle, .sheet.dragging .handle { background: var(--muted); width: 48px; }
.sheet-body { padding: 8px 20px 4px; overflow-y: auto; overscroll-behavior: contain; }
/* Cabeçalho do painel também serve para arrastar */
.sheet-body > :first-child { touch-action: none; }
.sheet.collapsed .sheet-body, .sheet.mid .sheet-body, .sheet.dragging .sheet-body { overflow: hidden; }
.sheet-footer {
  position: relative; z-index: 1; background: var(--bg);
  padding: 10px 16px max(8px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 10px;
}
.sheet-footer.row { flex-direction: row; }
.row { display: flex; gap: 10px; align-items: center; }

.sheet-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-title > div { flex: 1; min-width: 0; }
.sheet-title h2 { font-size: 20px; font-weight: 800; }
.btn.clear { color: var(--muted); }
.btn.clear:active { color: var(--red); }
.sub { color: var(--muted); font-size: 13px; font-weight: 500; }

/* Em rota com a lista aberta */
.on-route {
  display: flex; align-items: center; gap: 12px; width: 100%; margin-top: 12px;
  padding: 12px 14px; border: 0; border-radius: var(--radius); cursor: pointer; text-align: left;
  background: var(--green-soft); color: var(--title); font: inherit;
}
.on-route .grow { min-width: 0; }
.on-route b { display: block; font-size: 15px; font-weight: 700; color: var(--green); }
.on-route .grow > span { display: block; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.on-route-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--green); animation: on-route-pulse 1.6s ease-out infinite; }
@keyframes on-route-pulse { 0% { box-shadow: 0 0 0 0 rgba(10, 143, 74, .45); } 100% { box-shadow: 0 0 0 10px rgba(10, 143, 74, 0); } }
@media (prefers-reduced-motion: reduce) { .on-route-dot { animation: none; } }
.on-route-go { flex: none; display: inline-flex; align-items: center; gap: 2px; font-size: 14px; font-weight: 700; color: var(--green); }
.on-route-go .i { width: 18px; height: 18px; transform: rotate(-90deg); }
.order .now-tag {
  display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; vertical-align: 2px;
  background: var(--green-soft); color: var(--green); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em;
}
.order.current .num { background: var(--green); color: #fff; }
.stats { display: flex; gap: 8px; margin-top: 12px; }
.stats[hidden] { display: none; }
.stat {
  /* Dividem a largura toda, alinhados com a lista de pedidos */
  flex: 1 1 0; min-width: 0; justify-content: center;
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); border-radius: 10px;
  padding: 8px 6px; font-size: 13px; color: var(--fg); white-space: nowrap;
}
.stat.muted { flex: none; background: none; padding: 8px 0; }
.stat .i { width: 16px; height: 16px; color: var(--red); }
.stat b { font-weight: 700; color: var(--title); }

/* ---------- lista de pedidos ---------- */
.orders { list-style: none; padding: 0; margin: 12px 0 8px; }
.order {
  display: grid; grid-template-columns: 32px 1fr auto; gap: 4px 12px;
  align-items: start;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.order:last-child { border-bottom: 0; }
/* Sem linha encostando num card aberto */
.order:has(+ .order.open) { border-bottom-color: transparent; }
.order .num {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--red); color: #fff;
  display: grid; place-items: center;
  font-weight: 800; font-size: 14px;
}
.order.nogeo .num { background: var(--muted); }
.order.done .num { background: var(--green); }
.order.done .info, .order.done .code-pill { opacity: .5; }
.order .info { min-width: 0; cursor: pointer; }
.order .name { display: block; font-weight: 700; color: var(--title); font-size: 15px; }
.order .addr { display: block; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.order .leg-km { display: flex; align-items: center; gap: 4px; margin-top: 2px; font-size: 12px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.order .leg-km .i { width: 13px; height: 13px; }
.order .warn { display: flex; align-items: center; gap: 4px; margin-top: 4px; font-size: 12px; font-weight: 600; color: var(--amber); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.order .warn .i { width: 14px; height: 14px; flex: none; }
.code-pill {
  font-family: var(--mono); font-weight: 700; font-size: 15px; letter-spacing: .04em;
  font-variant-numeric: tabular-nums;
  color: var(--red); background: var(--red-soft);
  border-radius: 8px; padding: 4px 8px;
}
/* Ferramentas só no pedido tocado ou que pede ação (aviso): a lista cabe na tela.
   Ocupam a largura toda do card, sempre numa linha só */
/* Grupo dos entregues: uma linha discreta no fim da lista */
.done-group { border-top: 1px solid var(--line); }
.order + .done-group { border-top-color: transparent; }
.done-group button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 12px 0; border: 0; background: none; cursor: pointer;
  font: 700 14px var(--font); color: var(--muted); text-align: left;
}
.done-group button span { flex: 1; }
.done-group .i { color: var(--green); }
.done-group .i:last-child { color: var(--muted); transition: transform .2s var(--ease-out); }
.done-group.open .i:last-child { transform: rotate(180deg); }
/* Entregues abertos: mais compactos */
.order.done { padding: 8px 0; }
.order.done .num { width: 26px; height: 26px; margin-left: 3px; }
.order.done .num .i { width: 15px; height: 15px; }
.order.done .name { font-size: 14px; }
/* Cupom sendo lido: já aparece na lista enquanto a IA lê */
.order.reading .num { background: var(--red-soft); color: var(--red); }
.order.reading .num .i { width: 16px; height: 16px; }
.order.reading.now .num { animation: blink 1s ease-in-out infinite; }
.order.reading .name { color: var(--muted); }
.order.reading .tool { align-self: center; flex: none; }
.order .warn.info { color: var(--muted); }
.shimmer {
  display: block; width: 70%; height: 10px; margin-top: 6px; border-radius: 5px;
  background: linear-gradient(90deg, var(--surface) 0%, var(--line) 50%, var(--surface) 100%);
  background-size: 200% 100%; animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.order .tools { grid-column: 1 / -1; display: none; gap: 8px; margin-top: 8px; }
.order.open .tools { display: flex; }
.order.open {
  background: var(--surface); border-radius: 14px; border-bottom-color: transparent;
  margin: 6px -12px; padding: 12px;
}
.order.open + .order.open { margin-top: 8px; }
.tool {
  flex: 1 1 0; min-width: 0; min-height: 40px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: transparent; color: var(--fg);
  border-radius: 10px; padding: 0 6px;
  font: 600 13px var(--font); cursor: pointer; white-space: nowrap;
}
.tool span { overflow: hidden; text-overflow: ellipsis; }
.tool.wide { flex-grow: 1.5; } /* "Buscar de novo" tem o texto mais longo */
.tool .i { width: 16px; height: 16px; }
/* Celular estreito: só o texto, para os três caberem */
@media (max-width: 359px) { .tool .i { display: none; } }
.order.open .tool { background: var(--bg); }
.tool.danger { color: var(--red); }

.empty { text-align: center; padding: 20px 12px 12px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.empty[hidden] { display: none; }
.empty-icon { width: 56px; height: 56px; border-radius: 50%; background: var(--red-soft); color: var(--red); display: grid; place-items: center; margin-bottom: 6px; }
.empty-icon .i { width: 26px; height: 26px; }
.empty b { color: var(--title); font-size: 16px; }
.empty p { color: var(--muted); font-size: 13px; max-width: 280px; }

/* ---------- fila de leitura ---------- */
.queue {
  margin-top: 12px; padding: 14px;
  background: var(--red-soft); border-radius: 16px;
}
/* Cupons que falharam: alerta dentro do mesmo componente */
.queue.only-fail { background: #fff4e5; }
.q-fail { margin-top: 12px; }
.queue.only-fail .q-fail { margin-top: 0; }
.q-fail-head { display: flex; align-items: center; gap: 8px; color: #8a4b00; }
.q-fail-head .i { color: #d97706; }
.q-fail-head b { flex: 1; font-size: 14px; color: #7a3e00; }
.q-fail-head .link-btn { margin: 0; padding: 4px 0; color: #8a4b00; }
.q-fail-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.q-fail-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 6px 10px 6px 6px; border: 0; border-radius: 10px;
  background: var(--bg); color: var(--fg); text-align: left; cursor: pointer;
  font: inherit;
}
.q-fail-item img { width: 36px; height: 48px; object-fit: cover; border-radius: 6px; flex: none; }
.q-fail-item b { display: block; font-size: 14px; color: var(--title); }
.q-fail-item .grow > span { display: block; font-size: 12px; color: var(--muted); }
.q-fail-see { font-size: 13px; font-weight: 700; color: var(--red); white-space: nowrap; }
@media (prefers-color-scheme: dark) {
  .queue.only-fail { background: #3a2a10; }
  .q-fail-head, .q-fail-head .link-btn { color: #f6c68b; }
  .q-fail-head b { color: #ffd9a8; }
}
.fail-img { display: block; width: 100%; max-height: 62dvh; object-fit: contain; border-radius: var(--radius); background: var(--surface); }

/* ---------- botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 20px;
  border-radius: var(--radius); border: 0;
  background: var(--surface); color: var(--title);
  font: 700 15px var(--font);
  text-decoration: none; cursor: pointer; user-select: none;
  transition: background-color .15s ease, color .15s ease, var(--press);
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn.block { width: 100%; }
.btn[hidden] { display: none; }
.btn.primary { background: var(--red); color: #fff; }
.btn.primary:active { background: var(--red-press); }
.btn.soft { background: var(--red-soft); color: var(--red); }
.btn.success { background: var(--green); color: #fff; }
/* "Copiar código": botão neutro no cartão; confirma no próprio botão */
#d-copy { background: var(--bg); color: var(--title); }
.btn.copied, .btn.copied:active, #d-copy.copied { background: var(--green); color: #fff; }
.btn.outline { background: transparent; border: 1.5px solid var(--line); }
/* Confirmar entrega: preenchido na cor do canal (iFood vermelho, 99 amarelo) */
.btn.ifood { background: var(--red); color: #fff; }
.btn.ifood:active { background: var(--red-press); }
.btn.c99 { background: var(--c99); color: #111; }
.btn.c99:active { background: var(--c99-press); }
.btn.c99 .i { color: #111; }
.btn.icon { width: 52px; padding: 0; flex: none; }
.btn.icon.sm { width: 40px; min-height: 40px; border-radius: 50%; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); color: var(--title);
  border-radius: 999px; padding: 6px 12px;
  font-weight: 700; font-size: 13px; white-space: nowrap;
}
.chip .i { width: 15px; height: 15px; color: var(--red); }

/* ---------- modo entrega ---------- */
.d-head { display: flex; align-items: center; gap: 10px; }
.d-step { flex: 1; font-size: 13px; font-weight: 700; color: var(--muted); }
.progress { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; margin-top: 6px; }
.progress > div { height: 100%; width: 0; background: var(--red); border-radius: 2px; transition: width .3s var(--ease-out); }

.arrived {
  display: flex; gap: 12px; align-items: center;
  background: var(--green-soft); color: var(--green);
  border-radius: var(--radius); padding: 10px 14px; margin-top: 12px;
}
.arrived[hidden] { display: none; }
.arrived .i { width: 26px; height: 26px; }
.arrived b { display: block; font-size: 15px; }
.arrived span { font-size: 13px; color: var(--fg); }

.d-head-name { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-top: 14px; }
.d-customer { font-size: 22px; font-weight: 800; min-width: 0; }
.d-order { font-size: 13px; color: var(--muted); white-space: nowrap; flex: none; }
.d-order:empty { display: none; }
.d-address { margin-top: 4px; font-size: 15px; color: var(--fg); }
.d-compl { font-size: 13px; color: var(--muted); }
.d-compl:empty { display: none; }
.link-btn {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 8px; padding: 4px 0;
  border: 0; background: none; color: var(--red);
  font: 700 13px var(--font); cursor: pointer; text-align: left;
}
.link-btn .i { width: 16px; height: 16px; flex: none; }

.code-card {
  margin-top: 14px; padding: 14px;
  background: var(--surface); border-radius: 16px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  transition: background .2s;
}
#delivery.near .code-card { background: var(--green-soft); }
.code-card .label { font-size: 13px; font-weight: 700; color: var(--muted); }
.code-digits { display: flex; gap: 8px; width: 100%; justify-content: center; }
.code-digits span {
  width: 54px; height: 62px; border-radius: 12px;
  background: var(--bg); color: var(--title);
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 0;
}
#delivery.near .code-digits span { background: var(--bg); }
/* Localizador tem 8 dígitos: caixas menores, separadas em dois grupos de 4 */
.code-digits.long { gap: 4px; }
.code-digits.long span { flex: 1; width: auto; max-width: 40px; height: 54px; font-size: 26px; border-radius: 10px; }
.code-digits.long span:nth-child(4) { margin-right: 8px; }
#d-confirm { margin-top: -4px; }
.code-card .meta { font-size: 12px; color: var(--muted); }
/* Valor a cobrar na entrega: precisa chamar atenção */
.pay {
  display: flex; align-items: center; gap: 12px;
  margin-top: 14px; padding: 12px 14px;
  border-radius: var(--radius);
  background: #fff4e5; color: #8a4b00;
}
.pay .i { width: 24px; height: 24px; flex: none; color: #d97706; }
.pay b { display: block; font-size: 18px; font-weight: 800; color: #7a3e00; }
.pay span { font-size: 13px; font-weight: 600; }
.pay span:empty { display: none; }
@media (prefers-color-scheme: dark) {
  .pay { background: #3a2a10; color: #f6c68b; }
  .pay b { color: #ffd9a8; }
}
.nocode {
  display: flex; align-items: center; gap: 10px;
  margin-top: 14px; padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface); color: var(--title);
  font-weight: 700; font-size: 14px;
}
.nocode .i { color: var(--green); }
.code-pill.none { color: var(--muted); background: var(--surface); letter-spacing: .02em; font-size: 12px; }
.code-card .meta:empty { display: none; }

.tiles { display: flex; gap: 8px; margin: 12px 0 8px; }
.tile {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 4px; border-radius: var(--radius);
  background: var(--surface); color: var(--title);
  font-size: 12px; font-weight: 700; text-decoration: none;
}
.tile .i { color: var(--red); width: 22px; height: 22px; }
.tile[hidden] { display: none; }

/* ---------- diálogo de revisão ---------- */
/* Janela própria (não usa <dialog>, que falha em alguns celulares) */
.modal {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .45); animation: fade .2s var(--ease-out); }
.modal-card {
  position: relative;
  width: 100%; max-width: 560px;
  max-height: 92vh; max-height: 92dvh;
  margin: 0;
  display: flex; flex-direction: column;
  border-radius: 24px 24px 0 0;
  background: var(--bg); color: var(--fg);
  animation: up .3s var(--ease-drawer);
}
/* Sobe de baixo como gaveta; ao fechar desce mais rápido (.closing, ver js) */
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }
@keyframes down { to { transform: translateY(100%); } }
@keyframes fadeout { to { opacity: 0; } }
.modal.closing .modal-card { animation: down .2s var(--ease-out) forwards; }
.modal.closing .modal-backdrop { animation: fadeout .2s var(--ease-out) forwards; }
.modal.closing { pointer-events: none; }
body.modal-open { overscroll-behavior: none; }
.dlg-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 20px 12px; }
.dlg-head > div { flex: 1; }
.dlg-head h2 { font-size: 20px; font-weight: 800; }
.dlg-body { padding: 0 20px 8px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.dlg-foot { padding: 10px 16px max(8px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }

.spinner { color: var(--red); display: grid; animation: blink 1s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .35; } }
/* Faixa da foto na revisão: toque abre o cupom inteiro */
.preview { position: relative; display: block; width: 100%; height: 120px; margin: 0 0 12px; padding: 0; border: 0; border-radius: var(--radius); overflow: hidden; cursor: zoom-in; background: var(--surface); }
.preview[hidden] { display: none; }
#preview { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.preview-hint {
  position: absolute; right: 8px; bottom: 8px;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 999px;
  background: rgba(0, 0, 0, .6); color: #fff; font: 700 12px var(--font);
}
.preview-hint .i { width: 14px; height: 14px; }
.fail-img { cursor: zoom-in; }

/* Visualizador da foto em tela cheia */
.viewer { position: fixed; inset: 0; z-index: 3500; background: #000; overflow: hidden; touch-action: none; }
.viewer[hidden] { display: none; }
.viewer img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; transform-origin: 0 0; user-select: none; -webkit-user-drag: none; }
.viewer-close { position: absolute; top: calc(env(safe-area-inset-top) + 16px); right: 16px; }
.viewer-hint {
  position: absolute; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 20px); transform: translateX(-50%);
  background: rgba(0, 0, 0, .6); color: #fff; padding: 8px 14px; border-radius: 999px;
  font: 600 13px var(--font); white-space: nowrap; pointer-events: none;
}

.group { font-size: 15px; font-weight: 800; color: var(--title); margin: 20px 0 8px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.span2 { grid-column: span 2; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); }
.field input {
  font: 600 16px var(--font); color: var(--title);
  background: var(--surface); border: 1.5px solid transparent; border-radius: 10px;
  height: 48px; padding: 0 12px; width: 100%; outline: none;
  transition: border-color .15s, background .15s;
}
.field input:focus { border-color: var(--red); background: var(--bg); }
.code-field input {
  height: 64px; text-align: center;
  font-family: var(--mono); font-size: 28px; font-weight: 700; letter-spacing: .2em; padding-left: .2em;
  font-variant-numeric: tabular-nums;
  color: var(--red); background: var(--red-soft);
}
details { margin: 16px 0 4px; font-size: 13px; }
summary { color: var(--red); font-weight: 700; cursor: pointer; display: flex; align-items: center; gap: 6px; list-style: none; }
summary::-webkit-details-marker { display: none; }
/* Seta de abrir/fechar: aponta para baixo fechado, para cima aberto */
summary .i { width: 18px; height: 18px; transition: transform .2s var(--ease-out); }
details[open] > summary .i { transform: rotate(180deg); }
details pre { white-space: pre-wrap; font-size: 11px; max-height: 200px; overflow: auto; background: var(--surface); padding: 10px; border-radius: 8px; }

/* ---------- toast ---------- */
/* Avisos no topo, à esquerda da coluna de botões do mapa */
.toast {
  position: fixed; z-index: 3500; /* acima da tela de conta/pagamento */ left: 16px;
  top: calc(env(safe-area-inset-top) + 12px);
  display: flex; align-items: center; gap: 8px;
  background: #1f1f1f; color: #fff;
  padding: 12px 16px; border-radius: var(--radius);
  font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow-float);
  width: max-content; max-width: calc(100vw - 88px);
  /* Transição (não keyframe): avisos seguidos não reiniciam do zero */
  transition: opacity .2s var(--ease-out), transform .2s var(--ease-out);
}
.toast.out { opacity: 0; transform: translateY(-8px); pointer-events: none; }
.toast[hidden] { display: none; }
.toast .i { width: 18px; height: 18px; color: #5ee09a; }

/* ---------- aviso de nova versão ---------- */
.update {
  position: fixed; z-index: 999; left: 16px; right: 72px;
  top: calc(env(safe-area-inset-top) + 12px);
  display: flex; align-items: center; gap: 10px;
  background: var(--bg); color: var(--title);
  border-radius: var(--radius); padding: 8px 8px 8px 14px;
  box-shadow: var(--shadow-float);
  font-weight: 700; font-size: 14px;
  animation: slide .2s var(--ease-out);
}
@keyframes slide { from { transform: translateY(-8px); opacity: 0; } }
.update .i { color: var(--red); }
.update span { flex: 1; }
/* cadastro da primeira abertura: cobre o app todo até preencher */
.welcome {
  position: fixed; inset: 0; z-index: 3000; background: var(--bg); overflow-y: auto;
  display: grid; place-items: center; padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
}
.welcome-card { width: 100%; max-width: 380px; }
.welcome-logo { display: block; width: 72px; height: 72px; border-radius: 16px; margin-bottom: 14px; box-shadow: var(--shadow-float); }
.welcome-card h1 { margin: 0 0 4px; font-size: 26px; font-weight: 800; color: var(--title); }
.welcome-card .sub { margin: 0 0 20px; }
.welcome-card .field input { font-size: 16px; } /* 16px: o iPhone não dá zoom ao focar */
.installed-card { text-align: center; }
.installed-card .welcome-logo { margin-inline: auto; }
.welcome-go { width: 100%; margin-top: 18px; min-height: 52px; }
.welcome-error { margin: 10px 0 0; color: var(--red); font-weight: 700; font-size: 14px; }
.welcome-card .welcome-note { margin: 14px 0 0; font-size: 12px; text-align: center; }
/* conta e assinatura */
.auth-gap { margin-top: 12px; }
.auth-switch { margin-top: 8px; min-height: 46px; }
.auth-forgot { display: block; margin-top: 6px; text-align: center; font-size: 14px; color: var(--muted); }
.pw-card { position: relative; }
.pw-close { position: absolute; top: 0; right: 0; }
.pw-price { display: flex; align-items: baseline; gap: 4px; margin: 0 0 12px; }
.pw-price b { font-size: 34px; font-weight: 800; color: var(--title); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.pw-price span { color: var(--muted); font-weight: 600; }
.pw-list { list-style: none; margin: 0 0 6px; padding: 0; display: grid; gap: 8px; }
.pw-list li { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.pw-list .i { width: 18px; height: 18px; color: var(--green); flex: none; }
.pw-second { margin-top: 8px; min-height: 48px; }
#paywall.pix .pw-list { display: none; } /* no Pix, o QR code sobe para a tela */
.welcome-card .pw-note { margin: 10px 0 0; font-size: 13px; }
.pw-qr { display: block; width: 220px; height: 220px; margin: 14px auto 6px; border-radius: 12px; background: #fff; padding: 8px; image-rendering: pixelated; }
.pw-pixinfo { text-align: center; margin: 0; font-weight: 700; color: var(--title); }
.pw-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 16px; }
.acc-status { display: grid; gap: 4px; padding: 14px; border-radius: 14px; background: var(--surface); margin-bottom: 14px; }
.acc-status b { font-size: 17px; color: var(--title); }
.acc-status[data-status="active"] b, .acc-status[data-status="comp"] b { color: var(--green); }
.acc-status[data-status="past_due"] b, .acc-status[data-status="expired"] b { color: var(--red); }
.acc-actions { display: grid; gap: 8px; }
/* loader no botão enquanto espera o servidor */
.btn.loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.loading:disabled { opacity: 1; }
.btn.loading::after {
  content: ''; position: absolute; inset: 0; margin: auto; width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid var(--title); border-right-color: transparent; animation: btn-spin .7s linear infinite;
}
.btn.primary.loading::after { border-color: #fff; border-right-color: transparent; }
@keyframes btn-spin { to { transform: rotate(360deg); } }
/* guia de instalação no iPhone/iPad */
.ios-guide {
  position: fixed; inset: 0; z-index: 2500; background: rgba(0, 0, 0, .6);
  display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
  padding: 16px 16px max(10px, env(safe-area-inset-bottom)); animation: fade .2s var(--ease-out);
}
.ios-card {
  width: 100%; max-width: 420px; background: var(--bg); border-radius: 18px; padding: 20px 20px 18px;
  box-shadow: var(--shadow-float); animation: slide .25s var(--ease-out);
}
.ios-card h2 { margin: 0 0 2px; font-size: 20px; font-weight: 800; color: var(--title); }
.ios-card .sub { margin: 0 0 12px; }
.ios-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.ios-steps li { display: flex; gap: 12px; align-items: flex-start; line-height: 1.4; }
.ios-steps .n {
  flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--red); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 14px;
}
.ios-steps .i { width: 18px; height: 18px; vertical-align: -4px; color: var(--red); }
.ios-where { display: block; margin-top: 2px; color: var(--muted); font-size: 13px; }
.ios-card .welcome-go { margin-top: 16px; }
.ios-arrow {
  width: 44px; height: 44px; margin-top: 6px; color: #fff; stroke-width: 2.5;
  animation: ios-bounce 1s ease-in-out infinite;
}
@keyframes ios-bounce { 50% { transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { .ios-arrow { animation: none; } }
/* iPad: o Compartilhar fica no alto, à direita */
.ios-guide.ipad { justify-content: center; }
.ios-guide.ipad .ios-arrow { position: absolute; top: calc(env(safe-area-inset-top) + 6px); right: 70px; margin: 0; transform: rotate(180deg); animation: ios-bounce-up 1s ease-in-out infinite; }
@keyframes ios-bounce-up { 50% { transform: rotate(180deg) translateY(8px); } }
/* convite de instalação: mesmo cartão do aviso de versão, logo abaixo dele */
.install { flex-wrap: wrap; }
#update:not([hidden]) ~ .install { top: calc(env(safe-area-inset-top) + 68px); }
.install-x {
  width: 38px; height: 38px; border: 0; background: none; color: var(--muted);
  display: grid; place-items: center; border-radius: 10px; cursor: pointer;
}
.btn.sm { min-height: 38px; padding: 0 14px; font-size: 14px; border-radius: 10px; }
.field textarea {
  font: 500 16px var(--font); color: var(--title); width: 100%; min-height: 96px; resize: vertical;
  background: var(--surface); border: 1.5px solid transparent; border-radius: 10px; padding: 12px; outline: none;
  transition: border-color .15s, background .15s;
}
.field textarea:focus { border-color: var(--red); background: var(--bg); }
.sup-note { margin-top: 12px; font-size: 13px; }

/* ---------- marcadores do mapa ---------- */
.pin {
  width: 34px; height: 34px; border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: var(--red); border: 3px solid #fff;
  display: grid; place-items: center;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .3);
}
.pin span { transform: rotate(45deg); color: #fff; font: 800 13px var(--font); }
.pin.done { background: var(--green); }
.pin.current { background: #151515; transform: rotate(-45deg) scale(1.15); }
/* Motoboy: ponto, círculo de precisão (tamanho em px vem do js) e seta */
.me-wrap { position: relative; width: 18px; height: 18px; }
.me-wrap > i { position: absolute; display: block; }
.me-wrap > i[hidden] { display: none; }
.me { inset: 0; border-radius: 50%; background: #1a73e8; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .3); }
.me-acc {
  left: 50%; top: 50%; transform: translate(-50%, -50%);
  border-radius: 50%; background: rgba(26, 115, 232, .14); border: 1px solid rgba(26, 115, 232, .35);
  pointer-events: none;
}
/* Facho de direção: a base fica no centro do ponto e gira em torno dele */
.me-dir {
  left: 50%; bottom: 50%; width: 40px; height: 38px;
  transform: translateX(-50%); transform-origin: 50% 100%;
  background: linear-gradient(to top, rgba(26, 115, 232, .55), rgba(26, 115, 232, 0));
  clip-path: polygon(50% 100%, 8% 0, 92% 0);
}
.maplibregl-popup-content { border-radius: 12px; font: 500 13px/1.4 var(--font); letter-spacing: var(--tracking); padding: 10px 12px; color: var(--fg); background: var(--bg); }
.maplibregl-popup-tip { border-top-color: var(--bg) !important; }

/* ---------- loja ---------- */
.store-pin { width: 30px; height: 30px; border-radius: 9px; background: #151515; color: #fff; display: grid; place-items: center; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35); }
.store-pin .i { width: 16px; height: 16px; }

/* ---------- câmera ---------- */
.cam { position: fixed; inset: 0; z-index: 3000; background: #000; color: #fff; }
.cam video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cam-frame {
  /* Estreita como um cupom: sobra pouco fundo dos lados (o fundo atrapalha o OCR) */
  position: absolute; left: 50%; transform: translateX(-50%);
  width: min(70vw, calc((100dvh - 230px) / 2.4));
  top: calc(env(safe-area-inset-top) + 76px); bottom: calc(env(safe-area-inset-bottom) + 132px);
  border: 2px solid rgba(255,255,255,.9); border-radius: 18px;
  box-shadow: 0 0 0 100vmax rgba(0,0,0,.45);
  display: flex; align-items: flex-end; justify-content: center;
  pointer-events: none;
}
.cam-hint { margin-bottom: 14px; background: rgba(0,0,0,.6); padding: 8px 14px; border-radius: 999px; font-weight: 700; font-size: 14px; }
.cam-top, .cam-bottom { position: absolute; left: 16px; right: 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cam-top { top: calc(env(safe-area-inset-top) + 16px); }
.cam-bottom { bottom: calc(env(safe-area-inset-bottom) + 28px); }
.cam-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(0,0,0,.55); color: #fff; display: grid; place-items: center; cursor: pointer; }
.cam-btn.on { background: #ffd54a; color: #000; }
.cam-count { font-weight: 800; font-size: 15px; background: rgba(0,0,0,.55); padding: 8px 14px; border-radius: 999px; }
.cam-shot { width: 74px; height: 74px; border-radius: 50%; border: 5px solid #fff; background: var(--red); cursor: pointer; flex: none; }
.cam-shot { transition: var(--press); }
.cam-shot:active { transform: scale(.92); }
.cam-pill { display: inline-flex; align-items: center; gap: 6px; min-width: 112px; justify-content: center; height: 44px; padding: 0 14px; border-radius: 999px; border: 0; background: rgba(0,0,0,.55); color: #fff; font: 700 14px var(--font); cursor: pointer; }
.cam-pill.on { background: #fff; color: #151515; }
.cam-pill .i { width: 18px; height: 18px; }
.cam-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.cam-flash.go { animation: camflash .35s ease-out; }
@keyframes camflash { from { opacity: .85; } to { opacity: 0; } }

/* ---------- fechamento do dia ---------- */
.day-kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.day-kpi { background: var(--surface); border-radius: var(--radius); padding: 12px 14px; }
.day-kpi b { display: block; font-size: 24px; font-weight: 800; color: var(--title); font-variant-numeric: tabular-nums; }
.day-kpi span { font-size: 12px; font-weight: 600; color: var(--muted); }
.day-kpi.money b { color: var(--green); }
.day-rows { list-style: none; margin: 0 0 12px; padding: 0; }
.day-rows li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.day-rows li:last-child { border-bottom: 0; }
.day-rows b { color: var(--title); font-variant-numeric: tabular-nums; }
.day-rows .muted { font-size: 13px; }
.day-empty { color: var(--muted); text-align: center; padding: 20px 0; }
.day-total {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  background: var(--surface); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 6px;
}
.day-total span { font-size: 14px; font-weight: 600; }
.day-total b { font-size: 22px; font-weight: 800; color: var(--title); font-variant-numeric: tabular-nums; }
.day-rows .neg { color: var(--red); }
.day-rows li.total { border-top: 1.5px solid var(--title); border-bottom: 0; margin-top: 2px; padding-top: 10px; font-weight: 700; color: var(--title); }
.day-rows li.total b { font-size: 20px; color: var(--green); }
.day-config { margin: 4px 0 8px; }
.day-config summary { margin-bottom: 10px; }
.day-config .grid { margin-bottom: 4px; }

/* ---------- menos movimento ---------- */
/* Sem deslocamentos: só fades curtos, que ainda mostram o que mudou */
@media (prefers-reduced-motion: reduce) {
  .modal-card { animation: fade .15s ease; }
  .modal.closing .modal-card { animation: fadeout .15s ease forwards; }
  .sheet.animating .slide { transition-duration: .01s; }
  .shimmer, .order.reading.now .num { animation: none; }
  .sheet.entering .slide, .sheet.entering .sheet-footer { animation: fade .15s ease; }
  .toast { transition: opacity .15s ease; }
  .toast.out { transform: none; }
  .update { animation: fade .15s ease; }
  .btn:active, .fab-sm:active, .cam-shot:active { transform: none; }
}
