/* ===== Estética Claude — quente, limpa, tátil (tablet/chão de fábrica) ===== */
:root {
  --bg: #f5f4ef;
  --surface: #ffffff;
  --surface-2: #faf9f5;
  --ink: #2d2a26;
  --ink-soft: #6b6560;
  --line: #e6e2da;
  --accent: #3f6f5e;      /* verde-petróleo — distingue do apontamento */
  --accent-ink: #ffffff;
  --ok: #2f7d53;
  --warn: #c98a1e;
  --danger: #c0392b;
  --radius: 16px;
  --shadow: 0 2px 8px rgba(45,42,38,.06), 0 1px 2px rgba(45,42,38,.08);
  --shadow-lg: 0 8px 28px rgba(45,42,38,.12);
  font-size: 17px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #23241f; --surface: #2c2e27; --surface-2: #32342c;
    --ink: #f0ede6; --ink-soft: #b0a89f; --line: #3f4137;
    --accent: #5c9484; --shadow: none; --shadow-lg: 0 8px 28px rgba(0,0,0,.4);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  background: var(--bg); color: var(--ink);
  line-height: 1.45; -webkit-font-smoothing: antialiased;
  /* Chrome/Android ignora cada vez mais o user-scalable=no do viewport (por
     acessibilidade) — isso desativa o zoom por duplo-toque de forma
     confiável, sem bloquear o scroll normal da tela. */
  touch-action: manipulation;
}
#app { min-height: 100%; display: flex; flex-direction: column; }

/* ===== Topbar ===== */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; background: var(--surface);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  font-size: 22px; color: var(--accent);
  width: 42px; height: 42px; display: grid; place-items: center;
  background: var(--surface-2); border-radius: 12px; border: 1px solid var(--line);
}
.brand-title { font-weight: 700; font-size: 1.02rem; }
.brand-sub { font-size: .78rem; color: var(--ink-soft); }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.user-chip {
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 6px 14px; border-radius: 999px; font-weight: 600; font-size: .9rem;
}

/* ===== Layout de tela ===== */
.screen { flex: 1; width: 100%; max-width: 820px; margin: 0 auto; padding: 24px 20px 100px; }
.screen.center { display: flex; align-items: center; justify-content: center; }
.screen.narrow { max-width: 480px; }
.section { margin-top: 28px; }
.section h2 { font-size: 1rem; color: var(--ink-soft); margin-bottom: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
h1 { font-size: 1.6rem; margin-bottom: 16px; }
.muted { color: var(--ink-soft); }
.small { font-size: .85rem; }
code { background: var(--surface-2); padding: 2px 6px; border-radius: 6px; font-size: .85em; border: 1px solid var(--line); }

/* ===== Botões ===== */
.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; border-radius: 12px;
  padding: 11px 18px; transition: transform .05s, background .15s, box-shadow .15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:active { transform: scale(.97); }
.btn-lg { padding: 16px 22px; font-size: 1.08rem; border-radius: 14px; }
.btn-block { display: flex; width: 100%; }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-warn { background: var(--warn); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }

/* ===== Login / Keypad ===== */
.login-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 22px;
  padding: 34px 30px; box-shadow: var(--shadow-lg); text-align: center; width: 100%; max-width: 380px;
}
.login-card h1 { margin-bottom: 4px; }
.pin-display {
  font-size: 2rem; letter-spacing: .3em; margin: 22px 0; font-weight: 700;
  color: var(--accent); min-height: 44px;
}
.pin-display.shake { animation: shake .4s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-8px)} 75%{transform:translateX(8px)} }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.key {
  font: inherit; font-size: 1.5rem; font-weight: 600; padding: 18px 0;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px;
  cursor: pointer; color: var(--ink); transition: transform .05s, background .15s;
}
.key:active { transform: scale(.94); background: var(--line); }
.key-ok { background: var(--accent); color: #fff; border-color: var(--accent); }
.key-clear { background: var(--surface); color: var(--danger); }

/* ===== Home: cards de peritagem ===== */
.empty-active { text-align: center; padding: 40px 0; }
.empty-active .btn { margin-top: 16px; }
.list { display: flex; flex-direction: column; gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); cursor: pointer;
}
.card-rascunho { border-left: 5px solid var(--warn); }
.card-finalizada { border-left: 5px solid var(--ok); }
.card-tag { font-size: .72rem; font-weight: 800; letter-spacing: .06em; margin-bottom: 6px; }
.tag-rascunho { color: var(--warn); }
.tag-finalizada { color: var(--ok); }
.os-num { font-size: 1.4rem; font-weight: 800; }
.os-meta { font-size: .85rem; color: var(--ink-soft); margin: 4px 0 10px; }
.progress-bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--line); }
.progress-bar > div { height: 100%; background: var(--accent); border-radius: 999px; transition: width .2s; }
.progress-label { font-size: .78rem; color: var(--ink-soft); margin-top: 6px; }
.card-actions { display: flex; gap: 10px; margin-top: 14px; }
.card-actions .btn { flex: 1; }

