.cotizador-container {
  font-family: "Arial Narrow", Arial, sans-serif;
  font-size: 14px;
}

table {
  border-collapse: collapse;
  width: 100%;
  table-layout: fixed;
}

th, td {
  border: 1px solid #ccc;
  padding: 0;
  font-size: 11px;
  line-height: 1.1;
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

thead th {
  position: sticky;
  top: 0;
  background: #e6ffea;
  z-index: 2;
  border-bottom: 3px solid #ccc;
}

tfoot {
  position: sticky;
  bottom: 0;
  background-color: #e6ffea;
  z-index: 1;
  font-size: 11px;
  border-top: 3px solid #ccc;
}

td[contenteditable="true"] {
  background-color: #fefefe;
  outline: none;
}

td[contenteditable="true"]:focus {
  background-color: #e6f7ff;
}

td button {
  all: unset;
  font-size: 12px;
  width: 100%;
  text-align: center;
  line-height: 1;
  cursor: pointer;
}

td[data-col="acciones"] {
  text-align: center;
  padding: 0;
}

td button:hover {
  background-color: #eee;
  border-radius: 2px;
}

.tabla-scroll {
  max-height: 370px;
  overflow-y: auto;
  display: block;
  position: relative;
}

.cotizador-botones {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  font-size: 12px;
}

.cotizador-botones button,
.cotizador-botones label {
  font-size: 12px;
  padding: 2px 6px;
  line-height: 1.1;
}

.cotizador-botones input[type="number"] {
  width: 42px;
  font-size: 12px;
  padding: 2px;
}

#pegarInput {
  width: 100%;
  height: 19px;
  font-size: 14px;
  font-weight: bold;
  border: 1px solid #999966;
  background-color: #ffffcc;
  box-shadow: 0 0 5px rgba(0, 119, 204, 0.2);
}

#pegarInput:focus {
  background-color: #dceeff;
  box-shadow: 0 0 6px rgba(0, 119, 204, 0.5);
}

/* Distribución de columnas personalizada */
th:nth-child(1), td:nth-child(1) { width: 5%; }   /* Calc */
th:nth-child(2), td:nth-child(2) { width: 43%; }  /* Descripción */
th:nth-child(3), td:nth-child(3) { width: 8%; }   /* Cantidad */
th:nth-child(4), td:nth-child(4) { width: 8%; }   /* Precio */
th:nth-child(5), td:nth-child(5) { width: 14%; }  /* Tarifa */
th:nth-child(6), td:nth-child(6) { width: 9%; }   /* Importe */
th:nth-child(7), td:nth-child(7) { width: 7%; }   /* Fecha */
th:nth-child(8), td:nth-child(8) { width: 6%; }   /* Acciones */

/* Tamaño de fuente por columna */
td[data-col="calcular"] {
  text-align: center;
  overflow: visible;
  padding: 0;
}
td[data-col="descripcion"] { font-size: 14px; }
td[data-col="cantidad"]    { font-size: 14px; }
td[data-col="precio"]      { font-size: 14px; }
td[data-col="tarifa"]      { font-size: 14px; }
td[data-col="importe"]     { font-size: 14px; }
td[data-col="fecha"]       { font-size: 14px; }
td[data-col="acciones"]    { font-size: 13px; }


.mc-check-calcular {
  appearance: none;
  width: 20px;
  height: 20px;
  margin: 0;
  border: 2px solid #b3261e;
  border-radius: 3px;
  background: #fff;
  cursor: pointer;
  vertical-align: middle;
}

.mc-check-calcular:checked {
  border-color: #188038;
  background: #188038;
}

.mc-check-calcular:checked::after {
  content: "✓";
  display: block;
  color: #fff;
  font-size: 16px;
  font-weight: bold;
  line-height: 16px;
  text-align: center;
}

/* No altera el fondo: solo diferencia el texto de las líneas excluidas. */
#tablaCotizador tbody tr.fila-no-incluida td:not([data-col="calcular"]) {
  color: #555;
}

