:root {
  --app-bg: #070b11;
  --app-bg-2: #101720;
  --app-border: rgba(255, 255, 255, 0.09);
  --app-soft: #aeb7c6;

  --azul: #0b1635;
  --azul-licman: #0b4f8a;
  --azul-licman-2: #1565a9;
  --azul-suave: #eaf3fb;
  --rojo: #d93025;
  --rojo-2: #b3261e;
  --gris: #5f6b76;
  --borde: #d7dee7;
  --borde-azul: #9fb9d3;
  --fondo: #f5f7fa;
  --blanco: #ffffff;
  --negro: #111827;
}

* {
  box-sizing: border-box;
  font-family: "Inter", "Segoe UI", Arial, sans-serif;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 88% 12%, rgba(174, 24, 30, 0.22), transparent 26%),
    linear-gradient(180deg, var(--app-bg) 0%, var(--app-bg-2) 100%);
  color: #f5f7fb;
}

/* ===== CONTENEDOR APP ===== */

.page {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 28px;
}

/* ===== BOTONES ===== */

.actions {
  width: min(210mm, 100%);
  margin: 0 auto 18px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.actions .btn-secondary,
.actions .back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 132px;
  height: 44px;
  padding: 0 20px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: 0.2s ease;
  border: none;
  color: #ffffff;
}

.actions .btn-secondary {
  background: #0f4c81;
  box-shadow: 0 12px 24px rgba(15, 76, 129, 0.25);
}

.actions .btn-secondary:hover {
  background: #12619f;
  transform: translateY(-2px);
}

