/* ══════════════════════════════════════════════════════════════════
   Modulo Ventas — CSS propio (regla: un archivo por modulo).
   Prefijos por componente: .rcm- Reportes Comerciales · .fay- Factura con ayuda.
   ══════════════════════════════════════════════════════════════════ */

/* ══════════════════════════════════════════════════════════════════
   Reportes Comerciales (ReportesComercialesPage + Components/ReportesComerciales) — .rcm-

   Layout: .content-wrapper es una columna flex SIN scroll (insi-layout.css). Por eso .rcm-body ocupa el
   resto con flex: 1 1 0 y cada zona que puede crecer (tabla, gráficos, rentabilidad) trae su propio
   overflow. Un max-height en vh acá sería una bomba: al sumar un panel arriba, lo de abajo se OCULTA.
   ══════════════════════════════════════════════════════════════════ */
.rcm-header,
.rcm-body {
    --rcm-azul: var(--primario, #1e3a5f);
    --rcm-azul-medio: #2c5282;
    --rcm-dorado: #d4af37;
    --rcm-linea: #e0e4ec;
    --rcm-linea-suave: #eef1f6;
    --rcm-fondo: #f5f7fb;
    --rcm-texto: #1e293b;
    --rcm-gris: #64748b;
    --rcm-ok: #2e7d32;
    --rcm-warn: #c77700;
    --rcm-bad: #c62828;
}

.rcm-header .breadcrumb { margin-bottom: 6px; }

.rcm-tabsbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.rcm-tabsbar .rc-tabs { margin-bottom: 0; }

.rcm-candado {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px; border-radius: 999px;
    background: #fff8e6; border: 1px solid #f0d78c; color: #8a6d1d;
    font-size: 12px; font-weight: 600; cursor: help;
}

.rcm-contexto {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    margin-top: 2px; padding: 6px 10px 6px 12px;
    background: #f3f7fd; border: 1px solid #d6e3f5; border-left: 3px solid var(--rcm-dorado);
    border-radius: 8px; color: var(--rcm-azul); font-size: 13px; font-weight: 600;
}
.rcm-contexto > i { color: var(--rcm-dorado); }
.rcm-contexto .rcm-btn { margin-left: auto; }

.rcm-body {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px 3% 12px;
    overflow: hidden;
    position: relative; /* el spinner de lista cubre este contenedor */
}

/* ── Indicadores y filtros de tendencia ─────────────────────────── */
.rcm-resumen { flex: 0 0 auto; display: flex; flex-direction: column; gap: 8px; }

.rcm-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }

