/* ==========================================================================
   AILO QR • PLATAFORMA DE CONTROL DE ACCESO & PASES DIGITALES
   Diseño Blanco Elegante, Colores Suaves y Adaptabilidad Móvil PWA
   ========================================================================== */

:root {
  /* Paleta Principal: Blanco Elegante & Tonos Suaves para la Vista */
  --bg-main: #f8fafc;
  --bg-subtle: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-hover: #fcfdfe;
  --bg-input: #ffffff;
  --bg-muted: #f1f5f9;
  --border-subtle: #e2e8f0;
  --border-focus: #e11d48;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-highlight: #020617;

  /* Colores de Acento Suaves */
  --ailo-red: #e11d48;
  --ailo-red-hover: #be123c;
  --ailo-red-soft: rgba(225, 29, 72, 0.08);
  --ailo-red-glow: rgba(225, 29, 72, 0.18);

  --ailo-indigo: #4f46e5;
  --ailo-indigo-soft: rgba(79, 70, 229, 0.08);
  --ailo-indigo-hover: #4338ca;

  --success: #059669;
  --success-bg: rgba(5, 150, 105, 0.08);
  --warning: #d97706;
  --warning-bg: rgba(217, 119, 6, 0.08);
  --danger: #e11d48;
  --danger-bg: rgba(225, 29, 72, 0.08);
  --info: #0284c7;
  --info-bg: rgba(2, 132, 199, 0.08);

  --access-both: #059669;
  --access-both-bg: rgba(5, 150, 105, 0.08);
  --access-in: #0284c7;
  --access-in-bg: rgba(2, 132, 199, 0.08);
  --access-out: #ea580c;
  --access-out-bg: rgba(234, 88, 12, 0.08);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 26px;

  /* Sombras Suaves y Elegantes */
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05), 0 1px 2px rgba(15, 23, 42, 0.03);
  --shadow-md: 0 4px 16px -2px rgba(15, 23, 42, 0.06), 0 2px 6px -1px rgba(15, 23, 42, 0.03);
  --shadow-lg: 0 12px 32px -4px rgba(15, 23, 42, 0.08), 0 4px 12px -2px rgba(15, 23, 42, 0.04);

  --font-family: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'Cascadia Code', Menlo, Consolas, monospace;

  --transition-fast: 0.15s ease;
  --transition-smooth: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Modo Oscuro Opcional */
[data-theme="dark"] {
  --bg-main: #0b0f19;
  --bg-subtle: #111827;
  --bg-card: #162032;
  --bg-card-hover: #1e293b;
  --bg-input: #111827;
  --bg-muted: #1e293b;
  --border-subtle: #243247;
  --border-focus: #e11d48;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-highlight: #ffffff;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);

  --ailo-red-soft: rgba(225, 29, 72, 0.15);
  --ailo-indigo-soft: rgba(79, 70, 229, 0.15);
  --success-bg: rgba(16, 185, 129, 0.15);
  --warning-bg: rgba(245, 158, 11, 0.15);
  --danger-bg: rgba(239, 68, 68, 0.15);
  --info-bg: rgba(56, 189, 248, 0.15);
  --access-both-bg: rgba(16, 185, 129, 0.15);
  --access-in-bg: rgba(14, 165, 233, 0.15);
  --access-out-bg: rgba(249, 115, 22, 0.15);
}

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

html {
  font-size: 15px;
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
}

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

/* ==========================================================================
   CABECERA SUPERIOR Y BRANDING AILO QR
   ========================================================================== */
.app-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-sm);
}

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

.brand-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

.brand-logo-badge {
  background: linear-gradient(135deg, #e11d48 0%, #be123c 100%);
  color: #ffffff;
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: 0.3px;
  padding: 0.45rem 0.8rem;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 0.45rem;
  box-shadow: 0 3px 10px var(--ailo-red-glow);
}

.brand-logo-badge svg {
  width: 1.2rem;
  height: 1.2rem;
  fill: currentColor;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-highlight);
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.brand-title .badge-tag {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--ailo-red);
  background: var(--ailo-red-soft);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
}

.brand-subtitle {
  font-size: 0.76rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-install-app {
  background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
  color: #ffffff;
  border: none;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  box-shadow: 0 3px 10px rgba(79, 70, 229, 0.25);
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-install-app:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(79, 70, 229, 0.35);
}

.btn-install-app svg {
  width: 1rem;
  height: 1rem;
}

.theme-toggle-btn, .btn-ghost {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all var(--transition-fast);
}

.theme-toggle-btn:hover, .btn-ghost:hover {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-focus);
}