.actions .back-btn {
  background: linear-gradient(90deg, #e32d34 0%, #9f1119 100%);
  box-shadow: 0 12px 24px rgba(180, 20, 28, 0.25);
}

.actions .back-btn:hover {
  background: linear-gradient(90deg, #f03941 0%, #b5151e 100%);
  transform: translateY(-2px);
}

button {
  border: 0;
  cursor: pointer;
  font-family: inherit;
}

/* ===== ALERTA ===== */

.alerta-validacion {
  width: min(210mm, 100%);
  margin: 0 auto 14px;
  padding: 14px 18px;
  border-radius: 14px;
  background: rgba(217, 48, 37, 0.14);
  border: 1px solid rgba(217, 48, 37, 0.35);
  color: #ff9a9a;
  font-size: 14px;
  font-weight: 800;
}

.alerta-validacion strong {
  display: block;
  color: #ffffff;
  margin-bottom: 4px;
}

/* ===== HOJA ===== */

.sheet {
  width: min(210mm, 100%);
  min-height: 297mm;
  margin: 0 auto;
  background: var(--blanco);
  color: var(--negro);
  border: 1px solid #d7dee7;
  border-radius: 12px;
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04),
    0 30px 80px rgba(0, 0, 0, 0.42);
}

/* ===== HEADER COTIZACIÓN ===== */

.header {
  background: #ffffff;
  color: var(--negro);
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 20px;
  padding: 14px 18px 12px;
  align-items: center;
  border-bottom: 2px solid #123e63;
}

.header-visual {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.header-equipos-logos {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 2px 0;
}

.header-equipo {
  max-height: 82px;
  max-width: 92px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.logo-licman {
  max-width: 190px;
  max-height: 86px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.header-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
}

.title-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.title {
  margin: 0;
  font-size: 23px;
  font-weight: 900;
  color: #123e63;
  line-height: 1.1;
  letter-spacing: 0.2px;
}

.folio-input {
  width: 135px;
  border: none;
  border-bottom: 2px solid #123e63;
  background: transparent;
  color: #123e63;
  font-size: 23px;
  font-weight: 900;
  padding: 0 4px 2px;
  outline: none;
  text-align: left;
}

/* ===== CONTENIDO ===== */

.content {
  padding: 18px 20px 20px;
}

.section {
  margin-bottom: 18px;
}

.section:last-of-type {
  margin-bottom: 0;
}

.section-title {
  background: linear-gradient(180deg, #f5faff, #e8f2fb);
  color: var(--azul-licman);
  font-size: 14px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.45px;
  padding: 7px 10px;
  border: 1px solid var(--borde-azul);
  border-radius: 9px;
  margin-bottom: 12px;
}

.small-title {
  font-size: 12px;
  margin-bottom: 8px;
}

.grid-2,
.grid-3,
.grid-4 {
  display: grid;
  gap: 12px 14px;
}

.grid-2 {
  grid-template-columns: 1fr 1fr;
}

.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

.field {
  display: flex;
  flex-direction: column;
}

.field label {
  font-size: 12px;
  font-weight: 800;
  color: #0b1635;
  margin-bottom: 5px;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid #cdd6e1;
  border-radius: 9px;
  background: #ffffff;
  color: #1d2733;
  font-size: 13px;
  padding: 8px 10px;
  font-family: inherit;
  outline: none;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--azul-licman);
  box-shadow: 0 0 0 3px rgba(11, 79, 138, 0.12);
}

.field textarea {
  min-height: 74px;
  resize: vertical;
}

.select-field {
  cursor: pointer;
}

.descripcion-extra {
  margin: 0;
  color: var(--azul-licman);
  font-size: 13px;
  font-weight: 900;
}

/* ===== NOTAS ===== */

.notes-section {
  margin-bottom: 18px;
}

.notes-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: #1d2733;
  font-size: 13px;
}

.notes-line label {
  font-weight: 800;
  color: #0b1635;
}

.notes-line input {
  border: 1px solid #cdd6e1;
  border-radius: 8px;
  padding: 7px 9px;
  font-size: 13px;
  outline: none;
}

.input-periodo {
  width: 85px;
}

.input-xsmall {
  width: 85px;
}

.input-medium {
  min-width: 190px;
  max-width: 260px;
  border: 1px solid #cdd6e1;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 13px;
}

.notes-block {
  background: #f5f7fa;
  border: 1px solid #d7dee7;
  border-radius: 12px;
  padding: 12px 14px;
}

.notes-block p {
  margin: 0 0 8px;
  color: #1d2733;
  font-size: 13px;
  line-height: 1.5;
}

.notes-block p:last-child {
  margin-bottom: 0;
}

.notes-block .sublinea {
  margin-left: 24px;
  color: #4b5a6a;
}

.empresa-datos span {
  font-weight: 800;
  color: #0b1635;
}

/* ===== CONDICIONES / VALORES ===== */

.values-top-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 12px 0 16px;
}

.bottom-grid {
  display: grid;
  grid-template-columns: 1fr 0.75fr;
  gap: 16px;
  align-items: stretch;
}

.signature-box,
.values-panel {
  background: #f5f7fa;
  border: 1px solid #d7dee7;
  border-radius: 14px;
  padding: 14px;
}

.compact-signature textarea {
  min-height: 58px;
}

.signature-line {
  margin: 14px auto 0;
  width: 220px;
  max-width: 100%;
  border-top: 2px solid #23313d;
  text-align: center;
  padding-top: 6px;
  color: #5f6b76;
  font-size: 11px;
  font-weight: 800;
}

.values-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.totals-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.totals-row {
  display: grid;
  grid-template-columns: 130px 1fr;
  align-items: center;
  gap: 10px;
}

.totals-row span {
  font-size: 12px;
  font-weight: 900;
  color: #0b1635;
}

.totals-row input {
  width: 100%;
  border: 1px solid #cdd6e1;
  border-radius: 9px;
  background: #ffffff;
  color: #1d2733;
  font-size: 13px;
  padding: 8px 10px;
  outline: none;
}

.totals-row.total input {
  background: #eaf1f8;
  border-color: #b9ccdd;
  color: var(--azul-licman);
  font-weight: 900;
}

/* ===== ERRORES ===== */

.required-error {
  border-color: #d93025 !important;
  box-shadow: 0 0 0 3px rgba(217, 48, 37, 0.12) !important;
}

.required-error-wrapper {
  border-radius: 10px;
}

/* ===== RESPONSIVE ===== */

@media (max-width: 900px) {
  .page {
    padding: 16px;
  }

  .header {
    grid-template-columns: 1fr;
  }

  .header-info {
    align-items: flex-start;
    text-align: left;
  }

  .title-row {
    justify-content: flex-start;
  }

  .grid-2,
  .grid-3,
  .grid-4,
  .values-top-grid,
  .bottom-grid {
    grid-template-columns: 1fr;
  }

  .notes-line {
    flex-wrap: wrap;
  }
}

@media (max-width: 640px) {
  .page {
    padding: 0;
  }

  .actions {
    padding: 14px;
    flex-direction: column;
    align-items: stretch;
  }

  .actions .btn-secondary,
  .actions .back-btn {
    width: 100%;
  }

  .sheet {
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .content {
    padding: 16px;
  }

  .header-equipos-logos {
    flex-wrap: wrap;
  }

  .title {
    font-size: 20px;
  }

  .folio-input {
    font-size: 20px;
    width: 120px;
  }

  .totals-row {
    grid-template-columns: 1fr;
  }
}

/* ===== IMPRESIÓN ===== */

@media print {
  @page {
    size: A4;
    margin: 0;
  }

  html,
  body {
    width: 210mm;
    height: 297mm;
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
    overflow: hidden !important;
  }

  .actions,
  .alerta-validacion {
    display: none !important;
  }

  .page {
    width: 210mm !important;
    height: 297mm !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
  }

  .sheet {
    width: 210mm !important;
    height: 297mm !important;
    min-height: 297mm !important;
    margin: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    overflow: hidden !important;
  }
}

/* ===== MODO PDF COTIZACIÓN A4 ===== */

.pdf-mode-cotizacion {
  width: 210mm !important;
  height: 297mm !important;
  min-height: 297mm !important;
  max-height: 297mm !important;
  margin: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  overflow: hidden !important;
  background: #ffffff !important;
  display: flex !important;
  flex-direction: column !important;
}

/* Header PDF */
.pdf-mode-cotizacion .header {
  grid-template-columns: 1fr 210px !important;
  gap: 12px !important;
  padding: 8px 12px 7px !important;
}

.pdf-mode-cotizacion .header-equipos-logos {
  gap: 8px !important;
  padding: 0 !important;
}

.pdf-mode-cotizacion .logo-licman {
  max-width: 155px !important;
  max-height: 62px !important;
}

.pdf-mode-cotizacion .header-equipo {
  max-width: 70px !important;
  max-height: 62px !important;
}

.pdf-mode-cotizacion .title {
  font-size: 17px !important;
}

.pdf-mode-cotizacion .folio-input,
.pdf-mode-cotizacion .title-row .pdf-control-text {
  width: 90px !important;
  font-size: 17px !important;
  font-weight: 900 !important;
  color: #123e63 !important;
}

/* Contenido PDF */
.pdf-mode-cotizacion .content {
  padding: 10px 12px 12px !important;
}

.pdf-mode-cotizacion .section {
  margin-bottom: 9px !important;
}

.pdf-mode-cotizacion .section-title {
  font-size: 9.5px !important;
  padding: 4px 7px !important;
  border-radius: 6px !important;
  margin-bottom: 6px !important;
}

.pdf-mode-cotizacion .grid-2 {
  grid-template-columns: 1fr 1fr !important;
  gap: 5px 8px !important;
}

.pdf-mode-cotizacion .field label {
  font-size: 7.5px !important;
  margin-bottom: 2px !important;
}

.pdf-mode-cotizacion .field input,
.pdf-mode-cotizacion .field select,
.pdf-mode-cotizacion .field textarea {
  font-size: 8px !important;
  padding: 3px 5px !important;
  border-radius: 5px !important;
  min-height: 18px !important;
}

.pdf-mode-cotizacion .descripcion-extra {
  font-size: 8.5px !important;
}

/* Notas PDF */
.pdf-mode-cotizacion .notes-line {
  gap: 4px !important;
  margin-bottom: 4px !important;
  font-size: 8px !important;
}

.pdf-mode-cotizacion .notes-line input {
  font-size: 8px !important;
  padding: 2px 4px !important;
  border-radius: 5px !important;
  min-height: 16px !important;
}

.pdf-mode-cotizacion .input-periodo,
.pdf-mode-cotizacion .input-xsmall {
  width: 50px !important;
}

.pdf-mode-cotizacion .input-medium {
  min-width: 115px !important;
  max-width: 170px !important;
  font-size: 8px !important;
  padding: 2px 4px !important;
}

.pdf-mode-cotizacion .notes-block {
  padding: 7px 8px !important;
  border-radius: 8px !important;
}

.pdf-mode-cotizacion .notes-block p {
  font-size: 8px !important;
  line-height: 1.32 !important;
  margin-bottom: 4px !important;
}

.pdf-mode-cotizacion .notes-block .sublinea {
  margin-left: 14px !important;
}

/* Condiciones PDF */
.pdf-mode-cotizacion .values-top-grid {
  gap: 8px !important;
  margin: 6px 0 8px !important;
  grid-template-columns: 1fr 1fr !important;
}

.pdf-mode-cotizacion .bottom-grid {
  grid-template-columns: 1fr 0.72fr !important;
  gap: 8px !important;
}

.pdf-mode-cotizacion .signature-box,
.pdf-mode-cotizacion .values-panel {
  padding: 8px !important;
  border-radius: 9px !important;
}

.pdf-mode-cotizacion .compact-signature textarea {
  min-height: 34px !important;
}

.pdf-mode-cotizacion .signature-line {
  margin-top: 8px !important;
  width: 160px !important;
  font-size: 7.5px !important;
  padding-top: 4px !important;
}

.pdf-mode-cotizacion .values-panel {
  gap: 7px !important;
}

.pdf-mode-cotizacion .totals-box {
  gap: 5px !important;
}

.pdf-mode-cotizacion .totals-row {
  grid-template-columns: 78px 1fr !important;
  gap: 5px !important;
}

.pdf-mode-cotizacion .totals-row span {
  font-size: 7.5px !important;
}

.pdf-mode-cotizacion .totals-row input {
  font-size: 8px !important;
  padding: 3px 5px !important;
  border-radius: 5px !important;
}

/* Texto que reemplaza inputs en PDF */
.pdf-control-text {
  width: 100%;
  min-height: 18px;
  display: flex;
  align-items: center;
  padding: 3px 5px;
  border: 1px solid #cdd6e1;
  border-radius: 5px;
  background: #ffffff;
  color: #111827;
  font-size: 8px;
  font-weight: 700;
  line-height: 1.1;
  overflow: hidden;
  white-space: nowrap;
}

.pdf-mode-cotizacion .notes-line .pdf-control-text {
  width: auto;
  min-width: 48px;
  min-height: 16px;
  padding: 2px 4px;
}

.pdf-mode-cotizacion .empresa-datos .pdf-control-text {
  display: inline-flex;
  width: auto;
  min-width: 110px;
  margin: 0 3px;
}

.pdf-mode-cotizacion .totals-row .pdf-control-text {
  min-height: 18px;
}

.pdf-mode-cotizacion .title-row .pdf-control-text {
  border: none;
  border-bottom: 2px solid #123e63;
  border-radius: 0;
  background: transparent;
}

/* ===== MARCO VISUAL APP DOCUMENTOS ===== */

.page {
  width: 100%;
  min-height: 100vh;
  padding: 24px 20px 40px;
}

.document-frame {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
}

.document-topbar {
  width: 100%;
  margin: 0 0 22px 0;
  background: rgba(16, 23, 32, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 30px;
  padding: 26px 30px;
  box-shadow: 0 24px 55px rgba(0, 0, 0, 0.42);
  position: relative;
  overflow: hidden;
}

.document-topbar::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at top right, rgba(217, 39, 48, 0.24), transparent 32%),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04), transparent 45%);
  pointer-events: none;
}

