.watchlists-page {
    width: 100%;
    max-width: none;
    margin: 0;
}

.charts-grid {
    display: grid;
    grid-template-columns:
        repeat(var(--columns, 2), minmax(0, 1fr));
    gap: .4rem;
}

.charts-grid[data-responsive="responsive"][data-columns="1"] { --columns: 1; }
.charts-grid[data-responsive="responsive"][data-columns="2"] { --columns: 2; }
.charts-grid[data-responsive="responsive"][data-columns="3"] { --columns: 3; }
.charts-grid[data-responsive="responsive"][data-columns="4"] { --columns: 4; }
.charts-grid[data-responsive="responsive"][data-columns="5"] { --columns: 5; }
.charts-grid[data-responsive="responsive"][data-columns="6"] { --columns: 6; }
.charts-grid[data-responsive="responsive"][data-columns="7"] { --columns: 7; }
.charts-grid[data-responsive="responsive"][data-columns="8"] { --columns: 8; }
.charts-grid[data-responsive="responsive"][data-columns="9"] { --columns: 9; }
.charts-grid[data-responsive="responsive"][data-columns="10"] { --columns: 10; }



.chart-card {
    min-width: 0;
    overflow: hidden;
    border: 1px solid #d7dce2;
    border-radius: .25rem;
    background: #fff;
}

.chart-image-link {
    display: block;
    width: 100%;
    line-height: 0;
    text-decoration: none;
}

.chart-card img {
    display: block;
    width: 100%;
    height: auto;
    margin: 0;
    object-fit: contain;
}

.manager-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 1.5rem;
}

.ticker-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    min-height: 100px;
    padding: .75rem;
    border: 1px solid #d7dce2;
    border-radius: .5rem;
}

.ticker-chip {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .35rem .6rem;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    background: #fff;
}

.ticker-chip button {
    border: 0;
    background: transparent;
    color: #b42318;
}

.empty-box {
    display: grid;
    min-height: 220px;
    place-items: center;
    border: 1px dashed #b8c0cc;
    border-radius: .5rem;
    color: #6b7280;
}

@media (max-width: 991px) {
    .manager-layout {
        grid-template-columns: 1fr;
    }

    .charts-grid[data-responsive="responsive"][data-columns="3"],
    .charts-grid[data-responsive="responsive"][data-columns="4"] {
        --columns: 2;
    }
}

@media (max-width: 575px) {
    .charts-grid[data-responsive="responsive"] {
        --columns: 1 !important;
    }
}


/* Controles compactos e iconos de acciones */
.watchlists-page .form-label,
#managerModal .form-label {
    margin-bottom: .25rem;
    font-size: .875rem;
}

.watchlists-page .btn,
#managerModal .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
}

.button-icon {
    width: .9rem;
    height: .9rem;
    flex: 0 0 .9rem;
    fill: currentColor;
}

.btn-close-sm {
    width: .75rem;
    height: .75rem;
    padding: .4rem;
    background-size: .65rem;
}

.ticker-chip {
    font-size: .8rem;
}

.ticker-chip button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    padding: 0;
    border-radius: 50%;
    font-size: 1rem;
}

.manager-layout .list-group-item {
    padding: .4rem .65rem;
    font-size: .875rem;
}


/* Modal de administración al 90% del viewport */
.watchlist-manager-dialog {
    width: 90vw;
    max-width: 90vw;
    margin-left: auto;
    margin-right: auto;
}

/* Uso de pantalla completa */
html,
body {
    width: 100%;
}

.watchlists-page > .card {
    border-radius: .35rem;
}

.watchlists-page .card-body {
    padding: .65rem;
}

.watchlists-page .mb-3 {
    margin-bottom: .55rem !important;
}

.watchlists-page .charts-grid {
    width: 100%;
}

@media (max-width: 767.98px) {
    .watchlist-manager-dialog {
        width: 96vw;
        max-width: 96vw;
        margin: .5rem auto;
    }
}


/* Resumen compacto: conteo y selector de columnas */
.watchlist-summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
}

.watchlist-summary-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .5rem;
}

.columns-select {
    width: auto;
    min-width: 118px;
}

/* Controles superiores sin etiquetas */
.watchlists-page .card-body > .row {
    align-items: center !important;
}

