/* ── LDI App — style.css ─────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── Tokens ───────────────────────────────────────────── */
:root {
  --primary: #2563eb;
  --primary-dark: #1e3a8a;
  --primary-light: #dbeafe;
  --primary-50: #eff6ff;
  --bg-app: #f8fafb;
  --surface: #ffffff;
  --text-main: #111827;
  --text-secondary: #6b7280;
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --purple: #8b5cf6;
  --orange: #f97316;
  --sidebar-w: 260px;
  --header-h: 64px;
  --radius-lg: 1rem;
  --radius-xl: 1.25rem;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .08);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, .10);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, .14);
  --transition: all .2s cubic-bezier(.4, 0, .2, 1);
}

/* ── Reset base ───────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-app);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
}

input,
select,
textarea {
  font-family: inherit;
}

a {
  text-decoration: none;
  color: inherit;
}

/* ── Scrollbars ───────────────────────────────────────── */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

.scrollbar-hide {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.scrollbar-hide::-webkit-scrollbar {
  display: none;
}

/* ══════════════════════════════════════════════════════
   SPLASH SCREEN
══════════════════════════════════════════════════════ */
#splashScreen {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  transition: opacity .5s ease;
}

#splashScreen.fade-out {
  opacity: 0;
  pointer-events: none;
}

.splash-logo-wrap {
  width: 140px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: splash-pop .6s cubic-bezier(.34, 1.56, .64, 1) both;
}

.splash-logo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.splash-dots {
  display: flex;
  gap: .75rem;
  margin-top: 2.5rem;
}

.splash-dot {
  width: 10px;
  height: 10px;
  background: rgba(255, 255, 255, .9);
  border-radius: 50%;
  animation: pulse-dot 1.4s infinite;
}

.splash-dot:nth-child(2) {
  animation-delay: .2s;
}

.splash-dot:nth-child(3) {
  animation-delay: .4s;
}

@keyframes splash-pop {
  from {
    transform: scale(.5);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes pulse-dot {

  0%,
  100% {
    opacity: .3;
    transform: scale(.8);
  }

  50% {
    opacity: 1;
    transform: scale(1);
  }
}

/* ══════════════════════════════════════════════════════
   LOGIN / MFA
══════════════════════════════════════════════════════ */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  padding: 2rem 1rem;
  overflow-y: auto;
  /* Permite scroll si el contenido es grande */
}

.auth-screen.hidden {
  display: none;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 2.25rem 2rem;
  box-shadow: var(--shadow-lg);
  animation: slide-up .35s ease both;
}

.auth-logo {
  text-align: center;
  margin-bottom: 1.75rem;
}

.auth-logo img {
  height: 90px;
  object-fit: contain;
}

.auth-logo h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: .75rem;
}

.auth-logo p {
  font-size: .8rem;
  color: var(--text-secondary);
  margin-top: .25rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: .4rem;
}

.form-input {
  width: 100%;
  padding: .75rem 1rem;
  border: 1.5px solid #e5e7eb;
  border-radius: .75rem;
  font-size: .9rem;
  color: var(--text-main);
  background: #fff;
  transition: var(--transition);
  outline: none;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.form-input-wrap {
  position: relative;
}

.form-input-wrap .form-input {
  padding-right: 2.75rem;
}

.toggle-pass {
  position: absolute;
  right: .85rem;
  top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
  font-size: .9rem;
  transition: color .15s;
}

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

.btn-primary {
  width: 100%;
  padding: .9rem;
  background: var(--primary);
  color: #fff;
  font-size: .95rem;
  font-weight: 600;
  border-radius: .85rem;
  box-shadow: 0 4px 14px rgba(37, 99, 235, .35);
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
}

.btn-primary:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(37, 99, 235, .4);
}

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

.btn-primary:disabled {
  opacity: .6;
  cursor: not-allowed;
  transform: none;
}

/* ══════════════════════════════════════════════════════
   REDISEÑO DE BOTONES DE ACCIÓN (Globales)
══════════════════════════════════════════════════════ */
.btn-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  line-height: 1;
  text-decoration: none;
  outline: none;
  user-select: none;
}

.btn-action i {
  font-size: 14px;
}

.btn-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.btn-action:active {
  transform: translateY(0);
}

/* Primario (Azul - Imprimir, Guardar, Iniciar) */
.btn-action-primary {
  background-color: #2563eb;
  color: #ffffff;
}

