/* Design Tokens - Doma Silent Luxury Palette (Calibración Oficial) */
:root {
    /* Superficies y Fondos Cálidos (Porcelain & Marfil Editorial) */
    --bg-app: #F7F8F3;
    --bg-color: #F7F8F3;
    --porcelain: #F7F8F3;
    --surface: #FFFFFF;
    --surface-color: #FFFFFF;
    --surface-subtle: #FAFBF8;
    --surface-hover: #F2F4ED;
    --white: #FFFFFF;
    
    /* Jerarquía Tipográfica Ink Profundo (WCAG AAA 15.3:1 sobre fondo claro) */
    --ink: #16263D;
    --ink-primary: #16263D;
    --ink-secondary: #3B4D66;
    --ink-muted: #6B7D96;
    --text-main: #16263D;
    --text-muted: #6B7D96;
    
    /* Acentos de Marca (Teal Esmeralda Profundo y Calibrado) */
    --teal: #167C78;
    --teal-dark: #0F5E5A;
    --teal-deep: #0B4542;
    --teal-surface: #EFF7F6;
    --teal-border: rgba(22, 124, 120, 0.18);
    --brand-teal-900: #064E3B;
    --brand-teal-700: #0F5855;
    --brand-teal-600: #136E6A;
    --brand-teal-500: #167C78;
    --brand-teal-100: #E6F4F2;
    --brand-teal-50: #F0FAF8;
    --brand-teal-alpha-12: rgba(22, 124, 120, 0.12);
    --brand-teal-alpha-06: rgba(22, 124, 120, 0.06);
    
    /* Coral de Alerta y Conversión (Bermellón Sofisticado Micro-dosificado) */
    --coral: #E76547;
    --coral-text: #C44327;
    --coral-dark: #B83E22;
    --coral-accent: #E76547;
    --coral-surface: #FDF3F0;
    --coral-border: rgba(231, 101, 71, 0.22);
    --status-danger-bg: #FDF3F0;
    --status-danger-text: #C44327;
    
    /* Bordes Translúcidos Mist de Precisión (Estilo Linear / Apple, sin rejillas invasivas) */
    --mist: #DCEAE7;
    --border-color: rgba(22, 38, 61, 0.09);
    --border-subtle: rgba(22, 38, 61, 0.06);
    --border-regular: rgba(22, 38, 61, 0.11);
    --border-medium: rgba(22, 38, 61, 0.14);
    --border-focus: rgba(22, 124, 120, 0.35);
    
    /* Espaciado & Escala Espacial */
    --space-2xs: 0.25rem;
    --space-xs:  0.5rem;
    --space-sm:  0.75rem;
    --space-md:  1rem;
    --space-lg:  1.5rem;
    --space-xl:  2rem;
    --space-2xl: 3rem;

    /* Radios y Curvas */
    --radius-card: 14px;
    --radius-bubble: 20px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-pill: 9999px;
    
    /* Sombras Multicapa Difusas Ultra-Suaves (Efecto flotante sereno) */
    --shadow-subtle: 0 1px 3px rgba(22, 38, 61, 0.04), 0 2px 6px rgba(22, 38, 61, 0.02);
    --shadow-card: 0 2px 8px -2px rgba(22, 38, 61, 0.04), 0 1px 3px rgba(22, 38, 61, 0.02);
    --shadow-card-hover: 0 8px 20px -4px rgba(22, 38, 61, 0.08), 0 2px 6px rgba(22, 38, 61, 0.03);
    --shadow-modal: 0 24px 48px -12px rgba(22, 38, 61, 0.18), 0 0 0 1px rgba(22, 38, 61, 0.04);
    --shadow-sm: 0 1px 2px rgba(22, 38, 61, 0.04), 0 2px 4px rgba(22, 38, 61, 0.02);
    --shadow-md: 0 4px 8px -1px rgba(22, 38, 61, 0.05), 0 10px 16px -3px rgba(22, 38, 61, 0.03);
    --shadow-drawer: -8px 0 32px -4px rgba(22, 38, 61, 0.12);
    
    /* Transiciones Aceleradas por Hardware (GPU) */
    --transition: 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    --transition-fast: transform 0.15s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.15s ease, background-color 0.15s ease;
    --transition-smooth: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    --sidebar-width: 250px;
}

/* Dark mode disabled — Doma brand palette is designed for light mode */

/* Reset & Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Accesibilidad global y feedback táctil */
:focus-visible {
    outline: 2px solid var(--teal);
    outline-offset: 2px;
}

button:active, .btn:active {
    transform: scale(0.98);
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    display: flex;
    height: 100vh;
    overflow: hidden;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }
ul { list-style: none; }

/* ==========================================================================
   SIDEBAR & NAVIGATION (DOMA AESTHETIC — ULTRA-ERGONOMIC SCROLL & LAYOUT)
   ========================================================================== */

/* ==========================================================================
   SIDEBAR & NAVIGATION — SOLUCIÓN UNIVERSAL DE SCROLL Y FLEXBOX
   ========================================================================== */

.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    background-color: var(--ink);
    color: var(--porcelain);
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    min-height: 0;       /* CRÍTICO: Anula min-height: auto (min-content 1084px) */
    flex-shrink: 0;      /* Impide que el sidebar se comprima horizontalmente */
    overflow: hidden;    /* Contiene rígidamente todo hijo dentro del boundary */
    position: relative;
    transition: transform var(--transition);
    z-index: 100;
}

/* 1. Capa Superior Fija */
.sidebar-header {
    flex-shrink: 0;
    padding: 1.25rem 1.5rem 0.85rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--porcelain);
}

/* Contenedor del scroll con soporte de indicadores de gradiente */
.sidebar-nav-wrapper {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Indicadores de desbordamiento (Fade Gradients) */
.sidebar-nav-wrapper::before,
.sidebar-nav-wrapper::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 28px;
    pointer-events: none;
    z-index: 10;
    transition: opacity 0.25s ease;
}

.sidebar-nav-wrapper::before {
    top: 0;
    background: linear-gradient(to bottom, var(--ink) 15%, rgba(22, 38, 61, 0));
    opacity: var(--fade-top-opacity, 0);
}

.sidebar-nav-wrapper::after {
    bottom: 0;
    background: linear-gradient(to top, var(--ink) 15%, rgba(22, 38, 61, 0));
    opacity: var(--fade-bottom-opacity, 1);
}

/* 2. Capa Media con Scroll Independiente Fluido */
.nav-links {
    flex: 1 1 auto;
    min-height: 0;       /* Indispensable para flex containers anidados */
    height: 0;           /* Forzador de cálculo de overflow en WebKit/Blink */
    overflow-y: auto;    /* Activa scroll vertical */
    overflow-x: hidden;
    overscroll-behavior-y: contain; /* Evita arrastre al body */
    -webkit-overflow-scrolling: touch;
    padding: 0.35rem 0.5rem 1.5rem;
    list-style: none;

    /* Scrollbar Estándar W3C (Firefox) */
    scrollbar-width: thin;
    scrollbar-color: rgba(220, 234, 231, 0.4) rgba(0, 0, 0, 0.2);
    scrollbar-gutter: stable; /* Asienta el carril y evita saltos de layout */
}

/* Scrollbar Personalizado WebKit (Chrome, Safari, Edge, Opera) con Alto Contraste */
.nav-links::-webkit-scrollbar {
    width: 6px;
}

.nav-links::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 999px;
    margin: 4px 0;
}

.nav-links::-webkit-scrollbar-thumb {
    background: rgba(220, 234, 231, 0.38);
    border-radius: 999px;
    border: 1px solid rgba(22, 38, 61, 0.6);
}

