/* ==========================================================================
   FastQR Design System & Styling
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
  --font-display: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Primary Palette */
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --primary-light: #EEF2FF;
  --primary-glow: rgba(79, 70, 229, 0.25);

  /* Accent Colors */
  --accent: #06B6D4;
  --accent-purple: #8B5CF6;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;

  /* Neutrals */
  --bg-dark: #0F172A;
  --card-dark: #1E293B;
  --card-border: #334155;
  --text-primary: #0F172A;
  --text-secondary: #64748B;
  --text-light: #F8FAFC;
  --text-muted: #94A3B8;

  --bg-page: #F8FAFC;
  --card-light: #FFFFFF;
  --border-light: #E2E8F0;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-xl: 32px;

  --shadow-sm: 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 24px -4px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 40px -8px rgba(15, 23, 42, 0.12);
  --shadow-glow: 0 0 30px rgba(79, 70, 229, 0.35);
}

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.25;
  color: var(--text-primary);
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: all 0.2s ease;
}

/* ==========================================================================
   Navbar & Layout Header
   ========================================================================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-light);
  padding: 12px 24px;
}

.header-container {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.4rem;
  color: var(--text-primary);
}

.brand-logo img {
  width: 38px;
  height: 38px;
  border-radius: 10px;
}

.brand-badge {
  font-size: 0.65rem;
  background: var(--primary-light);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.nav-menu {
  display: flex;
  align-items: center;
  gap: 20px;
}

.nav-link {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
}

.nav-link:hover, .nav-link.active {
  color: var(--primary);
  background: var(--primary-light);
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  background: #F1F5F9;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
}

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

/* ==========================================================================
   Network Status Bar (PWA Offline / Online)
   ========================================================================== */
.network-status-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
  transition: all 0.3s ease;
}

.status-offline {
  background: #FEF2F2;
  color: #DC2626;
  border-bottom: 1px solid #FEE2E2;
}

.status-online {
  background: #ECFDF5;
  color: #059669;
  border-bottom: 1px solid #D1FAE5;
}

.badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.badge-offline { background: #DC2626; animation: pulse 1.5s infinite; }
.badge-online { background: #059669; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.hidden { display: none !important; }

/* ==========================================================================
   Main Content Layout
   ========================================================================== */
.main-wrapper {
  flex: 1;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 24px;
}

/* ==========================================================================
   Cards & Panels
   ========================================================================== */
.card {
  background: var(--card-light);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-primary:hover {
  background: var(--primary-hover);
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--primary-glow);
}

.btn-secondary {
  background: #F1F5F9;
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: #E2E8F0;
}

.btn-outline {
  border-color: var(--border-light);
  background: transparent;
  color: var(--text-primary);
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.btn-danger {
  background: #FEE2E2;
  color: #DC2626;
}

.btn-danger:hover {
  background: #FCA5A5;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1.05rem;
  border-radius: var(--radius-md);
}

.btn-block {
  width: 100%;
}

/* ==========================================================================
   Forms & Inputs
   ========================================================================== */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.form-control {
  width: 100%;
  padding: 12px 16px;
  font-size: 0.95rem;
  font-family: var(--font-body);
  color: var(--text-primary);
  background: #FFFFFF;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  outline: none;
  transition: all 0.2s ease;
}

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

/* ==========================================================================
   Dashboard Stats Grid
   ========================================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: white;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
}

.stat-label {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 600;
}

/* ==========================================================================
   Camera Scanner Viewport & HUD
   ========================================================================== */
.scanner-container {
  position: relative;
  background: #000000;
  border-radius: var(--radius-lg);
  overflow: hidden;
  max-width: 720px;
  margin: 0 auto;
  aspect-ratio: 3 / 4;
  box-shadow: var(--shadow-lg);
}

.scanner-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.scanner-hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px;
}

.hud-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: auto;
}

.hud-badge {
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(10px);
  color: #ffffff;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.hud-guide-box {
  width: 82%;
  height: 72%;
  margin: auto;
  border: 2px dashed rgba(56, 189, 248, 0.6);
  border-radius: 16px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.35);
  position: relative;
}

.hud-laser {
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #38BDF8, #818CF8, transparent);
  box-shadow: 0 0 14px #38BDF8;
  position: absolute;
  animation: scanMove 3s infinite ease-in-out;
}