.btn-action-primary:hover {
  background-color: #1d4ed8;
}

/* Peligro / Cancelar (Rojo suave) */
.btn-action-danger {
  background-color: #fee2e2;
  color: #991b1b;
  border-color: #fecaca;
}

.btn-action-danger:hover {
  background-color: #fecaca;
}

/* Éxito (Verde suave - Aprobar) */
.btn-action-success {
  background-color: #dcfce7;
  color: #166534;
  border-color: #bbf7d0;
}

.btn-action-success:hover {
  background-color: #bbf7d0;
}

/* Advertencia (Naranja suave - Devolver) */
.btn-action-warning {
  background-color: #fef3c7;
  color: #92400e;
  border-color: #fde68a;
}

.btn-action-warning:hover {
  background-color: #fde68a;
}

.auth-footer {
  text-align: center;
  margin-top: 1.5rem;
  font-size: .72rem;
  color: #9ca3af;
  line-height: 1.6;
}

/* MFA */
.mfa-inputs {
  display: flex;
  gap: .5rem;
  justify-content: center;
  margin: 1.25rem 0;
}

.mfa-digit {
  width: 48px;
  height: 56px;
  border: 2px solid #e5e7eb;
  border-radius: .65rem;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-dark);
  background: var(--primary-50);
  transition: var(--transition);
  outline: none;
}

.mfa-digit:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}

.mfa-hint {
  font-size: .75rem;
  color: var(--text-secondary);
  background: #f9fafb;
  border: 1px solid #f3f4f6;
  border-radius: .5rem;
  padding: .6rem .85rem;
  margin-bottom: 1rem;
  text-align: center;
}

.mfa-hint strong {
  color: var(--primary);
}

.btn-back {
  width: 100%;
  padding: .75rem;
  border: 1.5px solid #e5e7eb;
  border-radius: .85rem;
  color: #6b7280;
  font-size: .9rem;
  font-weight: 500;
  margin-top: .75rem;
  transition: var(--transition);
}

.btn-back:hover {
  background: #f9fafb;
  border-color: #d1d5db;
}

/* ══ MFA PREMIUM & RESPONSIVE ══════════════════════════════ */
#mfaScreen .auth-card {
  max-width: 400px;
  padding: 1.5rem 1.5rem;
  /* Más compacto */
}

.mfa-enroll-box {
  background: #f8fafc;
  border-radius: 1rem;
  padding: 1rem;
  margin-bottom: 1rem;
  border: 1px solid #e2e8f0;
  text-align: center;
}

