/* Estoque das Lojas — visual limpo, pensado primeiro para o celular */
:root {
  --bg: #f7f7f5;
  --card: #ffffff;
  --ink: #15171a;
  --muted: #6b7280;
  --line: #e7e7e2;
  --soft: #f1f1ed;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --accent-soft: #eaf1fe;
  --ok: #1b8a5f;
  --ok-bg: #e8f6ef;
  --warn: #9a6a12;
  --warn-bg: #fff6e0;
  --bad: #c2362b;
  --bad-bg: #fdecea;
  --radius: 14px;
  --abas-h: 62px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1113; --card: #17191c; --ink: #eceef0; --muted: #9aa1aa; --line: #2a2d31; --soft: #1e2124;
    --accent: #5b93f5; --accent-soft: #172235;
    --ok: #4cc38f; --ok-bg: #12261d; --warn: #e3b04b; --warn-bg: #2a2212; --bad: #f0706a; --bad-bg: #2b1715;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: calc(var(--abas-h) + env(safe-area-inset-bottom) + 16px);
}
a { color: inherit; }
[hidden] { display: none !important; }

/* ---------- topo e navegação ---------- */
.topo {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--bg); /* sem backdrop-filter: ele prenderia a barra inferior (fixed) dentro do topo */
  border-bottom: 1px solid var(--line);
}
.marca { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: -.01em; text-decoration: none; }
.marca-ponto { width: 12px; height: 12px; border-radius: 4px; background: var(--accent); transform: rotate(12deg); }
.periodo-chip {
  font-size: 13px; color: var(--muted); text-decoration: none;
  padding: 5px 11px; border: 1px solid var(--line); border-radius: 999px; background: var(--card);
  max-width: 55vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.abas {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line);
}
.abas a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: var(--abas-h); font-size: 12px; color: var(--muted); text-decoration: none;
}
.abas a.ativa { color: var(--accent); font-weight: 600; }

@media (min-width: 820px) {
  body { padding-bottom: 40px; }
  .abas {
    position: static; display: flex; gap: 4px; padding: 0; border: 0; background: none; margin-right: auto; margin-left: 24px;
  }
  .abas a { flex-direction: row; height: 38px; padding: 0 14px; border-radius: 10px; gap: 8px; font-size: 14px; }
  .abas a svg { width: 18px; height: 18px; }
  .abas a.ativa { background: var(--accent-soft); }
}

