/**
 * Tema oscuro (estilo fintech / MyInvestor-like).
 * Solo aplica bajo html.tema-oscuro / body.tema-oscuro.
 */
html.tema-oscuro,
body.tema-oscuro {
    --tema-bg: #0f1419;
    --tema-bg-elevated: #12181f;
    --tema-surface: #1a222c;
    --tema-surface-2: #222b36;
    --tema-border: #2a3441;
    --tema-border-soft: #243040;
    --tema-text: #e8eef4;
    --tema-text-muted: #9aa8b5;
    --tema-primary: #4f8cff;
    --tema-primary-soft: rgba(79, 140, 255, 0.16);
    --tema-success: #3dd68c;
    --tema-danger: #ff6b7a;
    --tema-warning-bg: #3a3118;
    --tema-warning-text: #f0d78c;
    --tema-success-bg: #163528;
    --tema-input-bg: #151c24;
    --web-tabla-cabecera-bg: #1e2733;
    color-scheme: dark;
    background-color: var(--tema-bg);
    color: var(--tema-text);
}

body.tema-oscuro {
    background-color: var(--tema-bg) !important;
    color: var(--tema-text);
}

body.tema-oscuro #app,
body.tema-oscuro #app > main {
    background-color: transparent;
    color: var(--tema-text);
}

body.tema-oscuro a:not(.btn):not(.dropdown-item):not(.nav-link):not(.page-link) {
    color: var(--tema-primary);
}

body.tema-oscuro .text-muted,
body.tema-oscuro .form-text,
body.tema-oscuro .small.text-muted {
    color: var(--tema-text-muted) !important;
}

body.tema-oscuro .text-body {
    color: var(--tema-text) !important;
}

body.tema-oscuro .text-dark {
    color: var(--tema-text) !important;
}

body.tema-oscuro .text-success {
    color: var(--tema-success) !important;
}

body.tema-oscuro .text-danger {
    color: var(--tema-danger) !important;
}

body.tema-oscuro .bg-white,
body.tema-oscuro .bg-light,
body.tema-oscuro .alert-light {
    background-color: var(--tema-surface) !important;
    color: var(--tema-text);
}

body.tema-oscuro .border,
body.tema-oscuro .border-top,
body.tema-oscuro .border-bottom,
body.tema-oscuro .border-start,
body.tema-oscuro .border-end,
body.tema-oscuro .border-1 {
    border-color: var(--tema-border) !important;
}

body.tema-oscuro .shadow-sm,
body.tema-oscuro .shadow {
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.35) !important;
}

/* Navbar / menú */
body.tema-oscuro .navbar.navbar-web,
body.tema-oscuro .navbar-light.bg-white {
    background-color: var(--tema-bg-elevated) !important;
    border-bottom: 1px solid var(--tema-border);
    color: var(--tema-text);
}

body.tema-oscuro .navbar-web-title,
body.tema-oscuro .navbar-web-subtitle,
body.tema-oscuro .navbar-light .navbar-brand,
body.tema-oscuro .navbar-light .navbar-nav .nav-link {
    color: var(--tema-text) !important;
}

body.tema-oscuro .navbar-web-subtitle {
    color: var(--tema-text-muted) !important;
}

body.tema-oscuro .navbar-light .navbar-toggler {
    border-color: var(--tema-border);
    color: var(--tema-text);
}

body.tema-oscuro .navbar-light .navbar-toggler-icon {
    filter: invert(1) grayscale(100%) brightness(1.4);
}

body.tema-oscuro .dropdown-menu,
body.tema-oscuro .nav-menu-web .dropdown-menu {
    background-color: var(--tema-surface);
    border-color: var(--tema-border);
}

body.tema-oscuro .dropdown-item,
body.tema-oscuro .nav-menu-web .dropdown-item {
    color: var(--tema-text);
}

body.tema-oscuro .dropdown-item:hover,
body.tema-oscuro .dropdown-item:focus,
body.tema-oscuro .nav-menu-web .dropdown-item:hover,
body.tema-oscuro .nav-menu-web .dropdown-item:focus {
    background-color: var(--tema-surface-2);
    color: var(--tema-text);
}

body.tema-oscuro .dropdown-item.active,
body.tema-oscuro .nav-menu-web .dropdown-item.active {
    background-color: var(--tema-primary-soft);
    color: var(--tema-primary);
}

body.tema-oscuro .dropdown-header,
body.tema-oscuro .nav-menu-web .dropdown-header {
    color: var(--tema-text-muted);
}

body.tema-oscuro .dropdown-divider {
    border-top-color: var(--tema-border);
}

body.tema-oscuro .offcanvas {
    background-color: var(--tema-bg-elevated);
    color: var(--tema-text);
}

body.tema-oscuro .offcanvas-header,
body.tema-oscuro .offcanvas-body {
    background-color: var(--tema-bg-elevated);
    color: var(--tema-text);
}

body.tema-oscuro .btn-close {
    filter: invert(1) grayscale(100%);
    opacity: 0.7;
}

/* Pie */
body.tema-oscuro .pie,
body.tema-oscuro footer {
    background-color: var(--tema-bg-elevated);
    color: var(--tema-text-muted);
    border-top: 1px solid var(--tema-border);
}

/* Tabs */
body.tema-oscuro .nav-tabs {
    border-bottom-color: var(--tema-border);
}

body.tema-oscuro .nav-tabs .nav-link {
    color: var(--tema-text-muted);
    border-color: transparent;
}

body.tema-oscuro .nav-tabs .nav-link:hover {
    color: var(--tema-text);
    border-color: var(--tema-border-soft);
}