.nav-links::-webkit-scrollbar-thumb:hover {
    background: var(--teal, #167C78);
}

/* Micro-agrupaciones Semánticas (Jerarquía Doma) */
.nav-section-header {
    padding: 0.95rem 0.85rem 0.35rem;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(220, 234, 231, 0.65);
    user-select: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-section-header::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(220, 234, 231, 0.12);
}

.nav-links li:first-child .nav-section-header,
.nav-section-header:first-child {
    padding-top: 0.25rem;
}

/* Enlaces de Navegación */
.nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.85rem;
    margin: 2px 0;
    border-radius: 8px;
    color: rgba(247, 248, 243, 0.82);
    font-size: 0.88rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-link:hover:not(.active) {
    background-color: rgba(255, 255, 255, 0.08);
    color: var(--porcelain);
    transform: translateX(3px);
}

.nav-link.active {
    background: linear-gradient(90deg, rgba(22, 124, 120, 0.32) 0%, rgba(22, 124, 120, 0.14) 100%);
    color: #FFFFFF;
    font-weight: 600;
    box-shadow: inset 0 0 0 1px rgba(22, 124, 120, 0.4);
}

.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 20%;
    bottom: 20%;
    width: 3.5px;
    border-radius: 0 4px 4px 0;
    background: var(--teal);
    box-shadow: 0 0 8px rgba(22, 124, 120, 0.8);
}

/* 3. Capa Inferior Fija (Pinned Footer) */
.sidebar-footer {
    flex-shrink: 0;
    margin-top: auto;
    padding: 0.85rem 1.25rem;
    padding-bottom: max(0.85rem, env(safe-area-inset-bottom, 0.85rem));
    font-size: 0.82rem;
    color: rgba(247, 248, 243, 0.7);
    border-top: 1px solid rgba(220, 234, 231, 0.15);
    background: rgba(15, 26, 42, 0.92);
    backdrop-filter: blur(8px);
    box-shadow: 0 -4px 14px rgba(0, 0, 0, 0.35); /* Affordance visual de scroll */
    z-index: 10;
}

.brand-link { color: var(--coral); font-weight: bold; }

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-width: 0;
    overflow-x: hidden;
    overflow-y: auto;
}

.top-header {
    padding: 1.5rem;
    background-color: var(--bg-color);
    display: flex;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 10;
}

.views-container {
    padding: var(--space-xl);
    flex: 1;
    contain: layout;
    overflow-y: auto;
}

.view {
    display: none;
    contain: layout style;
}

.view.active {
    display: block;
    animation: fadeInView 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: opacity, transform;
}

@keyframes fadeInView {
    from { opacity: 0; transform: translate3d(0, 4px, 0); }
    to { opacity: 1; transform: translate3d(0, 0, 0); }
}

/* Virtualización Nativa CSS para Tablas Extensas */
.doma-table-container tbody tr,
.table-container tbody tr {
    content-visibility: auto;
    contain-intrinsic-size: 0 52px;
}

/* Typography & Utilities */
h1 { font-size: 1.75rem; color: var(--text-main); font-weight: 700; letter-spacing: -0.015em; }
h2 { font-size: 1.4rem; margin-bottom: 1rem; color: var(--ink); font-weight: 700; letter-spacing: -0.01em; }
h3 { font-size: 1.1rem; margin-bottom: 0.5rem; color: var(--ink); font-weight: 600; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1.5rem; }
.hidden { display: none !important; }

/* Buttons */
.btn {
    padding: 0.58rem 1.15rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-weight: 600;
    font-size: 0.88rem;
    transition: var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    cursor: pointer;
    line-height: 1.3;
}

.btn-primary {
    background-color: var(--teal);
    color: #FFFFFF;
    box-shadow: 0 1px 3px rgba(22, 124, 120, 0.25);
}
.btn-primary:hover {
    background-color: var(--teal-dark);
    transform: translate3d(0, -1px, 0);
    box-shadow: 0 4px 10px rgba(22, 124, 120, 0.3);
}

.btn-secondary {
    background-color: var(--surface);
    color: var(--ink-secondary);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}
.btn-secondary:hover {
    background-color: var(--surface-hover);
    color: var(--ink);
    border-color: var(--border-medium);
}

.btn-block { width: 100%; }

.icon-btn {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

/* Cards & Layouts - Doma Silent Luxury */
.welcome-card-doma {
    background: var(--surface);
    border: 1px solid var(--teal-border);
    border-radius: var(--radius-card);
    padding: var(--space-xl);
    margin-bottom: var(--space-xl);
    box-shadow: var(--shadow-card);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-lg);
    flex-wrap: wrap;
    position: relative;
    overflow: hidden;
}

.welcome-card-doma::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--teal);
}

.welcome-card-doma h2 {
    color: var(--ink);
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: 0.3rem;
}

.welcome-card-doma p {
    color: var(--ink-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
    max-width: 620px;
    margin: 0;
}

/* ROI Shield Card (Value Framing & Retención $1,500/mes) */
.roi-shield-card {
    background: linear-gradient(135deg, #FFFFFF 0%, var(--teal-surface) 100%);
    border: 1px solid var(--teal-border);
    border-radius: var(--radius-card);
    padding: var(--space-lg) var(--space-xl);
    margin-bottom: var(--space-xl);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-lg);
    box-shadow: var(--shadow-card);
}

.roi-shield-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--teal-dark);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.3rem;
}

.roi-shield-stats {
    display: flex;
    gap: var(--space-xl);
    flex-wrap: wrap;
}

.roi-stat-item {
    display: flex;
    flex-direction: column;
}

.roi-stat-number {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.01em;
}

.roi-stat-label {
    font-size: 0.76rem;
    color: var(--ink-muted);
}

/* Grilla de Métricas Descomprimida */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
}

.stat-card {
    background-color: var(--surface);
    padding: var(--space-lg);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: var(--transition-fast);
}

.stat-card:hover {
    transform: translate3d(0, -2px, 0);
    box-shadow: var(--shadow-card-hover);
    border-color: var(--teal-border);
}

.stat-card h3 {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-muted);
    margin-bottom: var(--space-xs);
}

.stat-value {
    font-size: 1.85rem;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

/* Feed de Actividad Encapsulado */
.activity-card-container {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    padding: var(--space-lg);
    box-shadow: var(--shadow-card);
}

.activity-feed {
    list-style: none;
    margin-top: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.activity-feed li {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    background: var(--surface-subtle);
    border: 1px solid var(--border-subtle);
    font-size: 0.86rem;
    color: var(--ink-primary);
}

.stat-card h3 {
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-value {
    font-size: 2.15rem;
    font-weight: 800;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
}

.quick-actions {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

/* Agents Grid */
.agents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
    gap: 1.5rem;
}

.agent-card {
    background-color: var(--surface);
    border-radius: var(--radius-card);
    padding: 1.5rem;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-subtle);
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
    cursor: pointer;
}

.agent-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-card-hover);
    border-color: rgba(22, 124, 120, 0.4);
}

.agent-status {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    background-color: var(--mist);
    color: var(--teal);
    margin-bottom: 1rem;
}

/* Forms */
.form-group { margin-bottom: 1.25rem; }
.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-main);
}
.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: transparent;
    color: var(--text-main);
    font-family: inherit;
    transition: border-color var(--transition);
}
.form-control:focus {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(22, 124, 120, 0.1);
}
.form-control-sm { padding: 0.5rem; }

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(22, 38, 61, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--transition), visibility var(--transition);
}
.modal-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}
.modal {
    background-color: var(--surface);
    width: 100%;
    max-width: 620px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-modal);
    border: 1px solid var(--border-color);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    transform: translate3d(0, 12px, 0) scale(0.97);
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: transform;
    overflow: hidden;
}
.modal-overlay.active .modal { transform: translate3d(0, 0, 0) scale(1); }

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
}