/* ---------- conteúdo ---------- */
.conteudo { max-width: 1100px; margin: 0 auto; padding: 20px 16px 8px; }
h1 { font-size: 24px; line-height: 1.2; margin: 4px 0 4px; letter-spacing: -.02em; }
h2 { font-size: 17px; margin: 28px 0 10px; letter-spacing: -.01em; }
h3 { font-size: 15px; margin: 0 0 6px; }
.sub { color: var(--muted); margin: 0 0 18px; }
.mini { font-size: 13px; color: var(--muted); }
.cabeca { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.acoes { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.cartao {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px;
}
.cartao > :first-child { margin-top: 0; }
.cartao > :last-child { margin-bottom: 0; }

.aviso { padding: 12px 14px; border-radius: 12px; margin-bottom: 12px; font-size: 15px; border: 1px solid transparent; }
.aviso-ok { background: var(--ok-bg); color: var(--ok); }
.aviso-erro { background: var(--bad-bg); color: var(--bad); }
.aviso-aviso { background: var(--warn-bg); color: var(--warn); }

/* ---------- botões e formulários ---------- */
.botao {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font: inherit; font-weight: 600; font-size: 15px;
  text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.botao:active { transform: translateY(1px); }
.botao-primario { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.botao-perigo { color: var(--bad); }
.botao-pequeno { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.botao-largo { width: 100%; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
label.inline { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; margin: 0; }
input[type=text], input[type=search], input[type=url], input[type=tel], input[type=password],
input[type=number], select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); color: var(--ink); font: inherit; appearance: none; -webkit-appearance: none;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23888' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px;
}
textarea { min-height: 180px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.campo { margin-bottom: 14px; }
.grade { display: grid; gap: 12px 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grade-2 { grid-template-columns: 1fr 1fr; } .grade-3 { grid-template-columns: 1fr 1fr 1fr; } }
.opcoes { display: grid; gap: 8px; }
.opcao {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 1px solid var(--line);
  border-radius: 12px; cursor: pointer; font-weight: 500; margin: 0;
}
.opcao small { display: block; color: var(--muted); font-weight: 400; font-size: 13px; }
.opcao:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

.envio {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  padding: 12px; border: 1.5px dashed var(--line); border-radius: 12px; background: var(--soft); margin-bottom: 14px;
}
.envio input[type=file] { display: none; }
#ocr-status { font-size: 14px; color: var(--muted); }

/* ---------- selos ---------- */
.selo { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--soft); color: var(--muted); white-space: nowrap; }
.selo-ok { background: var(--ok-bg); color: var(--ok); }
.selo-aviso { background: var(--warn-bg); color: var(--warn); }
.selo-erro { background: var(--bad-bg); color: var(--bad); }
.selo-acento { background: var(--accent-soft); color: var(--accent); }

/* ---------- números do topo do resumo ---------- */
.numeros { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.numero { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.numero b { display: block; font-size: 24px; line-height: 1.1; letter-spacing: -.02em; }
.numero span { font-size: 13px; color: var(--muted); }

/* ---------- tabelas ---------- */
.tabela-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; white-space: nowrap; background: var(--card); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.matriz th:first-child, .matriz td:first-child { position: sticky; left: 0; z-index: 1; background: var(--card); min-width: 130px; max-width: 46vw; box-shadow: 1px 0 0 var(--line); }
.matriz td.num { white-space: nowrap; }
.matriz .zero { color: var(--bad); font-weight: 700; }
.matriz .vazio { color: var(--muted); opacity: .5; }
.matriz .total { font-weight: 700; background: var(--soft); }
.matriz tr.categoria td { background: var(--soft); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 6px 12px; }
.matriz .proj { display: block; font-size: 11px; font-weight: 600; line-height: 1.2; }
.matriz .proj-mais { color: var(--ok); }
.matriz .proj-menos { color: var(--warn); }
.matriz th small { display: block; text-transform: none; letter-spacing: 0; font-weight: 400; font-size: 11px; }
.busca { margin-bottom: 12px; }

/* ---------- listas de cadastro ---------- */
.lista { list-style: none; margin: 0; padding: 0; }
.lista li { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); }
.lista li:last-child { border-bottom: 0; }
.lista .titulo { font-weight: 600; }
.lista .detalhe { font-size: 13px; color: var(--muted); }
.lista li.arquivado { opacity: .55; }
.atalhos { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .atalhos { grid-template-columns: 1fr 1fr; } }
.atalho { display: block; text-decoration: none; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.atalho b { display: block; font-size: 17px; }
.atalho span { color: var(--muted); font-size: 14px; }

.vazio-estado { text-align: center; padding: 32px 16px; color: var(--muted); }
.vazio-estado b { display: block; color: var(--ink); font-size: 17px; margin-bottom: 4px; }

/* ---------- revisão do texto lido ---------- */
.linha-leitura { display: grid; gap: 10px 12px; padding: 14px 0; border-bottom: 1px solid var(--line); grid-template-columns: 1fr 104px; align-items: end; }
.linha-leitura:last-child { border-bottom: 0; }
.linha-leitura .orig { grid-column: 1 / -1; font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.linha-leitura.desmarcada { opacity: .45; }
.linha-leitura label { font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 3px; }
.linha-leitura label.inline { font-size: 14px; color: var(--ink); }
.linha-leitura .orig label.inline { font-weight: 600; }
.linha-leitura .nome-col, .linha-leitura .extra { grid-column: 1 / -1; }
@media (min-width: 820px) { .linha-leitura { grid-template-columns: 1fr 140px; } }

.detalhes summary { cursor: pointer; color: var(--muted); font-size: 14px; padding: 6px 0; }
.detalhes pre { white-space: pre-wrap; margin: 6px 0 0; font: 13px/1.5 ui-monospace, Menlo, monospace; color: var(--muted); }

/* ---------- transferências ---------- */
.transf { display: grid; gap: 4px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.transf:last-child { border-bottom: 0; }
.transf .linha { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.transf .rota { color: var(--muted); font-size: 14px; }
.transf.feita { opacity: .6; }
.transf.cancelada { opacity: .45; text-decoration: line-through; }
.dica-estoque { font-size: 13px; color: var(--muted); margin-top: 4px; }
.dica-estoque:empty { display: none; }

@media print {
  .topo, .abas, .acoes, .botao { display: none !important; }
  body { background: #fff; padding: 0; }
}