body.tema-oscuro .nav-tabs .nav-link.active,
body.tema-oscuro .nav-tabs .nav-item.show .nav-link,
body.tema-oscuro .nav-tabs.nav-tabs-connect .nav-link.active,
body.tema-oscuro .nav-tabs.nav-tabs-connect .nav-item.show .nav-link,
body.tema-oscuro .nav-tabs.nav-tabs-connect .nav-link.active:focus,
body.tema-oscuro .nav-tabs.nav-tabs-connect .nav-item.show .nav-link:focus,
body.tema-oscuro .lecturas-tabs-wrap .nav-link.active,
body.tema-oscuro .lecturas-tabs-wrap .nav-item.show .nav-link,
body.tema-oscuro .lecturas-tabs-wrap .nav-tabs.nav-tabs-connect .nav-link.active,
body.tema-oscuro .lecturas-tabs-wrap .nav-tabs.nav-tabs-connect .nav-item.show .nav-link,
body.tema-oscuro .lecturas-tabs-wrap .nav-tabs.nav-tabs-connect .nav-link.active:focus,
body.tema-oscuro .lecturas-tabs-wrap .nav-tabs.nav-tabs-connect .nav-item.show .nav-link:focus,
body.tema-oscuro .modal .nav-tabs .nav-item .nav-link.active {
    background-color: var(--tema-surface) !important;
    color: var(--tema-text) !important;
    border-color: var(--tema-border) var(--tema-border) var(--tema-surface) !important;
    border-bottom-color: var(--tema-surface) !important;
}

body.tema-oscuro .lecturas-tabs-wrap .nav-link {
    color: var(--tema-text-muted) !important;
    background-color: transparent !important;
}

body.tema-oscuro .lecturas-tabs-wrap .nav-link:hover,
body.tema-oscuro .lecturas-tabs-wrap .nav-link:focus {
    color: var(--tema-text) !important;
}

body.tema-oscuro .tab-content,
body.tema-oscuro #configuracionTabsContent,
body.tema-oscuro #gestionCatalogosTabsContent,
body.tema-oscuro #progresoTabsContent > .tab-pane,
body.tema-oscuro .tab-pane.bg-white,
body.tema-oscuro .lecturas-tabs-wrap .tab-pane.bg-white {
    background-color: var(--tema-surface) !important;
    color: var(--tema-text);
    border-color: var(--tema-border) !important;
}

/* Cards / bloques / alerts */
body.tema-oscuro .card,
body.tema-oscuro .modal-content,
body.tema-oscuro .alert,
body.tema-oscuro #progresoTotalConAjustes,
body.tema-oscuro .configuracion-kpi,
body.tema-oscuro .configuracion-tema-opcion,
body.tema-oscuro .inversion-riesgo-panel,
body.tema-oscuro .inversion-riesgo-stat-card,
body.tema-oscuro .inversion-xray-stat-card {
    background-color: var(--tema-surface) !important;
    color: var(--tema-text);
    border-color: var(--tema-border) !important;
}

body.tema-oscuro .configuracion-kpi:hover,
body.tema-oscuro .configuracion-kpi:focus,
body.tema-oscuro .configuracion-tema-opcion:hover,
body.tema-oscuro .configuracion-tema-opcion:focus {
    background-color: var(--tema-surface-2) !important;
    border-color: var(--tema-primary) !important;
}

body.tema-oscuro .configuracion-tema-opcion.is-active {
    border-color: var(--tema-primary) !important;
    box-shadow: 0 0 0 0.15rem var(--tema-primary-soft);
    background-color: var(--tema-surface-2) !important;
}

body.tema-oscuro .alert-warning {
    background-color: var(--tema-warning-bg) !important;
    color: var(--tema-warning-text) !important;
    border-color: #5a4a1e !important;
}

body.tema-oscuro .alert-success {
    background-color: var(--tema-success-bg) !important;
    color: var(--tema-success) !important;
    border-color: #245239 !important;
}

body.tema-oscuro .modal-header,
body.tema-oscuro .modal-footer {
    border-color: var(--tema-border);
    background-color: var(--tema-surface);
}

body.tema-oscuro .modal-title {
    color: var(--tema-text);
}

/* Formularios */
body.tema-oscuro .form-control,
body.tema-oscuro .form-select,
body.tema-oscuro .form-control-sm,
body.tema-oscuro .form-select-sm,
body.tema-oscuro .input-group-text {
    background-color: var(--tema-input-bg) !important;
    border-color: var(--tema-border) !important;
    color: var(--tema-text) !important;
}

body.tema-oscuro .form-control::placeholder {
    color: var(--tema-text-muted);
    opacity: 0.85;
}

body.tema-oscuro .form-control:focus,
body.tema-oscuro .form-select:focus {
    background-color: var(--tema-input-bg) !important;
    border-color: var(--tema-primary) !important;
    color: var(--tema-text) !important;
    box-shadow: 0 0 0 0.2rem var(--tema-primary-soft);
}

body.tema-oscuro .form-check-input {
    background-color: var(--tema-input-bg);
    border-color: var(--tema-border);
}

body.tema-oscuro .form-check-input:checked {
    background-color: var(--tema-primary);
    border-color: var(--tema-primary);
}

body.tema-oscuro .form-label {
    color: var(--tema-text);
}

/* Select2 */
body.tema-oscuro .select2-container--bootstrap-5 .select2-selection,
body.tema-oscuro .select2-container--bootstrap-5 .select2-dropdown {
    background-color: var(--tema-input-bg) !important;
    border-color: var(--tema-border) !important;
    color: var(--tema-text) !important;
}

body.tema-oscuro .select2-container--bootstrap-5 .select2-selection__rendered,
body.tema-oscuro .select2-container--bootstrap-5 .select2-results__option {
    color: var(--tema-text) !important;
}

body.tema-oscuro .select2-container--bootstrap-5 .select2-results__option--highlighted {
    background-color: var(--tema-primary-soft) !important;
    color: var(--tema-text) !important;
}

body.tema-oscuro .select2-container--bootstrap-5 .select2-search__field {
    background-color: transparent !important;
    color: var(--tema-text) !important;
    border-color: transparent !important;
}

