/* Estilos da tela: Contratos (use as variáveis de style.css) — Agente Contratos
   Parte 1: tela (lista, assistente, visualização). Parte 2: documento do contrato (A4, igual ao legado de Instalação).
   Parte 3: impressão (@media print; o @page é inserido pelo JS).

/* ================================================================== 1. Tela */
.linha-botoes { display: flex; gap: 8px; flex-wrap: wrap; }
.ctt-kpi-ativo { outline: 3px solid rgba(255,255,255,.95); }
.ctt-filtros { display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; }
.ctt-filtros .abas { margin-bottom: 6px; }
.ctt-filtros .aba .ic { width: 15px; height: 15px; }
.ctt-chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ctt-sel-cliente { width: auto; min-width: 220px; padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; margin-left: auto; }
.ctt-ponto { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }
.chip .ctt-ponto.ctt-st-rascunho { color: #d97706; } .chip .ctt-ponto.ctt-st-enviado { color: #0284c7; }
.chip .ctt-ponto.ctt-st-assinado { color: #059669; } .chip .ctt-ponto.ctt-st-cancelado { color: #94a3b8; }
.chip.ativo .ctt-ponto { color: #fff !important; }
.selo.ctt-st-rascunho { color: #d97706; } .selo.ctt-st-enviado { color: #0284c7; }
.selo.ctt-st-assinado { color: #059669; } .selo.ctt-st-cancelado { color: #64748b; }

.ctt-grade { grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.ctt-card { display: flex; flex-direction: column; cursor: pointer; padding: 8px; overflow: hidden; transition: transform .2s var(--anim), box-shadow .2s; }
.ctt-card:hover { transform: translateY(-4px); box-shadow: 0 24px 50px rgba(6,40,56,.28); }
.ctt-card.cancelado { opacity: .62; }
.ctt-card-faixa { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-radius: 15px; color: #fff; font-weight: 750;
  background: linear-gradient(135deg, var(--cor-tipo), color-mix(in srgb, var(--cor-tipo) 55%, #0b1720)); box-shadow: 0 8px 18px rgba(6,40,56,.18); }
.ctt-card-faixa .ic { width: 20px; height: 20px; }
.ctt-versao { margin-left: auto; background: rgba(255,255,255,.25); border-radius: 999px; padding: 2px 10px; font-size: 12.5px; }
.ctt-card-corpo { padding: 12px 8px 8px; display: flex; flex-direction: column; gap: 7px; flex: 1; }
.ctt-card-corpo > .fraco { display: flex; align-items: center; gap: 5px; }
.ctt-card-corpo > .fraco .ic { width: 14px; height: 14px; }
.ctt-card-cli { font-size: 15.5px; line-height: 1.3; }
.ctt-arquivo { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 11.5px; color: var(--texto-2); background: rgba(255,255,255,.65);
  border: 1px dashed rgba(12,37,51,.18); border-radius: 9px; padding: 5px 8px; word-break: break-all; }
.ctt-arquivo.claro { background: rgba(255,255,255,.18); color: #fff; border-color: rgba(255,255,255,.5); }
.ctt-card-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.ctt-valor { font-weight: 800; }
.ctt-valor small { font-weight: 600; color: var(--texto-3); }
.ctt-card-corpo .tag-alerta, .ctt-card-corpo .tag-ok { display: inline-flex; align-items: center; gap: 5px; width: fit-content; }
.tag-alerta .ic, .tag-ok .ic { width: 13px; height: 13px; }
.ctt-card-pe { display: flex; gap: 8px; padding: 4px; }
.ctt-card-pe .btn { flex: 1; }

/* Contraste dentro dos painéis da tela */
.ctt-form .fraco, .ctt-passo2 .fraco, .ctt-lado .fraco, .ctt-previa .fraco, .ctt-campo small { color: var(--texto-2); }
.ctt-lado .info-lista .i small { color: var(--texto-2); }
.ctt-form h2 .ic, .ctt-passo2 h2 .ic, .ctt-lado h2 .ic { color: var(--azul); }
.ctt-passo { color: var(--texto); }

/* Assistente */
.ctt-passos { display: flex; align-items: center; gap: 10px; padding: 10px 16px; margin-bottom: 16px; border-radius: 999px; width: fit-content; max-width: 100%; overflow-x: auto; }
.ctt-passo { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 13.5px; color: var(--texto-2); white-space: nowrap; }
.ctt-passo[data-passo] { cursor: pointer; }
.ctt-passo .bola { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.7); font-weight: 800; }
.ctt-passo .bola .ic { width: 15px; height: 15px; }
.ctt-passo.atual { color: var(--texto); }
.ctt-passo.atual .bola { background: var(--preto); color: #fff; box-shadow: 0 0 0 4px rgba(11,23,32,.15); }
.ctt-passo.feito .bola { background: var(--verde); color: #fff; }
.ctt-passo-linha { width: 34px; height: 2px; background: rgba(255,255,255,.7); border-radius: 2px; }
.ctt-tipos { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.ctt-tipo { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; text-align: left; padding: 22px; cursor: pointer; border-radius: var(--raio);
  transition: transform .2s var(--anim), box-shadow .2s; color: var(--texto); }
.ctt-tipo:hover, .ctt-tipo.ativo { transform: translateY(-4px); box-shadow: 0 24px 50px rgba(6,40,56,.28); }
.ctt-tipo b { font-size: 17px; }
.ctt-tipo span:last-child { color: var(--texto-2); font-size: 13.5px; }
.ctt-tipo-ic { width: 54px; height: 54px; border-radius: 17px; display: grid; place-items: center; color: #fff; margin-bottom: 6px;
  background: linear-gradient(135deg, var(--cor-tipo), color-mix(in srgb, var(--cor-tipo) 55%, #0b1720)); box-shadow: 0 10px 22px rgba(6,40,56,.2); }
.ctt-tipo-ic .ic { width: 28px; height: 28px; }
.ctt-passo2 { max-width: 860px; }
.ctt-passo2 h2 { display: flex; align-items: center; gap: 8px; }
.ctt-passo2 h2 .ic { width: 20px; height: 20px; }
.ctt-cli-resumo { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 12px; padding: 14px; border-radius: 16px; background: rgba(255,255,255,.55); margin-bottom: 10px; }
.ctt-cli-resumo small { display: block; color: var(--texto-3); font-size: 12px; }
.ctt-acoes { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

.ctt-editor { display: grid; grid-template-columns: minmax(320px, 430px) minmax(0, 1fr); gap: 18px; align-items: start; }
.ctt-form { position: sticky; top: 14px; max-height: calc(100vh - 28px); overflow: auto; }
.ctt-form h2 { display: flex; align-items: center; gap: 8px; }
.ctt-form h2 .ic { width: 19px; height: 19px; }
.ctt-grupo { border: 0; padding: 0; margin: 0 0 8px; }
.ctt-grupo legend { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--texto-2); font-weight: 750; margin-bottom: 8px; }
.ctt-grupo-campos { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.ctt-campo { margin-bottom: 11px; }
.ctt-campo.largo { grid-column: 1 / -1; }
.ctt-campo small { line-height: 1.3; }
.ctt-campo.falta input, .ctt-campo.falta textarea, .ctt-campo.falta select { border-color: #f59e0b; background: #fffbeb; }
.ctt-obrig { color: #e11d48; font-style: normal; }
.ctt-campo textarea { min-height: 52px; }
.ctt-moeda { position: relative; }
.ctt-moeda span { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--texto-3); font-weight: 650; font-size: 14px; }
.ctt-moeda input { padding-left: 38px; }

.ctt-previa { padding: 12px; min-width: 0; }
.ctt-previa-topo { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 6px 12px; flex-wrap: wrap; }
.ctt-previa-topo b { display: flex; align-items: center; gap: 7px; }
.ctt-previa-topo .ic { width: 17px; height: 17px; }
.ctt-previa-topo .tag-alerta, .ctt-previa-topo .tag-ok { display: inline-flex; align-items: center; gap: 5px; }
.ctt-folhas-caixa { overflow: hidden; }
.ctt-folhas { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 4px 0 10px; }

/* Folha A4 da tela (mesmas medidas do PDF) */
.ctt-folha { position: relative; width: 595.3pt; height: 841.9pt; flex: none; background: #fff; color: #000;
  padding: 35.4pt 55pt 50pt; box-shadow: 0 18px 40px rgba(6,40,56,.3); border-radius: 3px; display: flex; flex-direction: column; }
.ctt-folha-logo { height: 46pt; flex: none; display: flex; justify-content: center; margin-bottom: 43.5pt; }
.ctt-folha-logo img { height: 46pt; width: auto; }
.ctt-folha-corpo { position: relative; flex: 1; overflow: hidden; }
.ctt-folha-n { position: absolute; right: 14pt; bottom: 10pt; font: 600 9px var(--fonte); color: #9aa7ae; }

.ctt-ver { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; align-items: start; }
.ctt-lado { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 14px; }
.ctt-lado h2 { display: flex; align-items: center; gap: 8px; }
.ctt-lado h2 .ic { width: 19px; height: 19px; }
.ctt-acoes-lado { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.ctt-acoes-lado .btn { width: 100%; }
.ctt-pend-lista { margin-top: 14px; padding: 12px; border-radius: 14px; background: #fff7e6; border: 1px solid #fde3a7; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ctt-pend-lista b { width: 100%; color: #b45309; display: flex; align-items: center; gap: 6px; font-size: 13.5px; }
.ctt-pend-lista b .ic { width: 16px; height: 16px; }
.ctt-pend-lista span { font-size: 12px; background: #fff; border-radius: 999px; padding: 3px 9px; color: #92400e; font-weight: 600; }
.ctt-pend-lista .btn { margin-top: 4px; }
.ctt-tempo { display: flex; flex-direction: column; gap: 12px; }
.ctt-tempo-i { display: flex; gap: 10px; align-items: flex-start; }
.ctt-tempo-i .ic { width: 30px; height: 30px; padding: 6px; border-radius: 10px; background: rgba(20,184,166,.15); color: var(--turquesa); flex: none; }
.ctt-tempo-i b { display: block; font-size: 14px; }

@media (max-width: 1250px) { .ctt-editor { grid-template-columns: 1fr; } .ctt-form { position: static; max-height: none; } }
@media (max-width: 1100px) { .ctt-ver { grid-template-columns: 1fr; } .ctt-lado { position: static; order: -1; } }
@media (max-width: 820px) {
  .ctt-tipos { grid-template-columns: 1fr; }
  .ctt-cli-resumo, .ctt-grupo-campos { grid-template-columns: 1fr; }
  .ctt-sel-cliente { margin-left: 0; width: 100%; }
  .ctt-passo span:not(.bola) { display: none; }
  .ctt-passo.atual span:not(.bola) { display: inline; }
}

/* ================================================================== 2. Documento do contrato
   Layout do Contrato de Instalação (REGRAS.md): Times New Roman 10 pt, A4, margens 1000/1100 twips,
   logo 139×46 pt centralizada a 708 twips do topo, texto a ~126 pt do topo, sem rodapé. */
.ctt-doc { font-family: "Times New Roman", "Liberation Serif", Tinos, Times, serif; font-size: 10pt; line-height: 1.15; color: #000;
  text-rendering: geometricPrecision; -webkit-font-smoothing: auto; }
.ctt-doc * { font-family: inherit; }
.ctt-cabecalho { margin-bottom: 15pt; }
.ctt-titulo { font-size: 11pt; font-weight: bold; text-align: center; margin: 0 0 10pt; letter-spacing: 0; line-height: 1.15; }
.ctt-sub { font-weight: bold; text-align: center; margin: 0 0 2pt; }
.ctt-cabecalho > :last-child { margin-bottom: 0; }
.ctt-clausula { font-size: 10pt; font-weight: bold; margin: 12pt 0 6pt; letter-spacing: 0; line-height: 1.15; break-after: avoid; page-break-after: avoid; }
.ctt-cabecalho + .ctt-clausula { margin-top: 0; }
.ctt-p { text-align: justify; text-indent: 35pt; margin: 0 0 8pt; orphans: 2; widows: 2; }
.ctt-p em { font-style: italic; }
.ctt-nq { white-space: nowrap; }
.ctt-quebra-a { text-align-last: justify; margin-bottom: 0; }   /* parágrafo que continua na próxima folha (tela) */
.ctt-quebra-b { text-indent: 0; }
.ctt-ref { margin: 10pt 0 15pt; }
.ctt-enc { margin-bottom: 5pt; break-after: avoid; page-break-after: avoid; }
.ctt-banco { margin: 0 0 8pt; }
.ctt-banco div { margin: 0; }
.ctt-data { text-align: right; margin: 0; break-after: avoid; page-break-after: avoid; }
.ctt-assinaturas { break-inside: avoid; page-break-inside: avoid; }
.ctt-ass { text-align: center; border-top: .75pt solid #000; padding-top: 1pt; margin-top: 36.8pt; break-inside: avoid; }
.ctt-ass:first-child { margin-top: 43.2pt; }
.ctt-ass-nome { font-weight: bold; margin-bottom: 1pt; }
.ctt-ass-rep { font-style: italic; font-size: 9pt; }
.ctt-falta { background: #fff1a8; color: #9a3412; font-weight: bold; font-style: normal; padding: 0 2pt; border-radius: 2pt;
  -webkit-print-color-adjust: exact; print-color-adjust: exact; }

/* ================================================================== 3. Impressão / PDF
   O botão "Baixar PDF" coloca .ctt-fluxo no <body> e chama window.print().
   O @page (A4, margens 35,4 pt / 55 pt / 50 pt) é inserido pelo contratos.js só durante a impressão (#ctt-pagina),
   para não mudar a impressão das outras telas. A logo fica fixa (repete em todas as páginas)
   e o <thead> reserva o espaço dela no topo de cada página. */
.ctt-fluxo { display: none; }
@media print {
  body.ctt-imprimindo { background: #fff !important; margin: 0; }
  body.ctt-imprimindo::before, body.ctt-imprimindo::after { display: none !important; content: none !important; }
  body.ctt-imprimindo > *:not(.ctt-fluxo) { display: none !important; }
  body.ctt-imprimindo .ctt-fluxo { display: block; }
  .ctt-fluxo .ctt-cab-fixo { position: fixed; top: 0; left: 0; right: 0; height: 46pt; display: flex; justify-content: center; }
  .ctt-fluxo .ctt-cab-fixo img { height: 46pt; width: auto; }
  .ctt-fluxo .ctt-tab { width: 100%; border-collapse: collapse; }
  .ctt-fluxo .ctt-tab td { padding: 0; vertical-align: top; }
  .ctt-fluxo .ctt-espaco-cab { height: 89.5pt; }
  .ctt-fluxo .ctt-falta { background: #fff1a8 !important; }
}