/* ===== Formulário Nova Peritagem ===== */
.form-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow); margin-top: 12px;
}
.field-label { display: block; font-weight: 700; margin: 20px 0 8px; }
.input, select.input {
  width: 100%; font: inherit; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
}
.input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.input-lg { font-size: 1.3rem; padding: 15px 16px; font-weight: 600; }
.os-input-row { display: flex; gap: 10px; }
.os-input-row .input { flex: 1; }
.os-info { margin-top: 12px; }
.os-info-ok {
  background: rgba(47,125,83,.1); border: 1px solid rgba(47,125,83,.35);
  color: var(--ok); padding: 12px 14px; border-radius: 12px;
}
.os-info-ok div { color: var(--ink); }
.os-info-erro {
  background: rgba(192,57,43,.08); border: 1px solid rgba(192,57,43,.35);
  color: var(--danger); padding: 12px 14px; border-radius: 12px; font-weight: 600;
}

/* Checagem de OS duplicada (tela Nova peritagem) */
.os-dup {
  margin-top: 10px; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface-2); line-height: 1.45;
}
.os-dup div { margin-top: 4px; }
.os-dup-bloqueada {
  border-color: var(--danger); color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, var(--surface));
}
.os-dup-bloqueada div:not(.muted) { color: var(--ink); }
.os-dup-minha {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
}
.os-dup-finalizada {
  border-color: var(--warn);
  background: color-mix(in srgb, var(--warn) 12%, var(--surface));
}

/* ===== Navegação de seções (formulário de peritagem) ===== */
.secoes-nav {
  display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 12px;
  position: sticky; top: 66px; background: var(--bg); z-index: 9; margin-bottom: 8px;
}
.secoes-nav::-webkit-scrollbar { display: none; }
.secao-chip {
  /* A2: alvo de toque maior (≥44px de altura) — mais fácil de acertar com o
     dedo/luva no celular. */
  flex: 0 0 auto; font: inherit; font-size: .9rem; font-weight: 600; padding: 11px 17px;
  min-height: 44px; display: inline-flex; align-items: center;
  border-radius: 999px; background: var(--surface); border: 1px solid var(--line);
  color: var(--ink-soft); cursor: pointer; white-space: nowrap; position: relative;
}
.secao-chip.ativa { background: var(--accent); color: #fff; border-color: var(--accent); }
.secao-chip.feita { border-color: rgba(47,125,83,.5); }
.secao-chip.na { opacity: .5; text-decoration: line-through; }
.secao-chip .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); margin-left: 6px; vertical-align: middle; }
.secao-chip.ativa .dot { background: #fff; }
.secao-chip .na-x { margin-left: 6px; font-size: .72rem; color: var(--ink-soft); }
.secao-chip.ativa .na-x { color: rgba(255,255,255,.85); }

.progress-topo { margin-bottom: 4px; }

/* Navegação: contador + botão índice */
.nav-topo { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; }
.nav-contador { font-size: .82rem; color: var(--ink-soft); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-contador strong { color: var(--ink); }
.btn-indice { flex: 0 0 auto; padding: 7px 13px; font-size: .85rem; }

/* Índice (modal para pular direto a qualquer seção) */
.indice-grid { display: flex; flex-direction: column; gap: 6px; max-height: 62vh; overflow-y: auto; margin-top: 8px; }
.indice-item {
  display: flex; align-items: center; gap: 12px; text-align: left; font: inherit; cursor: pointer;
  padding: 11px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink);
}
.indice-item:active { transform: scale(.99); }
.indice-item.atual { border-color: var(--accent); background: rgba(63,111,94,.14); }
.indice-item.na { opacity: .55; text-decoration: line-through; }
.indice-num {
  width: 26px; height: 26px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--line); font-size: .78rem; font-weight: 700;
}
.indice-item.feita .indice-num { background: rgba(47,125,83,.15); border-color: rgba(47,125,83,.4); color: var(--ok); }
.indice-txt { flex: 1; }
.indice-badge { font-weight: 800; color: var(--ok); }
.indice-item.na .indice-badge { color: var(--ink-soft); }

.campo-bloco { margin-bottom: 22px; }
.campo-bloco > label { display: block; font-weight: 700; margin-bottom: 8px; font-size: .95rem; }
.campo-unidade { display: flex; align-items: center; gap: 8px; }
.campo-unidade .input { flex: 1; }
.campo-unidade .unidade { color: var(--ink-soft); font-size: .85rem; min-width: 28px; }

.campo-escala { display: flex; align-items: center; gap: 8px; }
.campo-escala .input-escala { flex: 0 0 88px; }
.campo-escala > input.input { flex: 1; }

