/* === CONTENEDOR PRINCIPAL (encapsulado) === */
#at-stock-table-micartera,
#at-stock-table-micartera * {
  box-sizing: border-box;
}

#at-stock-table-micartera.at-micartera-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 (encapsulado) === */
#at-stock-table-micartera .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-stock-table-micartera .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-stock-table-micartera .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-stock-table-micartera .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-stock-table-micartera .at-portfolio-table tbody td:last-child {
  text-align: center !important;
  padding-left: 6px !important;
}

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

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

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

/* === COLUMNA STICKY (encapsulada) === */
#at-stock-table-micartera .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;
}

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

#at-stock-table-micartera .sticky-col::before { left: 0; }
#at-stock-table-micartera .sticky-col::after { right: 0; }

/* === COLORES POSITIVO / NEGATIVO (encapsulados) === */
#at-stock-table-micartera .positive {
  color: green !important;
}

#at-stock-table-micartera .negative {
  color: red !important;
}

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

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

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

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

/* === BORDES INTERNOS NECESARIOS === */
#at-stock-table-micartera .at-portfolio-table thead tr:first-child th:nth-child(4),
#at-stock-table-micartera .at-portfolio-table thead tr:nth-child(2) th:nth-child(1),
#at-stock-table-micartera .at-portfolio-table thead tr:first-child th:nth-child(7),
#at-stock-table-micartera .at-portfolio-table thead tr:nth-child(2) th:nth-child(12),
#at-stock-table-micartera .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-stock-table-micartera .at-portfolio-table tbody td.sticky-col,
#at-stock-table-micartera .at-portfolio-table thead th.sticky-col {
  width: 80px !important;
  min-width: 80px !important;
  max-width: 80px !important;
}

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

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

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

  #at-stock-table-micartera .at-portfolio-table th {
    font-size: 12px;
    padding: 4px 4px;
    white-space: nowrap !important;
  }

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

  #at-stock-table-micartera .at-portfolio-table th:nth-child(1),
  #at-stock-table-micartera .at-portfolio-table td:nth-child(1) { width: 60px; }

  #at-stock-table-micartera .at-portfolio-table th:nth-child(2),
  #at-stock-table-micartera .at-portfolio-table td:nth-child(2) { width: 70px; }

  #at-stock-table-micartera .at-portfolio-table th:nth-child(3),
  #at-stock-table-micartera .at-portfolio-table td:nth-child(3) { width: 58px; text-align: right; }

  #at-stock-table-micartera .at-portfolio-table th:nth-child(4),
  #at-stock-table-micartera .at-portfolio-table td:nth-child(4) { width: 58px; text-align: right; }

  #at-stock-table-micartera .at-portfolio-table th:nth-child(5),
  #at-stock-table-micartera .at-portfolio-table td:nth-child(5) { width: 50px; text-align: right; }

  #at-stock-table-micartera .at-portfolio-table th:nth-child(6),
  #at-stock-table-micartera .at-portfolio-table td:nth-child(6) { width: 36px; }

  #at-stock-table-micartera .at-portfolio-table th:nth-child(7),
  #at-stock-table-micartera .at-portfolio-table td:nth-child(7) { width: 48px; }

  #at-stock-table-micartera .at-portfolio-table th:nth-child(8),
  #at-stock-table-micartera .at-portfolio-table td:nth-child(8) { width: 58px; text-align: right; }

  #at-stock-table-micartera .at-portfolio-table th:nth-child(9),
  #at-stock-table-micartera .at-portfolio-table td:nth-child(9) { width: 50px; text-align: right; }

  #at-stock-table-micartera .at-portfolio-table th:nth-child(10),
  #at-stock-table-micartera .at-portfolio-table td:nth-child(10) { width: 58px; text-align: right; }

  #at-stock-table-micartera .at-portfolio-table th:nth-child(11),
  #at-stock-table-micartera .at-portfolio-table td:nth-child(11) { width: 50px; text-align: right; }

  #at-stock-table-micartera .at-portfolio-table th:nth-child(12),
  #at-stock-table-micartera .at-portfolio-table td:nth-child(12) { width: 50px; text-align: center; }

  #at-stock-table-micartera .at-portfolio-table th:nth-child(13),
  #at-stock-table-micartera .at-portfolio-table td:nth-child(13) { width: 62px; text-align: right; }

  #at-stock-table-micartera .at-portfolio-table th:nth-child(14),
  #at-stock-table-micartera .at-portfolio-table td:nth-child(14) { width: 42px; text-align: right; }

  #at-stock-table-micartera .at-portfolio-table th:nth-child(15),
  #at-stock-table-micartera .at-portfolio-table td:nth-child(15) { width: 75px; text-align: right; }

  #at-stock-table-micartera .at-portfolio-table th:nth-child(16),
  #at-stock-table-micartera .at-portfolio-table td:nth-child(16) { width: 70px; text-align: right !important; }

  #at-stock-table-micartera .at-portfolio-table th:nth-child(17),
  #at-stock-table-micartera .at-portfolio-table td:nth-child(17) { width: 70px; text-align: right; }

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

  /* Sticky sincronizado */
  #at-stock-table-micartera .at-portfolio-table tbody td.sticky-col,
  #at-stock-table-micartera .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) {

  #at-stock-table-micartera .at-portfolio-table th,
  #at-stock-table-micartera .at-portfolio-table td {
    font-size: 12px !important;
    padding: 3px 4px;
    white-space: nowrap !important;
  }

  #at-stock-table-micartera .sticky-col,
  #at-stock-table-micartera .at-portfolio-table tbody td.sticky-col,
  #at-stock-table-micartera .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;
  }

  #at-stock-table-micartera .at-portfolio-table th:nth-child(18),
  #at-stock-table-micartera .at-portfolio-table td:nth-child(18) {
    max-width: 90px !important;
    width: 90px !important;
  }

  #at-stock-table-micartera .at-portfolio-table th {
    padding-top: 4px;
    padding-bottom: 4px;
  }

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