@media (max-width: 575.98px) {
    .watchlist-summary-row {
        align-items: stretch;
        flex-direction: column;
    }

    .watchlist-summary-controls {
        justify-content: space-between;
    }

    .columns-select {
        min-width: 125px;
    }
}


/* Indicadores dependientes de la temporalidad */
.indicator-panel {
    display: grid;
    grid-template-columns:
        repeat(
            auto-fit,
            minmax(110px, max-content)
        );
    align-items: center;
    gap: .35rem 1rem;
}

.indicator-option {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    margin: 0;
    font-size: .875rem;
    white-space: nowrap;
}

.indicator-option .form-check-input {
    margin: 0;
}

@media (max-width: 575.98px) {
    .indicator-panel {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }
}


/* Barra superior reorganizada */
.watchlists-toolbar-body {
    display: flex;
    flex-direction: column;
    gap: .55rem;
}

.watchlists-toolbar-primary {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.watchlist-select {
    flex: 0 0 40%;
    width: 40%;
    max-width: 40%;
}

.watchlist-filter-control {
    flex: 1 1 260px;
    max-width: 360px;
}

.watchlist-filter-control .input-group-text {
    color: var(--bs-secondary-color);
    background: var(--bs-tertiary-bg);
}

.watchlists-toolbar-primary .watchlist-filter-control .btn {
    width: auto;
}

.watchlist-summary-heading {
    display: flex;
    align-items: baseline;
    gap: .65rem;
    min-width: 0;
}

.watchlist-filter-status {
    color: var(--bs-secondary-color);
    font-size: .8rem;
}

.watchlist-filter-status strong {
    color: var(--bs-body-color);
}

.chart-filter-empty {
    grid-column: 1 / -1;
}

.watchlists-toolbar-secondary {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
}

.toolbar-field {
    display: flex;
    align-items: center;
    gap: .35rem;
}

.toolbar-caption {
    font-size: .8rem;
    font-weight: 600;
    color: var(--bs-secondary-color);
    white-space: nowrap;
}

.indicators-field {
    flex: 1 1 auto;
}

.theme-field {
    margin-left: auto;
}

.theme-field .form-select,
.watchlists-toolbar-secondary > .toolbar-field:first-child .form-select {
    width: auto;
    min-width: 105px;
}

.watchlists-dark-theme .chart-card {
    border-color: #3b4657;
    background: #111827;
}

.watchlists-dark-theme .ticker-cloud {
    border-color: #3b4657;
    background: #111827;
}

.watchlists-dark-theme .ticker-chip {
    border-color: #4b5563;
    background: #1f2937;
    color: #f9fafb;
}

@media (max-width: 767.98px) {
    .watchlists-toolbar-primary {
        align-items: stretch;
        flex-direction: column;
    }

    .watchlist-select {
        flex-basis: auto;
        width: 100%;
        max-width: none;
    }

    .watchlist-filter-control {
        flex-basis: auto;
        width: 100%;
        max-width: none;
    }

    .watchlists-toolbar-secondary {
        align-items: stretch;
        flex-direction: column;
    }

    .toolbar-field,
    .indicators-field,
    .theme-field {
        width: 100%;
        margin-left: 0;
    }

    .theme-field .form-select,
    .watchlists-toolbar-secondary > .toolbar-field:first-child .form-select {
        width: 100%;
    }
}


/* Indicadores en una sola línea */
.indicators-field {
    flex: 1 1 auto;
    min-width: 0;
}

.indicator-panel {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: .9rem;
    min-width: 0;
    white-space: nowrap;
}

.indicator-option {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    margin: 0;
}

@media (max-width: 991.98px) {
    .watchlists-toolbar-secondary {
        overflow-x: auto;
        padding-bottom: .2rem;
    }

    .indicator-panel {
        overflow-x: auto;
    }
}

@media (max-width: 767.98px) {
    .watchlists-toolbar-secondary {
        flex-direction: row;
        align-items: center;
        flex-wrap: nowrap;
    }

    .toolbar-field,
    .indicators-field,
    .theme-field {
        width: auto;
        flex: 0 0 auto;
    }

    .indicators-field {
        flex: 1 0 auto;
    }
}


/* Reducción responsive para densidades altas */
@media (max-width: 1399.98px) {
    .charts-grid[data-responsive="responsive"][data-columns="8"],
    .charts-grid[data-responsive="responsive"][data-columns="9"],
    .charts-grid[data-responsive="responsive"][data-columns="10"] {
        --columns: 7;
    }
}

@media (max-width: 1199.98px) {
    .charts-grid[data-responsive="responsive"][data-columns="6"],
    .charts-grid[data-responsive="responsive"][data-columns="7"],
    .charts-grid[data-responsive="responsive"][data-columns="8"],
    .charts-grid[data-responsive="responsive"][data-columns="9"],
    .charts-grid[data-responsive="responsive"][data-columns="10"] {
        --columns: 5;
    }
}

@media (max-width: 991.98px) {
    .charts-grid[data-responsive="responsive"][data-columns="4"],
    .charts-grid[data-responsive="responsive"][data-columns="5"],
    .charts-grid[data-responsive="responsive"][data-columns="6"],
    .charts-grid[data-responsive="responsive"][data-columns="7"],
    .charts-grid[data-responsive="responsive"][data-columns="8"],
    .charts-grid[data-responsive="responsive"][data-columns="9"],
    .charts-grid[data-responsive="responsive"][data-columns="10"] {
        --columns: 3;
    }
}

@media (max-width: 767.98px) {
    .charts-grid[data-responsive="responsive"][data-columns="3"],
    .charts-grid[data-responsive="responsive"][data-columns="4"],
    .charts-grid[data-responsive="responsive"][data-columns="5"],
    .charts-grid[data-responsive="responsive"][data-columns="6"],
    .charts-grid[data-responsive="responsive"][data-columns="7"],
    .charts-grid[data-responsive="responsive"][data-columns="8"],
    .charts-grid[data-responsive="responsive"][data-columns="9"],
    .charts-grid[data-responsive="responsive"][data-columns="10"] {
        --columns: 2;
    }
}



.watchlists-dark-theme {
    /*
     * Ajuste global del raster de Finviz en modo oscuro.
     * Se desplaza ligeramente el tono respecto a 180deg para
     * que las velas rojas se vean más rojas y menos anaranjadas.
     */
    --finviz-dark-filter:
        invert(1)
        hue-rotate(172deg)
        saturate(1.72)
        brightness(.74)
        contrast(1.2);
}

/* Tema oscuro aplicado también a las imágenes raster de Finviz */
.chart-card img {
    transition:
        filter .18s ease,
        opacity .18s ease;
}

.watchlists-dark-theme .chart-card {
    border-color: #374151;
    background: #0f172a;
}

.watchlists-dark-theme .chart-card img {
    /*
     * Invierte el fondo blanco y vuelve a rotar los colores para
     * conservar aproximadamente rojos, verdes, azules y naranjas.
     */
    filter:
        invert(1)
        hue-rotate(180deg)
        brightness(.88)
        contrast(1.08);
}

.watchlists-dark-theme .chart-image-link {
    background: #0f172a;
}

/*
 * Evita un destello blanco mientras se descarga la imagen
 * cuando el tema oscuro ya está activo.
 */
.watchlists-dark-theme .chart-card {
    min-height: 120px;
}


/* Encabezado compacto de la página */
.watchlists-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
}