@media (max-width: 640px) {
    .form-grid-2 {
        grid-template-columns: 1fr;
    }
}
.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.close-modal {
    background: transparent;
    border: none;
    font-size: 1.25rem;
    color: var(--text-muted);
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: color var(--transition), background-color var(--transition);
}
.close-modal:hover {
    color: var(--ink);
    background-color: var(--mist);
}
.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* Chat Layout */
.chat-container {
    display: flex;
    height: calc(100vh - 12rem);
    background-color: var(--porcelain);
    border-radius: var(--radius-card);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.chat-sidebar {
    width: 300px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background-color: var(--bg-color);
}

.chat-sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.conversations-list {
    flex: 1;
    overflow-y: auto;
}

.conversation-item {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color var(--transition);
}
.conversation-item:hover, .conversation-item.active {
    background-color: var(--mist);
}
.conv-name { font-weight: bold; }
.conv-preview { font-size: 0.875rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
    background-color: var(--porcelain);
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--white);
    min-height: 56px;
    gap: 0.75rem;
}

.chat-header-user-info {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    min-width: 0;
}

.chat-header-user-info h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-messages {
    flex: 1;
    padding: 1.25rem 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 0;
}

.chat-placeholder {
    margin: auto;
    color: var(--text-muted);
    text-align: center;
}

.message {
    max-width: 75%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-bubble);
    line-height: 1.4;
    word-break: break-word;
}
.msg-user {
    align-self: flex-end;
    background-color: var(--teal);
    color: #FFFFFF;
    border-bottom-right-radius: 4px;
}
.msg-assistant {
    align-self: flex-start;
    background-color: var(--porcelain);
    color: var(--ink);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
}
.msg-system {
    align-self: center;
    background-color: var(--mist);
    color: var(--ink);
    font-size: 0.85rem;
    padding: 0.5rem 1rem;
    border-radius: 12px;
}

.chat-input-area {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-color);
}
#chat-form {
    display: flex;
    gap: 0.5rem;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    align-self: flex-start;
    background-color: var(--mist);
    border-radius: 16px;
    margin-bottom: 1rem;
}
.dot {
    width: 6px; height: 6px;
    background-color: var(--teal);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}
.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Split Layout (KB) */
.split-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.documents-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.document-item {
    background-color: var(--porcelain);
    padding: 1rem;
    border-radius: var(--radius-card);
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.doc-info h4 { margin-bottom: 0.25rem; }
.btn-delete {
    color: var(--coral-dark, #B83E22);
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background-color var(--transition);
}
.btn-delete:hover {
    background-color: rgba(184, 62, 34, 0.1);
}

/* Analytics Chart (CSS Only) */
.chart-card {
    background-color: var(--porcelain);
    padding: 1.5rem;
    border-radius: var(--radius-card);
    border: 1px solid var(--border-color);
}
.css-bar-chart {
    display: flex;
    align-items: flex-end;
    height: 200px;
    gap: 1rem;
    margin-top: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}
.bar-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 100%;
}
.bar {
    width: 100%;
    background-color: var(--teal);
    border-radius: 4px 4px 0 0;
    transition: height 0.5s ease;
    min-height: 4px;
}
.bar-label {
    position: absolute;
    bottom: 0;
    font-size: 0.75rem;
    color: var(--text-muted);
}
.bar-value {
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
    font-weight: bold;
}

/* Toasts */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 2000;
}
.toast {
    background-color: var(--ink);
    color: var(--porcelain);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow-modal);
    animation: slideIn 0.3s ease;
}
.toast.error {
    background-color: var(--coral);
    color: var(--ink);
    font-weight: 600;
}
.toast.success { background-color: var(--teal); }
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    background-color: var(--porcelain);
    border-radius: var(--radius-card);
    border: 2px dashed var(--border-color);
    margin: 1.5rem 0;
    grid-column: 1 / -1;
}
.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 0.75rem;
}
.empty-state-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 0.5rem;
}
.empty-state-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    max-width: 420px;
    margin: 0 auto 1.25rem auto;
    line-height: 1.5;
}

/* Sidebar Backdrop */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(22, 38, 61, 0.5);
    backdrop-filter: blur(2px);
    z-index: 999;
}
.sidebar-backdrop.active {
    display: block;
}

/* Responsive */
.mobile-only { display: none; }

/* Mensaje de Operador Humano (Takeover) */
.msg-operator {
    align-self: flex-start;
    background-color: rgba(231, 101, 71, 0.08) !important;
    border: 1px solid rgba(231, 101, 71, 0.25) !important;
    border-left: 4px solid var(--coral) !important;
}
.operator-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--coral-dark);
    margin-bottom: 3px;
}

@media (max-width: 768px) {
    .mobile-only { display: block; }
    
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        height: 100vh;
        height: 100dvh;
        max-height: 100dvh;
        width: min(285px, 85vw);
        transform: translateX(-100%);
        z-index: 1000;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.35);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    #close-sidebar {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .views-container { padding: 1rem; }
    .top-header { padding: 1rem; }
    .modal-overlay { padding: 1rem; }
    .modal { width: calc(100% - 1rem); max-width: 100%; }

    .split-layout { grid-template-columns: 1fr; }
    .chat-container { flex-direction: column; }
    .chat-sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border-color); max-height: 35%; }
}

@media (max-width: 480px) {
    .modal-overlay {
        padding: 0.5rem;
    }
    .modal-header,
    .modal-body {
        padding: 1rem;
    }
    .view-header-actions {
        flex-direction: column;
        align-items: stretch !important;
    }
    .view-header-actions > div {
        flex-direction: column !important;
        align-items: stretch !important;
        width: 100% !important;
    }
    .view-header-actions input,
    .view-header-actions select {
        width: 100% !important;
        min-width: 0 !important;
    }
    .view-header-actions .btn {
        width: 100%;
        justify-content: center;
    }
    .table-container {
        -webkit-overflow-scrolling: touch;
    }
    .chat-header {
        padding: 0.6rem 0.8rem !important;
    }
    .modal-actions {
        flex-direction: column-reverse !important;
        gap: 0.5rem;
    }
    .modal-actions .btn {
        width: 100%;
        justify-content: center;
    }
}

/* Ergonomía táctil WCAG 2.5.5 / 2.5.8 (Touch Targets mínimos 44x44px) */
.table-action-btn,
.icon-btn {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0.6rem;
    font-size: 0.95rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background-color: var(--white);
    color: var(--text-main);
    transition: background-color var(--transition), border-color var(--transition), transform 0.1s ease;
}

.table-action-btn:hover,
.icon-btn:hover {
    background-color: var(--mist);
    border-color: var(--teal);
}

.table-action-btn.btn-danger {
    color: var(--coral);
    border-color: rgba(231, 101, 71, 0.3);
}

.table-action-btn.btn-danger:hover {
    background-color: rgba(231, 101, 71, 0.1);
    border-color: var(--coral);
}

/* Búsqueda CRM con botón de limpieza */
.search-input-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    width: 100%;
    max-width: 320px;
}

.search-input-wrapper input {
    width: 100%;
    padding-right: 2.2rem;
}

.search-clear-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    display: none;
    padding: 4px 6px;
    border-radius: 50%;
}

.search-clear-btn:hover {
    color: var(--ink);
    background-color: var(--mist);
}

