/*!
 * Trinity Design System v2.0
 * Professional CSS framework for Trinity Platform
 * Copyright (c) REDI TO RUN 2024-2026
 */

/* =====================================================
   1. CSS CUSTOM PROPERTIES (Design Tokens)
===================================================== */
:root {
    /* Brand Colors */
    --t-primary: #FF6B35;
    --t-primary-hover: #E55A2B;
    --t-primary-light: #FFF0EB;
    --t-primary-subtle: rgba(255, 107, 53, 0.08);
    --t-primary-rgb: 255, 107, 53;
    
    --t-secondary: #1A1D21;
    --t-secondary-light: #2D3238;
    
    --t-accent: #FFB800;
    --t-accent-light: #FFF8E1;
    
    /* Semantic Colors */
    --t-success: #10B981;
    --t-success-light: #ECFDF5;
    --t-success-rgb: 16, 185, 129;
    
    --t-danger: #EF4444;
    --t-danger-light: #FEF2F2;
    --t-danger-rgb: 239, 68, 68;
    
    --t-warning: #F59E0B;
    --t-warning-light: #FFFBEB;
    --t-warning-rgb: 245, 158, 11;
    
    --t-info: #3B82F6;
    --t-info-light: #EFF6FF;
    --t-info-rgb: 59, 130, 246;
    
    /* Neutrals */
    --t-gray-50: #F9FAFB;
    --t-gray-100: #F3F4F6;
    --t-gray-200: #E5E7EB;
    --t-gray-300: #D1D5DB;
    --t-gray-400: #9CA3AF;
    --t-gray-500: #6B7280;
    --t-gray-600: #4B5563;
    --t-gray-700: #374151;
    --t-gray-800: #1F2937;
    --t-gray-900: #111827;
    
    --t-white: #FFFFFF;
    --t-black: #000000;
    
    /* Background */
    --t-bg-primary: #F8FAFC;
    --t-bg-card: #FFFFFF;
    --t-bg-sidebar: #1A1D21;
    --t-bg-topbar: #1A1D21;
    
    /* Typography */
    --t-font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --t-font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace;
    
    --t-text-xs: 0.75rem;    /* 12px */
    --t-text-sm: 0.8125rem;  /* 13px */
    --t-text-base: 0.875rem; /* 14px */
    --t-text-md: 1rem;       /* 16px */
    --t-text-lg: 1.125rem;   /* 18px */
    --t-text-xl: 1.25rem;    /* 20px */
    --t-text-2xl: 1.5rem;    /* 24px */
    --t-text-3xl: 1.875rem;  /* 30px */
    
    --t-font-normal: 400;
    --t-font-medium: 500;
    --t-font-semibold: 600;
    --t-font-bold: 700;
    
    /* Spacing */
    --t-space-1: 0.25rem;   /* 4px */
    --t-space-2: 0.5rem;    /* 8px */
    --t-space-3: 0.75rem;   /* 12px */
    --t-space-4: 1rem;      /* 16px */
    --t-space-5: 1.25rem;   /* 20px */
    --t-space-6: 1.5rem;    /* 24px */
    --t-space-8: 2rem;      /* 32px */
    --t-space-10: 2.5rem;   /* 40px */
    --t-space-12: 3rem;     /* 48px */
    
    /* Border Radius */
    --t-radius-sm: 0.375rem;  /* 6px */
    --t-radius-md: 0.5rem;    /* 8px */
    --t-radius-lg: 0.75rem;   /* 12px */
    --t-radius-xl: 1rem;      /* 16px */
    --t-radius-2xl: 1.25rem;  /* 20px */
    --t-radius-full: 9999px;
    
    /* Shadows */
    --t-shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
    --t-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    --t-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
    --t-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --t-shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
    --t-shadow-inner: inset 0 2px 4px rgba(0, 0, 0, 0.05);
    --t-shadow-focus: 0 0 0 3px rgba(var(--t-primary-rgb), 0.2);
    
    /* Transitions */
    --t-transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --t-transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --t-transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Layout */
    --t-sidebar-width: 260px;
    --t-topbar-height: 60px;
    --t-content-max-width: 1400px;
}

/* =====================================================
   2. GOOGLE FONTS IMPORT
===================================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* =====================================================
   3. BASE / RESET
===================================================== */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: var(--t-font-family);
    font-size: var(--t-text-base);
    font-weight: var(--t-font-normal);
    line-height: 1.6;
    color: var(--t-gray-800);
    background-color: var(--t-bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    margin: 0;
    min-height: 100vh;
}

/* Sobrescribir azul de Bootstrap _reboot.scss (#0d6efd) */
a {
    color: var(--t-primary) !important;
    text-decoration: none;
    transition: color var(--t-transition-fast);
}

a:hover {
    color: var(--t-primary-hover) !important;
}

::selection {
    background: rgba(var(--t-primary-rgb), 0.15);
    color: var(--t-gray-900);
}

/* =====================================================
   4. TOPBAR
===================================================== */
.t-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--t-topbar-height);
    background: var(--t-bg-topbar);
    display: flex;
    align-items: center;
    padding: 0 var(--t-space-6);
    z-index: 1050;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.t-topbar__brand {
    display: flex;
    align-items: center;
    gap: var(--t-space-3);
    width: var(--t-sidebar-width);
    padding-right: var(--t-space-4);
    text-decoration: none;
    flex-shrink: 0;
}

.t-topbar__brand-logo {
    width: 32px;
    height: 32px;
    border-radius: var(--t-radius-md);
}

.t-topbar__brand-text {
    font-size: var(--t-text-lg);
    font-weight: var(--t-font-bold);
    color: var(--t-primary);
    letter-spacing: 0.5px;
}

.t-topbar__toggle {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.125rem;
    padding: var(--t-space-2);
    cursor: pointer;
    border-radius: var(--t-radius-sm);
    transition: all var(--t-transition-fast);
    margin-right: var(--t-space-4);
}

.t-topbar__toggle:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.t-topbar__center {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.t-topbar__right {
    display: flex;
    align-items: center;
    gap: var(--t-space-3);
    margin-left: auto;
}

/* Company Selector in Topbar */
.t-company-selector {
    display: flex;
    align-items: center;
    gap: var(--t-space-2);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--t-radius-md);
    padding: var(--t-space-1) var(--t-space-3);
    transition: all var(--t-transition-fast);
}

.t-company-selector:focus-within {
    border-color: var(--t-primary);
    background: rgba(255, 255, 255, 0.1);
}

.t-company-selector__label {
    font-size: var(--t-text-xs);
    color: rgba(255, 255, 255, 0.45);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.t-company-selector__select {
    background: transparent;
    border: none;
    color: #fff;
    font-size: var(--t-text-sm);
    font-family: var(--t-font-family);
    padding: var(--t-space-1) var(--t-space-2);
    min-width: 180px;
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
}

.t-company-selector__select option {
    background: var(--t-gray-800);
    color: #fff;
}

/* User Menu */
.t-user-menu {
    position: relative;
}

.t-user-menu__trigger {
    display: flex;
    align-items: center;
    gap: var(--t-space-2);
    padding: var(--t-space-1) var(--t-space-3);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--t-radius-full);
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: all var(--t-transition-fast);
    font-family: var(--t-font-family);
    font-size: var(--t-text-sm);
}

.t-user-menu__trigger:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.t-user-menu__avatar {
    width: 30px;
    height: 30px;
    border-radius: var(--t-radius-full);
    background: linear-gradient(135deg, var(--t-primary), var(--t-primary-hover));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--t-text-sm);
    font-weight: var(--t-font-semibold);
    color: #fff;
}

/* =====================================================
   5. SIDEBAR
===================================================== */
.t-sidebar {
    position: fixed;
    top: var(--t-topbar-height);
    left: 0;
    width: var(--t-sidebar-width);
    height: calc(100vh - var(--t-topbar-height));
    background: var(--t-bg-sidebar);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform var(--t-transition-slow);
    overflow: hidden;
}

.t-sidebar__menu {
    flex: 1;
    overflow-y: auto;
    padding: var(--t-space-4) 0;
}

/* Forzar la lista del sidebar a comportarse como columna, sin flexbox complejo */
.t-sidebar__menu .nav {
    display: block;
}

.t-sidebar__menu .nav > * {
    width: 100%;
}

/* Custom Scrollbar */
.t-sidebar__menu::-webkit-scrollbar {
    width: 4px;
}

.t-sidebar__menu::-webkit-scrollbar-track {
    background: transparent;
}