@keyframes scanMove {
  0% { top: 4%; }
  50% { top: 96%; }
  100% { top: 4%; }
}

.hud-bottom {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  pointer-events: auto;
  padding-bottom: 12px;
}

.shutter-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 6px solid rgba(255, 255, 255, 0.4);
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.4);
}

.shutter-btn:active {
  transform: scale(0.92);
  background: #E2E8F0;
}

/* ==========================================================================
   Capture Screen & Carousel Scheme (from pantalla_fotos.html)
   ========================================================================== */
.capture-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 520px;
  margin: 0 auto;
  width: 100%;
}

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  font-weight: 600;
}

.capture-card {
  background: linear-gradient(145deg, #1E293B, #0F172A);
  border: 1px solid #334155;
  border-radius: 20px;
  padding: 26px 20px;
  text-align: center;
  color: #FFFFFF;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.camera-icon {
  font-size: 44px;
  margin-bottom: 2px;
  filter: drop-shadow(0 0 12px rgba(56, 189, 248, 0.4));
}

.capture-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #F8FAFC;
}

.capture-desc {
  font-size: 0.84rem;
  color: #94A3B8;
  max-width: 320px;
  line-height: 1.5;
}

.capture-btn-group {
  display: flex;
  gap: 12px;
  width: 100%;
  max-width: 420px;
  justify-content: center;
}

@media (max-width: 480px) {
  .capture-btn-group {
    flex-direction: column;
    gap: 10px;
  }
}

.btn-capture {
  background: #10B981;
  color: #FFFFFF;
  border: none;
  border-radius: 14px;
  padding: 14px 28px;
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(16, 185, 129, 0.45);
  width: 100%;
  max-width: 320px;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-capture:hover {
  background: #059669;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.55);
}

.btn-capture:active {
  transform: scale(0.98);
}

.btn-upload-doc {
  background: #1E293B;
  color: #38BDF8;
  border: 1.5px solid #0284C7;
  border-radius: 14px;
  padding: 13px 20px;
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.25);
  flex: 1;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-upload-doc:hover {
  background: #0F172A;
  border-color: #38BDF8;
  color: #E0F2FE;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(56, 189, 248, 0.35);
}

.btn-upload-doc:active {
  transform: scale(0.98);
}

/* Sección Carrusel Inferior */
.carousel-section {
  background: #1E293B;
  border: 1px solid #334155;
  border-radius: 18px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.carousel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  font-weight: 700;
  color: #F8FAFC;
}

.carousel-track {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  min-height: 130px;
  align-items: center;
}

.carousel-track::-webkit-scrollbar {
  height: 5px;
}

.carousel-track::-webkit-scrollbar-thumb {
  background: #475569;
  border-radius: 4px;
}

.empty-state {
  width: 100%;
  text-align: center;
  color: #94A3B8;
  font-size: 0.86rem;
  padding: 24px 0;
  border: 1.5px dashed #334155;
  border-radius: 12px;
}

/* Miniatura de Página en Carrusel */
.thumb-card {
  position: relative;
  flex: 0 0 92px;
  height: 125px;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid #334155;
  scroll-snap-align: start;
  background: #090D16;
  cursor: pointer;
  transition: all 0.2s ease;
}

.thumb-card:hover {
  border-color: #38BDF8;
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(56, 189, 248, 0.3);
}

.thumb-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb-card .page-num {
  position: absolute;
  bottom: 6px;
  left: 6px;
  background: rgba(15, 23, 42, 0.85);
  color: #FFFFFF;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.thumb-card .btn-del {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(239, 68, 68, 0.9);
  border: none;
  color: white;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.thumb-card .btn-del:hover {
  transform: scale(1.15);
  background: #DC2626;
}

/* Miniatura Especial para Archivos Excel en Carrusel */
.thumb-card.thumb-card-excel {
  background: linear-gradient(145deg, #064E3B, #0F172A);
  border: 2px solid #10B981;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 6px;
  text-align: center;
}

.thumb-card.thumb-card-excel:hover {
  border-color: #34D399;
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.45);
}

.thumb-card-excel .excel-icon {
  font-size: 32px;
  margin-bottom: 4px;
  filter: drop-shadow(0 2px 6px rgba(16, 185, 129, 0.4));
}

.thumb-card-excel .excel-filename {
  font-size: 0.68rem;
  color: #E2E8F0;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80px;
  line-height: 1.2;
}

.thumb-card-excel .excel-badge {
  position: absolute;
  bottom: 6px;
  left: 6px;
  background: rgba(16, 185, 129, 0.9);
  color: #FFFFFF;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 5px;
  border-radius: 5px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* Barra de Acción Inferior */
.bottom-action {
  margin-top: 4px;
}

.btn-finish {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #4F46E5 0%, #06B6D4 100%);
  color: white;
  border: none;
  border-radius: 14px;
  font-size: 1.02rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(79, 70, 229, 0.35);
  transition: all 0.2s ease;
}

.btn-finish:disabled {
  background: #334155;
  color: #94A3B8;
  cursor: not-allowed;
  box-shadow: none;
}

/* ==========================================================================
   Crop & Perspective Editor Modal (100% Fit-to-Screen Mobile Optimized)
   ========================================================================== */
.crop-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 15, 25, 0.96);
  backdrop-filter: blur(14px);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.crop-card {
  background: #1E293B;
  border: 1px solid #334155;
  border-radius: 18px;
  padding: 10px 14px;
  max-width: 580px;
  width: 100%;
  max-height: calc(100dvh - 16px);
  display: flex;
  flex-direction: column;
  color: white;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.9);
  overflow: hidden;
}

.crop-header {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.crop-canvas-wrapper {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 4px 0;
  touch-action: none;
}

#crop-canvas {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  cursor: crosshair;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
  display: block;
}

.crop-controls {
  flex-shrink: 0;
  margin-top: 2px;
}

.filter-btn-group {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin: 4px 0 2px;
}

.filter-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 6px;
  border-radius: 10px;
  border: 1.5px solid #334155;
  background: #0F172A;
  color: #94A3B8;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.filter-btn:hover {
  border-color: #4F46E5;
  color: #FFFFFF;
}

