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

:root {
  --fundo: #f6f3ee;
  --superficie: #ffffff;
  --superficie-2: #efe9e0;
  --texto: #1e1b17;
  --suave: #6e665c;
  --borda: #e1d9cc;
  --destaque: #13744a;
  --destaque-forte: #0d5b39;
  --destaque-texto: #ffffff;
  --destaque-claro: #e1f2e8;
  --perigo: #b42318;
  --perigo-claro: #fdeceb;
  --aviso: #7a5000;
  --aviso-claro: #fff1cc;
  --sombra: 0 1px 2px rgb(30 27 23 / .06), 0 6px 20px rgb(30 27 23 / .06);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fundo: #141210;
    --superficie: #1f1c19;
    --superficie-2: #2b2723;
    --texto: #f3eee7;
    --suave: #a89f94;
    --borda: #3b3630;
    --destaque: #3cb878;
    --destaque-forte: #6ad69c;
    --destaque-texto: #08160e;
    --destaque-claro: #173726;
    --perigo: #ff8a80;
    --perigo-claro: #3a1d1a;
    --aviso: #ffd27a;
    --aviso-claro: #362a10;
    --sombra: 0 1px 2px rgb(0 0 0 / .35), 0 6px 20px rgb(0 0 0 / .25);
    color-scheme: dark;
  }
}

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  background: var(--fundo);
  color: var(--texto);
  -webkit-tap-highlight-color: transparent;
}
body:has(dialog[open]) { overflow: hidden; }
h1, h2, h3 { line-height: 1.2; }
img { display: block; max-width: 100%; }
button, input, textarea { font: inherit; color: inherit; }
a { color: var(--destaque); }
:focus-visible { outline: 3px solid var(--destaque); outline-offset: 2px; }

.container { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 16px; }

/* ---------- Topo da loja ---------- */
.topo { padding-top: 32px; padding-bottom: 20px; }
.topo h1 { margin: 0; font-size: clamp(1.7rem, 6vw, 2.4rem); font-weight: 800; letter-spacing: -0.025em; overflow-wrap: anywhere; }
.recado { margin: 8px 0 0; color: var(--suave); white-space: pre-line; max-width: 60ch; }
.estado { margin: 0; padding: 48px 0; color: var(--suave); text-align: center; }

/* ---------- Grade de produtos ---------- */
.grade {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(156px, 1fr));
  gap: 12px;
  padding-bottom: 120px;
}
@media (min-width: 640px) {
  .grade { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
}

.card { display: flex; flex-direction: column; background: var(--superficie); border-radius: 18px; overflow: hidden; box-shadow: var(--sombra); }
.card-foto { aspect-ratio: 1; background: var(--superficie-2); display: grid; place-items: center; overflow: hidden; }
.card-foto img { width: 100%; height: 100%; object-fit: cover; }
.inicial { font-size: 3rem; font-weight: 800; color: var(--suave); opacity: .55; }
.card-info { flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 12px; }
.card h3 { margin: 0; font-size: 1rem; font-weight: 600; overflow-wrap: anywhere; }
.preco { margin: 4px 0 0; font-size: 1.1rem; font-weight: 800; }
.disp { margin: 0; font-size: .8rem; color: var(--suave); }
.card-acao { margin-top: auto; padding-top: 10px; }
.card.esgotado .card-foto { filter: grayscale(1); opacity: .45; }
.card.esgotado h3, .card.esgotado .preco { color: var(--suave); }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px;
  border: 0; border-radius: 12px;
  font-weight: 700; text-decoration: none; cursor: pointer;
  transition: background-color .15s, transform .1s;
}
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-principal { background: var(--destaque); color: var(--destaque-texto); }
.btn-principal:hover:not(:disabled) { background: var(--destaque-forte); }
.btn-secundario { background: var(--superficie-2); color: var(--texto); }
.btn-perigo { background: var(--perigo-claro); color: var(--perigo); }
.btn-pequeno { min-height: 38px; padding: 6px 12px; font-size: .9rem; border-radius: 10px; }
.largo { width: 100%; }
.link { padding: 0; border: 0; background: none; color: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }

/* ---------- Seletor de quantidade (− 2 +) ---------- */
.stepper { display: flex; align-items: center; justify-content: space-between; min-height: 44px; background: var(--destaque-claro); border-radius: 12px; }
.stepper button { width: 44px; height: 44px; border: 0; border-radius: 12px; background: none; color: var(--destaque-forte); font-size: 1.4rem; font-weight: 700; cursor: pointer; }
.stepper button:disabled { opacity: .3; cursor: not-allowed; }
.stepper span { min-width: 2ch; text-align: center; font-weight: 800; color: var(--destaque-forte); }

/* ---------- Barra "Ver pedido" ---------- */
.barra {
  position: fixed; left: 0; right: 0; bottom: 0;
  padding: 24px 16px calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--fundo) 55%, transparent);
  pointer-events: none;
}
.barra-botao {
  pointer-events: auto;
  display: flex; justify-content: space-between;
  width: 100%; max-width: 520px; min-height: 56px; margin: 0 auto;
  border-radius: 16px; font-size: 1.05rem;
  box-shadow: 0 8px 24px rgb(19 116 74 / .3);
}
.bolha { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 7px; margin-left: 6px; border-radius: 999px; background: rgb(255 255 255 / .22); font-size: .85rem; }

/* ---------- Janela (carrinho / editor) ---------- */
.folha {
  width: min(560px, calc(100% - 32px)); max-height: min(88dvh, 780px);
  padding: 0; border: 0; border-radius: 22px;
  background: var(--superficie); color: var(--texto);
  box-shadow: 0 20px 60px rgb(0 0 0 / .3);
}
.folha[open] { display: flex; flex-direction: column; }
.folha::backdrop { background: rgb(20 18 16 / .5); }
.folha > form { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.folha-topo { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 8px; }
.folha-topo h2 { margin: 0; font-size: 1.3rem; }
.fechar { flex: none; width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--superficie-2); cursor: pointer; }
.folha-corpo { flex: 1; min-height: 0; overflow-y: auto; display: grid; align-content: start; gap: 16px; padding: 8px 20px 16px; }
.folha-rodape { display: flex; gap: 10px; padding: 12px 20px calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--borda); }
.folha-rodape .btn-principal { flex: 1; }
@media (max-width: 640px) {
  .folha { width: 100%; max-width: 100%; max-height: 92dvh; margin: auto 0 0; border-radius: 22px 22px 0 0; }
}
@media (prefers-reduced-motion: no-preference) {
  .folha[open] { animation: subir .22s ease-out; }
}
@keyframes subir { from { transform: translateY(24px); opacity: 0; } }