.mfa-qr-wrap {
  background: #fff;
  padding: 1rem;
  border-radius: .75rem;
  display: inline-block;
  margin-bottom: 1rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.mfa-qr-wrap img {
  display: block;
  max-width: 180px;
  height: auto;
}

.mfa-qr-placeholder {
  width: 180px;
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
  color: #94a3b8;
  border-radius: .5rem;
}

.mfa-manual-key {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  background: #fff;
  padding: .5rem .75rem;
  border-radius: .5rem;
  border: 1px solid #e2e8f0;
  margin-bottom: 1rem;
}

.key-label {
  font-size: .7rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
}

.key-code {
  font-family: monospace;
  font-size: .9rem;
  font-weight: 700;
  color: var(--primary-dark);
  letter-spacing: 1px;
}

.copy-btn {
  color: #94a3b8;
  transition: color .15s;
  padding: .25rem;
}

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

.mfa-install-info {
  text-align: left;
  border-top: 1px solid #e2e8f0;
  padding-top: 1rem;
  margin-top: .5rem;
}

.install-links {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  margin-top: .5rem;
}

.install-link {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .8rem;
  font-weight: 600;
  color: #475569;
  padding: .5rem;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: .5rem;
  transition: all .15s;
}

.install-link:hover {
  border-color: var(--primary);
  color: var(--primary);
  transform: translateX(2px);
}

.install-link i {
  font-size: 1rem;
  width: 20px;
  text-align: center;
}

.hidden {
  display: none !important;
}

/* Error / success alerts */
.alert {
  padding: .75rem 1rem;
  border-radius: .65rem;
  font-size: .82rem;
  font-weight: 500;
  margin-bottom: 1rem;
  display: none;
}

.alert.show {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.alert-error {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.alert-success {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.alert-info {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid var(--primary-light);
}

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

.btn-primary.loading .spinner {
  display: block;
}

.btn-primary.loading .btn-text {
  display: none;
}

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

/* ══════════════════════════════════════════════════════
   APP LAYOUT
══════════════════════════════════════════════════════ */
#appContainer {
  display: none;
  min-height: 100vh;
}

#appContainer.visible {
  display: flex;
  flex-direction: column;
}

/* Enfoque mobile-first: stack vertical */

/* ── Sidebar ──────────────────────────────────────────── */
.sidebar {
  display: none;
  /* Oculto por defecto en móvil */
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid #f0f0f0;
  height: 100vh;
  position: sticky;
  top: 0;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 20;
}

.sidebar-brand {
  padding: 1.5rem 20px;
  border-bottom: 1px solid #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.sidebar-logo-img {
  max-width: 155px;
  height: auto;
  display: block;
}

.mobile-brand img {
  height: 36px;
  width: 36px;
  object-fit: contain;
}

.sidebar-nav {
  flex: 1;
  padding: .75rem .6rem;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem .85rem;
  border-radius: .75rem;
  font-size: .85rem;
  font-weight: 500;
  color: #6b7280;
  transition: var(--transition);
  width: 100%;
  text-align: left;
  position: relative;
  margin-bottom: 2px;
}

.nav-item i {
  width: 18px;
  text-align: center;
  font-size: .9rem;
  color: #9ca3af;
  flex-shrink: 0;
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), color 0.25s;
}

.nav-item:hover {
  background: rgba(37, 99, 235, 0.04);
  color: var(--primary);
  transform: translateX(8px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

.nav-item:hover i {
  color: var(--primary);
  animation: navIconPulse 0.8s ease-in-out infinite alternate;
}

@keyframes navIconPulse {
  0% { transform: scale(1.3) rotate(12deg); }
  100% { transform: scale(1.4) rotate(18deg); }
}

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

.nav-item.active i {
  color: var(--primary);
}

.nav-item .nav-badge {
  margin-left: auto;
  font-size: .68rem;
  font-weight: 600;
  background: #d1fae5;
  color: #065f46;
  padding: .1rem .45rem;
  border-radius: 99px;
}

.sidebar-user {
  padding: .85rem .6rem;
  border-top: 1px solid #f3f4f6;
}

.sidebar-user-inner {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem .85rem;
  border-radius: .75rem;
  cursor: pointer;
  transition: var(--transition);
}

.sidebar-user-inner:hover {
  background: #fef2f2;
}

.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .8rem;
  background: var(--primary-light);
  color: var(--primary);
  flex-shrink: 0;
}

.sidebar-user-name {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-main);
}

.sidebar-user-role {
  font-size: .72rem;
  color: var(--text-secondary);
}

.sidebar-logout-btn {
  margin-left: auto;
  color: #d1d5db;
  font-size: .9rem;
  transition: color .15s;
}

.sidebar-user-inner:hover .sidebar-logout-btn {
  color: var(--error);
}

/* ── Main area ────────────────────────────────────────── */
.main-area {
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
}

/* ── Desktop topbar ───────────────────────────────────── */
.topbar {
  display: none;
  /* Oculto por defecto en móvil */
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid #f0f0f0;
  padding: 0 1.75rem;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 15;
  flex-shrink: 0;
}

.topbar-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: .85rem;
}

.role-badge {
  font-size: .72rem;
  font-weight: 600;
  padding: .25rem .75rem;
  border-radius: 99px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: .65rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  font-size: 1rem;
  transition: var(--transition);
  position: relative;
}

.icon-btn:hover {
  background: #f3f4f6;
  color: #1e293b;
}

.notif-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 8px;
  height: 8px;
  background: var(--error);
  border-radius: 50%;
  border: 2px solid #fff;
}

.topbar-divider {
  width: 1px;
  height: 24px;
  background: #e5e7eb;
}

.topbar-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  font-size: .78rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Page content ─────────────────────────────────────── */
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  /* Padding reducido para móvil */
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  align-self: stretch;
}

/* ══════════════════════════════════════════════════════
   MOBILE HEADER
══════════════════════════════════════════════════════ */
.mobile-header {
  height: 58px;
  background: var(--surface);
  border-bottom: 1px solid #f0f0f0;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 30;
}

.mobile-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
}