.filter-btn.active {
  background: #4F46E5 !important;
  color: #FFFFFF !important;
  border-color: #38BDF8 !important;
}

/* ==========================================================================
   Document Preview Modal (Step 3: Vista Previa)
   ========================================================================== */
.preview-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(14px);
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}

.preview-card {
  background: #1E293B;
  border: 1px solid #334155;
  border-radius: var(--radius-xl);
  padding: 24px;
  max-width: 820px;
  width: 100%;
  color: white;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  max-height: 94vh;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid #334155;
}

.preview-carousel {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0F172A;
  border-radius: var(--radius-lg);
  padding: 16px;
  min-height: 380px;
  overflow: hidden;
}

.preview-page-image {
  max-height: 52vh;
  max-width: 100%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  border: 1px solid #334155;
  background: white;
}

.preview-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  z-index: 10;
}

.preview-nav-btn:hover {
  background: #4F46E5;
  border-color: #38BDF8;
}

.preview-nav-prev { left: 16px; }
.preview-nav-next { right: 16px; }

.preview-thumb-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 12px 0 6px 0;
  margin: 12px 0;
  justify-content: center;
}

.preview-thumb-btn {
  width: 54px;
  height: 72px;
  border-radius: 6px;
  border: 2px solid #334155;
  overflow: hidden;
  padding: 0;
  background: #0F172A;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
}

.preview-thumb-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-thumb-btn.active {
  border-color: #38BDF8;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.6);
  transform: scale(1.08);
}

.preview-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid #334155;
}

/* ==========================================================================
   Scanned Pages Tray (Thumbnail Bar)
   ========================================================================== */
.scanned-tray-container {
  margin-top: 16px;
  background: white;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  padding: 14px;
}