/* Indicador de carga sutil Doma */
.spinner-inline {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--mist);
    border-top-color: var(--teal);
    border-radius: 50%;
    animation: spin-inline 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

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

/* Utilidad de accesibilidad para jerarquía h2 invisible para lectores de pantalla */
.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;
}

/* Corrección de contraste Doma WCAG 2.1 AA en badges y chips (Ratio > 6:1) */
.agent-status,
.doc-info span {
    background-color: var(--mist) !important;
    color: #0F5855 !important;
}

/* Toast tipo info */
.toast.info {
    background-color: var(--ink);
    color: var(--porcelain);
    border-left: 4px solid var(--teal);
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ========================================================
   EMBUDO DE VENTAS KANBAN CRM (Doma Aesthetic)
   ======================================================== */
.kanban-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.kanban-board {
    display: grid;
    grid-template-columns: repeat(6, minmax(280px, 1fr));
    gap: 1rem;
    min-width: 1720px;
    align-items: start;
}

.kanban-column {
    background: var(--porcelain);
    border-radius: 12px;
    border: 1px solid var(--mist);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 240px);
    box-shadow: 0 2px 6px rgba(22, 38, 61, 0.03);
}

.kanban-header {
    padding: 1rem;
    border-bottom: 2px solid var(--mist);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--white);
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

.kanban-header-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.kanban-header-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 600;
    background: var(--porcelain);
    padding: 2px 8px;
    border-radius: 12px;
    border: 1px solid var(--mist);
}

.kanban-dropzone {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    overflow-y: auto;
    min-height: 200px;
    flex: 1;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.kanban-dropzone.drag-over {
    background: rgba(22, 124, 120, 0.08);
    border: 2px dashed var(--teal);
    border-radius: 8px;
}

.kanban-card {
    background: var(--white);
    border-radius: 10px;
    border: 1px solid var(--mist);
    padding: 1rem;
    box-shadow: 0 2px 6px rgba(22, 38, 61, 0.04);
    cursor: grab;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    user-select: none;
}

.kanban-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(22, 38, 61, 0.08);
    border-color: var(--teal);
}

.kanban-card.dragging {
    opacity: 0.4;
    cursor: grabbing;
}

.kanban-card-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 0.35rem;
}

.kanban-card-phone {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.kanban-card-deal {
    display: inline-block;
    font-size: 0.82rem;
    font-weight: 700;
    color: #0F5855;
    background: rgba(22, 124, 120, 0.12);
    padding: 3px 8px;
    border-radius: 6px;
    margin-bottom: 0.4rem;
}

.kanban-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.kanban-card-tag {
    font-size: 0.72rem;
    background: var(--porcelain);
    color: var(--ink);
    border: 1px solid var(--mist);
    padding: 1px 6px;
    border-radius: 4px;
}

/* ========================================================
   MOTOR DE AUTOMATIZACIONES & WORKFLOWS
   ======================================================== */
.switch-toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider-round {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--mist);
    transition: 0.3s;
    border-radius: 24px;
}

.slider-round:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

input:checked + .slider-round {
    background-color: var(--teal);
}

input:checked + .slider-round:before {
    transform: translateX(20px);
}

.switch-toggle input:focus-visible + .slider-round {
    outline: 2px solid var(--teal);
    outline-offset: 2px;
}

.pill-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 8px;
    background: rgba(231, 101, 71, 0.12);
    color: #B83E22;
    border: 1px solid rgba(231, 101, 71, 0.25);
}

.pill-action {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 8px;
    background: rgba(22, 124, 120, 0.12);
    color: #0F5855;
    border: 1px solid rgba(22, 124, 120, 0.25);
}

/* ========================================================
   INFORME EJECUTIVO IA & VOZ SINTETIZADA
   ======================================================== */
.report-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.report-kpi-box {
    background: var(--porcelain);
    border: 1px solid var(--mist);
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
}

.report-kpi-val {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--ink);
    margin-top: 0.25rem;
}

.report-action-card {
    background: var(--white);
    border-left: 4px solid var(--teal);
    border: 1px solid var(--mist);
    border-left-width: 4px;
    border-radius: 8px;
    padding: 0.85rem 1rem;
    margin-bottom: 0.65rem;
}

.voice-play-btn {
    background: rgba(22, 124, 120, 0.12);
    color: var(--teal-dark);
    border: 1px solid rgba(22, 124, 120, 0.25);
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-height: 44px;
    min-width: 44px;
    transition: all 0.2s;
    margin-top: 0.35rem;
}

.voice-play-btn:hover {
    background: var(--teal);
    color: white;
}

.kanban-empty-dropzone {
    border: 2px dashed var(--mist);
    border-radius: var(--radius-card);
    padding: 1.5rem 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 0.5rem;
    background: rgba(255, 255, 255, 0.6);
}

.kanban-stage-selector {
    margin-top: 0.6rem;
    width: 100%;
    min-height: 44px;
    font-size: 0.85rem;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    border: 1.5px solid var(--teal);
    background: var(--white);
    color: var(--ink);
    font-weight: 600;
    cursor: pointer;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.kanban-stage-selector:focus-visible {
    outline: 2px solid var(--teal);
    outline-offset: 2px;
}

.table-action-btn {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.4rem;
}

/* Skeleton Loading Feedback */
.skeleton-shimmer {
    background: linear-gradient(90deg, rgba(220, 234, 231, 0.4) 25%, rgba(247, 248, 243, 0.8) 50%, rgba(220, 234, 231, 0.4) 75%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.6s ease-in-out infinite;
    border-radius: 4px;
    display: inline-block;
}

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

/* Mobile & PWA Safe Area Insets */
@supports (padding: env(safe-area-inset-bottom)) {
    body {
        padding-top: env(safe-area-inset-top, 0px);
        padding-bottom: env(safe-area-inset-bottom, 0px);
        padding-left: env(safe-area-inset-left, 0px);
        padding-right: env(safe-area-inset-right, 0px);
    }
}

/* ========================================================
   SISTEMA DE DISEÑO DOMA - DEAL INTELLIGENCE & SLAS
   ======================================================== */
.deal-score-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.82rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 8px;
    transition: all 0.25s ease;
}

.deal-score-hot {
    background: rgba(231, 101, 71, 0.15);
    color: #B83E22;
    border: 1px solid #B83E22;
}

.deal-score-warm {
    background: rgba(22, 124, 120, 0.15);
    color: #0F5855;
    border: 1px solid #0F5855;
}

.deal-score-cold {
    background: var(--porcelain);
    color: var(--ink);
    border: 1px solid var(--mist);
}

#deal-key-points-list {
    list-style: none;
    padding-left: 0;
    margin: 0.5rem 0;
}

#deal-key-points-list li {
    position: relative;
    padding-left: 1.25rem;
    margin-bottom: 0.35rem;
    font-size: 0.85rem;
    color: var(--ink);
    line-height: 1.4;
}

#deal-key-points-list li::before {
    content: "•";
    position: absolute;
    left: 0.25rem;
    color: var(--teal);
    font-size: 1.1rem;
    line-height: 1;
}

.sla-badge-live {
    font-size: 0.78rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    transition: all 0.3s ease;
}

.sla-badge-ok {
    background: var(--teal-surface);
    color: var(--teal-dark);
    border: 1px solid var(--teal-border);
}

.sla-badge-warning {
    background: #FFFBEB;
    color: #B45309;
    border: 1px solid rgba(180, 83, 9, 0.25);
}

.sla-badge-breached {
    background: var(--coral-surface);
    color: var(--coral-text);
    font-weight: 700;
    border: 1px solid var(--coral-border);
}

#chat-header-actions .btn,
#btn-takeover-toggle {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

