:root {
    --vz-icon-inline-item: rgba(0, 0, 0, .5) !important
}

[data-layout-mode=dark] {
    --vz-icon-inline-item: #fff !important
}

#datatablepage {
    width: 100% !important
}

#datatablepage_info, #datatablepage_length {
    float: left !important
}

.col-form-label {
    text-align: right !important
}

#datatablepage tbody tr.selected {
    background-color: #404750 !important
}

table.dataTable > tbody > tr.selected > * {
    box-shadow: none !important;
    color: #fff !important
}

table.dataTable tbody tr.selected > .dtfc-fixed-end, table.dataTable tbody tr.selected > .dtfc-fixed-start {
    background-color: #404750 !important;
    color: #fff !important
}

.px-20 {
    padding-right: 20rem !important;
    padding-left: 20rem !important
}

.px-22 {
    padding-right: 22rem !important;
    padding-left: 22rem !important
}

.dt-buttons {
    display: none
}

.select-item {
    margin: 0 3px !important
}

table.dataTable > tbody > tr .list-inline-item i {
    color: var(--vz-icon-inline-item) !important
}

table.dataTable > tbody > tr.selected .list-inline-item i {
    color: #fff !important
}

.alert.hide, [data-preloader=disable] #preloader {
    opacity: 0;
    visibility: hidden
}

*, html {
    scrollbar-width: thin;
    scrollbar-color: #888 #f1f1f1
}

@supports (-webkit-touch-callout:none) {
    ::-webkit-scrollbar {
        width: 12px;
        height: 12px
    }

    ::-webkit-scrollbar-track {
        background: #f1f1f1
    }

    ::-webkit-scrollbar-thumb {
        background-color: #888;
        border-radius: 10px;
        border: 3px solid #f1f1f1
    }

    ::-webkit-scrollbar-thumb:hover {
        background: #555
    }
}

@supports (scrollbar-width:thin) {
    * {
        scrollbar-width: thin;
        scrollbar-color: #888 #f1f1f1
    }
}

@supports (-ms-overflow-style:-ms-autohiding-scrollbar) {
    * {
        -ms-overflow-style: -ms-autohiding-scrollbar
    }
}

.min-width-40 {
    min-width: 40px
}

.alert {
    transition: opacity .5s ease-out, visibility .5s ease-out
}

.choices {
    margin-bottom: 0 !important
}

table.dataTable tbody tr > .dtfc-fixed-end, table.dataTable tbody tr > .dtfc-fixed-start, table.dataTable tfoot tr > .dtfc-fixed-end, table.dataTable tfoot tr > .dtfc-fixed-start, table.dataTable thead tr > .dtfc-fixed-end, table.dataTable thead tr > .dtfc-fixed-start {
    background-color: var(--vz-border-color) !important
}

.display-none {
    display: none !important
}

.dt-orderable-none {
    position: relative !important;
    padding-right: 30px !important;
}

.modal-xxl {
    max-width: 1520px
}

.bg-light-subtle {
    background-color: #f9fbfc !important
}

.dt-buttons {
    padding: 1rem 1rem;
    margin-right: .5rem !important
    float: left !important
}

.dt-length {
    padding: 1rem 1rem;
    float: right !important
}

.dt-search {
    padding: 1rem 1rem;
}

.dt-info {
    padding: 1rem 1rem;
}

.paging_full_numbers {
    padding: 0 1rem 3rem 1rem;
}

.data-choices-sm .choices__inner {
    padding: 0rem 3.6rem 0rem .5rem !important;
    min-height: 28.5px !important;
    font-size: 0.75rem !important;
}

.choices__item {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.datatable-check-all {
    display: block;
    position: absolute;
    top: 50%;
    left: 50%;
    width: 12px;
    height: 12px;
    box-sizing: border-box;
    margin-top: -6px;
    margin-left: -6px;
    border: 1px solid;
    border-radius: 3px;
    cursor: pointer;
}

.swal2-container, .swal2-html-container, swal2-actions {
    z-index: 21100 !important;
    overflow: visible !important;
}

.flatpickr-calendar {
    z-index: 20000 !important;
}

.choices__list--dropdown {
    z-index: 20000 !important;
}

.swal2-backdrop-show {
    background-color: rgba(0, 0, 0, 0.5) !important;
}

.swal2-validation-message {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    padding: 10px;
    margin: 20px 1.5rem 15px 1.5rem;
    font-size: 14px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.swal2-custom-swal-popup {
    max-height: 90vh;
    overflow-y: auto;
}

/* Ajustes para pantallas pequeñas */
@media (max-width: 768px) {
    .swal2-custom-swal-popup {
        width: 95% !important;
        max-height: 90vh;
    }
}

.table-responsive {
    overflow-x: hidden; /* Oculta el scroll horizontal inicialmente */
    overflow-y: hidden; /* Oculta el scroll vertical (si no es necesario) */
    width: 100%; /* Asegura que ocupe el 100% del ancho disponible */
    -webkit-overflow-scrolling: touch; /* Mejora el desplazamiento en dispositivos táctiles */
    position: relative; /* Necesario para algunos casos de uso avanzados */
}

.table-responsive:hover,
.table-responsive:focus-within {
    overflow-x: auto; /* Muestra el scroll horizontal al hacer hover o interactuar */
}

.auth-one-bg {
    background-image: url("../images/utils/login-cover-JWTLVtR.png");
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
}

.depot-select-container {
    position: relative;
}

.depot-select {
    position: relative;
    cursor: pointer;
}

.depot-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    padding: 0.5rem;
    margin-top: 0.25rem;
}

.depot-select.open .depot-dropdown {
    display: block;
}

.search-input {
    margin-bottom: 0.5rem;
}

.depot-results {
    max-height: 300px;
    overflow-y: auto;
}

.depot-item {
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-radius: 0.25rem;
}

.depot-item:hover {
    background-color: #f8f9fa;
}

.no-results {
    padding: 0.5rem 1rem;
    color: #6c757d;
}

.page-content {
    -webkit-box-shadow: none !important;
    box-shadow: none !important;
    padding: calc(57px + 1.5rem) calc(1.5rem / 2) 60px !important;
}

.container-fluid {
    padding-left: 0 !important;
}

#page-topbar {
    border-bottom: 1px solid rgba(0, 0, 0, .100) !important;
}

