/**
 * Identidad Visual Oficial de Inteligencia Artificial Contable
 * Paleta estricta en tonos morados/violetas y animaciones fluidas.
 * File: css/ai/ai-theme.css
 */

:root {
    --ai-purple-primary: #7C3AED;
    --ai-purple-dark: #6D28D9;
    --ai-purple-light: #8B5CF6;
    --ai-purple-soft: #EDE9FE;
    --ai-purple-border: #DDD6FE;
    --ai-gradient: linear-gradient(135deg, #7C3AED, #4F46E5);
    --ai-gradient-hover: linear-gradient(135deg, #6D28D9, #4338CA);
}

/* Botón Principal Morado de IA */
.btn-ai-purple {
    background: var(--ai-gradient);
    color: #ffffff !important;
    border: 1px solid #6D28D9;
    box-shadow: 0 3px 10px rgba(124, 58, 237, 0.28);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.22s ease;
    cursor: pointer;
    border-radius: 8px;
}

.btn-ai-purple:hover:not(:disabled) {
    background: var(--ai-gradient-hover);
    box-shadow: 0 5px 15px rgba(124, 58, 237, 0.42);
    transform: translateY(-1px);
    color: #ffffff !important;
}

.btn-ai-purple:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

.btn-ai-outline {
    background: var(--ai-purple-soft);
    color: var(--ai-purple-dark) !important;
    border: 1px solid #C4B5FD;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    cursor: pointer;
    border-radius: 8px;
}

.btn-ai-outline:hover:not(:disabled) {
    background: #DDD6FE;
    border-color: var(--ai-purple-primary);
}

/* Chip / Badge de Saldo de Tokens IA en la Barra Superior */
.ai-token-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #F5F3FF, #EDE9FE);
    color: #5B21B6;
    border: 1px solid #C4B5FD;
    border-radius: 9999px;
    padding: 5px 12px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(124, 58, 237, 0.12);
}

.ai-token-chip:hover {
    background: linear-gradient(135deg, #EDE9FE, #DDD6FE);
    border-color: var(--ai-purple-primary);
    box-shadow: 0 4px 10px rgba(124, 58, 237, 0.22);
    transform: translateY(-1px);
}

.ai-token-chip.is-low {
    background: linear-gradient(135deg, #FEF2F2, #FDE8E8);
    color: #B91C1C;
    border-color: #FCA5A5;
}

.ai-token-chip .ai-sparkle-icon {
    color: var(--ai-purple-primary);
    font-size: 0.9rem;
}

/* Animación Pulse para Icono de Destellos ✨ */
@keyframes aiSparklePulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.22) rotate(8deg);
        opacity: 0.72;
    }
}

.ai-sparkle-pulse {
    display: inline-block;
    animation: aiSparklePulse 1.3s ease-in-out infinite;
}

/* Efecto Shimmer Morado sobre filas del asiento mientras IA procesa */
@keyframes aiPurpleShimmer {
    0% {
        background-position: -600px 0;
    }
    100% {
        background-position: 600px 0;
    }
}

.ai-shimmer-active tr,
.ai-shimmer-row {
    position: relative;
    background: linear-gradient(
        90deg,
        rgba(237, 233, 254, 0.35) 0%,
        rgba(196, 181, 253, 0.55) 50%,
        rgba(237, 233, 254, 0.35) 100%
    ) !important;
    background-size: 1200px 100% !important;
    animation: aiPurpleShimmer 1.4s infinite linear !important;
}

.ai-shimmer-active input,
.ai-shimmer-active select {
    background-color: rgba(255, 255, 255, 0.75) !important;
    border-color: #C4B5FD !important;
}

/* Barra de Estado Dinámico durante Procesamiento IA */
.ai-processing-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: linear-gradient(135deg, #F5F3FF, #EDE9FE);
    border: 1px solid #C4B5FD;
    border-left: 4px solid var(--ai-purple-primary);
    border-radius: 10px;
    padding: 10px 16px;
    margin: 10px 24px 0 24px;
    color: #4C1D95;
    font-size: 0.86rem;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.12);
}

