/* ════════════════════════════════════════════════════════════════════
   PEUNEX — Informes internos del panel (detalle).
   Aditivo a panel-reports.css: reutiliza .page-head, .btn-act,
   .kpi-row/.kpi-tile, .status-pill y .list-table; agrega sólo la barra
   de filtros compacta, los bloques con encabezado y la versión en
   tarjetas de las tablas para celular.

   Colores: exclusivamente los tokens existentes (--primary,
   --primary-light, --surface, --surface-hover, --border, --text,
   --text-muted, --success, --danger, --warning). Las mezclas usan
   color-mix(in srgb, … N%, transparent o var(--surface)).

   Responsive: 360, 768, 1024 y 1440 px. Sin scroll horizontal en
   ≥1024 px; en celular cada fila se convierte en tarjeta con pares
   «etiqueta / valor» tomados de data-label.
   ════════════════════════════════════════════════════════════════════ */

/* ── Encabezado ───────────────────────────────────────────────────── */
.report-page-head {
  margin-bottom: 1rem;
}

.report-back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  box-sizing: border-box;
  height: 2.4rem;
  padding: 0 .55rem;
  border-radius: .5rem;
  color: var(--text-muted);
  font-size: .8rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition: color .16s ease, background-color .16s ease;
}

.report-back-link:hover,
.report-back-link:focus-visible {
  color: var(--primary);
  background: var(--surface-hover);
}

.report-back-link:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ── Barra de filtros compacta ────────────────────────────────────── */
.report-filters-card {
  padding: .85rem 1rem;
  margin-bottom: 1rem;
}

.report-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: .625rem;
  min-width: 0;
}

.report-filters__fields {
  display: grid;
  flex: 1 1 30rem;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  align-items: end;
  gap: .625rem;
  min-width: 0;
}

.report-filters__field {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 20rem;
}

.report-filters__fields > .report-filters__range {
  display: flex;
  grid-column: span 2;
  flex-wrap: wrap;
  gap: .5rem;
  min-width: 0;
}

.report-filters__field .form-label {
  margin-bottom: .25rem;
  color: var(--text-muted);
  font-size: .72rem;
  font-weight: 650;
  letter-spacing: .02em;
}

.report-filters__field .form-input {
  width: 100%;
  min-width: 0;
  height: 2.4rem;
  padding: .4rem .65rem;
  font-size: .8125rem;
}

.report-filters__range {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  min-width: 0;
}

.report-filters__range > .report-filters__field {
  flex: 1 1 7rem;
}

.report-filters__inline {
  display: flex;
  align-items: center;
  gap: .5rem;
  min-width: 0;
}

.report-filters__inline .form-input {
  width: 6rem;
  flex: 0 0 auto;
}

.report-filters__suffix {
  color: var(--text-muted);
  font-size: .8125rem;
  white-space: nowrap;
}

.report-filters__actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: flex-end;
  gap: .375rem;
  min-width: 0;
  margin-left: auto;
}

.report-filters__actions .btn-act {
  white-space: nowrap;
}

.report-filters__hint {
  margin: .55rem 0 0;
  color: var(--text-muted);
  font-size: .74rem;
  line-height: 1.45;
}

/* El atributo hidden debe ganar sobre el display de los campos. */
.report-filters [hidden] {
  display: none !important;
}

/* ── KPIs ─────────────────────────────────────────────────────────── */
.report-kpis {
  margin-bottom: 1rem;
}

.kpi-tile--compact .kpi-tile__value {
  font-size: 1.1rem;
  overflow-wrap: anywhere;
}

.report-kpi--value-sm .kpi-tile__value {
  font-size: .95rem;
  overflow-wrap: anywhere;
}

.report-kpi--neg {
  color: var(--danger);
}

.report-kpi--pos {
  color: var(--success);
}

/* ── Bloques / gráficos dentro de tarjeta ─────────────────────────── */
.report-block {
  min-width: 0;
  margin-bottom: 1rem;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: .9rem;
}

.report-block__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem .75rem;
  margin: 0;
  padding: .65rem .9rem;
  background: color-mix(in srgb, var(--surface-hover) 55%, var(--surface));
  border-bottom: 1px solid var(--border);
}

.report-block__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  border-radius: .5rem;
  background: var(--primary-light);
  color: var(--primary);
  font-size: .95rem;
  line-height: 1;
}

.report-block__title {
  margin: 0;
  color: var(--text);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .06em;
  line-height: 1.3;
  text-transform: uppercase;
}

.report-block__meta {
  margin-left: auto;
  color: var(--text-muted);
  font-size: .75rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
  text-align: right;
}

.report-block__body {
  padding: .9rem;
}

.report-block__body--flush {
  padding: 0;
}

.report-block__empty {
  margin: 0;
  padding: 1.6rem .9rem;
  color: var(--text-muted);
  font-size: .82rem;
  line-height: 1.5;
  text-align: center;
}

.report-block__note {
  display: flex;
  align-items: flex-start;
  gap: .4rem;
  margin: .75rem 0 0;
  color: var(--text-muted);
  font-size: .78rem;
  line-height: 1.45;
}