.advanced-marker {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 40px;
    height: 40px;
}

.marker-container {
    /*display: flex;
    justify-content: center;
    align-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease-in-out;*/

    position: relative;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: #10B981;
    color: #fff;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;


}

.marker-container:hover {
    transform: scale(1.2);
}

.marker-icon {
    position: absolute;
    top: 0px;
    right: 0px;
    transform: translate(40%, -40%);
    background-color: white;
    border-radius: 50%;
    padding: 2px;
    font-size: 10px;
}

.marker-index {
    z-index: 1;
}

.first .marker-container {
    border: 3px solid #1D4ED8;
}

.last .marker-container {
    border: 3px solid #7E22CE;
}


.flatpickr-calendar {
    background: white !important;
    box-shadow: none !important;
}

.flatpickr-months {
    background: white !important;
    border-bottom: 1px solid #eee !important;
}

.flatpickr-month {
    color: black !important;
    fill: black !important;
}

.flatpickr-weekdays {
    background: white !important;
}

span.flatpickr-weekday {
    color: black !important;
    background: white !important;
}

.flatpickr-day {
    color: black !important;
    background: white !important;
    border: none !important;
}

.flatpickr-day:hover {
    background: #f0f0f0 !important;
}

.flatpickr-day.today {
    border-color: #f3f3f9 !important;
    color: black !important;
    background: #f3f3f9 !important;
}

.flatpickr-day.selected {
    background: #323835 !important;
    color: white !important;
    border-color: #323835 !important;
}

.flatpickr-day.inRange {
    background: #f0f0f0 !important;
    box-shadow: none !important;
}

.blue-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 9px;
    height: 9px;
    background-color: #4CAF50; /* Verde */
    border-radius: 50%;
    z-index: 1;
}

.flatpickr-day {
    position: relative;
    padding-bottom: 12px;
}


.flatpickr-day.endRange.startRange + .endRange:not(:nth-child(7n+1)), .flatpickr-day.selected.startRange + .endRange:not(:nth-child(7n+1)), .flatpickr-day.startRange.startRange + .endRange:not(:nth-child(7n+1)) {
    -webkit-box-shadow: -10px 0 0 #323835;
    box-shadow: -10px 0 0 #323835;
}

.week-current {
    background-color: rgba(0, 123, 255, 0.1) !important;
    border-radius: 0;
}

/* Para resaltar toda la fila de la semana */
.flatpickr-calendar .flatpickr-weekwrapper .flatpickr-weeks .flatpickr-week.selected {
    background-color: rgba(0, 123, 255, 0.1);
}

@keyframes heartbeat {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(var(--marker-color-rgb), 0.7);
    }
    25% {
        transform: scale(1.3);
        box-shadow: 0 0 0 5px rgba(var(--marker-color-rgb), 0.4);
    }
    35% {
        transform: scale(1.25);
    }
    50% {
        transform: scale(1.3);
        box-shadow: 0 0 0 10px rgba(var(--marker-color-rgb), 0);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(var(--marker-color-rgb), 0);
    }
}

.heartbeat-marker .marker-container {
    border-radius: 50%;
    animation: heartbeat 1.5s infinite;
    transform-origin: center;
    will-change: transform, box-shadow;
}

.breadcrumb-item + .breadcrumb-item::before {
    line-height: 24px !important;
}

.toast {
    background-color: #FFFFFF !important;
}

.toast-margin-top {
    margin-top: 65px !important;
}

.fixed-item {
    background-color: #f8f9fa !important;
    cursor: not-allowed !important;
}

.fixed-item .drag-handle {
    display: none !important;
}

.sortable-ghost {
    opacity: 0.4;
    background-color: #e9ecef;
}

/* Estados de loading */
.sortable-loading {
    position: relative;
}

.sortable-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    z-index: 999;
}

/* Elementos fijos */
.fixed-item {
    background-color: #f8f9fa !important;
    cursor: not-allowed !important;
    border-left: 3px solid #6c757d !important;
}

.fixed-item .drag-handle {
    display: none !important;
}

/* Elementos arrastrables */
.sortable-item {
    border-left: 3px solid #007bff !important;
    transition: all 0.2s ease;
}

/* Cuando está deshabilitado */
.sortable-loading .sortable-item {
    opacity: 0.6;
    cursor: not-allowed !important;
}

.sortable-loading .drag-handle {
    cursor: not-allowed !important;
    opacity: 0.5;
}

/* Efectos durante arrastre */
.sortable-drag {
    opacity: 0.8;
    transform: rotate(2deg);
}

.sortable-ghost {
    opacity: 0.4;
    background-color: #e9ecef;
}

.gm-style-iw button.gm-ui-hover-effect {
    display: none !important;
}

/* Estilos personalizados para la guía horizontal */
.table-bordered td, .table-bordered th {
    border: 1px solid #e9ebec !important;
}

.bg-primary-subtle {
    background-color: rgba(64, 81, 137, 0.1) !important;
}

.bg-dark-subtle {
    background-color: #f3f3f3 !important;
}

/* Colores solicitados */
.text-success-custom {
    color: #28a745 !important;
}

/* Verde Esmeralda */
.text-optional-custom {
    color: #adb5bd !important;
}

/* Gris Suave */

.avatar-sm {
    width: 48px;
    height: 48px;
}

.avatar-title {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.italic {
    font-style: italic;
}

/* Efecto hover sobre la "hoja" de excel */
.table-nowrap tbody tr:hover td:not(:first-child) {
    background-color: rgba(64, 81, 137, 0.02);
}

.btn-soft-success {
    color: #28a745;
    background-color: rgba(40, 167, 69, 0.1);
    border-color: transparent;
}

.btn-soft-success:hover {
    color: #fff;
    background-color: #28a745;
}

.btn-label.right .label-icon {
    left: auto;
    right: 0;
}

.driver-pulse-marker {
    --driver-heading: 0deg;
    width: 20px;
    height: 20px;
    background-color: #4285F4;
    border: 2px solid white;
    border-radius: 50%;
    position: relative;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
    cursor: pointer;
}

.driver-pulse-marker .driver-heading-cone {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 34px;
    height: 34px;
    transform: translate(-50%, -50%) rotate(var(--driver-heading, 0deg));
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    background: conic-gradient(from -30deg at 50% 50%, rgba(66, 133, 244, 0.48) 0deg, rgba(66, 133, 244, 0.08) 60deg, transparent 61deg);
    border-radius: 50%;
    z-index: -1;
}

.driver-pulse-marker.has-heading .driver-heading-cone {
    opacity: 1;
}

.driver-pulse-marker::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1);
    width: 20px;
    height: 20px;
    background-color: rgba(66, 133, 244, 0.4);
    border-radius: 50%;
    animation: pulse-animation 2s infinite ease-out;
    will-change: transform, opacity;
    z-index: -1;
}

