:root {
  --azul: #003149;
  --azul-md: #0665a5;
  --azul-lt: #e6eff6;
  --rojo: #aa0d2e;
  --rojo-lt: #f9e6ea;
  --bg: #f2f5fb;
  --card: #ffffff;
  --texto: #2d3748;
  --suave: #6b7280;
  --borde: rgba(0, 49, 73, 0.10);
  --sombra: 0 4px 24px rgba(0, 49, 73, 0.08);
  --sombra-h: 0 14px 40px rgba(0, 49, 73, 0.16);
  --r: 18px;
  --r-sm: 10px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  background: var(--bg);
  margin: 0;
  font-family: 'Sora', sans-serif;
  color: var(--texto);
}

/* ============================================================
   MÓDULO: FACTURA
   ============================================================ */
.factura-wrap {
  width: min(1080px, calc(100% - 48px));
  max-width: 1080px;
  margin: 48px auto 80px;
  padding: 0;
}

.section-consulta {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 24px;
}

.section-consulta-line {
  flex: 1;
  height: 1px;
  background: var(--borde);
}

.section-consulta-badge {
  background: var(--azul);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 8px 16px;
  border-radius: 20px;
  white-space: nowrap;
}

.f-card {
  background: var(--card);
  border-radius: var(--r);
  border: 1px solid var(--borde);
  box-shadow: var(--sombra);
  margin-bottom: 20px;
  overflow: hidden;
  transition: box-shadow .3s, transform .3s;
}

.f-card:hover {
  box-shadow: var(--sombra-h);
  transform: translateY(-3px);
}

.f-card-strip {
  height: 3px;
  background: linear-gradient(90deg, var(--azul) 0%, var(--rojo) 100%);
}

.f-card-body {
  padding: 38px 42px 42px;
}

.f-card-title {
  font-size: clamp(1.35rem, 2.2vw, 1.75rem);
  font-weight: 700;
  color: var(--azul);
  margin: 0 0 22px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.f-card-title .ic {
  width: 32px;
  height: 32px;
  background: var(--azul-lt);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.0rem;
  flex-shrink: 0;
}

.items {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  list-style: none;
  padding: 0;
  counter-reset: s;
  margin: 0 0 24px;
}

.items li {
  position: relative;
  min-height: 68px;
  padding: 14px 16px 14px 48px;
  font-size: .98rem;
  color: var(--suave);
  border: 1px solid var(--borde);
  border-radius: 10px;
  background: #f8fafc;
  counter-increment: s;
  line-height: 1.5;
}

.items li:last-child {
  border-bottom: 1px solid var(--borde);
}

.items li::before {
  content: counter(s);
  position: absolute;
  left: 0;
  top: 14px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--azul-lt);
  color: var(--azul);
  font-size: .72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid rgba(0, 49, 73, .15);
}

.items li strong {
  color: var(--azul);
}

.tip {
  background: var(--azul-lt);
  border-left: 3px solid var(--azul);
  border-radius: var(--r-sm);
  padding: 12px 15px;
  font-size: .95rem;
  color: var(--azul);
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.fields-grid {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 14px;
  align-items: end;
  margin-top: 28px;
  padding: 22px;
  border: 1px solid var(--borde);
  border-radius: 12px;
  background: #f8fafc;
}

.fg label {
  display: block;
  font-size: .84rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--azul);
  margin-bottom: 6px;
}

.fg input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid rgba(0, 49, 73, .14);
  border-radius: var(--r-sm);
  font-size: 1rem;
  color: var(--texto);
  background: #f8fafc;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

.fg input:focus {
  border-color: var(--azul);
  box-shadow: 0 0 0 3px rgba(0, 49, 73, .08);
  background: #fff;
}

.btn-exec {
  padding: 10px 24px;
  background: var(--rojo);
  color: #fff;
  border: none;
  border-radius: 30px;
  font-size: .94rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  letter-spacing: .3px;
  transition: background .25s, box-shadow .25s, transform .2s;
}

.btn-exec:hover {
  background: var(--azul);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(170, 13, 46, .22);
}

.factura-page .msj-error {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 16px;
  padding: 13px 15px;
  border: 1px solid #efb9c4;
  border-left: 4px solid var(--rojo);
  border-radius: 9px;
  background: #fff5f6;
  color: #8e2037;
  font-size: .86rem;
  line-height: 1.45;
}

.factura-page .msj-error::before {
  content: '!';
  display: inline-grid;
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 50%;
  background: var(--rojo);
  color: #fff;
  font-size: .75rem;
  font-weight: 800;
}

.factura-page .msj-error[hidden] {
  display: none;
}

.pse-wrap {
  text-align: center;
  padding: 14px 0 4px;
}