@keyframes sla-pulse-warning {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.82; transform: scale(0.98); }
}

@keyframes sla-pulse-breached {
    0%, 100% { box-shadow: 0 0 0 0 rgba(231, 101, 71, 0.6); }
    50% { box-shadow: 0 0 0 5px rgba(231, 101, 71, 0); }
}

.call-send.mic-listening {
    animation: mic-pulse 1.2s infinite ease-in-out;
    background: #E76547 !important;
    border-color: #B83E22 !important;
}

@keyframes mic-pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(231, 101, 71, 0.6); }
    50% { transform: scale(1.08); box-shadow: 0 0 0 8px rgba(231, 101, 71, 0); }
}

/* ==========================================================================
   Sidebar Workspace Tag & High-Contrast Navigation (WCAG 2.1 AA)
   ========================================================================== */
.sidebar-workspace-tag {
    flex-shrink: 0;
    margin: 0.4rem 1rem 0.65rem;
    padding: 0.5rem 0.85rem;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(220, 234, 231, 0.12);
    color: var(--porcelain);
    border: 1px solid rgba(220, 234, 231, 0.25);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.sidebar-workspace-tag .ws-dot {
    width: 8px;
    height: 8px;
    min-width: 8px;
    border-radius: 50%;
    background-color: var(--teal);
    box-shadow: 0 0 6px rgba(22, 124, 120, 0.5);
}

.nav-link-portal {
    color: var(--porcelain) !important;
    font-weight: 700 !important;
    background: rgba(22, 124, 120, 0.28) !important;
    border: 1px solid rgba(220, 234, 231, 0.35) !important;
    border-radius: var(--radius-sm);
    margin: 0.25rem 0.75rem;
    min-height: 44px;
    display: flex !important;
    align-items: center;
    transition: var(--transition-fast);
}

.nav-link-portal:hover {
    background: rgba(22, 124, 120, 0.5) !important;
    border-color: var(--teal-surface) !important;
    transform: translate3d(2px, 0, 0);
}

/* ==========================================================================
   Workspace Context Switcher (Aislamiento Agencia B2B vs Clientes B2C)
   ========================================================================== */
.workspace-switcher-container {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-left: auto;
    flex-wrap: wrap;
}

.workspace-pill-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    transition: all var(--transition);
}

/* Modo Agencia: Formal, Ink Corporativo Doma */
.workspace-pill-badge.badge-agency {
    background-color: var(--ink);
    color: var(--porcelain);
    border: 1px solid var(--ink);
    box-shadow: 0 1px 3px rgba(22, 38, 61, 0.15);
}

/* Modo Cliente (Clínica): Clínico Teal Luminoso */
.workspace-pill-badge.badge-client {
    background-color: #E8F5F3;
    color: #0F5855;
    border: 1px solid #B8D3CE;
    box-shadow: 0 1px 3px rgba(22, 124, 120, 0.12);
}

/* Modo Consolidado Global: Neutro Mist Doma */
.workspace-pill-badge.badge-all {
    background-color: var(--mist);
    color: var(--ink);
    border: 1px solid rgba(22, 38, 61, 0.2);
}

.workspace-select-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.workspace-select {
    appearance: none;
    -webkit-appearance: none;
    min-height: 44px;
    padding: 0.5rem 2.2rem 0.5rem 1rem;
    border-radius: 8px;
    border: 1.5px solid var(--mist);
    background-color: var(--surface);
    color: var(--ink);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-card);
    transition: border-color var(--transition), box-shadow var(--transition);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23167C78' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
}

.workspace-select:hover {
    border-color: var(--teal);
}

.workspace-select:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(22, 124, 120, 0.15);
    outline: none;
}

.workspace-link-btn {
    min-height: 44px;
    padding: 0.5rem 1rem;
    font-size: 0.84rem;
    font-weight: 600;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    text-decoration: none;
    box-shadow: var(--shadow-card);
}

/* ==========================================================================
   SISTEMA DE TABLAS CENTRALIZADO (DOMA-TABLE)
   ========================================================================== */
.doma-table-container,
.table-container {
    background: var(--surface);
    border-radius: var(--radius-card);
    border: 1px solid var(--mist);
    box-shadow: var(--shadow-card);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

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

.doma-table thead tr {
    background-color: var(--porcelain);
    border-bottom: 1px solid var(--mist);
    color: var(--ink);
}

.doma-table th {
    padding: 0.85rem 1rem;
    font-weight: 700;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
}

.doma-table td {
    padding: 0.95rem 1rem;
    border-bottom: 1px solid var(--mist);
    color: var(--ink);
    vertical-align: middle;
}

.doma-table tbody tr:hover {
    background-color: rgba(220, 234, 231, 0.25);
}

.doma-table tbody tr:last-child td {
    border-bottom: none;
}

/* ==========================================================================
   BREAKPOINT INTERMEDIO TABLET / IPAD (769px a 1024px)
   ========================================================================== */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 220px;
    }

    .top-header {
        padding: 1rem;
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .workspace-switcher-container {
        width: 100%;
        justify-content: space-between;
        margin-left: 0;
    }

    .workspace-select-wrapper {
        flex: 1;
        max-width: 320px;
    }

    .workspace-select {
        width: 100%;
    }

    .split-layout {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }

    .chat-container {
        flex-direction: column;
        height: calc(100vh - 10rem);
    }

    .chat-sidebar {
        width: 100%;
        max-height: 38%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .kanban-wrapper {
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 1.5rem;
    }

    .kanban-column {
        scroll-snap-align: start;
    }
}

/* ==========================================================================
   TOOLTIPS NATIVOS CSS (CERO DEPENDENCIAS CDN)
   ========================================================================== */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    padding: 0.35rem 0.65rem;
    background-color: var(--ink);
    color: var(--porcelain);
    font-size: 0.72rem;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(22, 38, 61, 0.25);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1000;
}