.watchlists-page-description {
    font-size: .95rem;
    font-weight: 500;
    color: var(--bs-secondary-color);
}

.watchlists-admin-button {
    min-height: 30px;
    padding: .25rem .6rem;
    line-height: 1.15;
    white-space: nowrap;
}

@media (max-width: 575.98px) {
    .watchlists-page-header {
        align-items: stretch;
        flex-direction: column;
    }

    .watchlists-admin-button {
        align-self: flex-start;
    }
}


/* Vista ampliada al pasar el cursor sobre un gráfico */
.chart-hover-preview {
    position: fixed;
    z-index: 1085;
    max-width: calc(100vw - 28px);
    overflow: hidden;
    border: 1px solid rgba(15, 23, 42, .35);
    border-radius: .35rem;
    background: #fff;
    box-shadow:
        0 1rem 2.5rem
        rgba(15, 23, 42, .35);
    line-height: 0;
    pointer-events: none;
}

.chart-hover-preview[hidden] {
    display: none;
}

.chart-hover-preview img {
    display: block;
    width: min(980px, 62vw);
    max-width: calc(100vw - 28px);
    height: auto;
    margin: 0;
}

.watchlists-dark-theme .chart-hover-preview {
    border-color: #4b5563;
    background: #0f172a;
    box-shadow:
        0 1rem 3rem
        rgba(0, 0, 0, .68);
}

