/* 071m: Reportes rediseñados — cabecera con Favorito / Descargar / WhatsApp, lista con buscador, favoritos y grupos,
   periodo en botones con «Comparar con», números grandes, estado de resultados con IGV aparte. Usa las variables de
   app.css (así el modo oscuro sigue funcionando). */

/* ---- cabecera */
.rep-cab {
  align-items: flex-start;
  margin-bottom: 14px;
}
.rep-cab h1 {
  margin: 0;
}
.rep-cab .sub {
  margin: 4px 0 0;
  color: var(--gris);
  font-size: var(--t-texto-sec);
}
.rep-acciones {
  gap: 8px;
}
.rep-acciones .exporta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.rep .rep-fav-si {
  border-color: #e0b100;
}
.rep .rep-bajar summary {
  font-size: var(--t-boton);
  font-weight: 600;
  min-width: 0;
  padding: 0 16px;
  border-radius: 8px;
}
.rep .rep-bajar .op-menu {
  min-width: 170px;
}
.rep-abrir {
  display: none;
}

/* ---- lista de la izquierda */
.rep .rep-layout {
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 16px;
}
.rep .rep-lista {
  padding: 12px;
}
.rep-lista-cab {
  display: none;
}
.rep .rep-buscar {
  min-height: 44px;
  margin-bottom: 4px;
}
.rep .rep-grupo {
  margin-top: 10px;
}
.rep .rep-grupo h3 {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 6px 6px 4px;
}
.rep-n {
  font-weight: 600;
  letter-spacing: 0;
}
.rep .rep-lista .rep-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  min-height: 44px;
}
.rep-ic {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 14px;
  background: var(--azul-claro);
}
.rep-it-t {
  min-width: 0;
  flex: 1;
}
.rep-it-t small {
  display: block;
  font-size: var(--t-chico);
  color: var(--gris);
  font-weight: 500;
}
.rep-estrella {
  color: #e0b100;
  flex: none;
}
.rep .rep-lista .rep-item.activo {
  background: var(--azul);
  color: #fff;
}
.rep .rep-lista .rep-item.activo small {
  color: #dbe7f3;
}
.rep .rep-lista .rep-item.activo .rep-ic {
  background: rgba(255, 255, 255, 0.18);
}
.rep .rep-lista .rep-mas {
  color: var(--azul);
  font-weight: 600;
  font-size: var(--t-texto-sec);
  padding: 6px 10px;
  min-height: 36px;
}
.rep-fav-pista,
.rep-nada {
  margin: 10px 6px 0;
}

/* ---- filtros */
.rep .rep-filtros {
  gap: 10px 18px;
  padding: 10px 14px;
}
.rep-f {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  min-width: 0;
}
.rep-lab {
  font-size: var(--t-rotulo);
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--gris);
}
.rep-palabras {
  color: var(--gris);
  font-size: var(--t-texto-sec);
}
.rep-seg button[aria-pressed="true"] {
  background: var(--azul);
  color: #fff;
}

