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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: #f1f5f9;
  color: #1e293b;
  line-height: 1.5;
}

.app-header {
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  padding: 16px 24px;
}

.header-container {
  max-width: 1300px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.portal-back {
  display: block;
  font-size: 0.75rem;
  color: #64748b;
  text-decoration: none;
  font-weight: 600;
}
.portal-back:hover { color: #2563eb; }

.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon { font-size: 2rem; }

.brand-logo h1 {
  font-size: 1.25rem;
  font-weight: 800;
  color: #0f172a;
}

.tagline {
  font-size: 0.75rem;
  color: #64748b;
}

.main-container {
  max-width: 1300px;
  margin: 24px auto;
  padding: 0 16px;
}

.workspace-grid {
  display: grid;
  grid-template-columns: 460px 1fr;
  gap: 24px;
  align-items: start;
}

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

.form-panel {
  background: #ffffff;
  border-radius: 16px;
  padding: 24px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.panel-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #0f172a;
}

.btn-secondary-sm {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.form-group-row {
  display: flex;
  gap: 12px;
}
.flex-1 { flex: 1; }
.flex-2 { flex: 2; }

.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
  width: 100%;
}

.form-field label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #475569;
}

.form-field input,
.form-field select,
.form-field textarea {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 9px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  outline: none;
  background: #f8fafc;
  color: #1e293b;
  transition: all 0.2s;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  border-color: #2563eb;
  background: #ffffff;
}

.readonly-highlight {
  background: #f1f5f9 !important;
  color: #334155 !important;
  font-weight: 600;
  font-size: 0.8rem !important;
}

.form-divider {
  border: 0;
  border-top: 1px solid #e2e8f0;
  margin: 14px 0 10px 0;
}

.form-panel h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #64748b;
  margin-bottom: 10px;
  font-weight: 700;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.btn-primary {
  flex: 1;
  background: #1e3a8a;
  color: #ffffff;
  border: none;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 12px 18px;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(30, 58, 138, 0.25);
  transition: all 0.2s;
}
.btn-primary:hover {
  background: #172554;
}

.btn-outline {
  background: transparent;
  border: 1px solid #cbd5e1;
  color: #64748b;
  font-weight: 600;
  padding: 12px 14px;
  border-radius: 10px;
  cursor: pointer;
}

/* Preview Panel */
.preview-panel {
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid #e2e8f0;
  padding: 24px;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
}

.preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  background: #f8fafc;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
}

.btn-pro-trigger {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  color: #b45309;
  font-weight: 700;
  font-size: 0.78rem;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
}

/* Contrato Formal */
.contract-sheet-a4 {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  padding: 48px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.04);
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.05rem;
  line-height: 1.8;
  color: #111827;
  text-align: justify;
}

.contract-main-title {
  text-align: center;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.5rem;
  font-weight: 800;
  color: #0f172a;
  text-transform: uppercase;
  margin-bottom: 24px;
  letter-spacing: 1px;
}

.contract-section-clause {
  margin-bottom: 20px;
}

.clause-heading {
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.95rem;
  color: #1e3a8a;
  margin-bottom: 4px;
}

.contract-closing {
  margin-top: 32px;
}

.contract-signatures-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 36px;
  margin-top: 48px;
  text-align: center;
}

.contract-sig-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.sig-border {
  width: 90%;
  border-top: 1px solid #111827;
  margin-bottom: 6px;
}

.sig-role {
  font-size: 0.85rem;
  font-weight: 700;
}

.sig-name {
  font-size: 0.8rem;
  color: #374151;
}

.witnesses-block {
  margin-top: 40px;
  border-top: 1px dashed #cbd5e1;
  padding-top: 20px;
}

.witnesses-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 36px;
  margin-top: 24px;
  text-align: center;
}

.contract-watermark {
  text-align: center;
  font-size: 0.72rem;
  color: #94a3b8;
  margin-top: 32px;
  font-family: 'Inter', sans-serif;
  font-style: italic;
  border-top: 1px dotted #e2e8f0;
  padding-top: 8px;
}

.app-footer {
  text-align: center;
  padding: 32px 16px;
  color: #64748b;
  font-size: 0.8rem;
  margin-top: 48px;
  border-top: 1px solid #e2e8f0;
}

@media print {
  body { background: #ffffff !important; }
  .no-print, .app-header, .form-panel, .preview-toolbar, .app-footer, .ad-slot-container {
    display: none !important;
  }
  .main-container { max-width: 100% !important; margin: 0 !important; padding: 0 !important; }
  .workspace-grid { display: block !important; }
  .preview-panel { border: none !important; box-shadow: none !important; padding: 0 !important; }
  .contract-sheet-a4 {
    border: none !important;
    padding: 0 !important;
    box-shadow: none !important;
    font-size: 11pt !important;
    line-height: 1.6 !important;
  }
  @page { size: A4 portrait; margin: 20mm 15mm; }
}
