/* Variables del Sistema */
:root {
    --bg-gradient: linear-gradient(135deg, #221c1c 0%, #181313 50%, #1e1717 100%);
    --panel-bg: rgba(6, 5, 5, 0.85);
    --panel-border: rgba(255, 255, 255, 0.08);
    --glass-glow: rgba(158, 45, 42, 0.04);
    
    --bg-card: rgba(18, 14, 14, 0.85);
    --border-color: rgba(255, 255, 255, 0.1);
    --text-main: #ededed;
    --text-primary: #ededed;
    --text-secondary: #c6c6c6;
    --text-muted: #8e8e8e;
    
    /* Colores Temáticos */
    --color-blue: #3b82f6;
    --color-green: #10b981;
    --color-red: #9e2d2a; /* Rojo InTracker */
    --color-red-dark: #6b1515; /* Rojo Oscuro InTracker */
    --color-orange: #f97316;
    --color-yellow: #f59e0b;
    --color-purple: #9e2d2a; /* Rojo InTracker */
    
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
    --radius-lg: 12px;
    --radius-full: 9999px;

    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Modo Claro (Light Mode) */
[data-theme="light"] {
    --bg-gradient: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 50%, #f1f5f9 100%);
    --panel-bg: rgba(255, 255, 255, 0.92);
    --panel-border: rgba(0, 0, 0, 0.08);
    --glass-glow: rgba(158, 45, 42, 0.04);
    
    --bg-card: #ffffff;
    --border-color: #e2e8f0;
    --text-main: #0f172a;
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
}

/* Estilos Globales */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: var(--bg-gradient);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
}

/* Contenedor Principal */
.app-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header del Dashboard */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--panel-border);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.logo-symbol {
    height: 48px;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 4px 12px rgba(158, 45, 42, 0.3));
    transition: var(--transition-smooth);
}

.logo-symbol:hover {
    transform: rotate(5deg) scale(1.05);
}

.logo-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.15rem;
}

.logo-text-img {
    height: 22px;
    width: auto;
    object-fit: contain;
    display: block;
    align-self: flex-start;
}

.logo-text span {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 600;
    opacity: 0.8;
}

/* Filtros */
.filters-area {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-group label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.filter-group select,
.filter-group input {
    background: rgba(17, 12, 34, 0.7);
    border: 1px solid var(--panel-border);
    color: var(--text-primary);
    padding: 0.65rem 1rem;
    border-radius: 0.5rem;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    outline: none;
    min-width: 160px;
    transition: var(--transition-smooth);
}

.filter-group select:focus,
.filter-group input:focus {
    border-color: var(--color-red);
    box-shadow: 0 0 0 2px rgba(158, 45, 42, 0.2);
}

.custom-date-inputs {
    display: flex;
    gap: 1rem;
    transition: var(--transition-smooth);
}

.hidden {
    display: none !important;
}

/* Botón Primario */
.btn-primary {
    background: linear-gradient(135deg, var(--color-red) 0%, var(--color-red-dark) 100%);
    border: none;
    color: white;
    padding: 0.65rem 1.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 15px rgba(158, 45, 42, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(158, 45, 42, 0.4);
    background: linear-gradient(135deg, #b83633 0%, #7c1a1a 100%);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Contenido Principal y Cargando */
.dashboard-main {
    position: relative;
    min-height: 400px;
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(11, 9, 20, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    z-index: 100;
    border-radius: 1rem;
}

.loader-wrapper {
    position: relative;
    width: 90px;
    height: 90px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 1.5rem;
}

.loader-logo {
    width: 48px;
    height: 48px;
    object-fit: contain;
    animation: loader-pulse 2s infinite ease-in-out;
}

.loader-spinner {
    position: absolute;
    width: 80px;
    height: 80px;
    border: 3px solid rgba(158, 45, 42, 0.1);
    border-top: 3px solid var(--color-red);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

@keyframes loader-pulse {
    0%, 100% {
        transform: scale(0.95);
        filter: drop-shadow(0 0 4px rgba(158, 45, 42, 0.4));
    }
    50% {
        transform: scale(1.06);
        filter: drop-shadow(0 0 16px rgba(158, 45, 42, 0.8));
    }
}

.loading-overlay p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Alerta de Error */
.error-alert {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 0.75rem;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    margin-bottom: 2rem;
    animation: fadeIn 0.4s ease;
}

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

.error-alert i {
    font-size: 2rem;
    color: var(--color-red);
}

.error-msg h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.15rem;
    color: #fca5a5;
}

.error-msg p {
    font-size: 0.85rem;
    color: #fecaca;
}

.error-alert button {
    margin-left: auto;
    background: none;
    border: none;
    color: #fecaca;
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    transition: var(--transition-smooth);
}

.error-alert button:hover {
    color: white;
}

/* Glassmorphism General */
.glass {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 16px 40px -10px rgba(0, 0, 0, 0.85), 0 2px 24px 0 rgba(158, 45, 42, 0.08);
    border-radius: 1rem;
    position: relative;
    overflow: hidden;
}

.glass::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    background: rgba(255, 255, 255, 0.015);
    pointer-events: none;
}

/* Sección Financiera y Grid de KPIs */
.financial-section {
    margin-bottom: 1.5rem;
}

.financial-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.kpi-card {
    padding: 1.5rem;
    transition: var(--transition-smooth);
}

.kpi-card:hover {
    transform: translateY(-5px);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.95), 0 4px 30px 0 rgba(158, 45, 42, 0.16);
}

.kpi-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.kpi-card-header span {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 600;
    letter-spacing: 0.3px;
}

.kpi-icon {
    width: 40px;
    height: 40px;
    border-radius: 0.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.25rem;
}

.icon-blue { background: rgba(59, 130, 246, 0.15); color: var(--color-blue); }
.icon-green { background: rgba(16, 185, 129, 0.15); color: var(--color-green); }
.icon-red { background: rgba(239, 110, 110, 0.15); color: var(--color-red); }
.icon-orange { background: rgba(249, 115, 22, 0.15); color: var(--color-orange); }
.icon-yellow { background: rgba(245, 158, 11, 0.15); color: var(--color-yellow); }
.icon-purple { background: rgba(158, 45, 42, 0.15); color: var(--color-purple); }

.kpi-card-body h2 {
    font-size: 2.25rem;
    font-weight: 800;
    margin-bottom: 0.25rem;
    letter-spacing: -1px;
}

.kpi-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Gráficos */
.charts-section {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.chart-container {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 380px;
}

.chart-container.large {
    grid-column: span 2;
}

.chart-header {
    display: flex;
    flex-direction: column;
}

.chart-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chart-header span {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.chart-wrapper {
    flex-grow: 1;
    position: relative;
    width: 100%;
    height: 280px;
}

/* Tablas y Alertas */
.details-section {
    padding: 2rem;
    margin-bottom: 2rem;
}

.details-header {
    margin-bottom: 1.5rem;
}

.details-header h3 {
    font-size: 1.2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.details-header p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.color-yellow {
    color: var(--color-yellow);
}

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

.details-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.9rem;
}

.details-table th,
.details-table td {
    padding: 0.75rem 0.85rem;
    border-bottom: 1px solid var(--panel-border);
}

.details-table th {
    font-weight: 600;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.02);
}

.details-table tbody tr {
    transition: var(--transition-smooth);
}

.details-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.details-table td {
    color: var(--text-primary);
}

.text-center {
    text-align: center;
}

.btn-table {
    background: rgba(158, 45, 42, 0.1);
    color: var(--color-red);
    border: 1px solid rgba(158, 45, 42, 0.2);
    padding: 0.35rem 0.75rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition-smooth);
}

.btn-table:hover {
    background: var(--color-red);
    color: white;
}

/* Scrollbar Personalizado */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(11, 9, 20, 0.5);
}

::-webkit-scrollbar-thumb {
    background: rgba(158, 45, 42, 0.3);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(158, 45, 42, 0.5);
}

/* Media Queries para Responsividad */
@media (max-width: 1024px) {
    .charts-section {
        grid-template-columns: 1fr;
    }
    
    .chart-container.large {
        grid-column: span 1;
    }
}

@media (max-width: 768px) {
    .app-container {
        padding: 1rem;
    }
    
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .filters-area {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }
    
    .custom-date-inputs {
        flex-direction: column;
    }
    
    .btn-primary {
        width: 100%;
        justify-content: center;
    }
}

/* Estilos de Rendimiento Financiero e Ingresos */
.financial-section {
    margin-bottom: 3.5rem;
}

.financial-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
}

@media (max-width: 1024px) {
    /* No se requiere regla especial ya que auto-fit se ajusta dinámicamente */
}

@media (max-width: 768px) {
    /* No se requiere regla especial ya que auto-fit se ajusta dinámicamente */
}

/* Botón Secundario (Glassmorphism) */
.btn-secondary {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--panel-border);
    color: var(--text-secondary);
    padding: 0.65rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition-smooth);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border-color: var(--color-blue);
    transform: translateY(-2px);
}

