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

body {
  font-family: 'Inter', sans-serif;
  background: #f0f2f5;
  color: #1a1a2e;
  min-height: 100vh;
}

.container {
  min-height: 100vh;
}

/* ========== LOGIN ========== */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.login-box {
  background: white;
  padding: 40px;
  border-radius: 16px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-header {
  text-align: center;
  margin-bottom: 30px;
}

.login-header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: 4px;
  color: #1a1a2e;
}

.login-header p {
  font-size: 0.9rem;
  color: #666;
  letter-spacing: 2px;
  margin-top: 5px;
}

.login-form .form-group {
  margin-bottom: 20px;
}

.login-form label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: #555;
  margin-bottom: 8px;
}

.login-form input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid #e1e5eb;
  border-radius: 8px;
  font-size: 1rem;
  transition: all 0.2s;
}

.login-form input:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 0 3px rgba(52,152,219,0.15);
}

.login-form .btn-primary {
  width: 100%;
  padding: 16px;
  font-size: 1rem;
  margin-top: 10px;
}

.error-msg {
  color: #e74c3c;
  font-size: 0.85rem;
  margin-top: 15px;
  text-align: center;
}

/* ========== APP HEADER ========== */
.app-header {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  color: white;
  padding: 15px 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 20px rgba(0,0,0,0.2);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.header-left h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 2px;
}

.user-name {
  font-size: 0.85rem;
  opacity: 0.8;
  padding: 4px 12px;
  background: rgba(255,255,255,0.1);
  border-radius: 20px;
}

.header-nav {
  display: flex;
  gap: 10px;
}

.nav-btn {
  background: rgba(255,255,255,0.1);
  border: none;
  color: white;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
}

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

.btn-logout {
  background: rgba(231,76,60,0.8);
  border: none;
  color: white;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.btn-logout:hover {
  background: #e74c3c;
}

/* ========== APP MAIN ========== */
.app-main {
  padding: 30px;
  max-width: 1200px;
  margin: 0 auto;
}

/* ========== DASHBOARD ========== */
.dashboard h2 {
  margin-bottom: 30px;
  font-size: 1.8rem;
}

.dashboard-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 25px;
}

.dash-card {
  background: white;
  padding: 30px;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 4px 15px rgba(0,0,0,0.08);
}

.dash-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}

.dash-icon {
  font-size: 3rem;
  margin-bottom: 15px;
}

.dash-card h3 {
  font-size: 1.2rem;
  margin-bottom: 8px;
}

.dash-card p {
  color: #666;
  font-size: 0.9rem;
}

/* ========== VIEW HEADER ========== */
.view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
}

.view-header h2 {
  font-size: 1.6rem;
}

/* ========== SECTIONS ========== */
.form-sections {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.section {
  background: white;
  padding: 25px;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: #1a1a2e;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid #3498db;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
}

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

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

.form-group label {
  font-size: 0.8rem;
  font-weight: 500;
  color: #666;
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 12px 14px;
  border: 2px solid #e1e5eb;
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  transition: all 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 0 3px rgba(52,152,219,0.1);
}

.form-group textarea {
  resize: none;
  min-height: 44px;
}

.auto-resize {
  overflow-y: hidden;
  line-height: 1.4;
}

/* ========== ITEMS TABLE ========== */
.items-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 15px;
  table-layout: fixed; /* Ayuda a controlar mejor los anchos */
}

.items-table th, .items-table td {
  padding: 8px 5px; /* Reducido para que estén más pegados */
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}

.items-table th {
  text-align: left;
  background: #f8f9fa;
  font-size: 0.8rem;
  font-weight: 600;
  color: #666;
  border-bottom: 2px solid #e1e5eb;
}

/* Alineaciones de cabecera */
.items-table th:nth-child(2),
.items-table th:nth-child(3),
.items-table th:nth-child(4) {
  text-align: right;
}

/* Anchos de columna */
.items-table th:nth-child(1) { width: auto; } /* Descripción dinámica */
.items-table th:nth-child(2) { width: 80px; } /* Cantidad */
.items-table th:nth-child(3) { width: 130px; } /* Precio Unit */
.items-table th:nth-child(4) { width: 140px; } /* Subtotal */
.items-table th:nth-child(5) { width: 50px; }  /* Botón eliminar */

.items-table input {
  width: 100%;
  padding: 10px;
  border: 1px solid #e1e5eb;
  border-radius: 6px;
  font-size: 0.95rem;
  line-height: 1.2;
}

.items-table input.cantidad {
  text-align: right;
}

.items-table input.precio-unit {
  text-align: right;
}

.subtotal {
  font-weight: 600;
  color: #27ae60;
  text-align: right;
  white-space: nowrap;
  line-height: 42px; /* Alinea verticalmente con la altura del input */
  display: block;
}

.btn-remove {
  background: #e74c3c;
  color: white;
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
}

.btn-remove:hover {
  background: #c0392b;
}