#notificacion {
  position: fixed;
  top: 55%;
  left: 35%;
  transform: translate(-50%, -50%);
  background: #ffcaca;
  color: #900;
  padding: 10px 16px;
  border: 1px solid #e88;
  border-radius: 5px;
  font-size: 13px;
  opacity: 0;
  display: none;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  box-shadow: 0 0 10px rgba(0,0,0,0.2);
  transition: opacity 0.5s ease-in-out;
  z-index: 9999;
}

#notificacion.exito {
  background-color: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

#notificacion.visible {
  display: flex;
  opacity: 1;
}

#noti-cerrar {
  all: unset;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  background-color: transparent;
  border-radius: 3px;
}

#noti-cerrar:hover {
  background-color: #ddd;
}

.fila-caducada {
  background-color: #ffdddd !important;
}

/* Efecto visual para la última fila añadida */
tr.fila-nueva {
  animation: filaNuevaFlash 5s ease-out;
}

@keyframes filaNuevaFlash {
  0% {
    background-color: #dceeff; /* mismo azul del pegarInput:focus */
  }
  100% {
    background-color: inherit;
  }
}


/* Ocultar columna Precio */
#tablaCotizador th:nth-child(4),
#tablaCotizador td:nth-child(4) {
    display: none !important;
}

/* Ocultar columna Importe */
#tablaCotizador th:nth-child(6),
#tablaCotizador td:nth-child(6) {
    display: none !important;
}

/* Aprovechar espacio visible tras ocultar Precio e Importe */
#tablaCotizador th:nth-child(1),
#tablaCotizador td:nth-child(1) { width: 5% !important; }

#tablaCotizador th:nth-child(2),
#tablaCotizador td:nth-child(2) { width: 40% !important; }

#tablaCotizador th:nth-child(3),
#tablaCotizador td:nth-child(3) { width: 8% !important; }

#tablaCotizador th:nth-child(5),
#tablaCotizador td:nth-child(5) { width: 33% !important; }

#tablaCotizador th:nth-child(7),
#tablaCotizador td:nth-child(7) { width: 10% !important; }

#tablaCotizador th:nth-child(8),
#tablaCotizador td:nth-child(8) { width: 4% !important; }

/* Tarifa y Fecha con fuente como descripción */
#tablaCotizador td[data-col="tarifa"],
#tablaCotizador td[data-col="fecha"] {
    font-size: 14px !important;
}
#tablaCotizador th:nth-child(1) {
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
  text-align: center;
}

/* En la exportación PDF se clona la tabla tras eliminar Precio e Importe.
   La columna 3 pasa a ser Tarifa, por eso debe estar visible dentro del clon. */
.mc-export-pdf #tablaCotizador th,
.mc-export-pdf #tablaCotizador td {
    display: table-cell !important;
}
/* Ajustes específicos para PDF */
.mc-export-pdf #tablaCotizador th:nth-child(1),
.mc-export-pdf #tablaCotizador td:nth-child(1) {
    width: 42% !important;
}

.mc-export-pdf #tablaCotizador th:nth-child(2),
.mc-export-pdf #tablaCotizador td:nth-child(2) {
    width: 8% !important;
}

.mc-export-pdf #tablaCotizador th:nth-child(3),
.mc-export-pdf #tablaCotizador td:nth-child(3) {
    width: 38% !important;
}

.mc-export-pdf #tablaCotizador th:nth-child(4),
.mc-export-pdf #tablaCotizador td:nth-child(4) {
    width: 12% !important;
}
.mc-presupuesto-final {
  max-width: 620px;
  margin: 20px auto;
  padding: 16px;
  border: 1px solid #ddd;
  background: #fafafa;
}

.mc-presupuesto-final input,
.mc-presupuesto-final select {
  width: 100%;
  box-sizing: border-box;
  margin: 4px 0 10px 0;
  padding: 8px;
}