/* Chips seleccionados (categorías / etiquetas) */
body.tema-oscuro .select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__choice,
body.tema-oscuro .select2-container .select2-selection--multiple .select2-selection__choice {
    background-color: var(--tema-primary-soft) !important;
    border: 1px solid rgba(79, 140, 255, 0.45) !important;
    color: #d7e6ff !important;
}

body.tema-oscuro .select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__choice__remove,
body.tema-oscuro .select2-container .select2-selection--multiple .select2-selection__choice__remove {
    color: #b8cff8 !important;
    border-right-color: rgba(79, 140, 255, 0.35) !important;
}

body.tema-oscuro .select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__choice__remove:hover,
body.tema-oscuro .select2-container .select2-selection--multiple .select2-selection__choice__remove:hover {
    background-color: rgba(79, 140, 255, 0.28) !important;
    color: #fff !important;
}

body.tema-oscuro .select2-container--bootstrap-5.select2-container--focus .select2-selection,
body.tema-oscuro .select2-container--bootstrap-5.select2-container--open .select2-selection {
    border-color: var(--tema-primary) !important;
    box-shadow: 0 0 0 0.2rem var(--tema-primary-soft);
}

/* Datepicker */
body.tema-oscuro .datepicker,
body.tema-oscuro .datepicker-dropdown,
body.tema-oscuro .datepicker table tr td,
body.tema-oscuro .datepicker table tr th {
    background-color: var(--tema-surface);
    color: var(--tema-text);
    border-color: var(--tema-border);
}

body.tema-oscuro .datepicker table tr td.day:hover,
body.tema-oscuro .datepicker table tr td.focused {
    background-color: var(--tema-surface-2);
}

body.tema-oscuro .datepicker table tr td.active,
body.tema-oscuro .datepicker table tr td.active:hover {
    background-color: var(--tema-primary) !important;
    color: #fff !important;
}

/* Tablas / DataTables */
body.tema-oscuro table,
body.tema-oscuro .table,
body.tema-oscuro .dataTable {
    color: var(--tema-text);
    --bs-table-bg: transparent;
    --bs-table-striped-bg: rgba(255, 255, 255, 0.03);
    --bs-table-hover-bg: rgba(255, 255, 255, 0.05);
    --web-tabla-cabecera-bg: #243041;
    border-color: var(--tema-border);
}

/* Anula --web-tabla-cabecera-bg: #eef1f5 del CSS claro (más específico en main table) */
body.tema-oscuro main table.table:not(.movimientos-resumen-meses-tabla),
body.tema-oscuro .modal table.table:not(.movimientos-resumen-meses-tabla) {
    --web-tabla-cabecera-bg: #243041;
}

body.tema-oscuro .table > :not(caption) > * > *,
body.tema-oscuro table.dataTable tbody th,
body.tema-oscuro table.dataTable tbody td {
    background-color: transparent;
    color: var(--tema-text);
    border-color: var(--tema-border-soft);
}

/* Misma especificidad que web-gestor-cuentas.css (color #212529 + fondo claro) */
body.tema-oscuro main table.table:not(.movimientos-resumen-meses-tabla) > thead > tr > th,
body.tema-oscuro main table.table:not(.movimientos-resumen-meses-tabla) > thead > tr > td,
body.tema-oscuro main table.table:not(.movimientos-resumen-meses-tabla) > tfoot > tr > th,
body.tema-oscuro main table.table:not(.movimientos-resumen-meses-tabla) > tfoot > tr > td,
body.tema-oscuro .modal table.table:not(.movimientos-resumen-meses-tabla) > thead > tr > th,
body.tema-oscuro .modal table.table:not(.movimientos-resumen-meses-tabla) > thead > tr > td,
body.tema-oscuro .modal table.table:not(.movimientos-resumen-meses-tabla) > tfoot > tr > th,
body.tema-oscuro .modal table.table:not(.movimientos-resumen-meses-tabla) > tfoot > tr > td,
body.tema-oscuro .table thead th,
body.tema-oscuro table.dataTable thead th,
body.tema-oscuro table.dataTable thead td,
body.tema-oscuro .dataTables_wrapper .dataTables_scrollHead th,
body.tema-oscuro .dataTables_wrapper .dataTables_scrollHead td,
body.tema-oscuro .dataTables_scrollHeadInner table thead th,
body.tema-oscuro .fixedHeader-floating thead th,
body.tema-oscuro .fixedHeader-locked thead th,
body.tema-oscuro .inversion-xray-holdings-wrap thead th,
body.tema-oscuro main table.table > thead.sticky-top > tr > th,
body.tema-oscuro main table.table > thead.table-light > tr > th,
body.tema-oscuro .cuenta-movimientos-tabla-wrap thead.sticky-top > tr > th {
    background-color: #243041 !important;
    background-image: none !important;
    color: #e8eef4 !important;
    border-bottom-color: #2a3441 !important;
    border-color: #2a3441 !important;
}

body.tema-oscuro .table-hover > tbody > tr:hover > *,
body.tema-oscuro table.dataTable.hover tbody tr:hover > *,
body.tema-oscuro table.dataTable.display tbody tr:hover > * {
    background-color: rgba(255, 255, 255, 0.04) !important;
    color: var(--tema-text);
}

body.tema-oscuro .table-bordered > :not(caption) > *,
body.tema-oscuro .table-bordered > :not(caption) > * > * {
    border-color: var(--tema-border) !important;
}