/* ==========================================================================
   NAVEGACIÓN POR PESTAÑAS (RESPONSIVE TOUCH)
   ========================================================================== */
.app-nav-bar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 1.25rem;
  position: sticky;
  top: 57px;
  z-index: 90;
}

.nav-tabs-container {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0.25rem 0;
}

.nav-tabs-container::-webkit-scrollbar {
  display: none;
}

.nav-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.nav-tab-btn svg {
  width: 1.1rem;
  height: 1.1rem;
  opacity: 0.75;
}

.nav-tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-subtle);
}

.nav-tab-btn.active {
  color: var(--ailo-red);
  background: var(--ailo-red-soft);
  font-weight: 700;
}

.nav-tab-btn.active svg {
  opacity: 1;
}

.tab-badge {
  background: var(--ailo-red);
  color: #fff;
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: 20px;
  font-weight: 700;
}

/* ==========================================================================
   CONTENIDO PRINCIPAL
   ========================================================================== */
.app-main {
  flex: 1;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3.5rem;
}

.tab-panel {
  display: none;
  animation: fadeIn 0.25s ease-in-out;
}

.tab-panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Banner de PWA Install en la parte superior */
.pwa-banner-card {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid var(--border-subtle);
  border-left: 4px solid var(--ailo-indigo);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}

.pwa-banner-content {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.pwa-banner-icon {
  width: 2.4rem;
  height: 2.4rem;
  background: var(--ailo-indigo-soft);
  color: var(--ailo-indigo);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.pwa-banner-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-highlight);
}

.pwa-banner-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* Grid del Generador */
.generator-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 960px) {
  .generator-grid {
    grid-template-columns: 1fr;
  }
}

/* Tarjetas */
.app-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.card-header-styled {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
}

.card-title-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.card-icon-bubble {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: var(--radius-md);
  background: var(--ailo-red-soft);
  color: var(--ailo-red);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.card-icon-bubble svg {
  width: 1.25rem;
  height: 1.25rem;
}

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

.card-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.1rem;
}

/* Formularios */
.form-group {
  margin-bottom: 1.15rem;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

@media (max-width: 600px) {
  .form-row-2 {
    grid-template-columns: 1fr;
  }
}

.form-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
}

.form-label-hint {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--text-muted);
}

.input-control, .select-control, .textarea-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.95rem;
  font-size: 0.9rem;
  font-family: inherit;
  transition: all var(--transition-fast);
  min-height: 44px;
}

.input-control:focus, .select-control:focus, .textarea-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--ailo-red-glow);
  background: #ffffff;
}

.input-mono {
  font-family: var(--font-mono);
  letter-spacing: 0.5px;
}

.input-helper {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

/* Selectores de Dirección */
.direction-control-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 0.45rem;
}

@media (max-width: 480px) {
  .direction-control-grid {
    grid-template-columns: 1fr;
  }
}

.direction-btn {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.5rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.8rem;
  font-weight: 600;
  transition: all var(--transition-fast);
  min-height: 52px;
  justify-content: center;
}

.direction-btn svg {
  width: 1.15rem;
  height: 1.15rem;
}

.direction-btn:hover {
  border-color: var(--border-focus);
  color: var(--text-primary);
}

.direction-btn.active.both {
  background: var(--access-both-bg);
  border-color: var(--access-both);
  color: var(--access-both);
  font-weight: 700;
}

.direction-btn.active.in {
  background: var(--access-in-bg);
  border-color: var(--access-in);
  color: var(--access-in);
  font-weight: 700;
}

.direction-btn.active.out {
  background: var(--access-out-bg);
  border-color: var(--access-out);
  color: var(--access-out);
  font-weight: 700;
}

/* Periodo de Vigencia */
.segmented-control {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 0.4rem;
  background: var(--bg-subtle);
  padding: 0.3rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

@media (max-width: 480px) {
  .segmented-control {
    grid-template-columns: 1fr;
  }
}

.segment-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.55rem 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  transition: all var(--transition-fast);
  min-height: 46px;
  justify-content: center;
}

.segment-btn span.tag {
  font-size: 0.68rem;
  opacity: 0.85;
}

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