/* ---------- Itens do carrinho ---------- */
.itens { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.item-carrinho { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center; }
.item-carrinho .nome { font-weight: 600; overflow-wrap: anywhere; }
.item-carrinho .sub { color: var(--suave); font-size: .9rem; }
.item-carrinho .stepper { grid-row: span 2; width: 124px; }
.total-linha { display: flex; justify-content: space-between; align-items: baseline; padding-top: 12px; border-top: 1px dashed var(--borda); font-size: 1.1rem; }
.total-linha strong { font-size: 1.3rem; }

/* ---------- Formulários ---------- */
.campo { display: grid; gap: 6px; font-size: .92rem; font-weight: 600; }
.campo input, .campo textarea {
  width: 100%; padding: 12px 14px;
  border: 1.5px solid var(--borda); border-radius: 12px;
  background: var(--superficie); font-size: 16px; font-weight: 400;
}
.campo textarea { resize: vertical; min-height: 84px; }
.campo input:focus, .campo textarea:focus { outline: none; border-color: var(--destaque); box-shadow: 0 0 0 3px var(--destaque-claro); }
.opcional { font-weight: 400; color: var(--suave); }
.dica { margin: -8px 0 0; color: var(--suave); font-size: .86rem; font-weight: 400; }

.escolha { margin: 0; padding: 0; border: 0; }
.escolha legend { padding: 0; margin-bottom: 6px; font-size: .92rem; font-weight: 600; }
.opcoes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.opcao { position: relative; cursor: pointer; }
.opcao input { position: absolute; opacity: 0; pointer-events: none; }
.opcao span {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px; padding: 12px;
  border: 1.5px solid var(--borda); border-radius: 14px;
  background: var(--superficie); font-weight: 700;
  transition: background-color .15s, border-color .15s;
}
.opcao input:checked + span { border-color: var(--destaque); background: var(--destaque-claro); color: var(--destaque-forte); box-shadow: inset 0 0 0 1px var(--destaque); }
.opcao input:focus-visible + span { outline: 3px solid var(--destaque); outline-offset: 2px; }

.erro { margin: 0; padding: 10px 14px; border-radius: 12px; background: var(--perigo-claro); color: var(--perigo); font-size: .92rem; font-weight: 600; }
.pote { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* ---------- Pedido enviado ---------- */
.sucesso { display: grid; justify-items: center; gap: 8px; padding: 36px 24px calc(24px + env(safe-area-inset-bottom)); text-align: center; }
.sucesso-icone { font-size: 3.5rem; line-height: 1; }
.sucesso h2 { margin: 8px 0 0; font-size: 1.5rem; }
.sucesso p { margin: 0 0 16px; color: var(--suave); overflow-wrap: anywhere; }

/* ---------- Avisos rápidos ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 10;
  width: max-content; max-width: calc(100vw - 32px); padding: 12px 18px;
  border-radius: 999px; background: var(--texto); color: var(--fundo);
  font-weight: 600; text-align: center;
  opacity: 0; transform: translate(-50%, 16px); pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.mostrar { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Painel ---------- */
.admin-topo { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 20px; padding-bottom: 16px; }
.admin-topo h1 { margin: 0; font-size: 1.4rem; }
.admin-topo .acoes { display: flex; gap: 8px; }
.admin-main { max-width: 680px; }
main.admin-main { padding-bottom: 48px; }

.login { display: grid; gap: 16px; max-width: 380px; margin: 12vh auto 0; padding: 28px 24px; border-radius: 20px; background: var(--superficie); box-shadow: var(--sombra); }
.login h1 { margin: 0; font-size: 1.4rem; }

.abas { display: flex; gap: 4px; padding: 4px; margin-bottom: 16px; border-radius: 14px; background: var(--superficie-2); }
.aba { flex: 1; min-height: 42px; border: 0; border-radius: 10px; background: none; color: var(--suave); font-weight: 700; cursor: pointer; }
.aba[aria-selected="true"] { background: var(--superficie); color: var(--texto); box-shadow: var(--sombra); }

.aviso { margin: 0 0 16px; padding: 12px 14px; border-radius: 12px; background: var(--aviso-claro); color: var(--aviso); font-size: .92rem; }

.dica-lista { margin: 12px 0 0; color: var(--suave); font-size: .86rem; text-align: center; }
.lista-admin { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; }
.item { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 16px; background: var(--superficie); box-shadow: var(--sombra); }
.item-abrir { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 4px; border: 0; border-radius: 12px; background: none; text-align: left; cursor: pointer; }
.mini { flex: none; width: 56px; height: 56px; border-radius: 12px; object-fit: cover; background: var(--superficie-2); display: grid; place-items: center; color: var(--suave); font-size: 1.4rem; font-weight: 800; }
.item-texto { min-width: 0; display: grid; }
.item-texto strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-texto span { color: var(--suave); font-size: .9rem; }
.item.zerado .item-texto span { color: var(--perigo); font-weight: 600; }
.item .stepper { flex: none; width: 120px; }
.vazio-admin { padding: 32px 0; color: var(--suave); text-align: center; }

.foto-editor {
  width: 100%; height: 190px; padding: 0;
  display: grid; place-items: center; overflow: hidden;
  border: 2px dashed var(--borda); border-radius: 16px;
  background: var(--superficie-2); color: var(--suave);
  font-weight: 600; text-align: center; cursor: pointer;
}
.foto-editor img { width: 100%; height: 100%; object-fit: cover; }
.foto-editor.tem-foto { border-style: solid; }
.foto-editor .icone { display: block; font-size: 2rem; margin-bottom: 4px; }
.linha-botoes { display: flex; flex-wrap: wrap; gap: 10px; }
.linha-botoes .btn { flex: 1; }
.duas-colunas { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.cartao-form { display: grid; gap: 18px; padding: 20px; border-radius: 18px; background: var(--superficie); box-shadow: var(--sombra); }
.link-loja { display: flex; gap: 8px; }
.link-loja input { flex: 1; min-width: 0; }