/* Filas semánticas (ingresos/gastos) legibles en oscuro */
body.tema-oscuro .table-success,
body.tema-oscuro .table-success > th,
body.tema-oscuro .table-success > td {
    background-color: rgba(61, 214, 140, 0.12) !important;
    color: var(--tema-text) !important;
}
body.tema-oscuro .table-warning,
body.tema-oscuro .table-warning > th,
body.tema-oscuro .table-warning > td {
    background-color: rgba(240, 215, 140, 0.12) !important;
    color: var(--tema-text) !important;
}
/* Meses futuros en tablas de estadísticas */
body.tema-oscuro .table-secondary,
body.tema-oscuro tr.table-secondary {
    --bs-table-bg: #2a323c;
    --bs-table-striped-bg: #2a323c;
    --bs-table-striped-color: var(--tema-text-muted);
    --bs-table-active-bg: #323b47;
    --bs-table-active-color: var(--tema-text-muted);
    --bs-table-hover-bg: #323b47;
    --bs-table-hover-color: var(--tema-text-muted);
    color: var(--tema-text-muted);
}
body.tema-oscuro .table-secondary,
body.tema-oscuro .table-secondary > th,
body.tema-oscuro .table-secondary > td,
body.tema-oscuro tr.table-secondary > th,
body.tema-oscuro tr.table-secondary > td {
    background-color: #2a323c !important;
    color: var(--tema-text-muted) !important;
    box-shadow: none !important;
}

/* Badges / etiquetas en tablas */
body.tema-oscuro .badge.bg-primary {
    background-color: rgba(79, 140, 255, 0.22) !important;
    color: #d7e6ff !important;
    border: 1px solid rgba(79, 140, 255, 0.4);
    font-weight: 500;
}
body.tema-oscuro .badge.bg-secondary {
    background-color: rgba(154, 168, 181, 0.2) !important;
    color: #d5dde6 !important;
    border: 1px solid rgba(154, 168, 181, 0.35);
}
body.tema-oscuro .badge.bg-light,
body.tema-oscuro .badge.bg-light.text-dark {
    background-color: var(--tema-surface-2) !important;
    color: var(--tema-text) !important;
    border-color: var(--tema-border) !important;
}
body.tema-oscuro .badge.bg-success {
    background-color: rgba(61, 214, 140, 0.2) !important;
    color: #b8f0d3 !important;
    border: 1px solid rgba(61, 214, 140, 0.35);
}
body.tema-oscuro .badge.bg-danger {
    background-color: rgba(255, 107, 122, 0.2) !important;
    color: #ffc2c9 !important;
    border: 1px solid rgba(255, 107, 122, 0.35);
}

body.tema-oscuro .dataTables_wrapper .dataTables_paginate .paginate_button,
body.tema-oscuro .page-link {
    background-color: transparent !important;
    border-color: var(--tema-border) !important;
    color: var(--tema-text) !important;
}

body.tema-oscuro .dataTables_wrapper .dataTables_paginate .paginate_button.current,
body.tema-oscuro .page-item.active .page-link {
    background-color: var(--tema-primary) !important;
    border-color: var(--tema-primary) !important;
    color: #fff !important;
}

body.tema-oscuro .dataTables_wrapper .dataTables_info,
body.tema-oscuro .dataTables_wrapper .dataTables_length,
body.tema-oscuro .dataTables_wrapper .dataTables_filter label,
body.tema-oscuro .listado-paginacion-info {
    color: var(--tema-text-muted);
}

/* Zona «Mostrando…» + paginación: sin franja de fondo */
body.tema-oscuro .listado-toolbar,
body.tema-oscuro .listado-toolbar-footer,
body.tema-oscuro .listado-paginacion-wrap,
body.tema-oscuro .listado-paginacion,
body.tema-oscuro .dataTables_wrapper .row:has(.dataTables_info),
body.tema-oscuro .dataTables_wrapper .row:has(.dataTables_paginate) {
    background-color: transparent !important;
    box-shadow: none !important;
}

body.tema-oscuro .inversion-xray-holdings-wrap,
body.tema-oscuro .cuenta-movimientos-tabla-wrap {
    background: var(--tema-surface);
    border-color: var(--tema-border);
}

/* Carrusel meses (flechas Slick) */
body.tema-oscuro .movimientos-meses-carrusel .slick-prev,
body.tema-oscuro .movimientos-meses-carrusel .slick-next,
body.tema-oscuro .slick-prev,
body.tema-oscuro .slick-next {
    width: 2rem;
    height: 2rem;
    border-radius: 999px;
    background: var(--tema-surface-2) !important;
    border: 1px solid var(--tema-border) !important;
    box-shadow: 0 0.15rem 0.45rem rgba(0, 0, 0, 0.35);
    z-index: 3;
}
body.tema-oscuro .movimientos-meses-carrusel .slick-prev:hover,
body.tema-oscuro .movimientos-meses-carrusel .slick-next:hover,
body.tema-oscuro .slick-prev:hover,
body.tema-oscuro .slick-next:hover {
    background: var(--tema-primary-soft) !important;
    border-color: rgba(79, 140, 255, 0.55) !important;
}
body.tema-oscuro .movimientos-meses-carrusel .slick-prev:before,
body.tema-oscuro .movimientos-meses-carrusel .slick-next:before,
body.tema-oscuro .slick-prev:before,
body.tema-oscuro .slick-next:before {
    color: var(--tema-text) !important;
    opacity: 1;
    font-size: 1.05rem;
    line-height: 2rem;
}
body.tema-oscuro .mes-mov-slide-compact {
    background: var(--tema-surface) !important;
    border-color: var(--tema-border) !important;
    color: var(--tema-text);
}
body.tema-oscuro .mes-mov-slide-compact.mes-mov-slide-activo {
    border-color: var(--tema-primary) !important;
    box-shadow: 0 0 0 1px rgba(79, 140, 255, 0.4);
}
body.tema-oscuro .mes-mov-mes-card,
body.tema-oscuro .mes-mov-mes-card .card-header,
body.tema-oscuro .mes-mov-mes-card .card-body {
    background-color: var(--tema-surface) !important;
    color: var(--tema-text);
    border-color: var(--tema-border) !important;
}
body.tema-oscuro .mes-mov-mes-card .card-header.bg-primary {
    background-color: rgba(79, 140, 255, 0.28) !important;
    color: #e8f0ff !important;
}

