@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=Plus+Jakarta+Sans:wght@400;500;600;700&family=Source+Serif+4:ital,opsz,wght@0,8..60,400;0,8..60,600;0,8..60,700;1,8..60,400&display=swap');

:root {
  --bg-page: #f3f1ea;
  --bg-panel: #ffffff;
  --bg-subtle: #e9e5da;
  --ink: #161817;
  --ink-secondary: #4a504d;
  --ink-muted: #717874;
  --border: #d8d4c8;
  --border-strong: #b5b0a1;

  /* Paleta com personalidade: Verde Mineral + Terracota Sóbrio + Azul Petróleo */
  --brand: #0e4d38;
  --brand-mid: #16694d;
  --brand-hover: #093526;
  --brand-tint: #eaf3ef;
  --brand-border: #b7d7c8;

  --terracotta: #b84a14;
  --terracotta-tint: #fdf0e8;
  --terracotta-border: #f3c6ad;

  --slate-blue: #1e3a5f;
  --slate-blue-tint: #edf2f8;

  --paper: #fffefb;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-page);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Header Institucional com Faixa Superior Verde Mineral */
.topbar {
  background: var(--bg-panel);
  border-top: 4px solid var(--brand);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 0;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand-mark {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--ink);
}

.brand-name {
  font-family: 'Source Serif 4', Georgia, serif;
  font-weight: 700;
  font-size: 1.45rem;
  letter-spacing: -0.02em;
  color: var(--brand);
}

.brand-divider {
  color: var(--terracotta);
  font-weight: 700;
}

.brand-tag {
  font-size: 0.82rem;
  color: var(--ink-secondary);
  font-weight: 500;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.topbar-link {
  font-size: 0.84rem;
  color: var(--ink-secondary);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.15s;
}

.topbar-link:hover {
  color: var(--brand);
}

/* Cabeçalho Editorial */
.intro-strip {
  padding: 1.75rem 0 1.35rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.35rem;
}

.intro-grid {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 1rem;
}

.intro-title {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: clamp(1.55rem, 2.5vw, 2.15rem);
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1.2;
  max-width: 680px;
}

.intro-desc {
  font-size: 0.92rem;
  color: var(--ink-secondary);
  margin-top: 0.4rem;
  max-width: 640px;
}

.legal-stamp {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.73rem;
  color: var(--slate-blue);
  background: var(--slate-blue-tint);
  border: 1px solid #c9d8eb;
  padding: 0.55rem 0.85rem;
  border-radius: 5px;
  line-height: 1.45;
  font-weight: 500;
}

/* Seletor de Modelos por Atividade */
.templates-bar {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.templates-label {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--terracotta);
  font-weight: 700;
  margin-right: 0.35rem;
}

.prof-chip {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--ink-secondary);
  padding: 0.36rem 0.78rem;
  border-radius: 5px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s ease;
}

.prof-chip:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-tint);
}

.prof-chip.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(14, 77, 56, 0.2);
}

/* Layout Mesa de Trabalho (Formulário + Folha A4) */
.desk-grid {
  display: grid;
  grid-template-columns: 440px 1fr;
  gap: 2rem;
  align-items: start;
  margin-bottom: 4rem;
}

@media (max-width: 1024px) {
  .desk-grid {
    grid-template-columns: 1fr;
  }
}

/* Painel Lateral de Preenchimento com Cabeçalho Verde Mineral */
.editor-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(22, 24, 23, 0.04);
}

.editor-header {
  padding: 0.95rem 1.25rem;
  background: var(--brand);
  color: #ffffff;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.editor-header h2 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
}

.editor-step-tag {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7rem;
  color: #d1fae5;
  background: rgba(255, 255, 255, 0.12);
  padding: 0.18rem 0.5rem;
  border-radius: 3px;
}

.editor-body {
  padding: 1.25rem;
}

.fieldset-title {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.73rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--brand);
  background: var(--brand-tint);
  margin: 1.15rem 0 0.75rem;
  padding: 0.32rem 0.6rem;
  border-left: 3px solid var(--brand);
  border-radius: 0 4px 4px 0;
}

.fieldset-title:first-child {
  margin-top: 0;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.field-group {
  margin-bottom: 0.75rem;
}

label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-secondary);
  margin-bottom: 0.28rem;
}

input,
textarea,
select {
  width: 100%;
  background: #ffffff;
  border: 1px solid var(--border-strong);
  color: var(--ink);
  padding: 0.55rem 0.7rem;
  border-radius: 5px;
  font-size: 0.88rem;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand-mid);
  box-shadow: 0 0 0 3px rgba(22, 105, 77, 0.12);
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

.btn-submit {
  width: 100%;
  background: var(--brand);
  color: #ffffff;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--brand);
  border-radius: 5px;
  cursor: pointer;
  margin-top: 0.5rem;
  transition: background 0.15s;
}

.btn-submit:hover {
  background: var(--brand-hover);
}

.btn-brand {
  background: var(--terracotta);
  color: #ffffff;
  font-weight: 600;
  font-size: 0.88rem;
  padding: 0.74rem 1.15rem;
  border: 1px solid var(--terracotta);
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn-brand:hover {
  background: #963a0d;
}

.btn-outline {
  background: #ffffff;
  color: var(--brand);
  border: 1px solid var(--brand-border);
  font-weight: 600;
  font-size: 0.86rem;
  padding: 0.68rem 1rem;
  border-radius: 5px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: all 0.15s;
}

.btn-outline:hover {
  border-color: var(--brand);
  background: var(--brand-tint);
}

/* Folha de Papel A4 com Topo Institucional */
.a4-sheet {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--border-strong);
  border-top: 5px solid var(--brand);
  box-shadow: 0 8px 28px rgba(22, 24, 23, 0.08);
  padding: 2.75rem 3rem;
  position: relative;
  min-height: 780px;
  border-radius: 2px;
}