/* ---- números grandes */
.rep-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.rep-kpi {
  background: var(--blanco);
  border: 1px solid var(--borde);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.rep-kpi-t {
  font-size: var(--t-rotulo);
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--gris);
}
.rep-kpi-v {
  font-size: var(--t-kpi-medio);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.rep-kpi-s {
  font-size: var(--t-rotulo);
  color: var(--gris);
}
.rep-kpi-fin {
  border: 2px solid var(--verde);
}
.rep-kpi-fin .rep-kpi-v {
  color: var(--verde);
}
.rep-kpi-perdida {
  border: 2px solid var(--rojo);
}
.rep-kpi-perdida .rep-kpi-v,
.rep-kpi-mal .rep-kpi-v {
  color: var(--rojo-txt);
}
.rep-bien {
  color: var(--verde);
  font-weight: 700;
  white-space: nowrap;
}
.rep-mal {
  color: var(--rojo-txt);
  font-weight: 700;
  white-space: nowrap;
}
.rep-igual,
.rep-nuevo {
  color: var(--gris);
  white-space: nowrap;
}

/* ---- barras */
.rep-barras {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.rep-b-fila {
  display: grid;
  grid-template-columns: minmax(90px, 38%) minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  font-size: var(--t-texto-sec);
}
.rep-b-t {
  min-width: 0;
  /* 203 (B13): parte por palabra («CONSTRUCCIONES Y / FERRETERÍA»), no a mitad de una */
  overflow-wrap: break-word;
  word-break: normal;
}
.rep-b-pista {
  display: block;
  min-width: 0;
}
.rep-b {
  display: block;
  height: 14px;
  border-radius: 4px;
  background: #94a3b8;
}
.rep-b-v {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.rep-queda .rep-b {
  background: var(--verde);
}
.rep-queda .rep-b-t,
.rep-queda .rep-b-v {
  color: var(--verde);
  font-weight: 700;
}
.rep-pierdes .rep-b {
  background: var(--rojo);
}
.rep-pierdes .rep-b-t,
.rep-pierdes .rep-b-v {
  color: var(--rojo-txt);
  font-weight: 700;
}

/* ---- estado de resultados */
.rep-main {
  container-type: inline-size;
  min-width: 0;
}
/* el detalle y, al lado (si hay espacio) o debajo, el IGV y las barras */
.rep-er-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
@container (min-width: 980px) {
  .rep-er-grid {
    grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
  }
}
@container (min-width: 640px) and (max-width: 979.98px) {
  .rep-er-lado {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }
}
.rep-er-grid > .tarjeta,
.rep-er-lado > .tarjeta {
  margin-bottom: 0;
}
.rep-er-lado {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}
.rep-detalle,
.rep-cien {
  padding: 14px 16px;
}
.rep-det-cab {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 10px;
}
.rep-det-cab h3,
.rep-cien h3,
.rep-igv h3 {
  margin: 0 0 8px;
  font-size: var(--t-seccion);
}
.rep-er td {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.rep-er td:first-child {
  white-space: normal;
}
.rep-er tr.rep-sub td:first-child,
.rep-er tr.rep-info td:first-child {
  padding-left: 24px;
}
.rep-er tr.rep-info td {
  color: var(--gris);
  font-size: var(--t-texto-sec);
}
.rep-er tr.rep-base td,
.rep-er tr.rep-total td {
  font-weight: 800;
}
.rep-er tr.rep-total td {
  border-top: 2px solid var(--tinta);
  background: var(--suave);
}
.rep-er tr.rep-fin td {
  font-weight: 800;
  font-size: var(--t-tabla);
  background: var(--verde-claro);
  border-top: 2px solid var(--verde);
}
.rep-nota {
  font-size: var(--t-chico);
  font-weight: 600;
  color: var(--gris);
}
.rep-neg {
  color: var(--rojo-txt);
}
.rep-pct,
.rep-ant {
  color: var(--gris);
}
.rep-er tr.rep-ceros td {
  color: var(--gris);
  font-size: var(--t-chico);
  white-space: normal;
}
.rep-link {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--azul);
  cursor: pointer;
  text-align: left;
}
.rep-link:hover {
  text-decoration: underline;
}
.rep-igv {
  background: var(--ambar-claro);
  border: 1px solid #e8c77d;
  border-radius: 12px;
  padding: 14px 16px;
  color: var(--tinta);
}
.rep-igv p {
  margin: 4px 0 0;
  font-size: var(--t-texto-sec);
}
.rep-igv-v {
  display: block;
  font-size: var(--t-kpi);
  font-weight: 800;
  margin: 2px 0 4px;
}
.rep-igv .rep-igv-aviso {
  color: var(--ambar-txt);
  font-weight: 700;
  margin-top: 8px;
}
html[data-tema="oscuro"] .rep-igv {
  border-color: #6b5520;
}

/* ---- inventario valorizado */
.rep-inv-dos {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}
.rep-inv-dos > .tarjeta {
  margin-bottom: 0;
  padding: 14px 16px;
}
.rep-inv-dos h3 {
  margin: 0 0 8px;
  font-size: var(--t-seccion);
}
.rep-kpi-ambar .rep-kpi-v {
  color: var(--ambar-txt);
}
.rep-inv td.der {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.rep-inv-dos.rep-inv-tres {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.rep-inv-dos + .pista {
  margin: 0 0 10px;
}
.rep-inv tr.rep-sin-costo td {
  background: var(--ambar-claro);
}
.rep-inv tr.rep-negativo td {
  background: var(--rojo-claro);
}
.rep-inv tr.rep-negativo td.rep-stock {
  color: var(--rojo-txt);
  font-weight: 700;
}

/* ---- celular: una columna, la lista se abre como panel, botones de 44 px */
@media screen and (max-width: 860px) {
  .rep .rep-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .rep-acciones {
    width: 100%;
  }
  .rep-acciones > *,
  .rep-acciones .exporta > * {
    flex: 1 1 auto;
  }
  .rep .rep-bajar summary {
    width: 100%;
  }
  .rep .rep-acciones .btn,
  .rep .rep-bajar summary,
  .rep .rep-bajar .op-menu button {
    min-height: 44px;
  }
  .rep-abrir {
    display: flex;
    width: 100%;
    margin-bottom: 12px;
  }
  .rep .rep-lista {
    display: none;
  }
  .rep .rep-lista.abierta {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 70;
    max-height: none;
    border-radius: 0;
    overflow-y: auto;
    padding: 12px 16px 24px;
  }
  .rep-lista.abierta .rep-lista-cab {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
  }
  .rep .rep-filtros {
    flex-direction: column;
    align-items: stretch;
  }
  .rep .rep-filtros .rep-f,
  .rep .rep-filtros label.en-linea {
    flex-wrap: wrap;
  }
  .rep .rep-filtros select,
  .rep .rep-filtros input {
    min-height: 44px;
    flex: 1 1 160px;
    min-width: 0;
  }
  .rep-seg {
    width: 100%;
  }
  .rep .rep-seg button {
    min-height: 44px;
    flex: 1 1 auto;
  }
  .rep-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .rep-kpi {
    padding: 10px 12px;
  }
  .rep-kpi-v {
    font-size: var(--t-kpi-chico);
  }
  .rep-er-grid,
  .rep-inv-dos {
    grid-template-columns: minmax(0, 1fr);
  }
  .rep-er {
    font-size: var(--t-texto-sec);
  }
  .rep-er.con-ant .rep-pct {
    display: none;
  }
  .rep-er td:first-child {
    min-width: 120px;
  }
  .rep-er td,
  .rep-er th {
    padding-left: 6px;
    padding-right: 6px;
  }
  .rep-er tr.rep-sub td:first-child,
  .rep-er tr.rep-info td:first-child {
    padding-left: 14px;
  }
  .rep .rep-link {
    min-height: 32px;
  }
}

/* ---- impresión: sin la lista ni botones, con los números arriba y la tabla completa */
/* 203 (Auditoría Reportes, R2): con más de 7 columnas la hoja sale horizontal (la misma regla del PDF); reportes.js pone la clase
   .rep-horizontal según la tabla que está en pantalla (también vale para Ctrl+P) */
@page rep-horizontal {
  size: A4 landscape;
  margin: 10mm;
}
@media print {
  .rep.rep-horizontal {
    page: rep-horizontal;
  }
  .rep-mas-filas,
  .rep-reintentar {
    display: none !important;
  }
}
@media print {
  .rep .rep-layout {
    display: block;
  }
  .rep-lista,
  .rep-acciones,
  .rep-filtros,
  .rep-abrir,
  .rep-ceros,
  .rep-det-cab .pista {
    display: none !important;
  }
  .rep-kpi-v {
    font-size: 17px;
    white-space: nowrap;
  }
  .rep-cab .sub {
    display: none;
  }
  .rep-kpis {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .rep-kpi,
  .rep-er tr,
  .rep-igv,
  .rep-cien {
    break-inside: avoid;
  }
  .rep .tabla-caja {
    overflow: visible !important;
    max-height: none !important;
  }
  .rep .rep-er tr.rep-cero-fila[hidden] {
    display: table-row !important;
  }
  .rep-er-grid {
    display: block !important;
  }
  .rep-detalle {
    margin-bottom: 14px !important;
  }
  .rep-er-lado {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }
  .rep-link {
    color: inherit;
  }
  .rep-b,
  .rep-er tr td,
  .rep-igv {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* ---- 179: «Agrupar por» de dos niveles y el total por local de Cuentas por cobrar */
.rep-agrupar.activo .rep-lab {
  color: var(--azul);
}
.rep-y {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}
.rep-agr td.der {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.rep-agr-dos tr.rep-agr-g1 td {
  font-weight: 700;
  background: var(--suave);
}
.rep-agr-dos tr.rep-agr-g2 td:first-child {
  padding-left: 28px;
}
.rep-agr-abrir {
  font-weight: 700;
  text-align: left;
}
.rep-agr-flecha {
  display: inline-block;
  width: 1em;
}
.rep-agr-pista {
  margin: 0 0 10px;
}
.rep-por-local {
  margin-top: 14px;
  max-width: 560px;
}
.rep-por-local h3 {
  margin: 0 0 8px;
  font-size: var(--t-seccion);
}
@media (max-width: 860px) {
  .rep-inv-dos.rep-inv-tres {
    grid-template-columns: minmax(0, 1fr);
  }
  .rep-y {
    width: 100%;
  }
  .rep-agr-dos tr.rep-agr-g2 td:first-child {
    padding-left: 14px;
  }
}
@media print {
  .rep-agr-dos tr.rep-agr-g1 td {
    background: #f0f0f0 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* 180: inventario valorizado: las barras de marca y categoría se tocan para filtrar la tabla */
.rep-b-boton {
  width: 100%;
  border: 0;
  background: none;
  padding: 2px 4px;
  border-radius: 6px;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  min-height: 32px;
}
.rep-b-boton:hover,
.rep-b-boton:focus-visible {
  background: var(--azul-claro);
}
.rep-b-boton.activo {
  outline: 2px solid var(--azul);
}
.rep-filtro-inv {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
}
/* 180: agrupado de un nivel: lo de adentro de un grupo */
.rep-agr-subt td {
  border-top: 1px solid var(--borde2);
}
/* 180: «Por local» debajo del total y columnas por local */
.rep-por-local-mini {
  margin-top: 10px;
}
.rep-agr tr.rep-agr-det-fila td:first-child,
.rep-agr tr.rep-agr-subt td:first-child {
  padding-left: 28px;
}
.rep-agr tr.rep-agr-det-fila td {
  background: var(--suave);
}
.rep-agr-det {
  text-align: left;
}
@media (max-width: 860px) {
  .rep-agr tr.rep-agr-det-fila td:first-child,
  .rep-agr tr.rep-agr-subt td:first-child {
    padding-left: 14px;
  }
}
/* 180: columnas por local (inventario y stock): en el celular van debajo del nombre */
.rep-pl-cel {
  display: none;
}
@media (max-width: 640px) {
  .rep-pl-col {
    display: none;
  }
  .rep-pl-cel {
    display: block;
    font-size: var(--t-chico);
  }
}
@media print {
  .rep-pl-cel {
    display: none !important;
  }
  .rep-pl-col {
    display: table-cell !important;
  }
}
