/*
    Estilos compartidos por TODAS las páginas de Inversiones Caleb. Es la misma
    base de Taller Rodríguez y Apiarios, con colores propios y lo que necesita
    el punto de venta (tarjetas de productos, carrito, escáner).
    Los colores principales están como variables aquí arriba: cambiando uno
    aquí, cambia en todo el sistema.
*/

:root {
    --menu-fondo: #0f1d2b;        /* fondo del menú */
    --menu-linea: #1d3044;        /* líneas y hover del menú */
    --acento: #0d8a6a;            /* color principal (botones, menú activo) */
    --acento-oscuro: #0a6e55;
    --acento-claro: #e3f5ef;      /* fondos suaves del acento */
    --acento-texto: #08664e;      /* texto sobre fondos claros */
    --texto-menu: #d6e0ea;
    --texto-menu-suave: #8aa0b5;
    --verde: #16a35f;
    --rojo: #d63c3c;
    --azul: #2f6fe0;
    --naranja: #d9822b;
    --fondo: #f3f5f7;
    --borde: #e2e7ec;
    --texto: #16202a;
    --texto-suave: #6b7785;
    /* Colores de las gráficas (validados para daltonismo: azul y naranja) */
    --serie-1: #2a78d6;
    --serie-2: #eb6834;
    --serie-3: #8b8f96;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    background-color: var(--fondo);
    color: var(--texto);
}
.contenedor { display: flex; min-height: 100vh; }
button, input, select, textarea { font-family: inherit; }

