:root {
  --color-primary: #5D04D9;
  --color-secondary: #A65BD9;
  --color-tertiary: #CC94F2;
  --color-dark: #150940;
  --color-light: #91E0F2;
  --color-bg: #F4F6F8;
  --color-white: #FFFFFF;
  --color-error: #E74C3C;
  --color-success: #2ECC71;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', sans-serif;
}

body {
  background-color: var(--color-bg);
  color: var(--color-dark);
  -webkit-font-smoothing: antialiased;
}

/* Modales y utilidades mobile-first */
.container {
  padding: 20px;
  max-width: 100%;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 16px;
  background-color: var(--color-primary);
  color: var(--color-white);
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 12px;
  transition: opacity 0.2s;
}

.btn:active {
  opacity: 0.8;
}

.input-field {
  width: 100%;
  padding: 16px;
  border: 1px solid var(--color-tertiary);
  border-radius: 12px;
  font-size: 16px;
  margin-bottom: 16px;
  outline: none;
}

.input-field:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(93, 4, 217, 0.2);
}

.card {
  background: var(--color-white);
  padding: 20px;
  border-radius: 16px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
  margin-bottom: 16px;
}

/* Header de Login — independiente del header de la app */
.login-header {
  background: transparent;
  padding: 24px 20px 12px;
  text-align: center;
}

.header {
  background: linear-gradient(135deg, var(--color-dark) 0%, var(--color-primary) 100%);
  color: var(--color-white);
  padding: 0;
  border-bottom-left-radius: 24px;
  border-bottom-right-radius: 24px;
  box-shadow: 0 8px 32px rgba(21, 9, 64, 0.25);
  overflow: hidden;
  position: relative;
}

/* Barra superior: logo/título + botones de sesión */
.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 0;
  position: relative;
}

.app-topbar-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.app-topbar-brand h2 {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  margin: 0;
  letter-spacing: -0.2px;
}

.app-topbar-brand span {
  font-size: 0.72rem;
  color: var(--color-tertiary);
  margin-top: 1px;
  font-weight: 400;
}

.app-topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Botón de ayuda — icono puro */
.btn-icon {
  width: 34px;
  height: 34px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 10px;
  color: #fff;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(6px);
  text-decoration: none;
  flex-shrink: 0;
}

.btn-icon:hover {
  background: rgba(255,255,255,0.22);
  transform: scale(1.06);
}

/* Botón Cerrar Sesión — minimalista */
.btn-logout {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 12px;
  background: rgba(145, 224, 242, 0.15);
  border: 1.5px solid rgba(145, 224, 242, 0.5);
  border-radius: 20px;
  color: #91E0F2;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(6px);
  white-space: nowrap;
  letter-spacing: 0.2px;
}

.btn-logout:hover {
  background: rgba(145, 224, 242, 0.28);
  border-color: rgba(145, 224, 242, 0.8);
  transform: translateY(-1px);
}

.btn-logout:active { transform: scale(0.97); }

/* Botones de módulos — barra inferior del header */
.app-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px 18px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.app-nav::-webkit-scrollbar { display: none; }

.app-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border: none;
  border-radius: 22px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.22s cubic-bezier(0.34,1.56,0.64,1);
  letter-spacing: 0.1px;
  flex-shrink: 0;
}

.app-nav-btn:active { transform: scale(0.96); }

/* Variantes de color */
.app-nav-btn.nav-calendar {
  background: rgba(204,148,242,0.20);
  color: #E8C8FF;
  border: 1.5px solid rgba(204,148,242,0.40);
}
.app-nav-btn.nav-calendar:hover {
  background: rgba(204,148,242,0.35);
  border-color: rgba(204,148,242,0.7);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(166,91,217,0.30);
}

.app-nav-btn.nav-admin {
  background: rgba(255,255,255,0.18);
  color: #fff;
  border: 1.5px solid rgba(255,255,255,0.30);
}
.app-nav-btn.nav-admin:hover {
  background: rgba(255,255,255,0.28);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.20);
}

.app-nav-btn.nav-dashboard {
  background: rgba(52,73,94,0.45);
  color: #ccd6df;
  border: 1.5px solid rgba(255,255,255,0.15);
}
.app-nav-btn.nav-dashboard:hover {
  background: rgba(52,73,94,0.70);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.25);
}

/* Separador visual entre grupos de botones */
.app-nav-divider {
  width: 1px;
  height: 24px;
  background: rgba(255,255,255,0.15);
  flex-shrink: 0;
  margin: 0 2px;
}

@media (max-width: 480px) {
  .app-topbar-brand h2 { font-size: 0.9rem; }
  .app-nav-btn { font-size: 12px; padding: 8px 13px; }
  .btn-logout { font-size: 11px; padding: 6px 10px; }
}

#scanner-container {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
}