[data-tooltip]:hover::before,
[data-tooltip]:focus-visible::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Botón Primario Doma con Profundidad y Micro-click */
.btn-primary {
    background: linear-gradient(180deg, #188985 0%, var(--teal) 100%);
    box-shadow: 0 2px 6px rgba(22, 124, 120, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    font-weight: 600;
}

.btn-primary:hover {
    background: linear-gradient(180deg, var(--teal) 0%, #126360 100%);
    box-shadow: 0 4px 14px rgba(22, 124, 120, 0.4);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(1px) scale(0.98);
    box-shadow: 0 1px 3px rgba(22, 124, 120, 0.3);
}

/* ==========================================================================
   ARMONÍA DOMA — CHAT DE 3 COLUMNAS, INSPECTOR LATERAL Y COPILOTO TÁCTICO
   ========================================================================== */

/* Píldoras de Cabecera (Header Pills) */
.btn-chat-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.32rem 0.75rem;
    font-size: 0.76rem;
    font-weight: 600;
    border-radius: 9999px;
    border: 1px solid var(--mist);
    background: var(--porcelain);
    color: var(--ink);
    cursor: pointer;
    transition: all 0.18s ease;
    white-space: nowrap;
}

.btn-chat-pill:hover {
    border-color: var(--teal);
    background: var(--white);
    color: var(--teal);
    box-shadow: 0 1px 4px rgba(22, 124, 120, 0.12);
}

.btn-chat-pill.active {
    background: rgba(22, 124, 120, 0.1);
    border-color: var(--teal);
    color: var(--teal);
    box-shadow: 0 1px 4px rgba(22, 124, 120, 0.15);
}

.btn-chat-pill.mode-ai {
    background: rgba(22, 124, 120, 0.08);
    border-color: rgba(22, 124, 120, 0.3);
    color: var(--teal);
}

.btn-chat-pill.mode-human {
    background: rgba(231, 101, 71, 0.1);
    border-color: rgba(231, 101, 71, 0.4);
    color: var(--coral-dark);
}

/* Composer Integrado Moderno */
.chat-input-area {
    padding: 0.65rem 1.25rem 0.85rem 1.25rem;
    border-top: 1px solid var(--border-color);
    background-color: var(--white);
    position: relative;
}

.chat-input-form-clean {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    background: var(--porcelain);
    border: 1px solid var(--mist);
    border-radius: 28px;
    padding: 0.25rem 0.5rem 0.25rem 0.85rem;
    box-shadow: 0 2px 6px rgba(22, 38, 61, 0.03);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.chat-input-form-clean:focus-within {
    border-color: var(--teal);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(22, 124, 120, 0.12);
}

.chat-input-field-clean {
    flex: 1;
    min-width: 0;
    border: none !important;
    outline: none !important;
    background: transparent !important;
    font-size: 0.88rem;
    color: var(--ink);
    padding: 0.45rem 0.25rem;
}

.chat-input-field-clean::placeholder {
    color: var(--text-muted);
    font-size: 0.84rem;
}

.chat-input-btn-icon {
    background: none;
    border: none;
    font-size: 1.05rem;
    cursor: pointer;
    padding: 0.35rem;
    border-radius: 6px;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s, transform 0.1s;
    line-height: 1;
}

.chat-input-btn-icon:hover {
    background: var(--mist);
    color: var(--ink);
}

.chat-input-btn-icon:active {
    transform: scale(0.92);
}

.composer-copilot-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: rgba(22, 124, 120, 0.08);
    color: var(--teal);
    border: 1px solid rgba(22, 124, 120, 0.25);
    border-radius: 9999px;
    padding: 0.28rem 0.65rem;
    font-size: 0.74rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.composer-copilot-pill:hover {
    background: rgba(22, 124, 120, 0.16);
    border-color: var(--teal);
    transform: translateY(-1px);
}

.composer-send-btn {
    background: linear-gradient(180deg, var(--teal) 0%, #126360 100%);
    color: var(--white);
    border: none;
    border-radius: 9999px;
    padding: 0.42rem 1.05rem;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(22, 124, 120, 0.3);
    transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
    white-space: nowrap;
}

.composer-send-btn:hover {
    box-shadow: 0 4px 10px rgba(22, 124, 120, 0.4);
    transform: translateY(-1px);
}

.composer-send-btn:active {
    transform: translateY(1px) scale(0.98);
}

/* Floating Quick Replies */
.quick-replies-floating-bar {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 1.25rem;
    right: 1.25rem;
    background: var(--white);
    border: 1px solid var(--mist);
    border-radius: 12px;
    padding: 0.4rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 6px 16px rgba(22, 38, 61, 0.08);
    z-index: 15;
}

/* Inspector Lateral Deslizable (Columna 3) */
.chat-inspector {
    width: 340px;
    flex-shrink: 0;
    border-left: 1px solid var(--border-color);
    background-color: var(--bg-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease, transform 0.25s ease;
}

.chat-inspector.collapsed {
    display: none !important;
}

.inspector-tabs {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--white);
    min-height: 48px;
}

.inspector-tab-btn {
    background: transparent;
    border: none;
    padding: 0.35rem 0.65rem;
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.inspector-tab-btn:hover {
    color: var(--ink);
    background: var(--mist);
}

.inspector-tab-btn.active {
    color: var(--teal);
    background: rgba(22, 124, 120, 0.08);
    box-shadow: inset 0 0 0 1px rgba(22, 124, 120, 0.25);
}

/* Segmented Control para Opciones del Copiloto */
.copilot-segmented-nav {
    display: flex;
    background: var(--mist);
    padding: 2px;
    border-radius: 8px;
    gap: 2px;
}

.copilot-seg-btn {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.38rem 0.2rem;
    border-radius: 6px;
    color: var(--ink);
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: center;
    white-space: nowrap;
}

.copilot-seg-btn:hover {
    background: rgba(255, 255, 255, 0.6);
}

.copilot-seg-btn.active {
    background: var(--white);
    color: var(--teal);
    box-shadow: 0 1px 4px rgba(22, 38, 61, 0.08);
}

/* Tarjeta Única Destacada del Copiloto */
.copilot-featured-card {
    background: var(--white);
    border: 1px solid var(--mist);
    border-radius: 10px;
    padding: 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    box-shadow: 0 2px 8px rgba(22, 38, 61, 0.04);
}

.copilot-featured-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.copilot-featured-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--teal);
}

.copilot-featured-text {
    font-size: 0.84rem;
    line-height: 1.5;
    color: var(--ink);
    white-space: pre-wrap;
    background: var(--porcelain);
    padding: 0.7rem;
    border-radius: 8px;
    border: 1px solid rgba(22, 38, 61, 0.05);
    word-break: break-word;
    max-height: 220px;
    overflow-y: auto;
}

.copilot-featured-text::-webkit-scrollbar {
    width: 4px;
}
.copilot-featured-text::-webkit-scrollbar-thumb {
    background: var(--mist);
    border-radius: 4px;
}

.copilot-card-rationale {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-style: italic;
    line-height: 1.35;
}

.copilot-featured-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    border-top: 1px solid var(--porcelain);
    padding-top: 0.6rem;
    margin-top: 0.2rem;
}

#copilot-panel::-webkit-scrollbar,
#deal-intelligence-panel::-webkit-scrollbar {
    width: 4px;
}
#copilot-panel::-webkit-scrollbar-thumb,
#deal-intelligence-panel::-webkit-scrollbar-thumb {
    background: var(--mist);
    border-radius: 4px;
}

/* Responsividad para pantallas medianas / compactas (< 1050px) */
@media (max-width: 1050px) {
    .chat-inspector {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        width: 320px;
        z-index: 40;
        box-shadow: -4px 0 20px rgba(15, 23, 42, 0.15);
    }
}

/* ==========================================================================
   GLOBAL COPILOT COMPANION SUITE (OMNIPRESENTE EN TODA LA PLATAFORMA)
   ========================================================================== */

/* Barra de Sugerencia Proactiva Ambiental (Bajo el Top Header) */
.copilot-ambient-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.55rem 1.25rem;
    background: linear-gradient(90deg, rgba(19, 110, 106, 0.07) 0%, rgba(255, 255, 255, 0.9) 100%);
    border-bottom: 1px solid var(--brand-teal-alpha-12);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    font-size: 0.8rem;
    color: var(--ink-primary);
    transition: var(--transition-smooth);
    z-index: 20;
}

.copilot-ambient-bar.hidden {
    display: none !important;
}

.ambient-content {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    min-width: 0;
}

.ambient-sparkle {
    color: var(--brand-teal-600);
    font-size: 0.95rem;
    animation: copilotSparklePulse 3s infinite ease-in-out;
}

@keyframes copilotSparklePulse {
    0%, 100% { transform: scale(1); opacity: 0.9; }
    50% { transform: scale(1.15); opacity: 1; }
}

