:root {
  --fundo: #f6fafc;
  --card: #ffffff;
  --texto: #1f2d3a;
  --suave: #6b7c8a;
  --linha: #e3edf3;
  --marca: #0b7fbd;      /* azul dos botões */
  --marca-esc: #0a6a9e;
  --azul-claro: #e4f3fb; /* azul clarinho (bancos) */
  --rosa: #e47fb4;
  --rosa-bg: #fdeef3;
  --rosa-txt: #b0457d;

  --verde: #1f8a4c;   --verde-bg: #e3f5ea;
  --amarelo: #a86a00; --amarelo-bg: #fff1cc;
  --vermelho: #c62828; --vermelho-bg: #fde3e3;

  --raio: 16px;
  --sombra: 0 2px 12px rgba(31, 80, 110, .07);
  --item-h: 44px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fundo);
  color: var(--texto);
  -webkit-tap-highlight-color: transparent;
  padding-bottom: 110px;
}
button { font: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- Topo ---------- */
.topo {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: #fff;
  border-bottom: 3px solid var(--azul-claro);
  box-shadow: 0 2px 12px rgba(31, 80, 110, .06);
}
.topo::after { /* fio rosa */
  content: ""; position: absolute; left: 0; bottom: -3px; width: 30%; height: 3px; background: var(--rosa);
}
.marca { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: #fff; padding: 3px; border: 1px solid var(--linha);
}
.marca h1 { margin: 0; font-size: 19px; letter-spacing: .2px; color: #0d8fd3; }
.marca p { margin: 0; font-size: 12px; color: var(--suave); }
.sync {
  font-size: 11px; padding: 4px 9px; border-radius: 99px;
  background: var(--azul-claro); color: var(--marca-esc); white-space: nowrap;
}

main { max-width: 640px; margin: 0 auto; padding: 16px; }
.titulo-pagina h2 { margin: 4px 0 2px; font-size: 22px; }
.titulo-pagina p { margin: 0 0 14px; color: var(--suave); font-size: 14px; }

/* ---------- Resumo ---------- */
.resumo { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.resumo div {
  background: var(--card); border-radius: 12px; padding: 8px 6px; text-align: center;
  box-shadow: var(--sombra); border-top: 4px solid var(--linha);
}
.resumo b { display: block; font-size: 20px; }
.resumo span { font-size: 11px; color: var(--suave); }
.resumo .r-verde { border-top-color: var(--verde); }
.resumo .r-amarelo { border-top-color: #e0a100; }
.resumo .r-vermelho { border-top-color: var(--vermelho); }
.resumo .r-acabou { border-top-color: var(--rosa); }

.busca {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--linha);
  background: var(--card); font-size: 16px; margin-bottom: 12px; outline: none;
}
.busca:focus { border-color: var(--marca); }

/* ---------- Lista ---------- */
.lista { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border-radius: var(--raio); padding: 12px 12px 12px 14px;
  box-shadow: var(--sombra); border-left: 5px solid var(--linha);
}
.item.s-verde { border-left-color: var(--verde); }
.item.s-amarelo { border-left-color: #e0a100; }
.item.s-vermelho { border-left-color: var(--vermelho); }
.item.s-zero { border-left-color: var(--linha); }
.info { flex: 1; min-width: 0; }
.info b { display: block; font-size: 16px; }
.info .tam { font-size: 13px; color: var(--suave); }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.tag {
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px;
  background: var(--rosa-bg); color: var(--rosa-txt);
}
.tag.repor { background: var(--vermelho); color: #fff; }
.tag.baixo { background: var(--amarelo-bg); color: var(--amarelo); }

.qtd {
  min-width: 52px; text-align: center; font-weight: 800; font-size: 20px;
  padding: 6px 8px; border-radius: 12px;
}
.qtd.s-verde { background: var(--verde-bg); color: var(--verde); }
.qtd.s-amarelo { background: var(--amarelo-bg); color: var(--amarelo); }
.qtd.s-vermelho { background: var(--vermelho-bg); color: var(--vermelho); }
.qtd.s-zero { background: #eef3f6; color: var(--suave); font-size: 13px; font-weight: 600; }

.icone {
  width: 44px; height: 44px; border-radius: 12px; border: 0;
  background: var(--azul-claro); color: var(--marca-esc); display: grid; place-items: center;
}
.icone svg { width: 20px; height: 20px; }
.icone:active { transform: scale(.95); }

.acoes-rep { display: flex; flex-direction: column; gap: 6px; }
.btn-mini {
  border: 0; border-radius: 10px; padding: 8px 12px; font-size: 13px; font-weight: 600;
  background: var(--marca); color: #fff; white-space: nowrap;
}
.btn-mini.sec { background: #eef3f6; color: var(--suave); }

.vazio {
  text-align: center; color: var(--suave); padding: 28px 16px;
  background: var(--card); border-radius: var(--raio); border: 2px dashed var(--linha);
}
.vazio p { margin: 4px 0; }

/* ---------- Filtros ---------- */
.filtros { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; scrollbar-width: none; }
.filtros button {
  border: 1px solid var(--linha); background: var(--card); color: var(--suave);
  padding: 8px 14px; border-radius: 99px; font-size: 14px; white-space: nowrap;
}
.filtros button.ativo { background: var(--marca); border-color: var(--marca); color: #fff; }

/* ---------- Relatório ---------- */
.relatorio {
  margin-top: 22px; background: var(--card); border-radius: var(--raio);
  padding: 16px; box-shadow: var(--sombra); border-top: 4px solid var(--rosa);
}
.relatorio h3 { margin: 0; }
.sub { margin: 2px 0 12px; color: var(--suave); font-size: 13px; }
.rel-tab { width: 100%; border-collapse: collapse; font-size: 14px; margin-bottom: 14px; }
.rel-tab th { text-align: left; font-size: 12px; color: var(--suave); font-weight: 600; padding: 6px 4px; border-bottom: 2px solid var(--linha); }
.rel-tab td { padding: 8px 4px; border-bottom: 1px solid var(--linha); }
.rel-tab td:last-child, .rel-tab th:last-child { text-align: right; }
.rel-tab .n { font-weight: 800; }
.rel-tab .n.s-amarelo { color: var(--amarelo); }
.rel-tab .n.s-vermelho, .rel-tab .n.s-zero { color: var(--vermelho); }
.rel-ok { padding: 12px; border-radius: 12px; background: var(--verde-bg); color: var(--verde); margin-bottom: 14px; }

.campo { display: block; margin-bottom: 12px; }
.campo span { display: block; font-size: 13px; color: var(--suave); margin-bottom: 4px; }
.campo input { width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--linha); font-size: 16px; }

.btn {
  border: 0; border-radius: 14px; padding: 14px 18px; font-weight: 700; font-size: 16px;
  background: #eef3f6; color: var(--texto);
}
.btn.primario { background: var(--marca); color: #fff; }
.btn.primario:active { background: var(--marca-esc); }
.btn.largo { width: 100%; }

/* ---------- FAB ---------- */
.fab {
  position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 20;
  display: flex; align-items: center; gap: 8px;
  background: var(--marca); color: #fff; text-decoration: none; font-weight: 700;
  padding: 14px 20px 14px 16px; border-radius: 99px;
  box-shadow: 0 8px 24px rgba(11, 127, 189, .35);
}
.fab:active { transform: scale(.97); }
.fab-ico { font-size: 20px; }
.fab-badge {
  position: absolute; top: -6px; right: -4px; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 99px; background: var(--rosa); color: #fff; font-size: 12px; font-weight: 800;
  display: grid; place-items: center; border: 2px solid #fff;
}

/* ---------- Sheet + roda (wheel picker 3D) ---------- */
.sheet-fundo {
  position: fixed; inset: 0; z-index: 50; background: rgba(31, 45, 58, .4);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .15s ease;
}
.sheet {
  width: 100%; max-width: 480px; background: var(--card);
  border-radius: 24px 24px 0 0; padding: 10px 18px calc(18px + env(safe-area-inset-bottom));
  animation: sobe .22s ease;
}
.sheet-alca { width: 44px; height: 5px; border-radius: 9px; background: var(--linha); margin: 0 auto 12px; }
.sheet h3 { margin: 0; text-align: center; font-size: 19px; }
.sheet .sub { text-align: center; }
@keyframes fade { from { opacity: 0; } }
@keyframes sobe { from { transform: translateY(40px); opacity: .4; } }

.roda-wrap { position: relative; height: calc(var(--item-h) * 5); margin: 4px 0 6px; }
.roda-faixa {
  position: absolute; left: 0; right: 0; top: calc(var(--item-h) * 2); height: var(--item-h);
  background: #eff3f6; border-radius: 12px; pointer-events: none;
}
.roda {
  position: relative; height: 100%; overflow-y: auto; scroll-snap-type: y mandatory;
  scrollbar-width: none; outline: none; perspective: 700px;
  user-select: none; cursor: grab; overscroll-behavior: contain;
  -webkit-mask-image: linear-gradient(transparent, #000 32%, #000 68%, transparent);
          mask-image: linear-gradient(transparent, #000 32%, #000 68%, transparent);
}
.roda::-webkit-scrollbar { display: none; }
.roda.arrastando { cursor: grabbing; scroll-snap-type: none; }
.roda:focus-visible + .roda-faixa, .roda:focus-visible { box-shadow: none; }
.roda-pad { height: calc(var(--item-h) * 2); }
.roda-item {
  height: var(--item-h); scroll-snap-align: center;
  display: grid; place-items: center;
  font-size: 22px; font-weight: 600; color: #aab7c1;
  font-variant-numeric: tabular-nums;
  transform-origin: center center; backface-visibility: hidden; will-change: transform;
}
.roda-item.sel { color: var(--texto); font-weight: 800; font-size: 26px; }
.roda-item.sel.s-verde { color: var(--verde); }
.roda-item.sel.s-amarelo { color: #c98a00; }
.roda-item.sel.s-vermelho { color: var(--vermelho); }

.extra { text-align: center; min-height: 18px; margin: 4px 0 8px; font-size: 13px; color: var(--suave); }

.digitar { display: flex; justify-content: center; margin-bottom: 14px; }
.btn-digitar {
  border: 1px dashed var(--marca); background: var(--azul-claro); color: var(--marca-esc);
  border-radius: 99px; padding: 8px 16px; font-size: 14px; font-weight: 600;
}
.digitar-campo { display: flex; align-items: center; gap: 8px; }
.digitar-campo input {
  width: 120px; padding: 10px 12px; border-radius: 12px; border: 2px solid var(--marca);
  font-size: 22px; font-weight: 700; text-align: center; outline: none;
}
.digitar-campo span { color: var(--suave); font-size: 14px; }

.sheet-acoes { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 60;
  background: var(--texto); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px;
  box-shadow: var(--sombra); max-width: 90vw; text-align: center;
}

/* ---------- Novo sabor / medida ---------- */
.btn-novo {
  width: 100%; margin-bottom: 12px; padding: 12px; border-radius: 12px;
  border: 2px dashed var(--rosa); background: var(--rosa-bg); color: var(--rosa-txt);
  font-weight: 700; font-size: 15px;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--linha); background: #fff; color: var(--texto);
  padding: 8px 12px; border-radius: 99px; font-size: 14px;
}
.chip.on { background: var(--marca); border-color: var(--marca); color: #fff; font-weight: 600; }
.chip.on::before { content: "✓ "; }
.chip:disabled { background: #eef3f6; color: #a3b1bc; border-style: dashed; cursor: default; }
.chip:disabled::after { content: " · já existe"; font-size: 11px; }
.nova-medida { display: flex; gap: 8px; }
.nova-medida input { flex: 1; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--linha); font-size: 16px; }
.campo small { color: var(--suave); }
#form-novo .campo > input { width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--linha); font-size: 16px; }

/* ---------- Filtro de tamanho (conferência) ---------- */
.filtros small {
  display: inline-block; min-width: 20px; margin-left: 4px; padding: 0 6px; border-radius: 99px;
  background: var(--azul-claro); color: var(--marca-esc); font-size: 12px; font-weight: 700;
}
.filtros button.ativo small { background: rgba(255,255,255,.25); color: #fff; }

/* ---------- Usuário (topo) ---------- */
.topo-dir { display: flex; align-items: center; gap: 8px; position: relative; }
.btn-usuario { border: 0; background: none; padding: 0; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--rosa-bg); color: var(--rosa-txt); font-weight: 800; font-size: 15px;
  border: 2px solid var(--rosa);
}
.menu {
  position: absolute; top: calc(100% + 8px); right: 0; min-width: 210px; z-index: 30;
  background: #fff; border-radius: 14px; box-shadow: 0 10px 30px rgba(31, 45, 58, .18);
  padding: 6px; display: flex; flex-direction: column;
}
.menu-quem { padding: 10px 12px 8px; border-bottom: 1px solid var(--linha); margin-bottom: 4px; }
.menu-quem b { display: block; }
.menu-quem span { font-size: 12px; color: var(--suave); }
.menu a, .menu button {
  text-align: left; padding: 10px 12px; border-radius: 10px; border: 0; background: none;
  color: var(--texto); text-decoration: none; font-size: 15px;
}
.menu a:hover, .menu button:hover { background: var(--azul-claro); }
body:not(.adm) .so-adm { display: none !important; }

/* ---------- Login ---------- */
.tela-login {
  position: fixed; inset: 0; z-index: 70; background: var(--fundo);
  display: grid; place-items: center; padding: 20px; overflow-y: auto;
}
.cartao-login {
  width: 100%; max-width: 380px; background: #fff; border-radius: 20px; padding: 24px 20px;
  box-shadow: var(--sombra); border-top: 4px solid var(--rosa); text-align: center;
}
.cartao-login h2 { margin: 8px 0 2px; color: var(--marca-esc); }
.cartao-login .campo { text-align: left; }
.erro-form { color: var(--vermelho); font-size: 14px; min-height: 18px; margin: 4px 0 10px; }
body.sem-login main, body.sem-login .fab { display: none; }

/* ---------- Quem mexeu por último ---------- */
.por { display: block; font-size: 11.5px; color: var(--suave); margin-top: 2px; }

/* ---------- Equipe ---------- */
.cartao { background: #fff; border-radius: var(--raio); padding: 16px; box-shadow: var(--sombra); margin-bottom: 14px; }
.cartao h3 { margin: 0 0 10px; }
.grade-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
@media (max-width: 480px) { .grade-2 { grid-template-columns: 1fr; } }
.campo select, .hist-filtros select {
  width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--linha);
  font-size: 16px; background: #fff;
}
.item.inativo { opacity: .55; }
.tag.adm { background: var(--azul-claro); color: var(--marca-esc); }

/* ---------- Histórico ---------- */
.hist-filtros { display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; }
.hist-filtros select { margin-bottom: 12px; }
.hist-dia { font-size: 13px; font-weight: 700; color: var(--marca-esc); margin: 14px 2px 6px; }
.hist-item {
  display: grid; grid-template-columns: 52px 1fr; gap: 10px; align-items: start;
  background: #fff; border-radius: 12px; padding: 10px 12px; margin-bottom: 6px; box-shadow: var(--sombra);
}
.hist-hora { font-variant-numeric: tabular-nums; color: var(--suave); font-size: 13px; padding-top: 1px; }
.hist-quem { font-weight: 700; font-size: 14px; }
.hist-texto { font-size: 14px; color: var(--texto); }