/* Botones outline sobre oscuro */
body.tema-oscuro .btn-outline-secondary,
body.tema-oscuro .btn-outline-dark {
    color: var(--tema-text);
    border-color: var(--tema-border);
}

body.tema-oscuro .btn-outline-secondary:hover,
body.tema-oscuro .btn-outline-dark:hover {
    background-color: var(--tema-surface-2);
    border-color: var(--tema-text-muted);
    color: var(--tema-text);
}

body.tema-oscuro .btn-outline-primary {
    color: var(--tema-primary);
    border-color: var(--tema-primary);
}

body.tema-oscuro .btn-light {
    background-color: var(--tema-surface-2);
    border-color: var(--tema-border);
    color: var(--tema-text);
}

/* Inversión / progreso / resumen superficies frecuentes */
body.tema-oscuro .inversion-fondo-card,
body.tema-oscuro .inversion-cartera-barra-segmentada,
body.tema-oscuro .resumen-bloque-categoria,
body.tema-oscuro .bg-white.p-2 {
    background-color: var(--tema-surface) !important;
    color: var(--tema-text);
    border-color: var(--tema-border);
}

/* Filtros de página: sin caja de fondo (alineados visualmente con el contenido) */
body.tema-oscuro .filtros-resumen,
body.tema-oscuro .filtros_movimientos,
body.tema-oscuro #filtros {
    background-color: transparent !important;
    border-color: transparent !important;
    box-shadow: none !important;
}

body.tema-oscuro .inversion-cartera-barra-segmentada {
    background: var(--tema-surface-2);
}

body.tema-oscuro .list-group-item {
    background-color: var(--tema-surface);
    color: var(--tema-text);
    border-color: var(--tema-border);
}

body.tema-oscuro .popover,
body.tema-oscuro .tooltip-inner {
    background-color: var(--tema-surface-2);
    color: var(--tema-text);
    border-color: var(--tema-border);
}

body.tema-oscuro .swal2-popup {
    background: var(--tema-surface) !important;
    color: var(--tema-text) !important;
}

body.tema-oscuro .swal2-title,
body.tema-oscuro .swal2-html-container {
    color: var(--tema-text) !important;
}

body.tema-oscuro hr {
    border-color: var(--tema-border);
    opacity: 1;
}

/* Manual / contenido tipográfico */
body.tema-oscuro #titulo h1,
body.tema-oscuro h1,
body.tema-oscuro h2,
body.tema-oscuro h3,
body.tema-oscuro h4,
body.tema-oscuro h5,
body.tema-oscuro h6 {
    color: var(--tema-text);
}

body.tema-oscuro .pagination .page-item.disabled .page-link {
    background-color: var(--tema-surface);
    border-color: var(--tema-border);
    color: var(--tema-text-muted);
}

/* —— Mislecturas: cabecera, solapas y listados —— */
body.tema-oscuro .app-top-stack {
    background-color: var(--tema-bg-elevated);
    border-bottom-color: var(--tema-border);
}

body.tema-oscuro .panel-toggles-solapas {
    background-color: var(--tema-surface);
    border-color: var(--tema-border);
}

body.tema-oscuro .panel-toggles-solapas .btn,
body.tema-oscuro .panel-toggles-solapas a {
    color: var(--tema-text);
}

body.tema-oscuro .page-section-title,
body.tema-oscuro .page-section-heading h1 {
    color: var(--tema-text);
}

body.tema-oscuro .item-card {
    background-color: var(--tema-surface);
    border-color: var(--tema-border);
    color: var(--tema-text);
}

body.tema-oscuro .item-card .item-card-title,
body.tema-oscuro .item-card .item-card-subtitle {
    color: #c5ced8;
}
body.tema-oscuro .item-card .item-card-title a:not(.btn):not(.dropdown-item):not(.nav-link):not(.page-link),
body.tema-oscuro .item-card .item-card-subtitle a:not(.btn):not(.dropdown-item):not(.nav-link):not(.page-link) {
    color: #c5ced8 !important;
}
body.tema-oscuro .item-card .item-card-title a:not(.btn):not(.dropdown-item):not(.nav-link):not(.page-link):hover,
body.tema-oscuro .item-card .item-card-title a:not(.btn):not(.dropdown-item):not(.nav-link):not(.page-link):focus,
body.tema-oscuro .item-card .item-card-subtitle a:not(.btn):not(.dropdown-item):not(.nav-link):not(.page-link):hover,
body.tema-oscuro .item-card .item-card-subtitle a:not(.btn):not(.dropdown-item):not(.nav-link):not(.page-link):focus {
    color: #f0f4f8 !important;
    text-decoration: none;
}
body.tema-oscuro .item-card-grupo-icon {
    color: #9aa8b5;
}

body.tema-oscuro .item-card-footer {
    background-color: var(--tema-surface-2);
    border-top-color: var(--tema-border);
}

body.tema-oscuro .item-card-media-empty {
    background-color: var(--tema-surface-2);
    color: var(--tema-text-muted);
}

/* Toolbar de acciones / estado de lectura en cards */
body.tema-oscuro .item-card-toolbar {
    background: rgba(18, 24, 31, 0.92);
    border-color: var(--tema-border);
}