@keyframes pulse-animation {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.8;
    }
    100% {
        transform: translate(-50%, -50%) scale(2.5);
        opacity: 0;
    }
}


.gm-style .gm-style-iw-c {
    padding: 12px !important;
    border-radius: 14px !important;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.18) !important;
    z-index: 40;
}

.gm-style .gm-style-iw-ch {
    display: none !important;
}

.gm-style .gm-style-iw-d {
    overflow: hidden !important;
    max-height: none !important;
}

.googlemap-iw-wrapper.googlemap-iw-enter {
    animation: googlemapIwFadeIn 0.22s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    animation-timing-function: linear(0, 0.45 25%, 0.82 55%, 0.96 80%, 1);
    will-change: transform, opacity;
}

@keyframes googlemapIwFadeIn {
    0% {
        opacity: 0;
        transform: translateY(8px) scale(0.97);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.googlemap-iw-close {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1px solid #e2e8f0;
    background-color: #f8fafc;
    color: #64748b;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.googlemap-iw-close:hover {
    background-color: #f1f5f9;
    color: #0f172a;
    transform: scale(1.06);
}

@media (prefers-reduced-motion: reduce) {
    .googlemap-iw-wrapper.googlemap-iw-enter,
    .driver-pulse-marker .driver-heading-cone {
        animation: none !important;
        transition: none !important;
    }
}

@keyframes jump-shaking {
    0% {
        transform: translateX(0) translateY(0) scale(1);
    }
    25% {
        transform: translateY(-5px) scale(1.1);
    }
    35% {
        transform: translateY(-5px) rotate(5deg) scale(1.1);
    }
    55% {
        transform: translateY(-5px) rotate(-5deg) scale(1.1);
    }
    65% {
        transform: translateY(-5px) rotate(5deg) scale(1.1);
    }
    75% {
        transform: translateY(-5px) rotate(-5deg) scale(1.1);
    }
    100% {
        transform: translateY(0) rotate(0) scale(1);
    }
}

.marker-active-bounce {
    animation: jump-shaking 0.8s infinite;
    will-change: transform;
    z-index: 1000 !important;
    filter: drop-shadow(0 0 10px rgba(16, 185, 129, 0.8));
}

.custom-marker, .driver-pulse-marker {
    transition: transform 0.2s ease-in-out;
}

#googlemap {
    contain: layout style;
}

.googlemap-cluster-marker {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #405189 0%, #0ab39c 100%);
    border: 2.5px solid #ffffff;
    color: #ffffff;
    font-weight: 700;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.28);
    cursor: pointer;
    transition: transform 0.2s ease-in-out;
    -webkit-user-select: none;
    user-select: none;
}

.googlemap-cluster-marker:hover {
    will-change: transform;
    transform: scale(1.12);
}

.fade-in-animation {
    animation: fadeInRow 0.3s ease-in-out;
}

@keyframes fadeInRow {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.choices__list.choices__list--dropdown {
    z-index: 1050 !important;
    word-break: break-word;
}

thead.sticky-top {
    z-index: 1040 !important;
}

.choices[data-type*=select-multiple] .choices__button, .choices[data-type*=text] .choices__button {
    position: relative;
    display: inline-block;
    margin: 0 -4px 0 8px;
    padding-left: 16px;
    border-left: 1px solid #003642;
    background-image: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjEiIGhlaWdodD0iMjEiIHZpZXdCb3g9IjAgMCAyMSAyMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyBmaWxsPSIjRkZGIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yLjU5Mi4wNDRsMTguMzY0IDE4LjM2NC0yLjU0OCAyLjU0OEwuMDQ0IDIuNTkyeiIvPjxwYXRoIGQ9Ik0wIDE4LjM2NEwxOC4zNjQgMGwyLjU0OCAyLjU0OEwyLjU0OCAyMC45MTJ6Ii8+PC9nPjwvc3ZnPg==);
    background-size: 8px;
    width: 8px;
    line-height: 1;
    opacity: .75;
    border-radius: 0
}

.choices__list--multiple .choices__item {
    display: inline-block;
    vertical-align: middle;
    border-radius: 20px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    margin-right: 3.75px;
    margin-bottom: 3.75px;
    background-color: #005f75;
    border: 1px solid #004a5c;
    color: #fff;
    word-break: break-all;
    box-sizing: border-box
}

.choices__list--multiple .choices__item[data-deletable] {
    padding-right: 5px
}

.choices__list--dropdown .choices__item--selectable.is-highlighted::after, .choices__list[aria-expanded] .choices__item--selectable.is-highlighted::after {
    opacity: .5
}

.choices__item {
    cursor: default
}

.choices__item--selectable {
    cursor: pointer
}

.choices__item--disabled {
    cursor: not-allowed;
    -webkit-user-select: none;
    user-select: none;
    opacity: .5
}

.choices__heading {
    font-weight: 600;
    font-size: 12px;
    padding: 10px;
    border-bottom: 1px solid #f7f7f7;
    color: gray
}

.choices__button {
    text-indent: -9999px;
    appearance: none;
    border: 0;
    background-color: transparent;
    background-repeat: no-repeat;
    background-position: center;
    cursor: pointer
}

.choices__button:focus, .choices__input:focus {
    outline: 0
}

.choices__input {
    display: inline-block;
    vertical-align: baseline;
    background-color: #f9f9f9;
    font-size: 14px;
    margin-bottom: 5px;
    border: 0;
    border-radius: 0;
    max-width: 100%;
    padding: 4px 0 4px 2px
}

.choices__input::-webkit-search-cancel-button, .choices__input::-webkit-search-decoration, .choices__input::-webkit-search-results-button, .choices__input::-webkit-search-results-decoration {
    display: none
}

div.dt-button-collection div[role="menu"] {
    max-height: 30vh !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

#datatable-skeleton-container {
    width: 100%;
    background: #fff;
    z-index: 5;
}