@media (max-width: 680px) {
  .a4-sheet {
    padding: 1.5rem 1.25rem;
  }
  .field-row {
    grid-template-columns: 1fr;
  }
}

.watermark-draft {
  position: absolute;
  top: 44%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-24deg);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 2.3rem;
  font-weight: 600;
  color: rgba(184, 74, 20, 0.07);
  border: 3px solid rgba(184, 74, 20, 0.07);
  padding: 0.4rem 1.5rem;
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.a4-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 2px solid var(--brand);
  padding-bottom: 1.1rem;
  margin-bottom: 1.5rem;
  gap: 1rem;
}

.a4-doc-type {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.32rem;
  font-weight: 700;
  color: var(--brand);
  letter-spacing: -0.01em;
  line-height: 1.22;
}

.a4-sub {
  font-size: 0.82rem;
  color: var(--ink-secondary);
  margin-top: 0.3rem;
  font-weight: 500;
}

.a4-protocol {
  text-align: right;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.74rem;
  color: var(--ink-secondary);
  line-height: 1.45;
  flex-shrink: 0;
}

.status-tag {
  display: inline-block;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.18rem 0.5rem;
  border-radius: 3px;
  margin-bottom: 0.3rem;
  background: var(--terracotta-tint);
  color: var(--terracotta);
  border: 1px solid var(--terracotta-border);
}

.status-tag.paid {
  background: var(--brand-tint);
  color: var(--brand);
  border-color: var(--brand-border);
}

.a4-section {
  margin-bottom: 1.5rem;
}

.a4-section-title {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--brand);
  border-bottom: 1px solid var(--brand-border);
  padding-bottom: 0.3rem;
  margin-bottom: 0.75rem;
}

.parties-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.parties-table td {
  border: 1px solid var(--border);
  background: #faf9f5;
  padding: 0.7rem 0.85rem;
  vertical-align: top;
  width: 50%;
}

.party-role {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.68rem;
  color: var(--terracotta);
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: 0.2rem;
}

/* Tabela Orçamentária com Toque Verde Sóbrio */
.budget-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-top: 0.65rem;
}

.budget-table th {
  background: var(--brand-tint);
  border: 1px solid var(--brand-border);
  padding: 0.55rem 0.75rem;
  text-align: left;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--brand);
  font-weight: 700;
}

.budget-table td {
  border: 1px solid var(--brand-border);
  padding: 0.7rem 0.75rem;
}

.budget-total-row td {
  background: #f4f9f6;
  font-weight: 700;
  font-size: 0.95rem;
}

.mono-num {
  font-family: 'IBM Plex Mono', monospace;
}

/* Cláusulas Contratuais */
.clause-block {
  margin-bottom: 0.85rem;
  font-size: 0.84rem;
  line-height: 1.55;
  color: #262826;
  text-align: justify;
}

.clause-block strong {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 0.91rem;
  color: var(--slate-blue);
  display: block;
  margin-bottom: 0.15rem;
}

.clause-block.redacted span {
  color: transparent;
  text-shadow: 0 0 7px rgba(22, 24, 23, 0.42);
  user-select: none;
}

/* Barra de Homologação e Emissão com Destaque Quente */
.clearance-bar {
  margin-top: 1.75rem;
  background: var(--terracotta-tint);
  border: 1px solid var(--terracotta-border);
  border-left: 4px solid var(--terracotta);
  border-radius: 5px;
  padding: 1.15rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.clearance-info h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #7c2d12;
  margin-bottom: 0.2rem;
}

.clearance-info p {
  font-size: 0.82rem;
  color: #57534e;
}

.clearance-buttons {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

/* Assinaturas */
.signatures-grid {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2.5rem;
  font-size: 0.8rem;
  text-align: center;
}

.sig-line {
  border-bottom: 1px solid var(--ink);
  height: 2.2rem;
  margin-bottom: 0.4rem;
}

.doc-footer-hash {
  margin-top: 2rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.68rem;
  color: var(--ink-muted);
}

/* Modal Pix */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(14, 34, 26, 0.62);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal-backdrop.open {
  display: flex;
}

.modal-sheet {
  background: #ffffff;
  border: 1px solid var(--border-strong);
  border-top: 4px solid var(--brand);
  border-radius: 6px;
  max-width: 440px;
  width: 100%;
  padding: 1.5rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.modal-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
}

.pix-copy-box {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.74rem;
  background: var(--brand-tint);
  border: 1px solid var(--brand-border);
  color: var(--brand);
  padding: 0.75rem;
  border-radius: 4px;
  word-break: break-all;
  margin: 0.75rem 0;
}

/* Rodapé de Diretório Profissional */
.directory-footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0 3rem;
  margin-top: 2rem;
  font-size: 0.82rem;
  color: var(--ink-secondary);
}

.directory-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 1rem;
  margin-top: 0.75rem;
}

.directory-links a {
  color: var(--brand);
  text-decoration: none;
  font-weight: 500;
}

.directory-links a:hover {
  color: var(--terracotta);
  text-decoration: underline;
}

/* Impressão A4 Limpa */
@media print {
  body {
    background: #fff !important;
  }
  .topbar,
  .intro-strip,
  .templates-bar,
  .editor-panel,
  .clearance-bar,
  .directory-footer,
  .no-print,
  .watermark-draft {
    display: none !important;
  }
  .desk-grid {
    display: block !important;
    margin: 0 !important;
  }
  .a4-sheet {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
  }
}
