/* ============================================================
   Despensas San José — Sistema de Control
   Azul marino #14285C sobre blanco
   (más oscuro que el navy #000080 de Gourmetería, para no confundirlos)
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Barlow:wght@500;600;700&family=Source+Sans+3:wght@400;600;700&display=swap');

:root {
  --navy: #14285c;
  --navy-dark: #0c1b42;
  --navy-08: rgba(20, 40, 92, .08);
  --navy-15: rgba(20, 40, 92, .15);
  /* Blanco y azul es la base. Lo que tiene que resaltar va en verde;
     el rojo se queda solo para lo que está mal (vencido, faltante, margen bajo). */
  --resalte: #0f7b40;
  --texto: #14142b;
  --suave: #5b5b76;
  --linea: #e2e2ee;
  --fondo: #f6f7fb;
  --ok: #0f7b40;
  --ok-bg: #e6f5ec;
  --alerta: #14285c;
  --alerta-bg: rgba(20, 40, 92, .15);
  --error: #b3261e;
  --error-bg: #fdeceb;
  --radio: 10px;
  --sombra: 0 1px 3px rgba(0, 0, 40, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Source Sans 3', system-ui, sans-serif;
  color: var(--texto);
  background: var(--fondo);
  font-size: 15px;
}

h1, h2, h3, th, .btn, .tab { font-family: 'Barlow', system-ui, sans-serif; }
h1 { font-size: 1.75rem; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; margin: 0 0 14px; }
a { color: var(--navy); }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    linear-gradient(rgba(255,255,255,.94), rgba(255,255,255,.94)),
    repeating-linear-gradient(0deg, var(--navy-08) 0 1px, transparent 1px 46px),
    repeating-linear-gradient(90deg, var(--navy-08) 0 1px, transparent 1px 46px);
}
.login-card {
  width: 100%; max-width: 400px; background: #fff; padding: 40px 34px;
  border-radius: 14px; box-shadow: 0 10px 40px rgba(0, 0, 60, .12);
  border-top: 5px solid var(--navy);
}
.login-card .marca { text-align: center; margin-bottom: 26px; }
.login-card .marca img { max-width: 250px; width: 100%; }
.login-card .marca .rotulo {
  font-family: 'Barlow', sans-serif; font-weight: 600; color: var(--navy);
  letter-spacing: .18em; font-size: .72rem; margin-top: 10px;
}

/* ---------- Estructura ---------- */
header.barra {
  background: var(--navy); color: #fff; padding: 14px 26px;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
}
header.barra .logo { display: flex; align-items: center; gap: 14px; min-width: 0; }
header.barra .logo img { height: 38px; width: auto; }
header.barra .logo .rotulo {
  font-family: 'Barlow', sans-serif; font-weight: 500; font-size: .74rem;
  letter-spacing: .16em; text-transform: uppercase; opacity: .8;
  padding-left: 14px; border-left: 1px solid rgba(255, 255, 255, .3); white-space: nowrap;
}
header.barra .sesion { display: flex; align-items: center; gap: 16px; font-size: .88rem; }
header.barra .sesion .quien { text-align: right; line-height: 1.25; }
header.barra .sesion .quien span { display: block; opacity: .72; font-size: .78rem; }

nav.tabs {
  background: #fff; border-bottom: 1px solid var(--linea);
  display: flex; gap: 2px; padding: 0 18px; overflow-x: auto;
}
nav.tabs a {
  padding: 14px 16px; text-decoration: none; color: var(--suave);
  font-family: 'Barlow', sans-serif; font-weight: 600; font-size: .9rem;
  border-bottom: 3px solid transparent; white-space: nowrap;
}
nav.tabs a:hover { color: var(--navy); }
nav.tabs a.activo { color: var(--navy); border-bottom-color: var(--navy); }