.stimulus-controller-datatable.opacity-100 {
    position: relative;
    z-index: 10;
}

.dtfc-fixed-right{
    position: sticky !important;
    right: 0;
    z-index: 5;
    background: inherit;
}

.dtfc-fixed-right::before{
    content: "";
    position: absolute;
    top: 0;
    height: 100%;
    width: 2px;
    background: inherit;
}

.dataTable tbody td{
    background-clip: padding-box;
}

/* Corrección para NovaShip: Permitir que dropdowns escapen de columnas fijas */
.dataTables_scrollBody,
.dataTables_scrollBody table,
.dtfc-fixed-right,
.dtfc-fixed-left {
    /* Permitir visibilidad de elementos posicionados fuera del contenedor */
    overflow: visible !important;
}

/* Forzar que el menú de Bootstrap esté siempre por encima de las capas de DataTables */
.dropdown-menu.show {
    z-index: 2500 !important;
}

/* Estilo para que el dropdown no se vea transparente sobre la fila seleccionada */
.dropdown-menu {
    background-color: #ffffff !important;
    border: 1px solid rgba(0,0,0,.1);
}

div.dt-scroll {
  position: static!important;
}

#btn-allways-show:not(:empty),
#btn-one-row:not(:empty),
#btn-multiple-rows:not(:empty) {
    padding: 0.5rem 0.8rem 0.8rem 1rem;
    align-items: center;
    gap: 0.25rem;
    min-height: 44px;
    border-top-left-radius: 0.25rem;
    border-top-right-radius: 0.25rem;
    border-bottom: none;
    margin-bottom: 0;
}

#btn-allways-show:not(:empty) {
    border-top-right-radius: 0;
}

#btn-one-row:not(:empty),
#btn-multiple-rows:not(:empty) {
    border-left: none;
    border-top-left-radius: 0;
}

.custom-calendar-wrapper .flatpickr-current-month {
    left: 145px !important;
    width: calc(100% - 110px) !important;
}
.custom-calendar-wrapper .flatpickr-prev-month {
    left: 85px !important;
}

/* ==============================================================
   SISTEMA DE DISEÑO DE IA ENTERPRISE (TOKENS --ai-* & SUPERFICIES)
   ============================================================== */
.ai-master-layout {
    /* Paleta Tonal de Superficies (Gemini / Claude / Linear) */
    --ai-surface-sidebar: #f0f4f9;
    --ai-surface-sidebar-card: #ffffff;
    --ai-surface-header: rgba(248, 250, 252, 0.86);
    --ai-surface-canvas: #f8fafc;
    --ai-canvas-atmosphere:
        radial-gradient(circle at 20% 18%, rgba(79, 70, 229, 0.045) 0%, transparent 48%),
        radial-gradient(circle at 80% 25%, rgba(14, 165, 233, 0.045) 0%, transparent 48%);

    /* Burbujas de Conversación */
    --ai-surface-user-bubble: linear-gradient(135deg, #eef2ff 0%, #f1f5f9 100%);
    --ai-border-user-bubble: rgba(99, 102, 241, 0.18);
    --ai-text-user-bubble: #0f172a;
    --ai-surface-agent-bubble: #ffffff;
    --ai-border-agent-bubble: #e2e8f0;
    --ai-text-agent-bubble: #1e293b;

    /* Gradientes de Identidad IA (Signature AI Accents) */
    --ai-gradient-primary: linear-gradient(135deg, #2563eb 0%, #4f46e5 50%, #7c3aed 100%);
    --ai-gradient-accent: linear-gradient(135deg, #0ea5e9 0%, #4f46e5 55%, #7c3aed 100%);
    --ai-accent-indigo: #4f46e5;
    --ai-accent-violet: #7c3aed;
    --ai-accent-cyan: #0ea5e9;

    /* Composer Halo & Estados */
    --ai-composer-border: #e2e8f0;
    --ai-composer-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.05), 0 2px 6px -1px rgba(15, 23, 42, 0.03);
    --ai-composer-glow: 0 0 0 3px rgba(79, 70, 229, 0.14), 0 10px 30px -5px rgba(79, 70, 229, 0.08);
    --ai-composer-thinking-glow: 0 0 0 3px rgba(124, 58, 237, 0.18), 0 12px 32px -4px rgba(14, 165, 233, 0.12);

    /* Semántica de Razonamiento y Sistemas Externos */
    --ai-thinking-bg: linear-gradient(135deg, #f5f3ff 0%, #f8fafc 100%);
    --ai-thinking-border: rgba(124, 58, 237, 0.22);
    --ai-thinking-done: #10b981;
    --ai-bridge-bg: linear-gradient(135deg, rgba(13, 148, 136, 0.12) 0%, rgba(79, 70, 229, 0.12) 100%);
    --ai-bridge-text: #0f766e;
    --ai-bridge-border: rgba(13, 148, 136, 0.28);

    /* Código, Tablas y Tarjetas de Error */
    --ai-code-bg: #0f172a;
    --ai-code-header: #1e293b;
    --ai-code-text: #f8fafc;
    --ai-table-header: #f8fafc;
    --ai-table-border: #e2e8f0;
    --ai-table-hover: #f1f5f9;
    --ai-error-bg: linear-gradient(135deg, #fff1f2 0%, #fffbeb 100%);
    --ai-error-border: rgba(244, 63, 94, 0.28);
    --ai-error-text: #881337;

    height: 100vh;
    height: 100dvh !important;
    background-color: var(--ai-surface-canvas);
    background-image: var(--ai-canvas-atmosphere);
    position: relative;
    color: #0f172a;
}

.ai-master-layout > main {
    min-width: 0;
    min-height: 0;
    width: 100%;
    height: 100%;
    background: transparent;
}

#chat-conversation {
    --ai-conv-h: var(--ai-conversation-height, calc(100dvh - 190px));
    min-height: var(--ai-conv-h) !important;
    height: var(--ai-conv-h) !important;
    max-height: var(--ai-conv-h) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
}

#chat-conversation .simplebar-content-wrapper {
    scroll-behavior: smooth;
    overflow-x: hidden !important;
}

.sidebar-history {
    flex: 1 1 0% !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

.tabular-nums {
    font-variant-numeric: tabular-nums;
}

/* ==============================================================
   1. SIDEBAR TONAL & NAVEGACIÓN DE SESIONES
   ============================================================== */
.ai-sidebar {
    width: 320px;
    background-color: var(--ai-surface-sidebar);
    border-right: 1px solid #e2e8f0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1050;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-sidebar.sidebar-open {
    transform: translateX(0);
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(15, 23, 42, 0.42);
    backdrop-filter: blur(3px);
    z-index: 1040;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.sidebar-overlay.overlay-open {
    opacity: 1;
    visibility: visible;
}

@media (min-width: 768px) {
    .ai-sidebar {
        position: static;
        transform: translateX(0);
        z-index: 2;
    }

    .sidebar-overlay {
        display: none !important;
    }
}

.ai-avatar-badge {
    width: 44px;
    height: 44px;
    border-radius: 13px;
    background: var(--ai-gradient-primary);
    color: #ffffff !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 16px -3px rgba(79, 70, 229, 0.35);
    flex-shrink: 0;
}

.ai-avatar-sm {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--ai-gradient-primary);
    color: #ffffff !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px -2px rgba(79, 70, 229, 0.3);
    flex-shrink: 0;
}

.ai-avatar-badge svg,
.ai-avatar-sm svg,
.ai-sparkle-svg {
    color: #ffffff !important;
    fill: currentColor !important;
    display: block;
    flex-shrink: 0;
}

.ai-enterprise-badge {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    padding: 0.22rem 0.55rem;
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.12) 0%, rgba(124, 58, 237, 0.14) 100%);
    color: var(--ai-accent-indigo);
    border: 1px solid rgba(79, 70, 229, 0.2);
}

.ai-new-chat-btn {
    background: var(--ai-gradient-primary);
    color: #ffffff !important;
    border: none;
    border-radius: 12px;
    padding: 0.62rem 1rem;
    font-weight: 600;
    font-size: 0.84rem;
    letter-spacing: 0.01em;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.26);
    transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.ai-new-chat-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.36);
    filter: brightness(1.05);
}