.report-block__note--warn {
  color: var(--warning);
}

.report-block__note--flush {
  margin: 0;
  padding: .6rem .9rem;
  border-top: 1px solid var(--border);
}

/* Tonos de encabezado/ícono (mismos tokens del sistema). */
.report-block--ok .report-block__icon {
  background: color-mix(in srgb, var(--success) 14%, var(--surface));
  color: var(--success);
}

.report-block--warn .report-block__icon {
  background: color-mix(in srgb, var(--warning) 14%, var(--surface));
  color: var(--warning);
}

.report-block--bad .report-block__icon {
  background: color-mix(in srgb, var(--danger) 14%, var(--surface));
  color: var(--danger);
}

.report-block--info .report-block__icon {
  background: color-mix(in srgb, var(--primary) 14%, var(--surface));
  color: var(--primary);
}

/* Bloques plegables (<details>) con el mismo encabezado. */
.report-block--details > summary {
  cursor: pointer;
  list-style: none;
}

.report-block--details > summary::-webkit-details-marker {
  display: none;
}

.report-block--details > summary::marker {
  content: "";
}

.report-block--details[open] > summary {
  border-bottom: 1px solid var(--border);
}

.report-block--details:not([open]) > summary {
  border-bottom: 0;
}

.report-block__chevron {
  margin-left: auto;
  color: var(--text-muted);
  font-size: .8rem;
  line-height: 1;
  transition: transform .16s ease;
}

.report-block--details[open] .report-block__chevron {
  transform: rotate(180deg);
}

.report-blocks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr));
  gap: 1rem;
  align-items: start;
  margin-bottom: 1rem;
}

.report-blocks-grid > .report-block {
  margin-bottom: 0;
}

.report-blocks-grid > .report-block--wide {
  grid-column: 1 / -1;
}

/* ── Avisos ───────────────────────────────────────────────────────── */
.report-notice {
  display: flex;
  align-items: flex-start;
  gap: .65rem;
  margin-bottom: 1rem;
  padding: .85rem 1rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: .9rem;
}

.report-notice--warn {
  background: color-mix(in srgb, var(--warning) 8%, var(--surface));
  border-color: color-mix(in srgb, var(--warning) 35%, var(--border));
}

.report-notice--info {
  background: color-mix(in srgb, var(--primary) 6%, var(--surface));
  border-color: color-mix(in srgb, var(--primary) 25%, var(--border));
}

.report-notice__icon {
  flex: 0 0 auto;
  color: var(--warning);
  font-size: 1.1rem;
  line-height: 1.1;
}

.report-notice--info .report-notice__icon {
  color: var(--primary);
}

.report-notice__title {
  margin: 0;
  font-size: .85rem;
  font-weight: 650;
  line-height: 1.35;
}

.report-notice__text {
  margin: .1rem 0 0;
  color: var(--text-muted);
  font-size: .78rem;
  line-height: 1.45;
}

/* ── Lista de alertas (stock) ─────────────────────────────────────── */
.report-alert {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: .6rem .9rem;
  border-top: 1px solid var(--border);
}

.report-alert:first-child {
  border-top: 0;
}

.report-alert__main {
  min-width: 0;
}