/* Custom Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(21, 9, 64, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.2s ease-in-out;
}

.modal-overlay.show {
  opacity: 1;
}

.modal-content {
  background: var(--color-white);
  padding: 24px;
  border-radius: 16px;
  width: 90%;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
  transform: translateY(-20px);
  transition: transform 0.2s ease-out;
}

.modal-overlay.show .modal-content {
  transform: translateY(0);
}

.modal-title {
  font-size: 18px;
  font-weight: bold;
  color: var(--color-dark);
  margin-bottom: 12px;
}

.modal-text {
  font-size: 14px;
  color: #555;
  margin-bottom: 24px;
  line-height: 1.5;
}

.modal-buttons {
  display: flex;
  gap: 12px;
}

.modal-btn-cancel {
  flex: 1;
  padding: 12px;
  background-color: #E0E0E0;
  color: #333;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s;
}

.modal-btn-cancel:hover {
  background-color: #D5D5D5;
}

.modal-btn-confirm {
  flex: 1;
  padding: 12px;
  background-color: var(--color-primary);
  color: var(--color-white);
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.modal-btn-confirm.danger {
  background-color: var(--color-error);
}

.modal-btn-confirm.success {
  background-color: var(--color-success);
}

.modal-btn-confirm:active {
  opacity: 0.8;
}

/* ==========================================================================
   Botonera Minimalista y Elegante para Modales de Acción (e.g. Editar Conteo)
   ========================================================================== */
.action-bar-btn-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 20px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  outline: none;
  user-select: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.btn-action svg {
  width: 15px;
  height: 15px;
  stroke-width: 2;
  flex-shrink: 0;
}

.btn-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
}

.btn-action:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

/* Variantes de Color Minimalistas */
/* Enviar a SAP (Hero Primary) */
.btn-action-primary {
  background: linear-gradient(135deg, #5D04D9 0%, #7C3AED 100%);
  color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(93, 4, 217, 0.25);
}
.btn-action-primary:hover {
  background: linear-gradient(135deg, #4c03b3 0%, #6d28d9 100%);
  box-shadow: 0 4px 12px rgba(93, 4, 217, 0.35);
}

/* Cargar Plano (Emerald Soft) */
.btn-action-success {
  background-color: #ECFDF5;
  color: #059669;
  border-color: #A7F3D0;
}
.btn-action-success:hover {
  background-color: #D1FAE5;
  color: #047857;
  border-color: #6EE7B7;
}

/* Descargar Plantilla (Sky Soft) */
.btn-action-template {
  background-color: #F0F9FF;
  color: #0284C7;
  border-color: #BAE6FD;
}
.btn-action-template:hover {
  background-color: #E0F2FE;
  color: #0369A1;
  border-color: #7DD3FC;
}

/* Exportar Excel (Purple Soft) */
.btn-action-excel {
  background-color: #F5F3FF;
  color: #7C3AED;
  border-color: #DDD6FE;
}
.btn-action-excel:hover {
  background-color: #EDE9FE;
  color: #6D28D9;
  border-color: #C4B5FD;
}

/* Cerrar Conteo (Amber Warning Soft) */
.btn-action-warning {
  background-color: #FFFBEB;
  color: #D97706;
  border-color: #FDE68A;
}
.btn-action-warning:hover {
  background-color: #FEF3C7;
  color: #B45309;
  border-color: #FCD34D;
}

/* Cerrar Panel (Slate Neutral) */
.btn-action-close {
  background-color: #F8FAFC;
  color: #475569;
  border-color: #E2E8F0;
}
.btn-action-close:hover {
  background-color: #F1F5F9;
  color: #1E293B;
  border-color: #CBD5E1;
}

/* ==========================================================================
   Overlay de Carga Masiva (Bulk Upload Loading)
   ========================================================================== */
.bulk-upload-overlay {
  position: fixed;
  inset: 0;
  background: rgba(21, 9, 64, 0.72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.bulk-upload-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.bulk-upload-card {
  background: #fff;
  border-radius: 20px;
  padding: 36px 40px;
  text-align: center;
  max-width: 360px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(21, 9, 64, 0.30);
  transform: translateY(12px) scale(0.97);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.bulk-upload-overlay.visible .bulk-upload-card {
  transform: translateY(0) scale(1);
}

/* Spinner animado */
.bulk-spinner {
  width: 52px;
  height: 52px;
  margin: 0 auto 20px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #5D04D9 0%, #CC94F2 50%, #E0E7FF 100%);
  animation: bulk-spin 0.9s linear infinite;
  position: relative;
}

.bulk-spinner::after {
  content: '';
  position: absolute;
  inset: 6px;
  background: #fff;
  border-radius: 50%;
}

@keyframes bulk-spin {
  to { transform: rotate(360deg); }
}

.bulk-upload-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-dark);
  margin-bottom: 6px;
}

.bulk-upload-subtitle {
  font-size: 13px;
  color: #6B7280;
  margin-bottom: 24px;
  line-height: 1.5;
}

/* Barra de progreso indeterminada */
.bulk-progress-track {
  height: 6px;
  background: #EDE9FE;
  border-radius: 99px;
  overflow: hidden;
}

.bulk-progress-bar {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #5D04D9, #A65BD9, #CC94F2, #5D04D9);
  background-size: 200% 100%;
  animation: bulk-shimmer 1.4s linear infinite;
}

@keyframes bulk-shimmer {
  0%   { background-position: 100% 50%; }
  100% { background-position: -100% 50%; }
}
