:root {
  --primary: #0e8dd0;
  --primary-dark: #0039aa;
  --primary-light: #e0f2fe;
  --bg-gradient: linear-gradient(135deg, #0039aa 0%, #0e8dd0 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 {
  position: relative;
  display: flex;
  align-items: center;
}

.input-container .input-icon {
  position: absolute;
  left: 14px;
  color: #94a3b8;
  font-size: 16px;
  pointer-events: none;
}

.form-control {
  width: 100%;
  padding: 13px 14px 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(14, 141, 208, 0.15);
}

.toggle-password-btn {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px 6px;
  font-size: 16px;
  border-radius: 6px;
}

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

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

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

.checkbox-label 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(14, 141, 208, 0.25);
}

.btn-primary:hover:not(:disabled) {
  opacity: 0.95;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(14, 141, 208, 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 */
.install-banner {
  background: linear-gradient(135deg, #0284c7 0%, #0e8dd0 100%);
  color: white;
  padding: 14px 18px;
  margin: 14px;
  border-radius: var(--radius);
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-md);
  animation: slideDown 0.3s ease;
}

.install-text {
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.btn-install {
  background: white;
  color: var(--primary);
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.btn-install-close {
  background: transparent;
  color: white;
  border: none;
  padding: 6px;
  font-size: 14px;
  cursor: pointer;
  opacity: 0.8;
}

/* 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(14, 141, 208, 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: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

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

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

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

.module-title {
  font-size: 14px;
  font-weight: 600;
}

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

/* 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;
}