.ai-new-chat-btn:active:not(:disabled) {
    transform: translateY(0);
}

.ai-kbd-hint {
    font-size: 0.65rem;
    padding: 0.1rem 0.4rem;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    font-weight: 500;
}

.ai-sessions-scroll {
    max-height: 240px;
}

.ai-master-layout .ai-session-item {
    border-radius: 10px;
    transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease;
    border: 1px solid transparent;
    color: #334155;
}

.ai-master-layout .ai-session-item:hover {
    background-color: rgba(255, 255, 255, 0.78);
    border-color: #dbe3ef;
    color: #0f172a;
}

.ai-master-layout .ai-session-item.active {
    background-color: #ffffff;
    border-color: rgba(79, 70, 229, 0.24);
    color: #000000;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
}

.ai-master-layout .ai-session-delete {
    opacity: 0;
    transition: opacity 0.15s ease, color 0.15s ease;
    color: #94a3b8;
}

.ai-master-layout .ai-session-item:hover .ai-session-delete,
.ai-master-layout .ai-session-item:focus-within .ai-session-delete {
    opacity: 1;
}

.ai-master-layout .ai-session-delete:hover {
    color: #ef4444;
}

.sidebar-menu-btn {
    color: #475569;
    transition: background-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
    border-radius: 10px;
    font-size: 0.85rem;
}

.sidebar-menu-btn:hover {
    background-color: rgba(255, 255, 255, 0.85) !important;
    color: #0f172a;
    transform: translateX(2px);
}

.ai-sidebar-icon-box {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-profile-card {
    background-color: rgba(255, 255, 255, 0.75);
    border: 1px solid #dbe3ef;
    border-radius: 12px;
}

.ai-profile-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--ai-gradient-primary);
    color: #ffffff;
    font-weight: 700;
    font-size: 0.82rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ==============================================================
   2. HEADER SUPERIOR GLASSMORPHISM & ESTADO MERCURE
   ============================================================== */
.ai-header {
    background-color: var(--ai-surface-header);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(226, 232, 240, 0.85);
    z-index: 10;
}

.ai-mercure-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    cursor: default;
}

.ai-mercure-badge.is-connected {
    background-color: rgba(16, 185, 129, 0.1);
    color: #047857;
    border-color: rgba(16, 185, 129, 0.24);
}

.ai-mercure-badge.is-reconnecting {
    background-color: rgba(245, 158, 11, 0.12);
    color: #b45309;
    border-color: rgba(245, 158, 11, 0.28);
}

.ai-mercure-badge.is-disconnected {
    background-color: rgba(244, 63, 94, 0.12);
    color: #be123c;
    border-color: rgba(244, 63, 94, 0.28);
    cursor: pointer;
}

.ai-mercure-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: currentColor;
    display: inline-block;
}

.ai-mercure-badge.is-reconnecting .ai-mercure-dot {
    animation: aiPulseDot 1.2s infinite ease-in-out;
}

@keyframes aiPulseDot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.35; transform: scale(0.8); }
}

