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

:root {
    --bg: #F6F5F2;
    --surface: #FFFFFF;
    --surface-alt: #FAF9F6;
    --sidebar: #EFEDE8;
    --border: #E2DFD8;
    --border-strong: #D4D0C7;
    --divider: #F1EFEA;
    --text: #1C1B19;
    --text-2: #3A3833;
    --muted: #6B6860;
    --accent: #2B2B2E;
    --accent-hover: #45454A;

    --ok-bg: #E3F1E8;
    --ok-text: #1E5B38;
    --ok-icon: #1E7A45;
    --attn-bg: #FFF1D6;
    --attn-text: #7A4B00;
    --error-text: #A12A1B;
    --neutral-bg: #EFEDE8;
    --neutral-text: #3A3833;

    --icon-ventas-bg: #E8EEF6;
    --icon-ventas-text: #1D4E89;
    --icon-dinero-bg: var(--ok-bg);
    --icon-dinero-text: var(--ok-text);
    --icon-cuentas-bg: #F6EDE3;
    --icon-cuentas-text: var(--attn-text);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

.num { font-variant-numeric: tabular-nums; }

/* Barra "Ver como" */
.impersonando {
    height: 40px;
    background: var(--attn-text);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    font-size: 0.85rem;
}
.impersonando button.link { color: #fff; text-decoration: underline; }

/* Estructura: sidebar + contenido */
.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 232px;
    flex-shrink: 0;
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 12px 16px;
    gap: 2px;
}
.sidebar .brand {
    display: flex;
    align-items: baseline;
    gap: 6px;
    padding: 0 12px 20px;
}
.sidebar .brand .k { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
.sidebar .brand .g { font-size: 14px; color: var(--muted); }
.sidebar a.item {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 40px;
    padding: 0 12px;
    border-radius: 8px;
    color: var(--text-2);
    font-size: 14px;
    font-weight: 500;
}
.sidebar a.item:hover { background: #E6E3DC; }
.sidebar a.item.active {
    background: var(--surface);
    color: var(--accent);
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(28, 27, 25, 0.08);
}
.sidebar a.item svg { flex-shrink: 0; }
.sidebar .grupo {
    padding: 16px 12px 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}
.sidebar .spacer { flex-grow: 1; }
.sidebar .usuario {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    padding: 12px;
    border-top: 1px solid var(--border);
}
.sidebar .usuario .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--border-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
    flex-shrink: 0;
}
.sidebar .usuario .datos { display: flex; flex-direction: column; min-width: 0; }
.sidebar .usuario .nombre { font-size: 13px; font-weight: 600; color: var(--text); }
.sidebar .usuario .rol { font-size: 12px; color: var(--muted); }

.content { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    height: 64px;
    flex-shrink: 0;
    box-sizing: border-box;
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    gap: 1rem;
}
.topbar h1 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.01em;
}
.topbar .acciones { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

main { padding: 24px 28px; }
main.ancho { max-width: none; }

h1 { font-size: 1.4rem; margin-top: 0; }
h2 { font-size: 16px; font-weight: 600; }

table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td {
    text-align: left;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--divider);
    font-size: 15px;
}
th {
    background: none;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
}
tbody tr:hover { background: var(--surface-alt); }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(28, 27, 25, 0.06);
    padding: 20px 24px;
    margin-bottom: 20px;
}

.grupo-titulo {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 24px 0 12px;
}
.grupo-titulo:first-child { margin-top: 0; }