.watchlists-dark-theme .chart-hover-preview img {
    filter:
        var(--finviz-dark-filter);
}

/*
 * En dispositivos táctiles no existe rollover estable.
 * La imagen conserva el vínculo normal hacia Finviz.
 */
@media (hover: none), (pointer: coarse) {
    .chart-hover-preview {
        display: none !important;
    }
}


/* Corrección definitiva del botón Administrar */
.watchlists-page-header {
    min-height: 32px;
}

.watchlists-admin-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .3rem;
    width: auto;
    min-height: 30px;
    padding: .25rem .55rem;
    margin: 0;
    line-height: 1;
}


/* Tema oscuro aplicado también a las imágenes raster de Finviz */
.chart-card img {
    transition:
        filter .18s ease,
        opacity .18s ease;
}

.watchlists-dark-theme .chart-card {
    border-color: #2f3b52;
    background: #0f172a;
}

.watchlists-dark-theme .chart-image-link {
    background: #0f172a;
}

/*
 * Ajuste visual del raster de Finviz para acercarlo a un look
 * tipo "dark blue / trading terminal", similar al ejemplo:
 * - fondo muy oscuro
 * - rojos y verdes más vivos
 * - indicadores con mejor contraste
 */
.watchlists-dark-theme .chart-card img {
    filter:
        var(--finviz-dark-filter);
}

/*
 * Evita un destello blanco mientras se descarga la imagen
 * cuando el tema oscuro ya está activo.
 */
.watchlists-dark-theme .chart-card {
    min-height: 120px;
}

.watchlists-dark-theme .chart-hover-preview img {
    filter:
        invert(1)
        hue-rotate(180deg)
        saturate(1.45)
        brightness(.76)
        contrast(1.18);
}

/* Afinaciones del contenedor para combinar mejor con el nuevo estilo oscuro */
.watchlists-dark-theme .watchlists-page-description,
.watchlists-dark-theme .toolbar-caption,
.watchlists-dark-theme #tickerCount,
.watchlists-dark-theme .text-muted {
    color: #c8d2e2 !important;
}

.watchlists-dark-theme .card {
    background: #111827;
    border-color: #2f3b52;
}

.watchlists-dark-theme .card-body {
    background: #111827;
}

.watchlists-dark-theme .empty-box,
.watchlists-dark-theme .ticker-cloud {
    background: #111827;
    border-color: #334155;
    color: #dbe4f0;
}


/* Tickers compactos: forma de chip, no circular */
.ticker-cloud {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .4rem;
    min-height: 0;
    padding: .5rem;
}

.ticker-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    width: auto;
    min-width: 0;
    height: auto;
    min-height: 28px;
    padding: .25rem .55rem;
    border-radius: .4rem;
    line-height: 1.1;
    white-space: nowrap;
}

.ticker-chip button,
.ticker-chip .remove-ticker {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    min-width: 18px;
    padding: 0;
    margin: 0;
    border: 0;
    border-radius: .2rem;
    line-height: 1;
    background: transparent;
}


/* ============================================================
   Versión web responsive para Android y otros dispositivos táctiles
   ============================================================ */

html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

body.mobile-chart-open {
    overflow: hidden;
    touch-action: none;
}

.mobile-chart-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding:
        max(10px, env(safe-area-inset-top))
        max(10px, env(safe-area-inset-right))
        max(10px, env(safe-area-inset-bottom))
        max(10px, env(safe-area-inset-left));
    background: rgba(0, 0, 0, .84);
}

.mobile-chart-overlay[hidden] {
    display: none;
}

.mobile-chart-dialog {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 980px;
    max-height: 100%;
    overflow: hidden;
    border-radius: .65rem;
    background: var(--bs-body-bg);
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, .45);
}