.ai-telemetry-pill {
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    padding: 0.28rem 0.75rem;
    font-size: 0.73rem;
    color: #475569;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

/* ==============================================================
   3. EMPTY STATE HERO & TARJETAS DE SUGERENCIA
   ============================================================== */
.ai-empty-hero {
    max-width: 760px;
    margin: 0 auto;
    padding: 1.5rem 1rem 0.5rem;
    text-align: center;
}

.ai-gradient-text {
    background: var(--ai-gradient-accent);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 700;
}

.ai-suggestions-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.ai-suggestion-pill,
.ai-master-layout .suggestion-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    width: fit-content;
    padding: 0.42rem 0.85rem;
    border-radius: 10px;
    background-color: #f1f5f9;
    border: 1px solid transparent;
    box-shadow: none;
    color: #334155;
    font-size: 0.84rem;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    transition: background-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.ai-suggestion-pill i,
.ai-master-layout .suggestion-pill i {
    font-size: 0.95rem;
    color: #475569;
    transition: color 0.16s ease;
}

.ai-suggestion-pill:hover:not(:disabled),
.ai-suggestion-pill:focus-visible:not(:disabled),
.ai-master-layout .suggestion-pill:hover:not(:disabled),
.ai-master-layout .suggestion-pill:focus-visible:not(:disabled) {
    background-color: #e2e8f0;
    color: #0f172a;
    transform: translateY(-1px);
}

.ai-suggestion-pill:hover:not(:disabled) i,
.ai-suggestion-pill:focus-visible:not(:disabled) i,
.ai-master-layout .suggestion-pill:hover:not(:disabled) i,
.ai-master-layout .suggestion-pill:focus-visible:not(:disabled) i {
    color: #0f172a;
}

[data-bs-theme="dark"] .ai-suggestion-pill,
[data-bs-theme="dark"] .ai-master-layout .suggestion-pill {
    background-color: rgb(129 129 129 / 6%);
    color: #888a99;
}

[data-bs-theme="dark"] .ai-suggestion-pill i,
[data-bs-theme="dark"] .ai-master-layout .suggestion-pill i {
    color: #94a3b8;
}

[data-bs-theme="dark"] .ai-suggestion-pill:hover:not(:disabled),
[data-bs-theme="dark"] .ai-suggestion-pill:focus-visible:not(:disabled),
[data-bs-theme="dark"] .ai-master-layout .suggestion-pill:hover:not(:disabled),
[data-bs-theme="dark"] .ai-master-layout .suggestion-pill:focus-visible:not(:disabled) {
    background-color: rgb(129 129 129 / 6%);
    color: #888a99;
}

/* ==============================================================
   4. BURBUJAS DE CONVERSACIÓN (USUARIO & AGENTE)
   ============================================================== */
.ai-conversation-stream {
    max-width: 880px;
    margin: 0 auto;
    width: 100%;
}

#chat-conversation > .ai-conversation-stream {
    padding-bottom: 3rem !important;
}

.message-row {
    display: flex;
    gap: 0.85rem;
    width: 100%;
    max-width: 100%;
}

.message-row.user {
    flex-direction: row-reverse;
}

.message-row.ai {
    flex-direction: row;
}

.user-bubble {
    background: var(--ai-surface-user-bubble);
    color: var(--ai-text-user-bubble);
    border: 1px solid var(--ai-border-user-bubble);
    border-radius: 20px 20px 4px 20px;
    padding: 0.85rem 1.15rem;
    max-width: min(82%, 680px);
    font-size: 0.94rem;
    line-height: 1.6;
    box-shadow: 0 2px 8px -2px rgba(79, 70, 229, 0.08);
    word-break: break-word;
}

.ai-bubble {
    background-color: var(--ai-surface-agent-bubble);
    color: var(--ai-text-agent-bubble);
    border: 1px solid var(--ai-border-agent-bubble);
    border-radius: 4px 20px 20px 20px;
    padding: 1.05rem 1.3rem;
    width: 100%;
    font-size: 0.94rem;
    line-height: 1.65;
    box-shadow: 0 4px 14px -3px rgba(15, 23, 42, 0.04), 0 2px 4px -2px rgba(15, 23, 42, 0.02);
    overflow-x: auto;
}

.ai-user-attachment-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.65rem;
    border-radius: 8px;
    font-size: 0.74rem;
    font-weight: 600;
    background-color: rgba(255, 255, 255, 0.85);
    color: #047857;
    border: 1px solid rgba(16, 185, 129, 0.25);
}

/* ==============================================================
   5. TIMELINE DE RAZONAMIENTO ("PROCESO DE ANÁLISIS" & BRIDGE)
   ============================================================== */
.ai-thinking-card {
    width: fit-content;
    max-width: min(100%, 680px);
    box-sizing: border-box;
    overflow: hidden;
    background: var(--ai-thinking-bg);
    border: 1px solid var(--ai-thinking-border);
    border-left: 3px solid var(--ai-accent-violet);
    border-radius: 12px;
    padding: 0.55rem 0.95rem;
    margin-bottom: 0.55rem;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.ai-thinking-card[open]:not(.is-compact) {
    width: min(100%, 680px);
}

.ai-thinking-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.ai-thinking-summary > div:first-child,
.ai-thinking-summary-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1 1 0%;
    min-width: 0;
    overflow: hidden;
}

.ai-thinking-card[open]:not(.is-compact) [data-components--ai--chat-target="loadingText"],
.ai-thinking-card[open]:not(.is-compact) .ai-thinking-status-dot,
.ai-thinking-card[open]:not(.is-compact) .ai-thinking-status-text {
    display: none !important;
}

.ai-thinking-card.is-compact summary {
    cursor: default;
}

.ai-thinking-card.is-running {
    border-left-color: var(--ai-accent-indigo);
    box-shadow: 0 4px 16px -4px rgba(79, 70, 229, 0.14);
    background: linear-gradient(90deg, #f5f3ff 0%, #eef2ff 50%, #f5f3ff 100%);
    background-size: 200% 100%;
    animation: aiThinkingShimmer 2.8s infinite linear;
}

.ai-thinking-card.is-completed {
    border-left-color: var(--ai-thinking-done);
}

@keyframes aiThinkingShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.ai-thinking-card summary,
.ai-master-layout .ai-reasoning-trace summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
}

.ai-thinking-card summary::-webkit-details-marker,
.ai-master-layout .ai-reasoning-trace summary::-webkit-details-marker {
    display: none;
}