.chips-grupo { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-opcao {
  font: inherit; font-size: .85rem; padding: 10px 14px; border-radius: 12px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink);
  transition: all .12s;
}
.chip-opcao:active { transform: scale(.96); }
.chip-opcao.selecionada { background: var(--accent); color: #fff; border-color: var(--accent); }

.campo-calc { position: relative; }
.campo-calc label::after { content: ' (cálculo — preencher manualmente por ora)'; font-weight: 400; font-size: .75rem; color: var(--ink-soft); }

.campo-material-compra {
  background: rgba(63,111,94,.1); border: 1px solid rgba(63,111,94,.35);
  border-radius: 14px; padding: 14px 16px 4px;
}
.campo-material-compra label { color: var(--accent); }

/* Resumo consolidado de materiais para compra (seção "Materiais especificados") */
.resumo-compras {
  background: rgba(63,111,94,.1); border: 1px solid rgba(63,111,94,.35);
  border-radius: 14px; padding: 14px 16px; margin-bottom: 18px;
}
.resumo-compras-titulo { color: var(--accent); font-weight: 700; margin-bottom: 10px; }
.resumo-compras-grupo { margin-bottom: 10px; }
.resumo-compras-secao {
  font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em;
  color: var(--ink-soft); border-bottom: 1px solid var(--line); padding-bottom: 3px; margin-bottom: 4px;
}
.resumo-compras-item { margin: 3px 0; line-height: 1.4; }
.resumo-compras-rotulo { font-weight: 600; }
.resumo-compras p { margin: 8px 0 0; }
.resumo-compras-vazio { opacity: .85; }

/* ===== Cálculos (tolerância / resultado) ===== */
.calc-resumo {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 18px;
}
.calc-resumo > div { margin: 2px 0; }
.calc-box {
  font-weight: 700; padding: 12px 14px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--line);
}
.calc-box.ok { background: rgba(47,125,83,.12); border-color: rgba(47,125,83,.4); color: var(--ok); }
.calc-box.fora { background: rgba(192,57,43,.1); border-color: rgba(192,57,43,.4); color: var(--danger); }
.calc-box.muted { color: var(--ink-soft); font-weight: 400; }
.mp-verdito { font-weight: 800; padding: 2px 8px; border-radius: 8px; }
.mp-verdito.ok { background: rgba(47,125,83,.15); color: var(--ok); }
.mp-verdito.fora { background: rgba(192,57,43,.12); color: var(--danger); }

/* ===== Matéria-prima (cards) ===== */
.mp-card {
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.mp-titulo { font-weight: 800; font-size: 1.05rem; margin-bottom: 4px; }
.mp-card > .input { margin: 6px 0 4px; }
/* Textarea de matéria-prima: cresce sozinha pro texto nunca ficar cortado
   (descrição calculada costuma passar do que cabe numa linha só no celular).
   Altura real é ajustada via JS (ajustarAlturaTextareasMp em app.js). */
.mp-input {
  display: block; resize: none; overflow: hidden; line-height: 1.4;
  font-family: inherit; white-space: pre-wrap; word-break: break-word;
}
.mp-desc { font-size: 1rem; }
.mp-meta { font-size: .88rem; color: var(--ink-soft); margin-top: 4px; }
.mp-obs { font-size: .82rem; color: var(--warn); margin-top: 6px; }

/* ===== Seletor de rótula comercial (busca reversa) ===== */
.rotula-picker {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 18px;
}
.rotula-titulo { font-weight: 700; margin-bottom: 8px; }
.rotula-lista { display: flex; flex-direction: column; gap: 8px; }
.rotula-opcao {
  font: inherit; text-align: left; cursor: pointer;
  display: flex; flex-direction: row; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px 10px 14px; color: var(--ink); transition: all .12s;
}
.rotula-opcao:active { transform: scale(.98); }
.rotula-opcao.selecionada { background: var(--accent); color: #fff; border-color: var(--accent); }
.rotula-opcao.selecionada .muted { color: rgba(255,255,255,.85); }
.rotula-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rotula-ref { font-weight: 800; }
.rotula-thumb {
  position: relative; flex: 0 0 auto; width: 58px; height: 58px; border-radius: 10px; overflow: hidden;
  background: #fff; border: 1px solid var(--line); cursor: zoom-in;
  display: flex; align-items: center; justify-content: center;
}
.rotula-thumb img { width: 100%; height: 100%; object-fit: contain; }
.rotula-thumb::after {
  content: '🔍'; position: absolute; right: 2px; bottom: 2px; font-size: .62rem; line-height: 1;
  background: rgba(0,0,0,.55); border-radius: 5px; padding: 2px 3px; pointer-events: none;
}

/* Lightbox de imagem (amplia a foto do catálogo — padrão GabrielSeal) */
.img-lightbox {
  display: none; position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,.6);
  align-items: center; justify-content: center; padding: 24px;
}
.img-lightbox.open { display: flex; }
.img-lightbox .lb-card {
  background: var(--surface); border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.5);
  max-width: min(720px, 94vw); max-height: 92vh; overflow: auto; padding: 22px 24px; position: relative;
}
.img-lightbox .lb-close {
  position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); font-size: 16px; cursor: pointer;
}
.img-lightbox .lb-title { font-weight: 700; color: var(--accent); margin-bottom: 16px; padding-right: 40px; }
.img-lightbox .lb-imgs { display: flex; justify-content: center; }
.img-lightbox figure {
  margin: 0; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px;
}
.img-lightbox figcaption { font-size: .75rem; color: var(--ink-soft); margin-bottom: 8px; text-align: center; }
.img-lightbox img { max-width: 100%; max-height: 70vh; height: auto; display: block; }
.rotula-escolhido {
  background: rgba(47,125,83,.12); border: 1px solid rgba(47,125,83,.4);
  border-radius: 12px; padding: 10px 14px; margin-bottom: 18px;
}
.rotula-escolhido.rotula-personalizada {
  background: rgba(192,120,40,.14); border-color: rgba(192,120,40,.45);
}
.btn-limpar-rotula {
  font: inherit; font-size: .8rem; margin-left: 8px; cursor: pointer;
  background: transparent; border: 1px solid var(--line); border-radius: 8px;
  padding: 3px 10px; color: var(--ink-soft);
}

