Files
recreopay/public/index.html
T

3185 lines
251 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
<title>SiboPay - Tu Soda Escolar Digital</title>
<link rel="manifest" href="/manifest.json">
<link rel="icon" type="image/png" href="/img/sibopay-emblem.png">
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
<meta name="theme-color" content="#0284c7">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="apple-mobile-web-app-title" content="SiboPay">
<meta name="mobile-web-app-capable" content="yes">
<link rel="stylesheet" href="/css/styles.css?v=13.0">
<link rel="stylesheet" href="/css/desktop.css?v=2.2">
<style>
/* Transiciones suaves */
.fade-enter { animation: fadeIn 0.2s ease-in-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
</style>
</head>
<body class="">
<!-- VISTA DE LOGIN: WELCOME SPLASH SCREEN & BOTTOM SHEET (ESTILO ORDER-EAT / SIBOPAY) -->
<div id="viewLogin" class="splash-welcome-screen" style="display: none;">
<!-- Patrón de alimentos en marca de agua difuminada -->
<div class="splash-doodle-bg"></div>
<!-- Contenido principal centrado -->
<div class="splash-content-wrap">
<!-- Sección superior/media: Emblema y Marca -->
<div class="splash-brand-hero">
<div class="splash-emblem-wrap">
<img src="/img/sibopay-emblem.png" alt="SiboPay" class="splash-emblem-img">
</div>
<h1 class="splash-title">SiboPay</h1>
<p class="splash-tagline">Sistema Digital de Pagos y Monedero Estudiantil</p>
</div>
<!-- Sección inferior: Botones de acción y Disclaimer -->
<div class="splash-actions-box">
<button type="button" class="splash-btn-primary" onclick="openLoginSheet('login')">
Iniciar Sesión
</button>
<button type="button" class="splash-btn-secondary" onclick="openLoginSheet('register')">
Registrarse
</button>
<p class="splash-disclaimer">
Al iniciar sesión y registrarse, acepta nuestros
<a href="/terminos" target="_blank" rel="noopener noreferrer">Términos y Condiciones</a>
y nuestra
<a href="/privacidad" target="_blank" rel="noopener noreferrer">Política de Privacidad</a>.
</p>
</div>
</div>
<!-- BOTTOM SHEET: VENTANA INFERIOR DESLIZABLE PARA LOGIN Y REGISTRO -->
<div id="loginBottomSheet" class="bottom-sheet-backdrop" onclick="closeLoginSheet(event)">
<div class="bottom-sheet-card" onclick="event.stopPropagation()">
<div class="bottom-sheet-pill-handle"></div>
<div class="bottom-sheet-header">
<div style="display: flex; align-items: center; gap: 8px;">
<img src="/img/sibopay-emblem.png" alt="SiboPay" style="width: 24px; height: 24px; object-fit: contain;">
<h3 id="bottomSheetTitle" style="margin: 0; font-size: 1.22rem; font-weight: 800; color: #0f172a;">Iniciar Sesión</h3>
</div>
<button type="button" class="bottom-sheet-close-btn" onclick="closeLoginSheet()" title="Cerrar">✕</button>
</div>
<!-- CONTENIDO 1: INICIAR SESIÓN -->
<div id="sheetContentLogin">
<form id="formLogin" onsubmit="handleLoginSubmit(event)">
<div class="login-form-group">
<label id="lblLoginUser" for="loginUsername">Usuario, Teléfono o Carné:</label>
<input type="text" id="loginUsername" class="login-input" placeholder="Ej: padre, carlos_papa, 8888-1122 o mateo" required autocomplete="username">
</div>
<div class="login-form-group">
<label id="lblLoginPass" for="loginPassword">Contraseña o PIN:</label>
<input type="password" id="loginPassword" class="login-input" placeholder="••••••••" required autocomplete="current-password">
</div>
<div id="loginErrorMsg" style="display: none; background: #fee2e2; border: 1px solid #fca5a5; color: #991b1b; padding: 9px 12px; border-radius: 10px; font-size: 0.82rem; font-weight: 700; margin-bottom: 12px; text-align: center;"></div>
<button type="submit" id="btnLoginSubmit" class="login-submit-btn" style="display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 48px; border-radius: 12px; font-weight: 800; font-size: 1rem; background: linear-gradient(135deg, #0284c7, #0369a1); color: white; border: none; cursor: pointer; box-shadow: 0 4px 14px rgba(2, 132, 199, 0.35);">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4"/><polyline points="10 17 15 12 10 7"/><line x1="15" x2="3" y1="12" y2="12"/></svg>
<span id="lblBtnLoginText">Ingresar al Sistema</span>
</button>
</form>
<div style="text-align: center; margin-top: 14px;">
<p style="font-size: 0.82rem; color: #64748b; margin: 0;">
¿Aún no tienes cuenta?
<button type="button" onclick="switchSheetView('register')" style="background: none; border: none; color: #0284c7; font-weight: 800; cursor: pointer; text-decoration: underline; font-size: 0.82rem; padding: 0;">Regístrate como Padre aquí</button>
</p>
</div>
<!-- ACCESOS RÁPIDOS DE PRUEBA DESPLEGABLES (DEMO) -->
<details style="margin-top: 16px; border-top: 1px solid #f1f5f9; padding-top: 12px;">
<summary style="font-size: 0.76rem; font-weight: 800; color: #64748b; cursor: pointer; text-align: center; outline: none;">
⚡ Accesos rápidos de prueba (Demo 1-Click)
</summary>
<div class="login-demo-btns" style="margin-top: 10px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;">
<button type="button" class="login-demo-btn" onclick="quickFillLogin('dev', 'dev123')" style="border: 1.5px solid #0284c7; background: #f0f9ff; padding: 6px 4px; font-size: 0.72rem;">
<span style="color: #0284c7; font-weight: 800;">Developer</span>
</button>
<button type="button" class="login-demo-btn" onclick="quickFillLogin('admin', 'admin123')" style="padding: 6px 4px; font-size: 0.72rem;">
<span>Admin Soda</span>
</button>
<button type="button" class="login-demo-btn" onclick="quickFillLogin('cajero', 'cajero123')" style="padding: 6px 4px; font-size: 0.72rem;">
<span>Cajero</span>
</button>
<button type="button" class="login-demo-btn" onclick="quickFillLogin('padre', 'padre123')" style="padding: 6px 4px; font-size: 0.72rem;">
<span>Padre Demo</span>
</button>
<button type="button" class="login-demo-btn" onclick="quickFillLogin('mateo', '1234')" style="padding: 6px 4px; font-size: 0.72rem;">
<span>Mateo (2°)</span>
</button>
<button type="button" class="login-demo-btn" onclick="quickFillLogin('sofia', '1234')" style="padding: 6px 4px; font-size: 0.72rem;">
<span>Sofía (3°)</span>
</button>
</div>
</details>
</div>
<!-- CONTENIDO 2: REGISTRO DE PADRES -->
<div id="sheetContentRegister" style="display: none;">
<div style="background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%); border: 1.5px solid #bae6fd; border-radius: 12px; padding: 10px 12px; margin-bottom: 14px; display: flex; align-items: center; gap: 10px;">
<div style="width: 36px; height: 36px; border-radius: 10px; background: white; border: 1px solid #bae6fd; display: flex; align-items: center; justify-content: center; flex-shrink: 0; padding: 4px;">
<img src="/img/sibopay-emblem.png" alt="SiboPay" style="width: 100%; height: 100%; object-fit: contain;">
</div>
<div>
<strong style="color: #0369a1; font-size: 0.86rem; display: block; font-weight: 800;">Registro de Padres o Encargados</strong>
<span style="font-size: 0.72rem; color: #475569; display: block;">Crea tu cuenta para vincular a tus hijos y recargarles saldo con SINPE móvil.</span>
</div>
</div>
<form id="formRegisterPadre" onsubmit="handleRegisterPadreSubmit(event)">
<div class="login-form-group">
<label for="regNombre">Nombre y Apellidos:</label>
<input type="text" id="regNombre" class="login-input" placeholder="Ej: Carlos Alvarado Castro" required autocomplete="name">
</div>
<div class="login-form-group">
<label for="regTelefono">Teléfono o Celular (para SINPE):</label>
<input type="tel" id="regTelefono" class="login-input" placeholder="Ej: 8888-1122" required autocomplete="tel">
</div>
<div class="login-form-group">
<label for="regEmail">Correo Electrónico <span style="font-size: 0.72rem; color: #64748b;">(Opcional)</span>:</label>
<input type="email" id="regEmail" class="login-input" placeholder="Ej: [email protected]" autocomplete="email">
</div>
<div class="login-form-group">
<label for="regUsername">Nombre de Usuario:</label>
<input type="text" id="regUsername" class="login-input" placeholder="Ej: carlos_papa" required autocomplete="username">
</div>
<div class="login-form-group">
<label for="regPassword">Contraseña:</label>
<input type="password" id="regPassword" class="login-input" placeholder="Mínimo 4 caracteres" required autocomplete="new-password">
</div>
<div id="registerErrorMsg" style="display: none; background: #fee2e2; border: 1px solid #fca5a5; color: #991b1b; padding: 8px 12px; border-radius: 10px; font-size: 0.8rem; font-weight: 700; margin-bottom: 12px; text-align: center;"></div>
<button type="submit" id="btnRegisterSubmit" class="login-submit-btn" style="display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 48px; border-radius: 12px; font-weight: 800; font-size: 1rem; background: linear-gradient(135deg, #0284c7, #0369a1); color: white; border: none; cursor: pointer; box-shadow: 0 4px 14px rgba(2, 132, 199, 0.35);">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="9" cy="7" r="3.5"/><path d="M3 20v-1.5A4.5 4.5 0 0 1 7.5 14h3A4.5 4.5 0 0 1 15 18.5V20"/><circle cx="17.5" cy="7.5" r="2.5"/><path d="M15 14a3.5 3.5 0 0 1 5.5 3v3"/></svg>
<span>Crear Cuenta de Padre y Entrar</span>
</button>
</form>
<div style="text-align: center; margin-top: 14px;">
<p style="font-size: 0.82rem; color: #64748b; margin: 0;">
¿Ya tienes cuenta registrada?
<button type="button" onclick="switchSheetView('login')" style="background: none; border: none; color: #0284c7; font-weight: 800; cursor: pointer; text-decoration: underline; font-size: 0.82rem; padding: 0;">Inicia sesión aquí</button>
</p>
</div>
</div>
</div>
</div>
</div>
<!-- PANEL MASTER DEVELOPER (#viewDeveloper) -->
<div id="viewDeveloper" class="dev-container" style="display: none;">
<!-- CABECERA DE DEVELOPER -->
<header class="dev-header">
<div class="dev-badge">
<div class="dev-icon">
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>
</div>
<div>
<div style="display: flex; align-items: center; gap: 8px;">
<h2 style="font-size: 1.18rem; font-weight: 900; margin: 0; color: var(--text-main);">Developer Master Suite</h2>
<span style="background: #f0f9ff; color: #0284c7; border: 1px solid #bae6fd; font-size: 0.68rem; font-weight: 800; padding: 2px 8px; border-radius: 6px;">ROOT MASTER</span>
</div>
<span id="devLoggedName" style="font-size: 0.78rem; color: #64748b; font-weight: 700;">Master Developer (dev)</span>
</div>
</div>
<div class="dev-header-actions">
<button onclick="toggleTheme()" class="theme-toggle-btn" title="Alternar Modo Oscuro / Claro" style="display: inline-flex; align-items: center; justify-content: center;">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"/></svg>
</button>
<button onclick="switchDevToView('admin')" class="dev-action-btn" title="Ir al Panel de Soda" style="display: inline-flex; align-items: center; gap: 6px;">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/><polyline points="9 22 9 12 15 12 15 22"/></svg>
<span>Soda Admin</span>
</button>
<a href="/pos.html" target="_blank" class="dev-action-btn" title="Ir al Terminal de Caja POS" style="display: inline-flex; align-items: center; gap: 6px;">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="20" height="14" x="2" y="3" rx="2"/><line x1="8" x2="16" y1="21" y2="21"/><line x1="12" x2="12" y1="17" y2="21"/></svg>
<span>Caja POS</span>
</a>
<button onclick="switchDevToView('student')" class="dev-action-btn" title="Probar Vista de Alumno" style="display: inline-flex; align-items: center; gap: 6px;">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="20" height="14" x="2" y="5" rx="2"/><line x1="2" x2="22" y1="10" y2="10"/></svg>
<span>App Alumno</span>
</button>
<button onclick="logout(true)" class="dev-action-btn dev-action-btn-danger" style="display: inline-flex; align-items: center; gap: 6px;" title="Cerrar Sesión">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/><polyline points="16 17 21 12 16 7"/><line x1="21" x2="9" y1="12" y2="12"/></svg>
<span>Salir</span>
</button>
</div>
</header>
<!-- NAVEGACIÓN DE PESTAÑAS DEVELOPER -->
<nav class="dev-tabs-nav">
<button class="dev-tab-btn active" id="btnDevTabUsuarios" onclick="switchDevTab('usuarios')" style="display: inline-flex; align-items: center; gap: 8px;">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg>
<span>Usuarios & Administradores</span>
</button>
<button class="dev-tab-btn" id="btnDevTabDisenos" onclick="switchDevTab('disenos')" style="display: inline-flex; align-items: center; gap: 8px;">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="13.5" cy="6.5" r=".5" fill="currentColor"/><circle cx="17.5" cy="10.5" r=".5" fill="currentColor"/><circle cx="8.5" cy="7.5" r=".5" fill="currentColor"/><circle cx="6.5" cy="12.5" r=".5" fill="currentColor"/><path d="M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z"/></svg>
<span>Diseños de Tarjetas (Subir & Gestionar)</span>
</button>
<button class="dev-tab-btn" id="btnDevTabDiagnostico" onclick="switchDevTab('diagnostico')" style="display: inline-flex; align-items: center; gap: 8px;">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M22 12h-4l-3 9L9 3l-3 9H2"/></svg>
<span>Diagnóstico del Sistema & BD</span>
</button>
<button class="dev-tab-btn" id="btnDevTabEscuelas" onclick="switchDevTab('escuelas')" style="display: inline-flex; align-items: center; gap: 8px;">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 21h18"/><path d="M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"/><path d="M9 21v-4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v4"/><line x1="9" y1="9" x2="9" y2="9.01"/><line x1="15" y1="9" x2="15" y2="9.01"/></svg>
<span>Escuelas & Sedes</span>
</button>
<button class="dev-tab-btn" id="btnDevTabImportacion" onclick="switchDevTab('importacion')" style="display: inline-flex; align-items: center; gap: 8px;">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M23 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg>
<span>Carga Masiva (Excel/CSV)</span>
</button>
</nav>
<!-- 1. PESTAÑA: USUARIOS Y ADMINISTRADORES -->
<div id="devTabContentUsuarios" class="dev-tab-content">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 12px;">
<div style="display: flex; gap: 8px; flex-wrap: wrap; align-items: center;">
<input type="text" id="devUserSearchInput" placeholder="Buscar por nombre, usuario, rol..." oninput="filterDevUsuarios()" style="padding: 9px 14px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--card-bg); color: var(--text-main); font-size: 0.85rem; width: 260px; max-width: 100%;">
<select id="devUserRoleFilter" onchange="filterDevUsuarios()" style="padding: 9px 12px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--card-bg); color: var(--text-main); font-size: 0.85rem; font-weight: 700;">
<option value="all">Todos los Roles</option>
<option value="admin">Administradores</option>
<option value="developer">Developers</option>
<option value="cajero">Cajeros</option>
<option value="vendedor">Vendedores</option>
<option value="padre">Padres de Familia</option>
<option value="estudiante">Estudiantes</option>
</select>
</div>
<button onclick="openModalDevUser()" class="dev-action-btn dev-action-btn-primary" style="padding: 10px 18px; font-size: 0.88rem; display: inline-flex; align-items: center; gap: 6px;">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><line x1="19" x2="19" y1="8" y2="14"/><line x1="22" x2="16" y1="11" y2="11"/></svg>
<span>Crear Nuevo Usuario / Admin</span>
</button>
</div>
<!-- Resumen rápido de usuarios -->
<div id="devUserStatsStrip" style="display: flex; gap: 10px; overflow-x: auto; margin-bottom: 18px; padding-bottom: 4px;">
<!-- Inyectado dinámicamente -->
</div>
<!-- Tabla de usuarios -->
<div style="background: var(--card-bg); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; box-shadow: 0 4px 15px rgba(0,0,0,0.05);">
<div style="overflow-x: auto;">
<table style="width: 100%; border-collapse: collapse; font-size: 0.86rem; text-align: left;">
<thead>
<tr style="background: var(--bg-main); border-bottom: 1.5px solid var(--border); color: var(--text-muted); font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.5px;">
<th style="padding: 12px 14px;">ID</th>
<th style="padding: 12px 14px;">Usuario</th>
<th style="padding: 12px 14px;">Nombre</th>
<th style="padding: 12px 14px;">Rol</th>
<th style="padding: 12px 14px;">Contacto</th>
<th style="padding: 12px 14px;">Estado</th>
<th style="padding: 12px 14px; text-align: right;">Acciones</th>
</tr>
</thead>
<tbody id="devUsersTableBody">
<!-- Inyectado por JS -->
</tbody>
</table>
</div>
</div>
</div>
<!-- 2. PESTAÑA: DISEÑOS DE TARJETAS (SUBIR & GESTIONAR) -->
<div id="devTabContentDisenos" class="dev-tab-content" style="display: none;">
<!-- FORMULARIO DE SUBIDA DE NUEVO DISEÑO -->
<div style="background: var(--card-bg); border: 1.5px solid var(--border); border-radius: 18px; padding: 22px; margin-bottom: 30px; box-shadow: 0 6px 20px rgba(0,0,0,0.05);">
<div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 8px;">
<div>
<h3 style="font-size: 1.15rem; font-weight: 900; margin: 0; color: var(--text-main); display: flex; align-items: center; gap: 8px;">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 5v14"/><path d="M5 12h14"/></svg>
<span>Subir Nuevo Diseño de Tarjeta</span>
</h3>
<p style="font-size: 0.84rem; color: var(--text-muted); margin: 3px 0 0;">Sube una imagen personalizada. Quedará disponible inmediatamente para que los estudiantes la elijan.</p>
</div>
<span style="font-size: 0.78rem; font-weight: 800; background: #f0f9ff; color: #0284c7; border: 1px solid #bae6fd; padding: 4px 10px; border-radius: 8px;">Recomendado: 1200x756 (3:2)</span>
</div>
<form id="formDevCardDesign" onsubmit="saveDevCardDesign(event)" style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px;">
<!-- Columna Izquierda: Input de archivo y campos -->
<div>
<!-- Zona de subida -->
<label for="devCardFileInput" class="dev-card-uploader-box" id="devUploadDropZone" style="display: block;">
<input type="file" id="devCardFileInput" accept="image/*" style="display: none;" onchange="handleDevCardFileSelect(event)">
<div id="devUploadPrompt">
<div style="margin-bottom: 8px;">
<svg width="40" height="40" viewBox="0 0 24 24" fill="none" stroke="#94a3b8" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></svg>
</div>
<div style="font-weight: 800; font-size: 0.95rem; color: var(--text-main); margin-bottom: 4px;">Toca o arrastra una imagen de tarjeta aquí</div>
<div style="font-size: 0.78rem; color: var(--text-muted);">Soporta JPG, PNG, WEBP o SVG (hasta 20MB)</div>
</div>
<div id="devUploadSuccess" style="display: none; color: #10b981; font-weight: 800; font-size: 0.88rem;">
<span style="display: inline-flex; align-items: center; gap: 6px;"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg> Imagen seleccionada con éxito</span>
<div id="devUploadFileName" style="font-size: 0.75rem; color: var(--text-muted); margin-top: 4px;"></div>
</div>
</label>
<div style="margin-bottom: 12px;">
<label style="font-size: 0.82rem; font-weight: 800; color: var(--text-main); display: block; margin-bottom: 5px;">Nombre del Diseño:</label>
<input type="text" id="devCardName" placeholder="Ej: Cyber Dragón, Galaxia Púrpura..." required style="width: 100%; padding: 10px 12px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--bg-main); color: var(--text-main); font-weight: 700; box-sizing: border-box;" oninput="updateDevCardLivePreview()">
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px;">
<div>
<label style="font-size: 0.82rem; font-weight: 800; color: var(--text-main); display: block; margin-bottom: 5px;">Categoría:</label>
<select id="devCardCategory" style="width: 100%; padding: 10px 12px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--bg-main); color: var(--text-main); font-weight: 700; box-sizing: border-box;" onchange="updateDevCardLivePreview()">
<option value="uni">Unisex / Universal</option>
<option value="fem">Femenino</option>
<option value="masc">Masculino</option>
</select>
</div>
<div>
<label style="font-size: 0.82rem; font-weight: 800; color: var(--text-main); display: block; margin-bottom: 5px;">Contraste de Texto:</label>
<select id="devCardTextStyle" style="width: 100%; padding: 10px 12px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--bg-main); color: var(--text-main); font-weight: 700; box-sizing: border-box;" onchange="updateDevCardLivePreview()">
<option value="dark">Texto Blanco (Fondo Oscuro)</option>
<option value="light">Texto Oscuro (Fondo Claro)</option>
</select>
</div>
</div>
<button type="submit" id="btnDevSubmitCard" class="dev-action-btn dev-action-btn-primary" style="width: 100%; padding: 12px; justify-content: center; font-size: 0.95rem; border-radius: 12px; display: inline-flex; align-items: center; gap: 8px;">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" x2="12" y1="3" y2="15"/></svg>
<span>Guardar y Publicar Diseño</span>
</button>
</div>
<!-- Columna Derecha: Previsualizador en vivo con datos reales de estudiante -->
<div>
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;">
<span style="font-size: 0.82rem; font-weight: 800; color: var(--text-main); display: inline-flex; align-items: center; gap: 6px;">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"/><circle cx="12" cy="12" r="3"/></svg>
<span>Previsualización en Vivo de la Tarjeta</span>
</span>
<span style="font-size: 0.72rem; color: #10b981; font-weight: 800;">✓ Sin asteriscos</span>
</div>
<!-- Contenedor de la tarjeta simulada -->
<div id="devLiveCardPreviewWrapper" style="position: relative; width: 100%; aspect-ratio: 1.586; border-radius: 18px; overflow: hidden; background: #0f172a; border: 1.5px solid var(--border); box-shadow: 0 10px 25px rgba(0,0,0,0.25);">
<img id="devLiveCardBgImg" src="/img/cards/card_robo_lab.jpg" alt="Fondo" style="width: 100%; height: 100%; object-fit: cover; display: block;">
<div id="devLiveCardOverlay" class="card-overlay" style="opacity: 1; position: absolute; inset: 0; padding: 16px 18px; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none;">
<div style="display: flex; justify-content: space-between; align-items: center;">
<div class="card-emv-chip" style="width: 34px; height: 25px; margin: 0;">
<div class="chip-inner-circuit"></div>
</div>
<span id="devLiveCardBrand" style="font-weight: 900; font-size: 0.85rem; letter-spacing: 0.5px; text-transform: uppercase; color: #ffffff; text-shadow: 0 2px 8px rgba(0,0,0,0.8); display: inline-flex; align-items: center; gap: 5px;"><span style="color: #38bdf8; font-size: 0.65rem;">●</span> SIBOPAY</span>
</div>
<div style="margin-top: auto; margin-bottom: 6px;">
<div id="devLiveCardName" style="font-size: 1.05rem; font-weight: 900; color: #ffffff; text-shadow: 0 2px 8px rgba(0,0,0,0.9);">MATEO ALVARADO CASTRO</div>
<div id="devLiveCardGrade" style="font-size: 0.74rem; font-weight: 700; color: #cbd5e1; text-shadow: 0 2px 6px rgba(0,0,0,0.9);">2° Grado · Sección 2-A</div>
</div>
<div style="display: flex; justify-content: space-between; align-items: flex-end;">
<div>
<div id="devLiveCardBalLabel" style="font-size: 0.65rem; font-weight: 800; text-transform: uppercase; color: #cbd5e1; letter-spacing: 0.5px;">Saldo Disponible</div>
<div id="devLiveCardBalValue" style="font-size: 1.25rem; font-weight: 900; color: #4ade80; text-shadow: 0 2px 10px rgba(0,0,0,0.95);">₡5.300</div>
</div>
<div id="devLiveCardCode" style="font-size: 0.72rem; font-weight: 800; color: #ffffff; background: rgba(0,0,0,0.5); padding: 3px 8px; border-radius: 6px; backdrop-filter: blur(4px); border: 1px solid rgba(255,255,255,0.2);">EST-2026-00001</div>
</div>
</div>
</div>
<div id="devLiveCardThemeTitle" style="font-size: 0.85rem; font-weight: 800; color: var(--text-main); margin-top: 8px; text-align: center;">
Robo-Lab Tech (Vista Previa)
</div>
</div>
</form>
</div>
<!-- GALERÍA DE DISEÑOS DISPONIBLES EN EL SISTEMA -->
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 10px;">
<div>
<h3 style="font-size: 1.15rem; font-weight: 900; margin: 0; color: var(--text-main); display: flex; align-items: center; gap: 8px;">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><line x1="3" x2="21" y1="9" y2="9"/><line x1="9" x2="9" y1="21" y2="9"/></svg>
<span>Catálogo de Diseños Publicados (<span id="devDisenosCount">0</span>)</span>
</h3>
<p style="font-size: 0.82rem; color: var(--text-muted); margin: 3px 0 0;">Estos son los diseños que pueden elegir los estudiantes en su carrusel.</p>
</div>
<div style="display: flex; gap: 6px;">
<button class="dev-action-btn" onclick="filterDevDisenosGrid('all', this)">Todos</button>
<button class="dev-action-btn" onclick="filterDevDisenosGrid('fem', this)">Femenino</button>
<button class="dev-action-btn" onclick="filterDevDisenosGrid('masc', this)">Masculino</button>
<button class="dev-action-btn" onclick="filterDevDisenosGrid('uni', this)">Unisex</button>
</div>
</div>
<div id="devDisenosGrid" style="display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px;">
<!-- Inyectado dinámicamente -->
</div>
</div>
<!-- 3. PESTAÑA: DIAGNÓSTICO DEL SISTEMA & BD -->
<div id="devTabContentDiagnostico" class="dev-tab-content" style="display: none;">
<div id="devStatsContainer" style="display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px;">
<!-- Inyectado dinámicamente -->
</div>
<!-- SECCIÓN: COPIAS DE SEGURIDAD (BACKUPS) AUTOMÁTICAS -->
<div class="dev-card" style="background: var(--card-bg); border: 1.5px solid var(--border); border-radius: 18px; padding: 22px; margin-top: 20px;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 10px;">
<div style="display: flex; align-items: center; gap: 10px;">
<div style="width: 38px; height: 38px; border-radius: 10px; background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; display: flex; align-items: center; justify-content: center; font-size: 1.25rem;">
💾
</div>
<div>
<h3 style="margin: 0; font-size: 1.08rem; font-weight: 900; color: var(--text-main);">Copias de Seguridad del Sistema (Backups)</h3>
<span style="font-size: 0.76rem; color: var(--text-muted);">Respaldos automáticos diarios y descargas manuales</span>
</div>
</div>
<button type="button" onclick="ejecutarBackupManualDev()" id="btnDevCrearBackup" class="dev-action-btn dev-action-btn-primary" style="padding: 9px 18px; font-size: 0.84rem; display: inline-flex; align-items: center; gap: 6px;">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.3" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>
<span>Crear Respaldo Ahora</span>
</button>
</div>
<div id="devBackupsStatusMsg" style="display: none; padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; font-size: 0.82rem; font-weight: 700;"></div>
<div style="overflow-x: auto;">
<table class="dev-table" style="width: 100%; border-collapse: collapse; font-size: 0.82rem;">
<thead>
<tr style="border-bottom: 1.5px solid var(--border); text-align: left; color: var(--text-muted);">
<th style="padding: 10px 12px;">Archivo de Respaldo</th>
<th style="padding: 10px 12px;">Motor BD</th>
<th style="padding: 10px 12px;">Fecha y Hora</th>
<th style="padding: 10px 12px;">Tamaño</th>
<th style="padding: 10px 12px; text-align: right;">Acción</th>
</tr>
</thead>
<tbody id="devBackupsTableBody">
<tr>
<td colspan="5" style="text-align: center; padding: 18px; color: var(--text-muted);">Cargando copias de seguridad...</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<!-- 4. PESTAÑA: ESCUELAS & SEDES (MULTI-TENANT) -->
<div id="devTabContentEscuelas" class="dev-tab-content" style="display: none;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 12px;">
<div>
<h3 style="margin: 0; font-size: 1.18rem; font-weight: 900; color: var(--text-main);">Gestión de Escuelas & Sedes Multi-Tenant</h3>
<p style="margin: 4px 0 0 0; font-size: 0.85rem; color: var(--text-muted);">Cada centro educativo opera de forma autónoma con su propio catálogo, SINPE Móvil, estudiantes y personal.</p>
</div>
<button onclick="openModalDevEscuela()" class="dev-action-btn dev-action-btn-primary" style="padding: 10px 18px; font-size: 0.88rem; display: inline-flex; align-items: center; gap: 8px;">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>
<span>+ Dar de Alta Nueva Escuela</span>
</button>
</div>
<!-- Resumen global de sedes -->
<div id="devEscuelasSummaryStrip" style="display: flex; gap: 12px; overflow-x: auto; margin-bottom: 20px; padding-bottom: 4px;">
<!-- Inyectado dinámicamente -->
</div>
<!-- Grid de Tarjetas de Escuelas -->
<div id="devEscuelasGrid" style="display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px;">
<!-- Inyectado dinámicamente -->
</div>
</div>
<!-- 5. PESTAÑA: CARGA MASIVA DE ESTUDIANTES (DEVELOPER) -->
<div id="devTabContentImportacion" class="dev-tab-content" style="display: none;">
<div class="dev-card" style="background: var(--card-bg); border: 1.5px solid var(--border); border-radius: 18px; padding: 24px; margin-bottom: 20px;">
<div style="display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; flex-wrap: wrap; gap: 12px;">
<div>
<h3 style="margin: 0; font-size: 1.2rem; font-weight: 900; color: var(--text-main); display: flex; align-items: center; gap: 8px;">
<span>👥 Carga Masiva de Estudiantes vía Excel / CSV</span>
</h3>
<p style="margin: 4px 0 0 0; font-size: 0.82rem; color: var(--text-muted); line-height: 1.4;">
Importa decenas o cientos de estudiantes en segundos. Puedes subir un archivo <code>.csv</code> o pegar las celdas directamente copiadas desde Microsoft Excel o Google Sheets.
</p>
</div>
<div style="display: flex; gap: 8px; flex-wrap: wrap;">
<button type="button" onclick="cargarEjemploImportacionDev()" class="dev-action-btn" style="padding: 8px 14px; font-size: 0.80rem; display: inline-flex; align-items: center; gap: 6px; background: #e0f2fe; color: #0284c7; border: 1.5px solid #bae6fd; font-weight: 800;" title="Pega 3 estudiantes de muestra para probar la herramienta de inmediato">
<span>⚡ Cargar Datos de Ejemplo</span>
</button>
<button type="button" onclick="descargarPlantillaCsvEstudiantes()" class="dev-action-btn" style="padding: 8px 14px; font-size: 0.80rem; display: inline-flex; align-items: center; gap: 6px;">
<span>📥 Descargar Plantilla (.CSV)</span>
</button>
</div>
</div>
<!-- Paso 1: Seleccionar Escuela Destino -->
<div style="margin-bottom: 18px; background: #f8fafc; border: 1.5px solid var(--border); padding: 16px; border-radius: 14px;">
<label style="font-size: 0.84rem; font-weight: 800; color: var(--text-main); display: block; margin-bottom: 6px;">
1. Selecciona la Escuela / Sede de Destino: *
</label>
<select id="devImportEscuelaSelect" style="width: 100%; max-width: 420px; padding: 10px 14px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--card-bg); color: var(--text-main); font-weight: 700; font-size: 0.90rem;">
<option value="1">Soda Escolar Central (ESC01)</option>
</select>
</div>
<!-- Paso 2: Pegar o Subir Datos -->
<div style="margin-bottom: 18px;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px;">
<label style="font-size: 0.84rem; font-weight: 800; color: var(--text-main); display: block;">
2. Pega aquí los datos desde Excel o escribe en formato CSV:
</label>
<span style="font-size: 0.74rem; color: var(--text-muted);">Columnas: <strong>Nombre, Grado, Sección, Saldo (opcional), Alergias (opcional), Tel. Padre (opcional)</strong></span>
</div>
<textarea id="devImportTextarea" rows="7" placeholder="Ejemplo pegado desde Excel:&#10;Santiago Morales Castro&#9;5to&#9;5-B&#9;2500&#9;Lactosa&#9;8888-1234&#10;Valeria Solano Gómez&#9;3ro&#9;3-A&#9;5000&#9;Ninguna&#9;8765-4321&#10;Mateo Alvarado Pérez&#9;2do&#9;2-A&#9;0&#9;Maní&#9;8333-2211" style="width: 100%; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--card-bg); color: var(--text-main); font-family: monospace; font-size: 0.84rem; line-height: 1.45; box-sizing: border-box;"></textarea>
<div style="display: flex; justify-content: space-between; align-items: center; margin-top: 10px; flex-wrap: wrap; gap: 10px;">
<div style="display: flex; align-items: center; gap: 8px;">
<span style="font-size: 0.78rem; font-weight: 700; color: var(--text-muted);">O selecciona archivo CSV:</span>
<input type="file" id="devImportFileInput" accept=".csv,.txt" onchange="handleDevImportFile(event)" style="font-size: 0.78rem;">
</div>
<button type="button" onclick="analizarDatosImportacionDev()" class="dev-action-btn dev-action-btn-primary" style="padding: 10px 20px; font-size: 0.88rem; display: inline-flex; align-items: center; gap: 6px;">
<span>🔍 Previsualizar y Validar</span>
</button>
</div>
</div>
<!-- Paso 3: Previsualización de Datos -->
<div id="devImportPreviewBox" style="display: none; border-top: 1.5px dashed var(--border); padding-top: 18px; margin-top: 18px;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; flex-wrap: wrap; gap: 8px;">
<div style="display: flex; align-items: center; gap: 10px;">
<span id="devImportPreviewCount" style="background: #e0f2fe; color: #0284c7; padding: 4px 10px; border-radius: 8px; font-weight: 800; font-size: 0.80rem;">0 Alumnos Detectados</span>
<span style="font-size: 0.78rem; color: var(--text-muted);">Revisa la lista antes de guardar</span>
</div>
<button type="button" onclick="ejecutarImportacionMasivaDev()" id="btnDevEjecutarImport" class="dev-action-btn dev-action-btn-primary" style="background: linear-gradient(135deg, #16a34a, #15803d); border-color: #16a34a; padding: 10px 22px; font-size: 0.90rem; font-weight: 800;">
<span>⚡ Confirmar e Importar Todos los Estudiantes</span>
</button>
</div>
<div style="overflow-x: auto; max-height: 380px; overflow-y: auto; border: 1px solid var(--border); border-radius: 12px;">
<table class="dev-table" style="width: 100%; border-collapse: collapse; font-size: 0.82rem;">
<thead style="position: sticky; top: 0; background: var(--card-bg); z-index: 2;">
<tr style="border-bottom: 1.5px solid var(--border); text-align: left; color: var(--text-muted);">
<th style="padding: 8px 10px;">#</th>
<th style="padding: 8px 10px;">Nombre Completo</th>
<th style="padding: 8px 10px;">Grado/Sección</th>
<th style="padding: 8px 10px;">Saldo Inicial</th>
<th style="padding: 8px 10px;">Alergias</th>
<th style="padding: 8px 10px;">Teléfono Padre</th>
<th style="padding: 8px 10px;">Código Asignado</th>
</tr>
</thead>
<tbody id="devImportPreviewTbody">
<!-- Filas inyectadas -->
</tbody>
</table>
</div>
</div>
<div id="devImportResultMsg" style="display: none; margin-top: 16px; padding: 14px; border-radius: 12px; font-size: 0.84rem; line-height: 1.45;"></div>
</div>
</div>
</div>
<!-- PANEL DE ADMINISTRACIÓN DE LA SODA (#viewAdmin) -->
<div id="viewAdmin" class="admin-container" style="display: none;">
<!-- CABECERA DE ADMINISTRADOR -->
<header class="admin-header" style="display: flex; flex-direction: column; gap: 12px;">
<!-- FILA SUPERIOR: MARCA/TÍTULO A LA IZQUIERDA Y BOTÓN SALIR ÚNICO ARRIBITA A LA DERECHA -->
<div style="display: flex; justify-content: space-between; align-items: center; width: 100%; gap: 10px;">
<div class="admin-badge" style="display: flex; align-items: center; gap: 10px; min-width: 0;">
<div class="admin-icon" style="flex-shrink: 0;">
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/><polyline points="9 22 9 12 15 12 15 22"/></svg>
</div>
<div style="min-width: 0;">
<h2 style="font-size: 1.15rem; font-weight: 900; margin: 0; color: var(--text-main); line-height: 1.2;">Administración de la Soda</h2>
<span id="adminLoggedName" style="font-size: 0.76rem; color: #0284c7; font-weight: 700; display: block;">Soda Escolar Central</span>
</div>
</div>
<!-- ACCIONES SUPERIORES: TEMA Y BOTÓN SALIR ARRIBITA A LA DERECHA -->
<div style="display: flex; align-items: center; gap: 8px; flex-shrink: 0;">
<button onclick="toggleTheme()" class="btn-saas btn-saas-outline" style="width: 34px; height: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 9px;" title="Alternar Modo Oscuro / Modo Claro">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"/></svg>
</button>
<button onclick="logout(true)" class="btn-saas btn-saas-danger-subtle" style="height: 34px; font-size: 0.82rem; font-weight: 800; border-radius: 9px; padding: 0 14px; box-shadow: 0 1px 3px rgba(220, 38, 38, 0.08); display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;" title="Cerrar sesión y cambiar de cuenta">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.3" stroke-linecap="round" stroke-linejoin="round"><path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/><polyline points="16 17 21 12 16 7"/><line x1="21" y1="12" x2="9" y2="12"/></svg>
<span class="admin-btn-text">Salir</span>
</button>
</div>
</div>
<!-- FILA DE ACCIONES RÁPIDAS: RECARGAR SALDO, TERMINAL POS, PANEL DEV -->
<div class="admin-header-actions" style="display: flex; align-items: center; gap: 8px; flex-wrap: wrap; width: 100%;">
<button id="btnAdminDevPanel" onclick="switchAdminToDev()" class="btn-saas btn-saas-outline" style="display: none; border-color: #0284c7; color: #0284c7; height: 34px;" title="Volver al Panel Developer Master">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m18 16 4-4-4-4"/><path d="m6 8-4 4 4 4"/><path d="m14.5 4-5 16"/></svg>
<span class="admin-btn-text">Panel Dev</span>
</button>
<button onclick="switchAdminTab('recarga')" class="btn-saas btn-saas-primary" style="height: 34px;" title="Recargar saldo a un estudiante">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="20" height="14" x="2" y="5" rx="2"/><line x1="2" x2="22" y1="10" y2="10"/></svg>
<span class="admin-btn-text">Recargar Saldo</span>
</button>
<a href="/pos.html" target="_blank" class="btn-saas btn-saas-outline" style="height: 34px;" title="Abrir Caja / Terminal POS">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="20" height="14" x="2" y="3" rx="2"/><line x1="8" x2="16" y1="21" y2="21"/><line x1="12" x2="12" y1="17" y2="21"/></svg>
<span class="admin-btn-text">Terminal POS</span>
</a>
<button type="button" onclick="exportarVentasCsv()" class="btn-saas btn-saas-outline" style="height: 34px; border-color: #10b981; color: #166534;" title="Descargar histórico de ventas a archivo Excel / CSV">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>
<span class="admin-btn-text">📊 Ventas Excel</span>
</button>
<button type="button" onclick="exportarEstudiantesCsv()" class="btn-saas btn-saas-outline" style="height: 34px; border-color: #0284c7; color: #0284c7;" title="Descargar listado de saldos de alumnos a Excel / CSV">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>
<span class="admin-btn-text">📋 Saldos Excel</span>
</button>
</div>
</header>
<!-- MÉTRICAS DE HOY -->
<div class="admin-stats-grid">
<div class="admin-stat-card">
<div class="val" id="adminStatVentas">₡0</div>
<div class="lbl">Ventas Hoy</div>
</div>
<div class="admin-stat-card">
<div class="val" id="adminStatOrdenes">0</div>
<div class="lbl">Órdenes Despachadas</div>
</div>
<div class="admin-stat-card">
<div class="val" id="adminStatEstudiantes">0</div>
<div class="lbl">Estudiantes Activos</div>
</div>
<div class="admin-stat-card">
<div class="val" id="adminStatBloqueados" style="color: #ef4444;">0</div>
<div class="lbl">Tarjetas Bloqueadas</div>
</div>
<div class="admin-stat-card">
<div class="val" id="adminStatCriticos" style="color: #f59e0b;">0</div>
<div class="lbl">Bajo Stock / Agotados</div>
</div>
</div>
<!-- PESTAÑAS DE NAVEGACIÓN ADMIN -->
<div class="admin-tabs">
<button class="admin-tab-btn active" id="btnTabAdminInventario" onclick="switchAdminTab('inventario')">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m7.5 4.27 9 5.15"/><path d="M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"/><path d="m3.3 7 8.7 5 8.7-5"/><path d="M12 22V12"/></svg>
<span>Inventario & Stock</span>
</button>
<button class="admin-tab-btn" id="btnTabAdminEstudiantes" onclick="switchAdminTab('estudiantes')">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="18" height="18" x="3" y="3" rx="2"/><path d="M7 7h.01"/><path d="M11 7h6"/><path d="M7 11h.01"/><path d="M11 11h6"/><path d="M7 15h.01"/><path d="M11 15h6"/></svg>
<span>Estudiantes, Carnés & Bloqueos</span>
</button>
<button class="admin-tab-btn" id="btnTabAdminPersonal" onclick="switchAdminTab('personal')">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg>
<span>Personal & Cajeros</span>
</button>
<button class="admin-tab-btn" id="btnTabAdminRecarga" onclick="switchAdminTab('recarga')">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="20" height="14" x="2" y="5" rx="2"/><line x1="2" x2="22" y1="10" y2="10"/></svg>
<span>Recargas & SINPE</span>
<span id="badgeAdminTabSinpeCount" style="background: #10b981; color: white; padding: 2px 7px; border-radius: 10px; font-size: 0.70rem; font-weight: 800; display: none; margin-left: 5px;">0</span>
</button>
<button class="admin-tab-btn" id="btnTabAdminMovimientos" onclick="switchAdminTab('movimientos')">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2v4a2 2 0 0 0 2 2h4"/><path d="M16 22h2a2 2 0 0 0 2-2V7.5L14.5 2H6a2 2 0 0 0-2 2v3"/><path d="m3 12.5 3 3 6-6"/></svg>
<span>Movimientos & Reversiones</span>
</button>
</div>
<!-- TAB 1: INVENTARIO Y STOCK -->
<div id="adminTabContentInventario" class="admin-card">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; flex-wrap: wrap; gap: 10px;">
<div>
<h3 style="margin: 0; font-size: 1.1rem; font-weight: 800; color: var(--text-main);">Inventario y Existencias</h3>
<p style="margin: 2px 0 0 0; font-size: 0.75rem; color: var(--text-muted);">
Crea, edita productos, controla precios, existencias y clasificación nutricional.
</p>
</div>
<div style="display: flex; gap: 8px; align-items: center; flex-wrap: wrap;">
<input type="text" id="adminSearchProduct" placeholder="Buscar alimento o bebida..." oninput="filterAdminProducts(this.value)" style="padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border); font-size: 0.85rem; width: 190px; background: var(--card-bg); color: var(--text-main); outline: none;">
<button type="button" onclick="openCreateProductModal()" class="btn-saas btn-saas-primary" style="height: 36px; padding: 0 14px; font-size: 0.84rem;">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14"/><path d="M12 5v14"/></svg>
<span>Nuevo Producto</span>
</button>
</div>
</div>
<div id="adminProductsList">
<!-- Renderizado dinámico de productos y stock -->
</div>
</div>
<!-- TAB 2: ESTUDIANTES Y CARNÉS -->
<div id="adminTabContentEstudiantes" class="admin-card" style="display: none;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; flex-wrap: wrap; gap: 10px;">
<div>
<h3 style="margin: 0; font-size: 1.1rem; font-weight: 800; color: var(--text-main);">Alumnos y Tarjetas Escolares</h3>
<p style="margin: 2px 0 0 0; font-size: 0.75rem; color: var(--text-muted);">
Bloquea tarjetas perdidas, crea nuevos alumnos o genera carnés con código QR.
</p>
</div>
<div style="display: flex; gap: 8px; align-items: center; flex-wrap: wrap;">
<input type="text" id="adminSearchStudentsTab2" placeholder="Filtrar alumnos..." oninput="filterAdminStudentsTab2(this.value)" style="padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border); font-size: 0.85rem; width: 190px; background: var(--card-bg); color: var(--text-main); outline: none;">
<button onclick="openNewStudentModal()" class="btn-saas btn-saas-primary" style="height: 36px; padding: 0 14px; font-size: 0.84rem;">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14"/><path d="M12 5v14"/></svg>
<span>Nuevo Estudiante</span>
</button>
</div>
</div>
<div id="adminStudentsList">
<!-- Renderizado dinámico de estudiantes con botones de bloqueo -->
</div>
</div>
<!-- TAB 3: CARGA MANUAL DE DINERO Y APROBACIÓN SINPE -->
<div id="adminTabContentRecarga" class="admin-card" style="display: none; max-width: 820px; margin: 0 auto;">
<!-- SECCIÓN 1: SOLICITUDES SINPE PENDIENTES DE APROBACIÓN -->
<div id="adminSinpeRequestsBox" style="margin-bottom: 24px; background: #ffffff; border: 1.5px solid #86efac; border-radius: 16px; padding: 14px 14px; box-sizing: border-box; overflow: hidden; box-shadow: 0 2px 10px rgba(16, 185, 129, 0.08);">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; flex-wrap: wrap; gap: 10px;">
<div style="display: flex; align-items: center; gap: 10px;">
<div style="width: 40px; height: 40px; border-radius: 12px; background: #ecfdf5; color: #10b981; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; border: 1.5px solid #a7f3d0; flex-shrink: 0;">
📱
</div>
<div>
<h4 style="margin: 0; font-size: 1.05rem; font-weight: 900; color: #0f172a; display: flex; align-items: center; gap: 8px;">
<span>Aprobar Recargas SINPE Móvil</span>
<span id="adminSinpeCountBadge" style="background: #10b981; color: white; font-size: 0.72rem; font-weight: 800; padding: 2px 8px; border-radius: 12px; display: none;">0</span>
</h4>
<p style="margin: 2px 0 0 0; font-size: 0.78rem; color: #64748b;">
Verifica las transferencias reportadas por los padres y acredita el saldo al instante.
</p>
</div>
</div>
<button type="button" onclick="loadAdminSinpeRequests()" class="btn-saas btn-saas-outline" style="height: 32px; padding: 0 12px; font-size: 0.78rem; font-weight: 700;">
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="display: inline-block; vertical-align: middle; margin-right: 4px;"><path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/><path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"/><path d="M3 21v-5h5"/></svg>
<span>Refrescar</span>
</button>
</div>
<div id="adminSinpeRequestsList" style="display: flex; flex-direction: column; gap: 12px;">
<!-- Solicitudes SINPE pendientes cargadas dinámicamente -->
</div>
</div>
<!-- SEPARADOR CON RECARGA EN EFECTIVO -->
<div style="text-align: center; margin: 26px 0 20px 0; position: relative;">
<hr style="border: none; border-top: 1px solid #e2e8f0; margin: 0;">
<span style="position: absolute; top: -10px; left: 50%; transform: translateX(-50%); background: var(--card-bg, #ffffff); padding: 0 14px; font-size: 0.78rem; font-weight: 800; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.5px;">O Recarga Manual en Efectivo</span>
</div>
<div style="text-align: center; margin-bottom: 18px;">
<div style="width: 48px; height: 48px; border-radius: 12px; background: rgba(2, 132, 199, 0.1); color: #0284c7; display: flex; align-items: center; justify-content: center; margin: 0 auto 8px;">
<svg width="26" height="26" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="20" height="14" x="2" y="5" rx="2"/><line x1="2" x2="22" y1="10" y2="10"/></svg>
</div>
<h3 style="margin: 6px 0 2px 0; font-size: 1.25rem; font-weight: 900; color: var(--text-main);">Carga Manual de Dinero</h3>
<p style="margin: 0; font-size: 0.78rem; color: var(--text-muted);">
Recarga de monedero estudiantil por pago en efectivo en la soda o ajuste escolar
</p>
</div>
<!-- BUSCADOR INTELIGENTE Y BOTÓN ESCANEAR QR -->
<div style="background: rgba(2, 132, 199, 0.05); border: 2px solid #0284c7; border-radius: 16px; padding: 14px; margin-bottom: 16px; box-shadow: 0 3px 12px rgba(2, 132, 199, 0.08);">
<div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; flex-wrap: wrap; gap: 6px;">
<label for="inputAdminSearchStudent" style="font-size: 0.88rem; font-weight: 900; color: var(--text-main); display: flex; align-items: center; gap: 6px; margin: 0;">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="#0284c7" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/></svg>
<span>Buscador Inteligente de Estudiante:</span>
</label>
<span style="font-size: 0.68rem; font-weight: 800; background: #0284c7; color: white; padding: 2px 8px; border-radius: 6px;">
⚡ Búsqueda en vivo
</span>
</div>
<div class="admin-search-container" style="position: relative;">
<div class="admin-search-input-wrap" style="display: flex; gap: 8px; align-items: center;">
<div style="position: relative; flex: 1; width: 100%;">
<input type="text" id="inputAdminSearchStudent" class="admin-search-input" placeholder="Escribe para buscar (ej: Mateo, EST-2026, Alvarado)..." oninput="onAdminSearchStudent(this.value)" onfocus="onAdminSearchFocus()" autocomplete="off" style="width: 100%; box-sizing: border-box; padding: 11px 36px 11px 14px; font-size: 0.95rem; font-weight: 700; border-radius: 12px; border: 2px solid #cbd5e1; outline: none; background: var(--card-bg, #ffffff); color: var(--text-main);">
<button type="button" id="btnClearAdminSearch" onclick="clearAdminSearchStudent()" style="display: none; position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: #e2e8f0; border: none; border-radius: 50%; width: 22px; height: 22px; font-size: 0.75rem; font-weight: 900; color: #475569; cursor: pointer; align-items: center; justify-content: center;" title="Borrar búsqueda">✕</button>
</div>
<button type="button" onclick="openAdminScanQrModal()" class="btn-saas btn-saas-primary" title="Escanear carné físico o código QR con la cámara" style="flex-shrink: 0; height: 42px; padding: 0 14px; font-size: 0.85rem; border-radius: 10px;">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="18" height="18" x="3" y="3" rx="2"/><path d="M7 7h.01"/><path d="M17 7h.01"/><path d="M7 17h.01"/><path d="M17 17h.01"/></svg>
<span>Escanear QR</span>
</button>
</div>
<div id="adminSearchResultsDropdown" class="admin-search-dropdown" style="display: none;"></div>
</div>
<div style="font-size: 0.72rem; color: var(--text-muted); margin-top: 6px;">
<span style="display: inline-flex; align-items: center; gap: 4px;">
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" x2="12" y1="16" y2="12"/><line x1="12" x2="12.01" y1="8" y2="8"/></svg>
<em>Toca el buscador para ver alumnos o escribe nombre, apellidos o carné para filtrar al instante.</em>
</span>
</div>
</div>
<!-- ESTADO 2: FICHA DEL ESTUDIANTE SELECCIONADO TRAS ESCANEO O BÚSQUEDA -->
<div id="adminSelectedStudentWrap" style="display: none; margin-bottom: 16px;">
<div style="margin-bottom: 6px; display: flex; justify-content: space-between; align-items: center;">
<span style="font-size: 0.75rem; font-weight: 800; color: #166534; text-transform: uppercase; letter-spacing: 0.5px; display: flex; align-items: center; gap: 4px;">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="#16a34a" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>
<span>Estudiante Seleccionado:</span>
</span>
<button type="button" onclick="clearAdminSelectedStudent()" style="background: none; border: none; color: #ef4444; font-size: 0.74rem; font-weight: 800; cursor: pointer; display: flex; align-items: center; gap: 3px;">
✕ Cambiar / Quitar
</button>
</div>
<div id="adminSelectedStudentBanner" class="selected-student-banner" style="display: flex;">
<div style="display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1;">
<div id="adminSelectedAvatar" class="admin-selected-avatar-badge">ES</div>
<div style="min-width: 0;">
<div style="display: flex; align-items: center; gap: 6px; flex-wrap: wrap;">
<strong id="adminSelectedName" style="font-size: 1rem; color: var(--text-main); word-break: break-word;">Selecciona un alumno</strong>
<span id="adminSelectedStatusBadge" style="font-size: 0.65rem; font-weight: 800; background: #dcfce7; color: #166534; padding: 2px 6px; border-radius: 4px;">ACTIVA</span>
</div>
<div id="adminSelectedMeta" style="font-size: 0.75rem; color: var(--text-muted); margin-top: 2px;">
Grado y Sección • Cód: EST-2026-000
</div>
</div>
</div>
<div style="text-align: right; flex-shrink: 0;">
<div style="font-size: 0.68rem; font-weight: 800; color: var(--text-muted); text-transform: uppercase;">Saldo Actual</div>
<div id="adminSelectedBalance" style="font-size: 1.25rem; font-weight: 900; color: #10b981;">₡0</div>
</div>
</div>
</div>
<!-- SELECT OCULTO PARA COMPATIBILIDAD CON FUNCIONES JS -->
<select id="adminRecargaStudentSelect" style="display: none;" onchange="onAdminSelectChange(this.value)"></select>
<!-- SECCIÓN DE MONTO Y RECARGA (HABILITADA TRAS ESCANEO) -->
<div id="adminRecargaFormFields" style="opacity: 0.45; pointer-events: none; transition: all 0.25s ease;">
<div style="margin-bottom: 12px;">
<label style="display: block; font-size: 0.8rem; font-weight: 800; color: var(--text-main); margin-bottom: 5px;">
Monto a Recargar en Colones:
</label>
<div style="position: relative;">
<span style="position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-weight: 900; font-size: 1.1rem; color: #10b981;">₡</span>
<input type="tel" inputmode="numeric" pattern="[0-9]*" id="adminRecargaMonto" placeholder="Ej: 5000" style="width: 100%; padding: 11px 12px 11px 32px; border-radius: 10px; border: 2px solid #10b981; font-size: 1.15rem; font-weight: 900; color: var(--text-main); background: var(--card-bg); box-sizing: border-box;">
</div>
</div>
<div style="display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 14px;">
<button type="button" onclick="setAdminRecargaPreset(1000)" class="btn-saas btn-saas-outline" style="height: 36px; font-weight: 800;">₡1.000</button>
<button type="button" onclick="setAdminRecargaPreset(2000)" class="btn-saas btn-saas-outline" style="height: 36px; font-weight: 800;">₡2.000</button>
<button type="button" onclick="setAdminRecargaPreset(5000)" class="btn-saas btn-saas-outline" style="height: 36px; font-weight: 800;">₡5.000</button>
<button type="button" onclick="setAdminRecargaPreset(10000)" class="btn-saas btn-saas-outline" style="height: 36px; font-weight: 800;">₡10.000</button>
</div>
<div style="margin-bottom: 16px;">
<label style="display: block; font-size: 0.78rem; font-weight: 700; color: var(--text-muted); margin-bottom: 4px;">
Detalle o Recibo (Opcional):
</label>
<input type="text" id="adminRecargaDescripcion" placeholder="Ej: Pago en efectivo en mostrador" style="width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border); font-size: 0.85rem; box-sizing: border-box; background: var(--card-bg); color: var(--text-main);">
</div>
<button type="button" id="btnAdminSubmitRecarga" onclick="submitAdminManualRecharge()" class="btn-saas btn-saas-primary" style="width: 100%; height: 44px; font-size: 0.95rem; font-weight: 800; border-radius: 10px;">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="20" height="14" x="2" y="5" rx="2"/><line x1="2" x2="22" y1="10" y2="10"/></svg>
<span>Aplicar Recarga Inmediata</span>
</button>
</div>
</div>
<!-- TAB 4: MOVIMIENTOS Y REVERSIONES -->
<div id="adminTabContentMovimientos" class="admin-card" style="display: none; max-width: 900px; margin: 0 auto;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 10px;">
<div>
<h3 style="margin: 0; font-size: 1.2rem; font-weight: 900; color: var(--text-main); display: flex; align-items: center; gap: 8px;">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2v4a2 2 0 0 0 2 2h4"/><path d="M16 22h2a2 2 0 0 0 2-2V7.5L14.5 2H6a2 2 0 0 0-2 2v3"/><path d="m3 12.5 3 3 6-6"/></svg>
<span>Movimientos & Reversiones</span>
</h3>
<p style="margin: 3px 0 0 0; font-size: 0.78rem; color: var(--text-muted);">
Historial de recargas de monedero y cobros de meriendas. Permite anular o revertir transacciones erróneas.
</p>
</div>
<button type="button" onclick="loadAdminMovimientos()" class="btn-saas btn-saas-outline" style="height: 32px;">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/><path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"/><path d="M8 16H3v5"/></svg>
<span>Actualizar</span>
</button>
</div>
<!-- BARRA DE FILTROS Y BÚSQUEDA -->
<div style="display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; justify-content: space-between;">
<div style="display: flex; gap: 4px; background: rgba(148, 163, 184, 0.12); padding: 4px; border-radius: 10px; overflow-x: auto; max-width: 100%;">
<button type="button" class="mov-filter-btn active" id="btnFilterMovAll" onclick="setMovFilter('all')" style="padding: 6px 12px; border: none; border-radius: 7px; font-weight: 800; font-size: 0.78rem; cursor: pointer; background: white; color: #0284c7; box-shadow: 0 1px 3px rgba(0,0,0,0.08); white-space: nowrap;">
Todos
</button>
<button type="button" class="mov-filter-btn" id="btnFilterMovRecargas" onclick="setMovFilter('recargas')" style="padding: 6px 12px; border: none; border-radius: 7px; font-weight: 700; font-size: 0.78rem; cursor: pointer; background: transparent; color: #64748b; white-space: nowrap;">
Recargas
</button>
<button type="button" class="mov-filter-btn" id="btnFilterMovCobros" onclick="setMovFilter('cobros')" style="padding: 6px 12px; border: none; border-radius: 7px; font-weight: 700; font-size: 0.78rem; cursor: pointer; background: transparent; color: #64748b; white-space: nowrap;">
Cobros
</button>
<button type="button" class="mov-filter-btn" id="btnFilterMovRechazados" onclick="setMovFilter('rechazados')" style="padding: 6px 12px; border: none; border-radius: 7px; font-weight: 700; font-size: 0.78rem; cursor: pointer; background: transparent; color: #64748b; white-space: nowrap;">
Rechazados
</button>
</div>
<input type="text" id="inputSearchMovimientos" placeholder="Buscar por alumno, carné o detalle..." oninput="filterMovimientosUI(this.value)" style="flex: 1; min-width: 180px; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border); font-size: 0.85rem; box-sizing: border-box; background: var(--card-bg); color: var(--text-main); outline: none;">
</div>
<!-- LISTA DE MOVIMIENTOS -->
<div id="adminMovimientosList" style="display: flex; flex-direction: column; gap: 10px;">
<div style="text-align: center; color: var(--text-muted); padding: 30px; font-size: 0.88rem;">
Cargando movimientos...
</div>
</div>
</div>
<!-- TAB 5: GESTIÓN DE PERSONAL Y CAJEROS -->
<div id="adminTabContentPersonal" class="admin-card" style="display: none; max-width: 900px; margin: 0 auto;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 10px;">
<div>
<h3 style="margin: 0; font-size: 1.2rem; font-weight: 900; color: var(--text-main); display: flex; align-items: center; gap: 8px;">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg>
<span>Control de Personal & Cajeros</span>
</h3>
<p style="margin: 3px 0 0 0; font-size: 0.78rem; color: var(--text-muted);">
Crea cajeros, vendedores y personal. Administra contraseñas, bloquea o elimina accesos.
</p>
</div>
<button type="button" onclick="openCreateStaffModal()" class="btn-saas btn-saas-primary" style="height: 36px; padding: 0 14px; font-size: 0.84rem;">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><line x1="19" x2="19" y1="8" y2="14"/><line x1="22" x2="16" y1="11" y2="11"/></svg>
<span>Nuevo Empleado / Cajero</span>
</button>
</div>
<div id="adminStaffList" style="display: flex; flex-direction: column; gap: 10px;">
<div style="text-align: center; color: var(--text-muted); padding: 30px; font-size: 0.88rem;">
Cargando personal...
</div>
</div>
</div>
</div>
<!-- ========================================== -->
<!-- PORTAL COMPLETO DE PADRES (#viewPadres) -->
<!-- ========================================== -->
<div id="viewPadres" class="parent-container" style="display: none;">
<!-- CABECERA DE PADRES -->
<header class="parent-header">
<div class="parent-badge">
<div class="parent-icon">
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg>
</div>
<div>
<h2 style="font-size: 1.15rem; font-weight: 900; margin: 0; color: var(--text-main);">Portal de Padres</h2>
<span id="parentLoggedName" style="font-size: 0.76rem; color: #10b981; font-weight: 700;">Familia SiboPay</span>
</div>
</div>
<div class="parent-header-actions">
<button onclick="toggleTheme()" class="theme-toggle-btn" title="Alternar Modo Oscuro / Modo Claro" style="display: inline-flex; align-items: center; justify-content: center;">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"/></svg>
</button>
<button type="button" onclick="switchToSodaMenuAsParent()" class="mode-btn" style="background: var(--bg-main); border: 1.5px solid var(--border); font-size: 0.78rem; font-weight: 800; border-radius: 10px; padding: 7px 11px; cursor: pointer; color: var(--text-main); display: inline-flex; align-items: center; gap: 6px;" title="Ver menú y pre-ordenar para mi hijo">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1-2.5-2.5Z"/></svg>
<span>Ver Menú</span>
</button>
<button onclick="logout(true)" class="logout-btn" title="Cerrar sesión" style="display: inline-flex; align-items: center; gap: 6px;">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/><polyline points="16 17 21 12 16 7"/><line x1="21" x2="9" y1="12" y2="12"/></svg>
<span class="logout-text">Salir</span>
</button>
</div>
</header>
<!-- BANNER SI NO HAY HIJOS VINCULADOS -->
<div id="parentNoChildrenBanner" class="parent-card" style="display: none; text-align: center; border: 2px dashed #0284c7; background: #f0f9ff;">
<div style="width: 52px; height: 52px; border-radius: 50%; background: #e0f2fe; color: #0284c7; display: flex; align-items: center; justify-content: center; margin: 0 auto 10px;">
<svg width="26" height="26" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/></svg>
</div>
<h3 style="font-size: 1.15rem; font-weight: 900; color: #0369a1; margin: 8px 0 4px 0;">¡Bienvenido a SiboPay!</h3>
<p style="font-size: 0.82rem; color: #64748b; margin-bottom: 14px;">
Aún no has vinculado ningún estudiante a tu cuenta de padre. Escanea el carné de tu hijo para monitorear su saldo y recargarle al instante.
</p>
<button type="button" onclick="openScanChildQrModal()" class="login-submit-btn" style="background: linear-gradient(135deg, #0284c7, #0369a1); display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: auto; padding: 12px 24px;">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="18" height="18" x="3" y="3" rx="2"/><path d="M7 7h.01"/><path d="M17 7h.01"/><path d="M7 17h.01"/><path d="M17 17h.01"/></svg>
<span>Escanear Carné QR de mi Hijo</span>
</button>
</div>
<!-- SECCIÓN: MIS HIJOS (TARJETAS VISUALES) -->
<div id="parentChildrenSection" style="margin-bottom: 16px;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;">
<h3 style="font-size: 0.92rem; font-weight: 900; color: var(--text-main); text-transform: uppercase; letter-spacing: 0.5px; display: inline-flex; align-items: center; gap: 6px;">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg>
<span>Mis Hijos</span>
</h3>
<button type="button" onclick="openScanChildQrModal()" style="background: none; border: none; color: #0284c7; font-size: 0.8rem; font-weight: 800; cursor: pointer; display: flex; align-items: center; gap: 4px;">
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 5v14"/><path d="M5 12h14"/></svg>
<span>Vincular otro hijo con QR</span>
</button>
</div>
<!-- Cuadrícula de tarjetas de hijos -->
<div id="parentChildrenGrid" class="parent-children-grid">
<!-- Renderizado dinámico de tarjetas de hijos -->
</div>
</div>
<!-- SECCIÓN DE GESTIÓN DEL HIJO SELECCIONADO -->
<div id="parentSelectedChildContainer" style="display: none;">
<!-- TARJETA ELEGANTE DE SALDO Y RESUMEN DEL HIJO (BARRA SUPERIOR) -->
<div class="parent-balance-card-refined" style="margin-bottom: 16px;">
<div class="parent-balance-header-row">
<div style="display: flex; align-items: center; gap: 10px; min-width: 0;">
<div id="parentActiveChildAvatar" class="parent-active-child-avatar-badge">ES</div>
<div style="min-width: 0;">
<span class="parent-balance-tag-title">Estudiante Seleccionado</span>
<div style="display: flex; align-items: center; gap: 6px; margin-top: 2px; flex-wrap: wrap;">
<span id="parentActiveChildName" class="parent-balance-child-pill">Cargando...</span>
<span id="parentActiveChildMeta" class="parent-balance-grade-pill">Grado • Carné</span>
<span id="parentActiveSchoolNameBadge" style="font-size: 0.72rem; color: #0284c7; font-weight: 800; background: #f0f9ff; padding: 2px 7px; border-radius: 6px;">Soda Central</span>
</div>
</div>
</div>
<div style="display: flex; align-items: center; gap: 8px;">
<button type="button" onclick="openParentSubView('preordenes')" class="btn-saas btn-saas-outline" style="font-size: 0.78rem; font-weight: 800; border-radius: 10px; padding: 7px 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 5px;">
<span>🥪 Ver Menú</span>
</button>
</div>
</div>
<div class="parent-balance-amount-display">
<span id="parentActiveChildBalance">₡0</span>
</div>
<div id="parentActiveChildRetenidoNote" style="display: none; font-size: 0.74rem; color: #b45309; background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; padding: 4px 10px; margin-top: 4px; font-weight: 700;"></div>
<div class="parent-balance-footer-row">
<div class="parent-balance-limit-info">
Límite Diario: <strong id="parentDailyLimitInlineDisplay" style="color: #0284c7;">₡3.000</strong>
</div>
<button type="button" onclick="openParentSubView('sinpe')" class="parent-balance-btn-recharge">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>
<span>Recargar Saldo con SINPE</span>
</button>
</div>
</div>
<!-- LAYOUT DIVIDIDO A IZQUIERDA Y DERECHA (ESTILO GMAIL) -->
<div class="parent-split-wrapper">
<!-- COLUMNA IZQUIERDA: MENÚ DE CAJITAS (SIDEBAR) -->
<aside class="parent-sidebar-boxes" id="parentSidebarBoxes">
<div class="parent-nav-box active" data-view="resumen" onclick="openParentSubView('resumen')">
<div class="parent-nav-box-icon">📊</div>
<div class="parent-nav-box-text">
<strong>Resumen General</strong>
<span>Saldo y estado del carné</span>
</div>
<span class="parent-nav-arrow">›</span>
</div>
<div class="parent-nav-box" data-view="preordenes" onclick="openParentSubView('preordenes')">
<div class="parent-nav-box-icon">🥪</div>
<div class="parent-nav-box-text">
<strong>Pre-ordenar / Ver Menú</strong>
<span>Catálogo y pedidos de merienda</span>
</div>
<span class="parent-nav-arrow">›</span>
</div>
<div class="parent-nav-box" data-view="alergias" onclick="openParentSubView('alergias')">
<div class="parent-nav-box-icon rose-halo">⚠️</div>
<div class="parent-nav-box-text">
<strong style="color: #e11d48;">Alertas y Salud</strong>
<span>Alergias y veto de golosinas</span>
</div>
<span class="parent-nav-arrow" style="color: #f43f5e;">›</span>
</div>
<div class="parent-nav-box" data-view="limites" onclick="openParentSubView('limites')">
<div class="parent-nav-box-icon">💳</div>
<div class="parent-nav-box-text">
<strong>Límite Diario de Gasto</strong>
<span>Control y transferencias</span>
</div>
<span class="parent-nav-arrow">›</span>
</div>
<div class="parent-nav-box" data-view="historial" onclick="openParentSubView('historial')">
<div class="parent-nav-box-icon">📜</div>
<div class="parent-nav-box-text">
<strong>Historial de Compras</strong>
<span>Consumos en la soda</span>
</div>
<span class="parent-nav-arrow">›</span>
</div>
<div class="parent-nav-box" data-view="credenciales" onclick="openParentSubView('credenciales')">
<div class="parent-nav-box-icon">🔒</div>
<div class="parent-nav-box-text">
<strong>Seguridad y PIN</strong>
<span>PIN escolar y contraseña</span>
</div>
<span class="parent-nav-arrow">›</span>
</div>
<div class="parent-nav-box" data-view="sinpe" onclick="openParentSubView('sinpe')">
<div class="parent-nav-box-icon green-halo">💸</div>
<div class="parent-nav-box-text">
<strong style="color: #166534;">Recargar con SINPE</strong>
<span>Validar recarga bancaria</span>
</div>
<span class="parent-nav-arrow" style="color: #16a34a;">›</span>
</div>
</aside>
<!-- COLUMNA DERECHA: ESCENARIO DE CONTENIDO ACTIVO -->
<main class="parent-content-stage" id="parentContentStage">
<!-- SUBVISTA 0: RESUMEN GENERAL DEL ESTUDIANTE -->
<div id="parentSubViewResumen" class="parent-subview">
<div class="parent-subview-header">
<button type="button" onclick="closeParentSubView()" class="parent-subview-back-btn">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="19" y1="12" x2="5" y2="12"/><polyline points="12 19 5 12 12 5"/></svg>
<span>Volver</span>
</button>
<div class="parent-subview-child-tag">
<span class="parentSubViewChildAvatarBadge">ES</span>
<span class="parentSubViewChildName">Estudiante</span>
</div>
</div>
<div class="parent-card" style="background: var(--card-bg, #ffffff); border: 1px solid var(--border, #e2e8f0); border-radius: 18px; padding: 22px; margin-bottom: 16px; box-shadow: 0 2px 8px rgba(0,0,0,0.03);">
<div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 10px;">
<div style="display: flex; align-items: center; gap: 12px;">
<div class="parent-refined-icon-box" style="width: 44px; height: 44px; background: rgba(2, 132, 199, 0.1); color: #0284c7; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.25rem;">
📊
</div>
<div>
<h3 style="font-size: 1.1rem; font-weight: 900; color: var(--text-main); margin: 0;">Panel Principal del Estudiante</h3>
<span style="font-size: 0.76rem; color: var(--text-muted);">Monitoreo escolar en tiempo real de <strong id="parentSummaryChildName" style="color: #0284c7;">su hijo</strong></span>
</div>
</div>
<div class="parent-subview-child-tag" style="margin: 0;">
<span class="parentSubViewChildAvatarBadge">ES</span>
<span class="parentSubViewChildName">Estudiante</span>
</div>
</div>
<!-- Grid de métricas rápidas del estudiante -->
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 18px;">
<div style="background: var(--bg-main, #f8fafc); border: 1px solid var(--border, #e2e8f0); border-radius: 14px; padding: 14px;">
<span style="font-size: 0.72rem; font-weight: 800; color: var(--text-muted); text-transform: uppercase;">Saldo Disponible</span>
<div id="parentSummaryBalanceDisplay" style="font-size: 1.6rem; font-weight: 900; color: #0284c7; margin-top: 4px;">₡0</div>
<span id="parentSummaryRetenidoSubtitle" style="font-size: 0.68rem; color: #10b981; font-weight: 700;">● Disponible para compras</span>
</div>
<div style="background: var(--bg-main, #f8fafc); border: 1px solid var(--border, #e2e8f0); border-radius: 14px; padding: 14px;">
<span style="font-size: 0.72rem; font-weight: 800; color: var(--text-muted); text-transform: uppercase;">Límite por Día</span>
<div id="parentSummaryLimitDisplay" style="font-size: 1.6rem; font-weight: 900; color: var(--text-main); margin-top: 4px;">₡3.000</div>
<span style="font-size: 0.68rem; color: var(--text-muted); font-weight: 700;">Tope de consumo diario</span>
</div>
<div style="background: var(--bg-main, #f8fafc); border: 1px solid var(--border, #e2e8f0); border-radius: 14px; padding: 14px;">
<span style="font-size: 0.72rem; font-weight: 800; color: var(--text-muted); text-transform: uppercase;">Salud & Veto</span>
<div id="parentSummaryAllergyStatus" style="font-size: 1.1rem; font-weight: 900; color: #10b981; margin-top: 8px;">Sin alertas</div>
<span style="font-size: 0.68rem; color: var(--text-muted); font-weight: 700;">Expediente activo en caja</span>
</div>
</div>
<!-- Atajos Rápidos -->
<h4 style="font-size: 0.85rem; font-weight: 900; color: var(--text-main); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px;">Acciones Rápidas</h4>
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px;">
<button type="button" onclick="openParentSubView('preordenes')" class="btn-saas btn-saas-outline" style="padding: 12px 14px; border-radius: 12px; display: flex; align-items: center; gap: 10px; justify-content: flex-start; text-align: left;">
<span style="font-size: 1.3rem;">🥪</span>
<div>
<strong style="display: block; font-size: 0.84rem; color: var(--text-main);">Pre-ordenar Merienda</strong>
<span style="font-size: 0.7rem; color: var(--text-muted);">Ver platillos de la soda</span>
</div>
</button>
<button type="button" onclick="openParentSubView('sinpe')" class="btn-saas btn-saas-outline" style="padding: 12px 14px; border-radius: 12px; display: flex; align-items: center; gap: 10px; justify-content: flex-start; text-align: left; border-color: #86efac; background: #f0fdf4;">
<span style="font-size: 1.3rem;">💸</span>
<div>
<strong style="display: block; font-size: 0.84rem; color: #166534;">Recargar por SINPE</strong>
<span style="font-size: 0.7rem; color: #15803d;">Acreditar saldo al instante</span>
</div>
</button>
<button type="button" onclick="openParentSubView('historial')" class="btn-saas btn-saas-outline" style="padding: 12px 14px; border-radius: 12px; display: flex; align-items: center; gap: 10px; justify-content: flex-start; text-align: left;">
<span style="font-size: 1.3rem;">📜</span>
<div>
<strong style="display: block; font-size: 0.84rem; color: var(--text-main);">Ver Compras Recientes</strong>
<span style="font-size: 0.7rem; color: var(--text-muted);">Auditar consumos en caja</span>
</div>
</button>
</div>
</div>
</div>
<!-- SUBVISTA: PRE-ORDENAR MERIENDA Y VER CATÁLOGO -->
<div id="parentSubViewMenu" class="parent-subview" style="display: none;">
<div class="parent-subview-header">
<button type="button" onclick="closeParentSubView()" class="parent-subview-back-btn">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="19" y1="12" x2="5" y2="12"/><polyline points="12 19 5 12 12 5"/></svg>
<span>Volver</span>
</button>
<div class="parent-subview-child-tag">
<span class="parentSubViewChildAvatarBadge">ES</span>
<span class="parentSubViewChildName">Estudiante</span>
</div>
</div>
<div class="parent-card" style="background: var(--card-bg, #ffffff); border: 1px solid var(--border, #e2e8f0); border-radius: 18px; padding: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.03);">
<div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 8px;">
<div>
<h3 style="font-size: 1.1rem; font-weight: 900; color: var(--text-main); margin: 0; display: flex; align-items: center; gap: 8px;">
<span>🥪 Menú de la Soda y Pre-órdenes</span>
</h3>
<span style="font-size: 0.76rem; color: var(--text-muted);">Selecciona los alimentos para la merienda escolar de tu hijo</span>
</div>
<button type="button" onclick="openCartModal()" class="btn-saas btn-saas-primary" style="padding: 8px 16px; border-radius: 10px; font-size: 0.82rem; display: inline-flex; align-items: center; gap: 6px;">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2"><path d="M6 2L3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4z"/><line x1="3" y1="6" x2="21" y2="6"/><path d="M16 10a4 4 0 0 1-8 0"/></svg>
<span>Ver Mi Orden</span>
<span id="parentCartBadgeCount" style="background: #ffffff; color: #0284c7; padding: 1px 7px; border-radius: 10px; font-weight: 900; font-size: 0.72rem; margin-left: 2px;">0</span>
</button>
</div>
<!-- Buscador inteligente en catálogo de padres -->
<div style="margin-bottom: 14px;">
<div style="position: relative;">
<input type="text" id="parentCatalogSearch" placeholder="Buscar platillo, fresco, snack o precio (<1000)..." oninput="filterParentCatalog(this.value)" style="width: 100%; box-sizing: border-box; padding: 11px 12px 11px 36px; border-radius: 12px; border: 1.5px solid var(--border, #cbd5e1); font-size: 0.88rem; font-weight: 600; outline: none; background: var(--bg-main, #f8fafc); color: var(--text-main);">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#94a3b8" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="position: absolute; left: 11px; top: 50%; transform: translateY(-50%); pointer-events: none;">
<circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/>
</svg>
</div>
<div style="display: flex; gap: 6px; overflow-x: auto; padding-top: 8px; scrollbar-width: none;">
<button type="button" class="search-chip" onclick="quickFilterParentCatalog('fresco')">🥤 Frescos</button>
<button type="button" class="search-chip" onclick="quickFilterParentCatalog('almuerzo')">🍛 Almuerzos</button>
<button type="button" class="search-chip" onclick="quickFilterParentCatalog('saludable')">🥗 Saludables</button>
<button type="button" class="search-chip" onclick="quickFilterParentCatalog('<1000')">💰 < ₡1.000</button>
<button type="button" class="search-chip" onclick="quickFilterParentCatalog('')">✨ Todos</button>
</div>
</div>
<!-- Grid de productos en portal de padres -->
<div id="parentProductsGrid" class="parent-products-grid" style="display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px;">
<!-- Se llena dinámicamente con renderParentCatalog() -->
</div>
</div>
</div>
<!-- 1. SUB-PANTALLA: RECARGA SINPE MÓVIL -->
<div id="parentSubViewSinpe" class="parent-subview" style="display: none;">
<div class="parent-subview-header">
<button type="button" onclick="closeParentSubView()" class="parent-subview-back-btn">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="19" y1="12" x2="5" y2="12"/><polyline points="12 19 5 12 12 5"/></svg>
<span>Volver</span>
</button>
<div class="parent-subview-child-tag">
<span class="parentSubViewChildAvatarBadge">ES</span>
<span class="parentSubViewChildName">Estudiante</span>
</div>
</div>
<div class="parent-sinpe-desktop-grid">
<!-- Columna 1: Formulario de Recarga SINPE -->
<div class="parent-card parent-sinpe-form-card" style="background: #f0fdf4; border: 1.5px solid #86efac; margin-bottom: 0;">
<div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px;">
<div style="display: flex; align-items: center; gap: 10px;">
<div style="width: 36px; height: 36px; border-radius: 10px; background: #dcfce7; color: #166534; display: flex; align-items: center; justify-content: center; flex-shrink: 0;">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="14" height="20" x="5" y="2" rx="2" ry="2"/><line x1="12" x2="12.01" y1="18" y2="18"/></svg>
</div>
<div>
<strong style="color: #166534; font-size: 1rem; display: block;">Recarga por SINPE Móvil</strong>
<p style="font-size: 0.74rem; color: #15803d; margin: 0;">
<span id="parentSinpeEscuelaNombre" style="font-weight: 800;">Soda Escolar</span> · Tel: <strong id="parentSinpeNumero">8888-8888</strong>
</p>
<p style="font-size: 0.70rem; color: #166534; margin: 2px 0 0 0;">
Titular: <span id="parentSinpeTitular" style="font-weight: 700;">Soda Central</span>
</p>
</div>
</div>
<span style="font-size: 0.7rem; color: #166534; background: #dcfce7; font-weight: 800; padding: 3px 8px; border-radius: 6px;">Inmediato</span>
</div>
<!-- 1. Monto a Recargar -->
<div style="margin-bottom: 12px;">
<label for="inputParentSinpeMonto" style="display: block; font-size: 0.80rem; font-weight: 800; color: #166534; margin-bottom: 4px;">
1. Monto a recargar (₡):
</label>
<div style="position: relative;">
<span style="position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-weight: 900; color: #166534; font-size: 1.1rem;">₡</span>
<input type="tel" inputmode="numeric" pattern="[0-9]*" id="inputParentSinpeMonto" placeholder="Ej: 3000" style="width: 100%; padding: 10px 12px 10px 30px; border-radius: 10px; border: 1.8px solid #86efac; font-size: 1.1rem; font-weight: 800; color: #166534; background: white; box-sizing: border-box; outline: none;">
</div>
<!-- Montos sugeridos rápidos -->
<div style="display: flex; gap: 6px; margin-top: 7px; flex-wrap: wrap;">
<button type="button" onclick="setParentSinpeMonto(1000)" style="background: white; border: 1px solid #86efac; color: #166534; font-size: 0.74rem; font-weight: 700; padding: 4px 9px; border-radius: 8px; cursor: pointer;">₡1.000</button>
<button type="button" onclick="setParentSinpeMonto(2000)" style="background: white; border: 1px solid #86efac; color: #166534; font-size: 0.74rem; font-weight: 700; padding: 4px 9px; border-radius: 8px; cursor: pointer;">₡2.000</button>
<button type="button" onclick="setParentSinpeMonto(3000)" style="background: white; border: 1px solid #86efac; color: #166534; font-size: 0.74rem; font-weight: 700; padding: 4px 9px; border-radius: 8px; cursor: pointer;">₡3.000</button>
<button type="button" onclick="setParentSinpeMonto(5000)" style="background: white; border: 1px solid #86efac; color: #166534; font-size: 0.74rem; font-weight: 700; padding: 4px 9px; border-radius: 8px; cursor: pointer;">₡5.000</button>
<button type="button" onclick="setParentSinpeMonto(10000)" style="background: white; border: 1px solid #86efac; color: #166534; font-size: 0.74rem; font-weight: 700; padding: 4px 9px; border-radius: 8px; cursor: pointer;">₡10.000</button>
</div>
</div>
<!-- 2. Caja de Código de Detalle Obligatorio -->
<div style="background: #ffffff; border: 2px dashed #16a34a; border-radius: 12px; padding: 12px; margin-bottom: 12px; text-align: center; box-shadow: 0 2px 6px rgba(22, 163, 74, 0.06);">
<div style="font-size: 0.74rem; font-weight: 800; color: #15803d; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 3px;">
2. Código Obligatorio en el Detalle
</div>
<p style="font-size: 0.72rem; color: #475569; margin: 0 0 8px 0; line-height: 1.3;">
En la app de tu banco, coloca este código en el campo <strong>"Detalle"</strong> o <strong>"Motivo"</strong>:
</p>
<div style="display: flex; align-items: center; justify-content: center; gap: 8px; background: #f0fdf4; border: 1.5px solid #86efac; border-radius: 10px; padding: 8px 12px; margin-bottom: 6px;">
<span id="parentSinpeCodigoDisplay" style="font-family: 'Courier New', Courier, monospace; font-size: 1.45rem; font-weight: 900; color: #166534; letter-spacing: 1.5px; user-select: all;">SIBO-CARGANDO</span>
<button type="button" id="btnCopiarCodigoSinpe" onclick="copiarCodigoSinpe()" style="background: #16a34a; color: white; border: none; padding: 7px 12px; border-radius: 8px; font-weight: 800; font-size: 0.80rem; cursor: pointer; display: flex; align-items: center; gap: 4px; box-shadow: 0 2px 5px rgba(22, 163, 74, 0.25);">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>
<span id="lblCopiarCodigoSinpe">Copiar código</span>
</button>
</div>
<div style="display: flex; justify-content: space-between; align-items: center; font-size: 0.68rem; color: #64748b; padding: 0 2px;">
<span>Válido pegado, con guión o minúsculas.</span>
<button type="button" onclick="obtenerNuevoCodigoSinpe()" style="background: none; border: none; color: #0284c7; font-weight: 700; cursor: pointer; text-decoration: underline; font-size: 0.68rem; padding: 0;">
🔄 Cambiar código
</button>
</div>
</div>
<!-- 3. Comprobante Opcional -->
<div style="margin-bottom: 12px;">
<label for="inputParentSinpeComprobante" style="display: block; font-size: 0.76rem; font-weight: 800; color: #166534; margin-bottom: 3px;">
3. N° de Comprobante bancario <span style="font-size: 0.68rem; font-weight: 600; color: #64748b;">(Opcional)</span>:
</label>
<input type="text" id="inputParentSinpeComprobante" placeholder="Ej: 894321 (Opcional si pusiste el código en el detalle)" style="width: 100%; padding: 9px 11px; border-radius: 10px; border: 1.5px solid #86efac; font-size: 0.95rem; font-weight: 700; color: #166534; background: white; box-sizing: border-box;">
</div>
<!-- Botón de Validar SINPE -->
<button type="button" id="btnParentValidarSinpe" onclick="executeParentSinpeRecharge()" style="width: 100%; padding: 13px; background: linear-gradient(135deg, #16a34a, #15803d); color: white; border: none; border-radius: 12px; font-weight: 900; font-size: 0.98rem; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; box-shadow: 0 4px 10px rgba(22, 163, 74, 0.3);">
<svg width="17" height="17" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.3" stroke-linecap="round" stroke-linejoin="round"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/><polyline points="22 4 12 14.01 9 11.01"/></svg>
<span id="btnParentValidarSinpeText">Validar SINPE</span>
</button>
<!-- Enlace a Términos y Condiciones SINPE -->
<div style="text-align: center; margin-top: 10px; font-size: 0.72rem; color: #64748b; line-height: 1.45;">
<span>Al hacer pagos por SINPE acepta los </span>
<button type="button" onclick="openModalSinpeTerms()" style="background: none; border: none; padding: 0; color: #0284c7; font-weight: 800; font-size: 0.72rem; cursor: pointer; text-decoration: underline; display: inline;">
términos de pago con SINPE móvil
</button>
</div>
<!-- Banner de estado dinámico -->
<div id="parentSinpeStatusMsg" style="display: none; margin-top: 10px; padding: 10px 12px; border-radius: 10px; font-size: 0.80rem; line-height: 1.4;"></div>
<!-- LISTA DE SOLICITUDES SINPE PENDIENTES DEL HIJO -->
<div id="parentSinpePendingBox" style="margin-top: 14px; border-top: 1px dashed #86efac; padding-top: 10px; display: none;">
<div style="font-size: 0.76rem; font-weight: 800; color: #166534; margin-bottom: 6px;">Estado de Recargas Recientes:</div>
<div id="parentSinpePendingList" style="display: flex; flex-direction: column; gap: 6px;"></div>
</div>
</div>
<!-- Columna 2: Términos, Condiciones y Guía de Seguridad SINPE -->
<div class="parent-card parent-sinpe-terms-card" style="background: #ffffff; border: 1.5px solid var(--border, #cbd5e1); border-radius: 18px; padding: 22px; box-shadow: 0 2px 8px rgba(0,0,0,0.03); margin-bottom: 0;">
<!-- Encabezado de la Guía -->
<div style="display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border, #f1f5f9); padding-bottom: 12px; margin-bottom: 14px;">
<div style="display: flex; align-items: center; gap: 10px;">
<div style="width: 36px; height: 36px; border-radius: 10px; background: #e0f2fe; color: #0284c7; display: flex; align-items: center; justify-content: center; font-size: 1.15rem; flex-shrink: 0;">
🛡️
</div>
<div>
<strong style="color: var(--text-main, #0f172a); font-size: 0.96rem; display: block;">Términos y Guía SINPE Móvil</strong>
<span style="font-size: 0.73rem; color: var(--text-muted, #64748b);">Reglas para acreditación automática</span>
</div>
</div>
<span style="font-size: 0.68rem; font-weight: 800; background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; padding: 3px 8px; border-radius: 6px;">
Oficial
</span>
</div>
<!-- Alerta Dorada: Coincidencia Exacta -->
<div style="background: #fffbeb; border: 1.5px solid #fde68a; border-radius: 12px; padding: 12px; margin-bottom: 14px;">
<div style="display: flex; align-items: flex-start; gap: 8px;">
<span style="font-size: 1.15rem; line-height: 1;">⚠️</span>
<div style="font-size: 0.77rem; color: #92400e; line-height: 1.45;">
<strong style="display: block; font-size: 0.82rem; margin-bottom: 2px;">Atención a dos datos obligatorios:</strong>
El <strong>monto</strong> y el <strong>código SIBO</strong> deben coincidir con total precisión para que el sistema de la soda apruebe el saldo en segundos.
</div>
</div>
</div>
<!-- Lista de Términos Numerados -->
<div style="display: flex; flex-direction: column; gap: 13px; font-size: 0.78rem; color: var(--text-main, #334155); line-height: 1.45;">
<!-- 1. Monto Exacto -->
<div style="display: flex; gap: 10px; align-items: flex-start;">
<div style="width: 22px; height: 22px; border-radius: 50%; background: #dcfce7; color: #166534; font-weight: 900; font-size: 0.72rem; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px;">
1
</div>
<div>
<strong style="color: var(--text-main, #0f172a); display: block; font-size: 0.82rem;">Monto idéntico al transferido:</strong>
<span>El monto elegido en esta pantalla debe ser <strong>exactamente igual</strong> al transferido desde su banco (ej: si transfirió ₡3.000, digite ₡3.000). Diferencias en el importe impiden la conciliación automática.</span>
</div>
</div>
<!-- 2. Código Obligatorio -->
<div style="display: flex; gap: 10px; align-items: flex-start;">
<div style="width: 22px; height: 22px; border-radius: 50%; background: #dcfce7; color: #166534; font-weight: 900; font-size: 0.72rem; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px;">
2
</div>
<div>
<strong style="color: var(--text-main, #0f172a); display: block; font-size: 0.82rem;">Copiar y pegar el código en el Detalle:</strong>
<span>Es <strong>estrictamente obligatorio</strong> colocar el código que empieza con <code style="background: rgba(2, 132, 199, 0.08); color: #0284c7; padding: 1px 6px; border-radius: 4px; font-weight: 800; font-family: monospace;">SIBO-XXXXXX</code> en la casilla de <em>Detalle</em>, <em>Motivo</em> o <em>Concepto</em> del SINPE Móvil bancario.</span>
</div>
</div>
<!-- 3. Destinatario Oficial -->
<div style="display: flex; gap: 10px; align-items: flex-start;">
<div style="width: 22px; height: 22px; border-radius: 50%; background: #dcfce7; color: #166534; font-weight: 900; font-size: 0.72rem; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px;">
3
</div>
<div>
<strong style="color: var(--text-main, #0f172a); display: block; font-size: 0.82rem;">Verificación del Destinatario:</strong>
<span>Transfiera únicamente al número telefónico y titular oficial registrados de la soda escolar. SiboPay nunca le solicitará fondos a cuentas particulares.</span>
</div>
</div>
<!-- 4. Comprobante de Respaldo -->
<div style="display: flex; gap: 10px; align-items: flex-start;">
<div style="width: 22px; height: 22px; border-radius: 50%; background: #dcfce7; color: #166534; font-weight: 900; font-size: 0.72rem; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px;">
4
</div>
<div>
<strong style="color: var(--text-main, #0f172a); display: block; font-size: 0.82rem;">Comprobante de Respaldo:</strong>
<span>Conserve la captura o número de comprobante emitido por su banco. En caso de requerir aclaración, este servirá como comprobante ante la administración de la soda.</span>
</div>
</div>
<!-- 5. Disponibilidad del Saldo -->
<div style="display: flex; gap: 10px; align-items: flex-start;">
<div style="width: 22px; height: 22px; border-radius: 50%; background: #dcfce7; color: #166534; font-weight: 900; font-size: 0.72rem; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px;">
5
</div>
<div>
<strong style="color: var(--text-main, #0f172a); display: block; font-size: 0.82rem;">Disponibilidad Inmediata:</strong>
<span>Una vez validado el pago, los fondos quedan disponibles de inmediato para compras con carné QR o pre-órdenes. El saldo no vence durante el curso lectivo.</span>
</div>
</div>
<!-- 6. No Canjeable por Efectivo -->
<div style="display: flex; gap: 10px; align-items: flex-start;">
<div style="width: 22px; height: 22px; border-radius: 50%; background: #fee2e2; color: #991b1b; font-weight: 900; font-size: 0.72rem; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px;">
6
</div>
<div>
<strong style="color: #991b1b; display: block; font-size: 0.82rem;">No Canjeable por Dinero Real o Efectivo:</strong>
<span>Los fondos recargados corresponden a créditos escolares exclusivos para consumo de alimentos en la soda. <strong>No pueden ser convertidos ni devueltos en dinero en efectivo</strong> bajo ninguna circunstancia.</span>
</div>
</div>
</div>
<!-- Pie de Seguridad -->
<div style="margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border, #f1f5f9); display: flex; align-items: center; justify-content: space-between; font-size: 0.72rem; color: var(--text-muted, #64748b);">
<span style="display: flex; align-items: center; gap: 6px;">
<span style="width: 7px; height: 7px; border-radius: 50%; background: #10b981; display: inline-block;"></span>
<span>Conciliación automática activa 24/7</span>
</span>
<span style="font-weight: 800; color: #0284c7;">SiboPay Protegido</span>
</div>
</div>
</div>
</div>
<!-- 2. SUB-PANTALLA: ALERGIAS Y SALUD -->
<div id="parentSubViewAlergias" class="parent-subview" style="display: none;">
<div class="parent-subview-header">
<button type="button" onclick="closeParentSubView()" class="parent-subview-back-btn">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="19" y1="12" x2="5" y2="12"/><polyline points="12 19 5 12 12 5"/></svg>
<span>Volver</span>
</button>
<div class="parent-subview-child-tag">
<span class="parentSubViewChildAvatarBadge">ES</span>
<span class="parentSubViewChildName">Estudiante</span>
</div>
</div>
<div id="parentAllergiesCard" class="parent-card" style="background: #ffffff; border: 1.5px solid #fecdd3; border-radius: 20px; box-shadow: 0 4px 14px rgba(225, 29, 72, 0.05);">
<div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px;">
<div style="display: flex; align-items: center; gap: 10px;">
<div class="parent-refined-icon-box rose-halo" style="width: 36px; height: 36px;">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>
</div>
<div>
<strong style="color: #9f1239; font-size: 0.95rem; display: block;">Alergias y Restricciones</strong>
<span style="font-size: 0.72rem; color: #e11d48; font-weight: 600;">Expediente de salud y veto de golosinas</span>
</div>
</div>
<span id="parentAllergiesStatusBadge" style="font-size: 0.7rem; color: #e11d48; background: #ffe4e6; font-weight: 800; padding: 3px 8px; border-radius: 6px;">Sin alergias</span>
</div>
<!-- Alergias clínicas -->
<div style="margin-bottom: 14px; background: #fff1f2; border: 1px solid #fecdd3; padding: 12px; border-radius: 14px;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px;">
<label style="font-size: 0.76rem; font-weight: 800; color: #9f1239; display: block;">Alergias o Intolerancias Médicas:</label>
<span style="font-size: 0.68rem; color: #e11d48; font-weight: 700;">Visible en caja de soda</span>
</div>
<input type="text" id="inputParentStudentAllergies" placeholder="Ej: Maní, Gluten, Lactosa, Mariscos..." style="width: 100%; padding: 9px 12px; border-radius: 10px; border: 1.5px solid #fca5a5; font-size: 0.85rem; font-weight: 700; color: #881337; background: #ffffff; box-sizing: border-box;">
<div style="display: flex; gap: 5px; margin-top: 8px; flex-wrap: wrap;">
<button type="button" onclick="addParentAllergyTag('Maní')" class="allergy-tag-pill">+ Maní</button>
<button type="button" onclick="addParentAllergyTag('Gluten')" class="allergy-tag-pill">+ Gluten</button>
<button type="button" onclick="addParentAllergyTag('Lactosa')" class="allergy-tag-pill">+ Lactosa</button>
<button type="button" onclick="addParentAllergyTag('Mariscos')" class="allergy-tag-pill">+ Mariscos</button>
<button type="button" onclick="addParentAllergyTag('Huevo')" class="allergy-tag-pill">+ Huevo</button>
<button type="button" onclick="clearParentAllergies()" class="allergy-tag-pill" style="color: #64748b; background: white; border-color: #cbd5e1;">Ninguna</button>
</div>
</div>
<!-- Toggle Veto de Chucherías / Comida no saludable -->
<div style="display: flex; justify-content: space-between; align-items: center; background: #f8fafc; border: 1px solid #e2e8f0; padding: 12px; border-radius: 14px; margin-bottom: 12px;">
<div>
<strong style="font-size: 0.84rem; color: #1e293b; display: block;">Veto de Comida Chatarra / Golosinas</strong>
<span style="font-size: 0.70rem; color: #64748b; display: block; margin-top: 2px;">Bloquea confites, gaseosas y comida chatarra en caja</span>
</div>
<label class="switch-saas" title="Bloquear comida chatarra">
<input type="checkbox" id="chkParentBlockJunkFood" onchange="onToggleParentBlockJunkFood(this.checked)">
<span class="switch-saas-slider rose"></span>
</label>
</div>
<!-- Botón Guardar Alergias -->
<button type="button" onclick="saveParentAllergiesSettings()" style="width: 100%; padding: 11px; background: linear-gradient(135deg, #e11d48, #be123c); color: white; border: none; border-radius: 12px; font-weight: 800; font-size: 0.86rem; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; box-shadow: 0 3px 8px rgba(225, 29, 72, 0.25);">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"/><polyline points="17 21 17 13 7 13 7 21"/><polyline points="7 3 7 8 15 8"/></svg>
<span>Guardar Configuración de Salud</span>
</button>
</div>
</div>
<!-- 3. SUB-PANTALLA: LÍMITE DIARIO Y TRANSFERENCIAS -->
<div id="parentSubViewLimites" class="parent-subview" style="display: none;">
<div class="parent-subview-header">
<button type="button" onclick="closeParentSubView()" class="parent-subview-back-btn">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="19" y1="12" x2="5" y2="12"/><polyline points="12 19 5 12 12 5"/></svg>
<span>Volver</span>
</button>
<div class="parent-subview-child-tag">
<span class="parentSubViewChildAvatarBadge">ES</span>
<span class="parentSubViewChildName">Estudiante</span>
</div>
</div>
<!-- TARJETA ÚNICA DE LÍMITE DIARIO Y TRANSFERENCIAS (COMPACTA, ESTÉTICA Y FINTECH) -->
<div id="parentDailyLimitCard" class="parent-card" style="background: var(--card-bg, #ffffff); border: 1.5px solid #bae6fd; box-shadow: 0 4px 16px rgba(2, 132, 199, 0.06); padding: 22px; border-radius: 18px; margin-bottom: 14px;">
<!-- Cabecera con Icono y Badge -->
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 8px;">
<div style="display: flex; align-items: center; gap: 10px;">
<div style="width: 40px; height: 40px; border-radius: 11px; background: #e0f2fe; color: #0284c7; display: flex; align-items: center; justify-content: center; font-size: 1.15rem; flex-shrink: 0;">
🛡️
</div>
<div>
<strong style="font-size: 0.98rem; color: var(--text-main); display: block; line-height: 1.2;">Límite de Gasto Diario</strong>
<span style="font-size: 0.74rem; color: var(--text-muted); display: block; margin-top: 2px;">Tope de consumo por jornada escolar</span>
</div>
</div>
<div style="text-align: right;">
<span id="lblParentDailyLimitDisplay" style="font-size: 1.15rem; color: #0284c7; font-weight: 900; background: #f0f9ff; border: 1.5px solid #bae6fd; padding: 5px 14px; border-radius: 10px; display: inline-block; letter-spacing: -0.3px;">₡3.000 / día</span>
</div>
</div>
<!-- Selector de Montos Rápidos (Pills) -->
<div style="margin-bottom: 14px;">
<span style="display: block; font-size: 0.72rem; font-weight: 800; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px;">Montos sugeridos:</span>
<div style="display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;">
<button type="button" onclick="setParentLimitPreset(1500)" class="limit-preset-pill">₡1.500</button>
<button type="button" onclick="setParentLimitPreset(2500)" class="limit-preset-pill">₡2.500</button>
<button type="button" onclick="setParentLimitPreset(3500)" class="limit-preset-pill">₡3.500</button>
<button type="button" onclick="setParentLimitPreset(5000)" class="limit-preset-pill">₡5.000</button>
</div>
</div>
<!-- Barra Deslizadora Compacta y Estilizada -->
<div style="background: var(--bg-main, #f8fafc); border: 1px solid var(--border, #e2e8f0); border-radius: 12px; padding: 12px 14px; margin-bottom: 16px;">
<div style="display: flex; justify-content: space-between; align-items: center; font-size: 0.72rem; font-weight: 800; color: var(--text-muted);">
<span>Ajuste rápido:</span>
<span style="color: #0284c7; font-weight: 900;">Arrastra la barra</span>
</div>
<input type="range" id="rangeParentLimit" class="saas-range-slider" min="1000" max="10000" step="500" value="3000" oninput="onParentLimitSliderChange(this.value)">
<div style="display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--text-muted); font-weight: 700;">
<span>₡1.000 min</span>
<span>₡5.000</span>
<span>₡10.000 max</span>
</div>
</div>
<!-- Input Manual y Botón Guardar en Fila Compacta -->
<div style="display: flex; gap: 8px; align-items: center; margin-bottom: 18px;">
<div style="position: relative; flex: 1;">
<span style="position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-weight: 900; color: #0284c7; font-size: 1.05rem;">₡</span>
<input type="tel" inputmode="numeric" pattern="[0-9]*" id="inputParentCustomLimit" placeholder="Ej: 3000" oninput="onParentLimitInputChange(this.value)" style="width: 100%; height: 42px; padding: 0 12px 0 32px; border-radius: 10px; border: 1.5px solid var(--border, #cbd5e1); font-size: 1.05rem; font-weight: 900; color: var(--text-main); background: var(--card-bg, #ffffff); box-sizing: border-box; outline: none;">
</div>
<button type="button" onclick="saveParentCustomLimit()" class="btn-saas btn-saas-primary" style="height: 42px; padding: 0 20px; font-size: 0.85rem; font-weight: 800; border-radius: 10px; white-space: nowrap; flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px;">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><polyline points="20 6 9 17 4 12"/></svg>
<span>Guardar Límite</span>
</button>
</div>
<!-- Divisor Separador Elegante -->
<div style="border-top: 1px solid var(--border, #e2e8f0); margin: 18px 0 16px 0;"></div>
<!-- REGLA DE PERMISOS: TRANSFERENCIAS ENTRE COMPAÑEROS CON SWITCH TIPO IOS -->
<div style="display: flex; justify-content: space-between; align-items: center; gap: 14px;">
<div style="display: flex; align-items: center; gap: 10px; min-width: 0;">
<div style="width: 36px; height: 36px; border-radius: 10px; background: rgba(2, 132, 199, 0.08); color: #0284c7; display: flex; align-items: center; justify-content: center; font-size: 1.05rem; flex-shrink: 0;">
🔄
</div>
<div>
<strong style="font-size: 0.88rem; color: var(--text-main); display: block; line-height: 1.25;">Transferencias entre Compañeros</strong>
<span style="font-size: 0.72rem; color: var(--text-muted); display: block; margin-top: 2px;">Permitir transferir saldo a compañeros de clase</span>
</div>
</div>
<label class="switch-saas" title="Activar o desactivar transferencias">
<input type="checkbox" id="chkParentAllowTransferDirect" onchange="onToggleParentTransfer(this.checked)" checked>
<span class="switch-saas-slider"></span>
</label>
</div>
</div>
</div>
<!-- 4. SUB-PANTALLA: HISTORIAL DE COMPRAS -->
<div id="parentSubViewHistorial" class="parent-subview" style="display: none;">
<div class="parent-subview-header">
<button type="button" onclick="closeParentSubView()" class="parent-subview-back-btn">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="19" y1="12" x2="5" y2="12"/><polyline points="12 19 5 12 12 5"/></svg>
<span>Volver</span>
</button>
<div class="parent-subview-child-tag">
<span class="parentSubViewChildAvatarBadge">ES</span>
<span class="parentSubViewChildName">Estudiante</span>
</div>
</div>
<div id="parentHistoryCard" class="parent-card">
<h4 style="font-size: 0.95rem; font-weight: 900; color: var(--text-main); margin-bottom: 12px; display: flex; align-items: center; gap: 8px;">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/><line x1="16" x2="8" y1="13" y2="13"/><line x1="16" x2="8" y1="17" y2="17"/></svg>
<span>Historial Detallado de Compras</span>
</h4>
<div id="parentStudentHistoryList" style="font-size: 0.85rem; color: var(--text-muted);">
Sin compras recientes registradas.
</div>
</div>
</div>
<!-- 5. SUB-PANTALLA: SEGURIDAD Y CREDENCIALES -->
<div id="parentSubViewCredenciales" class="parent-subview" style="display: none;">
<div class="parent-subview-header">
<button type="button" onclick="closeParentSubView()" class="parent-subview-back-btn">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="19" y1="12" x2="5" y2="12"/><polyline points="12 19 5 12 12 5"/></svg>
<span>Volver</span>
</button>
<div class="parent-subview-child-tag">
<span class="parentSubViewChildAvatarBadge">ES</span>
<span class="parentSubViewChildName">Estudiante</span>
</div>
</div>
<div class="parent-card" style="border: 1.5px solid var(--border);">
<div style="display: flex; align-items: center; gap: 10px; margin-bottom: 14px;">
<div style="width: 38px; height: 38px; border-radius: 10px; background: rgba(51, 65, 85, 0.1); color: #334155; display: flex; align-items: center; justify-content: center; flex-shrink: 0;">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="18" height="11" x="3" y="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/></svg>
</div>
<div>
<strong style="font-size: 0.95rem; color: var(--text-main); display: block;">Credenciales de Acceso Escolar</strong>
<span style="font-size: 0.74rem; color: var(--text-muted);">Restablece el PIN de 4 dígitos o contraseña de tu hijo</span>
</div>
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px;">
<div>
<label style="display: block; font-size: 0.76rem; font-weight: 800; color: var(--text-muted); margin-bottom: 4px;">Nuevo PIN (4 dígitos):</label>
<input type="password" inputmode="numeric" maxlength="4" id="inputParentStudentPin" placeholder="1234" style="width: 100%; padding: 11px; border-radius: 10px; border: 1.5px solid var(--border); font-weight: 900; letter-spacing: 3px; text-align: center; box-sizing: border-box; background: var(--card-bg); color: var(--text-main); font-size: 1.05rem;">
</div>
<div>
<label style="display: block; font-size: 0.76rem; font-weight: 800; color: var(--text-muted); margin-bottom: 4px;">Nueva Contraseña:</label>
<input type="text" id="inputParentStudentPass" placeholder="Ej: 1234" style="width: 100%; padding: 11px; border-radius: 10px; border: 1.5px solid var(--border); font-weight: 800; box-sizing: border-box; background: var(--card-bg); color: var(--text-main); font-size: 0.95rem;">
</div>
</div>
<button type="button" onclick="saveParentStudentCredentials()" style="width: 100%; padding: 12px; background: #334155; color: white; border: none; border-radius: 10px; font-weight: 800; font-size: 0.88rem; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="20 6 9 17 4 12"/></svg>
<span>Guardar Nuevas Credenciales</span>
</button>
</div>
</main>
</div>
</div>
</div>
<div class="app-container" id="appContainer" style="display: none;">
<!-- BANNER DE TARJETA SUSPENDIDA / BLOQUEADA -->
<div id="bannerCardBlocked" class="banner-card-blocked" style="display: none;">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="#ef4444" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="4.93" x2="19.07" y1="4.93" y2="19.07"/></svg>
<span><strong>TARJETA SUSPENDIDA POR LA SODA.</strong> Acércate al mostrador de la soda para reactivar tu cuenta.</span>
</div>
<!-- BANNER DE ADVERTENCIA HTTPS PARA TELÉFONOS MÓVILES -->
<div id="bannerHttpsWarning" style="display: none; background: linear-gradient(135deg, #f59e0b, #d97706); color: white; padding: 10px 14px; font-size: 0.78rem; font-weight: 700; text-align: center; border-radius: 12px; margin: 10px 16px 0 16px; box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);">
<span style="display: inline-flex; align-items: center; gap: 6px;">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="18" height="11" x="3" y="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/></svg>
<span>Estás en HTTP. Para activar la cámara y pagos QR, tu celular requiere HTTPS:</span>
</span>
<div style="margin-top: 6px;">
<a id="linkHttpsRedirect" href="#" onclick="window.location.protocol = 'https:'; return false;" style="display: inline-flex; align-items: center; gap: 6px; padding: 5px 14px; background: white; color: #b45309; border-radius: 20px; font-weight: 900; text-decoration: none; font-size: 0.8rem; box-shadow: 0 2px 5px rgba(0,0,0,0.15);">
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" x2="21" y1="14" y2="3"/></svg>
<span>Abrir en HTTPS Seguro</span>
</a>
</div>
</div>
<!-- BARRA SUPERIOR UNIFICADA -->
<header class="top-bar">
<a href="#" class="brand-badge">
<div class="logo-icon" style="padding: 2px;">
<img src="/img/sibopay-emblem.png" alt="SiboPay" style="width: 26px; height: 26px; object-fit: contain;">
</div>
<div>
<span>Sibo<strong>Pay</strong></span>
<span style="font-size: 0.65rem; display: block; color: var(--text-muted); font-weight: 600;">SODA ESCOLAR CR</span>
</div>
</a>
<!-- ACCIONES DE CABECERA (TEMA OSCURO/CLARO Y SALIR) -->
<div class="top-actions">
<button id="btnCardDesigns" onclick="openCardDesignModal()" class="theme-toggle-btn card-design-toggle-btn" title="Personalizar diseño de mi tarjeta" style="display: inline-flex; align-items: center; justify-content: center; margin-right: 4px;">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="13.5" cy="6.5" r=".5" fill="currentColor"/><circle cx="17.5" cy="10.5" r=".5" fill="currentColor"/><circle cx="8.5" cy="7.5" r=".5" fill="currentColor"/><circle cx="6.5" cy="12.5" r=".5" fill="currentColor"/><path d="M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z"/></svg>
</button>
<button id="btnThemeToggle" onclick="toggleTheme()" class="theme-toggle-btn" title="Alternar Modo Oscuro / Modo Claro" style="display: inline-flex; align-items: center; justify-content: center;">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"/></svg>
</button>
<button id="btnModePadres" onclick="toggleParentPanel(true)" class="mode-btn" style="background: var(--bg-main); border: 1.5px solid var(--border); font-size: 0.8rem; font-weight: 800; border-radius: 10px; padding: 7px 11px; cursor: pointer; color: var(--text-main); display: inline-flex; align-items: center; gap: 6px;" title="Acceso al Portal de Padres">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg>
<span>Padres</span>
</button>
<button id="btnLogout" onclick="logout(true)" class="logout-btn" title="Cerrar sesión y cambiar de cuenta" style="display: inline-flex; align-items: center; gap: 6px;">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/><polyline points="16 17 21 12 16 7"/><line x1="21" x2="9" y1="12" y2="12"/></svg>
<span class="logout-text">Salir</span>
</button>
</div>
</header>
<!-- SELECTOR OCULTO PARA COMPATIBILIDAD JS -->
<select id="studentSelector" onchange="onStudentChange(this.value)" style="display: none;"></select>
<!-- TARJETA DIGITAL DE MONEDERO Y SALDO (ESTILO UNIFICADO TEENS) -->
<section class="wallet-card" id="mainWalletCard">
<!-- ELEMENTOS DE TARJETA INTELIGENTE (CHIP Y PAGO SIN CONTACTO, SIN ASTERISCOS) -->
<div class="card-chip-container">
<div class="card-emv-chip" title="Monedero Electrónico Escolar">
<div class="chip-inner-circuit"></div>
</div>
<div class="card-contactless-wave" title="Tecnología QR / Sin Contacto">
<span>)</span><span>)</span><span>)</span>
</div>
</div>
<div class="student-info">
<div id="walletAvatar" class="student-avatar">ES</div>
<div class="student-meta" style="flex: 1; min-width: 0;">
<div style="min-width: 0;">
<h2 id="walletName" style="word-break: break-word; margin: 0; font-size: 1.15rem; font-weight: 800;">Cargando...</h2>
<span id="walletGrade" class="student-grade">Grado y Sección</span>
</div>
</div>
</div>
<div class="balance-row">
<div class="balance-col">
<div class="label" id="balanceLabel">SALDO DISPONIBLE</div>
<div class="amount">
<span id="walletBalance">₡0</span>
<span class="kids-coin-icon" id="kidsCoinIcon" style="display: none;"></span>
</div>
<!-- Desglose transparente cuando hay pre-órdenes flotantes -->
<div id="breakdownSaldoBox" style="display: none; font-size: 0.72rem; margin-top: 5px; line-height: 1.35; background: rgba(0, 0, 0, 0.22); padding: 5px 8px; border-radius: 8px; backdrop-filter: blur(4px);">
<div style="color: rgba(255, 255, 255, 0.95);">Saldo total: <strong id="lblSaldoTotalBreakdown">₡0</strong></div>
<div style="color: #fef08a;">Retenido en pre-órdenes: <strong id="lblSaldoRetenidoBreakdown">₡0</strong></div>
</div>
</div>
<div style="display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end;">
<button class="qr-toggle-btn" onclick="openQrModal()">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="18" height="18" x="3" y="3" rx="2"/><path d="M7 7h.01"/><path d="M17 7h.01"/><path d="M7 17h.01"/><path d="M17 17h.01"/></svg>
<span id="qrBtnText">Mi QR</span>
</button>
<button id="btnCardTransfer" class="qr-toggle-btn" style="background: rgba(16, 185, 129, 0.25); border-color: rgba(52, 211, 153, 0.4);" onclick="openTransferModal()">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="17 1 21 5 17 9"/><path d="M3 11V9a4 4 0 0 1 4-4h14"/><polyline points="7 23 3 19 7 15"/><path d="M21 13v2a4 4 0 0 1-4 4H3"/></svg>
<span id="transferBtnText">Transferir</span>
</button>
</div>
</div>
</section>
<!-- BANNER DE LÍMITE DIARIO Y DISPONIBILIDAD (SÓLO LECTURA INFORMATIVA PARA EL ESTUDIANTE) -->
<div class="daily-limit-badge" id="dailyLimitBadge" style="cursor: default;" title="Límite diario establecido por tus padres">
<div>
<span>Límite diario fijado: </span>
<strong id="dailyLimitText">₡0</strong>
</div>
<div style="font-size: 0.76rem; color: var(--text-muted);" id="dailyAvailableText">
Disponible hoy: ₡0
</div>
</div>
<!-- BANNER DE ALERTA: LÍMITE DIARIO ALCANZADO (QR BLOQUEADO) -->
<div id="bannerQrDailyLimitBlocked" style="display: none; margin: 0 16px 12px 16px; background: #fef2f2; border: 1.5px solid #fecaca; border-radius: 12px; padding: 10px 14px; font-size: 0.8rem; color: #991b1b; align-items: center; gap: 8px;">
<span style="font-size: 1.3rem; line-height: 1;">⛔</span>
<div>
<strong style="display: block; font-size: 0.82rem; margin-bottom: 2px;">Límite diario alcanzado</strong>
<span id="bannerQrDailyLimitMsg" style="font-size: 0.75rem; color: #7f1d1d; line-height: 1.35;">
Has consumido tu límite de gasto de hoy. Tu código QR está bloqueado para nuevas compras hasta la siguiente jornada.
</span>
</div>
</div>
<!-- ALERGIAS (SI TIENE) -->
<div id="allergyWarning" style="display:none; margin: 0 16px 12px 16px; background: #fffbeb; border: 1px solid #fde68a; border-radius: 12px; padding: 8px 12px; font-size: 0.8rem; color: #92400e; align-items: center; gap: 6px;">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="#b45309" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z"/><line x1="12" x2="12" y1="9" y2="13"/><line x1="12" x2="12.01" y1="17" y2="17"/></svg>
<strong>Atención médica:</strong> <span id="allergyText"></span>
</div>
<!-- BUSCADOR INTELIGENTE DEL MENÚ PARA ESTUDIANTES Y PADRES -->
<div class="menu-smart-search-section" id="menuSmartSearchSection">
<div class="menu-smart-search-box">
<div class="menu-smart-search-icon">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
<circle cx="11" cy="11" r="8"/>
<path d="m21 21-4.3-4.3"/>
</svg>
</div>
<input
type="text"
id="menuSearchInput"
class="menu-smart-search-input"
placeholder="Buscar merienda, fresco, snack o precio (<1000)..."
oninput="handleMenuSearchInput(this.value)"
onkeydown="handleMenuSearchKeyDown(event)"
autocomplete="off"
spellcheck="false"
aria-label="Buscador inteligente del menú"
>
<button
type="button"
id="menuSearchClearBtn"
class="menu-smart-search-clear-btn"
onclick="clearMenuSearch()"
title="Borrar búsqueda"
style="display: none;"
>
✕
</button>
</div>
<!-- CHIPS INTELIGENTES DE ACCESO RÁPIDO -->
<div class="menu-smart-search-chips" id="menuSmartSearchChips">
<button type="button" class="search-chip" onclick="setMenuSearchSuggestion('fresco')">
<span>🥤 Frescos</span>
</button>
<button type="button" class="search-chip" onclick="setMenuSearchSuggestion('casado')">
<span>🍛 Casados</span>
</button>
<button type="button" class="search-chip" onclick="setMenuSearchSuggestion('empanada')">
<span>🥟 Empanadas</span>
</button>
<button type="button" class="search-chip" onclick="setMenuSearchSuggestion('<1000')">
<span>💰 Menos de ₡1.000</span>
</button>
<button type="button" class="search-chip" onclick="setMenuSearchSuggestion('saludable')">
<span>🥗 Saludables</span>
</button>
</div>
<!-- ESTADÍSTICAS Y RESET DE BÚSQUEDA -->
<div id="menuSearchStats" class="menu-smart-search-stats" style="display: none;">
<span id="menuSearchStatsText">Mostrando 0 productos</span>
<button type="button" class="menu-smart-search-reset-link" onclick="clearMenuSearch()">Mostrar menú completo</button>
</div>
</div>
<!-- BARRA DE CATEGORÍAS -->
<div class="category-scroll" id="categoriesBar">
<!-- Se llena dinámicamente -->
</div>
<!-- TÍTULO DE SECCIÓN -->
<div class="section-title">
<span id="catalogTitle">Menú del Recreo</span>
</div>
<!-- GRILLA DE PRODUCTOS -->
<div class="products-grid" id="productsGrid">
<!-- Se llena con productos de la soda -->
</div>
<!-- BARRA FLOTANTE DE PRE-ORDEN / CARRITO -->
<div class="floating-cart-bar" id="floatingCart" style="display: none;" onclick="openCartModal()">
<div class="cart-summary">
<span class="cart-count-badge" id="cartCountBadge">0</span>
<div class="cart-total-text" id="cartTotalText">₡0</div>
</div>
<button class="cart-action-btn" style="display: flex; align-items: center; justify-content: center; gap: 6px;">
<span>Pedir para el Recreo</span> <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><circle cx="8" cy="21" r="1"/><circle cx="19" cy="21" r="1"/><path d="M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12"/></svg>
</button>
</div>
<!-- ENLACES DE ACCESO RÁPIDO PARA DEMO Y REVISIÓN -->
<div style="margin: 30px 16px; padding: 14px; background: var(--card-bg); border: 1px solid var(--border); border-radius: 14px; font-size: 0.82rem; text-align: center;">
<p style="font-weight: 700; margin-bottom: 8px; color: var(--text-main);">Acceso Rápido del Sistema:</p>
<div style="display: flex; justify-content: center; gap: 10px; flex-wrap: wrap;">
<a href="/pos.html" target="_blank" style="color: #0284c7; font-weight: 700; text-decoration: none; padding: 4px 10px; background: #e0f2fe; border-radius: 8px; display: inline-flex; align-items: center; gap: 6px;"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="20" height="14" x="2" y="5" rx="2"/><line x1="2" x2="22" y1="10" y2="10"/></svg> Terminal Soda (Caja & QR)</a>
<a href="/carnet.html" target="_blank" style="color: #10b981; font-weight: 700; text-decoration: none; padding: 4px 10px; background: #d1fae5; border-radius: 8px; display: inline-flex; align-items: center; gap: 6px;"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 6 2 18 2 18 9"/><path d="M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"/><rect width="12" height="8" x="6" y="14"/></svg> Carnés Físicos para Imprimir</a>
</div>
</div>
</div>
<!-- MODAL INMERSIVO: CÓDIGO QR PARA PRESENTAR EN LA SODA (DISEÑO SIBOPAY EXACTO) -->
<div class="modal-qr-sibopay-immersive" id="modalQr" style="display: none;" onclick="closeQrModal(event)">
<!-- FONDO SUPERIOR CELESTE CON LOGO Y MARCA SIBOPAY -->
<div class="qr-immersive-bg-header">
<div class="qr-immersive-brand-header">
<div class="qr-immersive-brand-logo-wrap">
<img src="/img/sibopay-emblem.png" alt="SiboPay" class="qr-immersive-brand-logo">
</div>
<div class="qr-immersive-brand-title">
<span>Sibo</span><strong class="brand-pay-text">Pay</strong>
</div>
</div>
</div>
<!-- CONTENEDOR CENTRAL: TARJETA BLANCA Y BOTÓN CERRAR -->
<div class="qr-immersive-content" onclick="event.stopPropagation()">
<div class="qr-immersive-card">
<div class="qr-card-header-title">MI CARNÉ SIBOPAY</div>
<!-- Banner especial cuando el límite diario fue alcanzado pero tiene preórdenes -->
<div id="qrPreorderOnlyBanner" style="display: none; background: #eff6ff; border: 1.5px solid #bfdbfe; color: #1e40af; border-radius: 10px; padding: 7px 10px; margin-bottom: 10px; font-size: 0.75rem; text-align: center; font-weight: 700; line-height: 1.35;">
📦 Válido exclusivamente para retirar tu Pre-Orden en la soda.<br>
<span style="font-size: 0.70rem; color: #3b82f6;">Compras nuevas en mostrador bloqueadas por límite diario.</span>
</div>
<div class="qr-scanner-frame-wrapper">
<div class="qr-frame-corner top-left"></div>
<div class="qr-frame-corner top-right"></div>
<div class="qr-frame-corner bottom-left"></div>
<div class="qr-frame-corner bottom-right"></div>
<img id="qrDisplayImg" class="qr-immersive-code-img" src="" alt="Código QR">
<!-- LOGO DE LA 'S' EN EL CENTRO DEL QR -->
<div class="qr-center-logo-badge" title="SiboPay">
<img src="/img/sibopay-emblem.png" alt="S" class="qr-center-logo-img">
</div>
</div>
<div class="qr-card-token-text" id="qrTokenDisplay">
CODIGO-QR
</div>
</div>
<!-- BOTÓN CELESTE TIPO PÍLDORA -->
<button type="button" onclick="closeQrModal()" class="qr-immersive-btn-close">
Cerrar
</button>
</div>
</div>
<!-- MODAL: CARRITO Y PRE-ORDEN -->
<div class="modal-qr-backdrop" id="modalCart" style="display: none;" onclick="closeCartModal(event)">
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 420px; text-align: left;">
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #e2e8f0; padding-bottom: 10px; margin-bottom: 12px;">
<h3 style="color: #0f172a; font-size: 1.15rem; font-weight: 800;">Mi Pre-Orden Escolar</h3>
<button onclick="closeCartModal()" style="background: none; border: none; font-size: 1.2rem; cursor: pointer; color: #64748b;">✕</button>
</div>
<div style="margin-bottom: 14px; background: #f8fafc; border: 1.5px solid #e2e8f0; border-radius: 12px; padding: 12px;">
<label style="display: block; font-size: 0.82rem; font-weight: 800; color: #0f172a; margin-bottom: 6px; display: flex; align-items: center; gap: 6px;">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#0284c7" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg>
<span>¿Para cuál recreo deseas tu orden?</span>
</label>
<select id="momentoEntregaSelect" style="width: 100%; box-sizing: border-box; padding: 10px 12px; border-radius: 10px; border: 1.5px solid #cbd5e1; font-weight: 700; font-size: 0.88rem; color: #1e293b; background: white; outline: none; cursor: pointer;">
<option value="recreo_1">🔔 1er Recreo de la Mañana (9:30 AM)</option>
<option value="almuerzo">🍲 Hora de Almuerzo (11:45 AM)</option>
<option value="recreo_2">⏰ 2do Recreo de la Tarde (1:45 PM)</option>
</select>
<div style="font-size: 0.72rem; color: #64748b; margin-top: 6px; display: flex; align-items: center; gap: 4px;">
<span>⚡</span> <span>La soda preparará tus alimentos frescos para este horario.</span>
</div>
</div>
<!-- LISTA DE PRODUCTOS EN EL CARRITO -->
<div id="cartItemsList" style="max-height: 220px; overflow-y: auto; margin-bottom: 14px;">
<!-- Se llena dinámicamente -->
</div>
<div style="border-top: 1px solid #e2e8f0; padding-top: 10px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 4px;">
<div style="display: flex; justify-content: space-between; align-items: center;">
<span style="font-weight: 800; color: #334155; font-size: 0.92rem;">Total a Reservar (Monto Flotante):</span>
<span id="modalCartTotal" style="font-size: 1.3rem; font-weight: 900; color: #0284c7;">₡0</span>
</div>
<div style="font-size: 0.73rem; color: #64748b; text-align: right;">
🔒 El monto queda retenido y se rebajará definitivamente al retirar en la soda.
</div>
</div>
<button id="btnConfirmarOrden" onclick="submitPreOrder()" style="width: 100%; padding: 12px; background: #10b981; color: white; border: none; border-radius: 12px; font-weight: 800; font-size: 1rem; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 6 9 17l-5-5"/></svg> <span>Confirmar Pre-Orden (Monto Flotante)</span>
</button>
</div>
</div>
<!-- MODAL: PANEL DE PADRES (RECARGA SINPE Y LÍMITES) -->
<div class="modal-qr-backdrop" id="modalPadres" style="display: none;" onclick="toggleParentPanel(false, event)">
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 440px; text-align: left;">
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #e2e8f0; padding-bottom: 10px; margin-bottom: 14px;">
<div>
<h3 style="color: #0f172a; font-size: 1.15rem; font-weight: 800;">Portal de Padres SiboPay</h3>
<span style="font-size: 0.75rem; color: #64748b;">Control de meriendas, nutrición y recargas SINPE</span>
</div>
<button onclick="toggleParentPanel(false)" style="background: none; border: none; font-size: 1.2rem; cursor: pointer; color: #64748b;">✕</button>
</div>
<!-- SELECTOR DE HIJO PARA PADRES -->
<div id="parentChildSelectorBox" style="display: none; margin-bottom: 14px; background: #e0f2fe; padding: 10px 12px; border-radius: 12px; border: 1.5px solid #bae6fd;">
<label for="parentChildSelect" style="display: block; font-size: 0.76rem; font-weight: 800; color: #0369a1; margin-bottom: 4px;">Viendo información de:</label>
<select id="parentChildSelect" onchange="onParentChildSelect(this.value)" style="width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid #7dd3fc; font-weight: 800; color: #0c4a6e; background: white; font-size: 0.9rem;">
</select>
</div>
<!-- RECARGA SINPE MÓVIL (MONTO ESCRITO Y ACCESOS RÁPIDOS) -->
<div style="background: #f0fdf4; border: 1.5px solid #86efac; border-radius: 14px; padding: 14px; margin-bottom: 16px;">
<div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px;">
<div style="display: flex; align-items: center; gap: 8px;">
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="#16a34a" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><rect width="14" height="20" x="5" y="2" rx="2" ry="2"/><path d="M12 18h.01"/></svg>
<div>
<strong style="color: #166534; font-size: 0.95rem;">Recarga por SINPE Móvil</strong>
<p style="font-size: 0.74rem; color: #15803d;">Número de la Soda: <strong>8888-SODA (7632)</strong></p>
</div>
</div>
<span style="font-size: 0.7rem; color: #166534; background: #dcfce7; font-weight: 800; padding: 2px 8px; border-radius: 6px;">Acreditación Inmediata</span>
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px;">
<div>
<label for="inputCustomSinpe" style="display: block; font-size: 0.76rem; font-weight: 800; color: #166534; margin-bottom: 4px;">
Monto a recargar (₡):
</label>
<div style="position: relative;">
<span style="position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-weight: 900; color: #166534; font-size: 1.05rem;">₡</span>
<input type="tel" inputmode="numeric" pattern="[0-9]*" id="inputCustomSinpe" placeholder="Ej: 3000" style="width: 100%; padding: 10px 10px 10px 28px; border-radius: 10px; border: 1.5px solid #86efac; font-size: 1.05rem; font-weight: 800; color: #166534; background: white; box-sizing: border-box;">
</div>
</div>
<div>
<label for="inputCustomSinpeComprobante" style="display: block; font-size: 0.76rem; font-weight: 800; color: #166534; margin-bottom: 4px;">
N° Comprobante:
</label>
<input type="text" id="inputCustomSinpeComprobante" placeholder="Ej: 894321" style="width: 100%; padding: 10px 12px; border-radius: 10px; border: 1.5px solid #86efac; font-size: 1.05rem; font-weight: 800; color: #166534; background: white; box-sizing: border-box;">
</div>
</div>
<button type="button" onclick="customSinpeRecharge()" style="width: 100%; padding: 12px; background: linear-gradient(135deg, #16a34a, #15803d); color: white; border: none; border-radius: 10px; font-weight: 900; font-size: 0.95rem; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; box-shadow: 0 4px 10px rgba(22, 163, 74, 0.3);">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/><polyline points="22 4 12 14.01 9 11.01"/></svg> Validar SINPE
</button>
</div>
<!-- CONFIGURACIÓN DE LÍMITE DIARIO (ESCRITO Y DESLIZABLE) -->
<div style="background: #f0f9ff; border: 2px solid #38bdf8; border-radius: 14px; padding: 14px; margin-bottom: 16px; box-shadow: 0 2px 8px rgba(56, 189, 248, 0.15);">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px;">
<div>
<strong style="font-size: 0.92rem; color: #0369a1; display: flex; align-items: center; gap: 6px;"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#0284c7" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg> Límite de Gasto Máximo Diario</strong>
<span style="font-size: 0.74rem; color: #64748b;">Monto máximo que el estudiante puede gastar por día</span>
</div>
<span id="lblParentDailyLimit" style="font-size: 1.05rem; color: #0284c7; font-weight: 900; background: white; border: 1.5px solid #bae6fd; padding: 3px 10px; border-radius: 8px;">₡3.000</span>
</div>
<label for="inputCustomDailyLimit" style="display: block; font-size: 0.8rem; font-weight: 800; color: #0369a1; margin-bottom: 4px;">
Digita o escribe el límite en colones:
</label>
<div style="display: flex; gap: 8px; margin-bottom: 8px;">
<div style="position: relative; flex: 1;">
<span style="position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-weight: 900; color: #0284c7; font-size: 1.1rem;">₡</span>
<input type="tel" inputmode="numeric" pattern="[0-9]*" id="inputCustomDailyLimit" placeholder="Ej: 3000" oninput="onCustomDailyLimitInput(this.value)" style="width: 100%; padding: 10px 10px 10px 30px; border-radius: 10px; border: 2px solid #0284c7; font-size: 1.1rem; font-weight: 900; color: #0f172a; background: white; box-shadow: inset 0 1px 2px rgba(0,0,0,0.06);">
</div>
<button type="button" onclick="saveCustomDailyLimit()" style="padding: 10px 16px; background: linear-gradient(135deg, #0284c7, #0369a1); color: white; border: none; border-radius: 10px; font-weight: 900; font-size: 0.85rem; cursor: pointer; white-space: nowrap; box-shadow: 0 2px 6px rgba(2, 132, 199, 0.35); display: inline-flex; align-items: center; gap: 6px;">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"/><polyline points="17 21 17 13 7 13 7 21"/><polyline points="7 3 7 8 15 8"/></svg> Guardar
</button>
</div>
<div id="msgDailyLimitFeedback" style="display: none; font-size: 0.76rem; font-weight: 800; margin-bottom: 8px; padding: 4px 8px; border-radius: 6px; background: #dcfce7; color: #166534; text-align: center;"></div>
<!-- ACCESOS RÁPIDOS DE LÍMITES COMUNES -->
<div style="display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin-bottom: 10px;">
<button type="button" onclick="setWrittenDailyLimit(1500)" style="padding: 6px 2px; background: white; border: 1.5px solid #cbd5e1; border-radius: 8px; font-size: 0.74rem; font-weight: 800; color: #1e293b; cursor: pointer;">₡1.500</button>
<button type="button" onclick="setWrittenDailyLimit(2500)" style="padding: 6px 2px; background: white; border: 1.5px solid #cbd5e1; border-radius: 8px; font-size: 0.74rem; font-weight: 800; color: #1e293b; cursor: pointer;">₡2.500</button>
<button type="button" onclick="setWrittenDailyLimit(3500)" style="padding: 6px 2px; background: white; border: 1.5px solid #cbd5e1; border-radius: 8px; font-size: 0.74rem; font-weight: 800; color: #1e293b; cursor: pointer;">₡3.500</button>
<button type="button" onclick="setWrittenDailyLimit(5000)" style="padding: 6px 2px; background: white; border: 1.5px solid #cbd5e1; border-radius: 8px; font-size: 0.74rem; font-weight: 800; color: #1e293b; cursor: pointer;">₡5.000</button>
</div>
<div style="font-size: 0.72rem; color: #64748b; margin-bottom: 2px;">O desliza para ajustar rápido:</div>
<input type="range" id="rangeDailyLimit" min="1000" max="10000" step="500" value="3000" oninput="onDailyLimitSlider(this.value)" style="width: 100%;">
<div style="display: flex; justify-content: space-between; font-size: 0.7rem; color: #64748b; margin-top: 2px;">
<span>₡1.000 min</span>
<span>₡10.000 max</span>
</div>
</div>
<!-- CONTROL PARENTAL: PERMITIR O BLOQUEAR TRANSFERENCIAS ENTRE COMPAÑEROS -->
<div style="background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; display: flex; justify-content: space-between; align-items: center;">
<div>
<strong style="font-size: 0.85rem; color: #1e293b; display: flex; align-items: center; gap: 6px;"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#0284c7" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="m16 3 4 4-4 4"/><path d="M20 7H4"/><path d="m8 21-4-4 4-4"/><path d="M4 17h16"/></svg> RecreoTransfer entre Compas</strong>
<span style="font-size: 0.72rem; color: #64748b;">Permitir transferir saldo a compañeros de clase</span>
</div>
<input type="checkbox" id="chkParentAllowTransfer" onchange="onToggleAllowTransfer(this.checked)" style="width: 22px; height: 22px; cursor: pointer; accent-color: #0284c7;" checked>
</div>
<!-- RESTABLECER PIN Y CONTRASEÑA ESCOLAR DEL ALUMNO -->
<div style="background: #f8fafc; border: 1.5px dashed #cbd5e1; border-radius: 14px; padding: 14px; margin-bottom: 16px;">
<div style="display: flex; align-items: center; gap: 8px; margin-bottom: 8px;">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="#475569" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><rect width="18" height="11" x="3" y="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/></svg>
<div>
<strong style="font-size: 0.88rem; color: #1e293b; display: block;">Seguridad y Contraseña del Alumno</strong>
<span style="font-size: 0.72rem; color: #64748b;">Cambia el PIN de transferencias o la contraseña de acceso</span>
</div>
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px;">
<div>
<label style="display: block; font-size: 0.74rem; font-weight: 800; color: #475569; margin-bottom: 3px;">Nuevo PIN (4 dígitos):</label>
<input type="password" inputmode="numeric" maxlength="4" id="inputParentNewPin" placeholder="1234" style="width: 100%; padding: 8px; border-radius: 8px; border: 1.5px solid #cbd5e1; font-weight: 900; letter-spacing: 2px; text-align: center; box-sizing: border-box;">
</div>
<div>
<label style="display: block; font-size: 0.74rem; font-weight: 800; color: #475569; margin-bottom: 3px;">Nueva Contraseña:</label>
<input type="text" id="inputParentNewPass" placeholder="Ej: 1234" style="width: 100%; padding: 8px; border-radius: 8px; border: 1.5px solid #cbd5e1; font-weight: 800; box-sizing: border-box;">
</div>
</div>
<button type="button" onclick="saveParentChildAccess()" style="width: 100%; padding: 10px; background: #334155; color: white; border: none; border-radius: 8px; font-weight: 800; font-size: 0.82rem; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px;">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"/><polyline points="17 21 17 13 7 13 7 21"/><polyline points="7 3 7 8 15 8"/></svg> Guardar Nuevas Credenciales
</button>
</div>
</div>
<!-- HISTORIAL RECIENTE -->
<h4 style="font-size: 0.85rem; font-weight: 800; color: #1e293b; margin-bottom: 8px;">Consumos Recientes</h4>
<div id="parentHistoryList" style="max-height: 140px; overflow-y: auto; font-size: 0.78rem;">
<!-- Se llena dinámicamente -->
</div>
</div>
</div>
<!-- MODAL: REGISTRAR NUEVO ESTUDIANTE (ADMIN) -->
<div class="modal-qr-backdrop" id="modalNewStudent" style="display: none;" onclick="closeNewStudentModal(event)">
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 460px; text-align: left;">
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #e2e8f0; padding-bottom: 10px; margin-bottom: 14px;">
<div>
<h3 style="color: #0f172a; font-size: 1.15rem; font-weight: 800;">Registrar Nuevo Alumno</h3>
<span style="font-size: 0.75rem; color: #64748b;">Genera carné oficial y código QR al instante</span>
</div>
<button onclick="closeNewStudentModal()" style="background: none; border: none; font-size: 1.2rem; cursor: pointer; color: #64748b;">✕</button>
</div>
<form id="formNewStudent" onsubmit="submitNewStudent(event)">
<div style="margin-bottom: 10px;">
<label style="display: block; font-size: 0.78rem; font-weight: 800; color: var(--text-main); margin-bottom: 3px;">Tipo de Perfil / Negocio:</label>
<select id="newEstTipo" style="width: 100%; padding: 8px 10px; border-radius: 8px; border: 1.5px solid var(--border); font-weight: 800; box-sizing: border-box; background: var(--card-bg); color: var(--text-main);">
<option value="EST">Estudiante / Alumno (Escuela o Colegio)</option>
<option value="EMP">Colaborador / Empleado (Empresa o Comedor)</option>
<option value="EVT">Asistente / Pulsera (Evento o Feria)</option>
<option value="SOC">Socio / Miembro (Club o Gimnasio)</option>
</select>
</div>
<div style="margin-bottom: 10px;">
<label style="display: block; font-size: 0.78rem; font-weight: 800; color: var(--text-main); margin-bottom: 3px;">Nombre Completo *:</label>
<input type="text" id="newEstNombre" placeholder="Ej: Daniel Sánchez Méndez" required style="width: 100%; padding: 8px 10px; border-radius: 8px; border: 1.5px solid var(--border); font-weight: 700; box-sizing: border-box; background: var(--card-bg); color: var(--text-main);">
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 10px;">
<div>
<label style="display: block; font-size: 0.75rem; font-weight: 700; color: #334155; margin-bottom: 3px;">Edad:</label>
<input type="number" id="newEstEdad" value="8" min="5" max="19" required style="width: 100%; padding: 8px; border-radius: 8px; border: 1.5px solid #cbd5e1; font-weight: 700; box-sizing: border-box;">
</div>
<div>
<label style="display: block; font-size: 0.75rem; font-weight: 700; color: #334155; margin-bottom: 3px;">Grado:</label>
<input type="text" id="newEstGrado" placeholder="Ej: 3° Grado" required style="width: 100%; padding: 8px; border-radius: 8px; border: 1.5px solid #cbd5e1; font-weight: 700; box-sizing: border-box;">
</div>
<div>
<label style="display: block; font-size: 0.75rem; font-weight: 700; color: #334155; margin-bottom: 3px;">Sección:</label>
<input type="text" id="newEstSeccion" placeholder="Ej: 3-B" required style="width: 100%; padding: 8px; border-radius: 8px; border: 1.5px solid #cbd5e1; font-weight: 700; box-sizing: border-box;">
</div>
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px;">
<div>
<label style="display: block; font-size: 0.75rem; font-weight: 700; color: #334155; margin-bottom: 3px;">Saldo Inicial (₡):</label>
<input type="tel" inputmode="numeric" id="newEstSaldo" value="2000" style="width: 100%; padding: 8px; border-radius: 8px; border: 1.5px solid #cbd5e1; font-weight: 700; box-sizing: border-box;">
</div>
<div>
<label style="display: block; font-size: 0.75rem; font-weight: 700; color: #334155; margin-bottom: 3px;">Límite Diario (₡):</label>
<input type="tel" inputmode="numeric" id="newEstLimite" value="2500" style="width: 100%; padding: 8px; border-radius: 8px; border: 1.5px solid #cbd5e1; font-weight: 700; box-sizing: border-box;">
</div>
</div>
<div style="margin-bottom: 10px;">
<label style="display: block; font-size: 0.75rem; font-weight: 700; color: #334155; margin-bottom: 3px;">Alergias o Restricciones Médicas:</label>
<input type="text" id="newEstAlergias" placeholder="Ej: Ninguna conocida, Alergia al gluten..." style="width: 100%; padding: 8px; border-radius: 8px; border: 1.5px solid #cbd5e1; box-sizing: border-box;">
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px;">
<div>
<label style="display: block; font-size: 0.75rem; font-weight: 700; color: #334155; margin-bottom: 3px;">Nombre del Padre:</label>
<input type="text" id="newEstPadre" placeholder="Ej: Juan Sánchez" style="width: 100%; padding: 8px; border-radius: 8px; border: 1.5px solid #cbd5e1; box-sizing: border-box;">
</div>
<div>
<label style="display: block; font-size: 0.75rem; font-weight: 700; color: #334155; margin-bottom: 3px;">Teléfono Padre:</label>
<input type="text" id="newEstTel" placeholder="+506 8888-0000" style="width: 100%; padding: 8px; border-radius: 8px; border: 1.5px solid #cbd5e1; box-sizing: border-box;">
</div>
</div>
<button type="submit" id="btnSubmitNewStudent" style="width: 100%; padding: 12px; background: linear-gradient(135deg, #0284c7, #0369a1); color: white; border: none; border-radius: 12px; font-weight: 900; font-size: 0.95rem; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"/><polyline points="17 21 17 13 7 13 7 21"/><polyline points="7 3 7 8 15 8"/></svg> Guardar y Generar Carné
</button>
</form>
</div>
</div>
<!-- MODAL: CREAR / EDITAR PRODUCTO (ADMIN) -->
<div class="modal-qr-backdrop" id="modalAdminProduct" style="display: none;" onclick="closeAdminProductModal(event)">
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 480px; text-align: left; max-height: 90vh; overflow-y: auto;">
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); padding-bottom: 10px; margin-bottom: 14px;">
<div>
<h3 id="modalProductTitle" style="color: var(--text-main); font-size: 1.15rem; font-weight: 800; margin: 0; display: flex; align-items: center; gap: 6px;"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg> <span>Crear Nuevo Producto</span></h3>
<span style="font-size: 0.75rem; color: var(--text-muted);">Alimentos, bebidas y meriendas escolares</span>
</div>
<button type="button" onclick="closeAdminProductModal()" style="background: none; border: none; font-size: 1.25rem; cursor: pointer; color: var(--text-muted); padding: 4px;">✕</button>
</div>
<form id="formAdminProduct" onsubmit="submitAdminProduct(event)">
<input type="hidden" id="adminProdId" value="">
<div style="margin-bottom: 10px;">
<label style="display: block; font-size: 0.78rem; font-weight: 800; color: var(--text-main); margin-bottom: 3px;">Nombre del Alimento / Bebida *:</label>
<input type="text" id="adminProdNombre" placeholder="Ej: Empanada de Pollo, Fresco Natural..." required style="width: 100%; padding: 9px 12px; border-radius: 8px; border: 1.5px solid var(--border); font-weight: 700; box-sizing: border-box; background: var(--card-bg); color: var(--text-main);">
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px;">
<div>
<label style="display: block; font-size: 0.78rem; font-weight: 800; color: var(--text-main); margin-bottom: 3px;">Categoría *:</label>
<select id="adminProdCategoria" required style="width: 100%; padding: 9px; border-radius: 8px; border: 1.5px solid var(--border); font-weight: 700; box-sizing: border-box; background: var(--card-bg); color: var(--text-main);">
<!-- Opciones dinámicas de categorías -->
</select>
</div>
<div>
<label style="display: block; font-size: 0.78rem; font-weight: 800; color: var(--text-main); margin-bottom: 3px;">Precio en Colones (₡) *:</label>
<input type="number" id="adminProdPrecio" placeholder="Ej: 1200" min="50" step="50" required style="width: 100%; padding: 9px; border-radius: 8px; border: 1.5px solid var(--border); font-weight: 800; color: #0284c7; box-sizing: border-box; background: var(--card-bg);">
</div>
</div>
<div style="margin-bottom: 12px;">
<label style="display: block; font-size: 0.78rem; font-weight: 800; color: var(--text-main); margin-bottom: 6px;">Ícono Vectorial del Alimento:</label>
<input type="hidden" id="adminProdIcono" value="sandwich">
<div style="display: flex; gap: 12px; align-items: center; background: var(--bg-main, #f8fafc); border: 1.5px solid var(--border); border-radius: 12px; padding: 10px;">
<div id="adminProdIconPreview" style="flex-shrink: 0;"></div>
<div style="flex: 1; min-width: 0;">
<div style="display: flex; gap: 6px; flex-wrap: wrap;" id="adminProdIconPickerList"></div>
</div>
</div>
</div>
<div style="margin-bottom: 10px;">
<label style="display: block; font-size: 0.78rem; font-weight: 800; color: var(--text-main); margin-bottom: 3px;">Descripción (opcional):</label>
<input type="text" id="adminProdDescripcion" placeholder="Ej: Rellena de pollo mechado, horneada al día" style="width: 100%; padding: 8px 10px; border-radius: 8px; border: 1.5px solid var(--border); font-size: 0.85rem; box-sizing: border-box; background: var(--card-bg); color: var(--text-main);">
</div>
<div style="background: var(--bg-main, #f8fafc); border: 1px solid var(--border, #e2e8f0); border-radius: 10px; padding: 10px; margin-bottom: 12px;">
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: center;">
<div>
<label style="display: flex; align-items: center; gap: 6px; font-size: 0.8rem; font-weight: 800; cursor: pointer; color: var(--text-main);">
<input type="checkbox" id="adminProdControlStock" checked onchange="toggleStockInput(this.checked)">
<span>Controlar Existencias</span>
</label>
<div style="margin-top: 6px;" id="boxProdStockCount">
<label style="display: block; font-size: 0.72rem; color: var(--text-muted); font-weight: 700;">Stock Actual:</label>
<input type="number" id="adminProdStock" value="10" min="0" style="width: 100%; padding: 6px 8px; border-radius: 6px; border: 1px solid var(--border); font-weight: 800; background: var(--card-bg); color: var(--text-main); box-sizing: border-box;">
</div>
</div>
<div>
<label style="display: block; font-size: 0.75rem; font-weight: 800; color: var(--text-main); margin-bottom: 4px;">Clasificación Nutricional:</label>
<select id="adminProdMep" style="width: 100%; padding: 7px; border-radius: 6px; border: 1px solid var(--border); font-weight: 700; font-size: 0.8rem; background: var(--card-bg); color: var(--text-main); box-sizing: border-box;">
<option value="1">Saludable (Permitido)</option>
<option value="0">Consumo Ocasional</option>
</select>
</div>
</div>
</div>
<div style="display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px;">
<button type="button" id="btnDeleteProduct" onclick="handleDeleteProduct()" style="display: none; padding: 10px 14px; background: #fee2e2; color: #dc2626; border: 1px solid #fecaca; border-radius: 10px; font-weight: 800; font-size: 0.84rem; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg> Eliminar
</button>
<button type="button" onclick="closeAdminProductModal()" style="padding: 10px 14px; background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; border-radius: 10px; font-weight: 800; font-size: 0.84rem; cursor: pointer;">
Cancelar
</button>
<button type="submit" id="btnSaveProductSubmit" style="padding: 10px 18px; background: linear-gradient(135deg, #0284c7, #0369a1); color: white; border: none; border-radius: 10px; font-weight: 900; font-size: 0.88rem; cursor: pointer; display: flex; align-items: center; gap: 6px; box-shadow: 0 2px 6px rgba(2, 132, 199, 0.3);">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"/><polyline points="17 21 17 13 7 13 7 21"/><polyline points="7 3 7 8 15 8"/></svg> <span>Guardar Producto</span>
</button>
</div>
</form>
</div>
</div>
<!-- MODAL: CREAR / EDITAR EMPLEADO O CAJERO (ADMIN) -->
<div class="modal-qr-backdrop" id="modalAdminStaff" style="display: none;" onclick="closeAdminStaffModal(event)">
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 460px; text-align: left;">
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); padding-bottom: 10px; margin-bottom: 14px;">
<div>
<h3 id="modalStaffTitle" style="color: var(--text-main); font-size: 1.15rem; font-weight: 800; margin: 0; display: flex; align-items: center; gap: 6px;"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg> <span>Nuevo Empleado / Cajero</span></h3>
<span style="font-size: 0.75rem; color: var(--text-muted);">Crea credenciales de acceso para la soda</span>
</div>
<button type="button" onclick="closeAdminStaffModal()" style="background: none; border: none; font-size: 1.25rem; cursor: pointer; color: var(--text-muted); padding: 4px;">✕</button>
</div>
<form id="formAdminStaff" onsubmit="submitAdminStaff(event)">
<input type="hidden" id="adminStaffId" value="">
<div style="margin-bottom: 10px;">
<label style="display: block; font-size: 0.78rem; font-weight: 800; color: var(--text-main); margin-bottom: 3px;">Nombre Completo *:</label>
<input type="text" id="adminStaffNombre" placeholder="Ej: Carlos Murillo Vega" required style="width: 100%; padding: 9px 12px; border-radius: 8px; border: 1.5px solid var(--border); font-weight: 700; box-sizing: border-box; background: var(--card-bg); color: var(--text-main);">
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px;">
<div>
<label style="display: block; font-size: 0.78rem; font-weight: 800; color: var(--text-main); margin-bottom: 3px;">Usuario de Acceso *:</label>
<input type="text" id="adminStaffUsername" placeholder="cajero1" required style="width: 100%; padding: 9px; border-radius: 8px; border: 1.5px solid var(--border); font-weight: 700; box-sizing: border-box; background: var(--card-bg); color: var(--text-main);">
</div>
<div>
<label style="display: block; font-size: 0.78rem; font-weight: 800; color: var(--text-main); margin-bottom: 3px;">Rol en el Sistema *:</label>
<select id="adminStaffRol" required style="width: 100%; padding: 9px; border-radius: 8px; border: 1.5px solid var(--border); font-weight: 800; box-sizing: border-box; background: var(--card-bg); color: var(--text-main);">
<option value="cajero">Cajero (Terminal POS)</option>
<option value="vendedor">Vendedor / Despacho</option>
<option value="admin">Administrador</option>
</select>
</div>
</div>
<div style="margin-bottom: 10px;">
<label style="display: block; font-size: 0.78rem; font-weight: 800; color: var(--text-main); margin-bottom: 3px;" id="lblStaffPassword">Contraseña de Acceso *:</label>
<input type="password" id="adminStaffPassword" placeholder="••••••••" style="width: 100%; padding: 9px 12px; border-radius: 8px; border: 1.5px solid var(--border); font-weight: 700; box-sizing: border-box; background: var(--card-bg); color: var(--text-main);">
<small id="hintStaffPassword" style="display: none; font-size: 0.7rem; color: var(--text-muted); margin-top: 3px;">Deja en blanco para conservar la contraseña actual.</small>
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px;">
<div>
<label style="display: block; font-size: 0.78rem; font-weight: 700; color: var(--text-main); margin-bottom: 3px;">Teléfono:</label>
<input type="text" id="adminStaffTel" placeholder="+506 8888-0000" style="width: 100%; padding: 8px 10px; border-radius: 8px; border: 1.5px solid var(--border); box-sizing: border-box; background: var(--card-bg); color: var(--text-main);">
</div>
<div>
<label style="display: block; font-size: 0.78rem; font-weight: 700; color: var(--text-main); margin-bottom: 3px;">Email (opcional):</label>
<input type="email" id="adminStaffEmail" placeholder="[email protected]" style="width: 100%; padding: 8px 10px; border-radius: 8px; border: 1.5px solid var(--border); box-sizing: border-box; background: var(--card-bg); color: var(--text-main);">
</div>
</div>
<div style="display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px;">
<button type="button" onclick="closeAdminStaffModal()" style="padding: 10px 14px; background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; border-radius: 10px; font-weight: 800; font-size: 0.84rem; cursor: pointer;">
Cancelar
</button>
<button type="submit" id="btnSaveStaffSubmit" style="padding: 10px 18px; background: linear-gradient(135deg, #10b981, #059669); color: white; border: none; border-radius: 10px; font-weight: 900; font-size: 0.88rem; cursor: pointer; display: flex; align-items: center; gap: 6px; box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"/><polyline points="17 21 17 13 7 13 7 21"/><polyline points="7 3 7 8 15 8"/></svg> <span>Guardar Empleado</span>
</button>
</div>
</form>
</div>
</div>
<!-- MODAL: RECREOTRANSFER (PASAR PLATA A UN COMPAÑERO ESCANEANDO SU QR O CARNÉ) -->
<div class="modal-qr-backdrop" id="modalTransfer" style="display: none;" onclick="closeTransferModal(event)">
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 420px; text-align: left;">
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #e2e8f0; padding-bottom: 10px; margin-bottom: 12px;">
<div>
<h3 style="color: #0f172a; font-size: 1.15rem; font-weight: 800; display: flex; align-items: center; gap: 6px;"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="#0284c7" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="m16 3 4 4-4 4"/><path d="M20 7H4"/><path d="m8 21-4-4 4-4"/><path d="M4 17h16"/></svg> Pasar Plata a un Compa</h3>
<span style="font-size: 0.75rem; color: #64748b;">Escanea el carné o celular de tu amigo</span>
</div>
<button onclick="closeTransferModal()" style="background: none; border: none; font-size: 1.2rem; cursor: pointer; color: #64748b;">✕</button>
</div>
<!-- PASO 1: ESCANEAR CÁMARA O ELEGIR COMPAÑERO DE PRUEBA -->
<div id="transferStepScan">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px;">
<span style="font-size: 0.75rem; color: #64748b; font-weight: 700;" id="transferCameraStatus">Iniciando cámara...</span>
<div style="display: flex; gap: 6px;">
<button id="btnFlipTransferCamera" type="button" onclick="flipTransferCamera()" style="display:none; padding: 3px 8px; background: #334155; color: white; border: none; border-radius: 6px; font-size: 0.72rem; font-weight: 700; cursor: pointer; align-items: center; gap: 4px;"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M21.5 2v6h-6M21.34 15.57a10 10 0 1 1-.57-8.38l5.67-5.67"/></svg> Girar</button>
<button id="btnRetryTransferCamera" type="button" onclick="startTransferCamera(true)" style="display:none; padding: 3px 8px; background: #0284c7; color: white; border: none; border-radius: 6px; font-size: 0.72rem; font-weight: 700; cursor: pointer; align-items: center; gap: 4px;"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z"/><circle cx="12" cy="13" r="3"/></svg> Activar</button>
</div>
</div>
<div style="position: relative; border-radius: 12px; overflow: hidden; background: #000; min-height: 170px; margin-bottom: 10px; display: flex; align-items: center; justify-content: center;">
<video id="transferVideo" style="width: 100%; height: 170px; object-fit: cover;" autoplay playsinline webkit-playsinline muted></video>
<div class="laser-scan-line"></div>
<div id="transferCameraHelp" style="display: none; position: absolute; inset: 0; background: rgba(15, 23, 42, 0.92); padding: 14px; text-align: center; flex-direction: column; justify-content: center; align-items: center; gap: 10px; z-index: 10;">
<svg width="36" height="36" viewBox="0 0 24 24" fill="none" stroke="#38bdf8" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z"/><circle cx="12" cy="13" r="3"/></svg>
<div id="transferCameraHelpText" style="font-size: 0.76rem; color: #f8fafc; line-height: 1.35;">Toca el botón para permitir la cámara</div>
<div id="transferCameraActionContainer" style="display: flex; flex-direction: column; gap: 8px; width: 100%; align-items: center;">
<button id="btnAllowTransferCamera" type="button" onclick="startTransferCamera(true)" style="padding: 8px 18px; background: #0284c7; color: white; border: none; border-radius: 8px; font-weight: 800; font-size: 0.82rem; cursor: pointer; box-shadow: 0 4px 10px rgba(2, 132, 199, 0.3);">
Permitir Cámara
</button>
</div>
</div>
</div>
<!-- ACCESO DIRECTO PARA SUBIR O TOMAR FOTO DEL QR CON LA CÁMARA NATIVA -->
<div style="display: flex; justify-content: center; margin-bottom: 12px;">
<label style="cursor: pointer; display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; background: #f0fdf4; border: 1.5px dashed #86efac; border-radius: 10px; font-size: 0.78rem; font-weight: 800; color: #166534; box-shadow: 0 1px 3px rgba(0,0,0,0.04);">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z"/><circle cx="12" cy="13" r="3"/></svg> Tomar foto del QR o carné
<input type="file" accept="image/*" capture="environment" style="display: none;" onchange="handleTransferQrPhoto(event)">
</label>
</div>
<div style="text-align: center; margin-bottom: 12px;">
<span style="font-size: 0.74rem; color: #64748b; font-weight: 700;">O selecciona a un compañero para transferirle:</span>
<div id="quickTransferFriends" style="display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-top: 8px;">
<!-- Se llena dinámicamente con los otros estudiantes -->
</div>
</div>
</div>
<!-- PASO 2: CONFIRMAR COMPAÑERO Y MONTO -->
<div id="transferStepConfirm" style="display: none;">
<!-- Tarjeta del receptor -->
<div style="background: #f0fdf4; border: 1.5px solid #86efac; border-radius: 14px; padding: 12px; display: flex; align-items: center; gap: 12px; margin-bottom: 14px;">
<div id="transferTargetAvatar" class="transfer-target-avatar-badge">ES</div>
<div style="flex: 1;">
<div style="font-size: 0.7rem; color: #15803d; font-weight: 800; text-transform: uppercase;">Vas a transferir a:</div>
<h4 id="transferTargetName" style="font-size: 1rem; font-weight: 900; color: #0f172a; line-height: 1.2;">Nombre</h4>
<span id="transferTargetGrade" style="font-size: 0.75rem; color: #64748b;">Grado y Sección</span>
</div>
<button onclick="resetTransferScan()" style="background: #e2e8f0; border: none; padding: 4px 8px; border-radius: 6px; font-size: 0.75rem; font-weight: 700; cursor: pointer;">Cambiar</button>
</div>
<!-- MONTO A PASAR -->
<label style="display: block; font-size: 0.82rem; font-weight: 800; color: #1e293b; margin-bottom: 6px;">
¿Cuánto le vas a pasar?
</label>
<div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px;">
<button type="button" class="transfer-amount-btn active" id="btnTransfer500" onclick="setTransferAmount(500, this)">₡500</button>
<button type="button" class="transfer-amount-btn" id="btnTransfer1000" onclick="setTransferAmount(1000, this)">₡1.000</button>
<button type="button" class="transfer-amount-btn" id="btnTransfer1500" onclick="setTransferAmount(1500, this)">₡1.500</button>
</div>
<div style="margin-bottom: 12px;">
<input type="tel" inputmode="numeric" pattern="[0-9]*" id="inputTransferCustomAmount" value="500" placeholder="Otro monto (ej. 750)" style="width: 100%; padding: 10px; border-radius: 10px; border: 1.5px solid #cbd5e1; font-size: 1.05rem; font-weight: 800; color: #0284c7; box-sizing: border-box; text-align: center;">
</div>
<!-- MOTIVO OPCIONAL -->
<div style="margin-bottom: 12px;">
<label style="display: block; font-size: 0.75rem; font-weight: 700; color: #64748b; margin-bottom: 4px;">Motivo (Opcional):</label>
<input type="text" id="inputTransferMotivo" placeholder="Ej: Mitad de la empanada, fresco..." style="width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid #cbd5e1; font-size: 0.85rem; box-sizing: border-box;">
</div>
<!-- PIN DE SEGURIDAD (TECLADO NATIVO DEL TELÉFONO) -->
<div style="background: #f8fafc; border: 1.5px dashed #cbd5e1; border-radius: 14px; padding: 14px; margin-bottom: 14px; text-align: center;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;">
<label for="inputTransferPin" style="font-size: 0.8rem; font-weight: 800; color: #0f172a; display: flex; align-items: center; gap: 5px;"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="#475569" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><rect width="18" height="11" x="3" y="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/></svg> Digita tu PIN de seguridad:</label>
<span style="font-size: 0.72rem; color: #64748b; font-weight: 700;">(4 dígitos)</span>
</div>
<div style="position: relative; max-width: 240px; margin: 0 auto;">
<input type="password" inputmode="numeric" pattern="[0-9]*" maxlength="4" autocomplete="one-time-code" id="inputTransferPin" placeholder="••••" style="width: 100%; text-align: center; font-size: 1.8rem; letter-spacing: 10px; padding: 10px 42px 10px 18px; border-radius: 12px; border: 2px solid #cbd5e1; font-weight: 900; background: white; color: #0f172a; box-sizing: border-box; outline: none; transition: border-color 0.2s;" onfocus="this.style.borderColor='#0284c7'" onblur="this.style.borderColor='#cbd5e1'">
<button type="button" id="btnTogglePin" onclick="togglePinVisibility()" style="position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: none; border: none; font-size: 1.1rem; cursor: pointer; color: #64748b; padding: 4px; display: flex; align-items: center;" title="Ver/Ocultar PIN"><svg id="iconTogglePin" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"/><circle cx="12" cy="12" r="3"/></svg></button>
</div>
<div style="font-size: 0.72rem; color: #64748b; margin-top: 6px; font-weight: 600;">Se abrirá automáticamente el teclado numérico de tu teléfono</div>
</div>
<button id="btnConfirmTransfer" onclick="executeP2PTransfer()" style="width: 100%; padding: 14px; background: linear-gradient(135deg, #10b981, #059669); color: white; border: none; border-radius: 14px; font-weight: 900; font-size: 1.05rem; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><line x1="22" y1="2" x2="11" y2="13"/><polygon points="22 2 15 22 11 13 2 9 22 2"/></svg> <span id="lblBtnConfirmTransferText">Enviar ₡500 al Instante</span>
</button>
</div>
</div>
</div>
<!-- MODAL: VINCULAR HIJO POR QR O CÓDIGO (PORTAL PADRES) -->
<div class="modal-qr-backdrop" id="modalScanChildQr" style="display: none;" onclick="closeScanChildQrModal(event)">
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 440px; text-align: center; border-radius: 20px;">
<!-- CABECERA -->
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; border-bottom: 1px solid var(--border); padding-bottom: 10px;">
<div style="display: flex; align-items: center; gap: 8px;">
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="#0284c7" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/></svg>
<strong style="font-size: 1.05rem; color: var(--text-main);">Vincular Estudiante</strong>
</div>
<button type="button" onclick="closeScanChildQrModal()" style="background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--text-muted); padding: 4px;">✕</button>
</div>
<!-- VISTA 1: SELECCIÓN DE MÉTODO (PESTAÑAS) -->
<div id="linkChildViewTabs">
<div style="display: flex; gap: 6px; background: #f1f5f9; padding: 4px; border-radius: 12px; margin-bottom: 14px;">
<button type="button" id="tabBtnLinkCamera" onclick="switchLinkChildTab('camera')" style="flex: 1; padding: 9px 8px; border: none; border-radius: 8px; font-weight: 800; font-size: 0.82rem; cursor: pointer; transition: all 0.2s; background: #ffffff; color: #0284c7; box-shadow: 0 2px 4px rgba(0,0,0,0.06);">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" style="display:inline-block; vertical-align:middle; margin-right:4px;"><path d="M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z"/><circle cx="12" cy="13" r="3"/></svg> Escanear con Cámara
</button>
<button type="button" id="tabBtnLinkCode" onclick="switchLinkChildTab('code')" style="flex: 1; padding: 9px 8px; border: none; border-radius: 8px; font-weight: 700; font-size: 0.82rem; cursor: pointer; transition: all 0.2s; background: transparent; color: #64748b;">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" style="display:inline-block; vertical-align:middle; margin-right:4px;"><rect width="20" height="16" x="2" y="4" rx="2"/><path d="M6 8h.01"/><path d="M10 8h.01"/><path d="M14 8h.01"/><path d="M18 8h.01"/><path d="M8 12h.01"/><path d="M12 12h.01"/><path d="M16 12h.01"/><path d="M7 16h10"/></svg> Digitar Código
</button>
</div>
<!-- PANEL 1: CÁMARA QR -->
<div id="panelLinkCamera" style="display: block;">
<div style="position: relative; width: 100%; height: 220px; background: #000; border-radius: 14px; overflow: hidden; margin-bottom: 10px; border: 2px solid #0284c7;">
<video id="videoScanChild" playsinline webkit-playsinline autoplay muted style="width: 100%; height: 100%; object-fit: cover;"></video>
<canvas id="canvasScanChild" style="display: none;"></canvas>
<div class="laser-scan-line"></div>
<div id="badgeCameraChildStatus" style="position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%); background: rgba(15, 23, 42, 0.9); color: #38bdf8; padding: 3px 12px; border-radius: 20px; font-size: 0.72rem; font-weight: 800; border: 1px solid #0284c7; white-space: nowrap; display: flex; align-items: center; gap: 4px;">
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z"/><circle cx="12" cy="13" r="3"/></svg> Apunta al código QR del carné
</div>
</div>
<p style="font-size: 0.78rem; color: var(--text-muted); margin: 0 0 10px 0;">
Apunta la cámara hacia el código QR impreso en el carné del estudiante.
</p>
</div>
<!-- PANEL 2: DIGITAR CÓDIGO -->
<div id="panelLinkCode" style="display: none; text-align: left;">
<label for="inputManualStudentCode" style="display: block; font-size: 0.8rem; font-weight: 800; color: var(--text-main); margin-bottom: 6px;">
Código de carné del estudiante:
</label>
<div style="display: flex; gap: 8px; margin-bottom: 6px;">
<input type="text" id="inputManualStudentCode" placeholder="Ej: EST-2026-001" onkeydown="if(event.key==='Enter'){event.preventDefault();validateStudentCodeForLink();}" style="flex: 1; padding: 11px 12px; border-radius: 10px; border: 2px solid var(--border); font-size: 0.95rem; font-weight: 800; background: var(--card-bg); color: var(--text-main); box-sizing: border-box; text-transform: uppercase;">
<button type="button" id="btnValidateStudentCode" onclick="validateStudentCodeForLink()" style="padding: 10px 16px; background: #0284c7; color: white; border: none; border-radius: 10px; font-weight: 800; font-size: 0.85rem; cursor: pointer; white-space: nowrap; display: flex; align-items: center; gap: 6px; box-shadow: 0 2px 6px rgba(2, 132, 199, 0.3);">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg> Validar
</button>
</div>
<p style="font-size: 0.75rem; color: var(--text-muted); margin: 0 0 10px 0;">
Digita el código oficial que aparece en el carné escolar (ej: EST-2026-001).
</p>
</div>
<!-- MENSAJE DE ERROR -->
<div id="linkStudentErrorMsg" style="display: none; background: #fee2e2; border: 1.5px solid #ef4444; color: #991b1b; padding: 10px 12px; border-radius: 10px; font-size: 0.8rem; font-weight: 700; margin-top: 10px; text-align: center;"></div>
</div>
<!-- VISTA 2: TARJETA DE VERIFICACIÓN / CONFIRMACIÓN -->
<div id="linkChildViewConfirm" style="display: none; text-align: left;">
<div style="background: #f0fdf4; border: 1.5px solid #86efac; border-radius: 14px; padding: 10px 12px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px;">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="#16a34a" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/><polyline points="22 4 12 14.01 9 11.01"/></svg>
<span style="font-size: 0.82rem; font-weight: 800; color: #166534;">Estudiante Identificado Correctamente</span>
</div>
<!-- TARJETA DEL ESTUDIANTE -->
<div style="background: var(--card-bg); border: 2px solid #0284c7; border-radius: 16px; padding: 14px; margin-bottom: 14px; display: flex; align-items: center; gap: 14px; box-shadow: 0 4px 12px rgba(2, 132, 199, 0.1);">
<div id="linkPreviewAvatar" class="link-preview-avatar-badge">ES</div>
<div style="flex: 1; min-width: 0;">
<div style="font-size: 0.7rem; color: #64748b; font-weight: 800; text-transform: uppercase;">Alumno a vincular:</div>
<h3 id="linkPreviewName" style="font-size: 1.05rem; font-weight: 900; color: var(--text-main); margin: 2px 0; word-break: break-word; line-height: 1.2;">Nombre Alumno</h3>
<div id="linkPreviewGrade" style="font-size: 0.8rem; color: #0284c7; font-weight: 800; margin-top: 2px;">2° Grado - Sección 2-A</div>
<div id="linkPreviewCode" style="font-size: 0.72rem; color: var(--text-muted); font-weight: 700; margin-top: 2px;">Carné: EST-2026-001</div>
</div>
</div>
<p style="font-size: 0.78rem; color: var(--text-muted); margin: 0 0 14px 0; text-align: center;">
¿Confirmas que este es tu hijo/a para vincularlo a tu cuenta y gestionar sus fondos?
</p>
<!-- BOTONES DE ACCIÓN -->
<div style="display: flex; gap: 8px;">
<button type="button" onclick="resetLinkChildToTabs()" style="flex: 1; padding: 11px; background: #f1f5f9; color: #475569; border: 1px solid var(--border); border-radius: 10px; font-weight: 800; font-size: 0.82rem; cursor: pointer;">
← Cambiar
</button>
<button type="button" id="btnConfirmLinkChild" onclick="confirmLinkValidatedChild()" style="flex: 2; padding: 11px; background: linear-gradient(135deg, #10b981, #059669); color: white; border: none; border-radius: 10px; font-weight: 900; font-size: 0.88rem; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M20 6 9 17l-5-5"/></svg> Confirmar y Vincular
</button>
</div>
</div>
</div>
</div>
</div>
<!-- MODAL: ESCANEAR QR PARA RECARGA EN SODA (ADMIN) -->
<div class="modal-qr-backdrop" id="modalAdminScanQr" style="display: none;" onclick="closeAdminScanQrModal(event)">
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 420px; text-align: center;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; border-bottom: 1px solid var(--border); padding-bottom: 8px;">
<strong style="font-size: 1rem; color: var(--text-main); display: flex; align-items: center; gap: 6px;">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z"/><circle cx="12" cy="13" r="3"/></svg> Escanear Carné para Recarga
</strong>
<button type="button" onclick="closeAdminScanQrModal()" style="background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--text-muted);">✕</button>
</div>
<div style="position: relative; width: 100%; height: 230px; background: #000; border-radius: 14px; overflow: hidden; margin-bottom: 10px;">
<video id="videoAdminScan" playsinline webkit-playsinline autoplay muted style="width: 100%; height: 100%; object-fit: cover;"></video>
<canvas id="canvasAdminScan" style="display: none;"></canvas>
<div style="position: absolute; inset: 16px; border: 2px dashed #10b981; border-radius: 12px; pointer-events: none; overflow: hidden;">
<div style="position: absolute; left: 0; right: 0; height: 3px; background: #10b981; box-shadow: 0 0 10px #10b981, 0 0 20px #34d399; animation: adminScanLaser 2s ease-in-out infinite;"></div>
</div>
<button type="button" onclick="toggleAdminCameraFacing()" style="position: absolute; right: 10px; bottom: 10px; background: rgba(15, 23, 42, 0.75); color: white; border: 1px solid rgba(255,255,255,0.25); border-radius: 8px; padding: 5px 9px; font-size: 0.72rem; font-weight: 800; cursor: pointer; backdrop-filter: blur(4px); display: flex; align-items: center; gap: 4px;">
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M21.5 2v6h-6M21.34 15.57a10 10 0 1 1-.57-8.38l5.67-5.67"/></svg> Voltear
</button>
</div>
<style>
@keyframes adminScanLaser {
0% { top: 4%; opacity: 0.6; }
50% { top: 92%; opacity: 1; }
100% { top: 4%; opacity: 0.6; }
}
</style>
<div id="adminScanModalStatus" style="font-size: 0.8rem; font-weight: 800; color: #0284c7; min-height: 22px; margin-bottom: 6px; padding: 6px 10px; border-radius: 8px; background: #e0f2fe; transition: all 0.2s ease; display: flex; align-items: center; justify-content: center; gap: 6px;">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z"/><circle cx="12" cy="13" r="3"/></svg> Enfoca el código QR del carné
</div>
<!-- ALTERNATIVA: DIGITAR CÓDIGO O CARNÉ MANUALMENTE -->
<div style="margin: 8px 0 10px 0; display: flex; gap: 6px;">
<input type="text" id="inputAdminScanManualCode" placeholder="O digita carné (ej: EST-2026-001)" onkeydown="if(event.key==='Enter')submitAdminScanManualCode()" style="flex: 1; padding: 9px 12px; border-radius: 10px; border: 1.5px solid #cbd5e1; font-size: 0.85rem; font-weight: 700; outline: none; background: var(--card-bg, #ffffff); color: var(--text-main);">
<button type="button" onclick="submitAdminScanManualCode()" style="padding: 9px 14px; background: #0284c7; color: white; border: none; border-radius: 10px; font-weight: 800; font-size: 0.8rem; cursor: pointer; white-space: nowrap; display: flex; align-items: center; gap: 4px;">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg> Validar
</button>
</div>
<button type="button" onclick="closeAdminScanQrModal()" style="width: 100%; padding: 10px; background: #f1f5f9; color: #475569; border: 1px solid var(--border); border-radius: 10px; font-weight: 800; font-size: 0.82rem; cursor: pointer;">
Cerrar Cámara
</button>
</div>
</div>
<!-- MODAL: CARRUSEL DE PERSONALIZACIÓN DE TARJETA VIRTUAL -->
<div class="modal-qr-backdrop" id="modalCardDesigns" style="display: none;" onclick="closeCardDesignModal(event)">
<div class="modal-qr-card card-design-modal-card" onclick="event.stopPropagation()" style="max-width: 480px; text-align: left; padding: 18px 16px;">
<!-- CABECERA MODAL -->
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); padding-bottom: 10px; margin-bottom: 10px;">
<div style="display: flex; align-items: center; gap: 8px;">
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="#ec4899" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><circle cx="13.5" cy="6.5" r=".5" fill="currentColor"/><circle cx="17.5" cy="10.5" r=".5" fill="currentColor"/><circle cx="8.5" cy="7.5" r=".5" fill="currentColor"/><circle cx="6.5" cy="12.5" r=".5" fill="currentColor"/><path d="M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.563-2.512 5.563-5.563C22 6.5 17.5 2 12 2Z"/></svg>
<div>
<h3 style="margin: 0; font-size: 1.15rem; font-weight: 900; color: var(--text-main);">Diseños de Tarjeta</h3>
<span style="font-size: 0.74rem; color: var(--text-muted); font-weight: 600;">Desliza y elige tu estilo favorito</span>
</div>
</div>
<button type="button" onclick="closeCardDesignModal()" style="background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--text-muted); padding: 4px;">✕</button>
</div>
<!-- CARRUSEL WRAPPER CON BOTONES PREV / NEXT -->
<div class="card-carousel-wrapper">
<button type="button" class="carousel-nav-btn prev" onclick="scrollCardCarousel(-1)" title="Diseño anterior">‹</button>
<button type="button" class="carousel-nav-btn next" onclick="scrollCardCarousel(1)" title="Siguiente diseño">›</button>
<div class="card-carousel-container" id="cardCarouselContainer">
<!-- Slides generados dinámicamente con JS -->
</div>
</div>
<!-- PUNTOS INDICADORES DE PAGINACIÓN -->
<div class="carousel-dots" id="carouselDots">
<!-- Generados dinámicamente -->
</div>
<!-- TIRA DE ACCESO RÁPIDO A TEMAS -->
<div style="margin-top: 8px;">
<div style="font-size: 0.72rem; font-weight: 800; color: var(--text-muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.5px;">
Colección de Estilos:
</div>
<div class="theme-quick-strip" id="themeQuickStrip">
<!-- Generado dinámicamente -->
</div>
</div>
<!-- BOTÓN CERRAR / LISTO -->
<div style="margin-top: 14px; display: flex; justify-content: flex-end;">
<button type="button" onclick="closeCardDesignModal()" style="padding: 9px 18px; background: var(--bg-main); border: 1.5px solid var(--border); border-radius: 10px; font-weight: 800; font-size: 0.85rem; color: var(--text-main); cursor: pointer;">
Listo
</button>
</div>
</div>
</div>
<!-- MODAL: CREAR / EDITAR USUARIO (DEVELOPER) -->
<div class="modal-qr-backdrop" id="modalDevUser" style="display: none;" onclick="closeModalDevUser(event)">
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 500px; text-align: left; padding: 22px;">
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1.5px solid var(--border); padding-bottom: 12px; margin-bottom: 16px;">
<div style="display: flex; align-items: center; gap: 10px;">
<div style="width: 38px; height: 38px; border-radius: 10px; background: #f0f9ff; color: #0284c7; border: 1px solid #bae6fd; display: flex; align-items: center; justify-content: center; flex-shrink: 0;">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/></svg>
</div>
<div>
<h3 id="modalDevUserTitle" style="margin: 0; font-size: 1.15rem; font-weight: 900; color: var(--text-main);">Crear Nuevo Usuario</h3>
<span style="font-size: 0.76rem; color: var(--text-muted); font-weight: 600;">Control total de cuentas y permisos</span>
</div>
</div>
<button type="button" onclick="closeModalDevUser()" style="background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--text-muted); padding: 4px;">✕</button>
</div>
<form id="formDevUser" onsubmit="saveDevUser(event)">
<input type="hidden" id="devUserId" value="">
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px;">
<div>
<label style="font-size: 0.8rem; font-weight: 800; color: var(--text-main); display: block; margin-bottom: 4px;">Usuario (Login):</label>
<input type="text" id="devInputUsername" required placeholder="ej: admin2, carlos" style="width: 100%; padding: 9px 12px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--bg-main); color: var(--text-main); font-weight: 700; box-sizing: border-box;">
</div>
<div>
<label style="font-size: 0.8rem; font-weight: 800; color: var(--text-main); display: block; margin-bottom: 4px;">Rol en el Sistema:</label>
<select id="devInputRol" required style="width: 100%; padding: 9px 12px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--bg-main); color: var(--text-main); font-weight: 700; box-sizing: border-box;">
<option value="admin">Administrador (Soda/Escuela)</option>
<option value="developer">Developer Master</option>
<option value="cajero">Cajero POS</option>
<option value="vendedor">Vendedor</option>
<option value="padre">Padre de Familia</option>
<option value="estudiante">Estudiante</option>
</select>
</div>
</div>
<div style="margin-bottom: 12px;">
<label style="font-size: 0.8rem; font-weight: 800; color: var(--text-main); display: block; margin-bottom: 4px;">Nombre Completo:</label>
<input type="text" id="devInputNombre" required placeholder="ej: Juan Pérez Rojas" style="width: 100%; padding: 9px 12px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--bg-main); color: var(--text-main); font-weight: 700; box-sizing: border-box;">
</div>
<div id="devPasswordRow" style="margin-bottom: 12px;">
<label id="devPasswordLabel" style="font-size: 0.8rem; font-weight: 800; color: var(--text-main); display: block; margin-bottom: 4px;">Contraseña:</label>
<input type="password" id="devInputPassword" placeholder="Contraseña de acceso" style="width: 100%; padding: 9px 12px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--bg-main); color: var(--text-main); font-weight: 700; box-sizing: border-box;">
<small id="devPasswordHelp" style="font-size: 0.72rem; color: var(--text-muted); display: none;">Dejar en blanco si no deseas cambiar la contraseña actual.</small>
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px;">
<div>
<label style="font-size: 0.8rem; font-weight: 800; color: var(--text-main); display: block; margin-bottom: 4px;">Teléfono:</label>
<input type="text" id="devInputTelefono" placeholder="ej: 8888-8888" style="width: 100%; padding: 9px 12px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--bg-main); color: var(--text-main); font-weight: 700; box-sizing: border-box;">
</div>
<div>
<label style="font-size: 0.8rem; font-weight: 800; color: var(--text-main); display: block; margin-bottom: 4px;">Email:</label>
<input type="email" id="devInputEmail" placeholder="[email protected]" style="width: 100%; padding: 9px 12px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--bg-main); color: var(--text-main); font-weight: 700; box-sizing: border-box;">
</div>
</div>
<div style="display: flex; justify-content: flex-end; gap: 10px; border-top: 1.5px solid var(--border); padding-top: 14px;">
<button type="button" onclick="closeModalDevUser()" style="padding: 10px 18px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--bg-main); color: var(--text-main); font-weight: 800; font-size: 0.85rem; cursor: pointer;">
Cancelar
</button>
<button type="submit" class="dev-action-btn dev-action-btn-primary" style="padding: 10px 22px; font-size: 0.9rem; display: flex; align-items: center; gap: 6px;">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"/><polyline points="17 21 17 13 7 13 7 21"/><polyline points="7 3 7 8 15 8"/></svg> Guardar Usuario
</button>
</div>
</form>
</div>
</div>
<!-- MODAL: CAMBIO RÁPIDO DE CONTRASEÑA (DEVELOPER) -->
<div class="modal-qr-backdrop" id="modalDevPassword" style="display: none;" onclick="closeModalDevPassword(event)">
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 420px; text-align: left; padding: 22px;">
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1.5px solid var(--border); padding-bottom: 12px; margin-bottom: 16px;">
<div style="display: flex; align-items: center; gap: 10px;">
<div style="width: 38px; height: 38px; border-radius: 10px; background: #f0f9ff; color: #0284c7; border: 1px solid #bae6fd; display: flex; align-items: center; justify-content: center; flex-shrink: 0;">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><circle cx="7.5" cy="15.5" r="5.5"/><path d="m21 2-9.6 9.6"/><path d="m15.5 7.5 3 3L22 7l-3-3"/></svg>
</div>
<div>
<h3 style="margin: 0; font-size: 1.15rem; font-weight: 900; color: var(--text-main);">Cambiar Contraseña</h3>
<span id="devPwdTargetUser" style="font-size: 0.78rem; color: #0284c7; font-weight: 700;">Usuario</span>
</div>
</div>
<button type="button" onclick="closeModalDevPassword()" style="background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--text-muted); padding: 4px;">✕</button>
</div>
<form id="formDevPassword" onsubmit="saveDevPassword(event)">
<input type="hidden" id="devPwdUserId" value="">
<div style="margin-bottom: 16px;">
<label style="font-size: 0.82rem; font-weight: 800; color: var(--text-main); display: block; margin-bottom: 6px;">Nueva Contraseña:</label>
<input type="password" id="devInputNewPassword" required minlength="4" placeholder="Mínimo 4 caracteres" style="width: 100%; padding: 11px 12px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--bg-main); color: var(--text-main); font-weight: 700; box-sizing: border-box; font-size: 0.95rem;">
</div>
<div style="display: flex; justify-content: flex-end; gap: 10px; border-top: 1.5px solid var(--border); padding-top: 14px;">
<button type="button" onclick="closeModalDevPassword()" style="padding: 10px 18px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--bg-main); color: var(--text-main); font-weight: 800; font-size: 0.85rem; cursor: pointer;">
Cancelar
</button>
<button type="submit" class="dev-action-btn dev-action-btn-primary" style="padding: 10px 22px; font-size: 0.9rem; display: flex; align-items: center; gap: 6px;">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><rect width="18" height="11" x="3" y="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/></svg> Actualizar Contraseña
</button>
</div>
</form>
</div>
</div>
<!-- MODAL: CREAR NUEVA ESCUELA / SEDE MULTI-TENANT (DEVELOPER) -->
<div class="modal-qr-backdrop" id="modalDevEscuela" style="display: none;" onclick="closeModalDevEscuela(event)">
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 540px; text-align: left; padding: 24px;">
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1.5px solid var(--border); padding-bottom: 12px; margin-bottom: 16px;">
<div style="display: flex; align-items: center; gap: 10px;">
<div style="width: 38px; height: 38px; border-radius: 10px; background: #f0f9ff; color: #0284c7; border: 1px solid #bae6fd; display: flex; align-items: center; justify-content: center; flex-shrink: 0;">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 21h18"/><path d="M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"/><path d="M9 21v-4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v4"/><line x1="9" y1="9" x2="9" y2="9.01"/><line x1="15" y1="9" x2="15" y2="9.01"/></svg>
</div>
<div>
<h3 style="margin: 0; font-size: 1.18rem; font-weight: 900; color: var(--text-main);">Alta de Nueva Sede Escolar</h3>
<span style="font-size: 0.76rem; color: #0284c7; font-weight: 700;">Multi-Tenant & Soda Independiente</span>
</div>
</div>
<button type="button" onclick="closeModalDevEscuela()" style="background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--text-muted); padding: 4px;">✕</button>
</div>
<form id="formDevEscuela" onsubmit="guardarDevEscuela(event)">
<div style="display: grid; grid-template-columns: 1fr 2fr; gap: 12px; margin-bottom: 14px;">
<div>
<label style="font-size: 0.8rem; font-weight: 800; color: var(--text-main); display: block; margin-bottom: 4px;">Código Único: *</label>
<input type="text" id="devEscuelaCodigo" required maxlength="8" placeholder="Ej: SJT" style="width: 100%; padding: 10px 12px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--bg-main); color: var(--text-main); font-weight: 800; text-transform: uppercase; box-sizing: border-box;" oninput="this.value = this.value.toUpperCase().replace(/[^A-Z0-9]/g, '')">
<span style="font-size: 0.68rem; color: var(--text-muted); display: block; margin-top: 2px;">Prefijo para carnés</span>
</div>
<div>
<label style="font-size: 0.8rem; font-weight: 800; color: var(--text-main); display: block; margin-bottom: 4px;">Nombre del Centro Educativo: *</label>
<input type="text" id="devEscuelaNombre" required placeholder="Ej: Saint Joseph School" style="width: 100%; padding: 10px 12px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--bg-main); color: var(--text-main); font-weight: 700; box-sizing: border-box;">
</div>
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px;">
<div>
<label style="font-size: 0.8rem; font-weight: 800; color: var(--text-main); display: block; margin-bottom: 4px;">Teléfono SINPE Móvil: *</label>
<input type="tel" id="devEscuelaSinpe" required placeholder="Ej: 8888-1234" style="width: 100%; padding: 10px 12px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--bg-main); color: var(--text-main); font-weight: 700; box-sizing: border-box;">
<span style="font-size: 0.68rem; color: var(--text-muted); display: block; margin-top: 2px;">Para recargas de los padres</span>
</div>
<div>
<label style="font-size: 0.8rem; font-weight: 800; color: var(--text-main); display: block; margin-bottom: 4px;">Titular SINPE Móvil:</label>
<input type="text" id="devEscuelaSinpeNombre" placeholder="Ej: Soda Saint Joseph" style="width: 100%; padding: 10px 12px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--bg-main); color: var(--text-main); font-weight: 700; box-sizing: border-box;">
</div>
</div>
<div style="margin-bottom: 16px;">
<label style="font-size: 0.8rem; font-weight: 800; color: var(--text-main); display: block; margin-bottom: 4px;">Concesionario / Responsable Legal:</label>
<input type="text" id="devEscuelaConcesionario" placeholder="Ej: Servicios Alimentarios Gómez S.A." style="width: 100%; padding: 10px 12px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--bg-main); color: var(--text-main); font-weight: 700; box-sizing: border-box;">
</div>
<div style="background: #f0f9ff; border: 1px solid #bae6fd; border-radius: 12px; padding: 12px; margin-bottom: 18px; font-size: 0.78rem; color: var(--text-main); line-height: 1.45;">
<span style="display:inline-flex; align-items:center; gap:5px; color:#0284c7; font-weight:800;"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg> Automatización Instantánea:</span> Al registrar la sede, el sistema clonará de forma automática el menú base de productos saludables y creará sus credenciales operativas (<code>cajero_codigo</code> y <code>admin_codigo</code>, clave temporal <code>123456</code>).
</div>
<div style="display: flex; justify-content: flex-end; gap: 10px; border-top: 1.5px solid var(--border); padding-top: 14px;">
<button type="button" onclick="closeModalDevEscuela()" style="padding: 10px 18px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--bg-main); color: var(--text-main); font-weight: 800; font-size: 0.85rem; cursor: pointer;">
Cancelar
</button>
<button type="submit" id="btnDevSubmitEscuela" class="dev-action-btn dev-action-btn-primary" style="padding: 10px 22px; font-size: 0.9rem; display: flex; align-items: center; gap: 6px;">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"/><polyline points="17 21 17 13 7 13 7 21"/><polyline points="7 3 7 8 15 8"/></svg> Dar de Alta Escuela
</button>
</div>
</form>
</div>
</div>
<!-- ======================================================== -->
<!-- MODAL DE VALIDACIÓN Y ESTADO SINPE EN TIEMPO REAL -->
<!-- ======================================================== -->
<div class="modal-qr-backdrop modal-sinpe-backdrop" id="modalSinpeValidacion" style="display: none;" onclick="handleSinpeBackdropClick(event)">
<div class="modal-qr-card modal-sinpe-card" onclick="event.stopPropagation()">
<button type="button" class="modal-sinpe-close-btn" id="modalSinpeBtnCloseX" onclick="closeSinpeModal()" style="display: none;" title="Cerrar">✕</button>
<!-- 1. ESTADO: CARGANDO / VALIDANDO SINPE (Hasta 2 minutos con mensajes sutiles) -->
<div id="modalSinpeStateLoading" style="display: none;">
<div class="sinpe-spinner-container">
<div class="sinpe-pulse-ring"></div>
<div class="sinpe-icon-badge loading">
<svg class="sinpe-spin-svg" width="46" height="46" viewBox="0 0 24 24" fill="none">
<circle cx="12" cy="12" r="10" stroke="#e0f2fe" stroke-width="2.5"/>
<path d="M12 2a10 10 0 0 1 10 10" stroke="#0284c7" stroke-width="2.5" stroke-linecap="round"/>
</svg>
<div class="sinpe-center-s-circle">
<span>S</span>
</div>
</div>
</div>
<h3 style="margin: 14px 0 4px 0; font-size: 1.25rem; font-weight: 900; color: var(--text-main);">Validando SINPE</h3>
<p id="modalSinpeLoadingSubtext" style="font-size: 0.85rem; color: #64748b; margin: 0 0 10px 0; line-height: 1.35;">
Validando comprobante con el banco. Esto podría tardar hasta 1 minuto...
</p>
<!-- Subtítulos sutiles que rotan -->
<div style="text-align: center; margin: 0 0 14px 0; font-size: 0.78rem; color: #0284c7; font-weight: 800; min-height: 20px; display: flex; align-items: center; justify-content: center; gap: 6px;">
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" class="sinpe-spin-svg"><path d="M21 12a9 9 0 1 1-6.219-8.56"/></svg>
<span id="modalSinpeStepText">Consultando confirmación bancaria en tiempo real...</span>
</div>
<!-- Resumen de la Operación -->
<div class="sinpe-info-summary">
<div class="sinpe-info-row">
<span>Estudiante:</span>
<strong id="modalSinpeSummaryChild">-</strong>
</div>
<div class="sinpe-info-row">
<span>Monto a validar:</span>
<strong id="modalSinpeSummaryMonto" style="color: #0284c7; font-size: 0.96rem;">₡0</strong>
</div>
<div class="sinpe-info-row">
<span>Código de detalle:</span>
<strong id="modalSinpeSummaryCodigo" style="font-family: monospace; letter-spacing: 0.5px; color: #0369a1;">-</strong>
</div>
</div>
<div style="font-size: 0.73rem; color: #64748b; margin-top: 14px; line-height: 1.4; background: #f0f9ff; border: 1px solid #bae6fd; padding: 9px 12px; border-radius: 10px; text-align: left;">
<span style="font-weight: 800; color: #0284c7;">⏳ Espere un momento, por favor:</span> Esto podría tardar hasta 1 minuto mientras el banco emite el comprobante digital. No cierre esta pantalla.
</div>
</div>
<!-- ESTADO: TIEMPO DE ESPERA AGOTADO (2 minutos sin confirmación bancaria) -->
<div id="modalSinpeStateTimeout" style="display: none;">
<div class="sinpe-icon-badge timeout">
<svg width="38" height="38" viewBox="0 0 24 24" fill="none" stroke="#0284c7" stroke-width="2.3" stroke-linecap="round" stroke-linejoin="round">
<circle cx="12" cy="12" r="10"/>
<polyline points="12 6 12 12 16 14"/>
</svg>
</div>
<h3 style="margin: 14px 0 4px 0; font-size: 1.25rem; font-weight: 900; color: var(--text-main);">El banco aún no confirma</h3>
<p style="font-size: 0.84rem; color: #64748b; margin: 0 0 14px 0; line-height: 1.45;">
No hemos recibido el correo de confirmación de tu banco todavía. Puedes seguir esperando 1 minuto más o enviarla para que el comercio la revise manualmente.
</p>
<div class="sinpe-info-summary" style="margin-bottom: 16px;">
<div class="sinpe-info-row">
<span>Monto reportado:</span>
<strong id="modalSinpeTimeoutMonto" style="color: #0284c7; font-size: 0.96rem;">₡0</strong>
</div>
<div class="sinpe-info-row">
<span>Código de detalle:</span>
<strong id="modalSinpeTimeoutCodigo" style="font-family: monospace;">-</strong>
</div>
</div>
<div style="display: flex; flex-direction: column; gap: 8px;">
<button type="button" class="btn-sinpe-action btn-sinpe-sky" onclick="retrySinpeWaitMore()">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.3" stroke-linecap="round" stroke-linejoin="round"><path d="M21.5 2v6h-6M21.34 15.57a10 10 0 1 1-.57-8.38l5.67-5.67"/></svg>
<span>Seguir esperando 1 minuto más</span>
</button>
<button type="button" class="btn-sinpe-action btn-sinpe-subtle" onclick="confirmSinpeSendManualReview()">
<svg width="17" height="17" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.3" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/><line x1="16" y1="13" x2="8" y2="13"/><line x1="16" y1="17" x2="8" y2="17"/></svg>
<span>Enviar a revisión manual</span>
</button>
</div>
</div>
<!-- 2. ESTADO: ÉXITO / VALIDADO -->
<div id="modalSinpeStateSuccess" style="display: none;">
<div class="sinpe-icon-badge success">
<svg width="42" height="42" viewBox="0 0 24 24" fill="none" stroke="#16a34a" stroke-width="2.8" stroke-linecap="round" stroke-linejoin="round">
<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/>
<polyline points="22 4 12 14.01 9 11.01"/>
</svg>
</div>
<h3 style="margin: 14px 0 4px 0; font-size: 1.25rem; font-weight: 900; color: #15803d;">¡Pago Verificado con Éxito!</h3>
<p style="font-size: 0.84rem; color: #64748b; margin: 0 0 12px 0;">
El dinero fue acreditado automáticamente al monedero.
</p>
<div class="sinpe-card-receipt">
<div style="font-size: 0.72rem; text-transform: uppercase; color: #166534; font-weight: 800; letter-spacing: 0.5px; margin-bottom: 2px;">Monto Acreditado</div>
<div id="modalSinpeSuccessMonto" style="font-size: 1.8rem; font-weight: 900; color: #15803d; margin-bottom: 10px;">₡0</div>
<div class="sinpe-info-row">
<span>Estudiante:</span>
<strong id="modalSinpeSuccessChild">-</strong>
</div>
<div class="sinpe-info-row">
<span>Banco emisor:</span>
<strong id="modalSinpeSuccessBanco">Banco</strong>
</div>
<div class="sinpe-info-row">
<span>Comprobante:</span>
<strong id="modalSinpeSuccessComp" style="font-family: monospace;">-</strong>
</div>
<div class="sinpe-info-row" style="border-top: 1px dashed #86efac; padding-top: 8px; margin-top: 6px;">
<span style="font-weight: 800; color: #166534;">Nuevo Saldo Disponible:</span>
<strong id="modalSinpeSuccessNuevoSaldo" style="color: #15803d; font-size: 1.05rem;">₡0</strong>
</div>
</div>
<button type="button" class="btn-sinpe-action btn-sinpe-success" onclick="closeSinpeModal()">
<span>Aceptar y Continuar</span>
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"/></svg>
</button>
</div>
<!-- 3. ESTADO: PENDIENTE DE REVISIÓN COMERCIO (Timeout / sin notificación bancaria) -->
<div id="modalSinpeStatePending" style="display: none;">
<div class="sinpe-icon-badge pending">
<svg width="40" height="40" viewBox="0 0 24 24" fill="none" stroke="#d97706" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<circle cx="12" cy="12" r="10"/>
<polyline points="12 6 12 12 16 14"/>
</svg>
</div>
<h3 style="margin: 14px 0 4px 0; font-size: 1.25rem; font-weight: 900; color: #b45309;">Solicitud en Revisión</h3>
<p style="font-size: 0.85rem; color: #475569; margin: 0 0 14px 0; line-height: 1.45;">
Aún no ingresó la confirmación de tu banco. Tu solicitud de recarga por <strong>₡<span id="modalSinpePendingMonto">0</span></strong> quedó registrada para que el comercio la valide.
</p>
<div style="background: #fffbeb; border: 1.5px solid #fde68a; border-radius: 12px; padding: 12px; margin-bottom: 16px; text-align: left; font-size: 0.78rem; color: #92400e; line-height: 1.45;">
<div style="font-weight: 800; display: flex; align-items: center; gap: 5px; margin-bottom: 4px;">
<span>⚡ Acreditación Automática:</span>
</div>
Si la notificación del banco entra en los próximos minutos, el sistema la acreditará de forma automática sin que tengas que hacer nada más.
</div>
<button type="button" class="btn-sinpe-action btn-sinpe-pending" onclick="closeSinpeModal()">
<span>Entendido</span>
</button>
</div>
<!-- 4. ESTADO: ERROR / INVÁLIDO / REPETIDO -->
<div id="modalSinpeStateError" style="display: none;">
<div class="sinpe-icon-badge error">
<svg width="40" height="40" viewBox="0 0 24 24" fill="none" stroke="#dc2626" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<circle cx="12" cy="12" r="10"/>
<line x1="12" y1="8" x2="12" y2="12"/>
<line x1="12" y1="16" x2="12.01" y2="16"/>
</svg>
</div>
<h3 id="modalSinpeErrorTitle" style="margin: 14px 0 4px 0; font-size: 1.22rem; font-weight: 900; color: #b91c1c;">No se pudo validar</h3>
<p id="modalSinpeErrorMessage" style="font-size: 0.86rem; color: #475569; margin: 0 0 16px 0; line-height: 1.45;">
Ocurrió un inconveniente al validar la recarga.
</p>
<button type="button" class="btn-sinpe-action btn-sinpe-error" onclick="closeSinpeModal()">
<span>Entendido</span>
</button>
</div>
</div>
</div>
<!-- MODAL: TÉRMINOS, CONDICIONES Y GUÍA DE RECARGA SINPE MÓVIL -->
<div class="modal-qr-backdrop modal-sinpe-backdrop" id="modalSinpeTerms" style="display: none;" onclick="closeModalSinpeTerms(event)">
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 480px; max-height: 85vh; overflow-y: auto; text-align: left; padding: 22px; border-radius: 20px; box-sizing: border-box;">
<!-- Encabezado del Modal -->
<div style="display: flex; align-items: center; justify-content: space-between; border-bottom: 1.5px solid var(--border, #e2e8f0); padding-bottom: 12px; margin-bottom: 14px;">
<div style="display: flex; align-items: center; gap: 10px;">
<div style="width: 38px; height: 38px; border-radius: 10px; background: #e0f2fe; color: #0284c7; display: flex; align-items: center; justify-content: center; font-size: 1.25rem; flex-shrink: 0;">
🛡️
</div>
<div>
<h3 style="margin: 0; font-size: 1.05rem; font-weight: 900; color: var(--text-main, #0f172a);">Términos y Guía SINPE Móvil</h3>
<span style="font-size: 0.74rem; color: var(--text-muted, #64748b);">Reglas para acreditación automática</span>
</div>
</div>
<button type="button" onclick="closeModalSinpeTerms()" style="background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--text-muted, #64748b); padding: 4px;" title="Cerrar">✕</button>
</div>
<!-- Alerta Dorada: Coincidencia Exacta -->
<div style="background: #fffbeb; border: 1.5px solid #fde68a; border-radius: 12px; padding: 12px; margin-bottom: 14px;">
<div style="display: flex; align-items: flex-start; gap: 8px;">
<span style="font-size: 1.15rem; line-height: 1;">⚠️</span>
<div style="font-size: 0.77rem; color: #92400e; line-height: 1.45;">
<strong style="display: block; font-size: 0.82rem; margin-bottom: 2px;">Atención a dos datos obligatorios:</strong>
El <strong>monto</strong> y el <strong>código SIBO</strong> deben coincidir con total precisión para que el sistema de la soda apruebe el saldo en segundos.
</div>
</div>
</div>
<!-- Lista de Términos Numerados -->
<div style="display: flex; flex-direction: column; gap: 13px; font-size: 0.78rem; color: var(--text-main, #334155); line-height: 1.45;">
<!-- 1. Monto Exacto -->
<div style="display: flex; gap: 10px; align-items: flex-start;">
<div style="width: 22px; height: 22px; border-radius: 50%; background: #dcfce7; color: #166534; font-weight: 900; font-size: 0.72rem; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px;">
1
</div>
<div>
<strong style="color: var(--text-main, #0f172a); display: block; font-size: 0.82rem;">Monto idéntico al transferido:</strong>
<span>El monto elegido en esta pantalla debe ser <strong>exactamente igual</strong> al transferido desde su banco (ej: si transfirió ₡3.000, digite ₡3.000). Diferencias en el importe impiden la conciliación automática.</span>
</div>
</div>
<!-- 2. Código Obligatorio -->
<div style="display: flex; gap: 10px; align-items: flex-start;">
<div style="width: 22px; height: 22px; border-radius: 50%; background: #dcfce7; color: #166534; font-weight: 900; font-size: 0.72rem; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px;">
2
</div>
<div>
<strong style="color: var(--text-main, #0f172a); display: block; font-size: 0.82rem;">Copiar y pegar el código en el Detalle:</strong>
<span>Es <strong>estrictamente obligatorio</strong> colocar el código que empieza con <code style="background: rgba(2, 132, 199, 0.08); color: #0284c7; padding: 1px 6px; border-radius: 4px; font-weight: 800; font-family: monospace;">SIBO-XXXXXX</code> en la casilla de <em>Detalle</em>, <em>Motivo</em> o <em>Concepto</em> del SINPE Móvil bancario.</span>
</div>
</div>
<!-- 3. Destinatario Oficial -->
<div style="display: flex; gap: 10px; align-items: flex-start;">
<div style="width: 22px; height: 22px; border-radius: 50%; background: #dcfce7; color: #166534; font-weight: 900; font-size: 0.72rem; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px;">
3
</div>
<div>
<strong style="color: var(--text-main, #0f172a); display: block; font-size: 0.82rem;">Verificación del Destinatario:</strong>
<span>Transfiera únicamente al número telefónico y titular oficial registrados de la soda escolar. SiboPay nunca le solicitará fondos a cuentas particulares.</span>
</div>
</div>
<!-- 4. Comprobante de Respaldo -->
<div style="display: flex; gap: 10px; align-items: flex-start;">
<div style="width: 22px; height: 22px; border-radius: 50%; background: #dcfce7; color: #166534; font-weight: 900; font-size: 0.72rem; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px;">
4
</div>
<div>
<strong style="color: var(--text-main, #0f172a); display: block; font-size: 0.82rem;">Comprobante de Respaldo:</strong>
<span>Conserve la captura o número de comprobante emitido por su banco. En caso de requerir aclaración, este servirá como comprobante ante la administración de la soda.</span>
</div>
</div>
<!-- 5. Disponibilidad del Saldo -->
<div style="display: flex; gap: 10px; align-items: flex-start;">
<div style="width: 22px; height: 22px; border-radius: 50%; background: #dcfce7; color: #166534; font-weight: 900; font-size: 0.72rem; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px;">
5
</div>
<div>
<strong style="color: var(--text-main, #0f172a); display: block; font-size: 0.82rem;">Disponibilidad Inmediata:</strong>
<span>Una vez validado el pago, los fondos quedan disponibles de inmediato para compras con carné QR o pre-órdenes. El saldo no vence durante el curso lectivo.</span>
</div>
</div>
<!-- 6. No Canjeable por Efectivo -->
<div style="display: flex; gap: 10px; align-items: flex-start;">
<div style="width: 22px; height: 22px; border-radius: 50%; background: #fee2e2; color: #991b1b; font-weight: 900; font-size: 0.72rem; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px;">
6
</div>
<div>
<strong style="color: #991b1b; display: block; font-size: 0.82rem;">No Canjeable por Dinero Real o Efectivo:</strong>
<span>Los fondos recargados corresponden a créditos escolares exclusivos para consumo de alimentos en la soda. <strong>No pueden ser convertidos ni devueltos en dinero en efectivo</strong> bajo ninguna circunstancia.</span>
</div>
</div>
</div>
<!-- Pie de Seguridad y Botón de Aceptar -->
<div style="margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border, #f1f5f9); display: flex; flex-direction: column; gap: 12px;">
<div style="display: flex; align-items: center; justify-content: space-between; font-size: 0.72rem; color: var(--text-muted, #64748b);">
<span style="display: flex; align-items: center; gap: 6px;">
<span style="width: 7px; height: 7px; border-radius: 50%; background: #10b981; display: inline-block;"></span>
<span>Conciliación automática activa 24/7</span>
</span>
<span style="font-weight: 800; color: #0284c7;">SiboPay Protegido</span>
</div>
<button type="button" onclick="closeModalSinpeTerms()" style="width: 100%; padding: 12px; background: linear-gradient(135deg, #16a34a, #15803d); color: white; border: none; border-radius: 12px; font-weight: 900; font-size: 0.95rem; cursor: pointer; box-shadow: 0 4px 10px rgba(22, 163, 74, 0.25);">
Entendido y Aceptar
</button>
</div>
</div>
</div>
<!-- BARRA DE NAVEGACIÓN INFERIOR PWA (MÓVILES) -->
<nav class="pwa-bottom-nav" id="pwaBottomNav" style="display: none;">
<button class="pwa-nav-item active" id="pwaNavMenu" onclick="pwaNavigateTo('menu')">
<span class="pwa-nav-icon"><svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 2v7c0 1.1.9 2 2 2h4a2 2 0 0 0 2-2V2"/><path d="M7 2v20"/><path d="M21 15V2v0a5 5 0 0 0-5 5v6c0 1.1.9 2 2 2h3Zm0 0v7"/></svg></span>
<span class="pwa-nav-label">Menú</span>
</button>
<button class="pwa-nav-item" id="pwaNavQr" onclick="pwaNavigateTo('qr')">
<span class="pwa-nav-icon"><svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="5" height="5" x="3" y="3" rx="1"/><rect width="5" height="5" x="16" y="3" rx="1"/><rect width="5" height="5" x="3" y="16" rx="1"/><path d="M21 16h-3a2 2 0 0 0-2 2v3"/><path d="M21 21v.01"/><path d="M12 7v3a2 2 0 0 1-2 2H7"/><path d="M3 12h.01"/><path d="M12 3h.01"/><path d="M12 16v.01"/><path d="M16 12h1"/><path d="M21 12v.01"/><path d="M12 21v-1"/></svg></span>
<span class="pwa-nav-label">Mi QR</span>
</button>
<button class="pwa-nav-item" id="pwaNavTransfer" onclick="pwaNavigateTo('transfer')">
<span class="pwa-nav-icon"><svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m16 3 4 4-4 4"/><path d="M20 7H4"/><path d="m8 21-4-4 4-4"/><path d="M4 17h16"/></svg></span>
<span class="pwa-nav-label">Transferir</span>
</button>
<button class="pwa-nav-item" id="pwaNavPadres" onclick="pwaNavigateTo('padres')">
<span class="pwa-nav-icon"><svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg></span>
<span class="pwa-nav-label">Padres</span>
</button>
<button class="pwa-nav-item pwa-nav-logout" onclick="logout(true)" title="Cerrar sesión y cambiar de cuenta">
<span class="pwa-nav-icon"><svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/><polyline points="16 17 21 12 16 7"/><line x1="21" x2="9" y1="12" y2="12"/></svg></span>
<span class="pwa-nav-label">Salir</span>
</button>
</nav>
<script src="/js/sounds.js?v=9.6"></script>
<script src="/js/jsQR.js"></script>
<script src="/js/food-icons.js?v=1.1"></script>
<script src="/js/app.js?v=13.0"></script>
</body>
</html>