/* Produção e Estoque — Costela em Casa
   Vermelho-vinho é a identidade (cabeçalho e botões). Os alertas de saldo usam um vermelho vivo
   SEMPRE acompanhado de faixa lateral e texto, para não se confundirem com a marca. */
:root {
  --marca: #7A1712; --marca-escura: #5C100D; --marca-clara: #F7ECEA;
  --fundo: #F6F3EF; --cartao: #FFFFFF; --linha: #E3DDD5; --texto: #231F1C; --suave: #6B635C;
  --vermelho: #D0271D; --vermelho-fundo: #FDEBE9;
  --laranja: #B25A00; --laranja-fundo: #FFF1DC;
  --verde: #0A7040; --verde-fundo: #E5F5EC;
  --azul: #1F5FA8; --azul-fundo: #E8F0FA;
  --raio: 12px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--fundo); color: var(--texto); font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 1.3rem; } h3 { font-size: 1.05rem; }
p { margin: 0; }
a { color: var(--marca); }
.carregando { padding: 40px 20px; text-align: center; color: var(--suave); }
.suave { color: var(--suave); } .pequeno { font-size: .87rem; } .centro { text-align: center; }
.num { font-variant-numeric: tabular-nums; }

/* estrutura */
.topo { background: var(--marca); color: #fff; padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top)); display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 20; }
.topo img.logo { height: 46px; width: auto; margin: -4px 0; filter: drop-shadow(0 1px 2px rgba(0,0,0,.35)); }
.topo .marca { font-weight: 700; letter-spacing: .05em; font-size: .82rem; line-height: 1.15; text-transform: uppercase; }
.topo .marca small { display: block; font-weight: 500; opacity: .85; font-size: .78rem; letter-spacing: .04em; text-transform: uppercase; }
.topo .quem { margin-left: auto; text-align: right; font-size: .85rem; line-height: 1.2; }
.topo button { background: transparent; border: 1px solid rgba(255,255,255,.5); color: #fff; border-radius: 8px; padding: 3px 10px; min-height: 30px; margin-top: 3px; font: inherit; font-size: .8rem; }
.faixa-demo { background: #222; color: #FFD66B; text-align: center; font-weight: 700; font-size: .85rem; padding: 5px 10px; letter-spacing: .03em; }
main { max-width: 860px; margin: 0 auto; padding: 16px 14px 110px; display: grid; gap: 14px; }
nav.abas { position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--linha); display: flex; z-index: 20; padding-bottom: env(safe-area-inset-bottom); }
nav.abas a { flex: 1; text-align: center; padding: 9px 2px 8px; text-decoration: none; color: var(--suave); font-size: .74rem; font-weight: 600; position: relative; min-width: 0; }
nav.abas a .ic { display: block; font-size: 1.35rem; line-height: 1.2; }
nav.abas a.ativa { color: var(--marca); box-shadow: inset 0 3px 0 var(--marca); }
nav.abas .bolinha { position: absolute; top: 4px; left: 50%; margin-left: 8px; background: var(--vermelho); color: #fff; border-radius: 10px; font-size: .68rem; padding: 0 6px; min-width: 18px; }
@media (min-width: 860px) {
  nav.abas { position: sticky; top: 56px; bottom: auto; border-top: 0; border-bottom: 1px solid var(--linha); justify-content: center; }
  nav.abas a { flex: 0 0 130px; font-size: .85rem; }
  nav.abas a .ic { display: inline; font-size: 1rem; margin-right: 4px; }
  nav.abas a.ativa { box-shadow: inset 0 -3px 0 var(--marca); }
  main { padding-bottom: 40px; }
}

/* blocos */
.cartao { background: var(--cartao); border: 1px solid var(--linha); border-radius: var(--raio); padding: 14px; display: grid; gap: 10px; }
.linha { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.linha.entre { justify-content: space-between; }
.cresce { flex: 1; min-width: 0; }
.pilha { display: grid; gap: 10px; }
.nota { border-radius: 10px; padding: 10px 12px; font-size: .93rem; background: var(--azul-fundo); color: #123c6b; }
.nota.alerta { background: var(--laranja-fundo); color: #6b3600; }
.nota.erro { background: var(--vermelho-fundo); color: #8a1a13; }
.nota.ok { background: var(--verde-fundo); color: #075230; }
.etq { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: .78rem; font-weight: 700; background: #EEE9E2; color: #4b443e; white-space: nowrap; }
.etq.vermelho { background: var(--vermelho-fundo); color: var(--vermelho); }
.etq.laranja { background: var(--laranja-fundo); color: var(--laranja); }
.etq.verde { background: var(--verde-fundo); color: var(--verde); }
.etq.azul { background: var(--azul-fundo); color: var(--azul); }

/* formulários */
label { font-size: .85rem; font-weight: 600; color: var(--suave); display: grid; gap: 4px; }
input, select, textarea { font: inherit; padding: 12px; border: 1.5px solid #CFC7BD; border-radius: 10px; background: #fff; color: var(--texto); width: 100%; min-height: 48px; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(122,23,18,.25); border-color: var(--marca); }
input[type=checkbox] { width: 22px; height: 22px; min-height: 0; padding: 0; accent-color: var(--marca); }
label.check { display: flex; align-items: center; gap: 10px; font-size: 1rem; color: var(--texto); font-weight: 500; }
button, .botao { font: inherit; font-weight: 700; border: 0; border-radius: 12px; padding: 13px 18px; min-height: 50px; background: var(--marca); color: #fff; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
button:active { background: var(--marca-escura); }
button:disabled { opacity: .5; cursor: default; }
button.grande { width: 100%; min-height: 62px; font-size: 1.15rem; }
button.sec { background: #fff; color: var(--marca); border: 1.5px solid var(--marca); }
button.neutro { background: #EEE9E2; color: var(--texto); }
button.mini { min-height: 38px; padding: 6px 12px; font-size: .88rem; border-radius: 9px; }
button.perigo { background: #fff; color: var(--vermelho); border: 1.5px solid var(--vermelho); }
.segmentos { display: flex; background: #E9E3DB; border-radius: 10px; padding: 3px; }
.segmentos button { flex: 1; min-height: 40px; padding: 6px 10px; background: transparent; color: var(--suave); font-size: .9rem; border-radius: 8px; }
.segmentos button.ativo { background: #fff; color: var(--texto); box-shadow: 0 1px 2px rgba(0,0,0,.15); }

/* estoque */
.saldo { display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid var(--linha); border-left: 8px solid #CFC7BD; border-radius: var(--raio); padding: 12px 14px; text-decoration: none; color: inherit; }
.saldo .nome { flex: 1; min-width: 0; font-weight: 600; }
.saldo .nome small { display: block; font-weight: 500; }
.saldo .qtd { text-align: right; font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; line-height: 1.1; }
.saldo .qtd small { font-size: .85rem; font-weight: 600; color: var(--suave); margin-left: 3px; }
.saldo.vermelho { border-left-color: var(--vermelho); background: var(--vermelho-fundo); }
.saldo.vermelho .qtd { color: var(--vermelho); }
.saldo.vermelho .nome small { color: var(--vermelho); font-weight: 700; }
.saldo.laranja { border-left-color: #E8890C; background: var(--laranja-fundo); }
.saldo.laranja .qtd { color: var(--laranja); }
.saldo.verde { border-left-color: var(--verde); }
.saldo.verde .qtd { color: var(--verde); }

/* folha */
.item-folha { border: 1.5px solid var(--linha); border-radius: 12px; padding: 12px; display: grid; gap: 8px; background: #fff; }
.item-folha.duvida { border-color: #E8890C; background: #FFFAF2; }
.item-folha .duv { color: #8a4500; font-size: .92rem; font-weight: 600; }
.grade2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grade-qtd { display: grid; grid-template-columns: 1fr 130px; gap: 8px; align-items: end; }
.foto-mini { width: 100%; max-height: 220px; object-fit: cover; border-radius: 10px; border: 1px solid var(--linha); cursor: zoom-in; background: #ddd; }
.foto-cheia { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 50; display: flex; align-items: center; justify-content: center; overflow: auto; }
.foto-cheia img { max-width: 100%; }
.lista > * + * { border-top: 1px solid var(--linha); }
.lista .reg { padding: 11px 2px; display: flex; gap: 10px; align-items: center; text-decoration: none; color: inherit; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--linha); vertical-align: top; }
th { font-size: .78rem; color: var(--suave); text-transform: uppercase; letter-spacing: .03em; }
td.dir, th.dir { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rolagem { overflow-x: auto; }
.mais { color: var(--verde); font-weight: 700; } .menos { color: var(--vermelho); font-weight: 700; }

/* login */
.login { max-width: 380px; margin: 8vh auto 0; padding: 0 18px; display: grid; gap: 16px; }
.login .logo { text-align: center; }
.login .logo img { width: min(78%, 280px); height: auto; display: block; margin: 0 auto 4px; }
.login .logo span { font-weight: 700; letter-spacing: .06em; text-transform: uppercase; font-size: .9rem; color: var(--suave); }

#aviso { position: fixed; left: 50%; transform: translateX(-50%); bottom: 96px; z-index: 60; display: grid; gap: 8px; width: min(92vw, 460px); pointer-events: none; }
#aviso div { background: #231F1C; color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.3); font-weight: 600; }
#aviso div.erro { background: #8a1a13; }
dialog { border: 0; border-radius: 16px; padding: 18px; width: min(94vw, 480px); }
dialog::backdrop { background: rgba(0,0,0,.5); }