.rcm-kpi {
    display: flex; flex-direction: column; gap: 2px; min-width: 0;
    padding: 10px 14px; background: #fff;
    border: 1px solid var(--rcm-linea); border-radius: 10px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
.rcm-kpi--destacado { border-left: 3px solid var(--rcm-dorado); }
.rcm-kpi__label { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--rcm-gris); }
.rcm-kpi__valor { font-size: 20px; font-weight: 700; color: var(--rcm-azul); font-variant-numeric: tabular-nums; line-height: 1.25; }
.rcm-kpi__valor i { font-size: 14px; margin-right: 2px; }
.rcm-kpi__valor--texto { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rcm-kpi__nota { font-size: 11.5px; color: var(--rcm-gris); }
.rcm-kpi__nota--texto { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rcm-kpi__unidad { font-size: 12px; font-weight: 600; color: var(--rcm-azul-medio); }
.rcm-kpi__var { margin-left: 6px; font-size: 12px; font-weight: 700; }

.rcm-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

.rcm-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 12px; border-radius: 999px;
    border: 1px solid var(--rcm-linea); background: #fff; color: #334155;
    font-size: 12.5px; font-weight: 600; cursor: pointer;
    transition: background-color .15s, border-color .15s, color .15s;
}
.rcm-chip b { font-variant-numeric: tabular-nums; }
.rcm-chip:hover:not(:disabled) { border-color: #b8c6dc; background: #f8fafd; }
.rcm-chip:disabled { opacity: .45; cursor: default; }
.rcm-chip.rcm-tend--perdido i { color: var(--rcm-bad); }
.rcm-chip.rcm-tend--baja i { color: var(--rcm-warn); }
.rcm-chip.rcm-tend--sube i { color: var(--rcm-ok); }
.rcm-chip.rcm-tend--nuevo i { color: #1565c0; }
.rcm-chip--activo,
.rcm-chip--activo:hover:not(:disabled) { background: var(--rcm-azul); border-color: var(--rcm-azul); color: #fff; }
.rcm-chip--activo i { color: #fff !important; }
.rcm-chip--activo.rcm-tend--perdido { background: var(--rcm-bad); border-color: var(--rcm-bad); }
.rcm-chip--activo.rcm-tend--baja { background: var(--rcm-warn); border-color: var(--rcm-warn); }
.rcm-chip--activo.rcm-tend--sube { background: var(--rcm-ok); border-color: var(--rcm-ok); }
.rcm-chip--activo.rcm-tend--nuevo { background: #1565c0; border-color: #1565c0; }

.rcm-chips__ayuda { margin-left: auto; font-size: 12px; color: var(--rcm-gris); cursor: help; }

.rcm-aviso {
    padding: 6px 12px; border-radius: 8px;
    background: #eef5ff; border: 1px solid #cfe0fb; color: var(--rcm-azul); font-size: 12.5px;
}

/* ── Tarjeta con tabla (el scroll vive en .rcm-tabla-wrap) ──────── */
.rcm-card {
    flex: 1 1 0;
    min-height: 180px;
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid var(--rcm-linea);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .05);
}

.rcm-tabla-wrap { flex: 1 1 0; min-height: 0; overflow: auto; }
.rcm-pie { flex: 0 0 auto; padding: 6px 12px; border-top: 1px solid var(--rcm-linea); background: #fafbfd; }

.rcm-tabla { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; color: var(--rcm-texto); }

.rcm-tabla thead th {
    position: sticky; top: 0; z-index: 3;
    height: 34px; padding: 6px 10px;
    background: var(--rcm-azul); color: #fff;
    font-weight: 600; white-space: nowrap; vertical-align: middle;
    border-bottom: 2px solid var(--rcm-dorado);
}
.rcm-tabla thead tr.rcm-subhead th {
    top: 34px; height: 26px; padding: 3px 10px;
    background: var(--rcm-azul-medio); font-size: 11px; font-weight: 500;
}
.rcm-tabla thead th small { display: block; font-size: 9.5px; font-weight: 500; opacity: .8; line-height: 1; }
.rcm-tabla thead th.rcm-grupo { text-align: center; border-left: 1px solid rgba(255, 255, 255, .16); }
/* Con dos filas de encabezado, "en curso" va en la línea del mes: si bajara a una segunda, la fila crecería a 42px y
   la de Cant./S/, fija a 34px, le taparía el borde inferior al desplazar la tabla. */
.rcm-tabla thead th.rcm-grupo small { display: inline; margin-left: 4px; }

.rcm-sortable { cursor: pointer; user-select: none; }
.rcm-tabla thead th.rcm-sortable:hover { background: #24476f; }
.rcm-orden { margin-left: 4px; color: var(--rcm-dorado); }

.rcm-tabla tbody td {
    padding: 6px 10px; white-space: nowrap; vertical-align: middle;
    background: #fff; border-bottom: 1px solid var(--rcm-linea-suave);
}
.rcm-tabla tbody tr:nth-child(even) td { background: #fafbfd; }
.rcm-tabla tbody tr:hover td { background: #f1f6ff; }

.rcm-tabla tfoot td {
    position: sticky; bottom: 0; z-index: 2;
    padding: 7px 10px; white-space: nowrap;
    background: #eef2f8; color: var(--rcm-azul); font-weight: 700;
    border-top: 2px solid var(--rcm-azul);
}

/* Columna de nombre fija al desplazarse en horizontal */
.rcm-tabla .rcm-col-nombre {
    position: sticky; left: 0; z-index: 1;
    min-width: 240px; max-width: 340px; text-align: left;
    box-shadow: 1px 0 0 var(--rcm-linea);
}
.rcm-tabla thead th.rcm-col-nombre { z-index: 4; }
.rcm-tabla tfoot td.rcm-col-nombre { z-index: 3; }

/* Acciones fijas a la derecha: en una tabla de 12 meses no deben irse de la vista */
.rcm-tabla .rcm-col-acciones { position: sticky; right: 0; z-index: 1; text-align: right; box-shadow: -1px 0 0 var(--rcm-linea); }
.rcm-tabla thead th.rcm-col-acciones { z-index: 4; }
.rcm-tabla tfoot td.rcm-col-acciones { z-index: 3; }

.rcm-nombre { display: block; max-width: 320px; overflow: hidden; text-overflow: ellipsis; font-weight: 600; color: var(--rcm-texto); }
.rcm-sub { display: block; font-size: 11px; color: var(--rcm-gris); }
.rcm-und { margin-left: 4px; padding: 0 5px; border-radius: 4px; background: #eef2f8; color: var(--rcm-azul-medio); font-size: 10.5px; font-weight: 600; }
.rcm-badge { margin-left: 4px; padding: 0 6px; border-radius: 4px; background: #fff4e5; color: var(--rcm-warn); font-size: 10.5px; font-weight: 600; }

.rcm-num { text-align: right; font-variant-numeric: tabular-nums; }
.rcm-cero { color: #b8c1d1; }
.rcm-neg { color: var(--rcm-bad); }
.rcm-pos { color: var(--rcm-ok); }
.rcm-sec { color: var(--rcm-gris); }

.rcm-tabla tbody td.rcm-col-total { font-weight: 700; background: #f5f8fc; }
.rcm-tabla tbody tr:hover td.rcm-col-total { background: #e9f1fd; }
.rcm-tabla td.rcm-mes-curso { color: #7a8699; font-style: italic; }
.rcm-tabla td.rcm-mes-futuro,
.rcm-tabla th.rcm-mes-futuro { opacity: .45; }

/* ── Tendencia y su forma del año ───────────────────────────────── */
.rcm-tabla .rcm-col-tend { min-width: 210px; }
.rcm-tend-cell { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.rcm-tend {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 2px 9px; border-radius: 999px; border: 1px solid transparent;
    font-size: 11.5px; font-weight: 600; white-space: nowrap; cursor: help;
}
.rcm-tend i { font-size: 10px; }
.rcm-tend--perdido { background: #fdecec; border-color: #f6c8c8; color: #b71c1c; }
.rcm-tend--baja { background: #fff4e5; border-color: #f8dcae; color: #a86300; }
.rcm-tend--sube { background: #e8f5e9; border-color: #c3e3c5; color: var(--rcm-ok); }
.rcm-tend--nuevo { background: #e7f0fd; border-color: #c4d9f7; color: #1565c0; }
.rcm-tend--estable { background: #f1f5f9; color: #475569; }
.rcm-tend--sin { background: transparent; color: #94a3b8; cursor: default; }

.rcm-spark { display: block; flex: 0 0 auto; }
.rcm-spark__bar { fill: #9fb3cf; }
.rcm-spark__curso { fill: #cfd9e8; }
.rcm-spark__futuro { fill: #eef1f6; }
.rcm-spark__neg { fill: #e57373; }

/* ── Proyectado - Logrado ───────────────────────────────────────── */
.rcm-tabla .rcm-col-cumpl { min-width: 160px; }
.rcm-cumpl { display: flex; align-items: center; gap: 8px; }
.rcm-cumpl__barra { flex: 1; height: 6px; min-width: 60px; border-radius: 99px; background: var(--rcm-linea-suave); overflow: hidden; }
.rcm-cumpl__barra span { display: block; height: 100%; background: currentColor; border-radius: 99px; }
.rcm-cumpl b { min-width: 48px; text-align: right; font-size: 12px; font-variant-numeric: tabular-nums; }
.rcm-ok { color: var(--rcm-ok); }
.rcm-warn { color: var(--rcm-warn); }
.rcm-bad { color: var(--rcm-bad); }
.rcm-tabla tbody tr td.rcm-ok { background: #f3faf3; }
.rcm-tabla tbody tr td.rcm-warn { background: #fffaf0; }
.rcm-tabla tbody tr td.rcm-bad { background: #fdf3f3; }
.rcm-fila-fuera td { color: #7a8699; }
.rcm-fila-fuera .rcm-nombre { font-weight: 500; font-style: italic; color: #64748b; }

/* ── Botones ────────────────────────────────────────────────────── */
.rcm-acciones { display: inline-flex; gap: 6px; }

.rcm-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px; border-radius: 7px;
    border: 1px solid #d5dce8; background: #fff; color: var(--rcm-azul);
    font-size: 12.5px; font-weight: 600; white-space: nowrap; cursor: pointer;
    transition: background-color .15s, border-color .15s;
}
.rcm-btn:hover:not(:disabled) { background: #f1f5fb; border-color: #b8c6dc; }
.rcm-btn:disabled { opacity: .6; cursor: default; }
.rcm-btn--sm { padding: 3px 9px; font-size: 11.5px; }
.rcm-btn--excel { background: #1f7a4d; border-color: #1f7a4d; color: #fff; }
.rcm-btn--excel:hover:not(:disabled) { background: #19663f; border-color: #19663f; }

/* ── Estados ────────────────────────────────────────────────────── */
.rcm-vacio {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
    padding: 48px 16px; color: #94a3b8; text-align: center;
}
.rcm-vacio i { font-size: 2rem; opacity: .5; }
.rcm-vacio p { margin: 0; font-size: 13px; }

.rcm-estado {
    flex: 1 1 0; min-height: 200px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    padding: 32px 16px; text-align: center; color: #475569;
    background: #fff; border: 1px dashed #d5dce8; border-radius: 10px;
}
.rcm-estado > i { font-size: 2.2rem; color: var(--rcm-azul-medio); opacity: .6; }
.rcm-estado h4 { margin: 4px 0 0; font-size: 16px; font-weight: 700; color: var(--rcm-azul); }
.rcm-estado p { max-width: 520px; margin: 0; font-size: 13px; }
.rcm-estado--error > i { color: var(--rcm-bad); }

.rcm-nota { flex: 0 0 auto; margin: 0; font-size: 11.5px; color: var(--rcm-gris); }

/* ── Gráficos (scroll propio: sin esto la parte de abajo quedaba cortada) ── */
.rcm-graficos { flex: 1 1 0; min-height: 0; overflow: auto; }
.rcm-graficos__grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 12px; align-items: start; }
.rcm-graficos__grid--solo { grid-template-columns: minmax(0, 1fr); }
.rcm-graficos__panel { min-width: 0; }

/* ── Rentabilidad de un cliente ─────────────────────────────────── */
.rcm-rent { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.rcm-rent__barra { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 2px; }
.rcm-rent__titulo h3 { margin: 0; font-size: 17px; font-weight: 700; color: var(--rcm-azul); }
.rcm-rent__titulo small { color: var(--rcm-gris); }
.rcm-rent__barra .rcm-btn--excel { margin-left: auto; }

.rcm-tabla--pyg .rcm-col-nombre { min-width: 260px; }
.rcm-tabla--pyg tbody tr.rcm-pyg-ventas td { font-weight: 700; color: var(--rcm-azul); }
.rcm-tabla--pyg tbody tr.rcm-pyg-seccion td {
    padding-top: 10px; background: #eef2f8;
    color: var(--rcm-azul-medio); font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
}
.rcm-tabla--pyg tbody tr.rcm-pyg-detalle td.rcm-col-nombre { padding-left: 24px; color: #475569; }
.rcm-tabla--pyg tbody tr.rcm-pyg-subtotal td { font-weight: 700; border-top: 1px solid #d5dce8; }
.rcm-tabla--pyg tbody tr.rcm-pyg-separado td { border-top: 2px solid var(--rcm-azul); }
.rcm-tabla--pyg tbody tr.rcm-pyg-margen td { font-weight: 800; background: #fbf6e6; }
.rcm-tabla--pyg tbody tr.rcm-pyg-porcentaje td { font-weight: 600; }
.rcm-tabla--pyg tbody tr.rcm-pyg-nota td { color: #94a3b8; font-style: italic; }
/* Las filas de sección ocupan todo el ancho: su título se fija a la izquierda para no irse al desplazar. */
.rcm-pyg-titulo { position: sticky; left: 10px; display: inline-block; }

/* ── Pantallas chicas ───────────────────────────────────────────── */
@media (max-width: 1100px) {
    .rcm-graficos__grid { grid-template-columns: minmax(0, 1fr); }
}

/* En un teléfono los indicadores ya ocupan media pantalla: en vez de encoger la tabla a una franja,
   scrollea la página entera y la tabla conserva su propio scroll (y su encabezado fijo) con un alto máximo. */
@media (max-width: 768px) {
    .rcm-body { padding: 8px 12px; overflow-y: auto; }
    .rcm-card { flex: 0 0 auto; min-height: 0; }
    .rcm-tabla-wrap { flex: 0 0 auto; max-height: 75vh; }
    .rcm-graficos,
    .rcm-rent { flex: 0 0 auto; overflow: visible; }
    .rcm-estado { flex: 0 0 auto; }
    .rcm-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .rcm-kpi__valor { font-size: 17px; }
    .rcm-tabla .rcm-col-nombre { min-width: 150px; max-width: 170px; }
    .rcm-nombre { max-width: 150px; }
    .rcm-tabla .rcm-col-acciones { position: static; box-shadow: none; }
    .rcm-chips__ayuda { margin-left: 0; flex-basis: 100%; }
    .rcm-rent__barra .rcm-btn--excel { margin-left: 0; }
    /* Selector de columnas + Tabla/Gráficos miden más que un teléfono: sin esto, Gráficos quedaba fuera de la pantalla. */
    .rcm-header .page-toolbar__right { flex-shrink: 1; flex-wrap: wrap; justify-content: flex-end; row-gap: 6px; min-width: 0; }
}

/* ══════════════════════════════════════════════════════════════════
   Factura con ayuda (Compartido/Components/Ventas/ModalFacturaAyudaComponent) — .fay-

   Modal de Bootstrap 4.3.1 (modal-xl + modal-dialog-scrollable): el cuerpo es el que desplaza. Cada comprobante
   propuesto es una tarjeta; la tabla de productos trae su propio scroll horizontal para no ensanchar el modal.
   ══════════════════════════════════════════════════════════════════ */
.fay {
    --fay-azul: var(--primario, #1e3a5f);
    --fay-azul-medio: #2c5282;
    --fay-dorado: #d4af37;
    --fay-linea: #e0e4ec;
    --fay-linea-suave: #eef1f6;
    --fay-fondo: #f5f7fb;
    --fay-texto: #1e293b;
    --fay-gris: #64748b;
    --fay-ok: #2e7d32;
    --fay-warn: #c77700;
    --fay-bad: #c62828;
}

.fay .modal-content { border: 0; border-radius: 10px; overflow: hidden; }

.fay-header {
    background: linear-gradient(135deg, var(--fay-azul) 0%, var(--fay-azul-medio) 100%);
    border-bottom: 3px solid var(--fay-dorado);
    color: #fff;
    padding: 12px 16px;
    align-items: center;
}
.fay-header .modal-title { font-size: 17px; font-weight: 700; }
.fay-header__texto { min-width: 0; }
.fay-header__sub { font-size: 13px; opacity: .88; margin-top: 2px; overflow-wrap: anywhere; }
.fay-header .close { color: #fff; opacity: .85; text-shadow: none; }
.fay-header .close:hover { color: #fff; opacity: 1; }

.fay-body {
    position: relative; /* el spinner de lista cubre el cuerpo */
    min-height: 180px;
    background: var(--fay-fondo);
    padding: 14px 16px;
    color: var(--fay-texto);
}

/* Reglas que se aplicaron, en una fila */
.fay-reglas { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.fay-regla {
    display: inline-flex; align-items: center;
    padding: 3px 10px; border-radius: 999px;
    background: #fff; border: 1px solid var(--fay-linea);
    font-size: 12px; font-weight: 600; color: var(--fay-gris);
}
.fay-regla--info { background: #f3f7fd; border-color: #d6e3f5; color: var(--fay-azul); }

/* Un comprobante propuesto */
.fay-item {
    background: #fff;
    border: 1px solid var(--fay-linea);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 10px;
}
.fay-item--aviso { border-left: 4px solid var(--fay-warn); }

.fay-item__cabecera { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.fay-item__que { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; min-width: 0; }
.fay-item__mov { font-size: 13px; color: var(--fay-gris); overflow-wrap: anywhere; }
.fay-item__previa {
    display: inline-block; margin-left: 6px;
    padding: 1px 8px; border-radius: 999px;
    background: #eef1f6; color: var(--fay-azul-medio);
    font-size: 11px; font-weight: 600;
}
.fay-item__total { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.fay-item__total > span { display: block; font-size: 16px; font-weight: 700; color: var(--fay-azul); }
.fay-item__total > small { display: block; font-size: 12px; color: var(--fay-gris); }
.fay-item__motivo { margin-top: 6px; font-size: 13px; color: #475569; }

.fay-badge {
    display: inline-flex; align-items: center;
    padding: 3px 10px; border-radius: 999px;
    background: #eef1f6; color: #475569;
    font-size: 12px; font-weight: 700;
}
.fay-badge--det { background: #e8f0fb; color: var(--fay-azul-medio); box-shadow: inset 0 0 0 1px #c9daf2; }
.fay-badge--aviso { background: #fff4e0; color: #8a5200; box-shadow: inset 0 0 0 1px #f3d39c; }

.fay-aviso {
    display: flex; gap: 8px; align-items: flex-start;
    margin-top: 8px; padding: 8px 10px;
    background: #fff8ec; border: 1px solid #f3d39c; border-radius: 8px;
    color: #7a4a00; font-size: 13px; line-height: 1.4;
}
.fay-aviso > i { margin-top: 2px; color: var(--fay-warn); }

/* Qué parte lleva detracción y qué parte no */
.fay-grupos { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.fay-grupo {
    padding: 3px 10px; border-radius: 6px;
    background: var(--fay-fondo); border: 1px solid var(--fay-linea);
    font-size: 12px; color: #475569; font-variant-numeric: tabular-nums;
}
.fay-grupo--det { background: #f3f7fd; border-color: #d6e3f5; color: var(--fay-azul); }

.fay-tabla-wrap { margin-top: 10px; overflow-x: auto; border: 1px solid var(--fay-linea-suave); border-radius: 8px; }
.fay-tabla { width: 100%; border-collapse: collapse; font-size: 13px; }
.fay-tabla th {
    background: var(--fay-fondo); color: var(--fay-gris);
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
    padding: 6px 10px; border-bottom: 1px solid var(--fay-linea); white-space: nowrap; text-align: left;
}
.fay-tabla td { padding: 6px 10px; border-bottom: 1px solid var(--fay-linea-suave); vertical-align: top; }
.fay-tabla tbody tr:last-child td { border-bottom: 0; }
.fay-tabla .fay-num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.fay-prod { display: block; font-weight: 600; min-width: 160px; }
.fay-prod__sub { display: block; font-size: 11px; color: var(--fay-gris); }

.fay-item__pie {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    margin-top: 10px;
}
.fay-item__deposito { font-size: 13px; color: var(--fay-azul); }
.fay-item__pie .btn { white-space: nowrap; }

/* Lo que ya tiene comprobante */
.fay-hechos {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px;
    margin-top: 4px; padding: 8px 10px;
    background: #fff; border: 1px dashed var(--fay-linea); border-radius: 8px;
    font-size: 12px; color: var(--fay-gris);
}
.fay-hechos__titulo { font-weight: 700; }
.fay-hecho > i { color: var(--fay-ok); margin-right: 3px; }

/* Vacío y error */
.fay-vacio,
.fay-error {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    padding: 28px 16px; text-align: center; color: var(--fay-gris);
}
.fay-vacio > i { font-size: 28px; color: var(--fay-ok); }
.fay-error > i { font-size: 26px; color: var(--fay-warn); }
.fay-vacio p,
.fay-error p { margin: 0; max-width: 460px; }

.fay-footer { justify-content: space-between; gap: 10px; padding: 8px 16px; }
.fay-footer__nota { font-size: 12px; color: var(--fay-gris); }

@media (max-width: 576px) {
    .fay .modal-dialog { margin: 8px; }
    .fay-body { padding: 10px; }
    .fay-item { padding: 10px; }
    .fay-item__cabecera { flex-direction: column; gap: 6px; }
    .fay-item__total { text-align: left; }
    .fay-item__pie { flex-direction: column; align-items: stretch; }
    .fay-item__pie .btn { width: 100%; }
    .fay-footer { flex-direction: column; align-items: stretch; }
    .fay-footer .btn { width: 100%; }
}

/* ── Margen gerencial (SQL 107): ventas − costo de la última compra − costos internos ── */
.mgr .container-fluid { padding-bottom: 1.5rem; }
.mgr-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.mgr-periodo, .mgr-acciones { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.mgr-periodo > label { font-size: .78rem; color: #6b7a90; margin: 0; }
.mgr-periodo input[type=date] { width: 150px; }
.mgr-buscar { width: 240px; max-width: 100%; }

.mgr-nota { font-size: .78rem; color: #6b7a90; margin-bottom: 12px; }

.mgr-kpis { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.mgr-kpi {
    flex: 1 1 170px;
    background: #fff;
    border: 1px solid #e0e4ec;
    border-left: 4px solid var(--primario, #1e3a5f);
    border-radius: 4px;
    padding: 8px 12px;
}
.mgr-kpi > small { display: block; color: #6b7a90; font-size: .74rem; }
.mgr-kpi > span { display: block; font-size: 1.25rem; font-weight: 700; color: #1e3a5f; line-height: 1.2; }
.mgr-kpi > em { display: block; font-style: normal; font-size: .74rem; color: #2e7d32; }
.mgr-kpi--ganancia { border-left-color: #2e7d32; }
.mgr-kpi--ganancia.mgr-negativo { border-left-color: #c62828; }
.mgr-kpi--ganancia.mgr-negativo > span, .mgr-kpi--ganancia.mgr-negativo > em { color: #c62828; }

.mgr-advertencia {
    background: #fff8e1;
    border-left: 4px solid #c77700;
    border-radius: 4px;
    padding: 6px 10px;
    margin-bottom: 8px;
    font-size: .8rem;
    color: #6d4c00;
}
.mgr-advertencia > i { color: #c77700; }

.mgr-orden { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin-bottom: 6px; font-size: .8rem; color: #6b7a90; }
.mgr-orden > span { margin-right: auto; }
.mgr-orden > label { margin: 0; }
.mgr-orden > select { width: 170px; }

.mgr-card { margin-bottom: 14px; }
.mgr-tabla { font-size: .82rem; margin-bottom: 0; }
.mgr-tabla thead th {
    background: var(--primario, #1e3a5f);
    color: #fff;
    font-weight: 600;
    border: 0;
    padding: 6px 8px;
    white-space: nowrap;
}
.mgr-tabla tbody td { padding: 5px 8px; vertical-align: middle; }
.mgr-tabla tfoot th { background: #f5f7fb; border-top: 2px solid #e0e4ec; padding: 6px 8px; }
.mgr-fila { cursor: pointer; }
.mgr-fila:hover { background: #f5f7fb; }
.mgr-chevron { width: 24px; color: #8a94a6; }
.mgr-tabla td.mgr-producto { white-space: normal; min-width: 200px; }
.mgr-positivo { color: #2e7d32; font-weight: 600; }
.mgr-negativo { color: #c62828; font-weight: 600; }
.mgr-chip {
    display: inline-block;
    margin-left: 6px;
    padding: 0 6px;
    border-radius: 10px;
    background: #fff3e0;
    color: #c77700;
    font-size: .7rem;
    white-space: nowrap;
}

.mgr-detalle > td { background: #fafbfd; padding-top: 6px; padding-bottom: 10px; }
.mgr-detalle__resumen { font-size: .78rem; color: #4a5568; margin-bottom: 6px; white-space: normal; }
.mgr-subtabla { font-size: .78rem; margin-bottom: 0; background: #fff; }
.mgr-subtabla thead th { background: #e7edf6; color: #1e3a5f; font-weight: 600; border: 0; padding: 4px 6px; }
.mgr-subtabla tbody td { padding: 4px 6px; }

.mgr-vacio {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    align-items: center;
    padding: 24px;
    color: #6b7a90;
    font-size: .88rem;
}

@media (max-width: 575.98px) {
    .mgr-toolbar, .mgr-periodo, .mgr-acciones { width: 100%; }
    .mgr-periodo input[type=date] { width: calc(50% - 40px); }
    .mgr-buscar { flex: 1 1 auto; width: auto; }
    .mgr-kpi { flex: 1 1 calc(50% - 10px); }
    .mgr-orden > select { width: 100%; }
}
