:root {
  --bg: #fff;
  --text: #151515;
  --muted: #6b7280;
  --border: #e5e7eb;
  --red: #e2001a;
  --red-700: #c70015;
  --ok: #16a34a;
  --err: #dc2626;
  --disabled: #f3f4f6;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: Inter, system-ui, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: #f1efe3;
}

/* Header con logo */
.header {
  max-width: 700px;
  margin: 0 auto;
  padding: 10px 0px 10px 0px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.logo {
  height: auto;
  max-height: 5rem;
  width: auto;
  max-width: 9rem;
  object-fit: contain;
}

.crumbs {
  font-size: 12px;
  color: #9ca3af;
  flex: 1;
  text-align: right;
}

.container {
  max-width: 700px;
  margin: 0 auto;
  padding: 0 18px 56px;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.05);
  background: #fff;
}

.panel h1 {
  margin: 0 0 8px;
  font-size: 32px;
  font-weight: 800;
}

.panel .subtitle {
  color: var(--muted);
  margin-bottom: 24px;
}

/* Client info */
.client-info {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 24px;
}

.client-info .info-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 14px;
  gap: 12px;
}

.client-info .info-row:last-child {
  margin-bottom: 0;
}

.client-info .label {
  color: var(--muted);
  font-weight: 600;
}

.client-info .value {
  color: var(--text);
  font-weight: 400;
  text-align: right;
}

/* Warnings */
.expiry-warning {
  background: #fef3c7;
  border: 1px solid #fcd34d;
  color: #92400e;
  padding: 12px 16px;
  border-radius: 8px;
  text-align: center;
  font-weight: 600;
  margin: 16px;
  font-size: 14px;
}

.error-message {
  background: #fee;
  border: 1px solid #fcc;
  color: #c00;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}

/* Section groups */
.section-group {
  border: 1px solid var(--border);
  margin-bottom: 20px;
  border-radius: 12px;
  padding: 20px;
  background: #fafafa;
}

.section-group.completed {
  background: #f0fdf4;
  border-color: #22c55e;
}

.section-group.disabled {
  background: var(--disabled);
  opacity: 0.6;
  pointer-events: none;
}

.group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}

.group-title {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
}

.group-status {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 6px;
  font-weight: 600;
}

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

.group-status.completed {
  background: #dcfce7;
  color: #166534;
}

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

.group-status.available {
  background: #dbeafe;
  color: #1e40af;
}

/* Form fields */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

label {
  font-size: 13px;
  color: #394150;
  font-weight: 600;
}

.file-input-wrapper input[type="file"] {
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.file-input-wrapper input[type="file"]:disabled {
  background: var(--disabled);
  cursor: not-allowed;
}

/* Egresos */
.info-text {
  background: #f8fafc;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
  color: #6b7280;
  line-height: 1.5;
}

.debt-editable-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-family: inherit;
}

.debt-editable-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Deudas Experian */
.experian-debt-item {
  display: grid;
  grid-template-columns: 2fr 1fr auto 140px;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  margin-bottom: 12px;
}

.experian-debt-name {
  font-weight: 600;
  color: #374151;
  font-size: 14px;
}

.experian-debt-amount {
  font-weight: 700;
  color: #dc2626;
  font-size: 15px;
  text-align: right;
}

.experian-checkbox-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #6b7280;
  white-space: nowrap;
}

.experian-checkbox-wrapper input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  flex-shrink: 0;
}

.experian-payment-input {
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  width: 100%;
  max-width: 140px;
}

/* Grid egresos */
.egresos-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 24px 0 16px;
}

/* Egresos adicionales */
.additional-expense-item {
  padding: 16px;
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  animation: slideDown 0.3s ease-out;
}

.additional-expense-item .field {
  margin-bottom: 0;
}