.t-sidebar__menu::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 2px;
}

.t-sidebar__menu::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Menu Heading */
.t-sidebar__heading {
    padding: var(--t-space-5) var(--t-space-5) var(--t-space-2);
    font-size: 0.6875rem;
    font-weight: var(--t-font-semibold);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.3);
}

/* Menu Link - !important para ganar sobre Bootstrap _reboot.scss (a) */
.t-sidebar__link {
    display: flex;
    align-items: center;
    padding: var(--t-space-2) var(--t-space-5);
    margin: 1px var(--t-space-2);
    color: rgba(255, 255, 255, 0.8) !important;
    font-size: var(--t-text-sm);
    font-weight: var(--t-font-medium);
    border-radius: var(--t-radius-md);
    transition: all var(--t-transition-fast);
    cursor: pointer;
    text-decoration: none !important;
    position: relative;
}

.t-sidebar__link:hover {
    color: rgba(255, 255, 255, 0.9) !important;
    background: rgba(255, 255, 255, 0.06);
}

.t-sidebar__link.active {
    color: #fff !important;
    background: rgba(var(--t-primary-rgb), 0.15);
}

.t-sidebar__link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 4px;
    bottom: 4px;
    width: 3px;
    background: var(--t-primary);
    border-radius: 0 2px 2px 0;
}

.t-sidebar__link-icon {
    width: 20px;
    text-align: center;
    margin-right: var(--t-space-3);
    font-size: var(--t-text-base);
    opacity: 0.7;
}

.t-sidebar__link.active .t-sidebar__link-icon {
    color: var(--t-primary);
    opacity: 1;
}

/* Submenu Toggle Arrow */
.t-sidebar__arrow {
    margin-left: auto;
    font-size: 0.7rem;
    transition: transform var(--t-transition-fast);
    opacity: 0.5;
}

.t-sidebar__link.collapsed .t-sidebar__arrow {
    transform: rotate(-90deg);
}

/* Nested Menu */
.t-sidebar__nested {
    padding-left: var(--t-space-8);
}

.t-sidebar__nested .t-sidebar__link {
    font-size: var(--t-text-xs);
    padding: 6px var(--t-space-4);
    margin: 0 var(--t-space-2);
}

/* Status Circle Indicators */
.circle {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    vertical-align: middle;
}

.circle.verde {
    background-color: #22c55e;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.45);
}

.circle.naranja {
    background-color: #f59e0b;
    box-shadow: 0 0 6px rgba(245, 158, 11, 0.45);
    animation: pulse-dot 1.5s ease-in-out infinite;
}

.circle.rojo {
    background-color: #ef4444;
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.45);
}

.circle.gris {
    background-color: #94a3b8;
    box-shadow: 0 0 4px rgba(148, 163, 184, 0.3);
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Sidebar Footer */
.t-sidebar__footer {
    padding: var(--t-space-4) var(--t-space-5);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(0, 0, 0, 0.15);
}

.t-sidebar__user {
    display: flex;
    align-items: center;
    gap: var(--t-space-3);
    margin-bottom: var(--t-space-3);
}

.t-sidebar__user-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--t-radius-full);
    background: linear-gradient(135deg, var(--t-primary), var(--t-primary-hover));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--t-text-sm);
    font-weight: var(--t-font-semibold);
    color: #fff;
    flex-shrink: 0;
}

.t-sidebar__user-info {
    overflow: hidden;
}

.t-sidebar__user-label {
    font-size: 0.6875rem;
    color: rgba(255, 255, 255, 0.35);
}

.t-sidebar__user-name {
    font-size: var(--t-text-sm);
    font-weight: var(--t-font-medium);
    color: rgba(255, 255, 255, 0.8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.t-sidebar__logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--t-space-2);
    width: 100%;
    padding: var(--t-space-2) var(--t-space-3);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--t-radius-md);
    color: rgba(255, 255, 255, 0.6);
    font-size: var(--t-text-xs);
    font-family: var(--t-font-family);
    cursor: pointer;
    transition: all var(--t-transition-fast);
}

.t-sidebar__logout:hover {
    background: rgba(var(--t-danger-rgb), 0.15);
    border-color: rgba(var(--t-danger-rgb), 0.3);
    color: var(--t-danger);
}

/* =====================================================
   6. MAIN CONTENT AREA
===================================================== */
.t-layout {
    display: flex;
    min-height: 100vh;
}

.t-content {
    flex: 1;
    margin-left: var(--t-sidebar-width);
    padding-top: var(--t-topbar-height);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left var(--t-transition-slow);
}

.t-content__main {
    flex: 1;
    padding: var(--t-space-6);
    max-width: var(--t-content-max-width);
    width: 100%;
    margin: 0 auto;
}

/* Page Header */
.t-page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--t-space-6);
    flex-wrap: wrap;
    gap: var(--t-space-4);
}

.t-page-header__title {
    font-size: var(--t-text-2xl);
    font-weight: var(--t-font-bold);
    color: var(--t-gray-900);
    margin: 0;
    line-height: 1.3;
}

.t-page-header__subtitle {
    font-size: var(--t-text-sm);
    color: var(--t-gray-500);
    margin-top: var(--t-space-1);
}

/* Breadcrumb */
.t-breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--t-space-2);
    font-size: var(--t-text-sm);
    color: var(--t-gray-400);
    margin-bottom: var(--t-space-1);
}

.t-breadcrumb a {
    color: var(--t-gray-500);
}

.t-breadcrumb a:hover {
    color: var(--t-primary);
}

.t-breadcrumb__separator {
    font-size: 0.625rem;
}

.t-breadcrumb__current {
    color: var(--t-gray-700);
    font-weight: var(--t-font-medium);
}

/* Footer */
.t-footer {
    padding: var(--t-space-5) var(--t-space-6);
    background: var(--t-white);
    border-top: 1px solid var(--t-gray-200);
    font-size: var(--t-text-xs);
    color: var(--t-gray-400);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--t-space-2);
}

.t-footer a {
    color: var(--t-gray-500);
}

.t-footer a:hover {
    color: var(--t-primary);
}

/* =====================================================
   7. CARDS
===================================================== */
.t-card {
    background: var(--t-bg-card);
    border: 1px solid var(--t-gray-200);
    border-radius: var(--t-radius-lg);
    box-shadow: var(--t-shadow-xs);
    overflow: hidden;
    transition: box-shadow var(--t-transition-fast);
}

.t-card:hover {
    box-shadow: var(--t-shadow-sm);
}

.t-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--t-space-5) var(--t-space-6);
    border-bottom: 1px solid var(--t-gray-100);
}

.t-card__title {
    font-size: var(--t-text-md);
    font-weight: var(--t-font-semibold);
    color: var(--t-gray-900);
    margin: 0;
}

.t-card__body {
    padding: var(--t-space-6);
}

.t-card__footer {
    padding: var(--t-space-4) var(--t-space-6);
    background: var(--t-gray-50);
    border-top: 1px solid var(--t-gray-100);
}

/* =====================================================
   8. STAT CARDS (Dashboard)
===================================================== */
.t-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--t-space-5);
    margin-bottom: var(--t-space-6);
}

.t-stat-card {
    background: var(--t-bg-card);
    border: 1px solid var(--t-gray-200);
    border-radius: var(--t-radius-lg);
    padding: var(--t-space-5);
    display: flex;
    align-items: center;
    gap: var(--t-space-4);
    box-shadow: var(--t-shadow-xs);
    transition: all var(--t-transition-fast);
}

.t-stat-card:hover {
    box-shadow: var(--t-shadow-md);
    transform: translateY(-1px);
}

