/* FazDoc — layout "tela dividida": formulário em etapas à esquerda, documento ao vivo à direita.
   Visual único, só branco (preto + âmbar). */
:root {
  --bg: #ffffff;
  --area-doc: #f6f6f4;
  --ink: #16181d;
  --muted: #5f636c;
  --line: #e4e5e8;
  --field: #cfd1d6;
  --soft: #f2f2f3;
  --amber: #f2b632;
  --amber-soft: #fbe7b2;
  --amber-bg: #fff8e6;
  --warn: #9a3a0b;
  --warn-soft: #fdebe2;
  --ok: #1f7a4f;
  --ok-soft: #e3f4ea;
  --paper: #ffffff;
  --paper-ink: #111111;
  --mark: #fbe7b2;
  --mark-falta: #ffd9cc;
  --f-display: "Sora", "Segoe UI", system-ui, Arial, sans-serif;
  --f-ui: "Manrope", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --f-doc: "Tinos", "Times New Roman", Times, serif;
  --r: 10px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font-family: var(--f-ui); font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- cabeçalho ---------- */
.topo {
  background: var(--bg); border-bottom: 1px solid var(--line);
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
}
.topo-in { display: flex; align-items: center; gap: 18px; min-height: 60px; flex-wrap: wrap; padding-block: 6px; }
.marca { font-family: var(--f-display); font-weight: 700; font-size: 20px; letter-spacing: -.02em; white-space: nowrap; }
.marca span { background: var(--amber); padding: 0 5px; border-radius: 5px; margin-left: 1px; }
.tagline { font-size: 14px; color: var(--muted); }
.abas { display: flex; gap: 4px; flex-wrap: wrap; }
.abas button {
  border: 0; background: none; padding: 8px 14px; border-radius: 99px; cursor: pointer;
  color: var(--muted); font-weight: 700; font-size: 13.5px;
}
.abas button:hover { background: var(--soft); color: var(--ink); }
.abas button[aria-current="page"] { background: var(--ink); color: #fff; }
.usuario { margin-left: auto; font-size: 13px; color: var(--muted); display: flex; gap: 10px; align-items: center; }
.usuario .av { width: 30px; height: 30px; border-radius: 50%; background: var(--amber); color: var(--ink); display: inline-grid; place-items: center; font-weight: 800; }
.usuario a { color: var(--muted); }

.aviso-previa {
  background: var(--amber-bg); border-bottom: 1px solid var(--amber-soft); font-size: 13px;
  padding-block: 8px; padding-left: max(20px, env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px));
}

/* ---------- área de trabalho dividida ---------- */
.trabalho { display: flex; align-items: stretch; }
.lado-form {
  flex: 0 0 470px; max-width: 100%; border-right: 1px solid var(--line);
  padding: 22px 24px 28px; display: flex; flex-direction: column; gap: 18px; min-width: 0;
}
.lado-doc { flex: 1 1 0; min-width: 0; background: var(--area-doc); padding: 18px 24px 40px; display: flex; flex-direction: column; gap: 12px; }

@media (min-width: 1000px) {
  html, body { height: 100%; }
  body { display: flex; flex-direction: column; overflow: hidden; }
  body.rolavel { overflow: auto; display: block; }
  .trabalho { flex: 1 1 auto; min-height: 0; }
  .lado-form, .lado-doc { overflow-y: auto; }
}
@media (max-width: 999px) {
  .trabalho { flex-direction: column; }
  .lado-form { flex: none; border-right: 0; border-bottom: 1px solid var(--line); padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .lado-doc { padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: max(12px, env(safe-area-inset-right, 0px)); }
}

.lado-topo { display: grid; gap: 6px; }
.rot-modelo { font-size: 12px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.lado-topo select {
  width: 100%; border: 1px solid var(--field); border-radius: 10px; padding: 12px; font-weight: 700; font-size: 15px; background: var(--bg);
}
.links { display: flex; gap: 14px; flex-wrap: wrap; }
.link { border: 0; background: none; padding: 2px 0; color: var(--muted); font-size: 13px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.link:hover { color: var(--ink); }

.passos { display: flex; gap: 6px; flex-wrap: wrap; }
.passo {
  border: 0; background: var(--soft); color: var(--muted); padding: 7px 12px; border-radius: 99px;
  font-size: 13px; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.passo:hover { color: var(--ink); }
.passo .ic { font-size: 11px; min-width: 16px; height: 16px; border-radius: 99px; display: inline-grid; place-items: center; padding: 0 4px; }
.passo.feito .ic { background: var(--ok-soft); color: var(--ok); }
.passo.falta .ic { background: var(--mark-falta); color: var(--warn); }
.passo[aria-current="step"] { background: var(--ink); color: #fff; }
.passo[aria-current="step"] .ic { background: rgba(255,255,255,.18); color: #fff; }

.secao-tit { margin: 0; font-family: var(--f-display); font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
fieldset.secao { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: 14px; }
.aviso { background: var(--amber-bg); border: 1px solid var(--amber-soft); border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.aviso b { color: var(--warn); }

.grade { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.campo { display: grid; gap: 5px; min-width: 0; align-content: start; }
.campo label { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.campo label .req { color: var(--warn); }
.campo input, .campo select, .campo textarea {
  width: 100%; min-width: 0; border: 1px solid var(--field); background: var(--bg); border-radius: 10px;
  padding: 10px 11px; font-size: 15px; transition: border-color .15s, box-shadow .15s;
}
.campo textarea { resize: vertical; min-height: 66px; line-height: 1.45; }
.campo input:focus, .campo select:focus, .campo textarea:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); }
.campo .ajuda { font-size: 12px; color: var(--muted); }
.campo.erro input, .campo.erro select, .campo.erro textarea { border-color: #e0855a; background: var(--warn-soft); }
.campo.erro .ajuda { color: var(--warn); font-weight: 700; }
.campo.auto input { background: var(--soft); }
.w1 { grid-column: span 1; } .w2 { grid-column: span 2; } .w3 { grid-column: span 3; }
.w4 { grid-column: span 4; } .w5 { grid-column: span 5; } .w6 { grid-column: span 6; }

/* no painel estreito do formulário: grade de 4 */
.lado-form .grade { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.lado-form .w1, .lado-form .w2, .lado-form .w3 { grid-column: span 2; }
.lado-form .w1.curto { grid-column: span 1; }
.lado-form .w4, .lado-form .w5, .lado-form .w6 { grid-column: span 4; }
@media (max-width: 420px) {
  .lado-form .grade { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lado-form .w1, .lado-form .w1.curto { grid-column: span 1; }
  .lado-form .w2, .lado-form .w3, .lado-form .w4, .lado-form .w5, .lado-form .w6 { grid-column: span 2; }
}

.checks { display: grid; gap: 8px; }
.checks label { display: flex; gap: 9px; align-items: center; font-size: 14px; font-weight: 500; color: var(--ink); cursor: pointer; }
.checks input { width: 18px; height: 18px; accent-color: var(--ink); flex: none; }

.conferencia { font-size: 13px; padding: 9px 12px; border-radius: 10px; background: var(--soft); font-variant-numeric: tabular-nums; }
.conferencia.ok { background: var(--ok-soft); color: var(--ok); }
.conferencia.ruim { background: var(--warn-soft); color: var(--warn); }

/* partes */
.partes { display: grid; gap: 10px; }
.partes > .rot { font-family: var(--f-display); font-size: 16px; font-weight: 600; }
.pessoa { border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: grid; gap: 12px; }
.pessoa-topo { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pessoa-topo .nome { font-weight: 800; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-right: auto; }
.busca-pessoa { flex: 1 1 180px; border: 1px dashed #b4b7be; background: var(--bg); border-radius: 8px; padding: 7px 10px; font-size: 13.5px; min-width: 0; }
.busca-pessoa:focus { outline: none; border-style: solid; border-color: var(--amber); }

/* botões */
.btn {
  border: 1px solid var(--field); background: var(--bg); color: var(--ink);
  border-radius: 99px; padding: 9px 16px; font-weight: 700; font-size: 14px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--soft); }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn.prim { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.prim:hover { background: #2b2e36; }
.btn.amb { background: var(--amber); border-color: var(--amber); color: var(--ink); }
.btn.amb:hover { background: #e5a81f; }
.btn.grande { padding: 14px 22px; font-size: 15px; }
.btn.peq { padding: 7px 12px; font-size: 13px; }
.btn.fant { border-color: transparent; background: none; color: var(--muted); }
.btn.fant:hover { color: var(--ink); background: var(--soft); }
.btn.perigo { color: var(--warn); }
.btn.perigo.confirmar { background: var(--warn); border-color: var(--warn); color: #fff; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-add { justify-self: start; }
.acoes { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.nav-passos { display: flex; gap: 10px; margin-top: 4px; }
.nav-passos .btn { padding-block: 13px; }
.nav-passos #btnProximo { flex: 1; }
.nota { margin: 0; font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; align-items: flex-start; }
.nota svg { width: 14px; height: 14px; flex: none; margin-top: 2px; }

/* ---------- documento ---------- */
.doc-barra { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.estado { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.estado i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.estado.manual i { background: var(--amber); }
.faltas { font-size: 12.5px; font-weight: 700; color: var(--warn); background: var(--warn-soft); padding: 3px 10px; border-radius: 99px; }
.doc-acoes { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tog { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; font-weight: 600; margin-right: 4px; }
.tog input { accent-color: var(--ink); }
.editado { background: var(--amber-bg); border: 1px solid var(--amber-soft); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.editado span { flex: 1 1 260px; }
.dica-edit { font-size: 12.5px; color: var(--muted); margin: 0; text-align: center; }
.status-salvo { font-weight: 700; }
.status-salvo.ok { color: var(--ok); }

.folha-wrap { overflow-x: auto; padding: 4px 0 8px; }
.folha {
  background: var(--paper); color: var(--paper-ink);
  width: 210mm; max-width: 100%; min-height: 297mm; margin: 0 auto;
  padding: 25mm 20mm 20mm 30mm;
  box-shadow: 0 1px 2px rgba(0,0,0,.06), 0 12px 32px rgba(0,0,0,.08);
  font-family: var(--f-doc); font-size: 12pt; line-height: 1.5; text-align: justify;
}
.folha:focus { outline: 2px solid var(--amber); outline-offset: 4px; }
.folha p { margin: 0 0 8pt; }
.folha p.item { padding-left: 1.2cm; }
.folha .doc-titulo { font-size: 13pt; text-align: center; font-weight: 700; margin: 0 0 18pt; letter-spacing: .02em; text-wrap: balance; }
.folha .doc-sub { text-align: center; }
.folha .clausula { font-size: 12pt; font-weight: 700; margin: 14pt 0 6pt; text-align: left; }
.folha .local-data { text-align: right; margin-top: 18pt; }
.folha .assinaturas { display: flex; flex-wrap: wrap; justify-content: center; gap: 26pt 30pt; margin-top: 30pt; }
.folha .ass { flex: 0 1 calc(50% - 15pt); text-align: center; break-inside: avoid; page-break-inside: avoid; }
.folha .ass-linha { border-top: 1px solid #000; margin: 0 4% 4pt; }
.folha .ass-nome { font-weight: 700; font-size: 11pt; line-height: 1.25; }
.folha .ass-info { font-size: 10pt; line-height: 1.25; }
.folha .test-titulo { margin-top: 22pt; }
.folha.destacar .v { background: var(--mark); border-radius: 2px; box-shadow: 0 0 0 1px var(--mark); }
.folha .v.falta { background: var(--mark-falta); box-shadow: 0 0 0 1px var(--mark-falta); color: #8a2a00; border-radius: 2px; }
@media (max-width: 680px) {
  .folha { padding: 14mm 10mm; font-size: 11pt; min-height: 0; }
  .folha .ass { flex-basis: 100%; }
  .doc-acoes { margin-left: 0; width: 100%; }
}

/* ---------- páginas (pessoas, histórico, ajustes) ---------- */
.pagina {
  max-width: 980px; margin: 0 auto; padding-block: 28px 80px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.vista { display: grid; gap: 18px; }
h2.tit { font-family: var(--f-display); font-size: 24px; font-weight: 600; margin: 0; letter-spacing: -.02em; }
.sub { color: var(--muted); margin: 2px 0 0; font-size: 14px; }
.linha-tit { display: flex; align-items: end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pagina .secao { border: 1px solid var(--line); border-radius: 14px; padding: 18px; display: grid; gap: 14px; }
.pagina .secao > h3 { margin: 0; font-family: var(--f-display); font-size: 17px; font-weight: 600; }
.busca { width: 100%; max-width: 420px; border: 1px solid var(--field); background: var(--bg); border-radius: 99px; padding: 10px 16px; font-size: 15px; }
.lista { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.lista-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 13px 16px; border-top: 1px solid var(--line); }
.lista-item:first-child { border-top: 0; }
.lista-item .t { font-weight: 700; overflow-wrap: anywhere; }
.lista-item .m { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.chip { display: inline-block; font-size: 11.5px; font-weight: 800; padding: 2px 9px; border-radius: 99px; background: var(--amber-soft); color: var(--ink); margin-right: 7px; vertical-align: 1px; }
.vazio-lista { padding: 28px 18px; text-align: center; color: var(--muted); }
@media (max-width: 680px) {
  .grade { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .w1, .w2 { grid-column: span 1; }
  .w3, .w4, .w5, .w6 { grid-column: span 2; }
  .lista-item { grid-template-columns: 1fr; }
}

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px)); z-index: 50;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 99px; font-size: 14px; font-weight: 700;
  max-width: calc(100% - 32px); box-shadow: 0 8px 24px rgba(0,0,0,.18); transition: opacity .2s, transform .2s;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- impressão: só a folha ---------- */
@page { size: A4; margin: 25mm 20mm 20mm 30mm; }
@media print {
  html, body { height: auto !important; overflow: visible !important; display: block !important; background: #fff !important; }
  .topo, .aviso-previa, .lado-form, .doc-barra, .editado, .dica-edit, .toast, .pagina { display: none !important; }
  .trabalho, .lado-doc { display: block !important; padding: 0 !important; background: #fff !important; overflow: visible !important; }
  .folha-wrap { overflow: visible; padding: 0; }
  .folha { box-shadow: none; padding: 0; width: auto; min-height: 0; color: #000; }
  .folha .v, .folha.destacar .v, .folha .v.falta { background: none !important; box-shadow: none !important; color: inherit !important; }
}