body.tema-oscuro .item-card-status .dropdown-menu {
    background-color: var(--tema-surface);
    border-color: var(--tema-border);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

body.tema-oscuro .item-card-status .dropdown-item {
    color: var(--tema-text);
}

body.tema-oscuro .item-card-status .dropdown-item:hover,
body.tema-oscuro .item-card-status .dropdown-item:focus {
    background-color: var(--tema-primary-soft);
    color: var(--tema-text);
}

body.tema-oscuro .item-card-status-btn.btn-light,
body.tema-oscuro .item-card .btn-dropdown-lectura.btn-light {
    background: var(--tema-surface-2) !important;
    color: var(--tema-text-muted) !important;
    border-color: var(--tema-border) !important;
}

body.tema-oscuro .item-card-status-btn.btn-success,
body.tema-oscuro .item-card .btn-dropdown-lectura.btn-success {
    background: rgba(61, 214, 140, 0.18) !important;
    color: #b8f0d3 !important;
    border-color: rgba(61, 214, 140, 0.4) !important;
}

body.tema-oscuro .item-card-status-btn.btn-warning,
body.tema-oscuro .item-card .btn-dropdown-lectura.btn-warning {
    background: rgba(240, 215, 140, 0.16) !important;
    color: #f0d78c !important;
    border-color: rgba(240, 215, 140, 0.4) !important;
}

body.tema-oscuro .item-card-status-btn.btn-info,
body.tema-oscuro .item-card .btn-dropdown-lectura.btn-info {
    background: rgba(79, 140, 255, 0.16) !important;
    color: #b7d0ff !important;
    border-color: rgba(79, 140, 255, 0.4) !important;
}

body.tema-oscuro .item-card-icon-btn {
    background: var(--tema-surface-2);
    border-color: var(--tema-border);
    color: var(--tema-text-muted);
}

body.tema-oscuro .item-card-icon-btn:hover,
body.tema-oscuro .item-card-icon-btn:focus {
    background: var(--tema-primary-soft);
    border-color: rgba(79, 140, 255, 0.45);
    color: var(--tema-text);
}

body.tema-oscuro .item-card-icon-btn--info {
    background: rgba(79, 140, 255, 0.12);
    border-color: rgba(79, 140, 255, 0.35);
    color: #9ec2ff;
}

body.tema-oscuro .item-card-icon-btn--info:hover,
body.tema-oscuro .item-card-icon-btn--info:focus {
    background: rgba(79, 140, 255, 0.22);
    color: #d7e6ff;
}

body.tema-oscuro .item-card-icon-btn--dates {
    background: var(--tema-surface-2);
    border-color: var(--tema-border);
    color: var(--tema-text-muted);
}

body.tema-oscuro .item-card-icon-btn--dates:hover,
body.tema-oscuro .item-card-icon-btn--dates:focus {
    background: var(--tema-primary-soft);
    color: var(--tema-text);
}

body.tema-oscuro .item-card-icon-btn--loan {
    background: rgba(240, 215, 140, 0.12);
    border-color: rgba(240, 215, 140, 0.35);
    color: #f0d78c;
}

body.tema-oscuro .item-card-icon-btn--loan.is-active,
body.tema-oscuro .item-card-icon-btn--loan:hover,
body.tema-oscuro .item-card-icon-btn--loan:focus {
    background: rgba(240, 215, 140, 0.22);
    color: #f7e7a8;
}

body.tema-oscuro .item-card-icon-btn--success,
body.tema-oscuro .item-card-icon-btn.btn-success,
body.tema-oscuro .item-card-icon-btn.eliminar-comic-button {
    background: rgba(61, 214, 140, 0.16);
    border-color: rgba(61, 214, 140, 0.4);
    color: #b8f0d3;
}

body.tema-oscuro .item-card-icon-btn--warning {
    background: rgba(240, 215, 140, 0.14);
    border-color: rgba(240, 215, 140, 0.35);
    color: #f0d78c;
}

body.tema-oscuro .item-card-icon-btn--warning:hover,
body.tema-oscuro .item-card-icon-btn--warning:focus {
    background: rgba(240, 215, 140, 0.24);
    color: #f7e7a8;
}

body.tema-oscuro .item-card-icon-btn--danger {
    background: rgba(255, 107, 122, 0.14);
    border-color: rgba(255, 107, 122, 0.35);
    color: #ffc2c9;
}

body.tema-oscuro .item-card-icon-btn--danger:hover,
body.tema-oscuro .item-card-icon-btn--danger:focus {
    background: rgba(255, 107, 122, 0.24);
    color: #ffd6db;
}

/* Filtros y listados: sin caja de fondo más ancha/clara */
body.tema-oscuro .filtros-panel,
body.tema-oscuro .filtros-wrap,
body.tema-oscuro #filtros,
body.tema-oscuro .filtros-panel-body,
body.tema-oscuro .filtros-panel-toggles,
body.tema-oscuro .btn-toggle-filtros-wrap {
    background-color: transparent !important;
    border-color: transparent !important;
    box-shadow: none !important;
    color: var(--tema-text);
}

body.tema-oscuro .btn-toggle-filtros,
body.tema-oscuro .btn-toggle-coleccion-info {
    background-color: transparent !important;
    color: var(--tema-text-muted);
    box-shadow: none !important;
}

body.tema-oscuro .btn-toggle-filtros:hover,
body.tema-oscuro .btn-toggle-filtros:focus,
body.tema-oscuro .btn-toggle-coleccion-info:hover,
body.tema-oscuro .btn-toggle-coleccion-info:focus,
body.tema-oscuro .btn-toggle-filtros[aria-expanded="true"],
body.tema-oscuro .btn-toggle-coleccion-info[aria-expanded="true"] {
    background-color: transparent !important;
    color: var(--tema-text);
}

body.tema-oscuro .panel-toggles-solapas .btn-toggle-filtros:hover,
body.tema-oscuro .panel-toggles-solapas .btn-toggle-filtros:focus,
body.tema-oscuro .panel-toggles-solapas .btn-toggle-coleccion-info:hover,
body.tema-oscuro .panel-toggles-solapas .btn-toggle-coleccion-info:focus,
body.tema-oscuro .panel-toggles-solapas .btn-toggle-filtros[aria-expanded="true"],
body.tema-oscuro .panel-toggles-solapas .btn-toggle-coleccion-info[aria-expanded="true"] {
    background- transparent !important;
    color: var(--tema-text);
}

body.tema-oscuro .biblioteca-resumen,
body.tema-oscuro .resumen-bloque {
    background-color: var(--tema-surface) !important;
    border-color: var(--tema-border) !important;
    color: var(--tema-text);
}

body.tema-oscuro .ui-autocomplete,
body.tema-oscuro .ui-menu,
body.tema-oscuro .buscar-autocomplete,
body.tema-oscuro .ui-widget-content {
    background-color: var(--tema-surface) !important;
    border-color: var(--tema-border) !important;
    color: var(--tema-text) !important;
}

body.tema-oscuro .ui-menu-item-wrapper,
body.tema-oscuro .ui-menu .ui-menu-item-wrapper {
    color: var(--tema-text) !important;
}

body.tema-oscuro .ui-state-active,
body.tema-oscuro .ui-widget-content .ui-state-active,
body.tema-oscuro .ui-menu-item-wrapper.ui-state-active {
    background-color: var(--tema-primary-soft) !important;
    border-color: var(--tema-primary) !important;
    color: var(--tema-text) !important;
}

body.tema-oscuro .scrape-overlay {
    background-color: rgba(15, 20, 25, 0.72);
}

body.tema-oscuro .scrape-overlay-box {
    background-color: var(--tema-surface);
    border-color: var(--tema-border);
    color: var(--tema-text);
}

body.tema-oscuro .lecturas-tabs-wrap .tab-pane.bg-white {
    background-color: var(--tema-surface) !important;
}

body.tema-oscuro .progress,
body.tema-oscuro .progress-new-bar {
    background-color: var(--tema-surface-2);
}

body.tema-oscuro .comic-card,
body.tema-oscuro .libro-card,
body.tema-oscuro .coleccion-card {
    background-color: var(--tema-surface);
    border-color: var(--tema-border);
    color: var(--tema-text);
}

body.tema-oscuro .breadcrumb,
body.tema-oscuro .breadcrumb-item,
body.tema-oscuro .breadcrumb-item a {
    color: var(--tema-text-muted);
}

body.tema-oscuro .breadcrumb-item.active {
    color: var(--tema-text);
}

body.tema-oscuro .list-group-item {
    background-color: var(--tema-surface);
    border-color: var(--tema-border);
    color: var(--tema-text);
}

body.tema-oscuro .accordion-item,
body.tema-oscuro .accordion-button {
    background-color: var(--tema-surface);
    color: var(--tema-text);
    border-color: var(--tema-border);
}

body.tema-oscuro .accordion-button:not(.collapsed) {
    background-color: var(--tema-surface-2);
    color: var(--tema-text);
}

body.tema-oscuro .accordion-button::after {
    filter: invert(1) brightness(1.4);
}

body.tema-oscuro .configuracion-tema-opcion {
    background-color: var(--tema-surface);
    color: var(--tema-text);
}

body.tema-oscuro .configuracion-tema-opcion:hover,
body.tema-oscuro .configuracion-tema-opcion:focus {
    background-color: var(--tema-surface-2);
    border-color: var(--tema-primary) !important;
}

body.tema-oscuro .configuracion-tema-opcion.is-active {
    border-color: var(--tema-primary) !important;
    box-shadow: 0 0 0 0.15rem var(--tema-primary-soft);
}

/* —— Modales (libros y resto) —— */
body.tema-oscuro .modal-content,
body.tema-oscuro .modal-content > form,
body.tema-oscuro .modal-body,
body.tema-oscuro .modal-dialog-scrollable .modal-content > form > .modal-body {
    background-color: var(--tema-surface) !important;
    color: var(--tema-text);
}

body.tema-oscuro .modal-header,
body.tema-oscuro .modal-footer {
    background-color: var(--tema-surface-2) !important;
    border-color: var(--tema-border) !important;
    color: var(--tema-text);
}

body.tema-oscuro .modal-title,
body.tema-oscuro .modal-title.text-muted {
    color: var(--tema-text-muted) !important;
}

body.tema-oscuro .modal .form-label,
body.tema-oscuro .modal .form-text {
    color: var(--tema-text-muted) !important;
}

body.tema-oscuro .modal .form-control:disabled,
body.tema-oscuro .modal .form-control[readonly],
body.tema-oscuro .modal .form-select:disabled {
    background-color: var(--tema-surface-2) !important;
    color: var(--tema-text-muted) !important;
    opacity: 1;
}

body.tema-oscuro .modal input[type="date"],
body.tema-oscuro .modal input[type="datetime-local"],
body.tema-oscuro .modal input[type="time"] {
    color-scheme: dark;
}

body.tema-oscuro .modal .alert-danger {
    background-color: rgba(255, 107, 122, 0.14) !important;
    color: #ffc2c9 !important;
    border-color: rgba(255, 107, 122, 0.35) !important;
}

body.tema-oscuro .modal .alert-info,
body.tema-oscuro .modal .alert-primary {
    background-color: var(--tema-primary-soft) !important;
    color: #d7e6ff !important;
    border-color: rgba(79, 140, 255, 0.35) !important;
}

/* Modal añadir/editar libro */
body.tema-oscuro #modalLibro .modal-body {
    background: var(--tema-surface) !important;
}
body.tema-oscuro #modalLibro .form-label {
    color: var(--tema-text-muted) !important;
}
body.tema-oscuro .libro-portada-preview {
    background: linear-gradient(160deg, #1e2733 0%, #171e27 55%, #12181f 100%) !important;
    border-color: var(--tema-border) !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 12px 28px rgba(0, 0, 0, 0.35);
}
body.tema-oscuro .libro-portada-trigger:hover .libro-portada-preview,
body.tema-oscuro .libro-portada-trigger:focus-within .libro-portada-preview {
    border-color: rgba(79, 140, 255, 0.45) !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 14px 32px rgba(0, 0, 0, 0.45);
}
body.tema-oscuro .libro-portada-placeholder {
    color: var(--tema-text-muted) !important;
}
body.tema-oscuro .libro-autocomplete-menu.ui-autocomplete,
body.tema-oscuro .libro-autocomplete-menu.ui-widget-content {
    background-color: var(--tema-surface) !important;
    border-color: var(--tema-border) !important;
    color: var(--tema-text) !important;
}

/* Modal registro de lectura */
body.tema-oscuro #modalRegistroLectura .registro-lectura-titulo {
    color: var(--tema-text) !important;
}
body.tema-oscuro #modalRegistroLectura .registro-lectura-historial {
    background: var(--tema-input-bg) !important;
    border-color: var(--tema-border) !important;
}
body.tema-oscuro #modalRegistroLectura .registro-lectura-historial thead th {
    background: var(--tema-surface-2) !important;
    color: var(--tema-text) !important;
    box-shadow: 0 1px 0 var(--tema-border);
}
body.tema-oscuro #modalRegistroLectura .registro-lectura-editor {
    background: var(--tema-input-bg) !important;
    border-color: var(--tema-border) !important;
}
body.tema-oscuro #modalRegistroLectura .registro-lectura-editor-label,
body.tema-oscuro #modalRegistroLectura .registro-lectura-editor .form-label {
    color: var(--tema-text-muted) !important;
}
body.tema-oscuro #modalRegistroLectura .progress-new-bar {
    background-color: var(--tema-surface-2) !important;
}

