:root {
  --verde: #1d6b47;
  --verde-claro: #e3f1e9;
  --verde-forte: #14563a;
  --fundo: #f3f4f1;
  --cartao: #ffffff;
  --texto: #1b1f1c;
  --suave: #69716b;
  --linha: #e4e6e1;
  --perigo: #c2382e;
  --aviso: #b86b00;
  --sombra: 0 1px 2px rgba(20, 30, 24, .06), 0 4px 14px rgba(20, 30, 24, .06);
  --raio: 16px;
  --topo-h: 0px;
  --abas-h: 64px;
  --seg-b: env(safe-area-inset-bottom, 0px);
  --seg-t: env(safe-area-inset-top, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --verde: #3fae7a;
    --verde-claro: #183428;
    --verde-forte: #5cc591;
    --fundo: #101311;
    --cartao: #1a1e1b;
    --texto: #e9ece9;
    --suave: #9aa39c;
    --linha: #2a302c;
    --perigo: #ef6a5f;
    --aviso: #e8a33c;
    --sombra: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fundo);
  color: var(--texto);
  overscroll-behavior-y: none;
}
body.sem-rolagem { overflow: hidden; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { opacity: .35; cursor: default; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }

#app { max-width: 560px; margin: 0 auto; min-height: 100%; position: relative; }

/* abertura */
#app.carregando { display: grid; place-items: center; min-height: 100vh; }
.abertura { text-align: center; color: var(--suave); }
.abertura img { border-radius: 20px; animation: pulsar 1.4s ease-in-out infinite; }
@keyframes pulsar { 50% { transform: scale(.94); opacity: .7; } }

/* topo */
.topo {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--fundo) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  padding: calc(var(--seg-t) + 10px) 16px 10px;
  border-bottom: 1px solid var(--linha);
}
.topo-linha { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.topo h1 { font-size: 26px; line-height: 1.15; margin: 0; letter-spacing: -.02em; }
.topo-sub { display: flex; gap: 10px; align-items: center; font-size: 13px; color: var(--suave); margin-top: 2px; }
.ao-vivo { display: inline-flex; align-items: center; gap: 5px; color: var(--verde); font-weight: 600; }
.ao-vivo i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 0 currentColor; animation: vivo 2s infinite; }
.ao-vivo.fora { color: var(--aviso); }
.ao-vivo.fora i { animation: none; }
@keyframes vivo { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 50%, transparent); } 70% { box-shadow: 0 0 0 6px transparent; } }
.quem::before { content: "·"; margin-right: 10px; }
.icone-btn { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: var(--suave); }
.icone-btn:active { background: var(--linha); }

/* campo de adicionar */
.barra-add { margin-top: 10px; position: relative; }
.campo-add { display: flex; gap: 8px; }
.campo-add input {
  flex: 1; min-width: 0; height: 48px; border-radius: 14px; border: 1px solid var(--linha);
  background: var(--cartao); padding: 0 14px; font-size: 17px; outline: none; box-shadow: var(--sombra);
}
.campo-add input:focus { border-color: var(--verde); box-shadow: 0 0 0 3px color-mix(in srgb, var(--verde) 22%, transparent); }
.add-btn { width: 48px; height: 48px; border-radius: 14px; background: var(--verde); color: #fff; display: grid; place-items: center; flex: none; }
.add-btn:active { transform: scale(.95); }
.add-btn svg { width: 26px; height: 26px; stroke-width: 2.4; }
.previa { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 13px; color: var(--suave); }
.chip-setor {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: color-mix(in srgb, var(--cor) 16%, var(--cartao)); color: var(--texto); border: 1px solid color-mix(in srgb, var(--cor) 40%, transparent);
}
.chip-setor small { color: var(--suave); font-weight: 500; text-decoration: underline; }
.auto {
  position: absolute; left: 0; right: 56px; top: 54px; z-index: 30; background: var(--cartao); border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .18); border: 1px solid var(--linha); overflow: hidden;
}
.auto button { display: flex; justify-content: space-between; width: 100%; padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--linha); }
.auto button:last-child { border-bottom: 0; }
.auto button:active { background: var(--verde-claro); }
.auto small { color: var(--suave); }

