*, *::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: #059669;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

.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;
}

.pro-upload-field {
  background: #fffbeb;
  border: 1px dashed #f59e0b;
  padding: 12px;
  border-radius: 10px;
  margin-top: 10px;
}
.pro-upload-field label {
  font-size: 0.8rem;
  font-weight: 700;
  color: #92400e;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.pro-upload-field input {
  font-size: 0.8rem;
  margin-top: 4px;
}
.pro-upload-field small {
  color: #b45309;
  font-size: 0.7rem;
  display: block;
}

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

.btn-primary {
  flex: 1;
  background: #059669;
  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(5, 150, 105, 0.25);
  transition: all 0.2s;
}
.btn-primary:hover {
  background: #047857;
}

.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;
}

/* Folha de Recibo */
.sheet-a4 {
  display: flex;
  flex-direction: column;
}

.recibo-card {
  background: #ffffff;
  border: 2px solid #334155;
  border-radius: 4px;
  padding: 20px;
  margin-bottom: 16px;
  position: relative;
}

.recibo-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #334155;
  padding-bottom: 12px;
  margin-bottom: 16px;
}

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

.recibo-logo-img {
  max-height: 50px;
  max-width: 140px;
  object-fit: contain;
}

.recibo-main-title {
  font-size: 1.4rem;
  font-weight: 900;
  color: #0f172a;
  letter-spacing: 1px;
}

.recibo-via-badge {
  font-size: 0.75rem;
  color: #64748b;
  font-weight: 700;
  text-transform: uppercase;
}

.recibo-top-meta {
  display: flex;
  gap: 12px;
}

.meta-pill {
  border: 1px solid #cbd5e1;
  padding: 4px 10px;
  border-radius: 6px;
  text-align: right;
  background: #f8fafc;
}

.meta-pill .lbl {
  font-size: 0.65rem;
  color: #64748b;
  font-weight: 700;
  display: block;
}

.meta-pill .val {
  font-size: 1.15rem;
  font-weight: 800;
  color: #0f172a;
  font-family: 'Courier Prime', monospace;
}

.recibo-body {
  font-size: 0.95rem;
  line-height: 2;
  color: #1e293b;
  margin-bottom: 24px;
}

.recibo-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: 20px;
}

.recibo-date-local {
  font-size: 0.88rem;
  font-weight: 600;
}

.recibo-signature-box {
  width: 280px;
  text-align: center;
}

.recibo-signature-line {
  border-top: 1px solid #0f172a;
  margin-bottom: 6px;
}

.recibo-signature-name {
  font-size: 0.85rem;
  font-weight: 700;
}

.recibo-signature-doc {
  font-size: 0.75rem;
  color: #64748b;
}

/* Divisor de corte tesoura */
.cut-line-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 16px 0;
  color: #94a3b8;
  font-size: 0.75rem;
  font-weight: 600;
}

.cut-line-divider::before,
.cut-line-divider::after {
  content: '';
  flex: 1;
  border-top: 1px dashed #94a3b8;
}

/* Watermark */
.recibo-watermark {
  font-size: 0.68rem;
  color: #94a3b8;
  text-align: center;
  margin-top: 8px;
  font-style: italic;
}

.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; }
  .recibo-card {
    page-break-inside: avoid;
    break-inside: avoid;
    border: 1.5px solid #000000 !important;
    margin-bottom: 8mm;
  }
  @page { size: A4 portrait; margin: 12mm; }
}