/* ---------- Menú lateral ---------- */
.menu {
    width: 240px; background-color: var(--menu-fondo); color: white;
    display: flex; flex-direction: column; padding: 18px 0; flex-shrink: 0;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
    /* Nunca se desplaza de lado: con el zoom del navegador el menú se corría
       y quedaban cortados el logo y los textos */
    overflow-x: hidden;
}
.menu .marca > div:nth-child(2) { min-width: 0; }
.menu nav a { overflow-wrap: anywhere; }
.menu .marca { display: flex; align-items: center; gap: 10px; padding: 0 18px 16px 18px; border-bottom: 1px solid var(--menu-linea); }
.menu .logo {
    width: 38px; height: 38px; border-radius: 10px; background: var(--acento);
    display: flex; align-items: center; justify-content: center; font-size: 20px; color: white; flex-shrink: 0;
}
.menu .marca h1 { font-size: 14px; margin: 0; letter-spacing: 0.5px; }
.menu .marca p { font-size: 11px; margin: 0; color: var(--texto-menu-suave); }
.menu .boton-menu { display: none; margin-left: auto; background: none; border: none; color: white; font-size: 24px; cursor: pointer; }
.menu nav { flex: 1; padding-top: 4px; }
.menu nav .grupo { font-size: 10px; letter-spacing: 1.2px; color: var(--texto-menu-suave); padding: 14px 18px 4px 18px; text-transform: uppercase; }
.menu nav a { display: flex; align-items: center; gap: 12px; color: var(--texto-menu); text-decoration: none; padding: 9px 18px; font-size: 14px; }
.menu nav a:hover { background-color: var(--menu-linea); }
.menu nav a.activo {
    background-color: var(--acento); color: white; font-weight: bold; border-radius: 8px;
    margin: 0 10px; padding: 9px 8px;
}
.menu nav a.destacado { color: #7fe0c2; font-weight: bold; }
.menu nav a.activo.destacado { color: white; }
.menu nav a i.ti { font-size: 18px; width: 20px; text-align: center; }
.menu .usuario { padding: 14px 18px; border-top: 1px solid var(--menu-linea); font-size: 13px; }
.menu .usuario .nombre { font-weight: bold; }
.menu .usuario .rol { color: var(--texto-menu-suave); font-size: 12px; }
.menu .usuario .enlaces { display: flex; gap: 14px; margin-top: 8px; }
.menu .usuario .enlaces a { text-decoration: none; font-size: 13px; color: var(--texto-menu); }
.menu .salir { color: #ff8a7a !important; }

/* Aviso a pantalla completa cuando no hay permiso */
.sin-permiso { text-align: center; padding: 80px 20px; color: #888; }
.sin-permiso i.ti { font-size: 48px; color: var(--acento); }
.sin-permiso h2 { color: var(--texto); margin: 12px 0 6px 0; }

/* ---------- Contenido ---------- */
.contenido { flex: 1; padding: 24px 28px; min-width: 0; }
.encabezado { margin-bottom: 18px; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.encabezado h2 { margin: 0; font-size: 22px; }
.encabezado p { margin: 2px 0 0 0; color: var(--texto-suave); font-size: 13px; }

.barra-superior { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.buscador { flex: 1; min-width: 220px; display: flex; align-items: center; gap: 8px; background: white; border: 1px solid var(--borde); border-radius: 10px; padding: 10px 14px; }
.buscador input { border: none; outline: none; flex: 1; font-size: 15px; min-width: 0; background: transparent; }
.buscador .boton-escanear { border: none; background: var(--acento-claro); color: var(--acento-texto); border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 18px; }
.filtros { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filtros select, .filtros input { padding: 10px 12px; border-radius: 8px; border: 1px solid var(--borde); background: white; font-size: 14px; }
.lado-derecho { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.total-lista { font-size: 14px; }

.btn { text-decoration: none; border: none; padding: 11px 16px; border-radius: 8px; font-size: 14px; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; justify-content: center; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-principal { background: var(--acento); color: white; font-weight: bold; }
.btn-principal:hover:not(:disabled) { background: var(--acento-oscuro); }
.btn-secundario { background: #e9edf1; color: #2b3640; }
.btn-secundario:hover:not(:disabled) { background: var(--acento-claro); }
.btn-peligro { background: #fdecec; color: #b42323; }
.btn-peligro:hover:not(:disabled) { background: #f9d7d7; }
.btn-verde { background: var(--verde); color: white; font-weight: bold; }
.btn-pequeno { padding: 6px 10px; font-size: 12px; border-radius: 6px; }
.btn-grande { padding: 15px 20px; font-size: 17px; border-radius: 10px; }

/* Pestañas */
.pestanas { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.pestanas button { background: white; border: 1px solid var(--borde); padding: 8px 14px; border-radius: 20px; cursor: pointer; font-size: 13px; color: #4a5560; }
.pestanas button.activa { background: var(--acento); border-color: var(--acento); color: white; font-weight: bold; }
.pestanas button .cuenta { opacity: 0.75; margin-left: 4px; }

/* ---------- Tablas ---------- */
.tabla-contenedor { background: white; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th { text-align: left; font-size: 12px; color: var(--texto-suave); padding: 12px 14px; border-bottom: 1px solid #eef1f4; white-space: nowrap; text-transform: uppercase; letter-spacing: 0.3px; }
thead th.ordenable { cursor: pointer; user-select: none; }
thead th.ordenable:hover { color: var(--acento-texto); }
thead th.ordenado { color: var(--acento-texto); }
tbody td { padding: 11px 14px; font-size: 14px; border-bottom: 1px solid #f2f4f6; vertical-align: middle; }
tbody tr:hover { background: #f8fbfa; }
tbody tr.clic { cursor: pointer; }
tfoot td { padding: 12px 14px; font-size: 14px; font-weight: bold; border-top: 2px solid #eef1f4; }
.numero { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.monto-ingreso { color: var(--verde); font-weight: bold; }
.monto-egreso { color: var(--rojo); font-weight: bold; }
.monto-pendiente { color: var(--naranja); font-weight: bold; }
.secundario { font-size: 12px; color: var(--texto-suave); margin-top: 2px; }
.acciones-fila { display: flex; gap: 12px; }
.acciones-fila span { cursor: pointer; color: #6b7785; font-size: 18px; }
.acciones-fila span:hover { color: var(--acento); }
.sin-resultados { padding: 30px; text-align: center; color: #999; }
.fila-anulada td { color: #aaa; text-decoration: line-through; }
.fila-anulada td .badge { text-decoration: none; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 12px; font-size: 12px; white-space: nowrap; background: var(--acento-claro); color: var(--acento-texto); }
.badge-verde { background: #e4f8ec; color: #0f7a46; }
.badge-rojo { background: #fdecec; color: #b42323; }
.badge-azul { background: #eaf0fe; color: #2d48d6; }
.badge-naranja { background: #fdf0e1; color: #9a5512; }
.badge-gris, .badge-inactivo { background: #eee; color: #777; }

/* Miniatura de producto (tablas y listas) */
.mini-foto { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: #eef1f4; flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: #a5b0bb; font-size: 20px; }
.celda-producto { display: flex; align-items: center; gap: 10px; }

/* ---------- Modales ---------- */
.fondo-modal { display: none; position: fixed; inset: 0; background: rgba(10,20,30,0.55); align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.fondo-modal.abierto { display: flex; }
.modal { background: white; border-radius: 14px; padding: 22px 26px; width: 520px; max-width: 100%; max-height: 92vh; overflow-y: auto; }
.modal.ancho { width: 820px; }
.modal-encabezado { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid #eef1f4; gap: 10px; }
.modal-encabezado h3 { margin: 0; }
.cerrar-x { cursor: pointer; font-size: 20px; color: #888; border: none; background: none; }
.fila-doble { display: flex; gap: 14px; }
.campo { flex: 1; margin-bottom: 14px; min-width: 0; }
.campo label { display: block; font-size: 13px; margin-bottom: 5px; font-weight: 600; color: #34404c; }
.campo input, .campo select, .campo textarea { width: 100%; padding: 10px 11px; border: 1px solid #d5dce3; border-radius: 8px; font-size: 15px; background: white; }
.campo input:focus, .campo select:focus, .campo textarea:focus { outline: 2px solid var(--acento-claro); border-color: var(--acento); }
.campo input:disabled { background: #f5f5f5; }
.campo-check { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-bottom: 14px; cursor: pointer; }
.campo-check input { width: 18px; height: 18px; }
.con-boton { display: flex; gap: 6px; }
.con-boton input { flex: 1; }
.ayuda { font-size: 12px; color: var(--texto-suave); margin-top: 4px; }
.separador { border: none; border-top: 1px solid #eef1f4; margin: 14px 0; }
.botones-modal { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.mensaje-error { color: var(--rojo); background: #fdecec; border-radius: 8px; font-size: 13px; padding: 9px 12px; margin-bottom: 12px; display: none; }
.resumen-calculo { background: var(--acento-claro); border-radius: 10px; padding: 10px 14px; font-size: 14px; margin-bottom: 14px; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.subtitulo-seccion { font-size: 13px; font-weight: bold; color: var(--texto-suave); text-transform: uppercase; letter-spacing: 0.5px; margin: 6px 0 10px 0; }

.aviso { background: #fdf3e3; color: #74460f; border-radius: 10px; padding: 12px 16px; font-size: 14px; margin-bottom: 16px; display: none; }
.aviso a { color: #74460f; font-weight: bold; }
.aviso.visible { display: block; }

/* ---------- Tarjetas ---------- */
.tarjetas-resumen { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 20px; }
.tarjeta-resumen { background: white; border-radius: 12px; padding: 16px 18px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); display: flex; gap: 14px; align-items: center; }
.tarjeta-resumen .icono { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.tarjeta-resumen p { margin: 0; font-size: 13px; color: var(--texto-suave); }
.tarjeta-resumen h3 { margin: 3px 0 0 0; font-size: 21px; font-variant-numeric: tabular-nums; }
.tarjeta-resumen .detalle { font-size: 12px; color: #98a2ad; margin-top: 2px; }
.icono-ingreso { background: #e4f8ec; color: var(--verde); }
.icono-egreso { background: #fdecec; color: var(--rojo); }
.icono-balance { background: var(--acento-claro); color: var(--acento-texto); }
.icono-azul { background: #eaf0fe; color: var(--azul); }
.icono-naranja { background: #fdf0e1; color: var(--naranja); }

.tarjeta { background: white; border-radius: 12px; padding: 18px 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); margin-bottom: 18px; min-width: 0; }
.tarjeta h3 { margin: 0 0 4px 0; font-size: 16px; }
.tarjeta .subtitulo { margin: 0 0 14px 0; font-size: 13px; color: var(--texto-suave); }
.tarjeta .tabla-contenedor { box-shadow: none; border: 1px solid #eef1f4; }
.tarjeta-encabezado { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.rejilla-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 18px; }
.rejilla-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }

/* Tabla de dos columnas "concepto ........ monto" (caja, reportes) */
.cuadre { width: 100%; border-collapse: collapse; }
.cuadre td { padding: 7px 0; border-bottom: 1px solid #f2f4f6; font-size: 14px; }
.cuadre td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.cuadre .total td { font-weight: bold; font-size: 17px; border-top: 2px solid #dfe5ea; border-bottom: none; padding-top: 10px; }

/* Barrita horizontal de porcentaje */
.barra-porcentaje { display: flex; align-items: center; gap: 8px; min-width: 130px; }
.fondo-barra { flex: 1; height: 8px; background: #eef1f4; border-radius: 4px; overflow: hidden; }
.relleno-barra { height: 100%; border-radius: 4px; background: var(--acento); }
.barra-porcentaje span { font-size: 12px; color: var(--texto-suave); width: 46px; text-align: right; font-variant-numeric: tabular-nums; }

.presets { display: flex; gap: 6px; flex-wrap: wrap; }
.presets button { background: #e9edf1; border: none; padding: 9px 12px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.presets button:hover, .presets button.activa { background: var(--acento-claro); color: var(--acento-texto); }

/* Formulario de una sola línea (Configuración) */
.agregar-linea { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.agregar-linea input, .agregar-linea select { flex: 1; min-width: 120px; padding: 9px 10px; border: 1px solid #d5dce3; border-radius: 8px; font-size: 14px; }

/* Tabla de permisos (pantalla de Usuarios) */
table.tabla-permisos th { padding: 8px; font-size: 11px; text-align: center; }
table.tabla-permisos th:first-child { text-align: left; }
table.tabla-permisos td { padding: 8px; font-size: 13px; text-align: center; border-bottom: 1px solid #f2f4f6; }
table.tabla-permisos td:first-child { text-align: left; font-weight: bold; }
table.tabla-permisos input { width: auto; cursor: pointer; transform: scale(1.2); }
table.tabla-permisos .no-aplica { color: #ccc; }
table.tabla-permisos .ayuda-permiso { display: block; font-size: 10px; color: #98a2ad; font-weight: normal; }
.permisos-resumen { font-size: 12px; color: #666; white-space: normal; }

/* ---------- Buscador con lista desplegable (clientes y productos) ---------- */
.selector { position: relative; }
.selector .caja-busqueda { position: relative; }
.selector .caja-busqueda > i.ti { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: #999; }
.selector .caja-busqueda input { padding-left: 34px; }
.lista-opciones {
    display: none; position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30;
    background: white; border: 1px solid var(--borde); border-radius: 10px; box-shadow: 0 10px 28px rgba(0,0,0,0.14);
    max-height: 300px; overflow-y: auto;
}
.lista-opciones.abierta { display: block; }
.opcion { padding: 9px 12px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; align-items: center; font-size: 14px; border-bottom: 1px solid #f3f5f7; }
.opcion:last-child { border-bottom: none; }
.opcion:hover, .opcion.marcada { background: var(--acento-claro); }
.opcion .secundario { margin: 0; }
.opcion-nuevo { color: var(--acento-texto); font-weight: bold; justify-content: flex-start; }
.lista-opciones .vacia { padding: 12px; color: #999; font-size: 13px; text-align: center; }
.elegido {
    display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--borde);
    border-radius: 8px; background: #fbfdfc; min-height: 42px;
}
.elegido .icono-circulo { width: 30px; height: 30px; border-radius: 50%; background: var(--acento); color: white; display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 13px; flex-shrink: 0; }
.elegido .datos { flex: 1; min-width: 0; line-height: 1.3; }
.elegido .datos strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.elegido button { background: none; border: none; color: var(--acento-texto); cursor: pointer; font-size: 13px; white-space: nowrap; }

/* ---------- Líneas editables (compras y apartados) ---------- */
.lineas-editables { width: 100%; }
.lineas-editables td { padding: 6px 6px; vertical-align: middle; }
.lineas-editables input, .lineas-editables select { width: 100%; padding: 7px 8px; border: 1px solid #d5dce3; border-radius: 6px; font-size: 14px; min-width: 70px; }

/* ---------- Escáner de códigos (cámara) ---------- */
.zona-escaner { width: 100%; border-radius: 12px; overflow: hidden; background: #000; min-height: 240px; }
.zona-escaner video { width: 100% !important; }
.ultimo-escaneo { margin-top: 10px; padding: 10px 12px; border-radius: 8px; background: var(--acento-claro); color: var(--acento-texto); font-size: 14px; display: none; }
.ultimo-escaneo.error { background: #fdecec; color: #b42323; }

/* ---------- Fotos ---------- */
.zona-foto { display: flex; gap: 14px; align-items: center; }
.zona-foto .previa { width: 96px; height: 96px; border-radius: 12px; background: #eef1f4; display: flex; align-items: center; justify-content: center; overflow: hidden; color: #a5b0bb; font-size: 34px; flex-shrink: 0; }
.zona-foto .previa img { width: 100%; height: 100%; object-fit: cover; }
.visor { display: none; position: fixed; inset: 0; background: rgba(5,10,15,0.92); z-index: 200; align-items: center; justify-content: center; cursor: zoom-out; }
.visor.abierto { display: flex; }
.visor img { max-width: 94vw; max-height: 88vh; border-radius: 8px; }

/* ---------- Gráficas ---------- */
.grafica { position: relative; width: 100%; }
.grafica svg { display: block; width: 100%; height: auto; overflow: visible; }
.grafica .eje { font-size: 11px; fill: #8a95a1; }
.grafica .linea-guia { stroke: #eef1f4; stroke-width: 1; }
.grafica .linea-base { stroke: #cfd6dd; stroke-width: 1; }
.grafica .zona-hover { fill: transparent; cursor: pointer; }
.grafica .zona-hover:hover { fill: rgba(0,0,0,0.035); }
.leyenda { display: flex; gap: 16px; font-size: 13px; color: #4a5560; margin-bottom: 10px; flex-wrap: wrap; }
.leyenda span { display: inline-flex; align-items: center; gap: 6px; }
.leyenda i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.tooltip { position: absolute; pointer-events: none; background: #16202a; color: white; border-radius: 8px; padding: 8px 11px; font-size: 12px; line-height: 1.6; white-space: nowrap; display: none; z-index: 5; box-shadow: 0 4px 14px rgba(0,0,0,0.2); }
.tooltip i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; margin-right: 6px; }

/* ---------- Alertas ---------- */
.lista-alertas { display: flex; flex-direction: column; gap: 8px; }
.alerta { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; font-size: 14px; background: #f7f9fa; text-decoration: none; color: inherit; }
.alerta i.ti { font-size: 20px; }
.alerta .derecha { margin-left: auto; font-weight: bold; white-space: nowrap; }
.alerta-roja { background: #fdf0f0; }
.alerta-roja i.ti { color: var(--rojo); }
.alerta-naranja { background: #fdf3e3; }
.alerta-naranja i.ti { color: var(--naranja); }
.alerta-verde { background: #e9f8f1; }
.alerta-verde i.ti { color: var(--verde); }

i.ti { vertical-align: -2px; }
.oculto { display: none !important; }

/* ---------- Mensajito flotante ("Venta guardada") ---------- */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: #16202a; color: white; padding: 12px 18px; border-radius: 10px; font-size: 14px; z-index: 300; opacity: 0; transition: all 0.25s; pointer-events: none; max-width: 90vw; }
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: #b42323; }

/* ---------- Impresión ---------- */
.solo-impresion { display: none; }
@media print {
    body { background: white; }
    .menu, .no-imprimir, .barra-superior, .presets { display: none !important; }
    .solo-impresion { display: block; }
    .contenido { padding: 0; }
    .tarjeta, .tarjeta-resumen { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
    .rejilla-2, .rejilla-3 { display: block; }
    * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- Celular: el menú se vuelve una barra con botón ---------- */
@media (max-width: 860px) {
    .contenedor { flex-direction: column; }
    .menu { width: 100%; height: auto; position: sticky; top: 0; z-index: 50; padding: 10px 0; }
    .menu .marca { border-bottom: none; padding-bottom: 0; }
    .menu .boton-menu { display: block; }
    .menu nav, .menu .usuario { display: none; }
    .menu.desplegado nav, .menu.desplegado .usuario { display: block; }
    .menu.desplegado { max-height: 100vh; overflow-y: auto; }
    .contenido { padding: 16px 12px; }
    .fila-doble { flex-direction: column; gap: 0; }
    .rejilla-2, .rejilla-3 { grid-template-columns: 1fr; }
    .modal { padding: 18px 16px; border-radius: 12px; }
    .fondo-modal { padding: 8px; }
    .tarjetas-resumen { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .tarjeta-resumen { padding: 12px; gap: 10px; }
    .tarjeta-resumen .icono { width: 36px; height: 36px; font-size: 18px; }
    .tarjeta-resumen h3 { font-size: 17px; }
    .ocultar-celular { display: none !important; }
}
