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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f2f5;
  color: #333;
  line-height: 1.6;
}

.navbar {
  background: #1a237e;
  color: white;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.nav-brand {
  font-size: 1.3rem;
  font-weight: 700;
}

.nav-links {
  display: flex;
  gap: 0.5rem;
}

.nav-ejercicio {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(255,255,255,0.1);
  padding: 0.4rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
}

#ejercicio-actual-label {
  font-weight: 600;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
}

#user-name {
  color: rgba(255,255,255,0.9);
  font-size: 0.85rem;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-logout {
  background: rgba(255,255,255,0.15) !important;
  color: white !important;
  font-size: 0.8rem !important;
  padding: 0.35rem 0.75rem !important;
}

.btn-logout:hover {
  background: rgba(198,40,40,0.8) !important;
}

.nav-btn {
  background: transparent;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  cursor: pointer;
  border-radius: 4px;
  font-size: 0.9rem;
  transition: background 0.2s;
}

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

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
}

.seccion { display: none; }
.seccion.active { display: block; }

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.section-header h2 {
  color: #1a237e;
  font-size: 1.5rem;
}

.btn {
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
}

.btn-primary { background: #1a237e; color: white; }
.btn-primary:hover { background: #283593; }
.btn-secondary { background: #e0e0e0; color: #333; }
.btn-secondary:hover { background: #d0d0d0; }
.btn-danger { background: #d32f2f; color: white; }
.btn-danger:hover { background: #b71c1c; }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.btn-info { background: #0288d1; color: white; }
.btn-info:hover { background: #0277bd; }

.filtros {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.filtros input, .filtros select {
  padding: 0.5rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.9rem;
  background: white;
}

.filtros input:focus, .filtros select:focus {
  outline: none;
  border-color: #1a237e;
}

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

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

th {
  background: #f5f5f5;
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.85rem;
  color: #555;
  border-bottom: 2px solid #e0e0e0;
}

td {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid #eee;
  font-size: 0.9rem;
}

tr:hover { background: #f8f9ff; }

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-activo { background: #e8f5e9; color: #2e7d32; }
.badge-pasivo { background: #e3f2fd; color: #1565c0; }
.badge-capital { background: #f3e5f5; color: #7b1fa2; }
.badge-resultados { background: #fff3e0; color: #e65100; }
.badge-orden { background: #f5f5f5; color: #616161; }
.badge-deudora { background: #e8f5e9; color: #2e7d32; }
.badge-acreedora { background: #fce4ec; color: #c62828; }
.badge-activa { background: #e8f5e9; color: #2e7d32; }
.badge-inactiva { background: #ffebee; color: #c62828; }
.badge-cancelada { background: #ffebee; color: #c62828; }
.badge-ingreso-poliza { background: #e8f5e9; color: #1b5e20; }
.badge-egreso-poliza { background: #ffebee; color: #b71c1c; }
.badge-diario-poliza { background: #e3f2fd; color: #0d47a1; }

 saldo-positivo { color: #2e7d32; font-weight: 600; }
 saldo-negativo { color: #c62828; font-weight: 600; }
 saldo-cero { color: #999; }

.actions-cell {
  display: flex;
  gap: 0.3rem;
}

.modal {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal.active { display: flex; }

.modal-content {
  background: white;
  border-radius: 10px;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.modal-lg { max-width: 900px; }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid #eee;
}

.modal-header h3 { color: #1a237e; }

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #999;
}

.modal-close:hover { color: #333; }

form { padding: 1.5rem; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

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

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

.form-group label {
  font-weight: 600;
  font-size: 0.85rem;
  color: #555;
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 0.5rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.9rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #1a237e;
  box-shadow: 0 0 0 2px rgba(26,35,126,0.1);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid #eee;
}

h4 {
  margin: 1rem 0 0.5rem;
  color: #1a237e;
}

.detalle-row {
  display: grid;
  grid-template-columns: 2fr 2fr 1fr 1fr auto;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  align-items: center;
}

.detalle-row select,
.detalle-row input {
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.85rem;
}

.detalles-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #eee;
}

.totales {
  display: flex;
  gap: 1.5rem;
  font-size: 0.9rem;
}

.diferencia-ok { color: #2e7d32; font-weight: 600; }
.diferencia-error { color: #c62828; font-weight: 600; animation: shake 0.3s; }

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

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

.reporte-card {
  background: white;
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  cursor: pointer;
  transition: all 0.2s;
  border-left: 4px solid #1a237e;
}

.reporte-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.reporte-card h3 { color: #1a237e; margin-bottom: 0.5rem; font-size: 1rem; }
.reporte-card p { color: #666; font-size: 0.85rem; }

.reporte-card-actions {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #eee;
  text-align: right;
}

#contenido-reporte {
  background: white;
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.reporte-titulo {
  text-align: center;
  color: #1a237e;
  margin-bottom: 1.5rem;
  font-size: 1.2rem;
}

.reporte-subtitulo {
  text-align: center;
  color: #666;
  margin-bottom: 1rem;
}

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

.resumen-card {
  text-align: center;
  padding: 1rem;
  border-radius: 8px;
  background: #f8f9ff;
}

.resumen-card .label { font-size: 0.8rem; color: #666; text-transform: uppercase; }
.resumen-card .valor { font-size: 1.3rem; font-weight: 700; color: #1a237e; }

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: #666;
}

.empty-state h2 {
  color: #1a237e;
  margin-bottom: 0.5rem;
}

.empty-state p {
  margin-bottom: 1.5rem;
  font-size: 1.1rem;
}

.empty-state .btn {
  margin: 0 0.5rem;
}

.ej-activo {
  background: #e8f5e9 !important;
  border-left: 4px solid #2e7d32;
}

@media (max-width: 768px) {
  .navbar { flex-direction: column; height: auto; padding: 1rem; gap: 0.5rem; }
  .nav-links { flex-wrap: wrap; justify-content: center; }
  .form-grid { grid-template-columns: 1fr; }
  .detalle-row { grid-template-columns: 1fr; }
  .totales { flex-direction: column; gap: 0.5rem; }
}