.btn-secondary:active {
    transform: translateY(0);
}

/* Ficha de Rendimiento Comparativo */
.scorecard-section {
    padding: 2rem;
    margin-bottom: 2.5rem;
}

.scorecard-header {
    margin-bottom: 1.5rem;
}

.scorecard-header h3 {
    font-size: 1.2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.scorecard-header p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.scorecard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.scorecard-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--panel-border);
    padding: 1.25rem;
    border-radius: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    position: relative;
    overflow: hidden;
}

.scorecard-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

.scorecard-card.card-blue::before { background: var(--color-blue); }
.scorecard-card.card-purple::before { background: var(--color-purple); }
.scorecard-card.card-orange::before { background: var(--color-orange); }
.scorecard-card.card-green::before { background: var(--color-green); }

.scorecard-card-title {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.scorecard-card-value {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin: 0.25rem 0;
}

.scorecard-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.25rem 0.65rem;
    border-radius: 2rem;
    width: fit-content;
}

.badge-positive {
    background: rgba(16, 185, 129, 0.12);
    color: var(--color-green);
}

.badge-negative {
    background: rgba(239, 68, 68, 0.12);
    color: var(--color-red);
}

.badge-neutral {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
}

/* Leaderboard Ranking */
.rank-badge {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.85rem;
}

/* Golden rank first place styles */
.row-rank-1 {
    background: linear-gradient(90deg, rgba(251, 191, 36, 0.09) 0%, rgba(251, 191, 36, 0.02) 100%) !important;
}

.row-rank-1 td {
    border-bottom: 1px solid rgba(251, 191, 36, 0.15) !important;
    position: relative;
}

.row-rank-1 td:first-child::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: linear-gradient(180deg, #ffd700 0%, #fbbf24 100%);
    box-shadow: 0 0 8px rgba(251, 191, 36, 0.5);
}