main { max-width: 1320px; margin: 0 auto; padding: 26px 22px 60px; }
.encabezado { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.encabezado .acciones { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Tarjetas ---------- */
.tarjeta { background: #fff; border: 1px solid var(--linea); border-radius: var(--radio); box-shadow: var(--sombra); padding: 20px; }
.tarjeta + .tarjeta { margin-top: 18px; }
.rejilla { display: grid; gap: 16px; }
.rejilla.c2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.rejilla.c3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.rejilla.c4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

.metrica { background: #fff; border: 1px solid var(--linea); border-left: 4px solid var(--navy); border-radius: var(--radio); padding: 16px 18px; }
.metrica .rotulo { font-size: .74rem; letter-spacing: .1em; color: var(--suave); font-weight: 600; }
.metrica .valor { font-family: 'Barlow', sans-serif; font-size: 1.7rem; font-weight: 700; color: var(--navy); margin-top: 4px; }
.metrica .nota { font-size: .82rem; color: var(--suave); margin-top: 2px; }

/* ---------- Tablas ---------- */
.tabla-envoltura { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: .74rem; letter-spacing: .06em; color: var(--suave);
  font-weight: 600; padding: 10px 12px; border-bottom: 2px solid var(--linea); white-space: nowrap;
}
td { padding: 11px 12px; border-bottom: 1px solid var(--linea); vertical-align: middle; }
tbody tr:hover { background: rgba(20, 40, 92, .03); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.vacio { padding: 34px 12px; text-align: center; color: var(--suave); }

/* ---------- Formularios ---------- */
.campo { margin-bottom: 14px; }
.campo label { display: block; font-size: .82rem; font-weight: 600; color: var(--navy); margin-bottom: 5px; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--linea); border-radius: 7px;
  font-family: inherit; font-size: .95rem; background: #fff; color: var(--texto);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--navy-15); border-color: var(--navy); }
input[type=checkbox] { width: auto; }
textarea { min-height: 74px; resize: vertical; }
.linea-campos { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.ayuda { font-size: .8rem; color: var(--suave); margin-top: 4px; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  padding: 9px 16px; border-radius: 7px; border: 1px solid var(--navy);
  background: #fff; color: var(--navy); font-weight: 600; font-size: .88rem;
  cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--navy-08); }
.btn.primario { background: var(--navy); color: #fff; }
.btn.primario:hover { background: var(--navy-dark); }
.btn.tenue { border-color: var(--linea); color: var(--suave); }
.btn.tenue:hover { background: #f2f2f7; }
.btn.peligro { border-color: var(--error); color: var(--error); }
.btn.grande { width: 100%; padding: 12px; font-size: 1rem; }
.btn.chico { padding: 6px 11px; font-size: .8rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Etiquetas ---------- */
.etiqueta {
  display: inline-block; padding: 3px 9px; border-radius: 20px;
  font-size: .74rem; font-weight: 600; background: var(--navy-08); color: var(--navy);
}
.etiqueta.ok { background: var(--ok-bg); color: var(--ok); }
.etiqueta.alerta { background: var(--alerta-bg); color: var(--alerta); }
.etiqueta.error { background: var(--error-bg); color: var(--error); }
.etiqueta.gris { background: #eef0f5; color: var(--suave); }

/* ---------- Modal ---------- */
.modal-fondo {
  position: fixed; inset: 0; background: rgba(10, 10, 40, .45);
  display: none; align-items: flex-start; justify-content: center; padding: 40px 18px; z-index: 50; overflow-y: auto;
}
.modal-fondo.abierto { display: flex; }
.modal {
  background: #fff; border-radius: 12px; width: 100%; max-width: 620px;
  box-shadow: 0 20px 60px rgba(0, 0, 60, .25);
}
.modal.ancho { max-width: 980px; }
.modal header { padding: 18px 22px; border-bottom: 1px solid var(--linea); display: flex; align-items: center; }
.modal header h2 { margin: 0; }
.modal header .cerrar { margin-left: auto; background: none; border: none; font-size: 1.5rem; color: var(--suave); cursor: pointer; line-height: 1; padding: 0 4px; }
.modal .cuerpo { padding: 22px; }
.modal footer { padding: 16px 22px; border-top: 1px solid var(--linea); display: flex; gap: 10px; justify-content: flex-end; }

/* ---------- Avisos ---------- */
/* Buscador de las listas largas (DSJ.buscadorListas): aparece pegado a la lista que se tocó. */
.lista-buscable {
  position: fixed; z-index: 200; display: flex; flex-direction: column; min-height: 0;
  background: #fff; border: 1px solid var(--linea); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 40, .2);
}
.lista-buscable input { margin: 8px; width: calc(100% - 16px); padding: 8px 10px; }
.lista-buscable ul { list-style: none; margin: 0; padding: 0 6px 6px; overflow-y: auto; min-height: 0; }
.lista-buscable li { padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: .92rem; line-height: 1.25; }
.lista-buscable li.marcado { background: var(--navy-08); }
.lista-buscable li.actual { font-weight: 700; color: var(--navy); }
.lista-buscable li.nada { color: var(--suave); cursor: default; }
@media print { .lista-buscable { display: none; } }
#avisos { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 90; }
.aviso {
  background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0, 0, 60, .25); font-size: .9rem; max-width: 340px;
}
.aviso.error { background: var(--error); }
.aviso.ok { background: var(--ok); }

/* ---------- Selector de periodo (mes / año) ---------- */
.periodo { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.periodo-modo { display: inline-flex; border: 1px solid var(--linea); border-radius: 8px; overflow: hidden; }
.periodo-modo button {
  border: none; background: #fff; color: var(--suave); padding: 8px 16px; cursor: pointer;
  font-family: 'Barlow', sans-serif; font-weight: 600; font-size: .86rem;
}
.periodo-modo button + button { border-left: 1px solid var(--linea); }
.periodo-modo button.activo { background: var(--navy); color: #fff; }
.periodo-nav { display: inline-flex; align-items: center; gap: 6px; }
.periodo-nav button {
  width: 36px; height: 36px; border: 1px solid var(--linea); border-radius: 8px; background: #fff;
  color: var(--navy); font-size: 1.35rem; line-height: 1; cursor: pointer;
}
.periodo-nav button:hover { background: var(--navy-08); border-color: var(--navy); }
.periodo-nombre {
  display: inline-block; min-width: 180px; text-align: center;
  font-family: 'Barlow', sans-serif; font-size: 1.2rem; color: var(--navy);
}
.periodo-nombre::first-letter { text-transform: uppercase; }

/* ---------- Editor del calendario de pagos ---------- */
.plan-formas { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.plan-formas button {
  border: 1px solid var(--linea); background: #fff; color: var(--suave); border-radius: 20px;
  padding: 7px 13px; cursor: pointer; font-family: 'Barlow', sans-serif; font-weight: 600; font-size: .84rem;
}
.plan-formas button:hover { border-color: var(--navy); color: var(--navy); }
.plan-formas button.activo { background: var(--navy); border-color: var(--navy); color: #fff; }
.monto-fijo { padding: 8px 0; font-family: 'Barlow', sans-serif; font-weight: 700; font-size: 1.1rem; color: var(--navy); }
.plan-filas td { padding: 6px; }
.plan-filas input { padding: 6px 8px; font-size: .9rem; }
.plan-filas .filtro-check { margin-bottom: 4px; }
.plan-resumen { list-style: none; margin: 14px 0 0; padding: 10px 14px; background: #f4f6fa; border-radius: 8px; }
.plan-resumen li { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; font-size: .9rem; }
.plan-resumen li.falta { color: var(--error); font-weight: 600; border-top: 1px dashed var(--linea); margin-top: 4px; padding-top: 6px; }
.plan-resumen li.cuadra { color: var(--suave); border-top: 1px dashed var(--linea); margin-top: 4px; padding-top: 6px; }

.buscador { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.buscador input[type=search] { flex: 0 1 320px; min-width: 220px; }
.filtro-check { display: flex; align-items: center; gap: 6px; font-size: .88rem; color: var(--suave); white-space: nowrap; }

/* ============================================================
   Celular y tablet
   ============================================================ */

/* Tablas que no caben: cada renglón se vuelve una tarjeta con "columna: valor".
   La clase la pone app.js cuando la tabla es más ancha que su espacio (y siempre en celular). */
table.como-tarjetas > thead { display: none; }
table.como-tarjetas, table.como-tarjetas > tbody, table.como-tarjetas > tfoot,
table.como-tarjetas > tbody > tr, table.como-tarjetas > tfoot > tr { display: block; width: 100%; }
/* Cada tarjeta: el primer dato como título y el resto en dos columnas, con la etiqueta chica
   arriba del valor. Lo que viene vacío no se muestra. */
table.como-tarjetas > tbody > tr, table.como-tarjetas > tfoot > tr {
  border: 1px solid var(--linea); border-radius: 9px; padding: 8px 11px; margin-bottom: 10px; background: #fff;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 14px; row-gap: 2px;
}
table.como-tarjetas > tbody > tr:hover { background: #fff; }
/* Varias tarjetas por fila cuando hay espacio (tablet); una sola en celular. */
table.como-tarjetas > tbody {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 10px; align-items: start;
}
table.como-tarjetas > tbody > tr { margin-bottom: 0; }
table.como-tarjetas > tbody > tr:has(> td[colspan]) { grid-column: 1 / -1; }
table.como-tarjetas > tfoot > tr { margin-top: 10px; }
table.como-tarjetas > tbody > tr > td, table.como-tarjetas > tfoot > tr > td, table.como-tarjetas > tfoot > tr > th {
  display: block; position: static; border: none; padding: 5px 0; min-height: 0;
  text-align: left; white-space: normal; font-size: .85rem; min-width: 0; overflow-wrap: anywhere;
}
table.como-tarjetas > tbody > tr > td::before, table.como-tarjetas > tfoot > tr > *::before {
  content: attr(data-label); display: block; margin-bottom: 1px;
  font-family: 'Barlow', sans-serif; font-weight: 600; font-size: .6rem; letter-spacing: .05em;
  text-transform: uppercase; color: var(--suave); white-space: normal;
}
/* El título de la tarjeta: el primer dato con contenido, a todo lo ancho. */
table.como-tarjetas td[data-titulo] {
  grid-column: 1 / -1; font-size: .92rem; padding: 0 0 6px; margin-bottom: 3px; border-bottom: 1px solid var(--linea);
}
table.como-tarjetas td[data-titulo]::before { font-size: .62rem; }
/* Sin etiqueta, con botones o que abarcan columnas: a todo lo ancho. */
table.como-tarjetas td[data-label=""], table.como-tarjetas th[data-label=""],
table.como-tarjetas td[colspan], table.como-tarjetas td:has(.btn) { grid-column: 1 / -1; }
table.como-tarjetas td[data-label=""]::before, table.como-tarjetas th[data-label=""]::before { content: none; }
table.como-tarjetas td:has(.btn):not([data-titulo]) { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 8px; }
table.como-tarjetas td:has(.btn):not([data-titulo])::before { width: 100%; }
table.como-tarjetas td[data-vacio] { display: none; }
table.como-tarjetas tr[hidden], table.como-tarjetas td[hidden] { display: none !important; }
table.como-tarjetas td.vacio { text-align: center; padding: 22px 0; grid-column: 1 / -1; }
table.como-tarjetas td input, table.como-tarjetas td select { max-width: 100%; }

/* Botón de menú: solo en celular */
.btn-menu {
  display: none; align-items: center; gap: 8px; background: rgba(255, 255, 255, .12); color: #fff;
  border: 1px solid rgba(255, 255, 255, .35); border-radius: 8px; padding: 8px 12px; cursor: pointer;
  font-family: 'Barlow', sans-serif; font-weight: 600; font-size: .95rem;
}
.btn-menu .icono { font-size: 1.2rem; line-height: 1; }

@media (max-width: 1100px) {
  .btn-menu { display: inline-flex; }
  header.barra .logo .rotulo { display: none; }
  nav.tabs { display: none; flex-direction: column; padding: 4px 0; gap: 0; box-shadow: 0 8px 20px rgba(0, 0, 40, .12); }
  nav.tabs.abierto { display: flex; }
  nav.tabs a { border-bottom: none; border-left: 4px solid transparent; padding: 14px 20px; font-size: 1rem; }
  nav.tabs a.activo { border-left-color: var(--navy); background: var(--navy-08); }
}

@media (max-width: 640px) {
  header.barra { padding: 10px 14px; gap: 8px; }
  header.barra .logo img { height: 30px; }
  header.barra .sesion { gap: 8px; }
  header.barra .sesion .quien { display: none; }
  header.barra .sesion .btn { padding: 8px 10px; font-size: .82rem; }
  main { padding: 16px 12px 50px; }
  h1 { font-size: 1.4rem; }
  .tarjeta { padding: 14px; }

  /* Cifras de dos en dos */
  .rejilla.c3, .rejilla.c4 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .metrica { padding: 11px 12px; }
  .metrica .valor { font-size: 1.2rem; }
  .metrica .rotulo { font-size: .66rem; }

  /* 16 px evita que el iPhone haga zoom al escribir; botones cómodos para el dedo */
  input, select, textarea { font-size: 16px; }
  .btn { min-height: 40px; }
  .btn.chico { min-height: 34px; }
  .buscador input[type=search] { flex: 1 1 100%; min-width: 0; }
  .encabezado .acciones { width: 100%; margin-left: 0; }
  .encabezado .acciones .btn { flex: 1 1 auto; }

  /* Ventanas emergentes a pantalla completa */
  .modal-fondo { padding: 0; align-items: stretch; }
  .modal, .modal.ancho { max-width: none; border-radius: 0; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
  .modal .cuerpo { padding: 16px; flex: 1; }
  .modal header { padding: 14px 16px; position: sticky; top: 0; background: #fff; z-index: 2; }
  .modal footer { padding: 12px 16px; flex-wrap: wrap; position: sticky; bottom: 0; background: #fff; }
  .modal footer .btn { flex: 1 1 auto; }
  /* Dentro de una ventana en celular se desplaza todo junto, sin listas con su propio scroll. */
  .modal .tabla-envoltura { max-height: none !important; overflow: visible !important; }
}

/* ---------- Comprobantes de entrega ---------- */
.comprobantes-acciones { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.comprobantes-lista { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.comprobante { margin: 0; border: 1px solid var(--linea); border-radius: 9px; overflow: hidden; background: #fff; cursor: pointer; }
.comprobante:hover { border-color: var(--navy); }
.comprobante .vista {
  aspect-ratio: 4 / 3; background: #f1f2f6; display: flex; align-items: center; justify-content: center;
}
.comprobante .vista img { width: 100%; height: 100%; object-fit: cover; display: block; }
.comprobante .vista .pdf {
  font-family: 'Barlow', sans-serif; font-weight: 700; color: var(--navy); font-size: 1.1rem;
  border: 2px solid var(--navy); border-radius: 6px; padding: 6px 12px;
}
.comprobante figcaption { padding: 8px 10px; display: flex; flex-direction: column; gap: 5px; align-items: flex-start; }
.comprobante figcaption .ayuda { margin: 0; }

@media print {
  .comprobantes-acciones { display: none !important; }
  .comprobantes-lista { grid-template-columns: repeat(2, 1fr); }
  .comprobante { break-inside: avoid; }
  .comprobante .vista { aspect-ratio: auto; }
  .comprobante .vista img { height: auto; object-fit: contain; }
}

/* ============================================================
   Impresión — cualquier ventana se imprime o se guarda en PDF
   ============================================================ */
/* Encabezado de la hoja: solo aparece en el papel. */
.hoja-encabezado { display: none; }

@media print {
  @page { margin: 12mm 10mm; }
  html { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  html, body { background: #fff !important; font-size: 11.5px; }

  /* Fuera todo lo que sirve para operar, no para leer. */
  header.barra, nav.tabs, #avisos, .btn, .buscador, .filtro-check, .periodo-modo,
  .periodo-nav button, .periodos, .segmento, .btn-menu, .cerrar,
  .modal footer, .encabezado .acciones .etiqueta.solo-pantalla { display: none !important; }

  main { max-width: none !important; padding: 0 !important; margin: 0 !important; }
  .encabezado { margin-bottom: 10px; }
  h1 { font-size: 1.2rem; }
  h2 { font-size: 1rem; margin-bottom: 8px; }

  .hoja-encabezado {
    display: flex !important; align-items: center; gap: 12px; width: 100%;
    border-bottom: 2px solid var(--navy); padding-bottom: 8px; margin-bottom: 14px;
  }
  .hoja-encabezado img { height: 38px; width: auto; }
  .hoja-encabezado .que { flex: 1; line-height: 1.3; }
  .hoja-encabezado .que strong { display: block; font-family: 'Barlow', sans-serif; font-size: 1.15rem; color: var(--navy); }
  .hoja-encabezado .que span { color: var(--suave); font-size: .92rem; }
  .hoja-encabezado .cuando { text-align: right; color: var(--suave); font-size: .78rem; line-height: 1.4; }

  /* Las tarjetas no se parten a la mitad entre dos páginas. */
  .tarjeta { box-shadow: none !important; border: 1px solid #d8d8e4; break-inside: avoid; page-break-inside: avoid; padding: 12px; }
  .metrica { break-inside: avoid; padding: 10px 12px; }
  .metrica .valor { font-size: 1.25rem; }
  .rejilla { gap: 8px; }

  /* Las listas con scroll propio se imprimen completas, y ninguna vuelve a ser tarjeta. */
  .tabla-envoltura { overflow: visible !important; max-height: none !important; }
  table.como-tarjetas { display: table !important; }
  table.como-tarjetas > thead { display: table-header-group !important; }
  table.como-tarjetas > tbody { display: table-row-group !important; }
  table.como-tarjetas > tfoot { display: table-footer-group !important; }
  table.como-tarjetas > tbody > tr, table.como-tarjetas > tfoot > tr {
    display: table-row !important; border: none; border-radius: 0; padding: 0; margin: 0; background: none;
  }
  table.como-tarjetas > tbody > tr > td, table.como-tarjetas > tfoot > tr > td,
  table.como-tarjetas > tfoot > tr > th {
    display: table-cell !important; position: static; padding: 6px 8px; min-height: 0;
    text-align: inherit; border-top: none; border-bottom: 1px solid var(--linea);
  }
  table.como-tarjetas td::before, table.como-tarjetas th::before { content: none !important; }
  table.como-tarjetas > tbody > tr > td.num, table.como-tarjetas > tfoot > tr > td.num { text-align: right; }

  th, td { padding: 5px 7px; font-size: 10.5px; }
  thead { display: table-header-group; }
  tr { break-inside: avoid; page-break-inside: avoid; }
  tbody tr:hover { background: none !important; }
  .matriz th:first-child, .matriz td:first-child { position: static !important; }

  /* Ventanas emergentes: por omisión no se imprimen. */
  .modal-fondo { display: none !important; }

  /* Imprimiendo SOLO la ventana abierta (una venta, un estado de cuenta, un conteo). */
  body.imprime-modal > main, body.imprime-modal > .tarjeta { display: none !important; }
  body.imprime-modal .modal-fondo.abierto {
    display: block !important; position: static; padding: 0; overflow: visible; background: none; z-index: auto;
  }
  body.imprime-modal .modal-fondo.abierto .modal {
    max-width: none; width: 100%; border: none; box-shadow: none; border-radius: 0; min-height: 0;
  }
  body.imprime-modal .modal header { border: none; padding: 0 0 8px; position: static; }
  body.imprime-modal .modal .cuerpo { padding: 0; max-height: none !important; overflow: visible !important; }
  body.imprime-modal .modal .cuerpo .tabla-envoltura { max-height: none !important; overflow: visible !important; }

  /* Imprimiendo la pantalla completa de un pedido. */
  body.imprime-pantalla > main { display: none !important; }
  body.imprime-pantalla .pantalla.abierta { position: static; overflow: visible; background: #fff; }
  body.imprime-pantalla .pantalla .barra-sup {
    background: #fff !important; color: var(--navy) !important; position: static; padding: 0 0 10px;
    border-bottom: 1px solid var(--linea);
  }
  body.imprime-pantalla .pantalla .contenido { padding: 12px 0 0; max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