.mobile-brand img {
  height: 28px;
  object-fit: contain;
}

.mobile-brand-text {
  font-size: .85rem;
  font-weight: 700;
  color: var(--primary-dark);
}

/* ── Mobile drawer ────────────────────────────────────── */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  backdrop-filter: blur(3px);
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
}

.drawer-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  z-index: 10001;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform .28s cubic-bezier(.4, 0, .2, 1);
}

.drawer.open {
  transform: translateX(0);
}

.drawer-header {
  padding: 1.1rem 1rem;
  border-bottom: 1px solid #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-close {
  width: 34px;
  height: 34px;
  border-radius: .5rem;
  color: #6b7280;
  display: flex;
  align-items: center;
  justify-content: center;
}

.drawer-close:hover {
  background: #f3f4f6;
}

.drawer-nav {
  flex: 1;
  padding: .75rem .6rem;
  overflow-y: auto;
}

.drawer-footer {
  padding: .85rem;
  border-top: 1px solid #f3f4f6;
}

.btn-logout-drawer {
  width: 100%;
  padding: .75rem 1rem;
  background: #fef2f2;
  color: var(--error);
  border-radius: .75rem;
  font-weight: 600;
  font-size: .88rem;
  display: flex;
  align-items: center;
  gap: .6rem;
  transition: var(--transition);
}

.btn-logout-drawer:hover {
  background: #fee2e2;
}

/* ── FAB logout (mobile) ──────────────────────────────── */
.fab-logout {
  position: fixed;
  bottom: 22px;
  right: 22px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--error);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: 0 8px 24px rgba(239, 68, 68, .45);
  z-index: 35;
  transition: var(--transition);
}

.fab-logout:hover,
.fab-logout:active {
  transform: scale(1.1);
}

/* ══════════════════════════════════════════════════════
   NOTIFICATIONS PANEL
══════════════════════════════════════════════════════ */
.notif-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .2);
  backdrop-filter: blur(2px);
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}

.notif-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.notif-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 360px;
  max-width: 100vw;
  background: var(--surface);
  z-index: 70;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(.4, 0, .2, 1);
  box-shadow: -8px 0 40px rgba(0, 0, 0, .12);
}

.notif-panel.open {
  transform: translateX(0);
}

.notif-panel-header {
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.notif-panel-title {
  font-size: 1rem;
  font-weight: 700;
}

.notif-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: .75rem;
}

.notif-mark-all {
  font-size: .75rem;
  color: var(--primary);
  font-weight: 600;
}

.notif-mark-all:hover {
  text-decoration: underline;
}

.notif-item {
  display: flex;
  gap: .75rem;
  padding: .85rem;
  border-radius: .75rem;
  margin-bottom: .4rem;
  transition: background .15s;
  cursor: pointer;
}

.notif-item:hover {
  background: #f9fafb;
}

.notif-item.unread {
  background: var(--primary-50);
}

.notif-item.unread:hover {
  background: #dbeafe;
}

.notif-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .9rem;
  flex-shrink: 0;
}

.notif-title {
  font-size: .83rem;
  font-weight: 600;
  color: var(--text-main);
}

.notif-body {
  font-size: .78rem;
  color: var(--text-secondary);
  margin-top: .1rem;
}

.notif-time {
  font-size: .7rem;
  color: #9ca3af;
  margin-top: .25rem;
}

.notif-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
  margin-top: 4px;
}

/* ══════════════════════════════════════════════════════
   STAT CARDS (Dashboard)
══════════════════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid #f3f4f6;
  transition: var(--transition);
}

.stat-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-5px);
}

.stat-card:hover .stat-icon i {
  animation: iconShake 0.5s ease-in-out;
}

@keyframes iconShake {
  0% { transform: rotate(0); }
  25% { transform: rotate(15deg) scale(1.2); }
  50% { transform: rotate(-15deg) scale(1.2); }
  75% { transform: rotate(10deg) scale(1.1); }
  100% { transform: rotate(0) scale(1.1); }
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: .75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  margin-bottom: .85rem;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1;
  text-align: center;
}

.stat-label {
  font-size: .78rem;
  color: var(--text-secondary);
  margin-top: .3rem;
  text-align: center;
}

.stat-trend {
  font-size: .72rem;
  font-weight: 600;
  margin-top: .4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .25rem;
}

.stat-trend.up {
  color: var(--success);
}

.stat-trend.down {
  color: var(--error);
}

/* Ajustes para móviles */
@media (max-width: 640px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .stat-card {
    padding: 0.85rem;
  }

  .stat-icon {
    width: 32px;
    height: 32px;
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
  }

  .stat-value {
    font-size: 1.35rem;
  }

  .stat-label {
    font-size: 0.68rem;
    margin-top: 0.15rem;
  }

  .stat-trend {
    font-size: 0.65rem;
    margin-top: 0.25rem;
  }
}