.rank-1 {
    background: linear-gradient(135deg, #ffd700 0%, #d4af37 100%) !important;
    color: #0b0914 !important;
    border: 1px solid #ffd700 !important;
    box-shadow: 0 0 8px rgba(253, 224, 71, 0.6);
    font-weight: 800;
}

.rank-2 {
    background: rgba(156, 163, 175, 0.15);
    color: #e5e7eb;
    border: 1px solid rgba(156, 163, 175, 0.3);
}

.rank-3 {
    background: rgba(217, 119, 6, 0.15);
    color: #fb923c;
    border: 1px solid rgba(217, 119, 6, 0.3);
}

.rank-other {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
}

.leaderboard-name {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}

.leaderboard-crown {
    color: #ffd700;
    filter: drop-shadow(0 0 6px rgba(251, 191, 36, 0.8));
    animation: gold-pulse 2s infinite ease-in-out;
}

@keyframes gold-pulse {
    0%, 100% {
        transform: scale(1);
        filter: drop-shadow(0 0 4px rgba(251, 191, 36, 0.5));
    }
    50% {
        transform: scale(1.15) rotate(3deg);
        filter: drop-shadow(0 0 10px rgba(251, 191, 36, 0.9));
    }
}

/* Cabecera para Impresión */
.print-header {
    display: none;
}

/* Reglas de impresión / PDF */
@media print {
    body {
        background: #0b0914 !important;
        color: #f3f4f6 !important;
    }
    
    .print-header {
        display: block !important;
        margin-bottom: 2.5rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        padding-bottom: 1rem;
    }
    
    .print-header h1 {
        font-size: 2rem;
        color: #ffffff;
        font-weight: 800;
    }
    
    .print-header p {
        font-size: 0.95rem;
        color: #9ca3af;
        margin-top: 0.25rem;
    }
    
    .glass {
        background: rgba(20, 18, 43, 0.85) !important;
        border: 1px solid rgba(255, 255, 255, 0.08) !important;
        color: #f3f4f6 !important;
        box-shadow: none !important;
    }
    
    .glass::before,
    .scorecard-card::before {
        display: none !important;
    }
    
    .dashboard-header,
    .filters-area,
    #btn-refresh,
    #btn-export-pdf,
    #btn-export-csv,
    .btn-table,
    .loading-overlay {
        display: none !important;
    }
    
    .app-container {
        padding: 0 !important;
        max-width: 100% !important;
        background: #0b0914 !important;
    }
}

/* Estilos del Reporte PDF Corporativo e Imprimible - Versión Consolidada y Compacta */
.pdf-report-container {
    background: #ffffff !important;
    color: #1f2937 !important;
    padding: 10px 20px;
    font-family: var(--font-sans);
    line-height: 1.4;
}

.pdf-header {
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 10px;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.pdf-title-area h1 {
    font-size: 24px;
    font-weight: 800;
    color: #111827;
    margin: 0;
}

.pdf-title-area p {
    font-size: 13px;
    color: #6b7280;
    margin: 5px 0 0 0;
}

.pdf-brand {
    font-size: 16px;
    font-weight: 700;
    color: #3b82f6;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.pdf-section-title {
    font-size: 12px;
    font-weight: 700;
    color: #374151;
    margin-top: 20px;
    margin-bottom: 10px;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
    page-break-inside: avoid;
    break-inside: avoid;
}

.pdf-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 15px;
}

.pdf-kpi-box {
    border: 1px solid #e5e7eb;
    padding: 10px;
    border-radius: 8px;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 65px;
    page-break-inside: avoid;
    break-inside: avoid;
}

.pdf-kpi-title {
    font-size: 11px;
    color: #6b7280;
    font-weight: 600;
    text-transform: uppercase;
}

.pdf-kpi-value {
    font-size: 18px;
    font-weight: 800;
    color: #111827;
    margin-top: 2px;
}

.pdf-kpi-desc {
    font-size: 9px;
    color: #9ca3af;
    margin-top: 3px;
}

.pdf-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 15px;
    font-size: 11px;
    page-break-inside: avoid;
    break-inside: avoid;
}

.pdf-table tr {
    page-break-inside: avoid;
    break-inside: avoid;
}

.pdf-table th, 
.pdf-table td {
    border: 1px solid #e5e7eb;
    padding: 6px 10px;
    text-align: left;
}

.pdf-table th {
    background: #f3f4f6;
    color: #374151;
    font-weight: 700;
}

.pdf-table td {
    color: #4b5563;
}

.pdf-table tbody tr:nth-child(even) {
    background: #f9fafb;
}

.pdf-table-unmanaged {
    font-size: 10px;
}

/* Modal Estilos Premium */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(11, 9, 20, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    transition: var(--transition-smooth);
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
    display: none !important;
}

.modal-content {
    width: 95%;
    max-width: 1100px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    background: rgba(25, 22, 51, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    border-radius: 1.25rem;
    animation: modalSlideIn 0.37s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(30px) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--panel-border);
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
}

.btn-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.75rem;
    cursor: pointer;
    line-height: 1;
    transition: var(--transition-smooth);
    display: flex;
    justify-content: center;
    align-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.btn-close:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
}

.modal-body {
    padding: 2rem 2rem 2.5rem 2rem;
    overflow-y: auto;
    flex-grow: 1;
}

/* Efecto hover interactivo para tarjetas clicables */
.clickable:hover {
    cursor: pointer;
    box-shadow: 0 12px 40px 0 rgba(16, 185, 129, 0.2) !important;
    border-color: rgba(16, 185, 129, 0.4) !important;
}

/* Efecto hover interactivo específico para la tarjeta de leads perdidos */
#kpi-card-lost.clickable:hover {
    box-shadow: 0 12px 40px 0 rgba(239, 68, 68, 0.25) !important;
    border-color: rgba(239, 68, 68, 0.45) !important;
}

/* Efecto hover interactivo específico para la tarjeta de leads no gestionados */
#kpi-card-unmanaged.clickable:hover {
    box-shadow: 0 12px 40px 0 rgba(245, 158, 11, 0.25) !important;
    border-color: rgba(245, 158, 11, 0.45) !important;
}

/* Botón de cambio de tema */
.btn-theme {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--panel-border);
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    border-radius: 0.5rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.15rem;
    transition: var(--transition-smooth);
}

.btn-theme:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border-color: var(--color-red);
    transform: translateY(-2px);
}

.btn-theme:active {
    transform: translateY(0);
}