.t-stat-card__icon {
    width: 48px;
    height: 48px;
    border-radius: var(--t-radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.t-stat-card__icon--primary {
    background: var(--t-primary-light);
    color: var(--t-primary);
}

.t-stat-card__icon--success {
    background: var(--t-success-light);
    color: var(--t-success);
}

.t-stat-card__icon--warning {
    background: var(--t-warning-light);
    color: var(--t-warning);
}

.t-stat-card__icon--danger {
    background: var(--t-danger-light);
    color: var(--t-danger);
}

.t-stat-card__icon--info {
    background: var(--t-info-light);
    color: var(--t-info);
}

.t-stat-card__value {
    font-size: var(--t-text-2xl);
    font-weight: var(--t-font-bold);
    color: var(--t-gray-900);
    line-height: 1.2;
}

.t-stat-card__label {
    font-size: var(--t-text-sm);
    color: var(--t-gray-500);
    margin-top: 2px;
}

/* =====================================================
   9. TABLES
===================================================== */
.t-table-wrapper {
    background: var(--t-bg-card);
    border: 1px solid var(--t-gray-200);
    border-radius: var(--t-radius-lg);
    overflow: hidden;
    box-shadow: var(--t-shadow-xs);
}

.t-table-wrapper .table,
.t-card__body .table,
.t-card__body.p-0 + .table {
    margin: 0;
}

.t-table-wrapper .table thead th,
.t-card__body .table thead th,
.t-card .table thead th {
    background: var(--t-gray-50);
    border-bottom: 2px solid var(--t-gray-200);
    font-size: var(--t-text-xs);
    font-weight: var(--t-font-semibold);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--t-gray-500);
    padding: var(--t-space-3) var(--t-space-4);
    white-space: nowrap;
}

.t-table-wrapper .table tbody td,
.t-card__body .table tbody td,
.t-card .table tbody td {
    padding: var(--t-space-3) var(--t-space-4);
    vertical-align: middle;
    color: var(--t-gray-700);
    font-size: var(--t-text-sm);
    border-bottom: 1px solid var(--t-gray-100);
}

.t-table-wrapper .table tbody tr:last-child td,
.t-card .table tbody tr:last-child td {
    border-bottom: none;
}

.t-table-wrapper .table-hover tbody tr:hover,
.t-card .table-hover tbody tr:hover {
    background: rgba(var(--t-primary-rgb), 0.03);
}

/* DataTables Override */
.t-table-wrapper .dataTables_wrapper {
    padding: var(--t-space-4);
}

.t-table-wrapper .dataTables_wrapper .dataTables_length,
.t-table-wrapper .dataTables_wrapper .dataTables_filter {
    margin-bottom: var(--t-space-4);
}

.t-table-wrapper .dataTables_wrapper .dataTables_length select,
.t-table-wrapper .dataTables_wrapper .dataTables_filter input {
    border: 1px solid var(--t-gray-300);
    border-radius: var(--t-radius-sm);
    padding: var(--t-space-1) var(--t-space-3);
    font-size: var(--t-text-sm);
    font-family: var(--t-font-family);
}

.t-table-wrapper .dataTables_wrapper .dataTables_filter input:focus {
    outline: none;
    border-color: var(--t-primary);
    box-shadow: var(--t-shadow-focus);
}

.t-table-wrapper .dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: var(--t-radius-sm) !important;
    font-size: var(--t-text-sm) !important;
    padding: 4px 10px !important;
}

.t-table-wrapper .dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--t-primary) !important;
    border-color: var(--t-primary) !important;
    color: #fff !important;
}

.t-table-wrapper .dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--t-primary-hover) !important;
    border-color: var(--t-primary-hover) !important;
    color: #fff !important;
}

/* =====================================================
   10. BUTTONS
===================================================== */
.t-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--t-space-2);
    padding: var(--t-space-2) var(--t-space-4);
    font-size: var(--t-text-sm);
    font-weight: var(--t-font-medium);
    font-family: var(--t-font-family);
    line-height: 1.5;
    border-radius: var(--t-radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--t-transition-fast);
    white-space: nowrap;
    text-decoration: none;
}

.t-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
}

.t-btn--primary {
    background: var(--t-primary);
    color: #fff;
    border-color: var(--t-primary);
}

.t-btn--primary:hover {
    background: var(--t-primary-hover);
    border-color: var(--t-primary-hover);
    color: #fff;
    box-shadow: 0 2px 8px rgba(var(--t-primary-rgb), 0.3);
}

.t-btn--secondary {
    background: var(--t-white);
    color: var(--t-gray-700);
    border-color: var(--t-gray-300);
}

.t-btn--secondary:hover {
    background: var(--t-gray-50);
    border-color: var(--t-gray-400);
    color: var(--t-gray-900);
}

.t-btn--danger {
    background: var(--t-danger);
    color: #fff;
    border-color: var(--t-danger);
}

.t-btn--danger:hover {
    background: #DC2626;
    border-color: #DC2626;
    color: #fff;
}

.t-btn--ghost {
    background: transparent;
    color: var(--t-gray-600);
    border-color: transparent;
}

.t-btn--ghost:hover {
    background: var(--t-gray-100);
    color: var(--t-gray-900);
}

.t-btn--sm {
    padding: var(--t-space-1) var(--t-space-3);
    font-size: var(--t-text-xs);
}

.t-btn--lg {
    padding: var(--t-space-3) var(--t-space-6);
    font-size: var(--t-text-md);
}

.t-btn--block {
    width: 100%;
}

.t-btn--icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--t-radius-md);
}

.t-btn--icon.t-btn--sm {
    width: 28px;
    height: 28px;
}

/* =====================================================
   11. FORMS
===================================================== */
.t-form-group {
    margin-bottom: var(--t-space-5);
}

.t-form-label {
    display: block;
    margin-bottom: var(--t-space-2);
    font-size: var(--t-text-sm);
    font-weight: var(--t-font-medium);
    color: var(--t-gray-700);
}

.t-form-label--required::after {
    content: ' *';
    color: var(--t-danger);
}

.t-form-input {
    display: block;
    width: 100%;
    padding: var(--t-space-2) var(--t-space-3);
    font-size: var(--t-text-sm);
    font-family: var(--t-font-family);
    color: var(--t-gray-800);
    background: var(--t-white);
    border: 1px solid var(--t-gray-300);
    border-radius: var(--t-radius-md);
    transition: all var(--t-transition-fast);
    line-height: 1.5;
}

.t-form-input:focus {
    outline: none;
    border-color: var(--t-primary);
    box-shadow: var(--t-shadow-focus);
}

.t-form-input::placeholder {
    color: var(--t-gray-400);
}

.t-form-input--error {
    border-color: var(--t-danger);
}

.t-form-input--error:focus {
    box-shadow: 0 0 0 3px rgba(var(--t-danger-rgb), 0.15);
}

.t-form-error {
    display: block;
    margin-top: var(--t-space-1);
    font-size: var(--t-text-xs);
    color: var(--t-danger);
}

.t-form-hint {
    display: block;
    margin-top: var(--t-space-1);
    font-size: var(--t-text-xs);
    color: var(--t-gray-400);
}

select.t-form-input {
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%236B7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 12px;
    padding-right: 2.5rem;
}

textarea.t-form-input {
    min-height: 100px;
    resize: vertical;
}

/* =====================================================
   12. BADGES
===================================================== */
.t-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    font-size: 0.6875rem;
    font-weight: var(--t-font-semibold);
    border-radius: var(--t-radius-full);
    letter-spacing: 0.02em;
}

.t-badge--success {
    background: var(--t-success-light);
    color: var(--t-success);
}

.t-badge--danger {
    background: var(--t-danger-light);
    color: var(--t-danger);
}

.t-badge--warning {
    background: var(--t-warning-light);
    color: #92400E;
}

.t-badge--info {
    background: var(--t-info-light);
    color: #1D4ED8;
}

.t-badge--secondary {
    background: var(--t-gray-100);
    color: var(--t-gray-600);
}

.t-badge--primary {
    background: var(--t-primary-light);
    color: var(--t-primary);
}