.mc-total-base,
.mc-resultado-final {
  margin: 12px 0;
  padding: 10px;
  background: #fff;
  border: 1px solid #ddd;
}

.mc-aviso-datos,
.mc-aviso-profesional {
  font-size: 13px;
  line-height: 1.4;
  margin: 10px 0;
}

.mc-aviso-profesional {
  padding: 10px;
  background: #fff3cd;
  border: 1px solid #e0c36a;
}

#mc-boton-calcular-final {
  width: 100%;
  padding: 10px;
  font-weight: bold;
  cursor: pointer;
}
.mc-presupuesto-final label,
.mc-presupuesto-final input,
.mc-presupuesto-final select,
.mc-presupuesto-final button {
  display: block;
  width: 100%;
  max-width: 420px;
  box-sizing: border-box;
}

.mc-presupuesto-final label {
  margin-top: 10px;
}

.mc-presupuesto-final input,
.mc-presupuesto-final select {
  margin-bottom: 8px;
}

.mc-privacidad {
  display: flex !important;
  gap: 6px;
  align-items: center;
  max-width: 620px;
}

.mc-privacidad input {
  width: auto;
}
.mc-aviso-iva-reducido {
  margin-top: 14px;
  padding: 10px;
  font-size: 13px;
  line-height: 1.45;
  background: #f8f8f8;
  border: 1px solid #ddd;
}

#mc-boton-pdf-final {
  margin-top: 12px;
  padding: 10px;
  font-weight: bold;
  cursor: pointer;
}

.mc-export-pdf-final {
  position: relative;
  background: #fff;
  color: #000;
}

.mc-export-pdf-final h3 {
  margin: 12px 0 6px 0;
  font-size: 13px;
}

.mc-pdf-bloque-datos p,
.mc-pdf-resumen p {
  margin: 2px 0;
}

#mc-tabla-pdf-final th,
#mc-tabla-pdf-final td {
  border: 1px solid #aaa;
  padding: 4px;
  text-align: left;
  vertical-align: top;
}

#mc-tabla-pdf-final th:nth-child(1),
#mc-tabla-pdf-final td:nth-child(1) {
  width: 48%;
}

#mc-tabla-pdf-final th:nth-child(2),
#mc-tabla-pdf-final td:nth-child(2) {
  width: 8%;
  text-align: center;
}

#mc-tabla-pdf-final th:nth-child(3),
#mc-tabla-pdf-final td:nth-child(3) {
  width: 30%;
}

#mc-tabla-pdf-final th:nth-child(4),
#mc-tabla-pdf-final td:nth-child(4) {
  width: 14%;
}

.mc-pdf-resumen {
  margin-top: 12px;
  padding: 8px;
  border: 1px solid #aaa;
}

.mc-pdf-aviso {
  margin-top: 10px;
  padding: 8px;
  border: 1px solid #aaa;
  font-size: 13px;
}



.mc-pdf-datos-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 18px;
  row-gap: 2px;
}

.mc-pdf-datos-grid p {
  margin: 1px 0 !important;
  line-height: 1.2;
}

.mc-export-pdf-final h3 {
  margin: 6px 0 3px 0 !important;
}


.mc-export-pdf-final {
  margin-top: 0 !important;
  padding-top: 0 !important;
}

.mc-export-pdf-final * {
  box-sizing: border-box;
}

.mc-pdf-bloque-datos {
  margin-top: 0 !important;
  margin-bottom: 4px !important;
}

.mc-pdf-datos-grid {
  row-gap: 0 !important;
}

.mc-pdf-datos-grid p {
  margin: 0 !important;
  line-height: 1.12 !important;
  font-size: 10.4px !important;
}

#mc-tabla-pdf-final {
  margin-top: 4px !important;
}

#mc-tabla-pdf-final th,
#mc-tabla-pdf-final td {
  padding: 2px !important;
  font-size: 10.4px !important;
}

