/* Diseño de la factura imprimible (A4) y reglas de impresión.
   Basado en la plantilla de referencia con los colores del logo:
   azul #2b2e96 / #1c1f6b · amarillo #fdb600 · naranja #ff5d17 */

#mb.wide {
  max-width: 780px;
}
.ivw {
  overflow: hidden;
  border-radius: 6px;
  margin-bottom: 14px;
  background: #fff;
}
.iv {
  position: relative;
  overflow: hidden;
  width: 720px;
  min-height: 1018px;
  background: #fff;
  color: #2b2b36;
  font:
    12px/1.5 "DM Sans",
    system-ui,
    sans-serif;
  display: flex;
  flex-direction: column;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.iv > * {
  position: relative;
  z-index: 1;
}

/* Marca de agua de factura anulada */
.iv-wm {
  position: absolute !important;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 5 !important;
}
.iv-wm span {
  font-size: 100px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: rgba(220, 38, 38, 0.2);
  border: 10px solid rgba(220, 38, 38, 0.2);
  padding: 4px 28px;
  transform: rotate(-24deg);
}

/* Formas decorativas */
.iv > .iv-s1,
.iv > .iv-s2,
.iv > .iv-s3 {
  position: absolute;
  height: auto;
  pointer-events: none;
  z-index: 0;
}
.iv-s1 {
  top: 0;
  left: 0;
  width: 69%;
}
.iv-s2 {
  left: 0;
  bottom: 0;
  width: 65%;
}
.iv-s3 {
  right: 0;
  bottom: 0;
  width: 42%;
}
.iv-logo {
  position: absolute !important;
  top: 22px;
  left: 34px;
  height: 78px;
  width: auto;
  z-index: 2 !important;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.3));
}

/* Datos del cliente, de la factura y del pago */
.iv-top {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-areas:
    "l r"
    "l pm";
  grid-template-rows: auto 1fr;
  gap: 0 24px;
  padding: 0 38px;
  min-height: 330px;
}
.iv-l {
  grid-area: l;
  padding-top: 190px;
}
.iv-r {
  grid-area: r;
  padding-top: 34px;
}
.iv-pm {
  grid-area: pm;
  padding: 18px 0 0 38%;
  font-size: 10px;
  color: #5b5d70;
  line-height: 1.6;
}
.iv-k {
  color: #fdb600;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.iv-nm {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2;
  color: #14151f;
  margin: 3px 0 1px;
}
.iv-sb {
  font-size: 10.5px;
  color: #6b6d82;
  margin-bottom: 8px;
}
.iv-ln {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1px 14px;
  font-size: 10.5px;
  line-height: 1.65;
  color: #3a3b4c;
}
.iv-ln b {
  font-weight: 700;
  color: #14151f;
}
.iv-tt {
  text-align: right;
  font-size: 40px;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: #fdb600;
  line-height: 1;
}
.iv-mt {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1px 16px;
  margin: 12px 0 0 auto;
  width: max-content;
  font-size: 10.5px;
  line-height: 1.65;
}
.iv-mt b {
  font-weight: 700;
  color: #14151f;
}
.iv-mt span {
  color: #3a3b4c;
}
.iv-pm h4 {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 700;
  color: #fdb600;
}
.iv-pm b {
  color: #14151f;
}
.iv-pm i {
  display: block;
  font-style: normal;
  color: #7a7c8e;
}
.iv-pm i.anul {
  color: #dc2626;
  font-weight: 600;
}

/* Tabla de conceptos: encabezado amarillo en forma de píldora, filas grises alternas */
.iv-t {
  width: calc(100% - 76px);
  margin: 0 38px;
  border-collapse: separate;
  border-spacing: 0 4px;
  table-layout: fixed;
}
.iv-t th {
  padding: 12px 6px;
  color: #1c1f6b;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-align: center;
  background: #fdb600;
}
.iv-t th:first-child {
  border-radius: 20px 0 0 20px;
}
.iv-t th:last-child {
  border-radius: 0 20px 20px 0;
}
.iv-t th:nth-child(2) {
  text-align: left;
  padding-left: 14px;
}
.iv-t td {
  height: 47px;
  padding: 4px 8px;
  text-align: center;
  font-size: 10.5px;
  color: #3a3b4c;
}
.iv-t tr:nth-child(even) td {
  background: #ececee;
}
.iv-t td:first-child {
  border-radius: 20px 0 0 20px;
  color: #70728a;
}
.iv-t td:last-child {
  border-radius: 0 20px 20px 0;
}
.iv-t td:nth-child(2) {
  text-align: left;
  padding-left: 14px;
}
.it-t {
  font-weight: 700;
  font-size: 11px;
  color: #17182a;
}
.it-s {
  font-size: 8.5px;
  color: #66687c;
  line-height: 1.35;
}
.iv-t td.neg {
  color: #c2410c;
}

/* Términos a la izquierda; resumen, total y firma a la derecha */
.iv-bt {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 30px;
  padding: 20px 38px 0;
}
.iv-tn b {
  display: block;
  color: #fdb600;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 5px;
}
.iv-tn p {
  margin: 0 0 18px;
  font-size: 9.5px;
  line-height: 1.6;
  color: #4a4c60;
}
.iv-tn strong {
  display: block;
  color: #14151f;
  font-size: 13px;
}
.iv-sm {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 5px 14px;
  font-size: 10.5px;
  color: #3a3b4c;
  padding: 0 16px 12px;
}
.iv-sm span:nth-child(even) {
  text-align: right;
  font-weight: 600;
}
.iv-tot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 18px;
  border-radius: 22px;
  background: #fdb600;
  color: #1c1f6b;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 6px;
}
.iv-tot span:last-child {
  font-size: 14px;
}
.iv-tot.sd {
  background: #2b2e96;
  color: #fff;
}
.iv-tot.sd span:last-child {
  color: #fdb600;
}
.iv-sg {
  margin-top: 34px;
  text-align: center;
  font-size: 9.5px;
  color: #6b6d82;
}
.iv-sg i {
  display: block;
  border-top: 1px solid #c9c9d2;
  margin: 0 0 6px;
}
.iv-sg b {
  display: block;
  font-size: 11px;
  color: #14151f;
}

/* Contactos sobre la franja azul del pie */
.iv-ft {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 52%;
  padding: 0 0 18px 34px;
}
.iv-fi {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 8.5px;
  line-height: 1.35;
  color: #fff;
  min-width: 0;
  overflow-wrap: anywhere;
}
.iv-fi s {
  flex: none;
  display: grid;
  place-items: center;
  width: 14px;
  height: 14px;
  text-decoration: none;
}
.iv-fi svg {
  width: 13px;
  height: 13px;
}

@page {
  size: A4;
  margin: 0;
}
@media print {
  /* Solo se imprime la factura: se oculta la app, los botones y los avisos */
  body {
    background: #fff !important;
  }
  .app,
  #toasts,
  #mb > *:not(.ivw) {
    display: none !important;
  }
  #m,
  #m.on {
    position: static;
    display: block;
    background: none;
    backdrop-filter: none;
    animation: none;
  }
  #mb,
  #mb.wide {
    max-width: none;
    max-height: none;
    overflow: visible;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
    animation: none;
  }
  .ivw {
    margin: 0;
    border-radius: 0;
    overflow: visible;
  }
  #rc {
    zoom: 1 !important;
    width: 100%;
    min-height: 296mm;
  }
}