.report-alert__name {
  display: block;
  color: var(--text);
  font-size: .82rem;
  font-weight: 600;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.report-alert__meta {
  display: block;
  margin-top: .1rem;
  color: var(--text-muted);
  font-size: .72rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.report-alert__qty {
  flex: 0 0 auto;
  color: var(--text);
  font-size: .8rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
  text-align: right;
  white-space: nowrap;
}

.report-alert__qty strong {
  color: var(--danger);
  font-size: .9rem;
}

.report-alert__qty small {
  display: block;
  color: var(--text-muted);
  font-size: .68rem;
}

/* ── Tablas compactas ─────────────────────────────────────────────── */
.report-table-wrap {
  overflow-x: auto;
}

.report-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

/* El componente global .table-responsive fuerza min-width:760px; en los
   informes la tabla debe ajustarse al ancho de su tarjeta. */
.report-table-wrap .table-modern.report-table {
  min-width: 0;
}

.report-table th,
.report-table td {
  overflow: hidden;
}

.report-table thead th {
  overflow-wrap: anywhere;
  white-space: normal;
}

.report-col--rank {
  width: 3rem;
}

.report-col--code {
  width: 7rem;
}

.report-col--date {
  width: 8rem;
}

.report-col--num {
  width: 5rem;
}

.report-col--amount {
  width: 8.5rem;
}

.report-col--status {
  width: 6.5rem;
}

.report-col--actions {
  width: 6rem;
}

.report-col--wide {
  width: 11rem;
}

.report-table th.report-col--num,
.report-table td.report-cell--num {
  text-align: center;
}

.report-table th.report-col--amount,
.report-table td.report-cell--amount,
.report-table th.report-col--actions,
.report-table td.report-cell--actions {
  text-align: right;
}

.report-table td.report-cell--num,
.report-table td.report-cell--amount {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.report-cell--primary {
  color: var(--text);
  font-weight: 600;
}

.report-cell--muted {
  color: var(--text-muted);
}

.report-cell--money {
  color: var(--success);
  font-weight: 700;
}

.report-cell--money-neg {
  color: var(--danger);
  font-weight: 700;
}

.report-cell--rank {
  color: var(--text-muted);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.report-cell--code {
  color: var(--text-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .75rem;
}

.report-cell--actions {
  white-space: nowrap;
}

.report-table .status-pill {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.report-link {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

.report-link:hover,
.report-link:focus-visible {
  text-decoration: underline;
}

.report-stack {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.report-stack strong {
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.report-stack small,
.report-sub {
  display: block;
  margin-top: .1rem;
  color: var(--text-muted);
  font-size: .7rem;
  line-height: 1.35;
}

/* ── Grupos del informe de reparaciones ───────────────────────────── */
.repair-group + .repair-group {
  border-top: 1px solid var(--border);
}

.repair-group__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .4rem .75rem;
  padding: .55rem .9rem;
  background: color-mix(in srgb, var(--surface-hover) 40%, var(--surface));
  border-bottom: 1px solid var(--border);
}

.repair-group__title {
  margin: 0;
  color: var(--text);
  font-size: .8rem;
  font-weight: 650;
  line-height: 1.3;
}

/* ── Tablet: la tabla se ajusta dentro del wrapper ────────────────── */
@media (max-width: 1023.98px) {
  .report-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Tablas de 7 columnas: en tablet conservan ancho legible y se desplazan
   dentro de su contenedor; nunca generan scroll de página. */
@media (min-width: 700px) and (max-width: 1023.98px) {
  .report-table-wrap .table-modern.report-table.report-table--wide {
    min-width: 50rem;
  }
}

@media (min-width: 1024px) {
  .report-table-wrap {
    overflow-x: visible;
  }
}

/* ── Celular: filtros apilados y tablas como tarjetas ─────────────── */
@media (max-width: 699.98px) {
  .report-filters {
    flex-direction: column;
    align-items: stretch;
  }

  .report-filters__fields {
    flex: 1 1 auto;
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
  }

  .report-filters__field {
    width: 100%;
    max-width: none;
  }

  .report-filters__fields > .report-filters__range {
    grid-column: auto;
    flex-direction: column;
  }

  .report-filters__actions {
    flex-wrap: wrap;
    justify-content: stretch;
    margin-left: 0;
  }

  .report-filters__actions .btn-act {
    flex: 1 1 auto;
  }

  .report-block__head {
    padding: .6rem .75rem;
  }

  .report-block__meta {
    width: 100%;
    margin-left: 0;
    text-align: left;
  }

  .report-block__body {
    padding: .75rem;
  }

  .report-table-wrap {
    overflow: visible;
    padding: .75rem;
  }

  .report-table,
  .report-table tbody {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .report-table thead {
    display: none;
  }

  .report-table tbody tr.list-row {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    margin-bottom: .6rem;
    padding: .7rem .8rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: .8rem;
  }

  .report-table tbody tr.list-row:last-child {
    margin-bottom: 0;
  }

  .report-table tbody tr.list-row:hover {
    background: var(--surface-hover);
  }

  .report-table tbody td {
    display: block;
    height: auto;
    padding: 0;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    border: 0;
  }

  .report-table tbody td.report-cell--primary {
    order: -1;
    padding-bottom: .15rem;
    color: var(--text);
    font-size: .9rem;
    font-weight: 650;
    overflow-wrap: anywhere;
  }

  .report-table tbody td.report-cell--primary .list-ellipsis {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .report-table tbody td[data-label] {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: .75rem;
    min-width: 0;
  }

  .report-table tbody td[data-label]::before {
    content: attr(data-label) ":";
    flex: 0 0 auto;
    color: var(--text-muted);
    font-size: .68rem;
    font-weight: 650;
    line-height: 1.35;
  }

  .report-table tbody td[data-label] > * {
    min-width: 0;
    text-align: right;
  }

  .report-table tbody td[data-label] .list-ellipsis {
    overflow: visible;
    font-size: .8rem;
    text-overflow: clip;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .report-table tbody td.report-cell--amount,
  .report-table tbody td.report-cell--num {
    text-align: right;
  }

  .report-table tbody td.report-cell--actions {
    margin-top: .15rem;
    padding-top: .55rem;
    border-top: 1px solid var(--border);
  }

  .report-table tbody td .report-stack strong {
    overflow: visible;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .report-table tbody tr.list-row--empty {
    display: block;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: .8rem;
  }

  .report-table tbody tr.list-row--empty td {
    display: block;
    padding: 0;
  }

  .report-alert {
    flex-direction: column;
    gap: .35rem;
  }

  .report-alert__qty {
    text-align: left;
  }

  .report-notice {
    padding: .75rem .85rem;
  }
}

/* Puntero grueso: áreas táctiles cómodas sin agrandar las filas de escritorio. */
@media (pointer: coarse) {
  .report-back-link {
    min-height: 44px;
  }

  .report-filters__actions .btn-act {
    min-height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .report-back-link,
  .report-block__chevron {
    transition: none;
  }
}
