/* === CONTENEDOR PRINCIPAL === */
.at-usa-responsive,
.at-usa-responsive * {
  box-sizing: border-box;
}

.at-usa-responsive {
  max-width: 1148px;
  border-radius: 8px;
  box-shadow: 0 5px 10px rgba(0,0,0,0.15);
  border: 1px solid #e0e7ef;
  margin: 0 auto;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background:#e6f0fa;
}

/* === ESTILO GENERAL DE TABLA == */
.at-portfolio-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: 12px;
  color: #3c3c3c;
  text-align: center;
  border-left: 1px solid #e0e7ef !important;
  border-right: 1px solid #e0e7ef !important;
}

/* === ENCABEZADO: Primera fila === */
.at-portfolio-table thead tr:first-child th {
  padding: 7px 10px;
  background: linear-gradient(to bottom, #4a90e2, #357ab7);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  border-right: 1px solid rgba(255,255,255,0.2);
  border-bottom: 3px solid #2e68a2;
  vertical-align: middle !important;
  text-align: center !important;
}

/* === ENCABEZADO: Segunda fila === */
.at-portfolio-table thead tr:nth-child(2) th {
  background: linear-gradient(to bottom, #4a90e2, #357ab7);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  border-right: 1px solid rgba(255,255,255,0.2);
  border-bottom: 2px solid #2e68a2;
  padding: 6px 10px;
  vertical-align: middle !important;
  text-align: center !important;
}

/* === CUERPO === */
.at-portfolio-table tbody td {
  padding: 10px;
  border-bottom: 1px solid #e5eaf0;
  background-color: #ffffff;
  white-space: nowrap;
  font-weight: bold;
  vertical-align: middle !important;
}

.at-portfolio-table tbody td:last-child {
  text-align: center !important;
  padding-left: 6px !important;
}

/* === ALTERNANCIA DE FILAS === */
.at-portfolio-table tbody tr:nth-child(odd) td {
  background-color: #f9fcff;
}

/* === EFECTO HOVER === */
.at-portfolio-table tbody tr:hover td {
  background-color: #dcedff;
  cursor: pointer;
}

.at-portfolio-table tbody tr:hover .sticky-col {
  background-color: #dcedff !important;
}

/* === COLUMNA STICKY === */
.sticky-col {
  position: sticky;
  left: 0;
  background-color: #e9f3fd;
  box-shadow: inset -3px 0 5px rgba(0,0,0,0.1);
  z-index: 3 !important;
  font-weight: bold;
  vertical-align: middle !important;
}

.sticky-col::before,
.sticky-col::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background-color: #9ec5ec;
}

.sticky-col::before { left: 0; }
.sticky-col::after { right: 0; }

/* === COLORES POSITIVO / NEGATIVO === */
.positive {
  color: green !important;
}

.negative {
  color: red !important;
}

/* === AJUSTES RESPONSIVE === */
@media screen and (max-width: 768px) {
  .at-portfolio-table, .at-usa-responsive {
    font-size: 12px;
  }

  .at-portfolio-table thead th,
  .at-portfolio-table tbody td {
    padding: 8px 10px;
  }
}

/* === BORDES EXTERNOS DE ENCABEZADO === */
.at-portfolio-table thead tr:first-child th:first-child,
.at-portfolio-table thead tr:nth-child(2) th:first-child {
  border-left: 1px solid #4085cd !important;
}

.at-portfolio-table thead tr:first-child th:last-child,
.at-portfolio-table thead tr:nth-child(2) th:last-child {
  border-right: 1px solid #4085cd !important;
}

/* === BORDES INTERNOS NECESARIOS === */
.at-portfolio-table thead tr:first-child th:nth-child(4),
.at-portfolio-table thead tr:nth-child(2) th:nth-child(1),
.at-portfolio-table thead tr:first-child th:nth-child(7),
.at-portfolio-table thead tr:nth-child(2) th:nth-child(12),
.at-portfolio-table tbody td:nth-child(15) {
  border-right: 1px solid rgba(255,255,255,0.2) !important;
  border-left: 1px solid rgba(255,255,255,0.2) !important;
}

/* === ANCHO FIJO PARA LA PRIMERA COLUMNA STICKY (Ticker) === */
.at-portfolio-table tbody td.sticky-col,
.at-portfolio-table thead th.sticky-col {
  width: 80px !important;      /* igual que en th/td:nth-child(1) */
  min-width: 80px !important;
  max-width: 80px !important;
}

/* Separadores verticales entre bloques de columnas */
.at-portfolio-table th:nth-child(3),
.at-portfolio-table td:nth-child(3),
.at-portfolio-table th:nth-child(5),
.at-portfolio-table td:nth-child(5),
.at-portfolio-table th:nth-child(9),
.at-portfolio-table td:nth-child(9),
.at-portfolio-table th:nth-child(12),
.at-portfolio-table td:nth-child(12),
.at-portfolio-table th:nth-child(14),
.at-portfolio-table td:nth-child(14),
.at-portfolio-table th:nth-child(17),
.at-portfolio-table td:nth-child(17) {
    border-right: 1px dashed #a6b9d6;
}

/* Columna Sistema más estrecha (global) */
.at-portfolio-table th:last-child,
.at-portfolio-table td:last-child {
    max-width: 90px;
    width: 90px;
	text-align: center !important;
}

/* === AJUSTE COMPACTO PERFECTO PARA ESCRITORIO (CABE SIN SCROLL) === */
@media (min-width: 769px) {

  /* Tamaños generales reducidos */
  .at-portfolio-table th {
    font-size: 12px;
    padding: 4px 4px;
	white-space: nowrap !important;
  }

  .at-portfolio-table td {
    font-size: 12px;
    padding: 3px 4px;
    white-space: nowrap;
  }

  /* Anchos optimizados tras reducir font-size (total: ~1080px aprox.) */
  .at-portfolio-table th:nth-child(1),
  .at-portfolio-table td:nth-child(1) { width: 60px; } /* Ticker */

  .at-portfolio-table th:nth-child(2),
  .at-portfolio-table td:nth-child(2) { width: 70px; } /* Fecha */

  .at-portfolio-table th:nth-child(3),
  .at-portfolio-table td:nth-child(3) { 
	width: 58px; 
	text-align: right; 
  } /* Compra */

  .at-portfolio-table th:nth-child(4),
  .at-portfolio-table td:nth-child(4) { 
  	width: 58px; 
	text-align: right; 
	} /* Stop L */

  .at-portfolio-table th:nth-child(5),
  .at-portfolio-table td:nth-child(5) { 
    width: 50px; 
    text-align: right; 
  } /* SL % */

  .at-portfolio-table th:nth-child(6),
  .at-portfolio-table td:nth-child(6) { width: 36px; } /* Parc. */

  .at-portfolio-table th:nth-child(7),
  .at-portfolio-table td:nth-child(7) { 
    width: 48px; 
  } /* Posic. */

  .at-portfolio-table th:nth-child(8),
  .at-portfolio-table td:nth-child(8) { 
 	width: 58px; 
	text-align: right; 	
	} /* Objet. */

  .at-portfolio-table th:nth-child(9),
  .at-portfolio-table td:nth-child(9) { 
    width: 50px; 
    text-align: right; 
  } /* Obj % */

  .at-portfolio-table th:nth-child(10),
  .at-portfolio-table td:nth-child(10) { 
    width: 58px; 
    text-align: right; 
  } /* Precio */

  .at-portfolio-table th:nth-child(11),
  .at-portfolio-table td:nth-child(11) { 
    width: 50px; 
    text-align: right; 
  } /* Día % */

  .at-portfolio-table th:nth-child(12),
  .at-portfolio-table td:nth-child(12) { 
    width: 50px; 
    text-align: center; 
  } /* Hora */

  .at-portfolio-table th:nth-child(13),
  .at-portfolio-table td:nth-child(13) { 
    width: 62px; 
    text-align: right; 
  } /* Rentab % */

  .at-portfolio-table th:nth-child(14),
  .at-portfolio-table td:nth-child(14) { 
    width: 42px; 
    text-align: right; 
  } /* Días */

  .at-portfolio-table th:nth-child(15),
  .at-portfolio-table td:nth-child(15) { 
    width: 75px; 
    text-align: right; 
  } /* Capital */

  .at-portfolio-table th:nth-child(16),
  .at-portfolio-table td:nth-child(16) { 
    width: 70px; 
    text-align: right !important; 
  } /* P/L */

  .at-portfolio-table th:nth-child(17),
  .at-portfolio-table td:nth-child(17) { 
    width: 70px; 
    text-align: right; 
  } /* Total */

.at-portfolio-table th:nth-child(18),
.at-portfolio-table td:nth-child(18) {
    max-width: 70px;
    width: 70px;
    padding-right: 2px;
    padding-left: 2px;
	text-align: center !important;
} /* Sistema */

  /* Sticky sincronizado */
  .at-portfolio-table tbody td.sticky-col,
  .at-portfolio-table thead th.sticky-col {
    width: 60px !important;
    min-width: 60px !important;
    max-width: 60px !important;
  }
}


/* === VERSIÓN MÓVIL OPTIMIZADA === */
@media (max-width: 768px) {

    /* Tamaño uniforme: cuerpo y encabezado */
    .at-portfolio-table th,
    .at-portfolio-table td {
        font-size: 12px !important;
        padding: 3px 4px;
        white-space: nowrap !important; /* Evita saltos en encabezado */
    }

    /* Columna sticky (Ticker) más pequeña en móvil */
    .sticky-col,
    .sticky-col,
	.at-portfolio-table tbody td.sticky-col,
	.at-portfolio-table thead th.sticky-col {
    width: 60px !important;
    min-width: 60px !important;
    max-width: 60px !important;
    padding-left: 4px !important;
    padding-right: 4px !important;
}


    /* Columna Sistema más compacta */
    .at-portfolio-table th:nth-child(18),
    .at-portfolio-table td:nth-child(18) {
        max-width: 90px !important;
        width: 90px !important;
    }

    /* Ajustes de paddings para mejorar legibilidad */
    .at-portfolio-table th {
        padding-top: 4px;
        padding-bottom: 4px;
    }

    .at-portfolio-table td {
        padding-top: 5px;
        padding-bottom: 5px;
    }
}