.scanned-tray-list {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.scanned-thumb-item {
  position: relative;
  width: 72px;
  height: 96px;
  border-radius: 8px;
  border: 2px solid #CBD5E1;
  overflow: hidden;
  flex-shrink: 0;
  background: #F1F5F9;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.scanned-thumb-item:hover {
  transform: translateY(-2px);
  border-color: #4F46E5;
}

.scanned-thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb-page-num {
  position: absolute;
  bottom: 2px;
  left: 2px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
}

.thumb-delete-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  background: #EF4444;
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.thumb-delete-btn:hover {
  background: #DC2626;
  transform: scale(1.1);
}

/* ==========================================================================
   QR & Share View Styles
   ========================================================================== */
.share-container {
  max-width: 840px;
  margin: 0 auto;
}

.qr-card-hero {
  background: linear-gradient(135deg, #1E1B4B 0%, #0F172A 100%);
  border-radius: var(--radius-xl);
  padding: 40px 24px;
  text-align: center;
  color: white;
  position: relative;
  overflow: hidden;
  margin-bottom: 28px;
  border: 1px solid #334155;
  box-shadow: var(--shadow-lg);
}

.qr-box {
  background: white;
  padding: 16px;
  border-radius: 24px;
  display: inline-block;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35);
  margin: 20px 0;
}

.qr-box svg, .qr-box img {
  display: block;
  width: 240px;
  height: 240px;
}

.copy-url-bar {
  display: flex;
  gap: 8px;
  background: rgba(255, 255, 255, 0.08);
  padding: 6px;
  border-radius: var(--radius-md);
  max-width: 540px;
  margin: 0 auto 20px auto;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.copy-url-input {
  flex: 1;
  background: transparent;
  border: none;
  color: #FFFFFF;
  padding: 8px 12px;
  font-size: 0.9rem;
  outline: none;
}

/* ==========================================================================
   Data Tables (Admin & Documents)
   ========================================================================== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th {
  padding: 12px 16px;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-light);
  background: #F8FAFC;
}

.data-table td {
  padding: 14px 16px;
  font-size: 0.92rem;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.data-table tr:hover td {
  background: #F8FAFC;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.badge-success { background: #ECFDF5; color: #059669; }
.badge-warning { background: #FEF3C7; color: #D97706; }
.badge-danger { background: #FEF2F2; color: #DC2626; }
.badge-info { background: #EEF2FF; color: #4F46E5; }

/* ==========================================================================
   Footer
   ========================================================================== */
.app-footer {
  text-align: center;
  padding: 20px 16px;
  color: var(--text-secondary);
  font-size: 0.83rem;
  border-top: 1px solid var(--border-light);
  margin-top: auto;
  line-height: 1.6;
}

/* ==========================================================================
   Hamburger Button
   ========================================================================== */
.hamburger-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 42px;
  height: 42px;
  background: transparent;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 0;
  transition: background 0.2s ease, border-color 0.2s ease;
  flex-shrink: 0;
}

.hamburger-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

.ham-bar {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.3s ease,
              width 0.3s ease;
  transform-origin: center;
}

/* Animación X al abrir */
.hamburger-btn.open .ham-bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.hamburger-btn.open .ham-bar:nth-child(2) {
  opacity: 0;
  width: 0;
}
.hamburger-btn.open .ham-bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ==========================================================================
   Mobile Nav Overlay
   ========================================================================== */
.mobile-nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.mobile-nav-overlay.open {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

/* ==========================================================================
   Mobile Nav Drawer
   ========================================================================== */
.mobile-nav {
  position: fixed;
  top: 0;
  right: 0;
  height: 100dvh;
  width: min(320px, 88vw);
  background: #FFFFFF;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: -8px 0 40px rgba(15, 23, 42, 0.18);
  overflow: hidden;
}

.mobile-nav.open {
  transform: translateX(0);
}

.mobile-nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
  background: #FFFFFF;
  flex-shrink: 0;
}

.mobile-nav-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--border-light);
  background: transparent;
  color: var(--text-secondary);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}

.mobile-nav-close:hover {
  background: #FEF2F2;
  color: var(--danger);
  border-color: var(--danger);
}

.mobile-nav-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px 24px;
  -webkit-overflow-scrolling: touch;
}

.mobile-user-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 12px;
  background: var(--primary-light);
  border-radius: var(--radius-md);
  margin-bottom: 4px;
}

.mobile-nav-divider {
  height: 1px;
  background: var(--border-light);
  margin: 8px 4px;
}

.mobile-nav-section-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  padding: 8px 14px 4px;
}

.mobile-nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: none;
  transition: background 0.18s ease, color 0.18s ease;
  width: 100%;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
}