.mobile-chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .65rem .75rem;
    border-bottom: 1px solid var(--bs-border-color);
}

.mobile-chart-image-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    overflow: auto;
    background: var(--bs-tertiary-bg);
    touch-action: pan-x pan-y pinch-zoom;
}

.mobile-chart-image-wrapper img {
    display: block;
    width: 100%;
    height: auto;
    max-height: calc(100vh - 145px);
    object-fit: contain;
}

.mobile-chart-actions {
    display: flex;
    justify-content: center;
    padding: .65rem;
    border-top: 1px solid var(--bs-border-color);
}

.watchlists-dark-theme .mobile-chart-dialog,
.watchlists-dark-theme .mobile-chart-image-wrapper {
    background: #0f172a;
}

.watchlists-dark-theme .mobile-chart-image-wrapper img {
    filter: var(--finviz-dark-filter);
}

@media (max-width: 767.98px) {
    .watchlists-page {
        padding-left: .5rem;
        padding-right: .5rem;
    }

    .watchlists-page-header {
        display: grid;
        grid-template-columns: 1fr auto;
        align-items: center;
        gap: .5rem;
    }

    .watchlists-page-description {
        min-width: 0;
        font-size: .9rem;
    }

    .watchlists-toolbar-primary {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: .5rem;
    }

    .watchlist-select {
        width: 100%;
        max-width: none;
        min-width: 0;
        flex-basis: auto;
    }

    .watchlists-toolbar-secondary {
        display: flex;
        flex-wrap: nowrap;
        align-items: center;
        gap: .65rem;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scrollbar-width: thin;
        padding-bottom: .25rem;
    }

    .toolbar-field,
    .indicators-field,
    .theme-field {
        flex: 0 0 auto;
        width: auto;
        margin-left: 0;
    }

    .indicator-panel {
        display: flex;
        flex-wrap: nowrap;
        gap: .75rem;
        overflow: visible;
    }

    .watchlist-summary-row {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: .5rem;
    }

    .watchlist-summary-controls {
        display: flex;
        align-items: center;
        gap: .4rem;
    }

    .columns-select {
        min-width: 112px;
        width: auto;
    }

    /*
     * En celular se conserva el valor elegido, pero se limita la
     * cuadrícula visual a un máximo de dos columnas para evitar
     * gráficos ilegibles.
     */
    .charts-grid[data-responsive="responsive"][data-columns="1"] {
        --columns: 1;
    }

    .charts-grid[data-responsive="responsive"][data-columns="2"],
    .charts-grid[data-responsive="responsive"][data-columns="3"],
    .charts-grid[data-responsive="responsive"][data-columns="4"],
    .charts-grid[data-responsive="responsive"][data-columns="5"],
    .charts-grid[data-responsive="responsive"][data-columns="6"],
    .charts-grid[data-responsive="responsive"][data-columns="7"],
    .charts-grid[data-responsive="responsive"][data-columns="8"],
    .charts-grid[data-responsive="responsive"][data-columns="9"],
    .charts-grid[data-responsive="responsive"][data-columns="10"] {
        --columns: 2;
    }

    .chart-card img {
        width: 100%;
        height: auto;
    }

    .modal-dialog {
        width: calc(100% - 16px);
        max-width: none;
        margin: 8px;
    }

    .modal-content {
        max-height: calc(100vh - 16px);
    }

    .modal-body {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .ticker-import-panel textarea {
        min-height: 120px;
    }
}

@media (max-width: 479.98px) {
    .charts-grid[data-responsive="responsive"],
    .charts-grid[data-responsive="responsive"][data-columns="1"],
    .charts-grid[data-responsive="responsive"][data-columns="2"],
    .charts-grid[data-responsive="responsive"][data-columns="3"],
    .charts-grid[data-responsive="responsive"][data-columns="4"],
    .charts-grid[data-responsive="responsive"][data-columns="5"],
    .charts-grid[data-responsive="responsive"][data-columns="6"],
    .charts-grid[data-responsive="responsive"][data-columns="7"],
    .charts-grid[data-responsive="responsive"][data-columns="8"],
    .charts-grid[data-responsive="responsive"][data-columns="9"],
    .charts-grid[data-responsive="responsive"][data-columns="10"] {
        --columns: 1;
    }

    .watchlists-toolbar-primary {
        grid-template-columns: 1fr;
    }

    .watchlists-toolbar-primary .btn {
        width: 100%;
    }

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

    .watchlist-summary-controls {
        justify-content: space-between;
    }

    .mobile-chart-dialog {
        border-radius: .45rem;
    }
}

@media (hover: none), (pointer: coarse) {
    .chart-hover-preview {
        display: none !important;
    }

    .chart-image-link {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
}


/* Estabilidad de la cuadrícula durante la carga de imágenes */
.chart-image-link {
    aspect-ratio: 466 / 219;
    overflow: hidden;
}

.chart-card img {
    aspect-ratio: 466 / 219;
}

/*
 * Evita el efecto de rebote horizontal del navegador sin impedir
 * el desplazamiento vertical normal de la página.
 */
@media (hover: none), (pointer: coarse) {
    html,
    body {
        overscroll-behavior-x: none;
    }

    body {
        touch-action: pan-y pinch-zoom;
    }
}


/* Selector de comportamiento de columnas */
.responsive-mode-select {
    width: auto;
    min-width: 108px;
}

/*
 * En modo fijo se conserva exactamente el número configurado.
 * La página puede requerir desplazamiento horizontal cuando se
 * seleccionan muchas columnas en una pantalla pequeña.
 */
.charts-grid[data-responsive="fixed"] {
    min-width: max-content;
}

.charts-grid[data-responsive="fixed"] .chart-card {
    min-width: 180px;
}

@media (max-width: 575.98px) {
    .watchlist-summary-controls {
        flex-wrap: wrap;
    }

    .responsive-mode-select,
    .columns-select {
        min-width: 108px;
    }
}


/* ============================================================
   Corrección definitiva: modo Fijo respeta exactamente columnas
   ============================================================ */

/*
 * Estas reglas se colocan al final del archivo para tener prioridad
 * sobre todas las reglas responsive anteriores.
 */
.charts-grid[data-responsive="fixed"][data-columns="1"] {
    --columns: 1 !important;
}

.charts-grid[data-responsive="fixed"][data-columns="2"] {
    --columns: 2 !important;
}

.charts-grid[data-responsive="fixed"][data-columns="3"] {
    --columns: 3 !important;
}

.charts-grid[data-responsive="fixed"][data-columns="4"] {
    --columns: 4 !important;
}

.charts-grid[data-responsive="fixed"][data-columns="5"] {
    --columns: 5 !important;
}

.charts-grid[data-responsive="fixed"][data-columns="6"] {
    --columns: 6 !important;
}

.charts-grid[data-responsive="fixed"][data-columns="7"] {
    --columns: 7 !important;
}

.charts-grid[data-responsive="fixed"][data-columns="8"] {
    --columns: 8 !important;
}

.charts-grid[data-responsive="fixed"][data-columns="9"] {
    --columns: 9 !important;
}

.charts-grid[data-responsive="fixed"][data-columns="10"] {
    --columns: 10 !important;
}

/*
 * El modo fijo mantiene todas las columnas en una sola fila de cuadrícula.
 * En pantallas pequeñas puede aparecer scroll horizontal, que es el
 * comportamiento esperado al forzar muchas columnas.
 */
.charts-grid[data-responsive="fixed"] {
    width: max-content;
    min-width: 100%;
    grid-auto-flow: row;
}

.charts-grid[data-responsive="fixed"] .chart-card {
    min-width: 180px;
}


/* ============================================================
   Modo fijo ajustado al ancho completo de la ventana
   ============================================================ */

/*
 * Sobrescribe las reglas anteriores que usaban max-content y
 * anchos mínimos. Las N columnas se reparten dentro del 100%.
 */
.charts-grid[data-responsive="fixed"] {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    grid-auto-flow: row;
    grid-template-columns:
        repeat(
            var(--columns),
            minmax(0, 1fr)
        ) !important;
}

.charts-grid[data-responsive="fixed"] .chart-card {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
}

.charts-grid[data-responsive="fixed"] .chart-image-link,
.charts-grid[data-responsive="fixed"] .chart-card img {
    display: block;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: auto;
}


/* ============================================================
   Pantalla completa visual de la cuadrícula de gráficos
   ============================================================ */

.charts-fullscreen-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .3rem;
    white-space: nowrap;
}

.charts-fullscreen-button svg {
    width: 15px;
    height: 15px;
    fill: currentColor;
}

.charts-fullscreen-button .fullscreen-exit-icon {
    display: none;
}

.charts-fullscreen-button.is-active .fullscreen-enter-icon {
    display: none;
}

.charts-fullscreen-button.is-active .fullscreen-exit-icon {
    display: inline-block;
}

body.charts-fullscreen-active {
    overflow: hidden;
}

body.charts-fullscreen-active #watchListPage {
    position: fixed;
    inset: 0;
    z-index: 1900;
    width: 100vw;
    height: 100vh;
    max-width: none;
    overflow: auto;
    padding: .35rem;
    background: var(--bs-body-bg);
}