/* corpo */
.corpo { padding: 12px 12px calc(var(--abas-h) + var(--seg-b) + 90px); }

.progresso { padding: 4px 6px 12px; }
.progresso-txt { font-size: 14px; color: var(--suave); margin-bottom: 6px; }
.progresso-txt b { color: var(--texto); }
.barra { display: block; height: 6px; border-radius: 99px; background: var(--linha); overflow: hidden; }
.barra i { display: block; height: 100%; background: var(--verde); border-radius: 99px; transition: width .35s ease; }
.barra.fina { height: 4px; margin-top: 6px; }

/* setores */
.setor { background: var(--cartao); border-radius: var(--raio); box-shadow: var(--sombra); margin-bottom: 12px; overflow: hidden; border-left: 4px solid var(--cor); }
.setor h3 { display: flex; align-items: center; gap: 8px; margin: 0; padding: 12px 14px 6px; font-size: 15px; letter-spacing: .01em; }
.setor h3 small { margin-left: auto; color: var(--suave); font-weight: 500; font-size: 13px; }
.setor-ico { font-size: 20px; line-height: 1; }
.setor.pronto { opacity: .62; }
.setor ul { list-style: none; margin: 0; padding: 0 0 4px; }

.item { border-top: 1px solid var(--linha); }
.item:first-child { border-top: 0; }
.item-linha { display: flex; align-items: center; gap: 4px; padding: 4px 4px 4px 10px; min-height: 54px; }
.check {
  width: 30px; height: 30px; border-radius: 9px; border: 2px solid color-mix(in srgb, var(--suave) 60%, transparent);
  display: grid; place-items: center; flex: none; margin-right: 6px; color: transparent; transition: all .15s;
}
.check svg { width: 18px; height: 18px; stroke-width: 3; }
.item.ok .check { background: var(--verde); border-color: var(--verde); color: #fff; }
.item-txt { flex: 1; min-width: 0; padding: 8px 0; cursor: pointer; user-select: none; }
.item-txt .nome { font-size: 17px; }
.item-txt .qtd {
  display: inline-block; margin-left: 8px; font-size: 13px; font-weight: 600; padding: 1px 8px; border-radius: 99px;
  background: var(--verde-claro); color: var(--verde-forte); vertical-align: 2px;
}
.item-txt .sub { display: block; font-size: 12px; color: var(--suave); margin-top: 1px; }
.item.ok .nome { text-decoration: line-through; text-decoration-thickness: 2px; color: var(--suave); }
.item.ok .qtd { opacity: .55; }
.mini { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; color: var(--suave); flex: none; }
.mini:active { background: var(--linha); }
.mini svg { width: 20px; height: 20px; }

.preco-btn {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--verde-claro); color: var(--verde-forte);
}
.preco-btn svg { width: 18px; height: 18px; stroke-width: 2.6; }
.preco-btn.aberto { background: var(--verde); color: #fff; }
.preco-vazio { width: 32px; flex: none; }
.preco-carregando {
  width: 16px; height: 16px; margin: 0 8px; border-radius: 50%; flex: none; display: inline-block; vertical-align: -2px;
  border: 2px solid var(--linha); border-top-color: var(--verde); animation: girar .8s linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }

.painel-precos { margin: 0 10px 10px 46px; display: grid; gap: 6px; }
.mercado-linha {
  display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: start; padding: 10px; border-radius: 12px;
  background: color-mix(in srgb, var(--fundo) 70%, var(--cartao)); font-size: 14px;
}
.mercado-linha.nada { grid-template-columns: auto 1fr auto; align-items: center; color: var(--suave); }
.mercado-tag {
  font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 6px; color: #fff; background: var(--m); align-self: start;
}
.m-info { min-width: 0; }
.m-nome { display: block; font-size: 13px; color: var(--suave); line-height: 1.3; }
.m-preco { display: block; font-size: 17px; font-weight: 700; margin-top: 2px; }
.m-preco.menor { color: var(--verde); }
.m-preco s { font-size: 12px; color: var(--suave); font-weight: 400; }
.m-preco em { font-size: 11px; font-style: normal; font-weight: 600; color: var(--verde-forte); background: var(--verde-claro); padding: 1px 6px; border-radius: 99px; vertical-align: 2px; }
.m-acoes { grid-column: 2; display: flex; gap: 16px; }
.link { color: var(--verde); font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 3px; text-decoration: none; padding: 4px 0; }
.link svg { width: 14px; height: 14px; }

/* resumo de preços */
.cartao { background: var(--cartao); border-radius: var(--raio); box-shadow: var(--sombra); padding: 14px; margin-bottom: 12px; }
.cartao h3 { margin: 0 0 10px; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.cartao h3 small { margin-left: auto; color: var(--suave); font-weight: 500; font-size: 13px; }
.cartao.interno { box-shadow: none; border: 1px solid var(--linha); }
.precos-resumo { margin-top: 18px; }
.mercados { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mercado-total { border-radius: 14px; padding: 12px; border: 2px solid var(--linha); position: relative; }
.mercado-total.vence { border-color: var(--verde); background: var(--verde-claro); }
.mercado-total.vence::after {
  content: "mais barato"; position: absolute; top: -10px; right: 10px; font-size: 11px; font-weight: 700;
  background: var(--verde); color: #fff; padding: 2px 8px; border-radius: 99px;
}
.mt-nome { font-weight: 700; font-size: 14px; color: var(--m); }
.mt-valor { font-size: 24px; font-weight: 800; letter-spacing: -.02em; margin-top: 2px; }
.mt-sub { font-size: 12px; color: var(--suave); }
.comparacao { font-size: 14px; margin: 12px 0 0; }
.nota { font-size: 13px; color: var(--suave); margin: 8px 0; }
.nota.centro { text-align: center; }

/* botões */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px;
  border-radius: 14px; font-weight: 650; font-size: 16px;
}
.btn.primario { background: var(--verde); color: #fff; }
.btn.primario:active { background: var(--verde-forte); }
.btn.fantasma { background: var(--verde-claro); color: var(--verde-forte); }
.btn.perigo { background: color-mix(in srgb, var(--perigo) 12%, var(--cartao)); color: var(--perigo); }
.perigo-txt { color: var(--perigo) !important; background: transparent !important; }
.btn.largo { width: 100%; }
.btn.pequeno { min-height: 34px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn svg { width: 20px; height: 20px; }

.espaco-concluir { height: 8px; }
.concluir {
  position: fixed; left: 50%; transform: translateX(-50%); width: min(560px, 100%); z-index: 15;
  bottom: calc(var(--abas-h) + var(--seg-b)); padding: 10px 12px;
  background: linear-gradient(to top, var(--fundo) 65%, transparent);
}
.concluir .btn { box-shadow: 0 6px 18px color-mix(in srgb, var(--verde) 35%, transparent); min-height: 52px; }

/* vazio */
.vazio { text-align: center; padding: 48px 20px; color: var(--suave); }
.vazio-ico { font-size: 52px; }
.vazio h2 { color: var(--texto); margin: 10px 0 6px; font-size: 20px; }
.vazio p { max-width: 340px; margin: 0 auto 14px; }

/* sugestões */
.bloco-sug { margin-bottom: 18px; }
.bloco-cab { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; padding: 0 6px 8px; }
.bloco-sug h3 { margin: 0; font-size: 17px; }
.bloco-sug p { margin: 2px 0 0; font-size: 13px; color: var(--suave); }
.bloco-sug ul { list-style: none; margin: 0; padding: 0; background: var(--cartao); border-radius: var(--raio); box-shadow: var(--sombra); overflow: hidden; }
details.bloco-sug summary { list-style: none; padding: 0 6px 8px; cursor: pointer; }
details.bloco-sug summary::-webkit-details-marker { display: none; }
details.bloco-sug summary h3::after { content: " ▾"; color: var(--suave); }
details[open].bloco-sug summary h3::after { content: " ▴"; }
.sug { display: flex; align-items: center; gap: 10px; padding: 10px 8px 10px 12px; border-top: 1px solid var(--linha); }
.sug:first-child { border-top: 0; }
.sug-ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; flex: none; background: color-mix(in srgb, var(--cor) 16%, var(--cartao)); }
.sug-txt { flex: 1; min-width: 0; }
.sug-txt .nome { display: block; font-weight: 600; }
.sug-txt .sub { display: block; font-size: 12px; color: var(--suave); }
.quando { display: inline-block; font-size: 12px; font-weight: 700; margin-top: 3px; color: var(--suave); }
.quando.urgente { color: var(--perigo); }
.quando.breve { color: var(--aviso); }
.add-sug { width: 40px; height: 40px; border-radius: 12px; background: var(--verde); color: #fff; display: grid; place-items: center; flex: none; }
.add-sug:active { transform: scale(.94); }

/* histórico */
.acoes-topo { display: flex; justify-content: flex-end; margin-bottom: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 6px 12px; border-radius: 99px; background: var(--verde-claro); color: var(--verde-forte); font-size: 14px; }
.chip b { font-weight: 700; }
button.chip.sel { background: var(--verde); color: #fff; }
.hist { list-style: none; margin: 0; padding: 0; }
.hist li { display: flex; align-items: center; gap: 10px; padding: 4px 0; border-top: 1px solid var(--linha); }
.hist li:first-child { border-top: 0; }
.hist .nome { flex: 1; }
.hist .qtd { color: var(--suave); font-size: 13px; }

/* abas e botão de melhorias */
.abas {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: min(560px, 100%); z-index: 25;
  display: grid; grid-template-columns: repeat(3, 1fr); height: calc(var(--abas-h) + var(--seg-b)); padding-bottom: var(--seg-b);
  background: color-mix(in srgb, var(--cartao) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--linha);
}
.aba { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 12px; color: var(--suave); position: relative; font-weight: 600; }
.aba.ativa { color: var(--verde); }
.aba svg { width: 24px; height: 24px; }
.badge {
  position: absolute; top: 7px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px;
  background: var(--perigo); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center;
}
.fab {
  position: fixed; z-index: 24; right: max(14px, calc(50% - 280px + 14px));
  bottom: calc(var(--abas-h) + var(--seg-b) + 76px);
  display: flex; align-items: center; gap: 6px; height: 44px; padding: 0 14px 0 12px; border-radius: 99px;
  background: var(--cartao); color: var(--verde-forte); box-shadow: 0 6px 20px rgba(0, 0, 0, .16); border: 1px solid var(--linha);
  font-size: 14px; font-weight: 650;
}
.fab svg { width: 20px; height: 20px; }

/* folhas */
#folhas { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
#folhas.aberta { pointer-events: auto; }
.fundo { position: absolute; inset: 0; background: rgba(0, 0, 0, .38); animation: aparecer .2s; }
.folha {
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); width: min(560px, 100%);
  max-height: 88vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--cartao); border-radius: 22px 22px 0 0; padding: 10px 18px calc(22px + var(--seg-b));
  animation: subir .26s cubic-bezier(.2, .9, .3, 1);
}
@keyframes subir { from { transform: translate(-50%, 100%); } }
@keyframes aparecer { from { opacity: 0; } }
.folha-alca { width: 40px; height: 5px; border-radius: 9px; background: var(--linha); margin: 0 auto 8px; }
.folha .fechar { position: absolute; right: 8px; top: 8px; }
.folha h2 { margin: 6px 40px 12px 0; font-size: 21px; letter-spacing: -.01em; }
.folha p { margin: 0 0 10px; }
.sub-tit { font-size: 15px; margin: 20px 0 8px; }
.rotulo { display: block; font-size: 13px; font-weight: 650; color: var(--suave); margin: 12px 0 6px; }
.rotulo input, .rotulo textarea {
  display: block; width: 100%; margin-top: 6px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--linha);
  background: var(--fundo); font-size: 17px; font-weight: 400; color: var(--texto); outline: none; resize: vertical;
}
.rotulo input:focus, .rotulo textarea:focus { border-color: var(--verde); }
.acoes { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.acoes .btn { flex: 1; }
.acoes.coluna { flex-direction: column; }
.grade-setores { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.setor-op {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px; border-radius: 12px; font-size: 12px; font-weight: 600;
  border: 2px solid var(--linha); text-align: center; line-height: 1.2; min-height: 74px; justify-content: center;
}
.setor-op span { font-size: 24px; }
.setor-op.sel { border-color: var(--cor); background: color-mix(in srgb, var(--cor) 16%, var(--cartao)); }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--fundo); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { padding: 9px 6px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--suave); }
.seg button.sel { background: var(--cartao); color: var(--texto); box-shadow: var(--sombra); }
.fb-lista, .lista-simples, .lista-ordem, .produtos { list-style: none; margin: 0; padding: 0; }
.fb-lista li, .lista-simples li, .lista-ordem li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--linha); }
.fb-lista li:first-child, .lista-simples li:first-child, .lista-ordem li:first-child { border-top: 0; }
.fb-txt { flex: 1; font-size: 14px; }
.fb-txt small { display: block; color: var(--suave); font-size: 12px; margin-top: 2px; }
.fb-lista li.feita .fb-txt { opacity: .55; }
.lista-simples .nome, .lista-ordem .nome { flex: 1; }
.lista-ordem li > span:first-child { font-size: 20px; width: 28px; text-align: center; }
.tag { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: color-mix(in srgb, var(--cor) 18%, var(--cartao)); }
.linha-config { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.linha-config svg { vertical-align: -5px; margin-right: 6px; color: var(--verde); }
.linha-config small { color: var(--suave); }
.escolha-dias { margin: 6px 0; }
.produtos li button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border-radius: 12px; text-align: left; }
.produtos li.sel button { background: var(--verde-claro); outline: 2px solid var(--verde); }
.produtos img, .sem-img { width: 52px; height: 52px; object-fit: contain; border-radius: 8px; background: #fff; flex: none; }
.p-nome { flex: 1; font-size: 14px; }
.p-preco { font-weight: 700; white-space: nowrap; }

/* avisos */
#avisos {
  position: fixed; left: 50%; transform: translate(-50%, 20px); z-index: 60; opacity: 0; transition: all .25s; pointer-events: none;
  bottom: calc(var(--abas-h) + var(--seg-b) + 130px); width: max-content; max-width: calc(100% - 32px);
}
#avisos.visivel { opacity: 1; transform: translate(-50%, 0); }
.aviso { background: #1f2622; color: #fff; padding: 11px 16px; border-radius: 14px; font-size: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); text-align: center; }

/* entrada */
.tela-login { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login { width: 100%; max-width: 360px; text-align: center; }
.login img { border-radius: 22px; box-shadow: var(--sombra); }
.login h1 { margin: 12px 0 4px; font-size: 30px; letter-spacing: -.02em; }
.login p { color: var(--suave); margin: 0 0 10px; }
.login form { text-align: left; }
.login .btn { margin-top: 18px; }
.erro { color: var(--perigo); font-size: 14px; min-height: 20px; text-align: center; }
.m-preco small { font-size: 12px; color: var(--suave); font-weight: 500; }
.p-preco small { display: block; font-size: 11px; color: var(--suave); font-weight: 500; }

.topo-botoes { display: flex; align-items: center; gap: 2px; }
.pilula {
  display: inline-flex; align-items: center; gap: 5px; height: 36px; padding: 0 12px 0 10px; border-radius: 99px;
  background: var(--verde-claro); color: var(--verde-forte); font-size: 13px; font-weight: 650;
}
.pilula svg { width: 18px; height: 18px; }
@media (max-width: 350px) { .pilula span { display: none; } }