/* ===== Captura de foto (galeria multi-foto) ===== */
.foto-tile {
  border: 2px dashed var(--line); border-radius: 14px; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  gap: 8px; padding: 22px; cursor: pointer; color: var(--ink-soft); text-align: center;
  min-height: 110px;
}
.foto-tile:active { transform: scale(.98); }
.foto-tile .icone { font-size: 1.6rem; }
.foto-galeria { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.foto-galeria .foto-tile-row { grid-column: 1 / -1; display: flex; gap: 10px; }
.foto-galeria .foto-tile-row .foto-tile-add { flex: 1; min-height: 110px; padding: 12px; }
.foto-tile-galeria {
  flex: 0 0 64px; display: flex; align-items: center; justify-content: center;
  border: 2px dashed var(--line); border-radius: 14px; background: var(--surface-2);
  cursor: pointer; color: var(--ink-soft); font-size: 1.5rem;
}
.foto-tile-galeria:active { transform: scale(.94); }
.foto-item { position: relative; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); }
.foto-item img { width: 100%; height: 150px; object-fit: cover; display: block; }
.foto-item .foto-nome { font-size: .65rem; padding: 6px 8px; color: var(--ink-soft); word-break: break-all; }
.foto-item .btn-remover-foto {
  position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.6); color: #fff;
  border: none; border-radius: 10px; padding: 4px 9px; font-weight: 700; cursor: pointer;
}
.foto-badge {
  position: absolute; top: 6px; left: 6px; font-size: .65rem; font-weight: 800;
  padding: 3px 7px; border-radius: 8px; letter-spacing: .03em;
}
.foto-badge.principal { background: rgba(47,125,83,.85); color: #fff; }
.foto-badge.extra { background: rgba(0,0,0,.55); color: #fff; }

/* A5: fotos de evidência (não a principal da seção) em versão compacta —
   ocupam bem menos vertical, cortando o scroll da haste/camisa. Mesma função,
   só menores; continuam opcionais e vão igual pro ZIP/CSV. */
.foto-compacta .foto-galeria { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.foto-compacta .foto-tile { min-height: 58px; padding: 8px 12px; flex-direction: row; gap: 8px; font-size: .82rem; }
.foto-compacta .foto-tile .icone { font-size: 1.15rem; }
.foto-compacta .foto-tile-row .foto-tile-add { min-height: 58px; padding: 8px 12px; }
.foto-compacta .foto-tile-galeria { flex: 0 0 50px; font-size: 1.2rem; }
.foto-compacta .foto-item img { height: 100px; }

/* A1: no tablet/telas largas (≥760px), campos curtos (Ø, comprimentos, selects,
   data) ficam em DUAS colunas — corta quase pela metade o scroll da haste, que
   tem ~40 campos. Conteúdo largo (chips de grupo, fotos, cálculos, textos,
   dureza) ocupa a linha inteira. Gated por @supports :has para navegadores sem
   suporte manterem a coluna única (evita espremer chips/fotos). */
@supports selector(:has(*)) {
  @media (min-width: 760px) {
    #corpo-secao { display: grid; grid-template-columns: 1fr 1fr; column-gap: 22px; align-items: start; }
    #corpo-secao > #aviso-secao-critico,
    #corpo-secao > #calc-slot,
    #corpo-secao > #rotula-slot,
    #corpo-secao > .mp-card,
    #corpo-secao > .campo-bloco:has(.chips-grupo),
    #corpo-secao > .campo-bloco:has(.foto-galeria),
    #corpo-secao > .campo-bloco:has(.campo-escala),
    #corpo-secao > .campo-bloco:has(input[type="text"]:not([data-num])) {
      grid-column: 1 / -1;
    }
  }
}

/* ===== Assinatura ===== */
.assinatura-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
canvas#assinatura-canvas { width: 100%; height: 220px; background: #fff; border: 1px solid var(--line); border-radius: 12px; touch-action: none; display: block; }
.assinatura-acoes { display: flex; gap: 10px; margin-top: 14px; }

/* ===== Navegação inferior do formulário ===== */
.form-nav-bottom {
  position: sticky; bottom: 0; display: flex; gap: 10px; padding: 14px 0 0;
  background: linear-gradient(to top, var(--bg) 60%, transparent);
}
.form-nav-bottom .btn { flex: 1; }

/* ===== Concluída ===== */
.concluida-card { text-align: center; padding: 50px 20px; }
.concluida-card .icone-ok { font-size: 3.4rem; color: var(--ok); margin-bottom: 10px; }

/* ===== Tabela admin ===== */
.table-wrap { overflow-x: auto; margin-top: 14px; border: 1px solid var(--line); border-radius: 12px; }
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th, .tbl td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th { background: var(--surface-2); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); }
.tbl tr:last-child td { border-bottom: none; }

/* ===== Dashboard de produtividade ===== */
.dash-filtros { display: flex; flex-wrap: wrap; gap: 14px; }
.dash-filtros label {
  display: flex; flex-direction: column; gap: 4px; font-size: .82rem; color: var(--ink-soft);
  font-weight: 600;
}
.dash-filtros select, .dash-filtros input {
  padding: 9px 10px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-size: .92rem; min-width: 150px;
}

.dash-stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px;
}
.dash-stat-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); border-top: 4px solid var(--accent);
}
.dash-stat-card.dash-stat-warn { border-top-color: var(--warn); }
.dash-stat-card.dash-stat-ok { border-top-color: var(--ok); }
.dash-stat-valor { font-size: 1.7rem; font-weight: 800; line-height: 1.15; }
.dash-stat-label { font-size: .8rem; color: var(--ink-soft); margin-top: 4px; }