body.charts-fullscreen-active #watchListPage .watchlists-page-header,
body.charts-fullscreen-active #watchListPage .watchlists-toolbar-body,
body.charts-fullscreen-active #watchListPage .watchlist-query-summary > strong,
body.charts-fullscreen-active #watchListPage .watchlist-query-summary #tickerCount,
body.charts-fullscreen-active #watchListPage .watchlist-query-summary #responsiveMode {
    display: none !important;
}

/*
 * En fullscreen quedan visibles:
 * - selector de columnas;
 * - botón para salir.
 */
body.charts-fullscreen-active #watchListPage .watchlist-query-summary {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    justify-content: flex-end;
    margin: 0 0 .35rem !important;
    padding: .25rem;
    background: var(--bs-body-bg);
}

body.charts-fullscreen-active #watchListPage .watchlist-summary-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .35rem;
}

body.charts-fullscreen-active #watchListPage .charts-grid {
    width: 100%;
    max-width: none;
}

body.charts-fullscreen-active #watchListPage .chart-card {
    min-width: 0;
}

.watchlists-dark-theme.charts-fullscreen-active #watchListPage {
    background: #0f172a;
}

@media (max-width: 575.98px) {
    .fullscreen-button-text {
        display: none;
    }

    .charts-fullscreen-button {
        width: 34px;
        min-width: 34px;
        padding-left: .35rem;
        padding-right: .35rem;
    }

    body.charts-fullscreen-active #watchListPage {
        padding:
            max(.25rem, env(safe-area-inset-top))
            max(.25rem, env(safe-area-inset-right))
            max(.25rem, env(safe-area-inset-bottom))
            max(.25rem, env(safe-area-inset-left));
    }
}