.tarjetas-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}
@media (max-width: 700px) {
    .tarjetas-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.tarjeta-reporte {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
}
.tarjeta-reporte:hover { background: var(--surface-alt); border-color: var(--border-strong); }
.tarjeta-reporte .icono {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.tarjeta-reporte .icono.ventas { background: var(--icon-ventas-bg); color: var(--icon-ventas-text); }
.tarjeta-reporte .icono.dinero { background: var(--icon-dinero-bg); color: var(--icon-dinero-text); }
.tarjeta-reporte .icono.cuentas { background: var(--icon-cuentas-bg); color: var(--icon-cuentas-text); }
.tarjeta-reporte .datos { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; }
.tarjeta-reporte .titulo-tarjeta { font-size: 16px; font-weight: 600; color: var(--text); }
.tarjeta-reporte .descripcion-tarjeta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.tarjeta-reporte .flecha { flex-shrink: 0; color: var(--muted); }

label { display: block; margin: 0.75rem 0 0.25rem; font-size: 15px; font-weight: 600; color: var(--text-2); }
input, select, textarea {
    width: 100%;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
}
input:disabled, select:disabled, textarea:disabled { background: var(--bg); color: var(--muted); }

button, .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 40px;
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 0.55rem 1rem;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.92rem;
    font-weight: 600;
    font-family: inherit;
    text-decoration: none;
    margin-top: 0.75rem;
}
button:hover, .btn:hover { background: var(--accent-hover); }
button.secondary, .btn.secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border-strong);
}
button.secondary:hover, .btn.secondary:hover { background: var(--surface-alt); }
button.danger, .btn.danger { background: var(--error-text); }
button.link {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 0.92rem;
    margin-top: 0;
    padding: 0;
    min-height: auto;
}

.errors { background: #FBEAE7; border: 1px solid #F2B8B5; color: var(--error-text); padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.flash { background: var(--ok-bg); border: 1px solid #BEDFC9; color: var(--ok-text); padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 1rem; }

.badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    background: var(--neutral-bg);
    color: var(--neutral-text);
}
.badge.abierto, .badge.pagado { background: var(--ok-bg); color: var(--ok-text); }
.badge.parcial { background: var(--attn-bg); color: var(--attn-text); }
.badge.pendiente { background: #FBEAE7; color: var(--error-text); }
.badge.cerrado, .badge.anulado { background: var(--neutral-bg); color: var(--neutral-text); }

.text-right { text-align: right; }
.muted { color: var(--muted); font-size: 0.85rem; }
.login-wrap { max-width: 360px; margin: 4rem auto; }
.items-row { display: flex; gap: 0.5rem; align-items: end; }
.items-row > div { flex: 1; }

#producto-resultados { position: relative; }
#producto-lista {
    position: absolute;
    z-index: 10;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    width: 100%;
    max-height: 220px;
    overflow-y: auto;
}
#producto-lista div { padding: 0.4rem 0.6rem; cursor: pointer; border-bottom: 1px solid var(--divider); font-size: 0.88rem; }
#producto-lista div:hover { background: var(--surface-alt); }

/* Venta mostrador */
.venta-mostrador { display: flex; gap: 20px; align-items: flex-start; }
.venta-mostrador .columna-productos { flex-grow: 1; min-width: 0; }
.venta-mostrador .columna-ticket { width: 440px; flex-shrink: 0; }

.venta-mostrador #producto-buscar {
    height: 56px;
    font-size: 17px;
    padding: 0 1rem;
}
.venta-mostrador #producto-lista {
    position: static;
    border: none;
    max-height: none;
    margin-top: 0.5rem;
}
.venta-mostrador #producto-lista div { padding: 0; border: none; }

.producto-fila {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 64px;
    padding: 0 8px;
    border-bottom: 1px solid var(--divider);
    cursor: pointer;
}
.producto-fila:hover { background: var(--surface-alt); }
.producto-fila .miniatura {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: var(--sidebar);
    flex-shrink: 0;
}
.producto-fila .info-producto { flex-grow: 1; min-width: 0; }
.producto-fila .nombre-producto { font-size: 15px; font-weight: 500; color: var(--text); }
.producto-fila .meta-producto { font-size: 13px; color: var(--muted); }
.producto-fila .meta-producto .sku { font-family: "IBM Plex Mono", monospace; }
.descripcion-corta {
    display: inline-block;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
    color: var(--muted);
}
.producto-fila .precio-producto { font-weight: 600; white-space: nowrap; font-size: 15px; }
.producto-fila .agregar-btn {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    line-height: 1;
    padding: 0;
    margin: 0;
}
.producto-fila .agregar-btn:disabled { background: var(--border-strong); cursor: not-allowed; }