.segment-btn.active {
  background: var(--ailo-red);
  color: #ffffff;
  box-shadow: 0 2px 8px var(--ailo-red-glow);
}

/* Chips de Permisos */
.permission-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

@media (max-width: 500px) {
  .permission-grid {
    grid-template-columns: 1fr;
  }
}

.perm-chip {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  user-select: none;
  font-size: 0.82rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  min-height: 44px;
}

.perm-chip:hover {
  border-color: var(--border-focus);
}

.perm-chip input[type="checkbox"] {
  accent-color: var(--ailo-red);
  width: 1.1rem;
  height: 1.1rem;
}

.perm-chip.checked {
  background: var(--ailo-red-soft);
  border-color: var(--ailo-red);
  color: var(--text-highlight);
  font-weight: 600;
}

/* Botones Principales */
.btn-primary {
  background: linear-gradient(135deg, #e11d48 0%, #be123c 100%);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.85rem 1.25rem;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  width: 100%;
  box-shadow: 0 3px 12px var(--ailo-red-glow);
  transition: all var(--transition-smooth);
  min-height: 48px;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px var(--ailo-red-glow);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.75rem 1.1rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  transition: all var(--transition-fast);
  min-height: 44px;
}

.btn-secondary:hover {
  background: var(--bg-subtle);
  border-color: var(--border-focus);
}

.btn-whatsapp {
  background: linear-gradient(135deg, #25d366 0%, #1eb954 100%);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.75rem 1.1rem;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  transition: all var(--transition-fast);
  box-shadow: 0 3px 10px rgba(37, 211, 102, 0.25);
  min-height: 44px;
}

.btn-whatsapp:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(37, 211, 102, 0.35);
}

/* ==========================================================================
   TARJETA DE RESULTADO Y VISUALIZACIÓN QR
   ========================================================================== */
.result-box-container {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.result-card-display {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  position: relative;
}

.result-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.15rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.badge-status {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.badge-status.active {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(5, 150, 105, 0.25);
}

.badge-status.warning {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid rgba(217, 119, 6, 0.25);
}

.badge-status.expired {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(225, 29, 72, 0.25);
}

.badge-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
  animation: pulseDot 1.8s infinite;
}

@keyframes pulseDot {
  0% { transform: scale(0.9); opacity: 0.7; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.7; }
}

.badge-direction-display {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.badge-direction-display.both {
  background: var(--access-both-bg);
  color: var(--access-both);
  border: 1px solid rgba(5, 150, 105, 0.25);
}

.badge-direction-display.in {
  background: var(--access-in-bg);
  color: var(--access-in);
  border: 1px solid rgba(2, 132, 199, 0.25);
}

.badge-direction-display.out {
  background: var(--access-out-bg);
  color: var(--access-out);
  border: 1px solid rgba(234, 88, 12, 0.25);
}

.validity-tag {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ailo-red);
  background: var(--ailo-red-soft);
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-sm);
}

/* Sección QR */
.qr-preview-section {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.15rem;
}

@media (max-width: 520px) {
  .qr-preview-section {
    flex-direction: column;
    text-align: center;
  }
}

.qr-canvas-wrapper {
  background: #ffffff;
  padding: 0.5rem;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.qr-canvas-wrapper canvas {
  display: block;
  max-width: 140px;
  height: auto;
}

.qr-info-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.qr-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-highlight);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.qr-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.qr-format-pills {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.2rem;
  flex-wrap: wrap;
}

.qr-format-pill {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.25rem 0.55rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.qr-format-pill:hover {
  color: var(--text-primary);
  border-color: var(--border-focus);
}

.qr-format-pill.active {
  background: var(--ailo-red-soft);
  color: var(--ailo-red);
  border-color: var(--ailo-red);
  font-weight: 700;
}

/* Cajas de ID y Código */
.code-secondary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin-bottom: 1rem;
}

@media (max-width: 480px) {
  .code-secondary-grid {
    grid-template-columns: 1fr;
  }
}

.code-secondary-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.75rem;
}

.code-title-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.4px;
  margin-bottom: 0.25rem;
}

.code-secondary-val {
  font-family: var(--font-mono);
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-highlight);
  letter-spacing: 0.5px;
}

.code-display-block {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1rem;
  position: relative;
}

.code-value-formatted {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--ailo-red);
  letter-spacing: 1.2px;
  word-break: break-all;
  user-select: all;
}