/* Redefinición para Modo Claro */
body.light-mode {
    --bg-gradient: linear-gradient(135deg, #f7f6f6 0%, #ebe8e8 50%, #dfdbdb 100%);
    --panel-bg: rgba(255, 255, 255, 0.65);
    --panel-border: rgba(0, 0, 0, 0.08);
    --glass-glow: rgba(158, 45, 42, 0.02);
    
    --text-primary: #3a3a3a;      /* Gris Oscuro corporativo */
    --text-secondary: #5a5a5a;
    --text-muted: #888888;
}

body.light-mode .btn-theme {
    background: rgba(0, 0, 0, 0.03);
    color: var(--text-secondary);
    border-color: rgba(0, 0, 0, 0.08);
}

body.light-mode .btn-theme:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--text-primary);
    border-color: var(--color-red);
}

/* Estilos para las acciones del formulario dentro del modal */
.form-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
    padding-bottom: 1.5rem; /* Margen y espacio para separar los botones del borde inferior del modal */
}

body.light-mode .filter-group select,
body.light-mode .filter-group input {
    background: rgba(255, 255, 255, 0.85);
    border-color: rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
}

body.light-mode .filter-group select:focus,
body.light-mode .filter-group input:focus {
    border-color: var(--color-red);
    box-shadow: 0 0 0 2px rgba(158, 45, 42, 0.12);
}

body.light-mode .glass {
    box-shadow: 0 12px 36px 0 rgba(0, 0, 0, 0.24), 0 2px 6px 0 rgba(0, 0, 0, 0.06);
}

body.light-mode .kpi-card:hover {
    border-color: rgba(158, 45, 42, 0.25);
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.28), 0 4px 12px rgba(0, 0, 0, 0.08);
}

body.light-mode .scorecard-card {
    background: rgba(0, 0, 0, 0.015);
}

body.light-mode .details-table th {
    background: rgba(0, 0, 0, 0.02);
}

body.light-mode .details-table tbody tr:hover {
    background: rgba(0, 0, 0, 0.015);
}

body.light-mode .modal-content {
    background: #ffffff !important;
    border-color: rgba(0, 0, 0, 0.12) !important;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18) !important;
    color: #0f172a !important;
}

body.light-mode .modal-overlay {
    background: rgba(15, 23, 42, 0.4) !important;
}

body.light-mode .modal-header {
    border-bottom-color: rgba(0, 0, 0, 0.08);
}

body.light-mode .modal-header h3 {
    color: #0f172a !important;
}

body.light-mode .form-group label {
    color: #334155 !important;
}

body.light-mode .form-group input,
body.light-mode .form-group select {
    background: #f8fafc !important;
    color: #0f172a !important;
    border: 1px solid #cbd5e1 !important;
}

body.light-mode .form-group input:focus,
body.light-mode .form-group select:focus {
    border-color: #10b981 !important;
    background: #ffffff !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15) !important;
}

body.light-mode .form-group input::placeholder {
    color: #94a3b8 !important;
}

body.light-mode option {
    background: #ffffff !important;
    color: #0f172a !important;
}

body.light-mode .vendedoras-header,
body.light-mode .sales-history-card {
    background: #ffffff !important;
    border-color: #e2e8f0 !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05) !important;
}

body.light-mode .logo-text-img {
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.15)) brightness(0.85);
}

body.light-mode .loading-overlay {
    background: rgba(245, 245, 245, 0.85);
}

body.light-mode .loading-overlay p {
    color: var(--text-primary);
}

body.light-mode .loader-spinner {
    border: 3px solid rgba(158, 45, 42, 0.05);
    border-top-color: var(--color-red);
}

body.light-mode .rank-1 {
    background: rgba(217, 119, 6, 0.12);
    color: #b45309;
    border: 1px solid rgba(217, 119, 6, 0.25);
}

body.light-mode .rank-2 {
    background: rgba(107, 114, 128, 0.12);
    color: #4b5563;
    border: 1px solid rgba(107, 114, 128, 0.25);
}

body.light-mode .rank-3 {
    background: rgba(194, 65, 12, 0.12);
    color: #c2410c;
    border: 1px solid rgba(194, 65, 12, 0.25);
}

/* Estilos del Mapa de Calor */
.heatmap-container-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.5rem;
    margin-top: 0.5rem;
    overflow-x: auto;
}

.heatmap-header-hours {
    display: grid;
    grid-template-columns: 60px repeat(24, 1fr);
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
}

.heatmap-main-grid-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.heatmap-day-labels {
    display: grid;
    grid-template-rows: repeat(7, 32px);
    gap: 4px;
    width: 60px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-align: right;
    padding-right: 0.5rem;
    align-content: center;
}

.heatmap-grid {
    display: grid;
    grid-template-columns: repeat(24, 1fr);
    grid-template-rows: repeat(7, 32px);
    gap: 4px;
    flex-grow: 1;
}

.heatmap-cell {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.03);
    transition: var(--transition-smooth);
    position: relative;
    cursor: pointer;
    min-height: 32px;
}

.heatmap-cell:hover {
    transform: scale(1.12);
    border-color: rgba(255, 255, 255, 0.25);
    z-index: 10;
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.15);
}

/* Tooltip nativo */
.heatmap-cell[data-tooltip]::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 11, 11, 0.95);
    color: #fff;
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--panel-border);
    z-index: 100;
}

.heatmap-cell[data-tooltip]:hover::before {
    opacity: 1;
    bottom: 135%;
}