.ticket-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}
.ticket-header h2 { margin: 0; flex-shrink: 0; }
.ticket-header .ticket-cantidad { color: var(--muted); font-size: 13px; flex-grow: 1; }

.ticket-linea {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--divider);
}
.ticket-linea .nombre-linea { flex-grow: 1; min-width: 0; font-size: 14px; }
.ticket-linea .precio-linea { font-size: 13px; color: var(--muted); }

.cantidad-control { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.cantidad-control button {
    width: 26px;
    height: 26px;
    min-height: auto;
    padding: 0;
    margin: 0;
    border-radius: 6px;
    font-size: 15px;
    line-height: 1;
}
.cantidad-control span { min-width: 1.5rem; text-align: center; font-size: 14px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    min-height: auto;
    margin-top: 0;
    color: var(--text);
}
.chip.activo { background: var(--accent); color: #fff; border-color: var(--accent); }

.medios-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.medio-btn {
    padding: 10px 4px;
    border-radius: 8px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    min-height: 44px;
    margin-top: 0;
    color: var(--text);
}
.medio-btn.activo { background: var(--accent); color: #fff; border-color: var(--accent); }

.total-grande { font-size: 34px; font-weight: 700; }

.btn-cobrar { width: 100%; height: 56px; font-size: 17px; }

/* Inicio */
.estado-sistema { display: flex; align-items: center; gap: 16px; font-size: 12px; }
.estado-sistema .chip-estado { display: inline-flex; align-items: center; gap: 6px; }
.estado-sistema .chip-estado.ok { color: var(--ok-icon); }
.estado-sistema .chip-estado.atencion { color: var(--error-text); }
.estado-sistema .chip-estado.sin-datos { color: var(--muted); }

.kpis-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
@media (max-width: 900px) { .kpis-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 18px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
}
.kpi-card .kpi-label { font-size: 13px; color: var(--muted); }
.kpi-card .kpi-valor { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
.kpi-card .kpi-detalle { font-size: 13px; color: var(--muted); }

.grafico-barras { display: flex; align-items: flex-end; gap: 10px; height: 230px; padding-top: 20px; border-top: 1px dashed var(--divider); }
.grafico-barras .barra-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; height: 100%; }
.grafico-barras .barra-valor { font-size: 12px; font-weight: 600; }
.grafico-barras .barra { width: 100%; max-width: 40px; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; }
.grafico-barras .barra-label { font-size: 12px; color: var(--muted); white-space: nowrap; }

.caja-resumen { margin: 12px 0; }
.caja-resumen .linea { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px; }
.caja-resumen .linea.total { border-top: 1px solid var(--divider); margin-top: 6px; padding-top: 12px; font-weight: 600; font-size: 16px; }

.item-revisar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    margin: 0 -10px;
    border-radius: 8px;
}
.item-revisar:hover { background: var(--surface-alt); }
.item-revisar .icono-atencion {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 8px;
    background: var(--attn-bg);
    color: var(--attn-text);
    display: flex;
    align-items: center;
    justify-content: center;
}

@media print {
    .no-print { display: none !important; }
    body { background: #fff; }
    .shell { display: block; }
    main { max-width: 100%; padding: 0; margin: 0; }
    .card { border: none; padding: 0; box-shadow: none; }
}

/* Miniatura de producto en los buscadores */
.mini-producto {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    background: var(--surface-alt);
}
.mini-producto img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mini-producto-inicial { background: #E5E7EB; color: #6B7280; font-weight: 600; font-size: 16px; }
div.fila-con-mini { display: flex; align-items: center; gap: 10px; }

/* ---------- Paginación (vista resources/views/vendor/pagination/kaizen.blade.php) ---------- */
.paginacion { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; margin-top: 1rem; }
.paginacion-resumen { margin: 0; color: var(--muted); font-size: 13px; }
.paginacion-lista { display: flex; flex-wrap: wrap; gap: 4px; list-style: none; margin: 0; padding: 0; }
.pag { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; height: 36px; padding: 0 10px; box-sizing: border-box;
       border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--text); font-size: 14px; line-height: 1; text-decoration: none; }
a.pag:hover { background: var(--surface-alt); }
.pag-actual { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.pag-off { color: var(--muted); background: var(--surface-alt); cursor: default; }
.pag-icono { width: 16px; height: 16px; flex: none; }
/* Red de seguridad: si algún día vuelve la paginación de Tailwind de Laravel, sus flechas no pueden volver a ocupar la pantalla. */
.paginacion svg, nav[aria-label="Pagination Navigation"] svg { max-width: 24px; max-height: 24px; }

/* Cuentas corrientes (clientes y proveedores): deuda en rojo, saldo a favor en verde, cero en gris; siempre en negrita y un poco más grande. */
.saldo { font-weight: 700; font-size: 1.1em; font-variant-numeric: tabular-nums; }
.saldo-deuda { color: #b3261e; }
.saldo-favor { color: #1a6b3a; }
.saldo-cero { color: #6b7480; }
.saldo-etiqueta { font-weight: 400; font-size: 0.8em; color: var(--muted, #6b7480); }
/* Desglose secundario (deuda − a cuenta): mismos colores, sin negrita ni tamaño extra. */
.saldo-det-deuda { color: #b3261e; }
.saldo-det-favor { color: #1a6b3a; }

/* Marca de agua: yin yang gigante, centrado en la pantalla y fijo (no se mueve al scrollear). Ocupa casi toda la
   pantalla (94% del lado menor), color tinta #2B2B2E al 4% (bajado de 5% el 2026-10-08, pedido de Iván), por encima de las tarjetas pero sin recibir
   clics ni selección, y no sale al imprimir. Aprobado por Iván 2026-10-07. */
.marca-agua {
    position: fixed;
    top: 50%;
    left: 50%;
    width: min(94vw, 94vh);
    height: min(94vw, 94vh);
    transform: translate(-50%, -50%);
    color: #2B2B2E; /* fijo: --accent lo redefine kaizen-v1.css (azul) */
    opacity: .04;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    z-index: 40;
}
@media print { .marca-agua { display: none !important; } }


/* --- Pagos a proveedores: estados de egresos y cartel de "pago a cuenta sin aplicar" --- */
.cartel-rojo {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
    background: #FBEAE7; border: 2px solid var(--error-text); color: var(--error-text);
    padding: 0.85rem 1rem; border-radius: 8px; margin-bottom: 1rem;
}
.cartel-rojo strong { font-size: 1.05rem; }
.cartel-rojo .btn-aplicar, .btn-aplicar { background: var(--error-text); color: #fff; font-weight: 600; }
.estado-pago { display: inline-block; padding: 0.2rem 0.6rem; border-radius: 999px; font-weight: 700; font-size: 0.85rem; white-space: nowrap; }
.estado-pago.pendiente { background: var(--error-text); color: #fff; }
.estado-pago.pagado { background: var(--ok-icon); color: #fff; }
.estado-pago.parcial { background: var(--attn-bg); color: var(--attn-text); border: 1px solid #F0D28A; font-weight: 600; }
.aviso-a-cuenta { display: inline-block; margin-top: 0.25rem; padding: 0.15rem 0.5rem; border-radius: 6px; background: #FBEAE7; color: var(--error-text); font-size: 0.8rem; font-weight: 600; }
tr.fila-resaltada td { background: var(--attn-bg); }
.flash.pago-aplicado { border-width: 2px; }

/* --- Nota de crédito de proveedor: línea propia en verde y negrita (resta del saldo) --- */
.nota-credito-linea { color: var(--ok-icon); font-weight: 700; }

/* --- Empleados: lo que falta pagarles --- */
.falta-debe { color: var(--error-text); font-weight: 700; }
.falta-aldia { color: var(--ok-text); font-weight: 600; }

/* Venta mostrador: descuento por cantidad en la línea del ticket (etapa 1b) */
.ticket-linea .precio-linea s { color: var(--muted); }
.ticket-linea .desc-pct { color: #1f7a3d; font-weight: 600; }
.ticket-linea .desc-final { color: #1f7a3d; font-weight: 700; }
.ticket-linea .desc-nota { font-size: 12px; color: var(--muted); }