.copy-btn-inline {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all var(--transition-fast);
}

.copy-btn-inline:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-focus);
}

/* Cuenta Regresiva */
.countdown-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  margin-bottom: 1rem;
}

.countdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.countdown-digits-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
  text-align: center;
}

.count-digit-unit {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.2rem;
}

.count-number {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-highlight);
  display: block;
  line-height: 1.1;
}

.count-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}

.validity-progress-bar {
  width: 100%;
  height: 5px;
  background: var(--bg-muted);
  border-radius: 10px;
  overflow: hidden;
  margin-top: 0.65rem;
}

.validity-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--success) 0%, var(--warning) 70%, var(--danger) 100%);
  width: 100%;
  transition: width 0.4s ease;
}

.result-action-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

@media (max-width: 500px) {
  .result-action-buttons {
    grid-template-columns: 1fr;
  }
}

.meta-summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  margin-top: 0.75rem;
}

.meta-summary-table tr {
  border-bottom: 1px solid var(--border-subtle);
}

.meta-summary-table tr:last-child {
  border-bottom: none;
}

.meta-summary-table td {
  padding: 0.45rem 0;
}

.meta-summary-table td:first-child {
  color: var(--text-secondary);
  font-weight: 500;
  width: 42%;
}

.meta-summary-table td:last-child {
  color: var(--text-highlight);
  font-weight: 600;
  text-align: right;
}

/* ==========================================================================
   VALIDADOR Y SIMULADOR
   ========================================================================== */
.validator-container {
  max-width: 860px;
  margin: 0 auto;
}

.validator-input-card {
  margin-bottom: 1.5rem;
}

.validator-result-card {
  display: none;
  animation: fadeIn 0.3s ease;
}

.validator-result-card.show {
  display: block;
}

.terminal-scan-simulator {
  background: var(--bg-subtle);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  margin-top: 1.15rem;
}

.sim-buttons-row {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.65rem;
  flex-wrap: wrap;
}

.btn-sim-entry {
  background: var(--access-in-bg);
  border: 1px solid var(--access-in);
  color: var(--access-in);
  padding: 0.6rem 0.95rem;
  border-radius: var(--radius-md);
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all var(--transition-fast);
  min-height: 44px;
}

.btn-sim-entry:hover {
  background: var(--access-in);
  color: #fff;
}

.btn-sim-exit {
  background: var(--access-out-bg);
  border: 1px solid var(--access-out);
  color: var(--access-out);
  padding: 0.6rem 0.95rem;
  border-radius: var(--radius-md);
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all var(--transition-fast);
  min-height: 44px;
}

.btn-sim-exit:hover {
  background: var(--access-out);
  color: #fff;
}

.scan-log-box {
  background: #0f172a;
  color: #38bdf8;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  margin-top: 0.75rem;
  min-height: 48px;
  white-space: pre-wrap;
  border: 1px solid #1e293b;
}

/* ==========================================================================
   HISTORIAL Y TABLAS
   ========================================================================== */
.history-controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.search-box-wrapper {
  position: relative;
  flex: 1;
  min-width: 240px;
}

.search-box-wrapper svg {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.05rem;
  height: 1.05rem;
  color: var(--text-muted);
}

.search-input {
  padding-left: 2.35rem;
}

.filter-chips {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.filter-chip {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.45rem 0.8rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-chip.active {
  background: var(--ailo-red);
  color: #fff;
  border-color: var(--ailo-red);
}

.history-table-container {
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-card);
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  text-align: left;
  white-space: nowrap;
}

.history-table th {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--border-subtle);
}

.history-table td {
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

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

.history-table tr:hover td {
  background: var(--bg-card-hover);
}

.history-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.btn-icon-action {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  width: 1.9rem;
  height: 1.9rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-icon-action:hover {
  background: var(--bg-card);
  color: var(--ailo-red);
  border-color: var(--border-focus);
}

.empty-state {
  text-align: center;
  padding: 3rem 1.25rem;
  color: var(--text-muted);
}

.empty-state svg {
  width: 3rem;
  height: 3rem;
  margin-bottom: 0.85rem;
  opacity: 0.4;
}

/* ==========================================================================
   CENTRO DE RESPALDO
   ========================================================================== */
.backup-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
}

.backup-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.85rem;
}