/* Barra de Revisión de Sugerencia IA */
.ai-review-banner {
    background: linear-gradient(135deg, #FAF5FF, #EDE9FE);
    border: 1px solid #C4B5FD;
    border-left: 4px solid var(--ai-purple-primary);
    border-radius: 12px;
    padding: 12px 16px;
    margin: 12px 24px 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.1);
}

.ai-confidence-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--ai-gradient);
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 9999px;
    white-space: nowrap;
}

.ai-reasoning-text {
    font-size: 0.83rem;
    color: #3B0764;
    line-height: 1.4;
    flex: 1;
    min-width: 240px;
}

/* Botón IA por Renglón en Tabla de Asientos */
.btn-row-action.ai-row-action {
    color: var(--ai-purple-primary);
    background: var(--ai-purple-soft);
    border: 1px solid #DDD6FE;
    border-radius: 6px;
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-right: 4px;
}

.btn-row-action.ai-row-action:hover {
    background: var(--ai-purple-primary);
    color: #ffffff;
    border-color: var(--ai-purple-dark);
}

/* Modal Morado de Billetera IA y Paquetes */
.ai-wallet-header {
    background: var(--ai-gradient);
    color: #ffffff;
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ai-wallet-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.ai-wallet-stat-card {
    background: #FAF5FF;
    border: 1px solid #DDD6FE;
    border-radius: 12px;
    padding: 12px 14px;
    text-align: center;
}

.ai-wallet-stat-label {
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6D28D9;
    font-weight: 700;
    display: block;
    margin-bottom: 4px;
}

.ai-wallet-stat-value {
    font-size: 1.25rem;
    font-weight: 800;
    color: #3B0764;
}

.ai-packages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.ai-package-card {
    background: #ffffff;
    border: 2px solid #EDE9FE;
    border-radius: 14px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 10px;
    transition: all 0.22s ease;
}

.ai-package-card:hover {
    border-color: var(--ai-purple-primary);
    box-shadow: 0 6px 18px rgba(124, 58, 237, 0.16);
    transform: translateY(-2px);
}

.ai-package-tokens {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--ai-purple-dark);
}

.ai-package-price {
    font-size: 1.35rem;
    font-weight: 800;
    color: #1E1B4B;
}

@media (max-width: 768px) {
    .ai-wallet-stats {
        grid-template-columns: 1fr;
    }
    .ai-token-chip {
        padding: 4px 9px;
        font-size: 0.74rem;
    }
}

/* =========================================================================
   DIGITALIZADOR MULTIMODAL DE COMPROBANTES (SPLIT-VIEW + ESCÁNER LÁSER)
   ========================================================================= */

