/* Identidade Vinci Made: tinta #041C44, azul #045CFC, papel #F4F3EF, Fraunces + Switzer. */
:root {
  --bg: #f4f3ef;
  --bg-2: #ebeae4;
  --surface: #ffffff;
  --ink: #041c44;
  --ink-2: #4a5a78;
  --muted: #66728c;
  --line: #e2e0d8;
  --line-cool: #e3e8f1;
  --accent: #045cfc;
  --accent-hover: #0348c4;
  --accent-ink: #ffffff;
  --accent-soft: #e9f0ff;
  --tint: #f6f9fe;
  --warn: #8a5300;
  --warn-soft: #fff4dc;
  --danger: #c8452f;
  --danger-soft: #fbebe7;
  --ok: #1b7d41;
  --ok-soft: #e4f3ea;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(4, 28, 68, 0.05), 0 8px 24px rgba(4, 28, 68, 0.06);
  --sans: 'Switzer', 'Helvetica Neue', Arial, sans-serif;
  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  font-family: var(--sans);
  color: var(--ink);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* ---------- marca ---------- */
.logo { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.logo img { width: 30px; height: 28px; object-fit: contain; flex: none; }
.logo-txt { display: flex; flex-direction: column; line-height: 1.15; }
.logo-nome { font-size: 17px; font-weight: 500; letter-spacing: -0.02em; white-space: nowrap; }
.logo-nome span { color: var(--ink-2); font-weight: 400; }
.logo small { color: var(--muted); font-size: 11.5px; }

/* ---------- layout ---------- */
.topo {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 28px;
  padding: 12px 28px; background: rgba(244, 243, 239, 0.88); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.nav a { padding: 7px 13px; border-radius: 999px; text-decoration: none; color: var(--ink-2); white-space: nowrap; font-size: 14.5px; }
.nav a:hover { background: var(--bg-2); color: var(--ink); }
.nav a.ativo { background: var(--ink); color: #fff; }
main { max-width: 1280px; margin: 0 auto; padding: 28px 16px 80px; }
.cab-pagina { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.cab-pagina h1 { margin: 0; font-family: var(--serif); font-weight: 500; font-size: 30px; letter-spacing: -0.01em; }
.cartao { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.cartao h2 { font-family: var(--serif); font-weight: 500; font-size: 20px; }
main > h2 { font-family: var(--serif); font-weight: 500; }
.grade { display: grid; gap: 16px; }
.muted { color: var(--muted); }

/* ---------- botões ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 9px 16px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; text-decoration: none; color: var(--ink); white-space: nowrap; font-weight: 500; font-size: 14.5px;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { border-color: #c9c6ba; background: #fbfaf7; }
.btn.prim { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.prim:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.perigo { color: var(--danger); }
.btn.peq { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.acoes { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- formulários ---------- */
.campo { display: flex; flex-direction: column; gap: 5px; }
.campo label { font-size: 13px; font-weight: 600; color: var(--ink); }
.campo small { color: var(--muted); font-size: 12px; }
.opc { font-weight: 400; color: var(--muted); }
input[type='text'], input[type='email'], input[type='url'], input[type='number'], input[type='date'], input[type='password'], input[type='tel'], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
textarea { resize: vertical; }
.linha2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.segmentado { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: #fff; width: fit-content; }
.segmentado label { padding: 7px 16px; cursor: pointer; font-weight: 500; font-size: 14px; }
.segmentado input { display: none; }
.segmentado label:has(input:checked) { background: var(--ink); color: #fff; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.check input { margin-top: 3px; width: 18px; height: 18px; flex: none; accent-color: var(--accent); }

/* ---------- tabelas ---------- */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr.clic { cursor: pointer; }
.tbl tr.clic:hover td { background: #faf9f6; }
.tbl-wrap { overflow-x: auto; }
.vazio { text-align: center; padding: 44px 16px; color: var(--muted); }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.pendente { background: var(--warn-soft); color: var(--warn); }
.badge.assinado { background: var(--ok-soft); color: var(--ok); }
.badge.emitido { background: var(--accent-soft); color: var(--accent-hover); }
.badge.anulado { background: var(--danger-soft); color: var(--danger); }

.filtros { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filtros input, .filtros select { width: auto; min-width: 190px; }

.aviso { padding: 11px 14px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: 14px; }
.aviso.ok { background: var(--ok-soft); color: var(--ok); }
.aviso.erro { background: var(--danger-soft); color: var(--danger); }
.aviso ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- construtor de documentos ---------- */
.construtor { display: grid; grid-template-columns: 390px 1fr; gap: 22px; align-items: start; }
.construtor .painel { position: sticky; top: 80px; max-height: calc(100vh - 100px); overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.tipos { display: grid; gap: 8px; }
.tipo { display: block; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; background: #fff; transition: border-color 0.15s; }
.tipo:hover { border-color: #c9c6ba; }
.tipo strong { display: block; font-size: 14px; }
.tipo span { font-size: 12px; color: var(--muted); }
.tipo.ativo { border-color: var(--accent); background: var(--tint); box-shadow: inset 3px 0 0 var(--accent); }
.resumo { background: var(--tint); border: 1px solid var(--line-cool); border-radius: 10px; padding: 12px 14px; font-size: 14px; display: grid; gap: 4px; }
.resumo div { display: flex; justify-content: space-between; gap: 10px; }
.previa { overflow-x: auto; padding-bottom: 8px; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 16px; padding: 28px; }

/* ---------- configurações ---------- */
.planos-tbl input { min-width: 90px; }
.pad { width: 100%; height: 180px; border: 1.5px dashed #c3c9d6; border-radius: 10px; background: #fff; display: block; }
.sig-atual { height: 72px; border: 1px solid var(--line); border-radius: 10px; padding: 6px; background: #fff; }

/* =========================================================
   DOCUMENTO (A4)
   ========================================================= */
.documento {
  background: #fff; color: #1b2b4b; width: 210mm; max-width: 100%; margin: 0 auto; padding: 18mm 19mm 20mm;
  border-radius: 6px; box-shadow: 0 1px 2px rgba(4, 28, 68, 0.06), 0 18px 40px rgba(4, 28, 68, 0.1);
  font-family: var(--sans); font-size: 9.6pt; line-height: 1.62;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.documento p { margin: 0 0 8px; text-align: justify; hyphens: auto; }
.documento strong { color: var(--ink); font-weight: 600; }

/* cabeçalho */
.doc-cab { position: relative; display: flex; justify-content: space-between; align-items: center; gap: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--line-cool); }
.doc-cab::after { content: ''; position: absolute; left: 0; bottom: -1px; width: 64px; height: 2px; background: var(--accent); }
.doc-marca { display: flex; align-items: center; gap: 10px; font-size: 15pt; font-weight: 500; letter-spacing: -0.02em; color: var(--ink); }
.doc-marca img { width: 34px; height: 32px; object-fit: contain; }
.doc-wordmark span { color: var(--ink-2); font-weight: 400; }
.doc-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; font-family: var(--mono); font-size: 7.5pt; color: var(--muted); letter-spacing: 0.02em; }
.doc-meta span:first-child { color: var(--ink); font-weight: 500; }

/* título */
.doc-titulo { margin: 30px 0 24px; }
.documento h1 { font-family: var(--serif); font-weight: 500; font-size: 23pt; line-height: 1.12; letter-spacing: -0.015em; margin: 0; color: var(--ink); text-align: left; }
.doc-sub { margin: 8px 0 0 !important; color: var(--ink-2); font-size: 10pt; text-align: left !important; }

/* partes */
.partes-nota { color: var(--muted); font-size: 8.8pt; margin: 0 0 6px !important; }
.parte { background: var(--tint); border: 1px solid var(--line-cool); border-left: 3px solid var(--accent); border-radius: 8px; padding: 11px 16px 10px; margin-bottom: 8px; break-inside: avoid; }
.parte p { margin: 0 !important; }
.parte-rotulo { font-size: 7pt; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); margin-bottom: 3px; }

/* cláusulas */
.clausula { margin-top: 18px; }
.documento h3 { display: flex; align-items: baseline; gap: 12px; margin: 0 0 7px; color: var(--ink); break-after: avoid; page-break-after: avoid; }
.cl-num { flex: none; min-width: 78px; font-family: var(--sans); font-size: 7pt; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); }
.cl-sep { display: none; }
.cl-tit { font-family: var(--serif); font-weight: 500; font-size: 12pt; letter-spacing: -0.005em; }
.documento ol { margin: 0 0 8px; padding-left: 21px; }
.documento li { margin-bottom: 5px; padding-left: 3px; text-align: justify; hyphens: auto; }
.documento li::marker { color: var(--accent); font-weight: 600; font-size: 0.9em; }
.documento ol.alineas { list-style: lower-alpha; margin-top: 5px; }
.documento ol.alineas li::marker { color: var(--ink-2); font-weight: 500; }

/* anexos e registo */
.documento h2 { font-family: var(--serif); font-weight: 500; font-size: 15pt; letter-spacing: -0.01em; color: var(--ink); margin: 0 0 14px; }
.anexo .cl-tit, .anexo h3 { font-family: var(--serif); font-weight: 500; font-size: 11pt; display: block; margin: 0 0 6px; }
.anexo, .auditoria { margin-top: 34px; padding-top: 26px; border-top: 1px solid var(--line-cool); break-before: page; page-break-before: always; }
.documento .tabela { width: 100%; border-collapse: separate; border-spacing: 0; border: 1px solid var(--line-cool); border-radius: 8px; overflow: hidden; font-size: 9pt; }
.documento .tabela th, .documento .tabela td { padding: 7px 12px; vertical-align: top; text-align: left; border-bottom: 1px solid #edf0f6; }
.documento .tabela tr:last-child th, .documento .tabela tr:last-child td { border-bottom: none; }
.documento .tabela th { width: 34%; background: var(--tint); color: var(--ink-2); font-weight: 500; border-right: 1px solid #edf0f6; }
.documento .tabela td { color: var(--ink); }
.documento .tabela tr { break-inside: avoid; }
.documento .caixa { border-left: 3px solid var(--accent); padding: 7px 12px; margin: 6px 0; background: var(--tint); border-radius: 0 6px 6px 0; }
.documento .nota { font-size: 8.5pt; color: var(--muted); }
.documento .tabela + .nota { margin-top: 10px; }
.bloco-assinaturas { break-inside: avoid; page-break-inside: avoid; }
.documento .mono { font-family: var(--mono); font-size: 7.5pt; word-break: break-all; }
.documento .dest { text-align: left; }
.auditoria h2::before { content: '✓'; display: inline-grid; place-items: center; width: 22px; height: 22px; margin-right: 10px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); font-family: var(--sans); font-size: 11pt; font-weight: 700; vertical-align: 2px; }

/* assinaturas */
.doc-local { margin-top: 26px !important; font-style: italic; color: var(--muted); text-align: left !important; }
.assinaturas { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 14px; break-inside: avoid; page-break-inside: avoid; }
.sig { border: 1px solid var(--line-cool); border-radius: 10px; padding: 12px 16px 12px; font-family: var(--sans); }
.sig-img { height: 66px; display: flex; align-items: flex-end; justify-content: flex-start; }
.sig-img img { max-height: 66px; max-width: 100%; }
.sig-linha { border-top: 1px solid var(--ink); margin: 6px 0 7px; }
.sig-nome { font-weight: 600; color: var(--ink); font-size: 9.5pt; }
.sig-papel { color: var(--muted); font-size: 8pt; }

.ph { background: #fff1b8; color: #7a5600; border-radius: 4px; padding: 0 4px; font-family: var(--sans); font-size: 0.92em; font-weight: 500; }

/* ---------- página pública de assinatura ---------- */
.publica main { max-width: 920px; }
.barra-assinatura { margin: 26px auto 0; max-width: 210mm; }
.barra-assinatura h2 { margin-top: 0; }

/* ---------- toast ---------- */
#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 999px; font-size: 14px; z-index: 50; box-shadow: var(--shadow); }

@media (max-width: 960px) {
  .construtor { grid-template-columns: 1fr; }
  .construtor .painel { position: static; max-height: none; }
}
@media (max-width: 640px) {
  .topo { flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
  .linha2 { grid-template-columns: 1fr; }
  .documento { padding: 22px 16px; font-size: 10pt; border-radius: 0; }
  .doc-marca { font-size: 13pt; }
  .documento h1 { font-size: 19pt; }
  .documento h3 { flex-direction: column; gap: 1px; }
  .assinaturas { grid-template-columns: 1fr; }
  .filtros input, .filtros select { min-width: 0; flex: 1; }
  .cab-pagina h1 { font-size: 24px; }
}

@media print {
  @page { size: A4; margin: 15mm 16mm 17mm; }
  body { background: #fff; }
  .no-print, .topo, #toast { display: none !important; }
  main { padding: 0; max-width: none; }
  .documento { box-shadow: none; border-radius: 0; padding: 0; width: auto; }
  .anexo, .auditoria { border-top: none; padding-top: 0; margin-top: 0; }
  .ph { background: none; }
}