.ai-thinking-chevron {
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.ai-thinking-card[open] .ai-thinking-chevron {
    transform: rotate(180deg);
}

.ai-thinking-steps,
.ai-thinking-steps > ul {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box;
}

.ai-thinking-steps {
    margin-top: 0.55rem;
    padding-top: 0.55rem;
    border-top: 1px solid rgba(124, 58, 237, 0.14);
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.ai-step-item {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    align-items: center;
    column-gap: 0.75rem;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box;
    font-size: 0.78rem;
    color: #334155;
    padding: 0.25rem 0.4rem;
    border-radius: 6px;
}

.ai-step-item > div:first-child,
.ai-step-left {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    min-width: 0 !important;
    max-width: 100% !important;
    overflow: hidden !important;
}

.ai-step-item [data-step-label],
.ai-step-label {
    display: block !important;
    flex: 1 1 0% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

.ai-step-item > div:last-child,
.ai-step-right {
    display: inline-flex !important;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    flex-shrink: 0 !important;
    white-space: nowrap !important;
    padding-right: 0.2rem;
}

.ai-step-duration {
    font-size: 0.72rem;
    font-weight: 600;
    color: #64748b;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
    min-width: 3.1rem;
    text-align: right;
}

.ai-bridge-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.28rem;
    padding: 0.12rem 0.5rem;
    border-radius: 999px;
    font-size: 0.67rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    background: var(--ai-bridge-bg);
    color: var(--ai-bridge-text);
    border: 1px solid var(--ai-bridge-border);
    flex-shrink: 0;
    white-space: nowrap;
}

/* ==============================================================
   6. TARJETAS DE ERROR INLINE RESILIENTES (.ai-error-card)
   ============================================================== */
.ai-error-card {
    background: var(--ai-error-bg);
    border: 1px solid var(--ai-error-border);
    border-left: 4px solid #f43f5e;
    border-radius: 14px;
    padding: 0.95rem 1.15rem;
    color: var(--ai-error-text);
    box-shadow: 0 4px 12px rgba(244, 63, 94, 0.06);
}

.ai-error-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background-color: rgba(244, 63, 94, 0.12);
    color: #e11d48;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-error-retry-btn {
    background-color: #ffffff;
    color: #be123c;
    border: 1px solid rgba(244, 63, 94, 0.32);
    border-radius: 8px;
    padding: 0.32rem 0.75rem;
    font-size: 0.76rem;
    font-weight: 600;
    transition: all 0.18s ease;
}

.ai-error-retry-btn:hover {
    background-color: #ffe4e6;
    border-color: #f43f5e;
    color: #9f1239;
}

/* ==============================================================
   7. MARKDOWN EDITORIAL: TABLAS, CÓDIGO Y TARJETAS DE DESCARGA CSV
   ============================================================== */
.markdown-content {
    line-height: 1.65;
    color: #1e293b;
}

.markdown-content p:last-child {
    margin-bottom: 0;
}

.markdown-content ul,
.markdown-content ol {
    padding-left: 1.4rem;
    margin-bottom: 0.9rem;
}

.markdown-content img {
    max-width: 100%;
    max-height: 180px;
    object-fit: contain;
    border-radius: 10px;
    margin: 0.75rem 0;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
    display: block;
}

.markdown-content code {
    background-color: #f1f5f9;
    color: #4f46e5;
    padding: 0.18rem 0.42rem;
    border-radius: 5px;
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.84em;
}

.markdown-content pre {
    background-color: var(--ai-code-bg);
    color: var(--ai-code-text);
    padding: 1rem;
    border-radius: 10px;
    overflow-x: auto;
    margin: 0.9rem 0;
}

.markdown-content pre code {
    background-color: transparent;
    color: inherit;
    padding: 0;
}

.ai-code-block {
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #1e293b;
    margin: 0.9rem 0;
    background-color: var(--ai-code-bg);
}

.ai-code-block pre {
    margin: 0;
    border-radius: 0;
    border: none;
}

.ai-code-header {
    background-color: var(--ai-code-header);
    color: #94a3b8;
    padding: 0.42rem 0.85rem;
    font-size: 0.73rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.ai-code-copy-btn {
    background: rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    padding: 0.15rem 0.55rem;
    font-size: 0.7rem;
    font-weight: 500;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.ai-code-copy-btn:hover {
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
}

.ai-table-wrapper {
    margin: 1rem 0;
    border: 1px solid var(--ai-table-border);
    border-radius: 10px;
    overflow: hidden;
    background-color: #ffffff;
}

.ai-table-toolbar {
    background-color: var(--ai-table-header);
    border-bottom: 1px solid var(--ai-table-border);
    padding: 0.4rem 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.72rem;
    color: #64748b;
    font-weight: 600;
}

.ai-table-scroll {
    overflow-x: auto;
    width: 100%;
}

.markdown-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
    font-size: 0.84rem;
    font-variant-numeric: tabular-nums;
}

.markdown-content th,
.markdown-content td {
    padding: 0.65rem 0.9rem;
    border-bottom: 1px solid var(--ai-table-border);
    text-align: left;
}

.markdown-content th {
    background-color: var(--ai-table-header);
    font-weight: 700;
    color: #334155;
    text-transform: uppercase;
    font-size: 0.71rem;
    letter-spacing: 0.04em;
}

.markdown-content tbody tr:hover {
    background-color: var(--ai-table-hover);
}

.markdown-content tbody tr:last-child td {
    border-bottom: none;
}

.ai-export-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.85rem;
    padding: 0.75rem 1rem;
    margin: 0.75rem 0;
    border-radius: 12px;
    background: linear-gradient(135deg, #f0fdf4 0%, #f8fafc 100%);
    border: 1px solid rgba(16, 185, 129, 0.28);
    text-decoration: none !important;
    color: #0f172a !important;
    transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.ai-export-card:hover {
    transform: translateY(-1px);
    border-color: #10b981;
    box-shadow: 0 6px 16px -4px rgba(16, 185, 129, 0.18);
}

.ai-export-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background-color: rgba(16, 185, 129, 0.14);
    color: #059669;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.ai-export-action {
    background-color: #059669;
    color: #ffffff;
    font-size: 0.74rem;
    font-weight: 600;
    padding: 0.35rem 0.75rem;
    border-radius: 8px;
    white-space: nowrap;
}

.ai-master-layout .ai-action-toolbar {
    opacity: 0.85;
    transition: opacity 0.18s ease;
}

.ai-master-layout .message-row:hover .ai-action-toolbar {
    opacity: 1;
}

.ai-master-layout .ai-toolbar-btn {
    font-size: 0.73rem;
    padding: 0.22rem 0.58rem;
    border-radius: 7px;
    color: #64748b;
    background: transparent;
    border: 1px solid transparent;
    transition: all 0.15s ease;
}

.ai-master-layout .ai-toolbar-btn:hover {
    color: #0f172a;
    background-color: #f1f5f9;
    border-color: #e2e8f0;
}

/* ==============================================================
   8. COMPOSER CON HALO REACTIVO, CHIP DE ARCHIVO & BOTÓN STOP
   ============================================================== */
.chat-footer {
    background: linear-gradient(180deg, rgba(248, 250, 252, 0) 0%, rgba(248, 250, 252, 0.94) 24%, #f8fafc 100%);
    padding-bottom: max(1.1rem, env(safe-area-inset-bottom));
    position: relative;
}

.ai-scroll-bottom-btn {
    position: absolute;
    top: -42px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #ffffff;
    color: #334155;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    padding: 0.32rem 0.85rem;
    font-size: 0.75rem;
    font-weight: 600;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.1);
    z-index: 20;
    transition: all 0.18s ease;
}

.ai-scroll-bottom-btn:hover {
    color: var(--ai-accent-indigo);
    border-color: var(--ai-accent-indigo);
    transform: translate(-50%, -2px);
}

.ai-file-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    background-color: #ffffff;
    border: 1px solid rgba(16, 185, 129, 0.32);
    border-radius: 12px;
    padding: 0.4rem 0.75rem;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.08);
}