/* ══════════════════════════════════════════════════════
   STATUS BADGES
══════════════════════════════════════════════════════ */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .25rem .75rem;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}

.status-creada {
  background: #f3f4f6;
  color: #374151;
}

.status-asignada {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.status-en_proceso {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}

.status-por_revisar {
  background: #f5f3ff;
  color: #6d28d9;
  border: 1px solid #ddd6fe;
}

.status-devuelta {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.status-completada {
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.status-lista_entrega {
  background: #f0fdfa;
  color: #0d7377;
  border: 1px solid #99f6e4;
}

.status-entregada {
  background: #f9fafb;
  color: #6b7280;
}

.status-cancelada {
  background: #f3f4f6;
  color: #9ca3af;
  text-decoration: line-through;
}

/* ══════════════════════════════════════════════════════
   RECENT ORDERS TABLE / CARDS
══════════════════════════════════════════════════════ */
.section-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid #f3f4f6;
  overflow: hidden;
}

.section-card-header {
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid #f9fafb;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-card-title {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text-main);
}

.section-card-body {
  padding: 1rem;
}

/* ══════════════════════════════════════════════════════
   ANIMATIONS
══════════════════════════════════════════════════════ */
@keyframes slide-up {
  from {
    transform: translateY(24px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.animate-slide-up {
  animation: slide-up .3s ease both;
}

.animate-fade-in {
  animation: fade-in .25s ease both;
}

/* ══════════════════════════════════════════════════════
   RESPONSIVE - Desktop Overrides (min-width: 768px)
   ══════════════════════════════════════════════════════ */
@media (min-width: 768px) {
  #appContainer.visible {
    flex-direction: row;
  }

  .sidebar {
    display: flex;
  }

  .topbar {
    display: flex;
  }

  .mobile-header {
    display: none !important;
  }

  .fab-logout {
    display: none !important;
  }

  .page-content {
    padding: 1.75rem 2rem;
  }
}

@media (max-width: 767px) {
  .sidebar {
    display: none !important;
  }

  .topbar {
    display: none !important;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .payment-summary-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ── Payment Specific ────────────────────────────────── */
.form-control {
  padding: .6rem .75rem;
  border: 1.5px solid #e5e7eb;
  border-radius: .6rem;
  font-size: .88rem;
  transition: var(--transition);
  background: #fff;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-50);
}

.crud-table td {
  vertical-align: middle;
}

.payment-total-input {
  width: 90px;
  padding: .3rem;
  border: 1px solid #d1d5db;
  border-radius: .4rem;
  font-weight: 600;
  text-align: right;
}

@media (max-width: 767px) {
  .sidebar {
    display: none !important;
  }

  .topbar {
    display: none !important;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ── Print ───────────────────────────────────────────── */
@media print {
  @page {
    size: A6 portrait !important;
    margin: 0 !important;
  }

  html, body {
    width: 105mm !important;
    height: 148mm !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  body * {
    visibility: hidden;
  }

  #printArea,
  #printArea * {
    visibility: visible;
  }

  #printArea {
    position: absolute;
    left: 0;
    top: 0;
    width: 105mm !important;
    padding: 5mm !important;
    box-sizing: border-box !important;
  }
}

/* ══════════════════════════════════════════════════════
   BUSCADORES (Globales)
══════════════════════════════════════════════════════ */
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.search-wrap i {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  color: #64748b;
  font-size: 0.95rem;
  pointer-events: none;
  z-index: 1;
}

.search-input {
  width: 100%;
  padding: 12px 20px 12px 65px !important;
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 0.75rem;
  font-size: 14px;
  color: #1e293b;
  outline: none;
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.08);
  background: #fff;
}

.search-input::placeholder {
  color: #94a3b8;
}

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  padding: .6rem 1.25rem;
  border-radius: .75rem;
  font-weight: 600;
  font-size: .88rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  transition: var(--transition);
  cursor: pointer;
  border: 1.5px solid transparent;
}

.btn:active {
  transform: scale(.97);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, .2);
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.btn-secondary {
  background: #fff;
  color: #4b5563;
  border-color: #e5e7eb;
}

.btn-secondary:hover {
  background: #f9fafb;
  border-color: #d1d5db;
}

.btn-warning {
  background: var(--warning);
  color: #fff;
  box-shadow: 0 4px 12px rgba(245, 158, 11, .2);
}

.btn-warning:hover {
  background: #d97706;
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--error);
  color: #fff;
  box-shadow: 0 4px 12px rgba(239, 68, 68, .2);
}

.btn-danger:hover {
  background: #dc2626;
  transform: translateY(-1px);
}

/* ── Action Icons ────────────────────────────────────── */
.btn-icon-action {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  /* Gris por defecto */
  background: transparent;
  transition: all 0.2s ease;
  cursor: pointer;
  border: none;
  font-size: 1rem;
}

.btn-icon-action:hover {
  background: #f1f5f9;
  color: #1e293b;
}

.btn-icon-action.pay:hover {
  color: #10b981 !important;
  /* Verde al pasar el cursor */
  background: #f0fdf4;
}

.btn-icon-action.edit:hover {
  color: #2563eb;
  background: #eff6ff;
}

.btn-icon-action.print:hover {
  color: #4b5563;
  background: #f3f4f6;
}

.btn-icon-action.delete:hover {
  color: #ef4444;
  background: #fef2f2;
}

/* ══════════════════════════════════════════════════════
   LOGOUT CONFIRMATION MODAL
   ══════════════════════════════════════════════════════ */
.logout-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 20000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 1.5rem;
}

.logout-modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.logout-modal {
  background: #ffffff;
  width: 100%;
  max-width: 400px;
  border-radius: 24px;
  padding: 2.5rem;
  text-align: center;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
  transform: scale(0.9) translateY(20px);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.logout-modal-overlay.open .logout-modal {
  transform: scale(1) translateY(0);
}

.logout-modal h2 {
  font-size: 1.5rem;
  font-weight: 800;
  color: #1e293b;
  margin-bottom: 0.75rem;
  letter-spacing: -0.025em;
}

.logout-modal p {
  color: #64748b;
  line-height: 1.6;
  margin-bottom: 2rem;
  font-size: 0.95rem;
}

.logout-modal-actions {
  display: flex;
  gap: 1rem;
}

.logout-modal-actions .btn {
  flex: 1;
  padding: 0.875rem 1rem;
  font-weight: 700;
  border-radius: 12px;
  font-size: 0.95rem;
}

@media (max-width: 480px) {
  .logout-modal {
    padding: 2rem 1.5rem;
    border-radius: 20px;
  }

  .logout-modal-actions {
    flex-direction: column-reverse;
  }
}

/* ── NOTIFICATIONS PANEL ── */
.notif-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.notif-overlay.open {
  opacity: 1;
  visibility: visible;
}

.notif-panel {
  position: fixed;
  top: 0;
  right: -400px;
  width: 400px;
  height: 100%;
  background: white;
  z-index: 1001;
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.1);
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}

.notif-panel.open {
  right: 0;
}

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

.notif-header-content {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.notif-icon-circle {
  width: 42px;
  height: 42px;
  background: #eff6ff;
  color: #2563eb;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
}

.notif-header h3 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: #1e293b;
}

.notif-header p {
  margin: 0;
  font-size: 0.8rem;
  color: #64748b;
}

.notif-close-btn {
  background: #f8fafc;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s;
  display: grid;
  place-items: center;
}

.notif-close-btn:hover {
  background: #fee2e2;
  color: #ef4444;
}

.notif-list {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

/* Empty State */
.notif-empty-state {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
}

.empty-icon-box {
  width: 64px;
  height: 64px;
  background: #f8fafc;
  color: #cbd5e1;
  border-radius: 20px;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  margin-bottom: 1.25rem;
}

.notif-empty-state h4 {
  margin: 0 0 0.5rem 0;
  color: #334155;
  font-size: 1rem;
}

.notif-empty-state p {
  margin: 0;
  font-size: 0.85rem;
  color: #64748b;
  line-height: 1.5;
}

.notif-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid #f1f5f9;
  background: #f8fafc;
}

.btn-text-only {
  background: none;
  border: none;
  color: #2563eb;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 6px;
}

.btn-text-only:hover {
  background: #eff6ff;
}

@media (max-width: 480px) {
  .notif-panel {
    width: 100%;
    right: -100%;
  }
}

/* ══════════════════════════════════════════════════════
   CUSTOM SELECT (Premium Dropdowns)
   ══════════════════════════════════════════════════════ */
/* Filters container z-index fix */
.table-filters {
  position: relative !important;
  z-index: 200 !important;
  overflow: visible !important;
}

.custom-select {
  position: relative;
  width: 100%;
  outline: none;
  user-select: none;
  z-index: 10;
}

.custom-select.active {
  z-index: 101;
}

.custom-select.disabled {
  opacity: 0.6;
  pointer-events: none;
  background: #f1f5f9;
  border-radius: 0.75rem;
}

.select-trigger {
  width: 100%;
  height: 44px;
  padding: 0 1rem;
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.875rem;
  color: #1e293b;
}

.select-trigger:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.select-trigger.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.select-trigger i {
  font-size: 0.75rem;
  color: #64748b;
  transition: transform 0.2s;
}

.select-trigger.active i {
  transform: rotate(180deg);
}

.custom-select-options {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border-radius: 0.75rem;
  margin-top: 0.5rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  display: none;
  z-index: 1000;
  padding: 0.5rem;
  overflow: hidden;
  /* El scroll ahora está en .options-list */
}

/* Contenedor de Búsqueda dentro del Select */
.select-search-container {
  padding: 0.5rem;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.select-search-container i {
  color: #94a3b8;
  font-size: 0.85rem;
}

.select-search-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 0.875rem;
  color: #1e293b;
  outline: none;
  padding: 0.25rem 0;
}

.options-list {
  max-height: 250px;
  overflow-y: auto;
}

/* Scrollbar premium para la lista */
.options-list::-webkit-scrollbar {
  width: 5px;
}

.options-list::-webkit-scrollbar-track {
  background: transparent;
}

.options-list::-webkit-scrollbar-thumb {
  background: #e2e8f0;
  border-radius: 10px;
}

.custom-select-options.show {
  display: block;
}


.select-option {
  padding: 0.65rem 0.75rem;
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 0.875rem;
  color: #334155;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: background 0.15s;
}

.select-option:hover,
.select-option.focused {
  background: #f1f5f9;
  color: var(--primary);
}

.select-option.selected {
  background: var(--primary-50);
  color: var(--primary);
  font-weight: 600;
}

/* Status dots for select */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-creada {
  background: #94a3b8;
}

.dot-en_proceso {
  background: #3b82f6;
}

.dot-por_revisar {
  background: #8b5cf6;
}

.dot-aprobada {
  background: #10b981;
}

.dot-entregada {
  background: #f59e0b;
}

.dot-cancelada {
  background: #ef4444;
}

.dot-devuelta {
  background: #ea580c;
}

/* AUTOCOMPLETE PREMIUM */
.autocomplete-wrapper {
  position: relative;
  width: 100%;
}

.autocomplete-input-container {
  position: relative;
  display: flex;
  align-items: center;
}

.autocomplete-input-container .search-icon {
  position: absolute;
  left: 1rem;
  color: #94a3b8;
  font-size: 0.9rem;
}

.autocomplete-input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.5rem;
  border: 1.5px solid #e2e8f0;
  border-radius: 0.75rem;
  font-size: 0.9rem;
  color: #1e293b;
  background: white;
  transition: all 0.2s;
  outline: none;
}

.autocomplete-input-container.no-icon .autocomplete-input {
  padding-left: 1rem;
}

.autocomplete-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(var(--primary-rgb, 59, 130, 246), 0.1);
}

.autocomplete-results {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  background: white;
  border-radius: 0.75rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  border: 1px solid #e2e8f0;
  z-index: 1100;
  max-height: 300px;
  overflow-y: auto;
  display: none;
  padding: 0.5rem;
}

.autocomplete-item {
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 0.875rem;
  color: #334155;
  transition: background 0.15s;
}

.autocomplete-item:hover,
.autocomplete-item.focused {
  background: #f1f5f9;
  color: var(--primary);
}

.autocomplete-loader {
  position: absolute;
  right: 1rem;
  color: var(--primary);
}