.backup-card-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-highlight);
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.backup-card-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ==========================================================================
   GUÍA TÉCNICA
   ========================================================================== */
.guide-container {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 860px) {
  .guide-container {
    grid-template-columns: 1fr;
  }
}

.guide-sidebar {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.15rem;
  position: sticky;
  top: 110px;
}

.guide-nav-link {
  display: block;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  transition: all var(--transition-fast);
}

.guide-nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-subtle);
}

.guide-nav-link.active {
  background: var(--ailo-red-soft);
  color: var(--ailo-red);
}

.guide-content {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
}

.guide-section {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.guide-section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.guide-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-highlight);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.guide-step-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  margin-bottom: 0.85rem;
  position: relative;
  padding-left: 3.25rem;
}

.guide-step-num {
  position: absolute;
  left: 1rem;
  top: 1.15rem;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 50%;
  background: var(--ailo-red);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.guide-step-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-highlight);
  margin-bottom: 0.25rem;
}

.guide-step-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.guide-alert-box {
  background: var(--info-bg);
  border: 1px solid rgba(2, 132, 199, 0.25);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  padding: 0.9rem 1.15rem;
  margin: 1rem 0;
  font-size: 0.82rem;
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
}

/* ==========================================================================
   MODALES (PWA INSTALL & VOUCHER PRINT)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(5px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.active {
  display: flex;
}

.modal-container {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  position: relative;
}

.modal-header {
  padding: 1.15rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.2rem;
}

.modal-close-btn:hover {
  color: var(--ailo-red);
}

.modal-body {
  padding: 1.5rem;
}

/* Pestañas de Instalación PWA */
.install-tabs {
  display: flex;
  gap: 0.5rem;
  background: var(--bg-subtle);
  padding: 0.35rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.25rem;
}

.install-tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  padding: 0.6rem 0.5rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: all var(--transition-fast);
}

.install-tab-btn.active {
  background: var(--bg-card);
  color: var(--text-highlight);
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}

.install-guide-step {
  display: flex;
  gap: 0.85rem;
  margin-bottom: 1rem;
  align-items: flex-start;
}

.install-step-num {
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 50%;
  background: var(--ailo-indigo-soft);
  color: var(--ailo-indigo);
  font-weight: 800;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.install-step-text strong {
  color: var(--text-highlight);
  font-size: 0.88rem;
  display: block;
  margin-bottom: 0.15rem;
}

.install-step-text p {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Credencial de Impresión */
.voucher-print-card {
  background: #ffffff;
  color: #0f172a;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  padding: 1.75rem;
  font-family: var(--font-family);
  box-shadow: var(--shadow-md);
}

.voucher-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #e11d48;
  padding-bottom: 0.85rem;
  margin-bottom: 1.25rem;
}

.voucher-logo {
  font-size: 1.35rem;
  font-weight: 800;
  color: #e11d48;
  letter-spacing: 0.5px;
}

.voucher-tag {
  background: #f1f5f9;
  color: #334155;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.3rem 0.65rem;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
}

.voucher-highlight-box {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  padding: 1.15rem;
  text-align: center;
  margin-bottom: 1.25rem;
}

.voucher-code-main {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 800;
  color: #e11d48;
  letter-spacing: 1.5px;
  margin: 0.4rem 0;
}

.voucher-details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  margin-bottom: 1.25rem;
  font-size: 0.82rem;
}

.voucher-item-label {
  color: #64748b;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
}

.voucher-item-val {
  color: #0f172a;
  font-weight: 700;
}

.voucher-qr-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.85rem;
  border-top: 1px solid #e2e8f0;
}

.voucher-terms {
  font-size: 0.7rem;
  color: #64748b;
  max-width: 65%;
  line-height: 1.4;
}

/* Toast Notificaciones */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

@media (max-width: 500px) {
  .toast-container {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
  }
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  padding: 0.75rem 1.15rem;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  pointer-events: auto;
  animation: slideInToast 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 250px;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--info); }

@keyframes slideInToast {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@media print {
  body * { visibility: hidden; }
  .modal-overlay, .modal-container, .voucher-print-card, .voucher-print-card * { visibility: visible; }
  .modal-overlay { position: absolute; inset: 0; background: transparent; padding: 0; }
  .modal-header, .no-print { display: none !important; }
  .voucher-print-card { border: none; box-shadow: none; padding: 0; }
}
