:root {
  --primary: #a8123d;
  --primary-dark: #7a0c2c;
  --primary-light: #fce8ee;
  --bg-gradient: linear-gradient(135deg, #7a0c2c 0%, #a8123d 100%);
  --bg-app: #f8fafc;
  --surface: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -1px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.04);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Banner de conectividad */
#network-banner {
  display: none;
  padding: 8px 16px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10000;
  transition: all 0.3s ease;
}

#network-banner.offline {
  display: block;
  background-color: #ef4444;
  color: #ffffff;
}

#network-banner.online {
  display: block;
  background-color: #10b981;
  color: #ffffff;
}

/* Toast de notificaciones */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  left: 20px;
  max-width: 400px;
  margin: 0 auto;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  background: white;
  padding: 14px 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  font-weight: 500;
  animation: slideDown 0.3s ease-out;
  border-left: 4px solid var(--primary);
  pointer-events: auto;
}

.toast.error { border-left-color: var(--danger); color: #991b1b; }
.toast.success { border-left-color: var(--success); color: #065f46; }
.toast.warning { border-left-color: var(--warning); color: #92400e; }

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

/* Contenedor principal de pantallas */
.app-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

/* ============================================================
   PANTALLA DE LOGIN
   ============================================================ */
.login-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 24px 16px;
  background: radial-gradient(circle at top right, #e0f2fe 0%, #f8fafc 60%);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  padding: 36px 28px;
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(226, 232, 240, 0.8);
  position: relative;
  overflow: hidden;
}

.login-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: var(--bg-gradient);
}

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

.login-logo {
  max-width: 220px;
  height: auto;
  margin-bottom: 18px;
  display: inline-block;
}

.login-header h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.3px;
  margin-bottom: 4px;
}

.login-header p {
  font-size: 13px;
  color: var(--text-muted);
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 6px;
}

.input-container,
.input-icon-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.input-container .input-icon,
.input-icon-wrapper .input-icon {
  position: absolute;
  left: 14px;
  color: #94a3b8;
  font-size: 16px;
  line-height: 1;
  pointer-events: none;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
}

.form-control {
  width: 100%;
  padding: 13px 40px 13px 42px;
  background-color: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  color: var(--text-main);
  transition: all 0.2s ease;
  outline: none;
}

.form-control:focus {
  background-color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(168, 18, 61, 0.15);
}

.toggle-password-btn,
.btn-toggle-eye {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px 6px;
  font-size: 16px;
  line-height: 1;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: color 0.2s ease;
}

.toggle-password-btn:hover,
.btn-toggle-eye:hover {
  color: var(--primary);
}

.form-options,
.login-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
  font-size: 13px;
}

.checkbox-label,
.remember-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.checkbox-label input[type="checkbox"],
.remember-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

.btn-primary {
  width: 100%;
  padding: 14px 20px;
  background: var(--bg-gradient);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 4px 12px rgba(168, 18, 61, 0.25);
}

.btn-primary:hover:not(:disabled) {
  opacity: 0.95;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(168, 18, 61, 0.35);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

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

/* Spinner animado */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: none;
}

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

.login-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 12px;
  color: #94a3b8;
}

/* ============================================================
   PANTALLA DE DASHBOARD (POST-LOGIN)
   ============================================================ */
.dashboard-wrapper {
  padding-bottom: 70px; /* espacio para bottom nav en móviles */
}

/* Top Navigation Bar */
.top-navbar {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 12px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-brand img {
  height: 32px;
  width: auto;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-badge {
  text-align: right;
  line-height: 1.2;
}

.user-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  display: block;
}

.user-role {
  font-size: 11px;
  color: var(--text-muted);
}

.btn-logout {
  background: #f1f5f9;
  border: 1px solid var(--border);
  color: #475569;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-logout:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #b91c1c;
}

/* Banner de instalación PWA Global */
.global-install-banner, .install-banner {
  background: linear-gradient(135deg, #881337 0%, #a8123d 50%, #be123c 100%);
  color: white;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 14px rgba(168, 18, 61, 0.28);
  position: relative;
  z-index: 1000;
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
  animation: slideDown 0.3s ease;
}

.global-install-banner.hidden, .install-banner.hidden {
  display: none !important;
}

.gib-content {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.gib-icon-box {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  overflow: hidden;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  flex-shrink: 0;
}

.gib-app-icon {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gib-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.gib-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.2;
}

.gib-subtitle {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.9);
  line-height: 1.3;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gib-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: 8px;
}

.btn-gib-install, .btn-install {
  background: #ffffff;
  color: #a8123d;
  border: none;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  transition: transform 0.15s ease, background 0.15s ease;
}

.btn-gib-install:hover, .btn-install:hover {
  background: #fff1f2;
  transform: translateY(-1px);
}

.btn-gib-close, .btn-install-close {
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  border: none;
  font-size: 16px;
  padding: 6px 8px;
  cursor: pointer;
  border-radius: 50%;
  line-height: 1;
}

.btn-gib-close:hover, .btn-install-close:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.15);
}