/* DB Type Badges */
.t-badge--postgresql { background: #E8EEF4; color: #336791; }
.t-badge--mysql { background: #E5F2F5; color: #00758f; }
.t-badge--mssql { background: #FBE9E9; color: #cc2927; }
.t-badge--oracle { background: #FEF0E5; color: #C74634; }
.t-badge--folder { background: var(--t-gray-100); color: var(--t-gray-600); }
.t-badge--drive { background: #EBF2FE; color: #4285f4; }
.t-badge--s3 { background: #FFF4E5; color: #ff9900; }

/* =====================================================
   13. TOAST NOTIFICATIONS
===================================================== */
.t-toast-container {
    position: fixed;
    top: calc(var(--t-topbar-height) + var(--t-space-4));
    right: var(--t-space-4);
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: var(--t-space-3);
    max-width: 400px;
}

.t-toast {
    background: var(--t-white);
    border-radius: var(--t-radius-lg);
    box-shadow: var(--t-shadow-lg);
    padding: var(--t-space-4);
    display: flex;
    align-items: flex-start;
    gap: var(--t-space-3);
    border-left: 4px solid;
    animation: t-toast-in 0.3s ease-out;
    min-width: 320px;
}

.t-toast--success { border-left-color: var(--t-success); }
.t-toast--error { border-left-color: var(--t-danger); }
.t-toast--warning { border-left-color: var(--t-warning); }
.t-toast--info { border-left-color: var(--t-info); }

.t-toast__icon {
    font-size: 1.125rem;
    flex-shrink: 0;
    margin-top: 1px;
}

.t-toast--success .t-toast__icon { color: var(--t-success); }
.t-toast--error .t-toast__icon { color: var(--t-danger); }
.t-toast--warning .t-toast__icon { color: var(--t-warning); }
.t-toast--info .t-toast__icon { color: var(--t-info); }

.t-toast__content { flex: 1; }
.t-toast__title {
    font-weight: var(--t-font-semibold);
    font-size: var(--t-text-sm);
    color: var(--t-gray-900);
    margin-bottom: 2px;
}
.t-toast__message {
    font-size: var(--t-text-xs);
    color: var(--t-gray-500);
    line-height: 1.5;
}

.t-toast__close {
    background: none;
    border: none;
    color: var(--t-gray-400);
    cursor: pointer;
    padding: 2px;
    font-size: var(--t-text-sm);
    line-height: 1;
    transition: color var(--t-transition-fast);
    flex-shrink: 0;
}

.t-toast__close:hover {
    color: var(--t-gray-700);
}

@keyframes t-toast-in {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes t-toast-out {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(30px); }
}

.t-toast--exiting {
    animation: t-toast-out 0.25s ease-in forwards;
}

/* =====================================================
   14. MODALS
===================================================== */

/* Custom modal overlay (used by companies, contacts, DQ) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--t-space-4);
}

.modal-overlay > .modal-content {
    position: relative;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    background: #fff;
    border: none;
    border-radius: var(--t-radius-xl);
    box-shadow: var(--t-shadow-xl);
    display: flex;
    flex-direction: column;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--t-gray-500);
    cursor: pointer;
    padding: 0;
    transition: color 0.15s;
}

.modal-close:hover {
    color: var(--t-gray-900);
}

/* Bootstrap modal overrides */
.modal-content {
    border: none;
    border-radius: var(--t-radius-xl);
    box-shadow: var(--t-shadow-xl);
}

.modal-header {
    border-bottom: 1px solid var(--t-gray-100);
    padding: var(--t-space-5) var(--t-space-6);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-weight: var(--t-font-semibold);
    font-size: var(--t-text-lg);
    color: var(--t-gray-900);
}

.modal-body {
    padding: var(--t-space-6);
}

.modal-footer {
    border-top: 1px solid var(--t-gray-100);
    padding: var(--t-space-4) var(--t-space-6);
    gap: var(--t-space-2);
}

/* =====================================================
   15. LOADING & EMPTY STATES
===================================================== */
.t-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--t-space-12);
    flex-direction: column;
    gap: var(--t-space-4);
}

.t-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--t-gray-200);
    border-top-color: var(--t-primary);
    border-radius: 50%;
    animation: t-spin 0.7s linear infinite;
}

@keyframes t-spin {
    to { transform: rotate(360deg); }
}

.t-loading__text {
    font-size: var(--t-text-sm);
    color: var(--t-gray-400);
}

.t-empty-state {
    text-align: center;
    padding: var(--t-space-12) var(--t-space-6);
}

.t-empty-state__icon {
    font-size: 3rem;
    color: var(--t-gray-300);
    margin-bottom: var(--t-space-4);
}

.t-empty-state__title {
    font-size: var(--t-text-lg);
    font-weight: var(--t-font-semibold);
    color: var(--t-gray-700);
    margin-bottom: var(--t-space-2);
}

.t-empty-state__text {
    font-size: var(--t-text-sm);
    color: var(--t-gray-400);
    max-width: 400px;
    margin: 0 auto;
}

/* =====================================================
   16. RESPONSIVE
===================================================== */
@media (max-width: 991.98px) {
    .t-sidebar {
        transform: translateX(-100%);
    }
    
    .t-sidebar.is-open {
        transform: translateX(0);
    }
    
    .t-content {
        margin-left: 0;
    }
    
    /* Overlay when sidebar open on mobile */
    .t-sidebar-overlay {
        display: none;
        position: fixed;
        top: var(--t-topbar-height);
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 1035;
        backdrop-filter: blur(2px);
    }
    
    .t-sidebar-overlay.is-visible {
        display: block;
    }
    
    .t-topbar__brand {
        width: auto;
    }
}

/* Sidebar Toggle (Desktop) */
body.t-sidebar-collapsed .t-sidebar {
    transform: translateX(calc(-1 * var(--t-sidebar-width)));
}

body.t-sidebar-collapsed .t-content {
    margin-left: 0;
}

@media (max-width: 768px) {
    .t-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .t-content__main {
        padding: var(--t-space-4);
    }
    
    .t-page-header {
        flex-direction: column;
    }
}

@media (max-width: 576px) {
    .t-stats-grid {
        grid-template-columns: 1fr;
    }
}

/* =====================================================
   17. UTILITY CLASSES
===================================================== */
.t-text-primary { color: var(--t-primary) !important; }
.t-text-success { color: var(--t-success) !important; }
.t-text-danger { color: var(--t-danger) !important; }
.t-text-warning { color: var(--t-warning) !important; }
.t-text-muted { color: var(--t-gray-500) !important; }
.t-text-mono { font-family: var(--t-font-mono) !important; }

.t-bg-primary-light { background: var(--t-primary-light) !important; }
.t-bg-success-light { background: var(--t-success-light) !important; }
.t-bg-danger-light { background: var(--t-danger-light) !important; }
.t-bg-warning-light { background: var(--t-warning-light) !important; }

.t-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

@keyframes t-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.t-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Content area iframes */
.t-iframe-container {
    width: 100%;
    height: calc(100vh - var(--t-topbar-height) - 120px);
    border: 1px solid var(--t-gray-200);
    border-radius: var(--t-radius-lg);
    overflow: hidden;
}

.t-iframe-container iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* =====================================================
   18. BACKWARDS COMPATIBILITY
   These map old Bootstrap/SB Admin classes to new design
===================================================== */

/* Ensure Bootstrap 5 components follow our design token colors */
.btn-primary {
    --bs-btn-bg: var(--t-primary);
    --bs-btn-border-color: var(--t-primary);
    --bs-btn-hover-bg: var(--t-primary-hover);
    --bs-btn-hover-border-color: var(--t-primary-hover);
    --bs-btn-active-bg: var(--t-primary-hover);
    --bs-btn-active-border-color: var(--t-primary-hover);
    --bs-btn-focus-shadow-rgb: var(--t-primary-rgb);
}

/* Forzar fondo naranja aunque otros CSS cambien background */
.btn-primary,
.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
    background: linear-gradient(135deg, var(--t-primary), var(--t-primary-hover)) !important;
    border-color: var(--t-primary) !important;
    color: #fff !important;
}

.btn-outline-primary,
.btn-outline-primary:hover,
.btn-outline-primary:focus,
.btn-outline-primary:active {
    color: var(--t-primary) !important;
    border-color: var(--t-primary) !important;
    background-color: transparent !important;
}
.btn-outline-primary:hover,
.btn-outline-primary:focus,
.btn-outline-primary:active {
    color: #fff !important;
    background-color: var(--t-primary) !important;
    border-color: var(--t-primary) !important;
}

/* Unificar colores: todos los botones principales en naranja REDI */
.btn-success,
.btn-info {
    --bs-btn-bg: var(--t-primary);
    --bs-btn-border-color: var(--t-primary);
    --bs-btn-hover-bg: var(--t-primary-hover);
    --bs-btn-hover-border-color: var(--t-primary-hover);
    --bs-btn-active-bg: var(--t-primary-hover);
    --bs-btn-active-border-color: var(--t-primary-hover);
    --bs-btn-focus-shadow-rgb: var(--t-primary-rgb);
}

.btn-outline-success,
.btn-outline-info {
    --bs-btn-color: var(--t-primary);
    --bs-btn-border-color: var(--t-primary);
    --bs-btn-hover-bg: var(--t-primary);
    --bs-btn-hover-border-color: var(--t-primary);
    --bs-btn-active-bg: var(--t-primary);
    --bs-btn-active-border-color: var(--t-primary);
    --bs-btn-focus-shadow-rgb: var(--t-primary-rgb);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--t-primary);
    box-shadow: var(--t-shadow-focus);
}