.pse-wrap img {
  max-width: 130px;
  opacity: .80;
  transition: opacity .3s, transform .3s;
}

.pse-wrap img:hover {
  opacity: 1;
  transform: scale(1.05);
}

.factura-modal {
  width: min(820px, calc(100% - 32px));
  max-width: 820px;
  max-height: min(820px, calc(100dvh - 32px));
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: var(--texto);
  box-shadow: 0 28px 90px rgb(0 22 34 / 38%);
}

.factura-modal[open] {
  display: block;
}

.factura-modal::backdrop {
  background: rgb(0 25 39 / 62%);
  backdrop-filter: blur(3px);
}

.factura-modal .modal-content {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: inherit;
  border: 0;
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
}

.factura-modal .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 28px;
  background: var(--azul) !important;
  border-bottom: 4px solid var(--rojo);
}

.factura-modal .modal-header .heading {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: #fff;
  font-weight: 700;
  margin: 0;
  font-size: clamp(1.25rem, 2vw, 1.55rem);
  letter-spacing: .01em;
}

.factura-modal .modal-header .heading::before {
  content: 'Resumen de factura';
  color: rgb(255 255 255 / 68%);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.factura-modal #cerrar-modal {
  display: inline-grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  border: 1px solid rgb(255 255 255 / 42%);
  border-radius: 8px;
  background: rgb(255 255 255 / 10%);
  color: #fff;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  transition: background .2s ease, transform .2s ease;
}

.factura-modal #cerrar-modal:hover,
.factura-modal #cerrar-modal:focus-visible {
  background: rgb(255 255 255 / 18%);
  transform: scale(1.06);
  outline: none;
}

.factura-modal .modal-body {
  overflow-y: auto;
  padding: 28px;
  background: #f5f8fa;
}

.factura-modal .modal-body>.text-center {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  margin: 0 auto 24px;
  border-radius: 50%;
  background: #e7f0f5;
  border: 1px solid #cbdde6;
  color: var(--azul);
  font-size: 1.55rem;
}

.factura-modal .scrollable-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 20px;
}

.factura-modal .scrollable-form label {
  font-size: .67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: #617582;
  margin: 8px 0 0;
}

.factura-modal .scrollable-form input[type="text"] {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 11px 14px;
  border-radius: 8px;
  font: inherit;
  font-size: .94rem;
  font-weight: 600;
  border: 1px solid #d7e2e8;
  background: #fff;
  color: var(--azul);
  opacity: 1;
  -webkit-text-fill-color: var(--azul);
  text-overflow: ellipsis;
}

.factura-modal .scrollable-form input[type="text"]:disabled {
  cursor: default;
  background: #edf3f6;
}

.factura-modal .modal-footer {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px 16px;
  margin-top: 24px;
  padding: 22px 0 0;
  background: transparent;
  border-top: 1px solid #d7e2e8 !important;
}

.factura-modal .btn-dl {
  min-height: 46px;
  background: var(--rojo);
  color: #fff;
  border: none;
  padding: 11px 22px;
  border-radius: 8px;
  font-size: .92rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 7px 16px rgb(170 13 46 / 18%);
  transition: background .2s ease, transform .2s ease, box-shadow .2s ease;
}

.factura-modal .btn-dl:hover,
.factura-modal .btn-dl:focus-visible {
  background: var(--azul);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 9px 20px rgb(0 49 73 / 20%);
}

.factura-modal .modal-footer a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 5px 14px;
  border: 1px solid #cbdde6;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 2px 8px rgb(0 35 52 / 5%);
  transition: border-color .2s ease, transform .2s ease;
}

.factura-modal .modal-footer a:hover {
  border-color: var(--azul);
  transform: translateY(-1px);
}

.factura-modal .modal-footer a:focus-visible,
.factura-modal .btn-dl:focus-visible {
  outline: 3px solid rgb(6 101 165 / 30%);
  outline-offset: 2px;
}

@media (max-width: 640px) {
  .factura-wrap {
    width: min(100% - 28px, 560px);
    margin-top: 30px;
  }

  .f-card-body {
    padding: 26px 20px 28px;
  }

  .items {
    grid-template-columns: 1fr;
  }

  .factura-modal {
    width: min(100% - 20px, 560px);
    max-height: calc(100dvh - 20px);
  }

  .factura-modal .modal-header {
    padding: 18px 16px;
  }

  .factura-modal .modal-body {
    padding: 20px 16px;
  }

  .factura-modal .scrollable-form {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .factura-modal .scrollable-form label {
    margin-top: 9px;
  }

  .factura-modal .modal-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .factura-modal .btn-dl,
  .factura-modal .modal-footer a {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 640px) {
  .fields-grid {
    grid-template-columns: 1fr;
  }

  .f-card-body {
    padding: 20px;
  }
}