/* Base visual compartilhada (herdada do protótipo validado).
   Só o orquestrador edita este arquivo. Telas colocam CSS próprio num <style> da página. */

@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,600..800&family=Schibsted+Grotesk:wght@400..800&display=swap');

:root {
  --azul: #2B59F0;
  --azul-escuro: #1E44C7;
  --azul-claro: #EAF0FF;
  --roxo: #6B46F2;
  --roxo-claro: #F0EBFF;
  --tinta: #151A2D;
  --texto-2: #4A5168;
  --texto-3: #7A8199;
  --fundo: #F5F6FA;
  --superficie: #FFFFFF;
  --borda: #E3E6EE;
  --borda-forte: #CDD2DF;

  --ok: #1E8A55;      --ok-fundo: #E6F6EE;
  --risco: #B76E00;   --risco-fundo: #FFF4DE;
  --atraso: #C8323A;  --atraso-fundo: #FDECEC;
  --hoje: #1E44C7;    --hoje-fundo: #EAF0FF;
  --cliente: #6B46F2; --cliente-fundo: #F0EBFF;
  --neutro: #4A5168;  --neutro-fundo: #ECEEF4;

  --raio: 14px;
  --raio-sm: 10px;
  --raio-pill: 999px;
  --sombra: 0 1px 2px rgba(21, 26, 45, .06), 0 4px 16px rgba(21, 26, 45, .06);
  --sombra-alta: 0 12px 40px rgba(21, 26, 45, .18);

  --lateral: 248px;
  --topo: 64px;
  --nav-inferior: 68px;
  --gutter: 16px;

  --fonte-titulo: 'Bricolage Grotesque', 'Schibsted Grotesk', system-ui, sans-serif;
  font-family: 'Schibsted Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--tinta);
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--fundo); font-size: 15px; line-height: 1.45; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
h1, h2, .topo-titulo, .marca { font-family: var(--fonte-titulo); }
h1 { font-size: 24px; font-weight: 800; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }
p { margin: 0; }
a { color: var(--azul); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--texto-3); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Ícones ---------- */
.ic { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.ic-sm { width: 16px; height: 16px; }
.ic-lg { width: 24px; height: 24px; }

/* ---------- Layout do app ---------- */
.app { min-height: 100vh; }
.lateral {
  position: fixed; inset: 0 auto 0 0; width: var(--lateral);
  background: var(--superficie); border-right: 1px solid var(--borda);
  display: flex; flex-direction: column; padding: 16px 12px; gap: 4px; z-index: 30;
  overflow-y: auto;
}
.marca { display: flex; align-items: center; gap: 10px; padding: 6px 10px 18px; font-weight: 800; font-size: 16px; }
.marca-logo { width: 32px; height: 32px; border-radius: 10px; background: linear-gradient(135deg, var(--azul), var(--roxo)); display: grid; place-items: center; color: #fff; font-size: 14px; font-weight: 800; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--raio-sm);
  color: var(--texto-2); font-weight: 600; font-size: 14px;
}
.nav-item:hover { background: var(--fundo); color: var(--tinta); }
.nav-item.ativo { background: var(--azul-claro); color: var(--azul-escuro); }
.nav-item .badge { margin-left: auto; }
.nav-sub { padding: 2px 0 8px 22px; display: flex; flex-direction: column; gap: 2px; }
.nav-sub a { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 8px; color: var(--texto-2); font-size: 13px; }
.nav-sub a:hover { background: var(--fundo); }
.nav-sub .ponto { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.lateral-rodape { margin-top: auto; border-top: 1px solid var(--borda); padding-top: 12px; }

.principal { margin-left: var(--lateral); min-height: 100vh; display: flex; flex-direction: column; min-width: 0; }
.conteudo, .bloco, .item-texto { min-width: 0; }
.topo {
  position: sticky; top: 0; z-index: 20; height: var(--topo);
  display: flex; align-items: center; gap: 12px; padding: 0 24px;
  background: rgba(245, 246, 250, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--borda);
}
.topo-titulo { font-weight: 800; font-size: 18px; }
.busca {
  flex: 1; max-width: 420px; margin-left: auto; display: flex; align-items: center; gap: 8px;
  background: var(--superficie); border: 1px solid var(--borda); border-radius: var(--raio-pill); padding: 8px 14px; color: var(--texto-3);
}
.busca input { border: 0; outline: 0; background: transparent; width: 100%; }
.conteudo { padding: 24px; width: 100%; max-width: 1400px; }

.prototipo-tag {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--roxo); background: var(--roxo-claro); padding: 4px 8px; border-radius: 6px;
}
.ver-como { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--texto-2); }
.ver-como select { border: 1px solid var(--borda); border-radius: 8px; padding: 6px 8px; background: var(--superficie); }

