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

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --secondary: #64748b;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --background: #f1f5f9;
  --surface: #ffffff;
  --text: #1e293b;
  --text-light: #64748b;
  --border: #e2e8f0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--background);
  color: var(--text);
  line-height: 1.6;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

header {
  background: var(--primary);
  color: white;
  padding: 1rem 0;
  margin-bottom: 2rem;
}

header h1 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

nav {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.nav-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.3);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.nav-btn:hover, .nav-btn.active {
  background: rgba(255,255,255,0.2);
  border-color: white;
}

.section {
  display: none;
}

.section.active {
  display: block;
}

h2 {
  margin-bottom: 1.5rem;
  color: var(--text);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.stat-card h3 {
  color: var(--text-light);
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
}

.stat-card p {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--primary);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
  background: var(--surface);
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  margin-bottom: 2rem;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

label {
  font-weight: 500;
  margin-bottom: 0.25rem;
  font-size: 0.875rem;
}

input, select, textarea {
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 1rem;
}

textarea {
  min-height: 80px;
  resize: vertical;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.2s;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-warning {
  background: var(--warning);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
}

.btn-danger {
  background: var(--danger);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
}

.btn-success {
  background: var(--success);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
}

.table-container {
  background: var(--surface);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--background);
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-light);
}

tr:hover {
  background: var(--background);
}

.actions-bar {
  margin-bottom: 1rem;
}

.status-badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
}

.status-pendente {
  background: #fef3c7;
  color: #92400e;
}

.status-pago {
  background: #d1fae5;
  color: #065f46;
}

.status-atrasado {
  background: #fee2e2;
  color: #991b1b;
}

.status-protestado {
  background: #fce7f3;
  color: #9d174d;
}

.report-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.report-tab {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
}

.report-tab.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.report-content {
  background: var(--surface);
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--surface);
  padding: 2rem;
  border-radius: 8px;
  max-width: 500px;
  width: 90%;
  position: relative;
}

.modal-lg {
  max-width: 900px;
  max-height: 90vh;
  overflow-y: auto;
}

.contrato-editor {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  background: #f9fafb;
}

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

.editor-section h3 {
  font-size: 0.875rem;
  color: var(--text-light);
  text-transform: uppercase;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.editor-section .form-grid {
  background: transparent;
  padding: 0;
  box-shadow: none;
  margin-bottom: 0;
}

.readonly {
  background: #e2e8f0 !important;
  cursor: not-allowed;
}

.contrato-preview {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  background: white;
}

.contrato-preview h3 {
  font-size: 0.875rem;
  color: var(--text-light);
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}

.contrato-preview-box {
  border: 2px solid var(--primary);
  border-radius: 8px;
  overflow: hidden;
  background: white;
}

.contrato-preview-content {
  height: 500px;
  overflow-y: auto;
  padding: 1rem;
}

.preview-frame {
  border: 1px solid var(--border);
  border-radius: 4px;
  height: 400px;
  overflow-y: auto;
  background: white;
}

.preview-frame iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.btn-secondary {
  background: var(--secondary);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
}

.btn-secondary:hover {
  background: #475569;
}

.config-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0.5rem;
}

.config-tab {
  background: transparent;
  border: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  border-radius: 4px 4px 0 0;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
}

.config-tab:hover {
  background: var(--background);
}

.config-tab.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.config-content {
  background: var(--surface);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.config-panel {
  display: none;
  padding: 2rem;
}

.config-panel.active {
  display: block;
}

.config-panel h3 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.config-desc {
  color: var(--text-light);
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
}

.config-form {
  max-width: 600px;
}

.config-form .form-group {
  margin-bottom: 1.5rem;
}

.config-form .form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.config-form .form-group input,
.config-form .form-group select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 1rem;
}

.config-form .form-group small {
  display: block;
  margin-top: 0.5rem;
  color: var(--text-light);
  font-size: 0.75rem;
}

.config-form .form-group input[type="checkbox"] {
  width: auto;
  margin-right: 0.5rem;
}

.config-form .form-group label:has(input[type="checkbox"]) {
  display: flex;
  align-items: center;
  cursor: pointer;
}

.config-status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.config-status.configurado {
  background: #d1fae5;
  color: #065f46;
}

.config-status.nao-configurado {
  background: #fee2e2;
  color: #991b1b;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-light);
}

.alert-success {
  background: #d1fae5;
  color: #065f46;
  padding: 1rem;
  border-radius: 4px;
  margin-bottom: 1rem;
}

.alert-error {
  background: #fee2e2;
  color: #991b1b;
  padding: 1rem;
  border-radius: 4px;
  margin-bottom: 1rem;
}

@media (max-width: 768px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
  
  nav {
    flex-direction: column;
  }
  
  .nav-btn {
    width: 100%;
    text-align: center;
  }
}