/* Tablas / bloques frecuentes dentro de modales */
body.tema-oscuro .modal .table-responsive,
body.tema-oscuro .modal .list-group,
body.tema-oscuro .modal .list-group-item,
body.tema-oscuro .modal .card,
body.tema-oscuro .modal .bg-white,
body.tema-oscuro .modal .bg-light {
    background-color: var(--tema-surface) !important;
    color: var(--tema-text);
    border-color: var(--tema-border) !important;
}
body.tema-oscuro .modal .fixed-table-container,
body.tema-oscuro .modal .bootstrap-table,
body.tema-oscuro .modal .fixed-table-body,
body.tema-oscuro .modal .fixed-table-header,
body.tema-oscuro .modal .fixed-table-toolbar {
    background-color: transparent !important;
    color: var(--tema-text);
}

/* Modal agrupar ediciones */
body.tema-oscuro .obra-grupo-ayuda,
body.tema-oscuro .obra-grupo-banner,
body.tema-oscuro .obra-grupo-miembros-titulo,
body.tema-oscuro .obra-grupo-sin-resultados,
body.tema-oscuro .obra-grupo-resultado-editorial {
    color: var(--tema-text-muted) !important;
}
body.tema-oscuro .obra-grupo-resultados {
    background: var(--tema-input-bg) !important;
    border-color: var(--tema-border) !important;
}
body.tema-oscuro .obra-grupo-resultado {
    border-bottom-color: var(--tema-border) !important;
}
body.tema-oscuro .obra-grupo-resultado:hover,
body.tema-oscuro .obra-grupo-resultado.is-active {
    background: var(--tema-surface-2) !important;
}
body.tema-oscuro .obra-grupo-resultado-titulo {
    color: var(--tema-text) !important;
}
body.tema-oscuro .obra-grupo-miembro {
    border-top-color: var(--tema-border) !important;
}
body.tema-oscuro .obra-grupo-miembro-info a:not(.btn) {
    color: #c5ced8 !important;
}
body.tema-oscuro .obra-grupo-badge {
    background-color: var(--tema-primary-soft) !important;
    color: #d7e6ff !important;
}