.ambient-text {
    font-weight: 500;
    color: var(--ink-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ambient-text strong {
    color: var(--brand-teal-700);
}

.ambient-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.btn-ambient-action {
    background: var(--brand-teal-600);
    color: var(--white);
    border: none;
    border-radius: var(--radius-pill);
    padding: 0.28rem 0.75rem;
    font-size: 0.74rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-ambient-action:hover {
    background: var(--brand-teal-700);
    transform: translateY(-1px);
}

/* Botón Flotante Permanente (Glass Pill Launcher) */
.global-copilot-launcher {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: var(--radius-pill);
    color: var(--ink-primary);
    font-size: 0.82rem;
    font-weight: 600;
    box-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.08), 0 0 0 1px rgba(19, 110, 106, 0.08);
    cursor: pointer;
    z-index: 990;
    transition: var(--transition-smooth);
}

.global-copilot-launcher:hover {
    transform: translateY(-2px);
    background: #FFFFFF;
    border-color: rgba(19, 110, 106, 0.35);
    box-shadow: 0 8px 24px -4px rgba(19, 110, 106, 0.18), 0 0 0 1px rgba(19, 110, 106, 0.2);
}

.global-copilot-launcher.active {
    background: var(--brand-teal-50);
    border-color: var(--brand-teal-600);
    color: var(--brand-teal-700);
}

/* Pulso Orgánico Breathing */
.copilot-pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--brand-teal-600);
    display: inline-block;
    box-shadow: 0 0 0 0 rgba(19, 110, 106, 0.6);
    animation: copilotBreathe 2.4s infinite cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes copilotBreathe {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(19, 110, 106, 0.5); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 6px rgba(19, 110, 106, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(19, 110, 106, 0); }
}

.launcher-kbd {
    font-size: 0.68rem;
    padding: 1px 5px;
    border-radius: 4px;
    background: rgba(15, 23, 42, 0.05);
    color: var(--ink-muted);
    border: 1px solid rgba(15, 23, 42, 0.08);
}

/* Global Copilot Drawer (Lateral Global Anclable / Deslizable) */
.global-copilot-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 360px;
    background: #FFFFFF;
    border-left: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-drawer);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
    transform: translateX(105%);
    opacity: 0;
    pointer-events: none;
}

.global-copilot-drawer.open {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
}

/* Drawer Header */
.copilot-drawer-header {
    padding: 0.95rem 1.15rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-subtle);
    background: #FAFBFC;
}

.copilot-brand-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.copilot-sparkle-avatar {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--brand-teal-50);
    color: var(--brand-teal-600);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    border: 1px solid var(--brand-teal-alpha-12);
}

.copilot-brand-title h3 {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--ink-primary);
    margin: 0;
    line-height: 1.2;
}

.copilot-context-label {
    font-size: 0.7rem;
    color: var(--ink-muted);
    display: block;
}

.copilot-header-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.copilot-btn-icon {
    background: none;
    border: none;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0.3rem 0.45rem;
    border-radius: 6px;
    color: var(--ink-muted);
    transition: var(--transition);
}

.copilot-btn-icon:hover {
    background: var(--mist);
    color: var(--ink-primary);
}

/* Proactive Banner */
.copilot-proactive-banner {
    padding: 0.5rem 1rem;
    background: var(--brand-teal-50);
    border-bottom: 1px solid var(--brand-teal-alpha-12);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.74rem;
    color: var(--brand-teal-900);
    font-weight: 600;
}

/* Copilot Drawer Tabs */
.copilot-drawer-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--surface-subtle);
    padding: 0 var(--space-md);
    gap: var(--space-xs);
}

.copilot-tab-btn {
    background: none;
    border: none;
    padding: 0.65rem 0.85rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--ink-muted);
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: var(--transition-fast);
}

.copilot-tab-btn:hover {
    color: var(--ink);
}

.copilot-tab-btn.active {
    color: var(--teal);
    border-bottom-color: var(--teal);
}

/* Drawer Body & Insight Cards */
.copilot-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 0.85rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.copilot-drawer-body::-webkit-scrollbar {
    width: 4px;
}
.copilot-drawer-body::-webkit-scrollbar-thumb {
    background: rgba(15, 23, 42, 0.08);
    border-radius: 4px;
}

.copilot-insight-card {
    background: #FFFFFF;
    border: 1px solid var(--border-regular);
    border-radius: var(--radius-md);
    padding: 0.85rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.copilot-insight-card:hover {
    border-color: rgba(19, 110, 106, 0.35);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.copilot-insight-card.alert-p0 {
    border-color: rgba(224, 82, 52, 0.35);
    background: linear-gradient(180deg, #FFFFFF 0%, #FFFDFD 100%);
}

.copilot-insight-card.alert-p0:hover {
    border-color: var(--coral);
    box-shadow: 0 4px 12px rgba(224, 82, 52, 0.12);
}

.copilot-insight-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.copilot-insight-badge {
    font-size: 0.66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--brand-teal-alpha-06);
    color: var(--brand-teal-700);
}

.copilot-insight-badge.urgent {
    background: rgba(224, 82, 52, 0.1);
    color: var(--coral);
}

.copilot-insight-badge.money {
    background: rgba(4, 120, 87, 0.1);
    color: #047857;
}

.copilot-insight-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--ink-primary);
    line-height: 1.3;
}

.copilot-insight-desc {
    font-size: 0.76rem;
    color: var(--ink-secondary);
    line-height: 1.45;
}

.copilot-insight-rationale {
    font-size: 0.7rem;
    color: var(--ink-muted);
    font-style: italic;
    background: #F8FAFC;
    padding: 0.35rem 0.55rem;
    border-radius: 6px;
    border: 1px solid rgba(15, 23, 42, 0.04);
}

.copilot-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    width: 100%;
    padding: 0.42rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: #FFFFFF;
    background: linear-gradient(180deg, var(--brand-teal-600) 0%, #0D5C58 100%);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(19, 110, 106, 0.25);
    transition: var(--transition);
    margin-top: 0.25rem;
}

.copilot-action-btn:hover {
    box-shadow: 0 3px 8px rgba(19, 110, 106, 0.35);
    transform: translateY(-1px);
}

/* Revenue Widget / ROI Counter */
.copilot-roi-card {
    background: linear-gradient(135deg, rgba(19, 110, 106, 0.06) 0%, rgba(255, 255, 255, 0.9) 100%);
    border: 1px solid var(--brand-teal-alpha-12);
    border-radius: var(--radius-md);
    padding: 0.75rem;
}

.copilot-roi-title {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--brand-teal-700);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.25rem;
}

.copilot-roi-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
}

.copilot-roi-val {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--ink-primary);
}

.copilot-roi-lbl {
    font-size: 0.65rem;
    color: var(--ink-muted);
}

/* Drawer Footer con Input Omnipresente */
.copilot-drawer-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-subtle);
    background: #FAFBFC;
}

.copilot-omni-form {
    position: relative;
    display: flex;
    align-items: center;
}

.copilot-omni-input {
    width: 100%;
    padding: 0.45rem 2.2rem 0.45rem 0.75rem;
    font-size: 0.78rem;
    background: #FFFFFF;
    border: 1px solid var(--border-regular);
    border-radius: 20px;
    color: var(--ink-primary);
    outline: none;
    transition: var(--transition-smooth);
}

.copilot-omni-input:focus {
    border-color: var(--brand-teal-600);
    box-shadow: 0 0 0 3px var(--brand-teal-alpha-12);
}

.copilot-omni-submit {
    position: absolute;
    right: 4px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--brand-teal-600);
    color: #FFFFFF;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    transition: var(--transition);
}

.copilot-omni-submit:hover {
    background: var(--brand-teal-700);
    transform: scale(1.05);
}

/* Modo Anclado en Escritorio (> 1200px) */
@media (min-width: 1200px) {
    body.copilot-docked .main-content,
    .main-content.copilot-docked {
        margin-right: 360px;
        transition: margin-right 0.22s ease-out;
        contain: layout;
    }
}