.mc-pdf-resumen {
  margin-top: 4px !important;
  padding: 4px !important;
}

.mc-pdf-resumen p,
.mc-pdf-aviso {
  font-size: 10.4px !important;
  line-height: 1.1 !important;
}


.mc-export-pdf,
.mc-export-pdf-final {
  margin-top: 0 !important;
  padding-top: 0 !important;
}

.mc-export-pdf-final h2,
.mc-export-pdf-final h3,
.mc-export-pdf-final p,
.mc-export-pdf-final div {
  break-inside: auto !important;
}

.mc-export-pdf-final table {
  page-break-inside: auto !important;
}

.mc-export-pdf-final tr {
  page-break-inside: avoid !important;
}

.mc-export-pdf-final tbody {
  page-break-inside: auto !important;
}


/* PDF final: evitar espacio fantasma superior en html2canvas */
.mc-export-pdf-final {
  position: static !important;
  top: auto !important;
  left: auto !important;
  margin: 0 !important;
  padding: 0 !important;
  transform: none !important;
  min-height: 0 !important;
}

.mc-export-pdf-final img {
  position: static !important;
  top: auto !important;
  left: auto !important;
}

.mc-export-pdf-final > * {
  margin-top: 0 !important;
}

.mc-export-pdf-final h2,
.mc-export-pdf-final h3,
.mc-export-pdf-final p {
  margin-top: 0 !important;
}


/* PDF final aislado y compacto */
.mc-export-pdf-final {
  width: 190mm !important;
  max-width: 190mm !important;
  margin: 0 !important;
  padding: 0 !important;
  background: #fff !important;
  position: relative !important;
  top: 0 !important;
  left: 0 !important;
}

.mc-pdf-bloque-datos {
  margin: 0 0 3px 0 !important;
  padding: 0 !important;
}

.mc-pdf-datos-linea {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 2px 10px !important;
  margin: 0 0 3px 0 !important;
  padding: 0 !important;
  font-size: 9.8px !important;
  line-height: 1.12 !important;
}

.mc-pdf-datos-linea span {
  white-space: nowrap !important;
  margin: 0 !important;
  padding: 0 !important;
}

.mc-export-pdf-final table,
#mc-tabla-pdf-final {
  margin-top: 2px !important;
  border-collapse: collapse !important;
}

#mc-tabla-pdf-final th,
#mc-tabla-pdf-final td {
  padding: 1px 2px !important;
  font-size: 9.8px !important;
  line-height: 1.12 !important;
}

.mc-pdf-resumen {
  margin-top: 3px !important;
  padding: 3px !important;
}

.mc-pdf-resumen p {
  margin: 0 !important;
  line-height: 1.12 !important;
}


/* Ajuste final PDF: eliminar hueco superior y aumentar legibilidad */
.mc-export-pdf-final {
  width: 190mm !important;
  max-width: 190mm !important;
  min-height: 0 !important;
  height: auto !important;
  margin: 0 !important;
  padding: 0 !important;
  position: static !important;
  transform: none !important;
  font-size: 10.5px !important;
}

.mc-export-pdf-final * {
  page-break-before: auto !important;
  break-before: auto !important;
}

.mc-export-pdf-final > :first-child {
  margin-top: 0 !important;
  padding-top: 0 !important;
}

.mc-pdf-bloque-datos,
#mc-tabla-pdf-final,
.mc-pdf-resumen {
  page-break-before: auto !important;
  break-before: auto !important;
}


.mc-debug-descuento {
  margin: 6px 0;
  padding: 6px;
  background: #fff8d8;
  border: 1px solid #e0c36a;
  font-size: 13px;
}

/* Para ocultar la comprobación de descuento más adelante:*/
.mc-debug-descuento { display: none !important; }



.mc-resultado-final {
  font-weight: 700;
}

.mc-resultado-final #mc-aviso-iva-reducido,
.mc-resultado-final #mc-debug-descuento {
  font-weight: normal;
}