.remove-expense-btn {
  background: #ef4444;
  color: white;
  border: none;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  font-weight: 700;
  margin-top: 24px;
  height: 42px;
  width: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.remove-expense-btn:hover {
  background: #dc2626;
}

/* Total box */
.total-box {
  margin-top: 20px;
  padding: 16px;
  background: #f0f9ff;
  border: 2px solid #3b82f6;
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.total-label {
  font-weight: 700;
  font-size: 16px;
  color: #1e40af;
}

.total-amount {
  font-weight: 700;
  font-size: 20px;
  color: #1e40af;
}

/* Declaration */
.declaration-section {
  margin-top: 24px;
  padding: 20px;
  border: 2px solid #fbbf24;
  border-radius: 12px;
  background: #fffbeb;
}

.declaration-title {
  font-weight: 700;
  font-size: 16px;
  color: #92400e;
  margin-bottom: 12px;
}

.declaration-content {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.declaration-checkbox {
  margin-top: 4px;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.declaration-text {
  font-size: 14px;
  color: #78350f;
  line-height: 1.5;
}

.declaration-link {
  color: #c2410c;
  text-decoration: underline;
  cursor: pointer;
  font-weight: 600;
}

.declaration-link:hover {
  color: #ea580c;
}

/* Buttons */
.btn {
  border: 0;
  border-radius: 999px;
  padding: 14px 28px;
  font-weight: 700;
  cursor: pointer;
  font-size: 15px;
  transition: transform 0.04s, background 0.2s;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-red {
  background: #e2001a;
  color: #fff;
  width: 100%;
  margin-top: 20px;
}

.btn-red:hover:not(:disabled) {
  background: #c70015;
}

/* Loading */
.loading {
  display: none;
  text-align: center;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8f9fa;
  margin-top: 16px;
}

.spinner {
  border: 4px solid #f3f3f3;
  border-top: 4px solid #e2001a;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  animation: spin 1s linear infinite;
  margin: 0 auto 12px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-text {
  color: var(--muted);
  font-size: 14px;
}


.btn-remove-expense {
  background: #dc3545;
  color: white;
  border: none;
  border-radius: 6px;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 20px;
  height: 42px;
  min-width: 42px;
  transition: all 0.3s;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0;
}


.btn-remove-expense:hover {
  background: #c82333;
  transform: scale(1.05);
}

.btn-add-expense {
  width: 100%;
  padding: 12px;
  background: #f8f9fa;
  color: #495057;
  border: 2px dashed #6c757d;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 16px;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}


.btn-add-expense:hover {
  background: #e9ecef;
  border-color: #495057;
}

.btn-add-expense .plus-icon {
  font-size: 20px;
  font-weight: bold;
}

#additional-expenses {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 16px 0;
}
.additional-expense-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 16px;
  align-items: end;
}

.expense-fields {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  align-items: center;
}

.expense-field {
  display: flex;
  flex-direction: column;
}

.expense-name,
.expense-amount {
  width: 100%;
}


/* Notice */
.notice {
  display: none;
  margin: 16px;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 14px;
}

.notice.ok {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #065f46;
}

.notice.err {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

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

.modal.hidden {
  display: none;
}

.modal-content {
  background: white;
  border-radius: 12px;
  padding: 24px;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  margin: 20px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

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

.modal-title {
  font-size: 20px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--muted);
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.modal-close:hover {
  background: var(--border);
}

.modal-body {
  font-size: 14px;
  line-height: 1.6;
}

.modal-body h3 {
  margin-top: 0;
}

.modal-body ul {
  margin: 8px 0;
  padding-left: 24px;
}

.hidden {
  display: none !important;
}

/* RESPONSIVE */
@media (max-width: 768px) {
  .logo {
    max-height: 48px;
    max-width: 150px;
  }
  
  .panel {
    padding: 24px 16px;
  }
  
  .panel h1 {
    font-size: 24px;
  }
  
  .client-info .info-row {
    flex-direction: column;
    gap: 4px;
  }
  
  .client-info .value {
    text-align: left;
  }
  
  .egresos-grid {
    grid-template-columns: 1fr;
  }
  
  .experian-debt-item {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  
  .experian-payment-input {
    max-width: 100%;
  }
  
  .total-box {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .declaration-content {
    gap: 8px;
  }
  
   .expense-fields {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  
  .btn-remove-expense {
    width: 100%;
    height: 36px;
  }
}

@media (max-width: 640px) {
  .header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .crumbs {
    text-align: left;
  }
  
  .container {
    padding: 0 12px 40px;
  }
}

.error-input {
  border: 2px solid #dc3545 !important;
  animation: shake 0.5s;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-10px); }
  75% { transform: translateX(10px); }
}

.field.hidden-field {
  display: none !important;
  visibility: hidden !important;
  height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  overflow: hidden !important;
}

.field.visible-field {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  height: auto !important;
}