.mobile-nav-link:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.mobile-nav-link.active {
  background: var(--primary-light);
  color: var(--primary);
}

.mobile-nav-icon {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.mobile-logout-btn {
  color: #DC2626;
}

.mobile-logout-btn:hover {
  background: #FEF2F2;
  color: #DC2626;
}

/* ==========================================================================
   Responsive Adaptations — Tablet & Mobile
   ========================================================================== */

/* ── Tablet (≤ 900px) ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  .nav-desktop {
    display: none !important;
  }

  .hamburger-btn {
    display: flex;
  }

  /* El overlay se muestra únicamente con la clase .open (ver arriba) */
}

/* ── Mobile (≤ 768px) ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .app-header {
    padding: 10px 14px;
  }

  .brand-logo {
    font-size: 1.15rem;
    gap: 8px;
  }

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

  .main-wrapper {
    padding: 14px 12px;
  }

  /* Stats grid: 1 columna en móvil pequeño, 2 en tablet */
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
  }

  .stat-card {
    padding: 14px;
    gap: 12px;
  }

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

  .stat-icon {
    width: 40px;
    height: 40px;
    font-size: 1.15rem;
  }

  /* Card */
  .card {
    padding: 16px 14px;
    border-radius: var(--radius-md);
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 14px;
  }

  /* Scanner */
  .scanner-container {
    aspect-ratio: 9 / 16;
    border-radius: 0;
  }

  /* Flash messages */
  .main-wrapper > div:first-child {
    margin-top: 0;
  }

  /* QR Box */
  .qr-box svg, .qr-box img {
    width: 180px;
    height: 180px;
  }

  .qr-card-hero {
    padding: 28px 16px;
  }

  /* Preview modal */
  .preview-card {
    padding: 16px;
  }

  .preview-carousel {
    min-height: 240px;
  }

  .preview-page-image {
    max-height: 38vh;
  }

  /* Copy bar */
  .copy-url-bar {
    flex-direction: column;
    gap: 6px;
  }

  /* Share container */
  .share-container {
    max-width: 100%;
  }

  /* Preview footer */
  .preview-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .preview-footer .btn {
    width: 100%;
    justify-content: center;
  }
}

/* ── Small Mobile (≤ 480px) ───────────────────────────────────────── */
@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .brand-logo > span:first-of-type {
    display: none; /* Oculta texto "FastQR" en pantallas muy pequeñas, deja logo + badge */
  }

  .app-header {
    padding: 8px 12px;
  }

  .main-wrapper {
    padding: 12px 10px;
  }
}

/* ==========================================================================
   Dashboard Table → Mobile Cards (datos-table responsive)
   ========================================================================== */
@media (max-width: 700px) {
  /* Ocultar la tabla y mostrar cards */
  .data-table thead {
    display: none;
  }

  .data-table,
  .data-table tbody,
  .data-table tr,
  .data-table td {
    display: block;
    width: 100%;
  }

  .data-table tr {
    border: 1.5px solid var(--border-light);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    padding: 4px 0;
    background: var(--card-light);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
  }

  .data-table tr:hover td {
    background: transparent;
  }

  .data-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .data-table td:last-child {
    border-bottom: none;
  }

  /* Etiqueta de columna (pseudo-elemento) */
  .data-table td::before {
    content: attr(data-label);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    flex-shrink: 0;
    min-width: 90px;
  }

  /* Acciones full width */
  .data-table td:last-child {
    flex-direction: column;
    align-items: stretch;
  }

  .data-table td:last-child > div {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-start;
    width: 100%;
  }

  .data-table td:last-child .btn {
    flex: 1;
    min-width: 80px;
    font-size: 0.82rem;
    padding: 8px 10px;
    justify-content: center;
  }

  /* Buscador del dashboard */
  .card-header form {
    flex-direction: column;
    width: 100%;
  }

  .card-header form input,
  .card-header form select {
    width: 100% !important;
  }

  .card-header form button {
    width: 100%;
  }
}

/* ==========================================================================
   Admin Tables Responsive (plans, users, documents)
   ========================================================================== */
@media (max-width: 700px) {
  .table-responsive {
    border-radius: var(--radius-md);
    overflow: hidden;
  }
}

/* ==========================================================================
   Capture Layout & Bottom Carousel (pantalla_fotos.html schema)
   ========================================================================== */

