/* ============ Panel de administración — pensado para el celular ============ */
:root {
    --coral: #FF6B6B;
    --coral-oscuro: #E04F4F;
    --turquesa: #2EC4B6;
    --amarillo: #FFD166;
    --marino: #2D3047;
    --fondo: #F6F4F0;
    --blanco: #FFFFFF;
    --texto-suave: #6B6E80;
    --borde: #E8E4DD;
    --verde: #17A05D;
    --verde-claro: #DFF6EA;
    --rojo: #D64545;
    --rojo-claro: #FDE6E6;
    --radio: 16px;
    --sombra: 0 2px 10px rgba(45, 48, 71, 0.07);
    --alto-menu: 68px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: 'Poppins', -apple-system, 'Segoe UI', sans-serif;
    font-size: 16px;
    background: var(--fondo);
    color: var(--marino);
    line-height: 1.45;
    padding-bottom: calc(var(--alto-menu) + env(safe-area-inset-bottom) + 16px);
}

h1, h2, h3 { font-family: 'Fredoka', 'Poppins', sans-serif; font-weight: 600; margin: 0 0 .4em; line-height: 1.2; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
p { margin: 0 0 .6em; }

/* ---------- Barra superior ---------- */
.barra {
    position: sticky; top: 0; z-index: 50;
    background: var(--marino); color: #fff;
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top));
    min-height: 56px;
}
.barra-marca { font-family: 'Fredoka', sans-serif; font-size: 1.15rem; font-weight: 600; white-space: nowrap; }
.barra-volver { font-size: 2rem; line-height: 1; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; margin-left: -6px; }
.barra-volver:active { background: rgba(255,255,255,.15); }
.barra-titulo { flex: 1; font-size: 1.05rem; margin: 0; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
.barra-acciones { display: flex; gap: 4px; }
.barra-icono { position: relative; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; font-size: 1.2rem; }
.barra-icono:active, .barra-icono:hover { background: rgba(255,255,255,.12); }
.barra-icono b {
    position: absolute; top: 2px; right: 0; background: var(--coral); color: #fff;
    font-size: .7rem; min-width: 18px; height: 18px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px;
}

/* ---------- Menú inferior (celular) / superior (computadora) ---------- */
.menu {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    background: #fff; border-top: 1px solid var(--borde);
    display: flex; justify-content: space-around;
    padding-bottom: env(safe-area-inset-bottom);
    height: calc(var(--alto-menu) + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 16px rgba(45,48,71,.06);
}
.menu a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    font-size: .72rem; font-weight: 600; color: var(--texto-suave);
}
.menu-icono { font-size: 1.45rem; line-height: 1; filter: grayscale(1); opacity: .7; transition: .15s; }
.menu a.activo { color: var(--coral); }
.menu a.activo .menu-icono { filter: none; opacity: 1; transform: translateY(-1px) scale(1.08); }

@media (min-width: 900px) {
    body { padding-bottom: 30px; }
    .menu {
        position: sticky; top: 56px; bottom: auto; height: auto; padding: 0 20px;
        justify-content: center; gap: 6px; border-top: none; border-bottom: 1px solid var(--borde); box-shadow: none; z-index: 40;
    }
    .menu a { flex: 0 0 auto; flex-direction: row; gap: 8px; font-size: .92rem; padding: 14px 18px; border-bottom: 3px solid transparent; }
    .menu a.activo { border-bottom-color: var(--coral); }
    .menu-icono { font-size: 1.1rem; }
}

/* ---------- Contenido ---------- */
.contenido { max-width: 760px; margin: 0 auto; padding: 16px; }
.contenido.ancho { max-width: 1100px; }

.tarjeta {
    background: var(--blanco); border-radius: var(--radio); box-shadow: var(--sombra);
    padding: 18px; margin-bottom: 14px;
}
.tarjeta-titulo { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.tarjeta-titulo h2, .tarjeta-titulo h3 { margin: 0; }
.seccion-titulo { font-size: .82rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--texto-suave); margin: 22px 4px 10px; }

.suave { color: var(--texto-suave); }
.pequeno { font-size: .85rem; }
.centro { text-align: center; }
.vacio { text-align: center; color: var(--texto-suave); padding: 28px 10px; }
.vacio .grande { font-size: 2.6rem; display: block; margin-bottom: 6px; }

/* ---------- Avisos ---------- */
.aviso { padding: 14px 16px; border-radius: 12px; margin-bottom: 14px; font-weight: 600; transition: opacity .5s, max-height .5s, margin .5s, padding .5s; overflow: hidden; max-height: 200px; }
.aviso-ok { background: var(--verde-claro); color: #0F6E3F; }
.aviso-error { background: var(--rojo-claro); color: #A12E2E; }
.aviso-info { background: #EEF3FF; color: #34418C; font-weight: 500; }
.aviso.ocultar { opacity: 0; max-height: 0; padding-top: 0; padding-bottom: 0; margin: 0; }

/* ---------- Botones ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 48px; padding: 12px 20px; border-radius: 14px; border: 2px solid transparent;
    font-family: inherit; font-size: 1rem; font-weight: 600; cursor: pointer; text-align: center;
    transition: transform .1s, background .15s, opacity .15s; -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .6; }
.btn-primario { background: var(--coral); color: #fff; }
.btn-primario:hover { background: var(--coral-oscuro); }
.btn-oscuro { background: var(--marino); color: #fff; }
.btn-verde { background: var(--verde); color: #fff; }
.btn-whatsapp { background: #25D366; color: #fff; }
.btn-claro { background: #fff; color: var(--marino); border-color: var(--borde); }
.btn-peligro { background: #fff; color: var(--rojo); border-color: #F3C9C9; }
.btn-chico { min-height: 38px; padding: 7px 14px; font-size: .88rem; border-radius: 11px; }
.btn-bloque { width: 100%; }
.botones { display: flex; gap: 10px; flex-wrap: wrap; }
.botones > .btn { flex: 1 1 auto; }

/* Accesos grandes del inicio */
.accesos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.acceso {
    background: #fff; border-radius: var(--radio); box-shadow: var(--sombra);
    padding: 16px 12px; display: flex; flex-direction: column; align-items: center; gap: 6px;
    font-weight: 600; text-align: center; font-size: .95rem; border: 2px solid transparent;
}
.acceso .grande { font-size: 1.9rem; line-height: 1; }
.acceso:active { transform: scale(.97); }
.acceso.destacado { background: var(--coral); color: #fff; }

/* ---------- Números del inicio ---------- */
.numeros { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.numero { background: #fff; border-radius: var(--radio); box-shadow: var(--sombra); padding: 14px 16px; }
.numero .etiqueta { font-size: .8rem; color: var(--texto-suave); font-weight: 600; }
.numero .valor { font-family: 'Fredoka', sans-serif; font-size: 1.55rem; font-weight: 600; line-height: 1.2; margin-top: 2px; }
.numero .detalle { font-size: .78rem; color: var(--texto-suave); }
.numero.principal { grid-column: 1 / -1; background: var(--marino); color: #fff; }
.numero.principal .etiqueta, .numero.principal .detalle { color: rgba(255,255,255,.75); }
.numero.principal .valor { font-size: 2.1rem; color: var(--amarillo); }
@media (min-width: 640px) { .numeros { grid-template-columns: repeat(4, 1fr); } .numero.principal { grid-column: span 1; } .accesos { grid-template-columns: repeat(4, 1fr); } }

/* ---------- Listas ---------- */
.lista { background: #fff; border-radius: var(--radio); box-shadow: var(--sombra); overflow: hidden; margin-bottom: 14px; }
.fila { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--borde); }
.fila:last-child { border-bottom: none; }
a.fila:active, a.fila:hover { background: #FBFAF8; }
.fila-principal { flex: 1; min-width: 0; }
.fila-titulo { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fila-sub { font-size: .84rem; color: var(--texto-suave); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fila-derecha { text-align: right; flex-shrink: 0; }
.fila-monto { font-weight: 700; font-family: 'Fredoka', sans-serif; font-size: 1.1rem; }
.fila-flecha { color: #C5C1BA; font-size: 1.4rem; }
.avatar {
    width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
    display: grid; place-items: center; font-weight: 700; font-family: 'Fredoka', sans-serif; font-size: 1.05rem;
    background: #FFE3D6; color: #B5533A;
}
.miniatura { width: 54px; height: 54px; border-radius: 12px; object-fit: cover; flex-shrink: 0; background: var(--fondo); }

.chip { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.chip-debe { background: var(--rojo-claro); color: #A12E2E; }
.chip-pagado { background: var(--verde-claro); color: #0F6E3F; }
.chip-gris { background: #EFEDE9; color: var(--texto-suave); }
.chip-amarillo { background: #FFF1CC; color: #8A6400; }
.chip-turquesa { background: #D9F5F2; color: #137A71; }

.debe { color: var(--rojo); }
.pagado { color: var(--verde); }

/* ---------- Buscador ---------- */
.buscador { position: relative; margin-bottom: 14px; }
.buscador input {
    width: 100%; height: 52px; padding: 0 16px 0 46px; border-radius: 14px; border: 2px solid var(--borde);
    font-family: inherit; font-size: 1rem; background: #fff;
}
.buscador input:focus { outline: none; border-color: var(--turquesa); }
.buscador::before { content: '🔍'; position: absolute; left: 16px; top: 50%; transform: translateY(-50%); font-size: 1.1rem; opacity: .6; }

.pestanas { display: flex; gap: 8px; margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; }
.pestanas::-webkit-scrollbar { display: none; }
.pestanas a { padding: 9px 16px; border-radius: 20px; background: #fff; font-weight: 600; font-size: .9rem; white-space: nowrap; border: 2px solid var(--borde); }
.pestanas a.activo { background: var(--marino); color: #fff; border-color: var(--marino); }

/* ---------- Formularios ---------- */
.campo { margin-bottom: 16px; }
.campo > label, .campo > .etiqueta { display: block; font-weight: 600; margin-bottom: 6px; font-size: .95rem; }
.campo .ayuda { font-size: .82rem; color: var(--texto-suave); margin-top: 5px; }
.campo input[type=text], .campo input[type=tel], .campo input[type=number], .campo input[type=date],
.campo input[type=password], .campo input[type=search], .campo select, .campo textarea {
    width: 100%; min-height: 50px; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--borde);
    font-family: inherit; font-size: 1rem; background: #fff; color: var(--marino); -webkit-appearance: none; appearance: none;
}
.campo select { background-image: linear-gradient(45deg, transparent 50%, #888 50%), linear-gradient(135deg, #888 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
.campo textarea { min-height: 90px; resize: vertical; }
.campo input:focus, .campo select:focus, .campo textarea:focus { outline: none; border-color: var(--turquesa); }
.campo-dinero { position: relative; }
.campo-dinero::before { content: '$'; position: absolute; left: 15px; top: 50%; transform: translateY(-50%); font-weight: 700; color: var(--texto-suave); }
.campo-dinero input { padding-left: 30px !important; font-weight: 600; font-size: 1.1rem !important; }
.dos-columnas { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dos-columnas .campo { margin-bottom: 0; }
.dos-columnas + .campo, .dos-columnas + .dos-columnas { margin-top: 16px; }
.obligatorio::after { content: ' *'; color: var(--coral); }

.pildoras { display: flex; flex-wrap: wrap; gap: 8px; }
.pildora input { position: absolute; opacity: 0; pointer-events: none; }
.pildora span {
    display: inline-block; padding: 10px 16px; border-radius: 12px; border: 2px solid var(--borde); background: #fff;
    font-weight: 600; font-size: .92rem; cursor: pointer; user-select: none;
}
.pildora input:checked + span { background: var(--marino); color: #fff; border-color: var(--marino); }
.pildora input:focus-visible + span { outline: 3px solid var(--turquesa); }

.interruptor { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--borde); cursor: pointer; }
.interruptor:last-of-type { border-bottom: none; }
.interruptor input { width: 0; height: 0; opacity: 0; position: absolute; }
.interruptor .palanca { width: 52px; height: 30px; background: #D8D4CC; border-radius: 15px; position: relative; flex-shrink: 0; transition: .2s; }
.interruptor .palanca::after { content: ''; position: absolute; width: 24px; height: 24px; top: 3px; left: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.interruptor input:checked + .palanca { background: var(--verde); }
.interruptor input:checked + .palanca::after { left: 25px; }
.interruptor .texto b { display: block; }
.interruptor .texto small { color: var(--texto-suave); }

/* Resultado de búsqueda dentro de formularios */
.sugerencias { border: 2px solid var(--borde); border-radius: 12px; margin-top: 6px; overflow: hidden; background: #fff; max-height: 280px; overflow-y: auto; }
.sugerencias button { display: flex; width: 100%; text-align: left; gap: 10px; align-items: center; background: #fff; border: none; border-bottom: 1px solid var(--borde); padding: 12px 14px; font: inherit; cursor: pointer; }
.sugerencias button:last-child { border-bottom: none; }
.sugerencias button:hover, .sugerencias button:focus { background: #FFF5F0; outline: none; }
.elegido { display: flex; align-items: center; gap: 12px; border: 2px solid var(--turquesa); background: #F0FBFA; padding: 10px 12px; border-radius: 12px; }
.elegido .fila-principal { min-width: 0; }

/* Resumen de la venta antes de guardar */
.resumen-calculo { background: var(--fondo); border-radius: 12px; padding: 12px 14px; font-size: .95rem; }
.resumen-calculo div { display: flex; justify-content: space-between; padding: 3px 0; }
.resumen-calculo .total { border-top: 1px dashed #CFCAC0; margin-top: 4px; padding-top: 7px; font-weight: 700; }

/* ---------- Ficha de cliente / venta ---------- */
.ficha-cabeza { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.ficha-cabeza .avatar { width: 58px; height: 58px; font-size: 1.4rem; }
.ficha-cabeza h2 { margin: 0; font-size: 1.4rem; }

.totales { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.totales div { background: var(--fondo); border-radius: 12px; padding: 10px; text-align: center; }
.totales small { display: block; font-size: .74rem; color: var(--texto-suave); font-weight: 600; }
.totales b { font-family: 'Fredoka', sans-serif; font-size: 1.2rem; font-weight: 600; }

.venta { border: 2px solid var(--borde); border-radius: 14px; padding: 14px; margin-bottom: 12px; background: #fff; }
.venta.con-deuda { border-color: #F5CACA; }
.venta-cabeza { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.venta-cabeza h3 { margin: 0 0 2px; }
.barra-progreso { height: 10px; border-radius: 5px; background: #EFEDE9; overflow: hidden; margin: 12px 0 6px; }
.barra-progreso span { display: block; height: 100%; background: linear-gradient(90deg, var(--turquesa), var(--verde)); border-radius: 5px; }
.abonos { margin: 10px 0 0; padding: 0; list-style: none; font-size: .9rem; }
.abonos li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 0; border-top: 1px dashed var(--borde); }
.abonos .borrar { background: none; border: none; color: #B9B4AB; font-size: 1rem; cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.abonos .borrar:hover { color: var(--rojo); background: var(--rojo-claro); }
details.mas summary { cursor: pointer; color: var(--texto-suave); font-size: .88rem; font-weight: 600; list-style: none; padding: 6px 0; }
details.mas summary::-webkit-details-marker { display: none; }
details.mas summary::before { content: '▸ '; }
details.mas[open] summary::before { content: '▾ '; }

/* Ventana para registrar abono */
.hoja-fondo { position: fixed; inset: 0; background: rgba(20,22,35,.5); z-index: 100; display: none; align-items: flex-end; justify-content: center; }
.hoja-fondo.abierta { display: flex; }
.hoja { background: #fff; width: 100%; max-width: 520px; border-radius: 22px 22px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); max-height: 92vh; overflow-y: auto; animation: subir .2s ease-out; }
@keyframes subir { from { transform: translateY(40px); opacity: .5; } to { transform: none; opacity: 1; } }
@media (min-width: 640px) { .hoja-fondo { align-items: center; } .hoja { border-radius: 22px; } }
.hoja-cabeza { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.hoja-cerrar { background: var(--fondo); border: none; width: 38px; height: 38px; border-radius: 50%; font-size: 1.1rem; cursor: pointer; }
.montos-rapidos { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.montos-rapidos button { background: var(--fondo); border: none; border-radius: 10px; padding: 8px 12px; font: inherit; font-weight: 600; font-size: .88rem; cursor: pointer; }

/* ---------- Productos ---------- */
.producto-fila.oculto { opacity: .55; }
.foto-previa { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 10px; margin-top: 10px; }
.foto-previa > div { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; border: 2px solid var(--borde); background: var(--fondo); }
.foto-previa img { width: 100%; height: 100%; object-fit: cover; }
.foto-previa .quitar { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; border: none; background: rgba(214,69,69,.92); color: #fff; cursor: pointer; font-size: .85rem; }
.foto-previa .etiqueta-principal { position: absolute; left: 4px; bottom: 4px; background: var(--coral); color: #fff; font-size: .68rem; font-weight: 700; padding: 2px 7px; border-radius: 8px; }
.subir-foto { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border: 2px dashed #CFCAC0; border-radius: 14px; padding: 22px 14px; text-align: center; cursor: pointer; background: #FCFBF9; color: var(--texto-suave); font-weight: 600; }
.subir-foto .grande { font-size: 2rem; }
.subir-foto input { display: none; }
.tallas-rapidas { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tallas-rapidas button { min-width: 44px; padding: 8px 6px; border-radius: 10px; border: 2px solid var(--borde); background: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.tallas-rapidas button.si { background: var(--marino); color: #fff; border-color: var(--marino); }

/* ---------- Asistente ---------- */
.chat { display: flex; flex-direction: column; gap: 10px; padding-bottom: 10px; min-height: 40vh; }
.burbuja { max-width: 86%; padding: 11px 14px; border-radius: 18px; white-space: pre-wrap; word-wrap: break-word; font-size: .97rem; }
.burbuja.yo { align-self: flex-end; background: var(--marino); color: #fff; border-bottom-right-radius: 6px; }
.burbuja.ia { align-self: flex-start; background: #fff; box-shadow: var(--sombra); border-bottom-left-radius: 6px; }
.burbuja.pensando { color: var(--texto-suave); font-style: italic; }
.burbuja.error { background: var(--rojo-claro); color: #A12E2E; }
.propuesta { align-self: stretch; background: #FFF8E6; border: 2px solid var(--amarillo); border-radius: 16px; padding: 14px; }
.propuesta b.titulo { display: block; margin-bottom: 6px; }
.propuesta .botones { margin-top: 12px; }
.chat-entrada {
    position: sticky; bottom: calc(var(--alto-menu) + env(safe-area-inset-bottom) + 6px);
    display: flex; gap: 8px; background: var(--fondo); padding: 8px 0;
}
@media (min-width: 900px) { .chat-entrada { bottom: 10px; } }
.chat-entrada textarea { flex: 1; min-height: 52px; max-height: 140px; padding: 14px 16px; border-radius: 16px; border: 2px solid var(--borde); font: inherit; resize: none; }
.chat-entrada textarea:focus { outline: none; border-color: var(--turquesa); }
.chat-entrada .btn { min-width: 56px; padding: 0 16px; }
.sugeridos { display: flex; gap: 8px; flex-wrap: wrap; }
.sugeridos button { background: #fff; border: 2px solid var(--borde); border-radius: 14px; padding: 9px 13px; font: inherit; font-size: .88rem; cursor: pointer; text-align: left; }
.sugeridos button:hover { border-color: var(--turquesa); }
.btn-microfono.grabando { background: var(--rojo); color: #fff; animation: latido 1s infinite; }
@keyframes latido { 50% { opacity: .7; } }

/* ---------- Login ---------- */
.login-fondo { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(130deg, var(--coral), var(--amarillo)); }
body.login { padding-bottom: 0; }
.login-caja { background: #fff; border-radius: 22px; padding: 32px 24px; width: 100%; max-width: 380px; box-shadow: 0 20px 50px rgba(45,48,71,.2); }
.login-caja h1 { text-align: center; font-size: 1.5rem; }
.ver-clave { position: relative; }
.ver-clave button { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: none; border: none; font-size: 1.2rem; cursor: pointer; padding: 6px; }

/* ---------- Mensajes ---------- */
.mensaje-nuevo { border-left: 5px solid var(--coral); }

.campo input::placeholder, .campo textarea::placeholder, .buscador input::placeholder, .chat-entrada textarea::placeholder { color: #B8B3AA; font-weight: 400; }
@media (max-width: 639px) { .numeros .numero:nth-child(4) { grid-column: 1 / -1; } }