body.tema-oscuro #editarFechasTitulo.registro-lectura-titulo,
body.tema-oscuro .modal .registro-lectura-titulo {
    color: var(--tema-text) !important;
}

/* Chapas de número / próximos lanzamientos */
body.tema-oscuro .item-card-badge {
    color: #fff;
    background: rgba(8, 12, 18, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.16);
    box-shadow:
        0 2px 4px rgba(0, 0, 0, 0.35),
        0 6px 18px rgba(0, 0, 0, 0.55);
}
body.tema-oscuro .item-card-badge-meta {
    color: #d7dee6;
    opacity: 0.95;
}
body.tema-oscuro .item-card-badge--preparacion {
    color: #fff3c4;
    background: rgba(72, 58, 18, 0.98);
    border-color: rgba(240, 215, 140, 0.42);
}
body.tema-oscuro .item-card-badge--preparacion .item-card-badge-meta {
    color: #f0d78c;
}
body.tema-oscuro .item-card-badge--no-editado {
    color: #ffd6db;
    background: rgba(110, 32, 42, 0.96);
    border-color: rgba(255, 107, 122, 0.35);
}
body.tema-oscuro .item-card-badge--especial {
    color: #c9f0ed;
    background: rgba(22, 78, 76, 0.96);
    border-color: rgba(80, 190, 180, 0.35);
}

/* Modal detalles libro/manga */
body.tema-oscuro .modal-detalles-item .detalles-item-portada {
    background: var(--tema-surface-2);
    border-color: var(--tema-border);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}
body.tema-oscuro .modal-detalles-item .detalles-item-bloque-titulo {
    color: var(--tema-text-muted);
    border-bottom-color: var(--tema-border);
}
body.tema-oscuro .modal-detalles-item .detalles-item-tabla > :not(caption) > * > * {
    border-bottom-color: var(--tema-border-soft);
    color: var(--tema-text);
}
body.tema-oscuro .modal-detalles-item .detalles-item-label {
    color: var(--tema-text-muted);
}
body.tema-oscuro .modal-detalles-item .detalles-item-valor {
    color: var(--tema-text);
}