/* Forzar naranja en checkboxes/switches (evitar azul Bootstrap) */
.form-check-input:checked,
.form-switch .form-check-input:checked {
    background-color: var(--t-primary) !important;
    border-color: var(--t-primary) !important;
}

.form-check-input:focus,
.form-switch .form-check-input:focus {
    box-shadow: 0 0 0 0.25rem rgba(var(--t-primary-rgb), 0.25) !important;
    border-color: var(--t-primary) !important;
}

/* Badge overrides */
.badge {
    font-weight: var(--t-font-medium);
    font-size: var(--t-text-xs);
    padding: 0.3em 0.6em;
    border-radius: var(--t-radius-full);
}

/* Action buttons: Editar (naranja), Eliminar (rojo) - Usuarios, SPA, etc. */
.action-btn {
    background: rgba(var(--t-primary-rgb), 0.08);
    border: none;
    color: var(--t-primary);
    padding: 6px;
    cursor: pointer;
    border-radius: var(--t-radius-full);
    transition: all 0.2s;
    font-size: 13px;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.action-btn i {
    font-size: 13px;
}
.action-btn svg {
    width: 14px;
    height: 14px;
    color: inherit;
}
.action-btn:hover {
    background: rgba(var(--t-primary-rgb), 0.18);
    color: var(--t-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(var(--t-primary-rgb), 0.4);
}
.action-btn.danger {
    background: rgba(var(--t-danger-rgb), 0.08);
    color: var(--t-danger);
}
.action-btn.danger:hover {
    background: rgba(var(--t-danger-rgb), 0.18);
    color: #DC2626;
    box-shadow: 0 2px 6px rgba(var(--t-danger-rgb), 0.4);
}
.t-card .table .actions-cell,
.t-table-wrapper .table .actions-cell {
    display: flex;
    align-items: center;
    gap: 6px;
}
.t-card .table .actions-cell .action-btn,
.t-table-wrapper .table .actions-cell .action-btn {
    margin: 0;
}

/* Tabla usuarios: contraste legible para Rol y Estado (evitar gris sobre gris) */
.t-card .table tbody td .badge-role,
.t-card .table tbody td .badge-estado {
    color: inherit;
}
.t-card .table tbody td .badge-success.badge-estado {
    background: #d4edda;
    color: #155724;
}
.t-card .table tbody td .badge-danger.badge-estado {
    background: #f8d7da;
    color: #721c24;
}
.t-card .table tbody td .badge-role.badge-danger { background: #f8d7da; color: #721c24; }
.t-card .table tbody td .badge-role.badge-warning { background: #fff3cd; color: #856404; }
.t-card .table tbody td .badge-role.badge-info { background: #d1ecf1; color: #0c5460; }
.t-card .table tbody td .badge-role.badge-primary { background: #cce5ff; color: #004085; }
.t-card .table tbody td .badge-role.badge-success { background: #d4edda; color: #155724; }
.t-card .table tbody td .badge-role.badge-secondary { background: #e2e3e5; color: #383d41; }

/* Bootstrap card override for professional feel */
.card {
    border: 1px solid var(--t-gray-200);
    border-radius: var(--t-radius-lg);
    box-shadow: var(--t-shadow-xs);
}

.card-header {
    background: var(--t-white);
    border-bottom: 1px solid var(--t-gray-100);
    font-weight: var(--t-font-semibold);
}

/* Legacy support: map sb-admin classes */
.sb-nav-fixed .sb-topnav { display: none; }
.sb-nav-fixed #layoutSidenav #layoutSidenav_nav { display: none; }
.sb-nav-fixed #layoutSidenav #layoutSidenav_content { 
    padding-left: 0;
    padding-top: 0;
}

/* ======================================================================
   Module-specific styles (migrated from JS)
   ====================================================================== */

/* R2D2 - Empresas */
.r2d2-empresas .row {
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 5px;
    margin-bottom: 10px;
}
.r2d2-empresas .required {
    color: red;
}
.r2d2-empresas .form-label {
    font-weight: bold;
}
.r2d2-empresas #logoPreview {
    max-width: 100%;
    max-height: 140px;
    height: auto;
    width: auto;
    object-fit: contain;
    margin: 0 auto;
    display: none;
}
.r2d2-empresas .clickable-row {
    cursor: pointer;
}
.r2d2-empresas .clickable-row:hover {
    background-color: #f5f5f5;
}

/* R2D2 - Plantillas */
.r2d2-plantillas .required {
    color: red;
}
.r2d2-plantillas .form-label {
    font-weight: bold;
}
.r2d2-plantillas .clickable-row {
    cursor: pointer;
}
.r2d2-plantillas .clickable-row:hover {
    background-color: #f5f5f5;
}
.r2d2-plantillas #plantillaHelp {
    margin-top: 15px;
    padding: 10px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    max-height: 200px;
    overflow-y: auto;
    font-size: 0.9em;
}
.r2d2-plantillas #plantillaHelp ul {
    list-style-type: none;
    padding-left: 0;
    margin-bottom: 0;
}
.r2d2-plantillas #plantillaHelp li {
    margin-bottom: 5px;
    padding-bottom: 5px;
    border-bottom: 1px dashed #ccc;
}
.r2d2-plantillas #plantillaHelp li:last-child {
    border-bottom: none;
}
.r2d2-plantillas #plantillaHelp code {
    background-color: #e9ecef;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: bold;
}

/* R2D2 - Comunicaciones */
.r2d2-comunicaciones td.actions-cell {
    text-align: center;
    vertical-align: middle;
}
.r2d2-comunicaciones .actions-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 100%;
}
.r2d2-comunicaciones .action-link {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    border: none;
    background: var(--t-gray-100);
    transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.r2d2-comunicaciones .action-link i {
    font-size: 18px;
    line-height: 1;
}
.r2d2-comunicaciones .action-link.download {
    background: rgba(0, 163, 255, 0.08);
    color: #00a3ff;
}
.r2d2-comunicaciones .action-link.delete {
    background: rgba(239, 68, 68, 0.08);
    color: #ef4444;
}
.r2d2-comunicaciones .action-link:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.12);
}
.r2d2-comunicaciones .action-link:disabled,
.r2d2-comunicaciones .action-link.disabled {
    opacity: 0.5;
    cursor: default;
    box-shadow: none;
    transform: none;
}

/* Query Builder */
.qb-view .qb-drag-area {
    min-height: 120px;
    border: 1px dashed rgba(148, 163, 184, 0.7);
    border-radius: 10px;
    padding: 14px 16px;
    background: rgba(15, 23, 42, 0.02);
    font-size: 0.875rem;
}
.qb-view .qb-field-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: #0f172a;
    color: #e5e7eb;
    font-size: 0.75rem;
    margin: 2px;
    cursor: pointer;
}
.qb-view .qb-field-pill-remove {
    border: none;
    background: transparent;
    color: #9ca3af;
    padding: 0;
    line-height: 1;
}
.qb-view .qb-field-pill-remove:hover {
    color: #fca5a5;
}
.qb-view .qb-field-option {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    margin: 2px;
    border-radius: 999px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    font-size: 0.75rem;
    cursor: pointer;
}
.qb-view .qb-field-option:hover {
    background: #eff6ff;
    border-color: #bfdbfe;
}
.qb-view .qb-sql-preview {
    background: #020617;
    color: #e5e7eb;
    border-radius: 10px;
    padding: 12px 14px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.8rem;
    max-height: 260px;
    overflow: auto;
}
.qb-view .qb-filter-row {
    background: #ffffff;
    border-radius: 10px;
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
    margin-bottom: 8px;
}
.qb-view .qb-filter-row + .qb-filter-row {
    margin-top: 4px;
}
.qb-view .qb-filter-row:has(.qb-multiselect.open),
.qb-view .qb-filter-row:has(.qb-single-select.open) {
    position: relative;
    z-index: 1055;
}
.qb-view .qb-results-container {
    max-height: 420px;
    overflow: auto;
}
.qb-view .qb-chip {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    margin: 2px;
    border-radius: 999px;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    font-size: 0.75rem;
    cursor: pointer;
    color: #374151;
}
.qb-view .qb-chip.qb-chip--active {
    background: #0f172a;
    border-color: #0f172a;
    color: #f9fafb;
}
/* Multiselect tipo MDB: dropdown con checkboxes */
.qb-view .qb-multiselect {
    position: relative;
    width: 100%;
    z-index: 1;
}
.qb-view .qb-multiselect.open {
    z-index: 1060;
}
.qb-view .qb-multiselect-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 8px 10px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 999px;
    font-size: 0.8rem;
    color: #374151;
}
.qb-view .qb-multiselect-toggle:hover {
    border-color: #cbd5f5;
    box-shadow: 0 0 0 1px rgba(129, 140, 248, 0.35);
}
.qb-view .qb-multiselect-toggle .qb-multiselect-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
}
.qb-view .qb-multiselect-toggle .qb-multiselect-arrow {
    margin-left: 8px;
    font-size: 0.7rem;
    color: #6b7280;
}
.qb-multiselect-dropdown {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.28);
    border: 1px solid #e5e7eb;
    z-index: 1061;
}
.qb-multiselect-dropdown--fixed {
    position: fixed !important;
    display: flex !important;
    flex-direction: column;
    max-height: 280px;
    overflow: hidden;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.28);
    border: 1px solid #e5e7eb;
    z-index: 9999;
}
.qb-multiselect-dropdown--fixed .qb-multiselect-search {
    padding: 8px;
    border-bottom: 1px solid #e5e7eb;
}
.qb-multiselect-dropdown--fixed .qb-multiselect-search input {
    width: 100%;
    padding: 6px 10px;
    font-size: 0.8rem;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
}
.qb-multiselect-dropdown--fixed .qb-multiselect-options {
    overflow-y: auto;
    max-height: 200px;
    padding: 4px;
}
.qb-multiselect-dropdown--fixed .qb-multiselect-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    font-size: 0.8rem;
    cursor: pointer;
    border-radius: 6px;
}
.qb-multiselect-dropdown--fixed .qb-multiselect-option:hover {
    background: #f1f5f9;
}
.qb-multiselect-dropdown--fixed .qb-multiselect-actions {
    padding: 6px 8px;
    border-top: 1px solid #e5e7eb;
}
.qb-view .qb-single-select {
    position: relative;
    width: 100%;
    z-index: 1;
}
.qb-view .qb-single-select.open {
    z-index: 1060;
}