.document-topbar-content {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 28px;
  align-items: center;
}

.document-topbar .brand-block h1 {
  margin: 0 0 12px;
  color: #ffffff;
  font-size: clamp(1.8rem, 2.8vw, 3.2rem);
  line-height: 1.08;
  letter-spacing: -0.5px;
  font-weight: 900;
}

.document-topbar .brand-block p {
  margin: 0;
  color: #aeb7c6;
  font-size: 1.05rem;
}

.document-topbar .logo-box {
  background: #ffffff;
  border-radius: 24px;
  padding: 18px;
  min-height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.document-topbar .logo-box img {
  max-width: 240px;
  max-height: 90px;
  object-fit: contain;
}

.document-body-card {
  width: 100%;
  background: rgba(7, 14, 24, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 32px;
  padding: 26px 28px 30px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.document-body-card .actions {
  width: min(210mm, 100%);
  margin: 0 auto 18px;
}

.document-body-card form {
  width: 100%;
  display: flex;
  justify-content: center;
}

.document-body-card .sheet {
  margin: 0 auto;
}

@media (max-width: 900px) {
  .document-topbar-content {
    grid-template-columns: 1fr;
  }

  .document-topbar .logo-box {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .page {
    padding: 0;
  }

  .document-frame {
    max-width: 100%;
  }

  .document-topbar {
    border-radius: 0 0 28px 28px;
    margin-bottom: 18px;
  }

  .document-topbar .brand-block h1 {
    font-size: 1.8rem;
  }

  .document-body-card {
    border-radius: 28px 28px 0 0;
    padding: 18px 14px 24px;
  }
}

@media print {
  .document-topbar,
  .document-body-card > .actions {
    display: none !important;
  }

  .document-frame,
  .document-body-card {
    width: 210mm !important;
    height: 297mm !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
  }
}

/* ===== BUSCADOR DE CLIENTES REALES ===== */

.oculto {
  display: none;
}

.cliente-selector-field {
  position: relative;
  z-index: 40;
}

.cliente-buscador {
  position: relative;
}

.cliente-resultados {
  position: absolute;
  top: calc(100% + 7px);
  left: 0;
  right: 0;
  z-index: 1200;

  max-height: 280px;
  overflow-y: auto;

  padding: 7px;

  border: 1px solid #c9d5e1;
  border-radius: 12px;

  background: #ffffff;

  box-shadow:
    0 18px 45px
    rgba(7, 11, 17, 0.20);
}

.cliente-resultado-item {
  width: 100%;

  display: flex;
  flex-direction: column;
  align-items: flex-start;

  gap: 3px;

  padding: 10px 11px;

  border-radius: 9px;

  background: transparent;
  color: var(--negro);

  text-align: left;

  transition:
    background 0.15s ease,
    transform 0.15s ease;
}

.cliente-resultado-item:hover,
.cliente-resultado-item:focus {
  outline: none;

  background: #edf4fa;

  transform: translateY(-1px);
}

.cliente-resultado-nombre {
  font-size: 12px;
  font-weight: 900;

  color: #0e3a5b;
}

.cliente-resultado-detalle {
  font-size: 10px;
  font-weight: 700;

  color: #6b7783;
}

.cliente-resultados-vacio {
  padding: 13px 11px;

  color: #6b7783;

  font-size: 11px;
  font-weight: 700;

  text-align: center;
}

.cliente-seleccionado-badge {
  margin-top: 6px;

  min-height: 27px;

  padding: 5px 8px;

  display: flex;
  align-items: center;

  gap: 7px;

  border:
    1px solid #bad6c4;

  border-radius: 9px;

  background: #edf8f1;

  color: #1f6b3b;

  font-size: 10px;
  font-weight: 900;
}

.cliente-seleccionado-punto {
  width: 7px;
  height: 7px;

  flex: 0 0 7px;

  border-radius: 50%;

  background: #2f9e57;

  box-shadow:
    0 0 0 3px
    rgba(47, 158, 87, 0.14);
}

#clienteSeleccionadoTexto {
  flex: 1;

  min-width: 0;

  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#limpiarClienteSeleccionado {
  width: 21px;
  height: 21px;

  flex: 0 0 21px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  border-radius: 50%;

  background:
    rgba(31, 107, 59, 0.10);

  color: #1f6b3b;

  font-size: 16px;
  line-height: 1;
}

#limpiarClienteSeleccionado:hover {
  background:
    rgba(31, 107, 59, 0.18);
}

.cliente-resultados.oculto,
.cliente-seleccionado-badge.oculto {
  display: none !important;
}

/* No mostrar controles internos en el PDF */

.pdf-mode-cotizacion
.cliente-resultados,

.pdf-mode-cotizacion
.cliente-seleccionado-badge {
  display: none !important;
}