/* Escala de colores (Basada en Rojo InTracker GPS) */
.heatmap-cell.scale-0 { background: rgba(255, 255, 255, 0.02); }
.heatmap-cell.scale-1 { background: rgba(158, 45, 42, 0.15); border-color: rgba(158, 45, 42, 0.2); }
.heatmap-cell.scale-2 { background: rgba(158, 45, 42, 0.35); border-color: rgba(158, 45, 42, 0.4); }
.heatmap-cell.scale-3 { background: rgba(158, 45, 42, 0.55); border-color: rgba(158, 45, 42, 0.6); }
.heatmap-cell.scale-4 { background: rgba(158, 45, 42, 0.75); border-color: rgba(158, 45, 42, 0.8); }
.heatmap-cell.scale-5 { 
    background: linear-gradient(135deg, #9e2d2a 0%, #b83633 100%); 
    border-color: #ffd700; 
    box-shadow: inset 0 0 4px rgba(255, 215, 0, 0.3);
}

.heatmap-legend {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.legend-scale {
    display: flex;
    gap: 4px;
}

.legend-cell {
    width: 16px;
    height: 16px;
    border-radius: 2px;
}

.legend-cell.color-scale-1 { background: rgba(158, 45, 42, 0.15); }
.legend-cell.color-scale-2 { background: rgba(158, 45, 42, 0.35); }
.legend-cell.color-scale-3 { background: rgba(158, 45, 42, 0.55); }
.legend-cell.color-scale-4 { background: rgba(158, 45, 42, 0.75); }
.legend-cell.color-scale-5 { background: #9e2d2a; border: 1px solid #ffd700; }

/* Adaptación para modo claro */
body.light-mode .heatmap-cell {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.04);
}

body.light-mode .heatmap-cell.scale-0 { background: rgba(0, 0, 0, 0.02); border-color: rgba(0, 0, 0, 0.04); }
body.light-mode .heatmap-cell.scale-1 { background: rgba(158, 45, 42, 0.12) !important; border-color: rgba(158, 45, 42, 0.15) !important; }
body.light-mode .heatmap-cell.scale-2 { background: rgba(158, 45, 42, 0.28) !important; border-color: rgba(158, 45, 42, 0.3) !important; }
body.light-mode .heatmap-cell.scale-3 { background: rgba(158, 45, 42, 0.48) !important; border-color: rgba(158, 45, 42, 0.5) !important; }
body.light-mode .heatmap-cell.scale-4 { background: rgba(158, 45, 42, 0.68) !important; border-color: rgba(158, 45, 42, 0.7) !important; }
body.light-mode .heatmap-cell.scale-5 { 
    background: linear-gradient(135deg, #9e2d2a 0%, #b83633 100%) !important; 
    border-color: #ffd700 !important; 
}

body.light-mode .heatmap-cell[data-tooltip]::before {
    background: rgba(255, 255, 255, 0.98);
    color: #333;
    border-color: rgba(0, 0, 0, 0.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Layout del Mapa de Calor con Sidebar */
.heatmap-layout {
    display: flex;
    gap: 2rem;
    align-items: stretch;
}

.heatmap-main-content {
    flex: 1;
    min-width: 0;
}

.heatmap-sidebar {
    width: 320px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--panel-border);
    border-radius: 0.75rem;
    padding: 1.25rem;
}

.heatmap-sidebar-header {
    margin-bottom: 1.25rem;
}

.heatmap-sidebar-header h4 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.heatmap-sidebar-header p {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}

.heatmap-top-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex-grow: 1;
}

.top-slot-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 0.5rem;
    padding: 0.65rem 0.75rem;
    transition: var(--transition-smooth);
}

.top-slot-item:hover {
    transform: translateX(4px);
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.08);
}

.slot-badge {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-weight: 800;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.slot-details {
    flex-grow: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.slot-time {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.slot-bar-container {
    height: 4px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 2px;
    width: 100%;
    overflow: hidden;
}

.slot-bar {
    height: 100%;
    background: var(--color-red);
    border-radius: 2px;
    transition: width 0.8s ease-out;
}

/* Efectos de rango en el top y progress bar */
.top-slot-item.rank-row-1 .slot-bar {
    background: linear-gradient(90deg, #ffd700, #fbbf24);
    box-shadow: 0 0 4px rgba(253, 224, 71, 0.4);
}

.top-slot-item.rank-row-1 {
    background: linear-gradient(90deg, rgba(251, 191, 36, 0.06) 0%, rgba(251, 191, 36, 0.01) 100%);
    border-color: rgba(251, 191, 36, 0.12);
}

.top-slot-item.rank-row-2 {
    background: rgba(156, 163, 175, 0.03);
    border-color: rgba(156, 163, 175, 0.08);
}

.top-slot-item.rank-row-3 {
    background: rgba(217, 119, 6, 0.03);
    border-color: rgba(217, 119, 6, 0.08);
}

.slot-count {
    text-align: right;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
    flex-shrink: 0;
    white-space: nowrap;
}

.slot-count strong {
    font-size: 0.95rem;
    color: var(--text-primary);
    font-weight: 700;
    display: block;
    line-height: 1;
}

.slot-count span {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.top-list-empty {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    padding: 2rem 1rem;
    border: 1px dashed rgba(255, 255, 255, 0.05);
    border-radius: 0.5rem;
    height: 100%;
}

.top-list-empty i {
    font-size: 1.5rem;
}

/* Responsividad para heatmap layout */
@media (max-width: 1200px) {
    .heatmap-layout {
        flex-direction: column;
        gap: 1.5rem;
    }
    .heatmap-sidebar {
        width: 100%;
    }
}

/* Modo claro adaptaciones */
body.light-mode .heatmap-sidebar {
    background: rgba(0, 0, 0, 0.015);
}

body.light-mode .top-slot-item {
    background: rgba(0, 0, 0, 0.01);
    border-color: rgba(0, 0, 0, 0.03);
}

body.light-mode .top-slot-item:hover {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.06);
}

body.light-mode .slot-bar-container {
    background: rgba(0, 0, 0, 0.05);
}

body.light-mode .top-slot-item.rank-row-1 {
    background: linear-gradient(90deg, rgba(251, 191, 36, 0.07) 0%, rgba(251, 191, 36, 0.02) 100%);
    border-color: rgba(251, 191, 36, 0.2);
}

body.light-mode .top-slot-item.rank-row-1 .slot-badge.rank-1 {
    color: #451a03 !important;
}

body.light-mode .top-slot-item.rank-row-2 {
    background: rgba(107, 114, 128, 0.03);
    border-color: rgba(107, 114, 128, 0.12);
}

body.light-mode .top-slot-item.rank-row-3 {
    background: rgba(217, 119, 6, 0.03);
    border-color: rgba(217, 119, 6, 0.12);
}

body.light-mode .top-list-empty {
    border-color: rgba(0, 0, 0, 0.08);
}

/* Growth Badges Premium Styling */
.growth-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 2rem;
    height: fit-content;
    white-space: nowrap;
    transition: var(--transition-smooth);
    margin-bottom: 0.25rem;
}

/* Dark Mode (Default) Badges */
.growth-badge.positive {
    background: rgba(16, 185, 129, 0.12);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.growth-badge.negative {
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.growth-badge.neutral {
    background: rgba(255, 255, 255, 0.04);
    color: #9ca3af;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

/* Light Mode Overrides */
body.light-mode .growth-badge.positive {
    background: rgba(16, 185, 129, 0.1);
    color: #065f46;
    border: 1px solid rgba(16, 185, 129, 0.18);
}

body.light-mode .growth-badge.negative {
    background: rgba(239, 68, 68, 0.08);
    color: #991b1b;
    border: 1px solid rgba(239, 68, 68, 0.18);
}

body.light-mode .growth-badge.neutral {
    background: rgba(0, 0, 0, 0.03);
    color: #4b5563;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

/* Custom Share Badges (Kommo and Manual) with High Contrast */
#share-kommo-revenue {
    background: rgba(139, 92, 246, 0.15);
    color: #c4b5fd;
    border: 1px solid rgba(139, 92, 246, 0.25);
}

body.light-mode #share-kommo-revenue {
    background: rgba(139, 92, 246, 0.1);
    color: #6d28d9; /* High-contrast violet for light mode */
    border: 1px solid rgba(139, 92, 246, 0.2);
}

#share-manual-revenue {
    background: rgba(20, 184, 166, 0.15);
    color: #2dd4bf;
    border: 1px solid rgba(20, 184, 166, 0.25);
}

body.light-mode #share-manual-revenue {
    background: rgba(20, 184, 166, 0.1);
    color: #0f766e; /* High-contrast teal for light mode */
    border: 1px solid rgba(20, 184, 166, 0.2);
}

/* Custom Multiselect */
.custom-multiselect {
    position: relative;
    min-width: 220px;
    font-family: var(--font-sans);
}

.select-box {
    background: rgba(17, 12, 34, 0.7);
    border: 1px solid var(--panel-border);
    color: var(--text-primary);
    padding: 0.65rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition-smooth);
    user-select: none;
}

.select-box:hover {
    border-color: var(--color-purple);
}

.arrow-icon {
    font-size: 0.8rem;
    color: var(--text-secondary);
    transition: transform 0.3s ease;
}

.custom-multiselect.open .arrow-icon {
    transform: rotate(180deg);
}

.dropdown-options {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    background: rgba(20, 18, 43, 0.95);
    border: 1px solid var(--panel-border);
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    z-index: 200;
    max-height: 250px;
    overflow-y: auto;
    padding: 0.5rem;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.dropdown-option {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.25rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: var(--transition-smooth);
    user-select: none;
}

.dropdown-option:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.dropdown-option input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border: 1px solid var(--panel-border);
    border-radius: 3px;
    outline: none;
    background: rgba(17, 12, 34, 0.5);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: var(--transition-smooth);
    position: relative;
    min-width: 16px;
}

.dropdown-option input[type="checkbox"]:checked {
    background: var(--color-purple);
    border-color: var(--color-purple);
}

.dropdown-option input[type="checkbox"]:checked::after {
    content: "\f00c";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 0.65rem;
    color: white;
    position: absolute;
}

/* Adaptación para Light Mode */
body.light-mode .select-box {
    background: #ffffff;
    border-color: #d1d5db;
    color: #1f2937;
}

body.light-mode .select-box:hover {
    border-color: #8b5cf6;
}

body.light-mode .dropdown-options {
    background: #ffffff;
    border-color: #d1d5db;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

body.light-mode .dropdown-option {
    color: #4b5563;
}

body.light-mode .dropdown-option:hover {
    background: #f3f4f6;
    color: #111827;
}

body.light-mode .dropdown-option input[type="checkbox"] {
    background: #f9fafb;
    border-color: #d1d5db;
}

body.light-mode .dropdown-option input[type="checkbox"]:checked {
    background: #8b5cf6;
    border-color: #8b5cf6;
}

/* Selector nativo oculto */
.hidden-select {
    display: none !important;
}

/* Estilos de opción de selección única */
.dropdown-option-single {
    padding: 0.5rem 0.75rem;
    border-radius: 0.25rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: var(--transition-smooth);
    user-select: none;
}

.dropdown-option-single:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.dropdown-option-single.active {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    font-weight: 500;
}

/* Modo claro para opción de selección única */
body.light-mode .dropdown-option-single {
    color: #4b5563;
}

body.light-mode .dropdown-option-single:hover {
    background: #f3f4f6;
    color: #111827;
}

body.light-mode .dropdown-option-single.active {
    background: #e5e7eb;
    color: #111827;
    font-weight: 500;
}

/* Column sorting and filtering styles */
.sortable-header {
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: background-color 0.2s ease;
}

.sortable-header:hover {
    background: rgba(255, 255, 255, 0.05) !important;
}

.header-content-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    width: 100%;
}

.header-text-group {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.sort-indicator {
    font-size: 0.75rem;
    color: var(--text-muted);
    opacity: 0.3;
    transition: opacity 0.2s ease, color 0.2s ease;
}

.sortable-header:hover .sort-indicator {
    opacity: 0.7;
}

.sort-indicator.active {
    opacity: 1;
    color: var(--color-blue);
}

.filter-trigger {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 0.2rem 0.35rem;
    border-radius: 3px;
    transition: background-color 0.2s ease, color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.filter-trigger:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.filter-trigger.active {
    color: #10b981; /* Green when filter is active */
    background: rgba(16, 185, 129, 0.1);
}

/* Filter Dropdown Panel */
.column-filter-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 5px;
    background: rgba(20, 18, 43, 0.98);
    border: 1px solid var(--panel-border);
    border-radius: 0.5rem;
    padding: 0.75rem;
    min-width: 220px;
    max-width: 280px;
    z-index: 1000;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    text-align: left;
}

.column-filter-dropdown.hidden {
    display: none !important;
}

.filter-search-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--panel-border);
    border-radius: 0.35rem;
    padding: 0.4rem 0.6rem;
    color: var(--text-primary);
    font-size: 0.8rem;
    outline: none;
    font-family: var(--font-sans);
}

.filter-search-input:focus {
    border-color: var(--color-purple);
}

.filter-options-list {
    max-height: 140px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding-right: 0.25rem;
}

.filter-option-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

.filter-option-item:hover {
    color: var(--text-primary);
}

.filter-option-item input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border: 1px solid var(--panel-border);
    border-radius: 2px;
    outline: none;
    background: rgba(17, 12, 34, 0.5);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.filter-option-item input[type="checkbox"]:checked {
    background: var(--color-purple);
    border-color: var(--color-purple);
}

.filter-option-item input[type="checkbox"]:checked::after {
    content: "\f00c";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 0.55rem;
    color: white;
    position: absolute;
}

.filter-actions {
    display: flex;
    justify-content: space-between;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 0.5rem;
    margin-top: 0.25rem;
}

.btn-filter-action {
    background: none;
    border: none;
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    transition: background-color 0.2s ease;
}

.btn-filter-clear {
    color: var(--text-muted);
}

.btn-filter-clear:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.btn-filter-apply {
    color: #10b981;
    background: rgba(16, 185, 129, 0.1);
}

.btn-filter-apply:hover {
    background: rgba(16, 185, 129, 0.2);
}

/* Light Mode Overrides for Filters */
body.light-mode .column-filter-dropdown {
    background: #ffffff;
    border-color: #d1d5db;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

body.light-mode .filter-search-input {
    background: #f9fafb;
    border-color: #d1d5db;
    color: #1f2937;
}

body.light-mode .filter-option-item {
    color: #4b5563;
}

body.light-mode .filter-option-item:hover {
    color: #111827;
}

body.light-mode .filter-option-item input[type="checkbox"] {
    background: #f9fafb;
    border-color: #d1d5db;
}

body.light-mode .filter-option-item input[type="checkbox"]:checked {
    background: #8b5cf6;
    border-color: #8b5cf6;
}

body.light-mode .btn-filter-clear:hover {
    background: #f3f4f6;
    color: #111827;
}

body.light-mode .btn-filter-apply {
    color: #047857;
    background: rgba(16, 185, 129, 0.1);
}

body.light-mode .btn-filter-apply:hover {
    background: rgba(16, 185, 129, 0.2);
}

/* --- Estilos del Portal de Ventas Manuales --- */
.btn-success-custom {
    background: linear-gradient(135deg, var(--color-green) 0%, #065f46 100%) !important;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3) !important;
    border: none !important;
    color: white !important;
}
.btn-success-custom:hover {
    background: linear-gradient(135deg, #34d399 0%, #047857 100%) !important;
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.45) !important;
    transform: translateY(-2px);
}

.modal-form-width {
    max-width: 550px !important;
    width: 95% !important;
}

.modal-large-width {
    max-width: 950px !important;
    width: 95% !important;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 520px) {
    .form-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-group label .required {
    color: #ef4444;
    margin-left: 0.15rem;
}

.form-group input,
.form-group select {
    background: rgba(20, 15, 15, 0.6);
    border: 1px solid var(--panel-border);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition-smooth);
    width: 100%;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--color-green);
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.15);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    border-top: 1px solid var(--panel-border);
    padding-top: 1.25rem;
    margin-top: 0.5rem;
}

.modal-desc-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    line-height: 1.4;
}

/* Light mode overrides para el formulario */
body.light-mode .form-group input,
body.light-mode .form-group select {
    background: #ffffff;
    border-color: #d1d5db;
    color: #1f2937;
}

body.light-mode .form-group input:focus,
body.light-mode .form-group select:focus {
    border-color: #059669;
    box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.15);
}