/* SPA */
.spa-view .t-spa-helper-actions {
    margin-top: .4rem;
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
}
.spa-view .t-spa-masked {
    -webkit-text-security: disc;
    text-security: disc;
}
.spa-view .t-spa-btn-icon {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
}
.spa-view .t-spa-btn-icon i {
    font-size: 14px;
    line-height: 1;
}
.spa-view .t-spa-type-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 80px;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.spa-view .t-spa-type-pill--database {
    background: rgba(25, 135, 84, .08);
    color: #198754;
}
.spa-view .t-spa-type-pill--filesystem {
    background: rgba(13, 110, 253, .08);
    color: #0d6efd;
}
.spa-view .t-spa-type-pill--vault {
    background: rgba(102, 16, 242, .08);
    color: #6610f2;
}
.spa-view .t-spa-type-pill--other {
    background: rgba(108, 117, 125, .08);
    color: #6c757d;
}
.spa-view .t-spa-type-pill--api {
    background: rgba(253, 126, 20, .08);
    color: #fd7e14;
}
.spa-view .t-spa-type-pill--ai {
    background: rgba(0, 120, 212, .08);
    color: #0078d4;
}

/* Reports Dashboard (Dashboard Visual) */
.rd-dashboard-view .rd-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
    align-items: center;
}
.rd-dashboard-view .rd-sidebar {
    width: 280px;
    min-width: 280px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 12px;
    max-height: calc(100vh - 220px);
    overflow-y: auto;
}
.rd-dashboard-view .rd-main-wrap {
    display: flex;
    gap: 16px;
    margin-top: 12px;
}
.rd-dashboard-view .rd-main {
    flex: 1;
    min-width: 0;
}
.rd-dashboard-view .rd-drop-zone {
    border: 3px dashed #dee2e6;
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    margin-bottom: 20px;
    background: linear-gradient(45deg, #f8f9fa, #fff);
    min-height: 180px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}
.rd-dashboard-view .rd-drop-zone.drag-over {
    border-color: #0d6efd;
    background: linear-gradient(45deg, #e7f3ff, #f0f8ff);
}
.rd-dashboard-view .rd-drop-zone h4 {
    color: #6c757d;
    margin-bottom: 10px;
    font-weight: 600;
}
.rd-dashboard-view .rd-drop-zone p {
    color: #6c757d;
    margin-bottom: 12px;
    font-size: 0.9rem;
}
.rd-dashboard-view .rd-chart-type-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: 12px 0;
}
.rd-dashboard-view .rd-chart-type-btn {
    padding: 10px 6px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}
.rd-dashboard-view .rd-chart-type-btn:hover {
    border-color: #0d6efd;
    background: #e7f3ff;
}
.rd-dashboard-view .rd-chart-type-btn.active {
    border-color: #0d6efd;
    background: #0d6efd;
    color: #fff;
}
.rd-dashboard-view .rd-chart-type-btn i {
    font-size: 1.4rem;
    display: block;
    margin-bottom: 4px;
}
.rd-dashboard-view .rd-chart-type-btn small {
    font-size: 0.7rem;
    font-weight: 600;
}
.rd-dashboard-view .rd-query-item {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 8px;
    cursor: grab;
    transition: all 0.2s;
}
.rd-dashboard-view .rd-query-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.rd-dashboard-view .rd-query-item.selected {
    border-color: #0d6efd;
    background: #e7f3ff;
}
.rd-dashboard-view .rd-query-item.dragging {
    opacity: 0.6;
}
.rd-dashboard-view .rd-query-item h6 {
    margin: 0 0 4px 0;
    font-size: 0.9rem;
}
.rd-dashboard-view .rd-query-item p {
    margin: 0;
    font-size: 0.75rem;
    color: #6c757d;
}
.rd-dashboard-view .grid-stack {
    background: transparent;
    min-height: 200px;
}
.rd-dashboard-view .grid-stack-item-content {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.rd-dashboard-view .rd-widget-header {
    background: linear-gradient(135deg, #2c2c2c, #1a1a1a);
    color: #fff;
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
.rd-dashboard-view .rd-widget-title {
    font-size: 0.85rem;
    font-weight: 600;
    margin: 0;
}
.rd-dashboard-view .rd-widget-controls {
    display: flex;
    gap: 4px;
    align-items: center;
}
.rd-dashboard-view .rd-widget-controls .btn {
    padding: 0.2rem 0.4rem;
    font-size: 0.7rem;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border-radius: 4px;
}
.rd-dashboard-view .rd-widget-controls .btn:hover {
    background: rgba(255, 255, 255, 0.35);
}
.rd-dashboard-view .rd-widget-body {
    padding: 12px;
    flex: 1;
    min-height: 0;
}
.rd-dashboard-view .rd-widget-body canvas {
    max-width: 100%;
}
.rd-dashboard-view .rd-config-card {
    display: none;
    margin-top: 16px;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 1px solid #e9ecef;
}
.rd-dashboard-view .rd-config-card.show {
    display: block;
}
.rd-dashboard-view .rd-size-btn {
    padding: 6px 12px;
    border: 1px solid #dee2e6;
    background: #fff;
    border-radius: 6px;
    font-size: 0.8rem;
    margin-right: 6px;
    cursor: pointer;
}
.rd-dashboard-view .rd-size-btn.active {
    background: #0d6efd;
    color: #fff;
    border-color: #0d6efd;
}
.rd-dashboard-view .rd-dashboard-item {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}
.rd-dashboard-view .rd-dashboard-item:hover {
    border-color: #0d6efd;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.rd-dashboard-view .rd-dashboard-item.active {
    border-color: #0d6efd;
    background: #e7f3ff;
}
.rd-dashboard-view .rd-dashboard-item .name {
    font-weight: 600;
    font-size: 0.9rem;
}
.rd-dashboard-view .rd-dashboard-item .meta {
    font-size: 0.75rem;
    color: #6c757d;
    margin-top: 4px;
}
.rd-dashboard-view .rd-kpi-widget {
    text-align: center;
    padding: 24px;
    border-radius: 8px;
    color: #fff;
}
.rd-dashboard-view .rd-kpi-value {
    font-size: 2.2rem;
    font-weight: bold;
}
.rd-dashboard-view .rd-kpi-label {
    font-size: 0.9rem;
    opacity: 0.9;
    margin-top: 4px;
}
.rd-dashboard-view .rd-table-widget {
    overflow: auto;
    max-height: 100%;
    font-size: 0.85rem;
}
.rd-dashboard-view .rd-table-widget table {
    width: 100%;
    border-collapse: collapse;
}
.rd-dashboard-view .rd-table-widget th {
    background: #1a1a1a;
    color: #fff;
    padding: 8px 10px;
    text-align: left;
}
.rd-dashboard-view .rd-table-widget td {
    padding: 6px 10px;
    border-bottom: 1px solid #e9ecef;
}
.rd-dashboard-view .rd-table-widget tr:hover {
    background: #f8f9fa;
}

/* ── Reports Dashboard v2: barra de filtros globales ── */
.rd-dashboard-view .rd-filterbar {
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 10px;
    padding: 8px 12px;
    margin-bottom: 10px;
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
}
.rd-dashboard-view .rd-filterbar-controls {
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 10px;
}
.rd-dashboard-view .rd-filter-control {
    min-width: 160px;
    max-width: 240px;
}
.rd-dashboard-view .rd-filter-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.72rem;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    margin-bottom: 2px;
}
.rd-dashboard-view .rd-filter-remove {
    border: none;
    background: none;
    color: #adb5bd;
    font-size: 0.9rem;
    line-height: 1;
    padding: 0 2px;
    cursor: pointer;
}
.rd-dashboard-view .rd-filter-remove:hover { color: #dc3545; }
.rd-dashboard-view .rd-add-filter-btn { margin-bottom: 1px; }

/* Chips de filtros activos */
.rd-dashboard-view .rd-active-chips {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-left: auto;
}
.rd-dashboard-view .rd-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #e7f1ff;
    color: #0a58ca;
    border: 1px solid #b6d4fe;
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 0.78rem;
    white-space: nowrap;
}
.rd-dashboard-view .rd-chip--cross {
    background: #fff3cd;
    color: #997404;
    border-color: #ffe69c;
}
.rd-dashboard-view .rd-chip button {
    border: none;
    background: none;
    color: inherit;
    font-size: 0.9rem;
    line-height: 1;
    padding: 0 0 0 2px;
    cursor: pointer;
    opacity: 0.7;
}
.rd-dashboard-view .rd-chip button:hover { opacity: 1; }
.rd-dashboard-view .rd-chip-clear-all {
    font-size: 0.78rem;
    text-decoration: none;
    padding: 0 4px;
}

/* Indicadores de cross-filter en widgets */
.rd-dashboard-view .grid-stack-item.rd-widget--filtering .grid-stack-item-content {
    outline: 2px solid #ffc107;
    outline-offset: -2px;
}
.rd-dashboard-view .rd-widget-filtered-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: rgba(255, 193, 7, 0.25);
    color: #ffda6a;
    border-radius: 999px;
    padding: 0 8px;
    font-size: 0.68rem;
    margin-left: 8px;
}

/* Drill-down */
.rd-dashboard-view .rd-drill-breadcrumb {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 2px 10px;
    background: #f1f3f5;
    border-bottom: 1px solid #e9ecef;
    font-size: 0.75rem;
    color: #495057;
}
.rd-dashboard-view .rd-drill-up {
    padding: 0 4px;
    color: #0d6efd;
    line-height: 1.2;
}
.rd-dashboard-view .rd-widget-controls [data-rd-drill].active {
    background: #ffc107;
    color: #212529;
    border-radius: 4px;
}

/* Panel de configuración v2 (pestañas y medidas) */
.rd-dashboard-view .rd-config-tabs .nav-link {
    font-size: 0.82rem;
    padding: 4px 12px;
}
.rd-dashboard-view .rd-measure-row select { font-size: 0.78rem; }

/* KPI: comparativa con periodo anterior */
.rd-dashboard-view .rd-kpi-compare {
    font-size: 0.78rem;
    margin-top: 4px;
    font-weight: 600;
}
.rd-dashboard-view .rd-kpi-up { color: #b7f5c8; }
.rd-dashboard-view .rd-kpi-down { color: #ffc2c9; }

/* ── Layout estilo BI: sidebar | lienzo | panel de propiedades ── */
.rd-dashboard-view .rd-bi-layout {
    display: flex;
    gap: 12px;
    margin-top: 10px;
    align-items: flex-start;
}
.rd-dashboard-view .rd-bi-layout .rd-sidebar {
    width: 230px;
    min-width: 230px;
}
.rd-dashboard-view .rd-canvas-wrap {
    flex: 1;
    min-width: 0;
    position: relative;
    min-height: calc(100vh - 260px);
    border: 1px solid #e9ecef;
    border-radius: 10px;
    background: #f8f9fa;
    padding: 6px;
}
.rd-dashboard-view .rd-canvas-wrap.drag-over {
    border: 2px dashed #0d6efd;
    background: #eef6ff;
}
.rd-dashboard-view .rd-empty-state {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #6c757d;
    pointer-events: none;
    z-index: 1;
}
.rd-dashboard-view .rd-canvas-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.85);
    z-index: 20;
    border-radius: inherit;
}
.rd-dashboard-view .grid-stack-item.rd-widget--selected .grid-stack-item-content {
    outline: 2px solid #0d6efd;
    outline-offset: -2px;
}
.rd-dashboard-view .rd-dashboard-name { font-style: italic; }

/* Panel de propiedades */
.rd-dashboard-view .rd-props {
    width: 300px;
    min-width: 300px;
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    padding: 12px;
    max-height: calc(100vh - 220px);
    overflow-y: auto;
    position: sticky;
    top: 70px;
}
.rd-dashboard-view .rd-props-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 200px;
}
.rd-dashboard-view .rd-props-header { margin-bottom: 10px; }
.rd-dashboard-view .rd-props-title { font-weight: 600; }
.rd-dashboard-view .rd-props-query { margin-top: 4px; }
.rd-dashboard-view .rd-props-section-title {
    font-size: 0.72rem;
    font-weight: 700;
    color: #6c757d;
    text-transform: uppercase;
    margin: 8px 0 6px;
}
.rd-dashboard-view .rd-props-section {
    border-top: 1px solid #e9ecef;
    margin-top: 8px;
    padding-top: 6px;
}
.rd-dashboard-view .rd-props-section summary {
    font-size: 0.72rem;
    font-weight: 700;
    color: #6c757d;
    text-transform: uppercase;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
}
.rd-dashboard-view .rd-props-section summary::before {
    content: '▸';
    transition: transform 0.15s;
}
.rd-dashboard-view .rd-props-section[open] summary::before { transform: rotate(90deg); }
.rd-dashboard-view .rd-props-section-body { padding: 4px 0 8px; }

/* Selector de tipo de visual (iconos compactos) */
.rd-dashboard-view .rd-type-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
    margin-bottom: 6px;
}
.rd-dashboard-view .rd-type-btn {
    border: 1px solid #e9ecef;
    border-radius: 6px;
    background: #fff;
    padding: 6px 2px;
    cursor: pointer;
    text-align: center;
    color: #495057;
    transition: all 0.15s;
}
.rd-dashboard-view .rd-type-btn i { font-size: 0.95rem; display: block; }
.rd-dashboard-view .rd-type-btn span {
    display: block;
    font-size: 0.55rem;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.rd-dashboard-view .rd-type-btn:hover { border-color: #0d6efd; background: #e7f3ff; }
.rd-dashboard-view .rd-type-btn.active { border-color: #0d6efd; background: #0d6efd; color: #fff; }

/* Pozos de campos (field wells) */
.rd-dashboard-view .rd-well-group { margin-bottom: 8px; }
.rd-dashboard-view .rd-well-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    color: #6c757d;
    margin-bottom: 2px;
}
.rd-dashboard-view .rd-well-label small { font-weight: 400; text-transform: none; }
.rd-dashboard-view .rd-well {
    border: 1px dashed #ced4da;
    border-radius: 6px;
    background: #f8f9fa;
    min-height: 34px;
    padding: 4px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.rd-dashboard-view .rd-well.drag-over {
    border-color: #0d6efd;
    background: #e7f3ff;
}
.rd-dashboard-view .rd-well-empty {
    font-size: 0.72rem;
    color: #adb5bd;
    padding: 4px 6px;
}
.rd-dashboard-view .rd-pill {
    display: flex;
    align-items: center;
    gap: 5px;
    background: #e7f1ff;
    border: 1px solid #b6d4fe;
    border-radius: 5px;
    padding: 3px 6px;
    font-size: 0.76rem;
    color: #0a3979;
}
.rd-dashboard-view .rd-pill i { font-size: 0.7rem; opacity: 0.7; }
.rd-dashboard-view .rd-pill-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.rd-dashboard-view .rd-pill-select {
    border: 1px solid #b6d4fe;
    border-radius: 4px;
    background: #fff;
    font-size: 0.7rem;
    padding: 1px 2px;
    max-width: 92px;
}
.rd-dashboard-view .rd-pill button {
    border: none;
    background: none;
    color: #0a3979;
    font-size: 0.95rem;
    line-height: 1;
    padding: 0 2px;
    cursor: pointer;
    opacity: 0.6;
}
.rd-dashboard-view .rd-pill button:hover { opacity: 1; color: #dc3545; }

/* Lista de campos disponibles */
.rd-dashboard-view .rd-fields-list {
    max-height: 170px;
    overflow-y: auto;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 2px;
}
.rd-dashboard-view .rd-field-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 6px;
    font-size: 0.78rem;
    border-radius: 4px;
    cursor: grab;
    color: #343a40;
}
.rd-dashboard-view .rd-field-item i { font-size: 0.68rem; color: #6c757d; width: 12px; }
.rd-dashboard-view .rd-field-item:hover { background: #e7f3ff; }
.rd-dashboard-view .rd-prop-toggles {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    font-size: 0.82rem;
}

/* Tasks Editor multi-select dropdown */
.task-editor .multi-select-dropdown {
    position: relative;
    margin-bottom: 1rem;
}
.task-editor .multi-select-dropdown .dropdown-toggle {
    text-align: left;
    background: #fff;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid #ced4da;
    border-radius: .375rem;
    padding: .375rem .75rem;
    font-size: 1rem;
    line-height: 1.5;
    color: #495057;
}
.task-editor .multi-select-dropdown .dropdown-toggle:hover {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, .25);
}
.task-editor .multi-select-dropdown .dropdown-panel {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    background: #fff;
    border: 1px solid #ced4da;
    border-radius: .375rem;
    z-index: 1055;
    display: none;
    padding: .75rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, .15);
    margin-top: 2px;
}
.task-editor .multi-select-dropdown .dropdown-panel.open {
    display: block;
}
.task-editor .multi-select-dropdown .list {
    max-height: 240px;
    overflow-y: auto;
    background: #f8f9fa;
    padding: .5rem;
    padding-left: 20px;
    border-radius: .25rem;
    border: 1px solid #e9ecef;
}
.task-editor .multi-select-dropdown .list .form-check {
    padding: 4px 8px;
    margin: 2px 0;
    border-radius: 4px;
    transition: all .2s ease;
}
.task-editor .multi-select-dropdown .list .form-check:hover {
    background: #e3f2fd;
    transform: translateX(2px);
}
.task-editor .multi-select-dropdown .list .form-check input:checked + label {
    font-weight: 600;
    color: #0d6efd;
}
.task-editor .multi-select-dropdown .actions {
    display: flex;
    justify-content: space-between;
    margin-top: .75rem;
    font-size: .875rem;
    padding-top: .5rem;
    border-top: 1px solid #e9ecef;
}
.task-editor .multi-select-dropdown .actions a {
    color: #0d6efd;
    text-decoration: none;
    padding: .25rem .5rem;
    border-radius: .25rem;
    transition: background .2s;
}
.task-editor .multi-select-dropdown .actions a:hover {
    background: #e3f2fd;
    text-decoration: none;
}
.task-editor .multi-select-dropdown .summary {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.task-editor .remove-tool {
    position: absolute;
    top: 4px;
    right: 4px;
    background: #ffbcbc;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* =====================================================
   Tablas: filtros tipo Excel (icono en cabecera + panel flotante)
   ===================================================== */
.t-th-with-filter {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    width: 100%;
}
.t-th-with-filter .t-table-filter-btn {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 6px;
    background: #fff;
    color: #6b7280;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.t-th-with-filter .t-table-filter-btn:hover {
    background: #f3f4f6;
    color: var(--t-primary);
    border-color: var(--t-primary);
}
.t-th-with-filter .t-table-filter-btn.active {
    background: rgba(var(--t-primary-rgb), 0.1);
    color: var(--t-primary);
    border-color: var(--t-primary);
}
.t-table-filter-panel {
    position: fixed;
    z-index: 1060;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15), 0 0 1px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.08);
    overflow: hidden;
    max-height: 360px;
    display: flex;
    flex-direction: column;
}
.t-table-filter-panel-inner {
    display: flex;
    flex-direction: column;
    min-width: 220px;
    max-width: 320px;
}
.t-table-filter-panel .t-table-filter-search {
    margin: 10px 10px 6px;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    padding: 6px 10px;
    font-size: 0.875rem;
}
.t-table-filter-panel .t-table-filter-search:focus {
    border-color: var(--t-primary);
    box-shadow: 0 0 0 2px rgba(var(--t-primary-rgb), 0.2);
    outline: none;
}
.t-table-filter-actions {
    padding: 4px 10px 8px;
    font-size: 0.8125rem;
}
.t-table-filter-actions a {
    color: var(--t-primary);
    text-decoration: none;
}
.t-table-filter-actions a:hover {
    text-decoration: underline;
}
.t-table-filter-sep {
    color: #9ca3af;
    margin: 0 6px;
}
.t-table-filter-list {
    overflow-y: auto;
    max-height: 220px;
    padding: 4px 10px;
    border-top: 1px solid #f3f4f6;
}
.t-table-filter-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 6px;
    margin: 0;
    cursor: pointer;
    font-size: 0.875rem;
    border-radius: 4px;
}
.t-table-filter-item:hover {
    background: #f9fafb;
}
.t-table-filter-item .form-check-input {
    margin: 0;
    flex-shrink: 0;
}
.t-table-filter-item-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}
.t-table-filter-item-count {
    flex-shrink: 0;
    font-size: 0.75rem;
    color: #9ca3af;
}
.t-table-filter-footer {
    padding: 10px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: #f9fafb;
}
.t-table-filter-footer .t-table-filter-clear-all-2 {
    font-size: 0.8125rem;
    color: var(--t-primary);
    text-decoration: none;
}
.t-table-filter-footer .t-table-filter-clear-all-2:hover {
    text-decoration: underline;
}
.t-table-filter-footer .t-table-filter-apply {
    margin-left: auto;
}

/* Toolbar sobre la tabla: filtros aplicados + Exportar Excel */
.t-table-toolbar {
    margin-bottom: 0.75rem;
    padding: 0.5rem 0;
}
.t-table-toolbar-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    justify-content: space-between;
}
.t-table-applied-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}
.t-table-applied-label {
    color: var(--bs-secondary-color);
    font-weight: 500;
}
.t-table-filter-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    background: rgba(var(--t-primary-rgb, 253, 126, 20), 0.12);
    color: var(--t-primary);
    border-radius: 6px;
    font-size: 0.8125rem;
}
.t-table-filter-clear-all-filters {
    color: var(--t-primary);
    text-decoration: none;
    font-size: 0.8125rem;
}
.t-table-filter-clear-all-filters:hover {
    text-decoration: underline;
}
.t-table-toolbar-actions {
    flex-shrink: 0;
}
.t-table-export-excel {
    white-space: nowrap;
}
.t-table-export-excel i {
    color: #217346;
}