/* Barra horizontal simples (label + trilha proporcional + valor) — mesmo
   espírito visual da .progress-bar do formulário, sem lib de gráfico. */
.dash-barra-row {
  display: grid; grid-template-columns: minmax(90px, 160px) 1fr auto;
  align-items: center; gap: 10px; margin-bottom: 8px; font-size: .88rem;
}
.dash-barra-label { color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-barra-track {
  height: 14px; border-radius: 999px; background: var(--surface-2);
  border: 1px solid var(--line); overflow: hidden;
}
.dash-barra-fill { height: 100%; background: var(--accent); border-radius: 999px; }
.dash-barra-valor { white-space: nowrap; font-weight: 600; }

.dash-acima-media td { color: var(--danger); font-weight: 600; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(45,42,38,.45);
  display: grid; place-items: center; z-index: 100; padding: 20px;
}
.modal-card {
  background: var(--surface); border-radius: 18px; padding: 26px;
  max-width: 400px; width: 100%; box-shadow: var(--shadow-lg);
}
.modal-card h2 { margin-bottom: 12px; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* ===== Toast ===== */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 13px 22px; border-radius: 12px;
  font-weight: 600; box-shadow: var(--shadow-lg); z-index: 200; max-width: 90%;
}
.toast-ok { background: var(--ok); color: #fff; }
.toast-erro { background: var(--danger); color: #fff; }
.toast-warn { background: var(--warn); color: #fff; }

.hidden { display: none !important; }

/* ===== Avisos de integridade (fora da tabela ISO, persistência, pendências) ===== */
.banner-aviso {
  background: color-mix(in srgb, var(--warn) 12%, var(--surface));
  border: 1px solid var(--warn); border-radius: var(--radius);
  padding: 14px 18px; margin-bottom: 16px; font-size: .92rem; line-height: 1.5;
}
.aviso-fora-tabela {
  border-color: var(--warn);
  background: color-mix(in srgb, var(--warn) 12%, var(--surface));
}
.pendencias-lista { margin: 12px 0 12px 22px; }
.pendencias-lista li { margin-bottom: 4px; }

/* Aviso de medida implausível / dureza fora da faixa (C2/C4) — sob o campo. */
.campo-aviso {
  margin-top: 8px; font-size: .82rem; line-height: 1.4;
  color: var(--warn); font-weight: 600;
  background: color-mix(in srgb, var(--warn) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--warn) 40%, var(--surface));
  border-radius: 10px; padding: 8px 10px;
}
.campo-aviso[hidden] { display: none; }
/* Aviso de achado crítico sem foto (C6) — reusa o card de cálculo em âmbar. */
.aviso-critico {
  border-color: var(--warn);
  background: color-mix(in srgb, var(--warn) 14%, var(--surface));
}
/* Selo de backup do rascunho na nuvem (C1). */
.rascunho-sync { margin-top: 8px; font-size: .82rem; font-weight: 600; color: var(--ink-soft); }
.rascunho-sync.ok { color: var(--ok); }
.rascunho-sync.erro { color: var(--warn); }
.sync-rascunho-hint { color: var(--ok); font-weight: 600; }

/* ===== Gestão de colaboradores (Supervisão) ===== */
.pin-code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 3px 9px; font-size: .92rem; letter-spacing: .12em;
  display: inline-block; min-width: 3.6em; text-align: center;
}
.pin-wrap { display: inline-flex; align-items: center; gap: 6px; }
.btn-olho {
  background: none; border: none; cursor: pointer; font-size: 1rem;
  line-height: 1; padding: 2px; opacity: .75;
}
.btn-olho:hover { opacity: 1; }
.check-linha {
  display: flex; align-items: center; gap: 10px;
  margin-top: 16px; font-size: .95rem; cursor: pointer;
}
.check-linha input { width: 20px; height: 20px; accent-color: var(--accent); }
/* Ações da linha quebram em várias linhas quando não cabem: com 3+ botões
   (Editar / Transferir / ✕) a tabela passava da largura da tela e o último
   botão ficava escondido atrás do scroll horizontal — o supervisor não via
   o ✕ de excluir. */
.td-acoes { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.td-acoes .btn { padding: 8px 14px; font-size: .85rem; }
.btn-remover { color: var(--danger); }
#btn-add-colab { margin-bottom: 4px; }

/* ===== Revisão do supervisor ===== */
.banner-revisao {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  border-color: var(--accent); margin-top: 12px;
}
.revisao-ok { color: var(--ok); font-weight: 600; white-space: nowrap; }

/* ===== Aviso de versão nova do app ===== */
.banner-atualizacao {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 18px; background: var(--surface);
  border-top: 2px solid var(--accent); box-shadow: 0 -6px 24px rgba(0,0,0,.28);
}
.banner-atualizacao-texto { line-height: 1.4; }
.banner-atualizacao-texto .muted { display: block; }
.banner-atualizacao-acoes { display: flex; gap: 8px; margin-left: auto; }
.banner-atualizacao-acoes .btn { min-height: 44px; }

.home-rodape {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 26px; padding-top: 12px; border-top: 1px solid var(--line);
}

/* ===== Detalhe do fora-de-tolerância, geometria e desvio da rótula ===== */
.calc-fora-lista {
  margin: 8px 0 0; padding-left: 18px; font-size: .88rem; line-height: 1.5;
  color: var(--danger);
}
.calc-fora-lista strong { color: var(--danger); }
.calc-geo { margin-top: 6px; }
.rotula-dif { font-weight: 700; }
.rotula-dif.ok { color: var(--ok); }
.rotula-dif.leve { color: var(--warn); }
.rotula-dif.fora { color: var(--danger); }

/* ===== Pedidos de liberação de OS / transferência entre peritas ===== */
.os-dup-aguardando {
  margin-top: 10px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--warn); background: color-mix(in srgb, var(--warn) 12%, var(--surface));
  color: var(--ink);
}
.banner-liberacao {
  padding: 14px 18px; border-radius: var(--radius); margin-bottom: 14px;
  border: 1px solid var(--line); background: var(--surface); line-height: 1.5;
}
.banner-liberacao.ok { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, var(--surface)); }
.banner-liberacao.nao { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, var(--surface)); }
.banner-liberacao .btn { margin-top: 8px; }
.badge-pendentes {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; margin-left: 6px; padding: 0 6px;
  border-radius: 10px; background: var(--danger); color: #fff;
  font-size: .75rem; font-weight: 700;
}
.card-pedido { border-left: 4px solid var(--warn); }