/* ============================================================
   Barra única, botones de modo y autoactualización
   ============================================================ */

.watchlist-query-summary {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: .5rem !important;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    scrollbar-width: thin;
}

.watchlist-query-summary > strong {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.watchlist-summary-controls {
    display: flex !important;
    flex: 0 0 auto;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: .4rem;
    white-space: nowrap;
}

.responsive-mode-buttons {
    flex: 0 0 auto;
}

.responsive-mode-button {
    width: auto;
    min-width: 34px;
    padding-left: .55rem;
    padding-right: .55rem;
    font-weight: 500;
}

.responsive-mode-button.active {
    box-shadow: 0 0 0 .15rem rgba(13, 110, 253, .18);
}

.responsive-mode-button svg,
.auto-refresh-button svg {
    width: 15px;
    height: 15px;
    fill: currentColor;
}

.auto-refresh-button {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: .3rem;
    white-space: nowrap;
}

.auto-refresh-button.is-active .auto-refresh-icon {
    animation: watchlist-auto-refresh-spin 1.2s linear infinite;
}

@keyframes watchlist-auto-refresh-spin {
    to {
        transform: rotate(360deg);
    }
}

body.charts-fullscreen-active #watchListPage .watchlist-query-summary > strong,
body.charts-fullscreen-active #watchListPage .watchlist-query-summary #tickerCount,
body.charts-fullscreen-active #watchListPage .watchlist-query-summary #responsiveModeButtons {
    display: initial !important;
}

body.charts-fullscreen-active #watchListPage .watchlist-query-summary {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    overflow-x: auto;
}