.ai-digitizer-card {
    background: #ffffff;
    width: 96vw;
    max-width: 1320px;
    height: 90vh;
    max-height: 880px;
    border-radius: 18px;
    box-shadow: 0 25px 60px rgba(76, 29, 149, 0.35);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ai-digitizer-header {
    background: var(--ai-gradient);
    color: #ffffff;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.ai-split-container {
    display: grid;
    grid-template-columns: 38% 62%;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Panel Izquierdo: Visor y Dropzone Morado */
.ai-viewer-pane {
    background: #1E1B4B;
    border-right: 1px solid #DDD6FE;
    display: flex;
    flex-direction: column;
    min-height: 0;
    position: relative;
}

.ai-viewer-toolbar {
    background: #2E1065;
    padding: 8px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border-bottom: 1px solid rgba(196, 181, 253, 0.25);
    color: #EDE9FE;
    font-size: 0.8rem;
}

.ai-viewer-toolbar .btn-viewer-tool {
    background: rgba(124, 58, 237, 0.35);
    color: #ffffff;
    border: 1px solid rgba(196, 181, 253, 0.4);
    border-radius: 6px;
    padding: 4px 9px;
    font-size: 0.78rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: background 0.2s;
}

.ai-viewer-toolbar .btn-viewer-tool:hover {
    background: rgba(139, 92, 246, 0.75);
}

.ai-viewer-canvas {
    flex: 1;
    position: relative;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.ai-dropzone {
    width: 100%;
    height: 100%;
    min-height: 280px;
    background: #FAF5FF;
    border: 2.5px dashed #8B5CF6;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 28px;
    cursor: pointer;
    transition: all 0.25s ease;
    color: #4C1D95;
}

.ai-dropzone:hover,
.ai-dropzone.is-dragover {
    background: #EDE9FE;
    border-color: #6D28D9;
    box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.16);
}

.ai-dropzone-icon {
    width: 68px;
    height: 68px;
    border-radius: 18px;
    background: var(--ai-gradient);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin-bottom: 14px;
    box-shadow: 0 8px 20px rgba(124, 58, 237, 0.3);
}

.ai-preview-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
    transition: transform 0.2s ease;
}

.ai-preview-pdf {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 8px;
    background: #ffffff;
}

/* Animación de Escaneo Láser Morado */
@keyframes laserScan {
    0% {
        top: 0%;
        opacity: 0.95;
    }
    50% {
        top: calc(100% - 6px);
        opacity: 1;
    }
    100% {
        top: 0%;
        opacity: 0.95;
    }
}

.ai-laser-overlay {
    position: absolute;
    inset: 0;
    background: rgba(30, 27, 75, 0.45);
    backdrop-filter: blur(1.5px);
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: all;
}

.ai-laser-beam {
    position: absolute;
    left: 0;
    right: 0;
    height: 5px;
    background: linear-gradient(90deg, transparent 0%, #8B5CF6 20%, #C4B5FD 50%, #8B5CF6 80%, transparent 100%);
    box-shadow: 0 0 18px 6px rgba(139, 92, 246, 0.85), 0 0 38px 12px rgba(124, 58, 237, 0.55);
    animation: laserScan 2.3s ease-in-out infinite;
    z-index: 21;
}

.ai-laser-status-pill {
    position: relative;
    z-index: 22;
    background: linear-gradient(135deg, rgba(109, 40, 217, 0.95), rgba(79, 70, 229, 0.95));
    border: 1px solid #C4B5FD;
    color: #ffffff;
    padding: 12px 20px;
    border-radius: 9999px;
    font-size: 0.88rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
}

/* Panel Derecho: Datos Extraídos, Auditoría Fiscal y Asiento */
.ai-form-pane {
    background: #ffffff;
    overflow-y: auto;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ai-audit-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.ai-audit-badge {
    border-radius: 10px;
    padding: 8px 11px;
    font-size: 0.78rem;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    border: 1px solid #DDD6FE;
}

.ai-audit-badge.audit-ok {
    background: #FAF5FF;
    border-color: #C4B5FD;
    color: #4C1D95;
}

.ai-audit-badge.audit-warning {
    background: #FFFBEB;
    border-color: #FCD34D;
    color: #92400E;
}

.ai-audit-badge.audit-error {
    background: #FEF2F2;
    border-color: #FCA5A5;
    color: #991B1B;
}

.ai-section-card {
    background: #FAF5FF;
    border: 1px solid #EDE9FE;
    border-radius: 12px;
    padding: 14px 16px;
}

.ai-section-title {
    font-size: 0.78rem;
    font-weight: 800;
    color: #5B21B6;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0 0 10px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ai-meta-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.ai-meta-grid .form-label-sm {
    font-size: 0.74rem;
    font-weight: 700;
    color: #475569;
    margin-bottom: 3px;
    display: block;
}

.ai-tax-strip {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    background: #ffffff;
    border: 1px solid #DDD6FE;
    border-radius: 10px;
    padding: 10px;
}

.ai-tax-item {
    text-align: center;
}

.ai-tax-item span {
    display: block;
    font-size: 0.7rem;
    color: #6D28D9;
    font-weight: 700;
    text-transform: uppercase;
}

.ai-tax-item strong {
    font-size: 0.9rem;
    color: #1E1B4B;
}

.ai-digitizer-footer {
    background: #FAF5FF;
    padding: 14px 24px;
    border-top: 1px solid #DDD6FE;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    gap: 12px;
}

.dig-amt-input {
    font-family: monospace;
    font-weight: 700;
    font-size: 0.82rem !important;
    padding: 5px 7px !important;
    min-width: 118px;
    text-align: right;
    -moz-appearance: textfield;
}

.dig-amt-input::-webkit-outer-spin-button,
.dig-amt-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

@media (max-width: 992px) {
    .ai-split-container {
        grid-template-columns: 1fr;
        grid-template-rows: 260px 1fr;
    }
    .ai-viewer-pane {
        border-right: none;
        border-bottom: 1px solid #DDD6FE;
    }
    .ai-meta-grid {
        grid-template-columns: 1fr 1fr;
    }
    .ai-tax-strip {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ============================================================================
   MÓDULO: AUDITORÍA CONTINUA IA Y RADAR ANIMADO (PALETA MORADA)
   ============================================================================ */

@keyframes aiRadarPulse {
    0% {
        transform: scale(0.35);
        opacity: 0.9;
    }
    70% {
        opacity: 0.35;
    }
    100% {
        transform: scale(1.35);
        opacity: 0;
    }
}

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

.ai-audit-page {
    max-width: 1220px;
    margin: 0 auto;
    padding: 20px 16px 40px 16px;
}

.ai-audit-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 18px;
}

.ai-audit-title-group {
    display: flex;
    align-items: center;
    gap: 14px;
}

.ai-audit-icon-box {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: var(--ai-gradient);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.45rem;
    box-shadow: 0 6px 16px rgba(124, 58, 237, 0.32);
    flex-shrink: 0;
}

.ai-audit-controls-card {
    background: linear-gradient(135deg, #FAF5FF 0%, #FFFFFF 65%, #EEF2FF 100%);
    border: 1.5px solid #DDD6FE;
    border-radius: 16px;
    padding: 18px 22px;
    box-shadow: 0 6px 20px rgba(109, 40, 217, 0.08);
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 20px;
}

.ai-audit-period-fields {
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 14px;
}

.ai-audit-field label {
    display: block;
    font-size: 0.74rem;
    font-weight: 700;
    color: #5B21B6;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 5px;
}

.ai-audit-field .form-control,
.ai-audit-field .form-select {
    border: 1px solid #C4B5FD;
    border-radius: 9px;
    padding: 8px 12px;
    font-size: 0.88rem;
    font-weight: 600;
    color: #1E1B4B;
    background: #ffffff;
}

.ai-audit-field .form-control:focus,
.ai-audit-field .form-select:focus {
    outline: none;
    border-color: var(--ai-purple-primary);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.18);
}

/* Radar / Onda Expansiva Animada */
.ai-audit-radar-card {
    background: linear-gradient(135deg, #1E1B4B 0%, #312E81 52%, #4C1D95 100%);
    border: 1.5px solid #8B5CF6;
    border-radius: 18px;
    padding: 26px 28px;
    color: #ffffff;
    box-shadow: 0 18px 42px rgba(79, 70, 229, 0.28);
    margin-bottom: 22px;
    display: flex;
    align-items: center;
    gap: 28px;
    flex-wrap: wrap;
}

.ai-radar-stage {
    position: relative;
    width: 118px;
    height: 118px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-radar-circle {
    position: relative;
    width: 108px;
    height: 108px;
    border-radius: 50%;
    border: 2px solid rgba(196, 181, 253, 0.45);
    background: radial-gradient(circle, rgba(139, 92, 246, 0.22) 0%, rgba(30, 27, 75, 0.7) 75%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.ai-radar-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid #A78BFA;
    animation: aiRadarPulse 2.2s cubic-bezier(0.22, 0.61, 0.36, 1) infinite;
}

.ai-radar-ring.ring-2 {
    animation-delay: 0.75s;
}

.ai-radar-ring.ring-3 {
    animation-delay: 1.5s;
}

.ai-radar-sweep {
    position: absolute;
    inset: -2px;
    border-radius: 50%;
    background: conic-gradient(from 0deg, rgba(167, 139, 250, 0.65) 0deg, rgba(124, 58, 237, 0.08) 70deg, transparent 120deg);
    animation: aiRadarSweep 2.1s linear infinite;
}

.ai-radar-core {
    position: relative;
    z-index: 2;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--ai-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: #ffffff;
    box-shadow: 0 0 18px rgba(167, 139, 250, 0.8);
}

.ai-audit-progress-info {
    flex: 1;
    min-width: 260px;
}

.ai-audit-progress-track {
    width: 100%;
    height: 9px;
    background: rgba(255, 255, 255, 0.16);
    border-radius: 9999px;
    overflow: hidden;
    margin: 12px 0;
}

.ai-audit-progress-fill {
    height: 100%;
    border-radius: 9999px;
    background: linear-gradient(90deg, #C4B5FD, #8B5CF6, #6366F1);
    transition: width 0.55s ease;
}

.ai-audit-stages-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 10px;
}

.ai-stage-pill {
    font-size: 0.76rem;
    padding: 7px 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(196, 181, 253, 0.22);
    color: #DDD6FE;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-stage-pill.is-active {
    background: rgba(139, 92, 246, 0.34);
    border-color: #C4B5FD;
    color: #ffffff;
    font-weight: 700;
}

.ai-stage-pill.is-done {
    background: rgba(16, 185, 129, 0.22);
    border-color: rgba(110, 231, 183, 0.45);
    color: #D1FAE5;
}

/* Medidor Circular y Resumen Ejecutivo */
.ai-audit-summary-grid {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 20px;
    margin-bottom: 22px;
}

.ai-health-gauge-card {
    background: #ffffff;
    border: 1.5px solid #DDD6FE;
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 6px 18px rgba(109, 40, 217, 0.06);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.ai-gauge-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.ai-health-svg {
    transform: rotate(-90deg);
}

.ai-health-ring-bg {
    fill: none;
    stroke: #EDE9FE;
}

.ai-health-ring-fg {
    fill: none;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.8s ease;
}

.ai-health-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.ai-health-score-num {
    font-size: 2rem;
    font-weight: 800;
    color: #1E1B4B;
    line-height: 1;
}

.ai-health-score-sub {
    font-size: 0.72rem;
    font-weight: 700;
    color: #6D28D9;
    text-transform: uppercase;
    margin-top: 4px;
}

.ai-executive-card {
    background: #ffffff;
    border: 1.5px solid #DDD6FE;
    border-radius: 16px;
    padding: 20px 24px;
    box-shadow: 0 6px 18px rgba(109, 40, 217, 0.06);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 16px;
}

.ai-kpi-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.ai-kpi-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 700;
    border: 1px solid transparent;
}

.ai-kpi-chip.critical {
    background: #FFF1F2;
    color: #BE123C;
    border-color: #FECDD3;
}

.ai-kpi-chip.warning {
    background: #FFFBEB;
    color: #B45309;
    border-color: #FDE68A;
}

.ai-kpi-chip.info {
    background: #F5F3FF;
    color: #6D28D9;
    border-color: #DDD6FE;
}

.ai-kpi-chip.resolved {
    background: #ECFDF5;
    color: #047857;
    border-color: #A7F3D0;
}

/* Barra de Filtros y Tarjetas de Hallazgos */
.ai-filter-bar {
    background: #FAF5FF;
    border: 1px solid #DDD6FE;
    border-radius: 14px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 18px;
}

.ai-filter-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.ai-filter-pill {
    background: #ffffff;
    border: 1px solid #DDD6FE;
    color: #4C1D95;
    border-radius: 9999px;
    padding: 5px 12px;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.18s ease;
}

.ai-filter-pill:hover {
    background: #EDE9FE;
}

.ai-filter-pill.active {
    background: var(--ai-gradient);
    color: #ffffff;
    border-color: #6D28D9;
    box-shadow: 0 3px 8px rgba(124, 58, 237, 0.25);
}

.ai-findings-stack {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.ai-finding-card {
    background: #ffffff;
    border: 1px solid #DDD6FE;
    border-left: 5px solid #7C3AED;
    border-radius: 14px;
    padding: 18px 20px;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.ai-finding-card:hover {
    box-shadow: 0 8px 22px rgba(109, 40, 217, 0.1);
}

.ai-finding-card.severity-critical {
    border-left-color: #BE123C;
    border-color: #FECDD3;
    border-left-width: 5px;
    background: linear-gradient(to right, #FFF1F2 0%, #FFFFFF 12%);
}

.ai-finding-card.severity-warning {
    border-left-color: #D97706;
    border-color: #FDE68A;
    border-left-width: 5px;
    background: linear-gradient(to right, #FFFBEB 0%, #FFFFFF 12%);
}

.ai-finding-card.severity-info {
    border-left-color: #7C3AED;
    border-color: #DDD6FE;
    border-left-width: 5px;
    background: linear-gradient(to right, #F5F3FF 0%, #FFFFFF 12%);
}

.ai-finding-card.is-closed {
    opacity: 0.78;
    background: #F8FAFC;
    border-color: #E2E8F0;
    border-left-color: #94A3B8;
}

.ai-severity-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
}

.ai-severity-badge.critical {
    background: #FFE4E6;
    color: #9F1239;
    border: 1px solid #FDA4AF;
}

.ai-severity-badge.warning {
    background: #FEF3C7;
    color: #92400E;
    border: 1px solid #FCD34D;
}

.ai-severity-badge.info {
    background: #EDE9FE;
    color: #5B21B6;
    border: 1px solid #C4B5FD;
}

.ai-category-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 700;
    background: #F5F3FF;
    color: #6D28D9;
    border: 1px solid #DDD6FE;
}

.ai-finding-rec-box {
    background: #FAF5FF;
    border: 1px solid #EDE9FE;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 0.84rem;
    color: #3B0764;
    margin-top: 10px;
}

.ai-finding-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid #F3E8FF;
}

/* Tarjeta Preventiva dentro de Cierre Fiscal */
.fc-ai-audit-card {
    background: linear-gradient(135deg, #FAF5FF 0%, #FFFFFF 60%, #EEF2FF 100%);
    border: 1.5px solid #C4B5FD;
    border-radius: 14px;
    padding: 18px 20px;
    margin-top: 18px;
    box-shadow: 0 6px 18px rgba(124, 58, 237, 0.08);
}

.fc-ai-preview-grid {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 18px;
    align-items: center;
    margin-top: 14px;
}

@media (max-width: 900px) {
    .ai-audit-summary-grid,
    .fc-ai-preview-grid {
        grid-template-columns: 1fr;
    }
    .ai-audit-stages-list {
        grid-template-columns: 1fr;
    }
}

/* ============================================================================
   MÓDULO: COPILOTO FINANCIERO Y ANÁLISIS DE ESTADOS FINANCIEROS (PALETA MORADA)
   ============================================================================ */

/* Botón Flotante (FAB) en esquina inferior derecha */
.ai-copilot-fab {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 9500;
    background: var(--ai-gradient);
    color: #ffffff;
    border: 1.5px solid #A78BFA;
    border-radius: 9999px;
    padding: 12px 20px;
    font-size: 0.92rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 12px 28px rgba(109, 40, 217, 0.38);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ai-copilot-fab:hover {
    background: var(--ai-gradient-hover);
    transform: translateY(-2px);
    box-shadow: 0 16px 34px rgba(109, 40, 217, 0.5);
}

.ai-copilot-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.42);
    backdrop-filter: blur(2px);
    z-index: 9950;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
}

.ai-copilot-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
}

/* Drawer Lateral Derecho Morado */
.ai-copilot-drawer {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 470px;
    max-width: 96vw;
    background: #FAF5FF;
    border-left: 2px solid #C4B5FD;
    box-shadow: -12px 0 36px rgba(30, 27, 75, 0.24);
    z-index: 9960;
    display: flex;
    flex-direction: column;
    transform: translateX(105%);
    transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1);
}

.ai-copilot-drawer.is-open {
    transform: translateX(0);
}

.ai-copilot-header {
    background: var(--ai-gradient);
    color: #ffffff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-shrink: 0;
}

.ai-copilot-toolbar {
    background: #FFFFFF;
    border-bottom: 1px solid #DDD6FE;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-shrink: 0;
}

.ai-copilot-chips-wrap {
    padding: 10px 16px;
    background: #F5F3FF;
    border-bottom: 1px solid #DDD6FE;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex-shrink: 0;
}

.ai-copilot-chip {
    background: #FFFFFF;
    color: #5B21B6;
    border: 1px solid #C4B5FD;
    border-radius: 9999px;
    padding: 5px 11px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.16s ease;
    text-align: left;
}

.ai-copilot-chip:hover {
    background: #EDE9FE;
    border-color: var(--ai-purple-primary);
    transform: translateY(-1px);
}

.ai-copilot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-msg-user {
    align-self: flex-end;
    max-width: 86%;
    background: var(--ai-gradient);
    color: #ffffff;
    padding: 10px 14px;
    border-radius: 14px 14px 4px 14px;
    font-size: 0.87rem;
    line-height: 1.45;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.24);
}

.ai-msg-assistant {
    align-self: flex-start;
    width: 100%;
    background: #ffffff;
    color: #1E293B;
    border: 1px solid #DDD6FE;
    border-left: 4px solid var(--ai-purple-primary);
    padding: 13px 14px;
    border-radius: 4px 14px 14px 14px;
    font-size: 0.86rem;
    line-height: 1.5;
    box-shadow: 0 4px 14px rgba(109, 40, 217, 0.06);
}

.ai-chat-kpi-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 10px 0 6px 0;
}

.ai-chat-kpi-pill {
    background: #F5F3FF;
    border: 1px solid #DDD6FE;
    border-radius: 8px;
    padding: 5px 9px;
    font-size: 0.74rem;
}

.ai-chat-kpi-pill span {
    color: #6D28D9;
    font-weight: 700;
    display: block;
    font-size: 0.68rem;
}

.ai-chat-kpi-pill strong {
    color: #1E1B4B;
    font-size: 0.82rem;
}

.ai-chat-table-wrap {
    margin-top: 10px;
    border: 1px solid #DDD6FE;
    border-radius: 10px;
    overflow-x: auto;
    background: #FFFFFF;
}

.ai-chat-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.76rem;
}

.ai-chat-table th {
    background: #EDE9FE;
    color: #4C1D95;
    font-weight: 700;
    padding: 6px 8px;
    text-align: left;
    white-space: nowrap;
}

.ai-chat-table td {
    padding: 6px 8px;
    border-top: 1px solid #F3E8FF;
    color: #1E293B;
}

.ai-chat-table td.is-num,
.ai-chat-table th.is-num {
    text-align: right;
    font-family: monospace;
    font-weight: 600;
}

.btn-ai-csv {
    background: #FAF5FF;
    color: #6D28D9;
    border: 1px solid #C4B5FD;
    border-radius: 8px;
    padding: 4px 10px;
    font-size: 0.74rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.btn-ai-csv:hover {
    background: #EDE9FE;
}

/* Animación Neural (3 puntos + onda morada) */
@keyframes aiNeuralDot {
    0%, 80%, 100% {
        transform: scale(0.65);
        opacity: 0.45;
    }
    40% {
        transform: scale(1.15);
        opacity: 1;
    }
}

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

.ai-neural-bubble {
    background: linear-gradient(135deg, #F5F3FF 0%, #EDE9FE 100%);
    border: 1px solid #C4B5FD;
    border-left: 4px solid #7C3AED;
    border-radius: 6px 14px 14px 14px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-neural-dots {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.ai-neural-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #7C3AED;
    animation: aiNeuralDot 1.2s infinite ease-in-out both;
}

.ai-neural-dots span:nth-child(2) { animation-delay: 0.2s; }
.ai-neural-dots span:nth-child(3) { animation-delay: 0.4s; }

.ai-neural-wave-bar {
    height: 4px;
    width: 100%;
    border-radius: 9999px;
    background: linear-gradient(90deg, #DDD6FE, #7C3AED, #4F46E5, #DDD6FE);
    background-size: 200% 100%;
    animation: aiNeuralWave 1.6s linear infinite;
}

.ai-copilot-input-bar {
    background: #FFFFFF;
    border-top: 1px solid #DDD6FE;
    padding: 12px 14px;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

.ai-copilot-input-bar textarea {
    flex: 1;
    resize: none;
    border: 1px solid #C4B5FD;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 0.86rem;
    min-height: 40px;
    max-height: 110px;
    font-family: inherit;
}

.ai-copilot-input-bar textarea:focus {
    outline: none;
    border-color: var(--ai-purple-primary);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.16);
}

/* Tarjeta Ejecutiva en Estados Financieros */
.ai-statement-analysis-host {
    margin-bottom: 18px;
}

.ai-statement-card {
    background: #FFFFFF;
    border: 1.5px solid #C4B5FD;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 10px 26px rgba(109, 40, 217, 0.12);
}

.ai-statement-card-header {
    background: var(--ai-gradient);
    color: #ffffff;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.ai-statement-card-body {
    padding: 18px 20px;
    background: linear-gradient(180deg, #FAF5FF 0%, #FFFFFF 30%);
}

.ai-statement-shimmer {
    padding: 24px;
    background: linear-gradient(90deg, #FAF5FF 0%, #EDE9FE 50%, #FAF5FF 100%);
    background-size: 600px 100%;
    animation: aiPurpleShimmer 1.6s infinite linear;
}

.ai-kpi-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin: 14px 0;
}

.ai-statement-kpi-box {
    background: #FFFFFF;
    border: 1px solid #DDD6FE;
    border-radius: 12px;
    padding: 12px 14px;
}

.ai-statement-kpi-box.status-good { border-top: 3px solid #059669; }
.ai-statement-kpi-box.status-warning { border-top: 3px solid #D97706; }
.ai-statement-kpi-box.status-danger { border-top: 3px solid #DC2626; }

.ai-statement-blocks-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-top: 12px;
}

.ai-statement-subblock {
    background: #FAF5FF;
    border: 1px solid #EDE9FE;
    border-radius: 12px;
    padding: 14px 16px;
}

@media (max-width: 900px) {
    .ai-kpi-grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    .ai-statement-blocks-2 {
        grid-template-columns: 1fr;
    }
}

@media print {
    .ai-copilot-fab,
    .ai-copilot-backdrop,
    .ai-copilot-drawer,
    .ai-statement-card-controls,
    .ai-statement-analysis-host.no-print {
        display: none !important;
    }

    .ai-statement-analysis-host:not(.no-print) .ai-statement-card {
        box-shadow: none !important;
        border: 1px solid #94A3B8 !important;
        break-inside: avoid;
        margin-bottom: 14px;
    }

    .ai-statement-analysis-host:not(.no-print) .ai-statement-card-header {
        background: #EDE9FE !important;
        color: #1E1B4B !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}