/* ===== Sincronização online (Fase 2) ===== */
.acoes-linha { display: flex; flex-wrap: wrap; gap: 10px; }
.sync-badge { font-size: .82rem; font-weight: 600; white-space: nowrap; }
.sync-ok { color: var(--ok); }
.sync-pendente { color: var(--warn); }
.sync-erro { color: var(--danger); }
.btn-sync-retry { padding: 2px 8px; font-size: .78rem; color: var(--accent); text-decoration: underline; }

/* ===== Ações de grupo de parafuso (adicionar/remover) ===== */
.parafuso-acoes {
  display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 4px;
  padding-top: 16px; border-top: 1px dashed var(--line);
}

/* ===== Botão "→ próximo campo" (navegação por toque no celular) ===== */
.btn-proximo-campo {
  flex: 0 0 auto; width: 44px; height: 44px; font-size: 1.25rem; line-height: 1;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2);
  color: var(--accent); cursor: pointer; display: grid; place-items: center;
  transition: transform .05s, background .15s;
}
.btn-proximo-campo:active { transform: scale(.92); background: var(--line); }

/* ===== Laudo (impressão / PDF) ===== */
.laudo-toolbar {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 14px 20px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.laudo-doc {
  max-width: 900px; margin: 0 auto; padding: 32px 28px 80px; color: var(--ink);
}
.laudo-cabecalho {
  border-bottom: 3px solid var(--accent); padding-bottom: 16px; margin-bottom: 24px;
  display: flex; flex-direction: column; gap: 10px;
}
.laudo-titulo { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.laudo-titulo h1 { font-size: 1.4rem; margin: 0; }
.laudo-os { font-size: 1.2rem; font-weight: 800; color: var(--accent); }
.laudo-meta {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 4px 20px; font-size: .92rem; color: var(--ink-soft);
}
.laudo-meta strong { color: var(--ink); }

.laudo-secao { margin-bottom: 22px; break-inside: avoid-page; }
.laudo-secao h2 {
  font-size: 1rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--accent); border-bottom: 1px solid var(--line); padding-bottom: 6px; margin-bottom: 10px;
}
.laudo-secao-vazia h2 { color: var(--ink-soft); }
.laudo-campos-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 6px 18px;
}
.laudo-campo { display: flex; flex-direction: column; font-size: .88rem; padding: 4px 0; border-bottom: 1px dotted var(--line); }
.laudo-campo-label { color: var(--ink-soft); font-size: .78rem; }
.laudo-campo-valor { font-weight: 600; }