body.charts-fullscreen-active #watchListPage .watchlist-summary-controls {
    display: flex !important;
    flex-wrap: nowrap !important;
}

@media (max-width: 575.98px) {
    .watchlist-query-summary {
        flex-direction: row !important;
        align-items: center !important;
    }

    .watchlist-summary-controls {
        justify-content: flex-end !important;
    }

    .auto-refresh-text {
        display: none;
    }

    .auto-refresh-button {
        width: 34px;
        min-width: 34px;
        padding-left: .35rem;
        padding-right: .35rem;
    }
}


/* ============================================================
   Orden y dimensiones uniformes de controles
   ============================================================ */

.watchlist-summary-controls > .btn,
.watchlist-summary-controls > .btn-group,
.watchlist-summary-controls > .form-select {
    height: 31px;
}

.responsive-mode-buttons {
    height: 31px;
}

.responsive-mode-buttons .responsive-mode-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 31px !important;
    min-height: 31px !important;
    padding-top: 0;
    padding-bottom: 0;
}

.responsive-mode-button svg,
.auto-refresh-button svg {
    display: block;
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    overflow: visible;
}

.auto-refresh-button {
    height: 31px !important;
    min-height: 31px !important;
    padding-top: 0;
    padding-bottom: 0;
}

.auto-refresh-button .auto-refresh-icon {
    transform-origin: center;
}

.columns-select,
.charts-fullscreen-button {
    height: 31px !important;
    min-height: 31px !important;
}


/* Agrupadores de tickers */
.chart-group-separator {
    grid-column: 1 / -1;
    margin-top: .35rem;
    padding: .45rem .65rem;
    border-left: 4px solid var(--bs-primary);
    border-bottom: 1px solid #cfd6df;
    background: #f3f6fa;
    font-size: .95rem;
    font-weight: 700;
    line-height: 1.2;
}

.ticker-cloud {
    display: block;
}

.ticker-group-admin {
    margin-bottom: .8rem;
    border: 1px solid #d7dce2;
    border-radius: .45rem;
    overflow: hidden;
}

.ticker-group-admin:last-child {
    margin-bottom: 0;
}

.ticker-group-admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .6rem;
    padding: .4rem .55rem;
    background: #f3f6fa;
    border-bottom: 1px solid #d7dce2;
}

.ticker-group-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
}

.ticker-group-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    min-height: 42px;
    padding: .55rem;
}

.watchlists-dark-theme .chart-group-separator,
.watchlists-dark-theme .ticker-group-admin-header {
    border-color: #4b5563;
    background: #1f2937;
    color: #f9fafb;
}

.watchlists-dark-theme .ticker-group-admin {
    border-color: #4b5563;
}

@media (max-width: 575.98px) {
    .ticker-group-admin-header {
        align-items: flex-start;
        flex-direction: column;
    }
}


.capture-charts-button {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    height: 31px;
    white-space: nowrap;
}

.capture-charts-icon {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.capture-charts-button.is-capturing {
    cursor: progress;
    opacity: .75;
}

.capture-charts-button.capture-complete {
    border-color: #198754;
    color: #198754;
}

.auto-refresh-button.is-active {
    border-color: #198754;
    background: #198754;
    color: #fff;
}


.capture-charts-button.capture-error {
    border-color: #dc3545;
    color: #dc3545;
}

.capture-charts-button:disabled {
    cursor: wait;
}


.preview-switch {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    min-height: 31px;
    margin: 0;
    padding: 0;
    white-space: nowrap;
}

.preview-switch .form-check-input {
    float: none;
    flex: 0 0 auto;
    margin: 0;
}

.preview-switch .form-check-label {
    margin: 0;
    font-size: .82rem;
    line-height: 1;
    cursor: pointer;
}

.watchlist-preview-disabled .chart-hover-preview,
.watchlist-preview-disabled .mobile-chart-overlay {
    display: none !important;
}

@media (max-width: 575.98px) {
    .preview-switch .form-check-label {
        display: none;
    }
}


/*
 * El panel fullscreen usa z-index 1900.
 * La vista ampliada debe quedar por encima cuando está activa.
 */
body.charts-fullscreen-active .chart-hover-preview {
    z-index: 2000;
}