body.light-mode .modal-desc-text {
    color: #4b5563;
}

/* Estilo para botón de borrar venta en tabla */
.btn-delete-sale {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 0.35rem 0.65rem;
    border-radius: 0.35rem;
    cursor: pointer;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    transition: var(--transition-smooth);
}

.btn-delete-sale:hover {
    background: #ef4444;
    color: white;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

body.light-mode .btn-delete-sale {
    background: rgba(220, 38, 38, 0.08);
    color: #dc2626;
    border-color: rgba(220, 38, 38, 0.15);
}

body.light-mode .btn-delete-sale:hover {
    background: #dc2626;
    color: white;
}

/* Sistema de Notificaciones Push Toast (Arriba a la Derecha) */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 999999 !important; /* Por encima de cualquier modal o overlay */
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: none;
    max-width: 440px;
    width: 90%;
}

.toast {
    pointer-events: auto;
    background: #1e293b;
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 1rem 1.25rem;
    border-radius: 0.75rem;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 0.85rem;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.4;
    animation: toastPushIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    transition: all 0.3s ease;
}

@keyframes toastPushIn {
    from {
        opacity: 0;
        transform: translateX(60px) scale(0.88);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

.toast-error {
    background: #991b1b !important;
    border-color: #f87171 !important;
    color: #ffffff !important;
    box-shadow: 0 12px 35px rgba(220, 38, 38, 0.45) !important;
}

.toast-success {
    background: #065f46 !important;
    border-color: #34d399 !important;
    color: #ffffff !important;
    box-shadow: 0 12px 35px rgba(16, 185, 129, 0.4) !important;
}

.toast-info {
    background: #1e40af !important;
    border-color: #60a5fa !important;
    color: #ffffff !important;
}

/* ==========================================
   --- ESTILOS UNIFICADOS Y ROBUSTOS DE MODALES ---
   ========================================== */
.modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.78) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    z-index: 10000 !important;
    padding: 1rem !important;
    box-sizing: border-box !important;
}