.ai-file-chip-icon {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    background-color: rgba(16, 185, 129, 0.12);
    color: #059669;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.chat-input-box {
    background-color: #ffffff;
    border: 1px solid var(--ai-composer-border);
    border-radius: 24px;
    min-height: 56px;
    box-shadow: var(--ai-composer-shadow);
    transition: border-color 0.22s ease, box-shadow 0.22s ease, background-color 0.22s ease;
    align-items: flex-end !important;
}

.chat-input-box:focus-within {
    border-color: rgba(79, 70, 229, 0.45);
    box-shadow: var(--ai-composer-glow);
}

.chat-input-box.is-processing {
    border-color: rgba(124, 58, 237, 0.38);
    box-shadow: var(--ai-composer-thinking-glow);
}

.chat-textarea {
    resize: none;
    overflow-y: auto;
    min-height: 24px;
    max-height: 150px;
    line-height: 1.5;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    font-size: 0.95rem !important;
    color: #0f172a;
}

.chat-textarea::-webkit-scrollbar {
    width: 0;
    background: transparent;
}

.chat-input-box .form-control,
.chat-input-box .form-control:focus,
.chat-input-box .form-control:active,
.chat-input-box .form-control:focus-visible {
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
    background: transparent !important;
}

.chat-input-box .form-control:disabled {
    background-color: transparent !important;
    opacity: 0.65;
    cursor: not-allowed;
}

.ai-composer-tool-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    color: #64748b;
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.16s ease;
    flex-shrink: 0;
}

.ai-composer-tool-btn:hover:not(:disabled) {
    color: var(--ai-accent-indigo);
    border-color: rgba(79, 70, 229, 0.3);
    background-color: #eef2ff;
}

.ai-voice-btn {
    position: relative;
    z-index: 1;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    color: #64748b;
    background-color: #f8fafc;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease, color 0.16s ease, border-color 0.16s ease;
    flex-shrink: 0;
}

.ai-voice-btn:hover:not(:disabled) {
    color: var(--ai-accent-indigo);
    border-color: rgba(79, 70, 229, 0.3);
    background-color: #eef2ff;
}

.ai-voice-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.ai-voice-btn.is-listening {
    background: linear-gradient(135deg, #e11d48 0%, #be123c 100%) !important;
    color: #ffffff !important;
    border-color: transparent !important;
    box-shadow: 0 0 12px rgba(225, 29, 72, 0.45) !important;
}

.ai-voice-btn.is-listening i {
    color: #ffffff !important;
    animation: aiVoiceIconBeat 0.9s infinite ease-in-out !important;
}

.ai-voice-btn.is-listening::before,
.ai-voice-btn.is-listening::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 50%;
    border: 2px solid #f43f5e;
    opacity: 0;
    pointer-events: none;
    z-index: -1;
    animation: aiVoiceRadarWave 1.8s infinite cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.ai-voice-btn.is-listening::after {
    animation-delay: 0.9s !important;
}

.chat-input-box.is-listening {
    border-color: rgba(225, 29, 72, 0.45);
    box-shadow: 0 0 0 4px rgba(225, 29, 72, 0.1), var(--ai-composer-shadow);
}

@keyframes aiVoiceRadarWave {
    0% {
        transform: scale(0.95);
        opacity: 0.85;
    }
    100% {
        transform: scale(1.65);
        opacity: 0;
    }
}

@keyframes aiVoiceIconBeat {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.18); }
}

.ai-master-layout .ai-toolbar-btn.is-speaking {
    color: #e11d48;
    background-color: #fff1f2;
    border-color: #fecdd3;
    font-weight: 600;
}

.ai-master-layout .ai-action-toolbar:has(.ai-toolbar-btn.is-speaking) {
    opacity: 1;
}

.ai-submit-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--ai-gradient-primary);
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.28);
    transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
    flex-shrink: 0;
}

.ai-submit-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.38);
}

.ai-submit-btn.is-stop-mode {
    background: linear-gradient(135deg, #e11d48 0%, #be123c 100%);
    box-shadow: 0 4px 14px rgba(225, 29, 72, 0.3);
}

.ai-char-counter {
    font-size: 0.68rem;
    color: #94a3b8;
    font-variant-numeric: tabular-nums;
    user-select: none;
}

.ai-char-counter.is-near-limit {
    color: #d97706;
    font-weight: 600;
}

.ai-composer-footnote {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    white-space: nowrap;
    font-size: 0.74rem;
    color: #64748b;
}

.ai-composer-footnote small {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-composer-footnote kbd {
    background-color: #f8fafc;
    color: #475569;
    border: 1px solid #cbd5e1;
    padding: 0.08rem 0.38rem;
    border-radius: 5px;
    font-size: 0.68rem;
    font-weight: 600;
}

.ai-master-layout .ai-dropzone-overlay {
    background: rgba(15, 23, 42, 0.58);
    backdrop-filter: blur(6px);
    z-index: 1050;
    transition: opacity 0.2s ease;
}

.ai-dropzone-card {
    background: #ffffff;
    border: 2px dashed var(--ai-accent-indigo);
    border-radius: 20px;
    padding: 2.25rem 2.75rem;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.2);
}

.spin-animation {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    100% { transform: rotate(360deg); }
}

.animate__fadeIn {
    animation: fadeIn 0.24s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .ai-thinking-card.is-running,
    .ai-mercure-badge.is-reconnecting .ai-mercure-dot,
    .ai-voice-btn.is-listening,
    .ai-voice-btn.is-listening i,
    .ai-voice-btn.is-listening::before,
    .ai-voice-btn.is-listening::after,
    .animate__fadeIn {
        animation: none !important;
    }

    .ai-voice-btn.is-listening {
        box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.28) !important;
    }
}

@supports (-webkit-touch-callout: none) {
    .ai-master-layout {
        position: fixed;
        inset: 0;
        height: 100% !important;
    }

    .chat-footer {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
}