@media (max-width: 768px) {
    .global-copilot-drawer {
        width: 100%;
    }
    .global-copilot-launcher {
        bottom: 16px;
        right: 16px;
        padding: 6px 12px;
        font-size: 0.76rem;
    }
}

/* ==========================================================================
   🧪 SANDBOX DE SIMULACIÓN & AUDITOR IA-AS-A-JUDGE (Doma Aesthetic)
   ========================================================================== */

.sandbox-layout-grid {
    display: grid;
    grid-template-columns: 300px 1fr 360px;
    gap: 1.25rem;
    align-items: stretch;
    min-height: calc(100vh - 240px);
}

@media (max-width: 1240px) {
    .sandbox-layout-grid {
        grid-template-columns: 280px 1fr;
    }
    .sandbox-judge-panel {
        grid-column: span 2;
    }
}

@media (max-width: 860px) {
    .sandbox-layout-grid {
        grid-template-columns: 1fr;
    }
    .sandbox-judge-panel {
        grid-column: span 1;
    }
}

.sandbox-judge-panel {
    max-height: calc(100vh - 220px);
    overflow-y: auto;
}

.sandbox-card {
    background: var(--white);
    border: 1px solid var(--mist);
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(22, 38, 61, 0.04);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 1.25rem;
}

.sandbox-card-header {
    border-bottom: 1px solid var(--mist);
    padding-bottom: 0.85rem;
    margin-bottom: 1rem;
}

/* Escenarios Adversarios */
.sandbox-scenarios-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    overflow-y: auto;
    max-height: 440px;
    padding-right: 0.25rem;
}

.sandbox-scenario-btn {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    background: var(--porcelain);
    border: 1px solid var(--mist);
    border-radius: 8px;
    padding: 0.7rem 0.85rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    width: 100%;
}

.sandbox-scenario-btn:hover {
    background: #FFFFFF;
    border-color: var(--teal);
    box-shadow: 0 2px 8px rgba(22, 124, 120, 0.08);
    transform: translateY(-1px);
}

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

.sandbox-scenario-btn .scenario-icon {
    font-size: 1.35rem;
    line-height: 1;
    flex-shrink: 0;
    margin-top: 2px;
}

.sandbox-scenario-btn .scenario-info {
    flex: 1;
    min-width: 0;
}

.sandbox-scenario-btn .scenario-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 0.2rem;
    line-height: 1.25;
}

.sandbox-scenario-btn .scenario-desc {
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.35;
}

/* Chat Interactivo Simulado */
.sandbox-chat-panel {
    display: flex;
    flex-direction: column;
}

.sandbox-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--mist);
    padding-bottom: 0.75rem;
    margin-bottom: 0.85rem;
}

.sandbox-live-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #10B981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
    display: inline-block;
    animation: sandbox-pulse 2s infinite;
}

@keyframes sandbox-pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.sandbox-messages-container {
    flex: 1;
    min-height: 380px;
    max-height: 480px;
    overflow-y: auto;
    padding: 1rem;
    background: var(--porcelain);
    border: 1px solid var(--mist);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    margin-bottom: 1rem;
}

.sandbox-empty-chat {
    margin: auto;
    text-align: center;
    padding: 2rem 1rem;
}

.sandbox-msg {
    display: flex;
    flex-direction: column;
    max-width: 82%;
    animation: fadeIn 0.2s ease-out;
}

.sandbox-msg.user {
    align-self: flex-end;
}

.sandbox-msg.agent {
    align-self: flex-start;
}

.sandbox-msg-bubble {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-size: 0.88rem;
    line-height: 1.45;
    position: relative;
    word-break: break-word;
}

.sandbox-msg.user .sandbox-msg-bubble {
    background: var(--teal);
    color: #FFFFFF;
    border-bottom-right-radius: 3px;
}

.sandbox-msg.agent .sandbox-msg-bubble {
    background: var(--white);
    color: var(--ink);
    border: 1px solid var(--mist);
    border-bottom-left-radius: 3px;
    box-shadow: 0 1px 4px rgba(22, 38, 61, 0.04);
}

.sandbox-msg-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.sandbox-msg.user .sandbox-msg-meta {
    justify-content: flex-end;
}

.sandbox-msg.agent .sandbox-msg-meta {
    justify-content: flex-start;
}

.sandbox-escalation-tag {
    background: rgba(231, 101, 71, 0.1);
    color: var(--coral);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.65rem;
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}

/* Panel IA-as-a-Judge */
.judge-dimensions-grid {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.judge-dim-item {
    background: var(--porcelain);
    border: 1px solid var(--mist);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
}

.judge-dim-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 0.35rem;
}

.judge-progress-track {
    background: rgba(22, 38, 61, 0.08);
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
}

.judge-progress-fill {
    height: 100%;
    border-radius: 3px;
    background: var(--teal);
    transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==========================================================================
   Smart Broadcast 2.0 & Centro de Integraciones (Doma Aesthetic)
   ========================================================================== */

/* Grid de Plantillas en 1 Clic para Integraciones */
.integration-templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.integration-template-card {
    background: var(--porcelain);
    border: 1px solid var(--mist);
    border-radius: 12px;
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    position: relative;
    overflow: hidden;
}

.integration-template-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(22, 38, 61, 0.06);
    border-color: rgba(22, 124, 120, 0.4);
}

.template-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.65rem;
}

.template-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--ink);
    margin: 0.25rem 0 0.4rem 0;
    line-height: 1.3;
}

.template-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
    margin-bottom: 1rem;
    flex-grow: 1;
}

.template-badge {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 8px;
    border-radius: 6px;
}

.ping-result-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

.ping-result-badge.success {
    background: rgba(22, 124, 120, 0.1);
    color: var(--teal);
    border: 1px solid rgba(22, 124, 120, 0.25);
}

.ping-result-badge.error {
    background: rgba(231, 101, 71, 0.1);
    color: var(--coral);
    border: 1px solid rgba(231, 101, 71, 0.25);
}

/* Banner Regulatorio TCPA Florida */
.broadcast-tcpa-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(22, 124, 120, 0.06);
    border: 1px solid rgba(22, 124, 120, 0.2);
    border-radius: 10px;
    padding: 0.75rem 1.1rem;
    margin-bottom: 1.25rem;
    font-size: 0.85rem;
    color: var(--ink);
}

.broadcast-tcpa-banner.warning {
    background: rgba(231, 101, 71, 0.06);
    border-color: rgba(231, 101, 71, 0.25);
}

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

.tcpa-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--teal);
    box-shadow: 0 0 0 3px rgba(22, 124, 120, 0.2);
}

.tcpa-dot.warning {
    background: var(--coral);
    box-shadow: 0 0 0 3px rgba(231, 101, 71, 0.2);
}

/* Opciones de Copy Generadas por IA */
.broadcast-ai-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.broadcast-copy-card {
    background: var(--porcelain);
    border: 1px solid var(--mist);
    border-radius: 8px;
    padding: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.broadcast-copy-card:hover {
    border-color: var(--teal);
    background: #FFFFFF;
    box-shadow: 0 3px 10px rgba(22, 38, 61, 0.05);
}

.broadcast-copy-card.selected {
    border-color: var(--teal);
    background: #FFFFFF;
    box-shadow: 0 0 0 2px var(--teal);
}

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

.copy-card-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--ink);
}

.copy-card-rate {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--teal);
    background: rgba(22, 124, 120, 0.08);
    padding: 2px 6px;
    border-radius: 4px;
}

.copy-card-text {
    font-size: 0.82rem;
    color: var(--ink);
    line-height: 1.45;
    margin-bottom: 0.5rem;
    white-space: pre-wrap;
}