.modal-overlay.hidden {
    display: none !important;
}

.modal-content,
.modal-card {
    background: var(--panel-bg, rgba(6, 5, 5, 0.95)) !important;
    border: 1px solid var(--panel-border, rgba(255, 255, 255, 0.1)) !important;
    border-radius: 1rem !important;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.85) !important;
    width: 96vw !important;
    max-width: 1480px !important;
    max-height: 90vh !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    position: relative !important;
}

.modal-form-width {
    max-width: 550px !important;
}

.modal-large-width {
    max-width: 1100px !important;
}

.modal-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 1rem 1.5rem !important;
    border-bottom: 1px solid var(--panel-border, rgba(255, 255, 255, 0.08)) !important;
    flex-shrink: 0 !important;
    background: rgba(255, 255, 255, 0.02) !important;
}

.modal-header h2,
.modal-header h3 {
    margin: 0 !important;
    font-size: 1.15rem !important;
    font-weight: 700 !important;
    color: var(--text-primary, #ededed) !important;
    display: flex !important;
    align-items: center !important;
    gap: 0.5rem !important;
}

.modal-close,
.btn-close {
    background: none !important;
    border: none !important;
    color: var(--text-muted, #8e8e8e) !important;
    font-size: 1.5rem !important;
    cursor: pointer !important;
    line-height: 1 !important;
    padding: 0.2rem 0.5rem !important;
    border-radius: 0.35rem !important;
    transition: var(--transition-smooth, all 0.2s ease) !important;
}

.modal-close:hover,
.btn-close:hover {
    color: var(--text-primary, #ffffff) !important;
    background: rgba(255, 255, 255, 0.1) !important;
}

.modal-body {
    padding: 1.25rem 1.5rem !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    flex-grow: 1 !important;
    display: flex !important;
    flex-direction: column !important;
}

.table-wrapper {
    width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding-bottom: 0.5rem !important;
    margin-bottom: 0.5rem !important;
}

.details-table {
    width: 100% !important;
    min-width: 100% !important;
    border-collapse: collapse !important;
    font-size: 0.82rem !important;
    text-align: left !important;
}

.details-table th {
    padding: 0.6rem 0.75rem !important;
    background: rgba(255, 255, 255, 0.04) !important;
    color: var(--text-secondary, #c6c6c6) !important;
    font-weight: 600 !important;
    font-size: 0.78rem !important;
    border-bottom: 1px solid var(--panel-border, rgba(255, 255, 255, 0.08)) !important;
    white-space: nowrap !important;
}

.details-table td {
    padding: 0.55rem 0.75rem !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04) !important;
    color: var(--text-primary, #ededed) !important;
    vertical-align: middle !important;
    white-space: nowrap !important;
}

.btn-table {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.35rem !important;
    padding: 0.3rem 0.65rem !important;
    font-size: 0.75rem !important;
    font-weight: 600 !important;
    color: #ef4444 !important;
    background: rgba(239, 68, 68, 0.12) !important;
    border: 1px solid rgba(239, 68, 68, 0.25) !important;
    border-radius: 0.4rem !important;
    cursor: pointer !important;
    white-space: nowrap !important;
    transition: var(--transition-smooth) !important;
}

.btn-table:hover {
    background: #ef4444 !important;
    color: #ffffff !important;
    border-color: #ef4444 !important;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3) !important;
}

/* Light mode overrides para modales */
body.light-mode .modal-content,
body.light-mode .modal-card {
    background: #ffffff !important;
    border-color: #e2e8f0 !important;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15) !important;
}

body.light-mode .modal-header {
    background: #f8fafc !important;
    border-color: #e2e8f0 !important;
}

body.light-mode .modal-header h2,
body.light-mode .modal-header h3 {
    color: #0f172a !important;
}

body.light-mode .details-table th {
    background: #f1f5f9 !important;
    color: #334155 !important;
    border-color: #e2e8f0 !important;
}

body.light-mode .details-table td {
    color: #0f172a !important;
    border-color: #e2e8f0 !important;
}

/* Acciones de exportación en cabecera de modales */
.modal-header-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
    margin-right: 15px;
    align-items: center;
}

.btn-modal-export {
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    background: rgba(255, 255, 255, 0.04) !important;
    color: var(--text-primary) !important;
    border-radius: 6px !important;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-modal-export:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    border-color: rgba(255, 255, 255, 0.15) !important;
    transform: translateY(-1px);
}

.btn-modal-export:active {
    transform: translateY(0);
}

/* Soporte para modo claro */
body.light-mode .btn-modal-export {
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
    background: rgba(0, 0, 0, 0.04) !important;
    color: var(--text-primary) !important;
}

body.light-mode .btn-modal-export:hover {
    background: rgba(0, 0, 0, 0.08) !important;
    border-color: rgba(0, 0, 0, 0.15) !important;
}