/* ========== TOTAL BOX ========== */
.total-box {
  background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
  color: white;
  padding: 20px 25px;
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1.2rem;
  font-weight: 600;
  margin-top: 15px;
}

.total-box span:last-child {
  font-size: 1.5rem;
}

#totalManual::placeholder {
  color: rgba(255, 255, 255, 0.7);
}

/* ========== BUTTONS ========== */
.btn-primary,
.btn-secondary,
.btn-whatsapp {
  padding: 14px 24px;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(52,152,219,0.4);
}

.btn-secondary {
  background: #f8f9fa;
  color: #1a1a2e;
  border: 2px solid #e1e5eb;
}

.btn-secondary:hover {
  border-color: #3498db;
  color: #3498db;
}

.btn-whatsapp {
  background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
  color: white;
}

.btn-whatsapp:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(37,211,102,0.4);
}

.actions {
  display: flex;
  gap: 15px;
  margin-top: 20px;
  flex-wrap: wrap;
}

/* ========== ACCORDION ========== */
.accordion {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.accordion-item {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
  transition: all 0.3s;
}

.accordion-item.active {
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
}

.accordion-header {
  padding: 20px 25px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  background: white;
  transition: background 0.2s;
}

.accordion-header:hover {
  background: #f8f9fa;
}

.accordion-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #1a1a2e;
}

.accordion-content {
  padding: 20px 25px 25px 25px; /* Añadido 20px arriba */
  border-top: 1px solid #f0f0f0;
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========== STATUS ========== */
.status {
  margin-top: 15px;
  padding: 15px 20px;
  border-radius: 8px;
  font-weight: 500;
  text-align: center;
}

.status.hidden { display: none; }
.status.success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.status.error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.status.loading { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

/* ========== LISTADO TABLE ========== */
.table-container {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
}

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

.listado-table th {
  text-align: left;
  padding: 15px 20px;
  background: #f8f9fa;
  font-size: 0.8rem;
  font-weight: 600;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.listado-table td {
  padding: 15px 20px;
  border-bottom: 1px solid #f0f0f0;
  font-size: 0.95rem;
}

.listado-table tr:last-child td { border-bottom: none; }

.listado-table tr:hover { background: #fafbfc; }

.amount {
  font-weight: 600;
  color: #27ae60;
}

.empty-row {
  text-align: center;
  color: #999;
  padding: 40px !important;
}

.actions-cell {
  display: flex;
  gap: 8px;
}

.btn-icon {
  background: #f8f9fa;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: #e1e5eb;
}

.hidden {
  display: none !important;
}

.error-msg {
  background: #fdf2f2;
  color: #e74c3c;
  padding: 10px 15px;
  border-radius: 6px;
  font-size: 0.85rem;
  margin-top: 15px;
  border: 1px solid #fadbd8;
  text-align: center;
}

/* ========== BADGES ========== */
.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge.admin { background: #e8f4fd; color: #2980b9; }
.badge.vendedor { background: #eaf2f8; color: #3498db; }
.badge.active { background: #d4edda; color: #27ae60; }
.badge.inactive { background: #f8d7da; color: #e74c3c; }

/* ========== MODAL ========== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  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: white;
  padding: 30px;
  border-radius: 16px;
  width: 100%;
  max-width: 450px;
}

.modal-content h3 {
  margin-bottom: 20px;
  font-size: 1.3rem;
}

.modal-content .form-group {
  margin-bottom: 15px;
}

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

.modal-actions .btn-secondary,
.modal-actions .btn-primary {
  flex: 1;
}

#passHint {
  font-size: 0.75rem;
  color: #999;
  font-weight: normal;
}

/* ========== PREVIEW MODAL ========== */
.preview-modal {
  padding: 0;
  background: rgba(0,0,0,0.85);
}

.preview-window {
  width: 95%;
  max-width: 1000px;
  height: 95vh;
  background: #525659;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

.preview-header-bar {
  background: #1a1a2e;
  padding: 12px 25px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
}

.preview-actions-left {
  display: flex;
  gap: 15px;
}

.btn-small {
  padding: 8px 16px !important;
  font-size: 0.85rem !important;
}

.btn-close-x {
  background: transparent;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
  padding: 5px;
  line-height: 1;
}

.btn-close-x:hover {
  opacity: 1;
}

.budget-preview-body {
  flex: 1;
  overflow-y: auto;
  padding: 40px 20px;
  display: flex;
  justify-content: center;
}

/* Ajustes para el iframe en el preview */
#previewIframe {
  max-width: 100%;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
  .app-header {
    flex-direction: column;
    gap: 15px;
    padding: 15px;
  }
  
  .header-nav {
    flex-wrap: wrap;
    justify-content: center;
  }
  
  .form-grid {
    grid-template-columns: 1fr;
  }
  
  .actions {
    flex-direction: column;
  }
  
  .actions button {
    width: 100%;
    justify-content: center;
  }
  
  .listado-table {
    font-size: 0.85rem;
  }
  
  .listado-table th,
  .listado-table td {
    padding: 10px 12px;
  }
}