/* Paginación Bootstrap / DataTables con estilo Trinity */
.pagination .page-link {
    color: var(--t-primary);
    border-color: #d1d5db;
}

.pagination .page-link:hover {
    color: var(--t-primary);
    background-color: #f3f4f6;
    border-color: #9ca3af;
}

.page-item.active .page-link {
    background-color: #f3f4f6 !important;
    border-color: #e5e7eb !important;
    color: var(--t-primary) !important;
    box-shadow: none;
}

.page-item.disabled .page-link {
    color: #9ca3af;
    background-color: #f9fafb;
    border-color: #e5e7eb;
}

/* Ocultar texto de info de DataTables solo en la tabla de logs del Dashboard
   (la API devuelve máximo 500 registros por llamada y el texto estándar sería confuso) */
#logsTable_wrapper .dataTables_info {
    display: none;
}

/* Fallback: Bootstrap puede no cargar si la CSP HTTP bloquea cdn.jsdelivr.net.
   Estos estilos aseguran que el menú de usuario funcione sin Bootstrap CSS. */
.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 1050;
    min-width: 160px;
    padding: 4px 0;
    background-color: #fff;
    border: 1px solid rgba(0,0,0,.15);
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,.12);
    list-style: none;
}
.dropdown-menu.show {
    display: block;
}