/* Botón flotante para cuando el banner esté minimizado */
.pwa-floating-install-pill {
  position: fixed;
  bottom: 78px;
  right: 16px;
  background: linear-gradient(135deg, #a8123d 0%, #be123c 100%);
  color: white;
  border: 2px solid white;
  border-radius: 30px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 4px 15px rgba(168, 18, 61, 0.35);
  z-index: 9998;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  animation: pwaPulse 2.5s infinite;
  transition: transform 0.2s ease;
}

.pwa-floating-install-pill:hover {
  transform: scale(1.05);
}

@keyframes pwaPulse {
  0% { box-shadow: 0 4px 15px rgba(168, 18, 61, 0.35); }
  50% { box-shadow: 0 4px 22px rgba(168, 18, 61, 0.65); }
  100% { box-shadow: 0 4px 15px rgba(168, 18, 61, 0.35); }
}

/* Modal de Instalación PWA */
.pwa-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(3px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}

.pwa-modal-backdrop.hidden {
  display: none !important;
}

.pwa-modal-card {
  background: #ffffff;
  width: 100%;
  max-width: 440px;
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  animation: slideUp 0.25s ease;
}

.pwa-modal-header {
  background: linear-gradient(135deg, #a8123d 0%, #881337 100%);
  color: white;
  padding: 24px 20px;
  text-align: center;
  position: relative;
}

.pwa-modal-header .btn-pwa-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pwa-modal-logo {
  width: 60px;
  height: 60px;
  border-radius: 16px;
  background: white;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
  margin: 0 auto 12px auto;
  display: block;
}

.pwa-modal-header h3 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  color: white;
}

.pwa-modal-header p {
  margin: 6px 0 0 0;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.9);
}

.pwa-modal-body {
  padding: 20px;
}

.pwa-benefits-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.pwa-benefit-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.pwa-benefit-icon {
  font-size: 18px;
  background: #fdf2f4;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.pwa-benefit-title {
  font-size: 13px;
  font-weight: 700;
  color: #1e293b;
  display: block;
}

.pwa-benefit-desc {
  font-size: 12px;
  color: #64748b;
  display: block;
}

/* Pasos para iOS o manual */
.pwa-guide-box {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 20px;
}

.pwa-guide-step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: #334155;
  margin-bottom: 8px;
}

.pwa-guide-step:last-child {
  margin-bottom: 0;
}

.pwa-step-num {
  background: #a8123d;
  color: white;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.pwa-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-pwa-primary {
  background: #a8123d;
  color: white;
  border: none;
  padding: 13px;
  border-radius: 12px;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  box-shadow: 0 4px 10px rgba(168, 18, 61, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.btn-pwa-primary:hover {
  background: #900f33;
}

.btn-pwa-secondary {
  background: transparent;
  color: #64748b;
  border: none;
  padding: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}

.btn-pwa-secondary:hover {
  color: #1e293b;
}

/* Contenido Principal Dashboard */
.main-content {
  padding: 18px 16px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

.welcome-card {
  background: white;
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  overflow: hidden;
}

.welcome-card::after {
  content: "";
  position: absolute;
  right: -20px;
  top: -20px;
  width: 100px;
  height: 100px;
  background: rgba(168, 18, 61, 0.05);
  border-radius: 50%;
}

.welcome-info h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text-main);
}

.welcome-info p {
  font-size: 13px;
  color: var(--text-muted);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  background: #ecfdf5;
  color: #065f46;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
}

/* Grid de Módulos Operativos */
.section-title {
  font-size: 15px;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 14px;
}

.modules-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

.module-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-align: left;
  text-decoration: none;
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  cursor: pointer;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 14px;
  width: 100%;
}

.module-card:hover, .module-card:active {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.module-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  background: var(--primary-light);
  color: var(--primary);
  flex-shrink: 0;
}

.module-content {
  flex: 1;
  min-width: 0;
}

.module-title {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}

.module-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.module-arrow {
  color: #cbd5e1;
  font-size: 20px;
  font-weight: 700;
  flex-shrink: 0;
  margin-left: auto;
}

/* Bottom Navigation Bar para Móviles */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: white;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 99;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: #64748b;
  text-decoration: none;
  cursor: pointer;
  padding: 6px;
  width: 25%;
}

.bottom-nav-item.active {
  color: var(--primary);
  font-weight: 600;
}

.bottom-nav-item .nav-icon {
  font-size: 18px;
}


/* Robust Header Styles to prevent deformation */
.top-navbar {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: 58px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.nav-brand {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.nav-brand img {
  height: 34px;
  max-height: 38px;
  width: auto;
  object-fit: contain;
  display: block;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.user-badge {
  text-align: right;
  line-height: 1.2;
}

.user-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.user-role {
  font-size: 11px;
  color: var(--primary);
  font-weight: 600;
}

.btn-logout {
  background: #fdf2f4;
  border: 1px solid #f8d7df;
  color: var(--primary);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-logout:hover {
  background: var(--primary);
  color: #ffffff;
}

.login-header .login-logo {
  max-height: 70px;
  width: auto;
  object-fit: contain;
  margin-bottom: 12px;
}