.veredito { font-weight: 800; padding: 1px 8px; border-radius: 999px; font-size: .82rem; display: inline-block; }
.veredito-ok { color: var(--ok); background: rgba(47,125,83,.12); border: 1px solid var(--ok); }
.veredito-fora { color: var(--danger); background: rgba(192,57,43,.12); border: 1px solid var(--danger); }

.laudo-materiais { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.laudo-material-item { font-size: .88rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }

.laudo-fotos { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.laudo-foto-label { font-size: .82rem; color: var(--ink-soft); margin-bottom: 4px; }
.laudo-foto-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.laudo-foto { display: block; width: 160px; height: 160px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in; transition: filter .12s ease, transform .12s ease; }
.laudo-foto:hover { filter: brightness(1.04); }

/* A miniatura é um link (âncora p/ a foto ampliada no anexo — usado no PDF). */
.foto-link { position: relative; display: inline-block; line-height: 0; text-decoration: none; border-radius: 8px; }
.foto-link:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.foto-zoom-hint {
  position: absolute; right: 5px; bottom: 5px; width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center; font-size: .8rem;
  background: rgba(15,23,20,.55); color: #fff; border-radius: 999px;
  opacity: 0; transition: opacity .12s ease; pointer-events: none;
}
.foto-link:hover .foto-zoom-hint, .foto-link:focus-visible .foto-zoom-hint { opacity: 1; }

/* ===== Anexo fotográfico (só no PDF/impressão) ===== */
.only-print { display: none; }
.anexo-fotos { break-before: page; page-break-before: always; }
.anexo-fotos h2 { margin-bottom: 4px; }
.anexo-item { break-inside: avoid; page-break-inside: avoid; margin: 0 0 10mm; text-align: center; }
.anexo-img {
  max-width: 100%; max-height: 200mm; object-fit: contain;
  border: 1px solid var(--line); border-radius: 6px;
}
.anexo-legenda {
  display: flex; justify-content: space-between; gap: 12px; align-items: baseline;
  margin-top: 5px; font-size: .82rem; color: var(--ink-soft);
}
.anexo-voltar { white-space: nowrap; color: var(--primary); text-decoration: none; }

/* ===== Lightbox: clicar na foto amplia num pop-up (só na tela; some na impressão) ===== */
.laudo-lightbox {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  padding: 24px; background: rgba(15, 23, 20, .82);
  opacity: 0; pointer-events: none; transition: opacity .18s ease;
  cursor: zoom-out; -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.laudo-lightbox.aberto { opacity: 1; pointer-events: auto; }
.laudo-lightbox img {
  max-width: 100%; max-height: 100%; object-fit: contain;
  border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,.5);
  transform: scale(.86); transition: transform .18s cubic-bezier(.2,.8,.25,1);
}
.laudo-lightbox.aberto img { transform: scale(1); }
.laudo-lightbox-legenda {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 14px 20px; color: #fff; font-size: .9rem; text-align: center;
  background: linear-gradient(to top, rgba(0,0,0,.55), transparent);
}
.laudo-lightbox-fechar {
  position: absolute; top: 14px; right: 18px;
  width: 42px; height: 42px; border-radius: 999px; border: none;
  background: rgba(255,255,255,.14); color: #fff; font-size: 1.5rem; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.laudo-lightbox-fechar:hover { background: rgba(255,255,255,.26); }
@media (prefers-reduced-motion: reduce) {
  .laudo-lightbox, .laudo-lightbox img { transition: none; }
  .laudo-lightbox img { transform: none; }
}

.laudo-assinaturas-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.laudo-assinatura-bloco { text-align: center; }
.laudo-assinatura-img { height: 100px; display: flex; align-items: center; justify-content: center; border-bottom: 1px solid var(--ink); margin-bottom: 6px; }
.laudo-assinatura-img img { max-height: 90px; max-width: 100%; }
.laudo-assinatura-nome { font-weight: 700; }
.laudo-assinatura-papel { font-size: .8rem; color: var(--ink-soft); }

.laudo-rodape { margin-top: 32px; font-size: .78rem; color: var(--ink-soft); text-align: center; }

/* Tabela-invólucro do laudo: o thead se repete em toda página impressa. */
.laudo-print-wrap { width: 100%; border-collapse: collapse; }
.laudo-print-wrap > thead > tr > td,
.laudo-print-wrap > tbody > tr > td { padding: 0; }
.laudo-cabecalho-repetido { display: none; }

/* ===== Resumo executivo ===== */
.resumo-tabela { width: 100%; border-collapse: collapse; font-size: .85rem; }
.resumo-tabela th, .resumo-tabela td {
  border: 1px solid var(--line); padding: 5px 9px; text-align: left; vertical-align: top;
}
.resumo-tabela th {
  background: var(--surface-2); font-size: .72rem; text-transform: uppercase;
  letter-spacing: .03em; color: var(--ink-soft);
}
.resumo-na td { color: var(--ink-soft); }
.resumo-motivos { font-size: .78rem; color: var(--ink-soft); margin-top: 3px; }
.resumo-sintese { margin-top: 8px; font-size: .9rem; }

/* ===== Parecer final do cilindro ===== */
.parecer-selo {
  display: inline-block; padding: 8px 18px; border-radius: 999px;
  font-size: 1.05rem; font-weight: 800; letter-spacing: .02em; border: 2px solid;
}
.parecer-recuperavel { color: var(--ok); border-color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, transparent); }
.parecer-ressalva { color: var(--warn); border-color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); }
.parecer-condenado { color: var(--danger); border-color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.parecer-obs { margin-top: 8px; font-size: .92rem; line-height: 1.5; }
.laudo-parecer-vazio { border-left: 3px solid var(--warn); padding-left: 10px; }
.sintese-ok { color: var(--ok); }
.sintese-fora { color: var(--danger); }

/* ===== Medição declarada como não realizada ===== */
.nao-medido { color: var(--warn); font-weight: 600; font-style: italic; }

/* ===== Critérios de avaliação ===== */
.laudo-criterios ul { margin: 4px 0 8px 20px; font-size: .88rem; }
.laudo-criterios li { margin-bottom: 3px; }

@media print {
  /* Imprime SEMPRE na paleta clara — mesmo se o app/SO estiver no modo escuro,
     o laudo sai com as mesmas cores da tela (verde no cabeçalho/títulos, verde
     OK, vermelho FORA), em vez do antigo preto-e-branco. */
  :root {
    --bg: #fff; --surface: #fff; --surface-2: #faf9f5;
    --ink: #2d2a26; --ink-soft: #6b6560; --line: #e6e2da;
    --accent: #3f6f5e; --accent-ink: #fff;
    --ok: #2f7d53; --warn: #c98a1e; --danger: #c0392b;
  }
  /* Sem isto o navegador descarta fundos/cores ao imprimir (economia de tinta);
     precisamos deles para os selos OK/FORA e o realce do resumo. */
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  .no-print, .topbar, .toast, .modal-overlay { display: none !important; }
  body, .bg { background: #fff !important; }
  .laudo-doc { max-width: 100%; padding: 0; }
  .veredito-fora { font-weight: 900; }
  .laudo-secao { break-inside: avoid-page; }
  .dash-section { break-inside: avoid-page; }
  /* Identificação repetida no topo de cada página impressa (via thead). */
  .laudo-cabecalho-repetido {
    display: block; font-size: .74rem; color: var(--ink-soft);
    border-bottom: 1px solid var(--line); padding: 0 0 2mm; margin-bottom: 3mm;
  }

  /* Anexo de fotos ampliadas aparece só no PDF. */
  .only-print { display: block !important; }
  /* Miniatura no PDF: sem sublinhado de link nem dica de zoom. */
  .foto-link { text-decoration: none !important; }
  @page { margin: 15mm; }
}