.nav-inferior { display: none; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: var(--raio-sm); border: 1px solid transparent;
  font-weight: 700; font-size: 14px; cursor: pointer; white-space: nowrap; background: none;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primario { background: var(--azul); color: #fff; }
.btn-primario:hover { background: var(--azul-escuro); }
.btn-roxo { background: var(--roxo); color: #fff; }
.btn-secundario { background: var(--superficie); border-color: var(--borda-forte); color: var(--tinta); }
.btn-secundario:hover { border-color: var(--texto-3); }
.btn-fantasma { color: var(--azul); }
.btn-fantasma:hover { background: var(--azul-claro); }
.btn-perigo { background: var(--superficie); border-color: var(--atraso); color: var(--atraso); }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn-lg { min-height: 52px; padding: 0 22px; font-size: 16px; border-radius: 12px; }
.btn-bloco { width: 100%; }
.btn-icone { width: 40px; padding: 0; }

/* ---------- Chips, etiquetas, badges ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--raio-pill);
  font-size: 12px; font-weight: 700; white-space: nowrap;
}
.chip::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip-ok { color: var(--ok); background: var(--ok-fundo); }
.chip-risco { color: var(--risco); background: var(--risco-fundo); }
.chip-hoje { color: var(--hoje); background: var(--hoje-fundo); }
.chip-atrasada { color: var(--atraso); background: var(--atraso-fundo); }
.chip-cliente { color: var(--cliente); background: var(--cliente-fundo); }
.chip-neutro { color: var(--neutro); background: var(--neutro-fundo); }

.tag {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 6px;
  font-size: 12px; font-weight: 600; color: var(--texto-2); background: var(--neutro-fundo);
}
.tag .ic { width: 14px; height: 14px; }
.badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--raio-pill);
  background: var(--atraso); color: #fff; font-size: 11px; font-weight: 800; display: inline-grid; place-items: center;
}
.badge-azul { background: var(--azul); }

.avatar {
  width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center;
  font-size: 11px; font-weight: 800; color: #fff; flex: none;
}
.avatar-vazio { background: var(--neutro-fundo); color: var(--texto-3); border: 1px dashed var(--borda-forte); }

/* ---------- Superfícies ---------- */
.bloco { background: var(--superficie); border: 1px solid var(--borda); border-radius: var(--raio); box-shadow: var(--sombra); }
.bloco-cab { display: flex; align-items: center; gap: 10px; padding: 16px 18px 12px; }
.bloco-cab h2 { font-size: 16px; }
.bloco-cab .contagem { color: var(--texto-3); font-weight: 700; }
.bloco-cab .acoes { margin-left: auto; display: flex; gap: 8px; }
.bloco-corpo { padding: 0 18px 16px; }

.lista { list-style: none; margin: 0; padding: 0; }
.item {
  display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--borda);
}
.item:first-child { border-top: 0; }
.item-texto { min-width: 0; flex: 1; }
.item-titulo { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-sub { font-size: 13px; color: var(--texto-3); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; margin-top: 2px; }
.item-acao { flex: none; }

.vazio { padding: 24px 18px; color: var(--texto-3); font-size: 14px; }

/* ---------- Miniatura da peça ---------- */
.thumb {
  position: relative; flex: none; border-radius: 10px; overflow: hidden; color: #fff;
  display: flex; align-items: flex-end; justify-content: flex-start; padding: 6px;
  background: linear-gradient(160deg, var(--thumb-a, #8aa0ff), var(--thumb-b, #3a4bb0));
}
.thumb::after { content: ''; position: absolute; inset: 0; background: radial-gradient(circle at 80% 15%, rgba(255,255,255,.35), transparent 45%); }
.thumb .ic { position: relative; z-index: 1; width: 16px; height: 16px; }
.thumb-9x16 { aspect-ratio: 9 / 16; }
.thumb-4x5 { aspect-ratio: 4 / 5; }
.thumb-1x1 { aspect-ratio: 1 / 1; }
.thumb-sem { background: repeating-linear-gradient(45deg, var(--neutro-fundo), var(--neutro-fundo) 6px, #fff 6px, #fff 12px); color: var(--texto-3); border: 1px dashed var(--borda-forte); }
.thumb-sem::after { display: none; }

/* ---------- Card da peça ---------- */
.card-peca {
  display: flex; gap: 12px; padding: 12px; background: var(--superficie); border: 1px solid var(--borda);
  border-radius: var(--raio); box-shadow: var(--sombra); cursor: pointer; position: relative;
}
.card-peca:hover { border-color: var(--borda-forte); }
.card-peca .thumb { width: 54px; }
.card-peca-corpo { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.card-peca-cliente { font-size: 12px; font-weight: 700; color: var(--texto-3); display: flex; align-items: center; gap: 6px; }
.card-peca-cliente .ponto { width: 8px; height: 8px; border-radius: 50%; }
.card-peca-titulo { font-weight: 700; font-size: 14px; line-height: 1.3; }
.card-peca-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.card-peca-rodape { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--texto-2); }
.card-peca-rodape .avatar { width: 22px; height: 22px; font-size: 10px; margin-left: auto; }
.card-peca.selecionado { outline: 2px solid var(--azul); outline-offset: -1px; background: var(--azul-claro); }
.card-check {
  position: absolute; top: 10px; right: 10px; width: 22px; height: 22px; border-radius: 6px;
  border: 2px solid var(--borda-forte); background: #fff; display: grid; place-items: center;
}
.card-peca.selecionado .card-check { background: var(--azul); border-color: var(--azul); color: #fff; }

/* ---------- Abas e segmentado ---------- */
.abas { display: flex; gap: 4px; border-bottom: 1px solid var(--borda); overflow-x: auto; scrollbar-width: none; }
.aba {
  padding: 10px 14px; border: 0; background: none; font-weight: 700; font-size: 14px; color: var(--texto-3);
  border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; white-space: nowrap; display: flex; gap: 6px; align-items: center;
}
.aba.ativa { color: var(--azul); border-bottom-color: var(--azul); }
.seg { display: inline-flex; background: var(--neutro-fundo); border-radius: 12px; padding: 4px; gap: 2px; }
.seg button { border: 0; background: none; padding: 7px 14px; border-radius: 9px; font-weight: 700; font-size: 13px; color: var(--texto-2); cursor: pointer; display: flex; gap: 6px; align-items: center; }
.seg button.ativo { background: var(--superficie); color: var(--tinta); box-shadow: var(--sombra); }

/* ---------- Filtros ---------- */
.filtros { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filtro {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: var(--raio-pill);
  border: 1px solid var(--borda); background: var(--superficie); font-size: 13px; font-weight: 600; cursor: pointer;
}
.filtro.ativo { border-color: var(--azul); background: var(--azul-claro); color: var(--azul-escuro); }

/* ---------- Formulário ---------- */
.campo { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.campo label { font-size: 13px; font-weight: 700; color: var(--texto-2); }
.campo input, .campo select, .campo textarea {
  border: 1px solid var(--borda-forte); border-radius: var(--raio-sm); padding: 10px 12px; background: #fff; min-height: 42px;
}
.campo textarea { min-height: 96px; resize: vertical; }
.campo input:focus, .campo select:focus, .campo textarea:focus { outline: 2px solid var(--azul-claro); border-color: var(--azul); }
.campo .ajuda { font-size: 12px; color: var(--texto-3); }

.aviso { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--raio-sm); font-size: 13px; line-height: 1.4; }
.aviso .ic { margin-top: 1px; }
.aviso-risco { background: var(--risco-fundo); color: #7A4A00; }
.aviso-info { background: var(--azul-claro); color: var(--azul-escuro); }
.aviso-atraso { background: var(--atraso-fundo); color: #8E1F26; }

/* ---------- Painel (lateral no desktop, inferior no celular) ---------- */
.veu { position: fixed; inset: 0; background: rgba(21, 26, 45, .38); z-index: 60; opacity: 0; pointer-events: none; transition: opacity .2s; }
.veu.aberto { opacity: 1; pointer-events: auto; }
.painel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100%); background: var(--superficie); z-index: 70;
  box-shadow: var(--sombra-alta); transform: translateX(100%); transition: transform .25s ease; display: flex; flex-direction: column;
}
.painel.aberto { transform: none; }
.painel-cab { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--borda); }
.painel-cab h2 { flex: 1; }
.painel-corpo { padding: 18px; overflow-y: auto; flex: 1; }
.painel-rodape { padding: 14px 18px; border-top: 1px solid var(--borda); display: flex; gap: 10px; justify-content: flex-end; }

/* ---------- Barra de ações em lote ---------- */
.barra-lote {
  position: fixed; left: calc(var(--lateral) + 24px); right: 24px; bottom: 24px; z-index: 40;
  display: none; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--raio);
  background: var(--tinta); color: #fff; box-shadow: var(--sombra-alta);
}
.barra-lote.visivel { display: flex; }
.barra-lote .btn-secundario { background: transparent; color: #fff; border-color: rgba(255,255,255,.35); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0; z-index: 90;
  background: var(--tinta); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 600; font-size: 14px;
  transition: all .2s; pointer-events: none; max-width: calc(100% - 32px);
}
.toast.visivel { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Barra de progresso segmentada ---------- */
.progresso { display: flex; height: 10px; border-radius: var(--raio-pill); overflow: hidden; background: var(--neutro-fundo); }
.progresso span { display: block; height: 100%; }
.legenda-progresso { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--texto-2); margin-top: 8px; }
.legenda-progresso i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }

/* ---------- Grade de blocos ---------- */
.grade { display: grid; gap: 16px; }
.grade-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grade-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pilha { display: flex; flex-direction: column; gap: 16px; }
.linha { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cab-pagina { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.cab-pagina .sub { color: var(--texto-3); font-size: 14px; margin-top: 4px; }
.cab-pagina .acoes { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Complementos do app real ---------- */
.thumb-img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.thumb-img::after { display: none; }
.thumb-img .ic { position: absolute; left: 6px; bottom: 6px; filter: drop-shadow(0 1px 2px rgba(0,0,0,.5)); }
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.toast-erro { background: var(--atraso); }
.mensagem { white-space: pre-wrap; background: #E7F7EE; border-radius: 12px; padding: 14px; font-size: 14px; line-height: 1.5; color: #12321F; overflow-wrap: anywhere; }
.painel-largo { width: min(760px, 100%); }
.painel-peca { margin-bottom: 14px; }
.ordem-arquivos { margin: 6px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.ordem-arquivos li { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 4px 8px; background: var(--fundo); border-radius: 8px; }
.ordem-arquivos .nome { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gira-90 { transform: rotate(90deg); }
.sino { position: relative; }
.sino .badge { position: absolute; top: 2px; right: 0; min-width: 18px; height: 18px; font-size: 10px; padding: 0 4px; }
.item-peca { cursor: pointer; }
.item-peca:hover { background: #FAFBFD; }
.item-peca .thumb { width: 36px; }
.item .ponto, .card-peca-cliente .ponto { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.lista-mais .item { color: var(--tinta); }
.lista-mais .badge { margin-left: auto; }
.carregando { text-align: center; }
.erro-form ul { margin: 6px 0 0; padding-left: 18px; }
.erro-form { display: block; }
.erro-form[hidden] { display: none; }
.progresso-envio { margin-bottom: 12px; }
:focus-visible { outline: 2px solid var(--azul); outline-offset: 2px; }

/* ---------- Tablet ---------- */
@media (max-width: 1199px) {
  :root { --lateral: 76px; }
  .lateral { padding: 16px 10px; }
  .marca span, .nav-item span, .nav-item .badge, .nav-sub, .lateral-rodape span { display: none; }
  .nav-item { justify-content: center; }
  .grade-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- Celular ---------- */
@media (max-width: 767px) {
  body { font-size: 15px; }
  .lateral { display: none; }
  .principal { margin-left: 0; padding-bottom: calc(var(--nav-inferior) + env(safe-area-inset-bottom)); }
  .topo { padding: 0 var(--gutter); height: 56px; }
  .busca { display: none; }
  .sino { margin-left: auto; }
  .item-peca { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; column-gap: 12px; row-gap: 6px; align-items: start; }
  .item-peca .thumb { grid-row: span 2; }
  .item-peca > .chip { grid-column: 2; justify-self: start; }
  .item-peca .item-acao { grid-column: 3; grid-row: 1 / span 2; align-self: center; }
  .item-peca .item-acao .btn span { display: none; }
  .item-peca .item-acao .btn { width: 40px; padding: 0; }
  .ver-como span { display: none; }
  .conteudo { padding: var(--gutter); }
  h1 { font-size: 21px; }
  .grade-2, .grade-3 { grid-template-columns: 1fr; }
  .cab-pagina { margin-bottom: 14px; }
  .cab-pagina .acoes { margin-left: 0; width: 100%; }

  .nav-inferior {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    height: calc(var(--nav-inferior) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--superficie); border-top: 1px solid var(--borda);
  }
  .nav-inferior a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    font-size: 11px; font-weight: 700; color: var(--texto-3); position: relative;
  }
  .nav-inferior a.ativo { color: var(--azul); }
  .nav-inferior .badge { position: absolute; top: 8px; left: calc(50% + 6px); min-width: 18px; height: 18px; font-size: 10px; }

  .painel { top: auto; left: 0; width: 100%; max-height: 92vh; border-radius: 20px 20px 0 0; transform: translateY(100%); }
  .painel.aberto { transform: none; }
  .painel-cab::before { content: ''; position: absolute; top: 6px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 4px; background: var(--borda-forte); }
  .painel-cab { position: relative; padding-top: 20px; }
  .painel-rodape { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .painel-rodape .btn { flex: 1; }

  .barra-lote { left: 12px; right: 12px; bottom: calc(var(--nav-inferior) + 12px); flex-wrap: wrap; }
  .item { padding: 12px var(--gutter); }
  /* iOS dá zoom ao focar campo com menos de 16px */
  input, select, textarea { font-size: 16px !important; }
  .bloco-cab { padding: 14px var(--gutter) 10px; }
  .bloco-corpo { padding: 0 var(--gutter) 14px; }
}