.capture-container {
  max-width: 500px;
  margin: 0 auto;
  padding: 8px 12px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: calc(100vh - 120px);
}

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  font-weight: 600;
}

/* Tarjeta de Captura Principal */
.capture-card {
  background: linear-gradient(145deg, #1e293b, #0f172a);
  border: 1px solid #334155;
  border-radius: 20px;
  padding: 26px 18px;
  text-align: center;
  color: #fff;
  box-shadow: 0 10px 25px rgba(0,0,0,0.22);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.camera-icon { font-size: 44px; margin-bottom: 2px; }
.capture-title { font-size: 1.15rem; font-weight: 700; color: #F8FAFC; }
.capture-desc { font-size: 0.82rem; color: #94a3b8; max-width: 280px; line-height: 1.4; }

.capture-btn-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 320px;
  margin: 4px 0;
}

@media (min-width: 480px) {
  .capture-btn-group {
    flex-direction: row;
    max-width: 440px;
  }
}

.btn-capture {
  flex: 1;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 13px 18px;
  font-size: 0.98rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.4);
  transition: all 0.2s ease;
  white-space: nowrap;
}
.btn-capture:hover { background: #059669; transform: translateY(-1px); box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5); }
.btn-capture:active { transform: scale(0.98); }

.btn-upload-doc {
  flex: 1;
  background: linear-gradient(135deg, #3B82F6 0%, #1D4ED8 100%);
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 13px 18px;
  font-size: 0.98rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.35);
  transition: all 0.2s ease;
  white-space: nowrap;
  text-decoration: none;
}
.btn-upload-doc:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5); color: #fff; }
.btn-upload-doc:active { transform: scale(0.98); }

/* Sección Carrusel Inferior */
.carousel-section {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.carousel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  font-weight: 700;
  color: #1e293b;
}

.carousel-track {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 6px 2px 10px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  min-height: 130px;
  align-items: center;
}
.carousel-track::-webkit-scrollbar { height: 6px; }
.carousel-track::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 6px; }

.empty-state {
  width: 100%;
  text-align: center;
  color: #64748b;
  font-size: 0.85rem;
  padding: 24px 12px;
}

/* Miniatura de Página (Thumb Card) */
.thumb-card {
  position: relative;
  flex: 0 0 88px;
  width: 88px;
  height: 120px;
  border-radius: 10px;
  overflow: hidden;
  border: 1.5px solid #cbd5e1;
  scroll-snap-align: start;
  background: #0f172a;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.thumb-card:hover {
  transform: translateY(-2px);
  border-color: #38BDF8;
}
.thumb-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.thumb-card .page-num {
  position: absolute;
  bottom: 4px;
  left: 4px;
  background: rgba(15, 23, 42, 0.85);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}
.thumb-card .btn-del {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(239, 68, 68, 0.95);
  border: none;
  color: white;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  transition: transform 0.1s ease;
}
.thumb-card .btn-del:hover {
  transform: scale(1.15);
  background: #dc2626;
}

/* Tarjeta de Excel en el Carrusel Híbrido */
.thumb-card.thumb-card-excel {
  background: linear-gradient(145deg, #065F46, #047857);
  border: 1.5px solid #10B981;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 6px;
  text-align: center;
  color: #fff;
}
.thumb-card-excel .excel-icon {
  font-size: 28px;
  margin-bottom: 4px;
}
.thumb-card-excel .excel-filename {
  font-size: 0.65rem;
  font-weight: 600;
  line-height: 1.2;
  word-break: break-word;
  max-height: 38px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.thumb-card-excel .excel-badge {
  position: absolute;
  bottom: 4px;
  left: 4px;
  background: rgba(16, 185, 129, 0.9);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 4px;
}

/* Barra de Acción Inferior */
.bottom-action {
  margin-top: auto;
  padding-top: 8px;
}
.btn-finish {
  width: 100%;
  padding: 14px 20px;
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 14px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
  transition: all 0.2s ease;
}
.btn-finish:hover:not(:disabled) {
  background: #1d4ed8;
  transform: translateY(-1px);
}
.btn-finish:disabled {
  background: #cbd5e1;
  color: #64748b;
  box-shadow: none;
  cursor: not-allowed;
}

