/* ==========================================================================
   PULOLA CRM - Diseño Moderno, Intuitivo y Responsive
   ========================================================================== */

:root {
    --crm-primary: #4f46e5;
    --crm-primary-hover: #4338ca;
    --crm-primary-light: #eef2ff;
    --crm-primary-dark: #3730a3;
    
    --crm-bg: #f8fafc;
    --crm-surface: #ffffff;
    --crm-surface-card: #ffffff;
    --crm-border: #e2e8f0;
    --crm-border-hover: #cbd5e1;
    
    --crm-text: #0f172a;
    --crm-text-muted: #64748b;
    --crm-text-light: #94a3b8;
    
    --status-nuevo: #0284c7;
    --status-nuevo-bg: #e0f2fe;
    --status-contactado: #d97706;
    --status-contactado-bg: #fef3c7;
    --status-cualificado: #059669;
    --status-cualificado-bg: #d1fae5;
    --status-convertido: #7c3aed;
    --status-convertido-bg: #ede9fe;
    --status-descartado: #64748b;
    --status-descartado-bg: #f1f5f9;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

    --header-height: 64px;
    --bnav-height: 62px;
    --transition-fast: 0.15s ease;
    --transition-smooth: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body.crm-body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--crm-bg);
    color: var(--crm-text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* ==========================================================================
   Header Superior
   ========================================================================== */
.crm-header {
    position: sticky;
    top: 0;
    z-index: 40;
    height: var(--header-height);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--crm-border);
}

.crm-header-container {
    max-width: 1280px;
    height: 100%;
    margin: 0 auto;
    padding: 0 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.crm-brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    cursor: pointer;
    text-decoration: none;
}

.crm-logo-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--crm-primary), #6366f1);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.35);
}

.crm-brand-text {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.brand-name {
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: -0.02em;
    color: var(--crm-text);
}

.brand-badge {
    font-size: 0.68rem;
    font-weight: 700;
    background: var(--crm-primary-light);
    color: var(--crm-primary);
    padding: 0.15rem 0.45rem;
    border-radius: var(--radius-sm);
    letter-spacing: 0.05em;
}

/* Navegación Desktop */
.crm-desktop-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.crm-desktop-nav .nav-item {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.5rem 0.9rem;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--crm-text-muted);
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: all var(--transition-fast);
}

.crm-desktop-nav .nav-item:hover {
    color: var(--crm-text);
    background: var(--crm-border);
}

.crm-desktop-nav .nav-item.active {
    color: var(--crm-primary);
    background: var(--crm-primary-light);
    font-weight: 600;
}

.crm-desktop-nav .nav-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.crm-header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.server-badge {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 0.3rem 0.6rem;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 500;
    color: #64748b;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    cursor: default;
    user-select: none;
}

.server-dot {
    width: 6px;
    height: 6px;
    background-color: #3b82f6;
    border-radius: var(--radius-full);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.tenant-badge {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--crm-bg);
    border: 1px solid var(--crm-border);
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius-full);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--crm-text-muted);
}

.tenant-dot {
    width: 7px;
    height: 7px;
    background-color: var(--status-cualificado);
    border-radius: var(--radius-full);
    box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.2);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, #334155, #0f172a);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.78rem;
    border: 2px solid #ffffff;
    box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   Contenido Principal
   ========================================================================== */
.crm-main {
    flex: 1;
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
    padding: 1.5rem 1.25rem 5rem 1.25rem;
}

.crm-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--crm-text);
}

.page-subtitle {
    font-size: 0.88rem;
    color: var(--crm-text-muted);
    margin-top: 0.2rem;
}

/* ==========================================================================
   Tarjetas KPI
   ========================================================================== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    background: var(--crm-surface-card);
    border: 1px solid var(--crm-border);
    border-radius: var(--radius-md);
    padding: 1.15rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-smooth), box-shadow var(--transition-smooth), border-color var(--transition-smooth);
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--crm-border-hover);
}

.kpi-info {
    display: flex;
    flex-direction: column;
}

.kpi-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--crm-text-muted);
}

.kpi-value {
    font-size: 1.65rem;
    font-weight: 700;
    color: var(--crm-text);
    margin-top: 0.25rem;
}

.kpi-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.kpi-icon.total {
    background: var(--crm-primary-light);
    color: var(--crm-primary);
}

.kpi-icon.new {
    background: var(--status-nuevo-bg);
    color: var(--status-nuevo);
}

.kpi-icon.contacted {
    background: var(--status-contactado-bg);
    color: var(--status-contactado);
}

.kpi-icon.qualified {
    background: var(--status-cualificado-bg);
    color: var(--status-cualificado);
}

/* ==========================================================================
   Barra de Herramientas (Búsqueda y Filtros)
   ========================================================================== */
.crm-toolbar {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    margin-bottom: 1.5rem;
}

.search-box {
    position: relative;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--crm-text-light);
    pointer-events: none;
}

.search-box input {
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 2.75rem;
    font-size: 0.92rem;
    font-family: inherit;
    border: 1px solid var(--crm-border);
    border-radius: var(--radius-full);
    background: var(--crm-surface);
    color: var(--crm-text);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
}

.search-box input:focus {
    outline: none;
    border-color: var(--crm-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.btn-clear-search {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--crm-text-light);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0.2rem;
}

.filter-pills {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.35rem;
    scrollbar-width: none;
}

.filter-pills::-webkit-scrollbar {
    display: none;
}

.pill {
    padding: 0.45rem 0.95rem;
    font-size: 0.82rem;
    font-weight: 500;
    font-family: inherit;
    border: 1px solid var(--crm-border);
    border-radius: var(--radius-full);
    background: var(--crm-surface);
    color: var(--crm-text-muted);
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition-fast);
}

.pill:hover {
    border-color: var(--crm-border-hover);
    color: var(--crm-text);
}

.pill.active {
    background: var(--crm-text);
    border-color: var(--crm-text);
    color: #ffffff;
    font-weight: 600;
}

/* ==========================================================================
   Tarjetas de Leads (Grid Responsive)
   ========================================================================== */
.leads-container {
    min-height: 250px;
}

.leads-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
    gap: 1.15rem;
}

.lead-card {
    background: var(--crm-surface-card);
    border: 1px solid var(--crm-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform var(--transition-smooth), box-shadow var(--transition-smooth), border-color var(--transition-smooth);
    position: relative;
}

.lead-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--crm-border-hover);
}

.lead-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}

.lead-avatar-name {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.lead-initials {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.lead-company-info {
    min-width: 0;
}

.lead-company-name {
    font-size: 1.02rem;
    font-weight: 700;
    color: var(--crm-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lead-sector-cif {
    font-size: 0.78rem;
    color: var(--crm-text-muted);
    margin-top: 0.15rem;
}

/* Badges de Estado */
.status-badge {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

.status-badge.NUEVO {
    background: var(--status-nuevo-bg);
    color: var(--status-nuevo);
}

.status-badge.CONTACTADO {
    background: var(--status-contactado-bg);
    color: var(--status-contactado);
}

.status-badge.CUALIFICADO {
    background: var(--status-cualificado-bg);
    color: var(--status-cualificado);
}

.status-badge.CONVERTIDO {
    background: var(--status-convertido-bg);
    color: var(--status-convertido);
}

.status-badge.DESCARTADO {
    background: var(--status-descartado-bg);
    color: var(--status-descartado);
}

/* Cuerpo de la Tarjeta */
.lead-card-body {
    margin-bottom: 1.15rem;
    font-size: 0.85rem;
    color: var(--crm-text-muted);
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.contact-person {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
    color: var(--crm-text);
}

.contact-role {
    font-weight: 400;
    color: var(--crm-text-light);
    font-size: 0.78rem;
}

.lead-location {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
}

.lead-notes-preview {
    margin-top: 0.4rem;
    padding: 0.5rem 0.65rem;
    background: var(--crm-bg);
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    color: var(--crm-text-muted);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Botones de Acción Táctiles */
.lead-card-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--crm-border);
}

.action-touch-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    height: 38px;
    font-size: 0.82rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    text-decoration: none;
    border: 1px solid var(--crm-border);
    background: var(--crm-surface);
    color: var(--crm-text);
    transition: all var(--transition-fast);
}

.action-touch-btn.call:hover {
    background: var(--status-cualificado-bg);
    color: var(--status-cualificado);
    border-color: var(--status-cualificado);
}

.action-touch-btn.mail:hover {
    background: var(--crm-primary-light);
    color: var(--crm-primary);
    border-color: var(--crm-primary);
}

.action-icon-btn {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--crm-border);
    background: var(--crm-surface);
    color: var(--crm-text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.action-icon-btn:hover {
    color: var(--crm-text);
    border-color: var(--crm-border-hover);
    background: var(--crm-bg);
}

/* ==========================================================================
   Estado Vacío (Empty State)
   ========================================================================== */
.empty-state {
    text-align: center;
    padding: 3.5rem 1.5rem;
    background: var(--crm-surface);
    border: 1px dashed var(--crm-border-hover);
    border-radius: var(--radius-lg);
}

.empty-icon {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-full);
    background: var(--crm-primary-light);
    color: var(--crm-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.25rem auto;
}

.empty-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--crm-text);
}

.empty-desc {
    font-size: 0.88rem;
    color: var(--crm-text-muted);
    max-width: 420px;
    margin: 0.35rem auto 1.5rem auto;
}

/* ==========================================================================
   Botones Principales
   ========================================================================== */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.65rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    color: #ffffff;
    background: var(--crm-primary);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.3);
    transition: all var(--transition-fast);
}

.btn-primary:hover {
    background: var(--crm-primary-hover);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
    transform: translateY(-1px);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.65rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    color: var(--crm-text);
    background: var(--crm-surface);
    border: 1px solid var(--crm-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-secondary:hover {
    background: var(--crm-bg);
    border-color: var(--crm-border-hover);
}

/* Floating Action Button (Móvil) */
.fab-btn {
    position: fixed;
    right: 1.25rem;
    bottom: calc(var(--bnav-height) + 1.25rem);
    width: 54px;
    height: 54px;
    border-radius: var(--radius-full);
    background: var(--crm-primary);
    color: #ffffff;
    border: none;
    box-shadow: var(--shadow-lg), 0 4px 16px rgba(79, 70, 229, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 35;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.fab-btn:active {
    transform: scale(0.92);
}

/* ==========================================================================
   Drawer / Slide-Over Modal
   ========================================================================== */
.crm-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 50;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-smooth), visibility var(--transition-smooth);
}

.crm-modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.crm-slideover,
.crm-lead-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.96);
    width: 92vw;
    max-width: 960px;
    height: 86vh;
    max-height: 850px;
    background: var(--crm-surface);
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25);
    z-index: 55;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.crm-slideover.active,
.crm-lead-dialog.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.dialog-header,
.slideover-header {
    padding: 1.1rem 1.5rem;
    border-bottom: 1px solid var(--crm-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #ffffff;
    flex-shrink: 0;
}

.dialog-header-left {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.dialog-avatar {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--crm-primary), #6366f1);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
    flex-shrink: 0;
}

.dialog-title-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.dialog-title,
.slideover-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--crm-text);
    letter-spacing: -0.015em;
}

.dialog-subtitle,
.slideover-subtitle {
    font-size: 0.8rem;
    color: var(--crm-text-muted);
}

.dialog-header-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.btn-action-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--crm-border);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: var(--transition-fast);
}

.btn-action-icon.call {
    color: #059669;
    background: #ecfdf5;
    border-color: #a7f3d0;
}

.btn-action-icon.call:hover {
    background: #d1fae5;
    transform: translateY(-1px);
}

.btn-action-icon.mail {
    color: #4f46e5;
    background: #eef2ff;
    border-color: #c7d2fe;
}

.btn-action-icon.mail:hover {
    background: #e0e7ff;
    transform: translateY(-1px);
}

.btn-close-modal {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--crm-border);
    background: var(--crm-bg);
    color: var(--crm-text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.btn-close-modal:hover {
    background: #fee2e2;
    color: #dc2626;
    border-color: #fca5a5;
}

/* ==========================================================================
   Barra de Pestañas (Tabs)
   ========================================================================== */
.dialog-nav-tabs {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem 1.5rem;
    background: #f1f5f9;
    border-bottom: 1px solid var(--crm-border);
    flex-shrink: 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.dialog-nav-tabs::-webkit-scrollbar {
    display: none;
}

.tab-label-desktop {
    display: inline;
}

.tab-label-mobile {
    display: none;
}

.dialog-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: transparent;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--crm-text-muted);
    cursor: pointer;
    transition: var(--transition-fast);
}

.dialog-tab:hover {
    color: var(--crm-text);
    background: #e2e8f0;
}

.dialog-tab.active {
    color: var(--crm-primary);
    background: #ffffff;
    border-color: var(--crm-border);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

.tab-badge {
    background: var(--crm-primary-light);
    color: var(--crm-primary);
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.1rem 0.5rem;
    border-radius: var(--radius-full);
}

/* ==========================================================================
   Cuerpo Desplazable Único de la Ficha
   ========================================================================== */
.dialog-body-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.5rem;
    background: #f8fafc;
    min-height: 0;
}

.tab-pane {
    display: none;
    width: 100%;
}

.tab-pane.active {
    display: block;
}

.tab-pane-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding: 1rem 1.25rem;
    background: #ffffff;
    border: 1px solid var(--crm-border);
    border-radius: var(--radius-md);
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

.tab-pane-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--crm-text);
    margin-bottom: 0.15rem;
}

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

.panel-section {
    background: #ffffff;
    border: 1px solid var(--crm-border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
    margin-bottom: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.panel-section-title {
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--crm-text-muted);
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--crm-border);
}

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    width: 100%;
    box-sizing: border-box;
}

.col-span-2 {
    grid-column: span 2;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    box-sizing: border-box;
    min-width: 0;
    padding: 0.65rem 0.85rem;
    font-size: 0.9rem;
    font-family: inherit;
    border: 1px solid var(--crm-border);
    border-radius: var(--radius-sm);
    background: #ffffff;
    color: var(--crm-text);
    transition: var(--transition-fast);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--crm-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.form-footer-action {
    display: flex;
    justify-content: flex-end;
    padding: 1rem 0 1.5rem 0;
}

.btn-lg {
    padding: 0.8rem 2rem;
    font-size: 0.95rem;
    font-weight: 600;
}

/* ==========================================================================
   Listado de Oportunidades
   ========================================================================== */
.deals-container-full {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
}

.deal-card-row {
    background: #ffffff;
    border: 1px solid var(--crm-border);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
    transition: var(--transition-fast);
}

.deal-card-row:hover {
    border-color: var(--crm-primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.deal-main {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.deal-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--crm-text);
}

.deal-meta-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.78rem;
    color: var(--crm-text-muted);
}

.deal-amount-box {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--crm-primary);
    text-align: right;
    white-space: nowrap;
}

.deal-stage {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.2rem 0.55rem;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    display: inline-block;
}

.deal-stage.prospeccion { background: #f1f5f9; color: #475569; }
.deal-stage.cualificado { background: #e0f2fe; color: #0284c7; }
.deal-stage.propuesta { background: #ede9fe; color: #7c3aed; }
.deal-stage.negociacion { background: #fef3c7; color: #d97706; }
.deal-stage.ganada { background: #d1fae5; color: #059669; }
.deal-stage.perdida { background: #fee2e2; color: #dc2626; }

/* ==========================================================================
   Línea de Tiempo y Estados Vacíos
   ========================================================================== */
.timeline-container-full {
    width: 100%;
}

.empty-state-pane {
    text-align: center;
    padding: 3.5rem 1.5rem;
    background: #ffffff;
    border: 2px dashed var(--crm-border);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.65rem;
}

.empty-state-pane .empty-icon {
    font-size: 2.75rem;
    line-height: 1;
    margin-bottom: 0.25rem;
}

.empty-state-pane h4 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--crm-text);
}

.empty-state-pane p {
    font-size: 0.85rem;
    color: var(--crm-text-muted);
    max-width: 400px;
    margin-bottom: 0.6rem;
}

/* ==========================================================================
   Modales Emergentes (Popups para Nueva Oportunidad / Nueva Actividad)
   ========================================================================== */
.crm-modal-backdrop.submodal {
    z-index: 70;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
}

.crm-popup-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    width: 92vw;
    max-width: 540px;
    background: #ffffff;
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.35);
    z-index: 75;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.crm-popup-dialog.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.popup-header {
    padding: 1.1rem 1.5rem;
    border-bottom: 1px solid var(--crm-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #ffffff;
}

.popup-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--crm-text);
}

.popup-subtitle {
    font-size: 0.78rem;
    color: var(--crm-text-muted);
}

.popup-body {
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 75vh;
    overflow-y: auto;
    background: #ffffff;
}

.popup-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--crm-border);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    background: #f8fafc;
}

.act-type-selector {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.act-pill {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid var(--crm-border);
    background: #ffffff;
    border-radius: var(--radius-full);
    cursor: pointer;
    color: var(--crm-text-muted);
    transition: var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.act-pill:hover {
    border-color: var(--crm-border-hover);
    color: var(--crm-text);
}

.act-pill.active {
    background: var(--crm-primary);
    color: #ffffff;
    border-color: var(--crm-primary);
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.25);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

.checkbox-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.85rem;
    color: var(--crm-text);
    cursor: pointer;
}


.slideover-form {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.form-section-title {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--crm-text-muted);
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--crm-border);
}

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

.form-row {
    display: flex;
    gap: 0.75rem;
}

.col-6 {
    flex: 1;
}

.form-group label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--crm-text);
}

.required {
    color: var(--crm-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 0.65rem 0.85rem;
    font-size: 0.9rem;
    font-family: inherit;
    border: 1px solid var(--crm-border);
    border-radius: var(--radius-sm);
    background: var(--crm-surface);
    color: var(--crm-text);
    transition: all var(--transition-fast);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--crm-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.slideover-actions {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--crm-border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    background: var(--crm-surface);
}

/* ==========================================================================
   Bottom Navigation (Móvil)
   ========================================================================== */
.crm-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bnav-height);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--crm-border);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 30;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.bnav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--crm-text-muted);
    text-decoration: none;
    transition: all var(--transition-fast);
}

.bnav-item.active {
    color: var(--crm-primary);
    font-weight: 700;
}

.bnav-item.disabled {
    opacity: 0.4;
}

/* ==========================================================================
   Toasts y Notificaciones
   ========================================================================== */
.crm-toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.crm-toast {
    background: #0f172a;
    color: #ffffff;
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    animation: toastSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.crm-toast.success {
    background: #065f46;
}

.crm-toast.error {
    background: #991b1b;
}

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

/* Spinner de carga */
.loading-spinner-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    gap: 0.75rem;
    color: var(--crm-text-muted);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--crm-border);
    border-top-color: var(--crm-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ==========================================================================
   Utilidades Responsive
   ========================================================================== */
.show-on-mobile {
    display: none !important;
}

@media (max-width: 768px) {
    .hide-on-mobile {
        display: none !important;
    }
    .show-on-mobile {
        display: flex !important;
    }
    .crm-main {
        padding-bottom: calc(var(--bnav-height) + 4.5rem);
    }
    .leads-grid {
        grid-template-columns: 1fr;
    }
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .crm-slideover {
        max-width: 100%;
    }
    .crm-toast-container {
        left: 1rem;
        right: 1rem;
        bottom: calc(var(--bnav-height) + 1rem);
    }
}

/* ==========================================================================
   Slide-over Tabs & Actividades Timeline
   ========================================================================== */
.slideover-tabs {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--crm-border);
}

.slideover-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.85rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--crm-text-muted);
    cursor: pointer;
    transition: var(--transition-fast);
}

.slideover-tab-btn:hover {
    color: var(--crm-text);
    background: #e2e8f0;
}

.slideover-tab-btn.active {
    color: var(--crm-primary);
    background: #ffffff;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

.tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: var(--radius-full);
    background: var(--crm-primary-light);
    color: var(--crm-primary);
    font-size: 0.7rem;
    font-weight: 700;
}

.actividades-aviso {
    padding: 1rem;
    margin: 1.25rem;
    background: #fffbeb;
    border: 1px solid #fef3c7;
    border-radius: var(--radius-md);
    color: #b45309;
    font-size: 0.875rem;
}

.quick-activity-card {
    background: #f8fafc;
    border: 1px solid var(--crm-border);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin: 1.25rem 1.25rem 1.5rem 1.25rem;
}

.quick-act-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--crm-text);
    margin-bottom: 0.65rem;
}

.act-type-selector {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.act-type-btn {
    padding: 0.35rem 0.65rem;
    font-size: 0.775rem;
    font-weight: 500;
    border: 1px solid var(--crm-border);
    background: #ffffff;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--crm-text-muted);
    transition: var(--transition-fast);
}

.act-type-btn:hover {
    border-color: var(--crm-primary);
    color: var(--crm-primary);
}

.act-type-btn.active {
    background: var(--crm-primary);
    border-color: var(--crm-primary);
    color: #ffffff;
}

.timeline-heading {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--crm-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0 1.25rem;
    margin-bottom: 0.75rem;
}

.timeline-stream {
    padding: 0 1.25rem 2rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.timeline-item {
    position: relative;
    padding-left: 1.75rem;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 24px;
    bottom: -15px;
    width: 2px;
    background: var(--crm-border);
}

.timeline-item:last-child::before {
    display: none;
}

.timeline-dot {
    position: absolute;
    left: 0;
    top: 4px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #ffffff;
    border: 3px solid var(--crm-primary);
}

.timeline-dot.llamada { border-color: #0284c7; }
.timeline-dot.reunion { border-color: #7c3aed; }
.timeline-dot.email { border-color: #d97706; }
.timeline-dot.tarea { border-color: #ef4444; }
.timeline-dot.nota { border-color: #64748b; }

.timeline-card {
    background: #ffffff;
    border: 1px solid var(--crm-border);
    border-radius: var(--radius-md);
    padding: 0.85rem 1rem;
    box-shadow: var(--shadow-sm);
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.35rem;
}

.timeline-badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
}

.timeline-badge.llamada { background: #e0f2fe; color: #0284c7; }
.timeline-badge.reunion { background: #ede9fe; color: #7c3aed; }
.timeline-badge.email { background: #fef3c7; color: #d97706; }
.timeline-badge.tarea { background: #fee2e2; color: #ef4444; }
.timeline-badge.nota { background: #f1f5f9; color: #64748b; }

.timeline-date {
    font-size: 0.75rem;
    color: var(--crm-text-light);
}

.timeline-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--crm-text);
    margin-bottom: 0.25rem;
}

.timeline-desc {
    font-size: 0.825rem;
    color: var(--crm-text-muted);
    white-space: pre-line;
}

.timeline-task-status {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
}

.timeline-task-status.pending {
    background: #fff1f2;
    color: #e11d48;
    font-weight: 600;
}

.timeline-task-status.done {
    background: #ecfdf5;
    color: #059669;
    font-weight: 600;
}

/* Responsive para Workspace Dialog de Leads y Modales */
@media (max-width: 768px) {
    .crm-lead-dialog {
        top: 0 !important;
        left: 0 !important;
        transform: translateY(100%) !important;
        width: 100vw !important;
        max-width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        border-radius: 0 !important;
    }
    .crm-lead-dialog.active {
        transform: translateY(0) !important;
    }
    .tab-label-desktop {
        display: none !important;
    }
    .tab-label-mobile {
        display: inline !important;
    }
    .dialog-nav-tabs {
        display: grid !important;
        grid-template-columns: 1fr 1fr 1fr !important;
        padding: 0.35rem 0.5rem !important;
        gap: 0.35rem !important;
        overflow-x: hidden !important;
        scrollbar-width: none !important;
        -ms-overflow-style: none !important;
    }
    .dialog-nav-tabs::-webkit-scrollbar {
        display: none !important;
    }
    .dialog-tab {
        white-space: nowrap !important;
        padding: 0.45rem 0.2rem !important;
        font-size: 0.76rem !important;
        justify-content: center !important;
        gap: 0.25rem !important;
        text-align: center !important;
        border-radius: var(--radius-sm) !important;
    }
    .dialog-tab svg {
        width: 13px !important;
        height: 13px !important;
        flex-shrink: 0 !important;
    }
    .tab-badge {
        font-size: 0.65rem !important;
        padding: 0.05rem 0.3rem !important;
        min-width: 16px !important;
        height: 16px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    .dialog-body-scroll {
        padding: 1rem;
    }
    .form-grid-2 {
        grid-template-columns: 1fr !important;
    }
    .col-span-2 {
        grid-column: span 1 !important;
    }
    .tab-pane-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    .tab-pane-header button {
        width: 100%;
    }
    .deal-card-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.6rem;
    }
    .deal-amount-box {
        text-align: left;
    }
    .crm-popup-dialog {
        width: 95vw !important;
        max-width: 95vw !important;
    }
}

/* ==========================================================================
   FASE 2: AGENDA GLOBAL DE ACTIVIDADES Y TAREAS
   ========================================================================== */
.agenda-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.agenda-kpi-card {
    background: var(--crm-surface);
    border: 1px solid var(--crm-border);
    border-radius: var(--radius-lg);
    padding: 1.1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-sm);
    position: relative;
    user-select: none;
}

.agenda-kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--crm-border-hover);
}

.agenda-kpi-card.active {
    box-shadow: 0 0 0 2px var(--crm-primary), var(--shadow-md);
}

.agenda-kpi-card.kpi-urgent .kpi-icon-bubble {
    background: #fee2e2;
    color: #dc2626;
}
.agenda-kpi-card.kpi-urgent.active {
    box-shadow: 0 0 0 2px #ef4444, var(--shadow-md);
    background: rgba(239, 68, 68, 0.03);
}

.agenda-kpi-card.kpi-today .kpi-icon-bubble {
    background: #e0e7ff;
    color: #4f46e5;
}
.agenda-kpi-card.kpi-today.active {
    box-shadow: 0 0 0 2px #6366f1, var(--shadow-md);
    background: rgba(99, 102, 241, 0.03);
}

.agenda-kpi-card.kpi-upcoming .kpi-icon-bubble {
    background: #ede9fe;
    color: #7c3aed;
}
.agenda-kpi-card.kpi-upcoming.active {
    box-shadow: 0 0 0 2px #8b5cf6, var(--shadow-md);
    background: rgba(139, 92, 246, 0.03);
}

.agenda-kpi-card.kpi-done .kpi-icon-bubble {
    background: #d1fae5;
    color: #059669;
}
.agenda-kpi-card.kpi-done.active {
    box-shadow: 0 0 0 2px #10b981, var(--shadow-md);
    background: rgba(16, 185, 129, 0.03);
}

.kpi-icon-bubble {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.kpi-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.kpi-number {
    font-size: 1.65rem;
    font-weight: 800;
    line-height: 1.1;
    color: var(--crm-text);
}

.kpi-label {
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--crm-text);
    margin-top: 0.2rem;
}

.kpi-hint {
    font-size: 0.72rem;
    color: var(--crm-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 0.15rem;
}

.agenda-nav-bar {
    margin-bottom: 1.25rem;
    background: var(--crm-surface);
    border: 1px solid var(--crm-border);
    border-radius: var(--radius-lg);
    padding: 0.45rem;
}

.agenda-tabs {
    display: flex;
    gap: 0.45rem;
    overflow-x: auto;
}

.agenda-tab {
    padding: 0.55rem 1.1rem;
    border-radius: var(--radius-md);
    border: none;
    background: transparent;
    color: var(--crm-text-muted);
    font-weight: 600;
    font-size: 0.88rem;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    white-space: nowrap;
}

.agenda-tab:hover {
    color: var(--crm-text);
    background: var(--crm-bg);
}

.agenda-tab.active {
    color: var(--crm-primary);
    background: var(--crm-primary-light);
    font-weight: 700;
}

.agenda-stream-container {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.agenda-card {
    background: var(--crm-surface);
    border: 1px solid var(--crm-border);
    border-left: 4px solid var(--crm-primary);
    border-radius: var(--radius-lg);
    padding: 1.1rem 1.35rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
}

.agenda-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--crm-border-hover);
}

.agenda-card.tipo-LLAMADA { border-left-color: #2563eb; }
.agenda-card.tipo-REUNION { border-left-color: #7c3aed; }
.agenda-card.tipo-EMAIL   { border-left-color: #0891b2; }
.agenda-card.tipo-TAREA   { border-left-color: #d97706; }
.agenda-card.tipo-NOTA    { border-left-color: #64748b; }

.agenda-card.is-completed {
    border-left-color: #10b981;
    background: rgba(241, 245, 249, 0.6);
    opacity: 0.85;
}

.agenda-card.is-completed .agenda-title {
    text-decoration: line-through;
    color: var(--crm-text-muted);
}

.agenda-card-left {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    flex: 1;
    min-width: 0;
}

.agenda-type-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
    background: var(--crm-bg);
    border: 1px solid var(--crm-border);
}

.agenda-card.tipo-LLAMADA .agenda-type-icon { background: #eff6ff; }
.agenda-card.tipo-REUNION .agenda-type-icon { background: #f5f3ff; }
.agenda-card.tipo-EMAIL   .agenda-type-icon { background: #ecfeff; }
.agenda-card.tipo-TAREA   .agenda-type-icon { background: #fffbeb; }
.agenda-card.tipo-NOTA    .agenda-type-icon { background: #f8fafc; }

.agenda-details {
    flex: 1;
    min-width: 0;
}

.agenda-top-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.55rem;
    margin-bottom: 0.35rem;
}

.agenda-lead-pill {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--crm-primary);
    background: #eef2ff;
    border: 1px solid rgba(99, 102, 241, 0.35);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: all var(--transition-fast);
}

.agenda-lead-pill:hover {
    background: var(--crm-primary);
    color: #ffffff;
    border-color: var(--crm-primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.25);
}

.lead-pill-badge {
    background: rgba(99, 102, 241, 0.15);
    color: var(--crm-primary);
    font-size: 0.72rem;
    padding: 0.1rem 0.45rem;
    border-radius: 4px;
    font-weight: 700;
    margin-left: 0.2rem;
    transition: all var(--transition-fast);
}

.agenda-lead-pill:hover .lead-pill-badge {
    background: #ffffff;
    color: var(--crm-primary);
}

.agenda-general-pill {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--crm-text-muted);
    background: #f1f5f9;
    border: 1px dashed #cbd5e1;
    padding: 0.22rem 0.7rem;
    border-radius: var(--radius-full);
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    transition: all var(--transition-fast);
}

.agenda-general-pill:hover {
    background: #e2e8f0;
    color: var(--crm-text);
    border-color: #94a3b8;
}

.agenda-contact-name {
    font-size: 0.82rem;
    color: var(--crm-text-muted);
    font-weight: 500;
}

.agenda-phone-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: #047857;
    background: #d1fae5;
    padding: 0.18rem 0.55rem;
    border-radius: var(--radius-full);
    text-decoration: none;
    transition: all var(--transition-fast);
}

.agenda-phone-link:hover {
    background: #059669;
    color: #ffffff;
}

.agenda-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--crm-text);
    margin: 0 0 0.3rem 0;
    word-break: break-word;
}

.agenda-desc {
    font-size: 0.86rem;
    color: var(--crm-text-muted);
    margin: 0 0 0.5rem 0;
    line-height: 1.45;
    word-break: break-word;
}

.agenda-badges-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.badge-due {
    font-size: 0.76rem;
    font-weight: 600;
    padding: 0.22rem 0.6rem;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.badge-due.urgent {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid rgba(220, 38, 38, 0.2);
}

.badge-due.today {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid rgba(180, 83, 9, 0.2);
}

.badge-due.future {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid var(--crm-border);
}

.badge-due.done {
    background: #d1fae5;
    color: #065f46;
}

.badge-tipo {
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.2rem 0.55rem;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}
.badge-tipo.tipo-LLAMADA { background: #eff6ff; color: #1d4ed8; }
.badge-tipo.tipo-REUNION { background: #f5f3ff; color: #6d28d9; }
.badge-tipo.tipo-EMAIL   { background: #ecfeff; color: #0e7490; }
.badge-tipo.tipo-TAREA   { background: #fffbeb; color: #b45309; }
.badge-tipo.tipo-NOTA    { background: #f1f5f9; color: #475569; }

.agenda-general-pill {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--crm-text-muted);
    background: var(--crm-bg);
    border: 1px solid var(--crm-border);
    padding: 0.2rem 0.65rem;
    border-radius: var(--radius-full);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.agenda-card-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.btn-agenda-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.55rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
    white-space: nowrap;
}

.btn-agenda-action.btn-edit {
    background: var(--crm-bg);
    color: var(--crm-text);
    border-color: var(--crm-border);
}

.btn-agenda-action.btn-edit:hover {
    background: var(--crm-surface);
    color: var(--crm-primary);
    border-color: var(--crm-primary);
}

.btn-agenda-action.btn-check {
    background: #e0e7ff;
    color: #4338ca;
    border-color: #c7d2fe;
}

.btn-agenda-action.btn-check:hover {
    background: #4f46e5;
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
    transform: translateY(-1px);
}

.btn-agenda-action.btn-reopen {
    background: var(--crm-bg);
    color: var(--crm-text-muted);
    border-color: var(--crm-border);
}

.btn-agenda-action.btn-reopen:hover {
    background: var(--crm-surface);
    color: var(--crm-text);
    border-color: var(--crm-border-hover);
}

/* Responsive Agenda en Móvil */
@media (max-width: 768px) {
    .agenda-kpi-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.65rem !important;
        margin-bottom: 1rem !important;
    }
    .agenda-kpi-card {
        padding: 0.75rem 0.85rem !important;
        gap: 0.65rem !important;
    }
    .kpi-icon-bubble {
        width: 36px !important;
        height: 36px !important;
        font-size: 1.15rem !important;
    }
    .kpi-number {
        font-size: 1.35rem !important;
    }
    .kpi-label {
        font-size: 0.75rem !important;
    }
    .kpi-hint {
        display: none !important;
    }

    .agenda-tabs {
        display: grid !important;
        grid-template-columns: repeat(5, 1fr) !important;
        gap: 0.2rem !important;
        padding: 0 !important;
    }
    .agenda-tab {
        padding: 0.45rem 0.2rem !important;
        font-size: 0.74rem !important;
        justify-content: center !important;
    }

    .agenda-card {
        flex-direction: column !important;
        align-items: stretch !important;
        padding: 1rem !important;
        gap: 0.85rem !important;
    }
    .agenda-card-right {
        justify-content: flex-end !important;
        border-top: 1px dashed var(--crm-border);
        padding-top: 0.75rem;
    }
    .btn-agenda-action {
        width: 100% !important;
    }
}

/* ==========================================================================
   VISTA CALENDARIO INTERACTIVO (AGENDA)
   ========================================================================== */

/* Conmutador de Vistas: Lista vs Calendario */
.view-switch-tabs {
    display: inline-flex;
    background: #f1f5f9;
    padding: 0.25rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--crm-border);
    gap: 0.25rem;
}

.btn-switch-view {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.95rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--crm-text-muted);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-switch-view:hover {
    color: var(--crm-text);
}

.btn-switch-view.active {
    background: var(--crm-surface);
    color: var(--crm-primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Contenedor del Calendario */
.calendar-wrapper {
    background: var(--crm-surface);
    border: 1px solid var(--crm-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
}

/* Barra de Navegación del Mes */
.calendar-header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.calendar-nav-controls {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.btn-cal-nav {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    border: 1px solid var(--crm-border);
    background: var(--crm-surface);
    color: var(--crm-text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-cal-nav:hover {
    background: var(--crm-bg);
    border-color: var(--crm-border-hover);
    color: var(--crm-primary);
}

.cal-month-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--crm-text);
    min-width: 220px;
    text-align: center;
    letter-spacing: -0.02em;
}

.btn-cal-today {
    padding: 0.45rem 1rem;
    font-size: 0.84rem;
    font-weight: 600;
    background: var(--crm-surface);
    border: 1px solid var(--crm-border);
    border-radius: var(--radius-md);
    color: var(--crm-text);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-cal-today:hover {
    background: var(--crm-bg);
    border-color: var(--crm-border-hover);
    color: var(--crm-primary);
}

/* Días de la semana */
.cal-weekdays-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    text-align: center;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--crm-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding-bottom: 0.65rem;
    border-bottom: 1px solid var(--crm-border);
}

.cal-weekdays-grid span.weekend {
    color: #94a3b8;
}

/* Cuadrícula de Celdas Mensual */
.cal-month-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    margin-top: 10px;
}

/* Celda de Día */
.cal-day-cell {
    min-height: 120px;
    background: #ffffff;
    border: 1px solid var(--crm-border);
    border-radius: var(--radius-sm);
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    transition: all 0.15s ease;
    cursor: pointer;
    position: relative;
}

.cal-day-cell:hover {
    border-color: var(--crm-primary);
    background: #fdfdfe;
}

.cal-day-cell.is-today {
    border-color: var(--crm-primary);
    background: rgba(79, 70, 229, 0.03);
}

.cal-day-cell.other-month {
    opacity: 0.35;
    background: #f8fafc;
}

.cal-day-cell.cal-drag-over {
    background: #eef2ff !important;
    border: 2px dashed var(--crm-primary) !important;
}

.cal-day-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.2rem;
}

.cal-day-num {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--crm-text);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
}

.cal-day-cell.is-today .cal-day-num {
    background: var(--crm-primary);
    color: #ffffff;
    font-weight: 700;
}

.cal-day-cell.selected {
    border-color: var(--crm-primary);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.25);
}

/* Pastilla de Actividad en Calendario */
.cal-event-pill {
    padding: 0.22rem 0.45rem;
    border-radius: 4px;
    font-size: 0.74rem;
    font-weight: 500;
    line-height: 1.3;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    cursor: grab;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    border: 1px solid transparent;
    user-select: none;
    overflow: hidden;
}

.cal-event-pill:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.cal-event-pill.dragging {
    opacity: 0.35;
    cursor: grabbing;
}

.cal-event-pill.done {
    opacity: 0.6;
    text-decoration: line-through;
}

.cal-event-pill.tipo-llamada {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1e40af;
}

.cal-event-pill.tipo-reunion {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: #065f46;
}

.cal-event-pill.tipo-email {
    background: #f5f3ff;
    border-color: #ddd6fe;
    color: #5b21b6;
}

.cal-event-pill.tipo-tarea {
    background: #fffbeb;
    border-color: #fde68a;
    color: #92400e;
}

.cal-event-pill.tipo-nota {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #334155;
}

.cal-event-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.cal-more-badge {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--crm-primary);
    padding: 0.1rem 0.35rem;
    border-radius: var(--radius-sm);
    background: var(--crm-primary-light);
    width: fit-content;
    margin-top: 0.15rem;
}

/* Detalle de Día en Móvil */
.cal-mobile-day-detail {
    margin-top: 1.25rem;
    border-top: 1px solid var(--crm-border);
    padding-top: 1rem;
}

.cal-mobile-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.cal-mobile-detail-header h4 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--crm-text);
}

.btn-cal-add-day {
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.35rem 0.75rem;
    background: var(--crm-primary-light);
    color: var(--crm-primary);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

/* Responsive Móvil para Calendario */
@media (max-width: 768px) {
    .calendar-wrapper {
        padding: 0.85rem !important;
    }

    .cal-month-title {
        font-size: 1.1rem !important;
        min-width: auto !important;
    }

    .cal-month-grid {
        gap: 4px !important;
    }

    .cal-day-cell {
        min-height: 60px !important;
        padding: 0.25rem !important;
    }

    .cal-event-pill {
        padding: 0.15rem 0.25rem !important;
        font-size: 0.68rem !important;
    }

    .view-switch-tabs {
        width: 100%;
        justify-content: center;
    }
}

/* ==========================================================================
   FASE 3: Embudo de Ventas Global (Pipeline / Kanban)
   ========================================================================== */

.pipeline-wrapper {
    max-width: 100% !important;
    padding-bottom: 2rem;
}

/* Cabecera Superior con Espaciado Generoso */
.crm-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    row-gap: 1.25rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.crm-top-bar-info {
    flex: 1 1 auto;
    min-width: 280px;
}

.crm-view-title {
    font-size: 1.7rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--crm-text);
    margin: 0;
    line-height: 1.25;
}

.crm-view-subtitle {
    font-size: 0.92rem;
    color: var(--crm-text-muted);
    margin-top: 0.4rem;
    margin-bottom: 0;
    line-height: 1.4;
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    flex-shrink: 0;
}

.top-bar-actions .btn-secondary,
.top-bar-actions .btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 0.72rem 1.35rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: all var(--transition-fast);
}

.top-bar-actions .btn-secondary {
    background: var(--crm-surface);
    border: 1px solid var(--crm-border);
    color: var(--crm-text);
}

.top-bar-actions .btn-secondary:hover {
    background: var(--crm-bg);
    border-color: var(--crm-border-hover);
    color: var(--crm-primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.top-bar-actions .btn-primary {
    background: var(--crm-primary);
    border: 1px solid var(--crm-primary);
    color: #ffffff;
}

.top-bar-actions .btn-primary:hover {
    background: var(--crm-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

/* KPIs Financieros en Directo */
.pipeline-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.15rem;
    margin-bottom: 1.75rem;
}

.pipeline-kpi-card {
    background: var(--crm-surface);
    border: 1px solid var(--crm-border);
    border-radius: var(--radius-lg);
    padding: 1.1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-smooth);
}

.pipeline-kpi-card:hover {
    border-color: var(--crm-border-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.pipeline-kpi-card.kpi-total { border-left: 4px solid #3b82f6; }
.pipeline-kpi-card.kpi-weighted { border-left: 4px solid #8b5cf6; }
.pipeline-kpi-card.kpi-won { border-left: 4px solid #10b981; }
.pipeline-kpi-card.kpi-conversion { border-left: 4px solid #f59e0b; }

.pipeline-kpi-card.kpi-total .kpi-number { color: #1e40af; }
.pipeline-kpi-card.kpi-weighted .kpi-number { color: #5b21b6; }
.pipeline-kpi-card.kpi-won .kpi-number { color: #065f46; }
.pipeline-kpi-card.kpi-conversion .kpi-number { color: #92400e; }

/* Selector de columnas para móvil */
.kanban-mobile-tabs {
    display: none;
    overflow-x: auto;
    gap: 0.4rem;
    padding: 0.4rem 0 0.8rem 0;
    margin-bottom: 0.5rem;
    -webkit-overflow-scrolling: touch;
}

.kanban-mobile-tabs .k-tab {
    padding: 0.4rem 0.75rem;
    background: var(--crm-surface);
    border: 1px solid var(--crm-border);
    border-radius: var(--radius-full);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--crm-text-muted);
    white-space: nowrap;
    cursor: pointer;
}

.kanban-mobile-tabs .k-tab.active {
    background: var(--crm-primary);
    color: #ffffff;
    border-color: var(--crm-primary);
}

/* Tablero Kanban Scrollable */
.kanban-board-container {
    display: flex;
    gap: 1.15rem;
    overflow-x: auto;
    padding: 0.35rem 0.25rem 1.5rem 0.25rem;
    min-height: calc(100vh - 280px);
    align-items: flex-start;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
}

/* Columna Kanban */
.kanban-column {
    flex: 0 0 310px;
    width: 310px;
    background: #f8fafc;
    border: 1px solid var(--crm-border);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 250px);
    min-height: 440px;
    box-shadow: var(--shadow-sm);
    scroll-snap-align: start;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.kanban-column.drag-over {
    background: #eef2ff !important;
    border: 2px dashed var(--crm-primary) !important;
}

/* Colores de cabecera según fase */
.col-prospeccion { border-top: 4px solid #3b82f6; }
.col-prospeccion .col-dot { background: #3b82f6; }

.col-cualificado { border-top: 4px solid #06b6d4; }
.col-cualificado .col-dot { background: #06b6d4; }

.col-propuesta { border-top: 4px solid #f59e0b; }
.col-propuesta .col-dot { background: #f59e0b; }

.col-negociacion { border-top: 4px solid #8b5cf6; }
.col-negociacion .col-dot { background: #8b5cf6; }

.col-ganada { border-top: 4px solid #10b981; }
.col-ganada .col-dot { background: #10b981; }

.col-perdida { border-top: 4px solid #ef4444; }
.col-perdida .col-dot { background: #ef4444; }

/* Cabecera de Columna */
.kanban-column-header {
    padding: 0.9rem 1rem 0.75rem 1rem;
    border-bottom: 1px solid var(--crm-border);
    background: rgba(255, 255, 255, 0.7);
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.col-title-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.col-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}

.col-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--crm-text);
    letter-spacing: -0.01em;
    flex: 1;
}

.col-count-badge {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--crm-text-muted);
    background: #e2e8f0;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-full);
}

.col-amount-badge {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--crm-text-muted);
    padding-left: 1.15rem;
}

/* Contenedor de Tarjetas */
.kanban-cards-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 0.85rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 150px;
}

/* Tarjeta de Oportunidad */
.kanban-card {
    background: #ffffff;
    border: 1px solid var(--crm-border);
    border-radius: var(--radius-md);
    padding: 0.9rem 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    cursor: grab;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    user-select: none;
    position: relative;
}

.kanban-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--crm-border-hover);
}

.kanban-card.dragging {
    opacity: 0.35;
    transform: scale(0.96);
    cursor: grabbing;
}

/* Elementos de la Tarjeta */
.card-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
}

.card-title {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--crm-text);
    line-height: 1.35;
    margin: 0;
    cursor: pointer;
}

.card-title:hover {
    color: var(--crm-primary);
}

.card-btn-edit {
    background: transparent;
    border: none;
    color: var(--crm-text-light);
    cursor: pointer;
    padding: 0.2rem;
    border-radius: var(--radius-sm);
    line-height: 1;
    transition: color 0.15s ease;
}

.card-btn-edit:hover {
    color: var(--crm-primary);
    background: var(--crm-primary-light);
}

/* Enlace a la Ficha 360° del Prospecto */
.card-lead-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: #f1f5f9;
    color: #334155;
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    width: fit-content;
    max-width: 100%;
}

.card-lead-badge:hover {
    background: var(--crm-primary-light);
    color: var(--crm-primary);
    border-color: #c7d2fe;
}

.card-lead-badge .lead-name-truncate {
    max-width: 210px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Importe y Probabilidad */
.card-finance-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding-top: 0.25rem;
    border-top: 1px dashed #f1f5f9;
}

.card-amount {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--crm-text);
    letter-spacing: -0.02em;
}

.card-prob-pill {
    font-size: 0.74rem;
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    border-radius: var(--radius-full);
    background: #eef2ff;
    color: #4338ca;
}

/* Footer de la Tarjeta */
.card-footer-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.74rem;
    color: var(--crm-text-muted);
    gap: 0.5rem;
}

.card-due-date {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.card-due-date.overdue {
    color: #ef4444;
    font-weight: 600;
}

.card-loss-reason {
    font-size: 0.74rem;
    background: #fee2e2;
    color: #b91c1c;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

/* Botón Mover de etapa en móvil */
.card-mobile-stage-btn {
    display: none;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--crm-primary);
    background: var(--crm-primary-light);
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.25rem 0.5rem;
    cursor: pointer;
}

/* Cuadrícula de Motivos de Pérdida */
.loss-reasons-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.loss-pill {
    background: var(--crm-bg);
    border: 1px solid var(--crm-border);
    border-radius: var(--radius-md);
    padding: 0.55rem 0.65rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--crm-text);
    cursor: pointer;
    text-align: left;
    transition: all 0.15s ease;
}

.loss-pill:hover {
    background: #f1f5f9;
    border-color: var(--crm-border-hover);
}

.loss-pill.active {
    background: #fee2e2;
    border-color: #f87171;
    color: #b91c1c;
    font-weight: 600;
}

.btn-danger-link {
    background: transparent;
    border: none;
    color: #ef4444;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius-sm);
    transition: background 0.15s ease;
}

.btn-danger-link:hover {
    background: #fee2e2;
}

/* Estado de columna vacía */
.kanban-empty-drop {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 120px;
    border: 1px dashed #cbd5e1;
    border-radius: var(--radius-md);
    color: var(--crm-text-light);
    font-size: 0.78rem;
    gap: 0.35rem;
    text-align: center;
    padding: 0.5rem;
}

/* Responsive Kanban en Móvil */
@media (max-width: 768px) {
    .pipeline-kpi-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.65rem !important;
        margin-bottom: 1rem !important;
    }

    .pipeline-kpi-card {
        padding: 0.75rem 0.85rem !important;
        gap: 0.65rem !important;
    }

    .kanban-mobile-tabs {
        display: flex !important;
    }

    .kanban-board-container {
        gap: 0.75rem !important;
        padding-bottom: 5rem !important;
    }

    .kanban-column {
        flex: 0 0 86vw !important;
        width: 86vw !important;
        min-height: 380px !important;
    }

    .card-mobile-stage-btn {
        display: inline-block !important;
    }
}

/* ==========================================================================
   Configuración & Integraciones (Meta Ads, Google Ads, Calendar/Meet)
   ========================================================================== */
.settings-wrapper {
    max-width: 1040px;
    margin: 0 auto;
    padding: 2rem 1.5rem 6rem;
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1.25rem;
}

.settings-title-block {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.settings-title {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    color: var(--crm-text);
    margin: 0;
}

.settings-subtitle {
    font-size: 0.92rem;
    color: var(--crm-text-muted);
    margin: 0;
}

/* Barra de pestañas de Ajustes */
.settings-tabs-bar {
    display: flex;
    gap: 0.6rem;
    padding: 0.4rem;
    background: #e2e8f0;
    border-radius: var(--radius-lg);
    margin-bottom: 2rem;
    overflow-x: auto;
    scrollbar-width: none;
}

.settings-tabs-bar::-webkit-scrollbar {
    display: none;
}

.settings-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    border: none;
    background: transparent;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    color: #64748b;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition-fast);
}

.settings-tab:hover {
    color: var(--crm-text);
    background: rgba(255, 255, 255, 0.6);
}

.settings-tab.active {
    color: var(--crm-primary);
    background: #ffffff;
    box-shadow: var(--shadow-sm);
    font-weight: 700;
}

.settings-tab .tab-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.settings-tab .tab-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.25;
}

.settings-tab .tab-text small {
    font-size: 0.72rem;
    font-weight: 500;
    opacity: 0.75;
}

.settings-tab-pane {
    display: none;
}

.settings-tab-pane.active {
    display: block;
    animation: fadeIn 0.2s ease-in-out;
}

.field-hint {
    font-size: 0.78rem;
    color: var(--crm-text-muted);
    margin-top: 0.25rem;
    display: block;
    line-height: 1.35;
}

.settings-bottom-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

/* Card Contenedora */
.settings-card {
    background: #ffffff;
    border: 1px solid var(--crm-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.05);
    overflow: hidden;
    margin-bottom: 2rem;
}

.settings-card-header {
    padding: 1.5rem 1.75rem;
    border-bottom: 1px solid var(--crm-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ffffff;
    gap: 1rem;
    flex-wrap: wrap;
}

.settings-card-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.settings-card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.settings-card-icon.meta {
    background: linear-gradient(135deg, #1877f2, #0056b3);
    color: #ffffff;
}

.settings-card-icon.google-ads {
    background: linear-gradient(135deg, #fbbc04, #ea4335);
    color: #ffffff;
}

.settings-card-icon.calendar {
    background: linear-gradient(135deg, #34a853, #1a73e8);
    color: #ffffff;
}

.settings-card-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--crm-text);
    margin: 0 0 0.2rem 0;
}

.settings-card-desc {
    font-size: 0.85rem;
    color: var(--crm-text-muted);
    margin: 0;
}

.settings-card-body {
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Info Box / Banner Informativo */
.settings-info-box {
    display: flex;
    gap: 1rem;
    padding: 1.1rem 1.35rem;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    line-height: 1.5;
}

.settings-info-box.info {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
}

.settings-info-box.warning {
    background: #fffbeb;
    border: 1px solid #fef3c7;
    color: #92400e;
}

.settings-info-box.success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.settings-info-icon {
    flex-shrink: 0;
    margin-top: 0.15rem;
}

.settings-info-title {
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.settings-info-desc {
    color: inherit;
    opacity: 0.9;
}

/* Switch Toggle */
.switch-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    user-select: none;
}

.switch-toggle {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

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

.switch-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: #cbd5e1;
    transition: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    border-radius: 26px;
}

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

.switch-toggle input:checked + .switch-slider {
    background-color: var(--crm-primary);
}

.switch-toggle input:checked + .switch-slider:before {
    transform: translateX(22px);
}

.switch-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--crm-text);
}

/* Campo con botón de Revelar Contraseña / Clave Secreta */
.input-password-wrap {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.input-password-wrap input {
    padding-right: 2.75rem !important;
}

.btn-toggle-pwd {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--crm-text-muted);
    cursor: pointer;
    padding: 0.4rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition-fast);
}

.btn-toggle-pwd:hover {
    color: var(--crm-text);
}

/* Copiado de Webhook / URLs */
.copy-field-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    width: 100%;
}

.copy-field-row input {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace !important;
    font-size: 0.85rem !important;
    background: #f8fafc !important;
    color: #475569 !important;
    cursor: default;
}

.btn-copy {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.65rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--crm-primary);
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    border-radius: var(--radius-sm);
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition-fast);
}

.btn-copy:hover {
    background: #e0e7ff;
    border-color: #a5b4fc;
    transform: translateY(-1px);
}

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

/* Help text debajo de inputs */
.field-help-text {
    font-size: 0.78rem;
    color: var(--crm-text-muted);
    margin-top: 0.25rem;
    line-height: 1.4;
}

/* Barra inferior fija / flotante de guardar cambios */
.settings-actions-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--crm-border);
}

/* Responsive para Settings */
@media (max-width: 768px) {
    .settings-wrapper {
        padding: 1.25rem 1rem 5rem;
    }

    .settings-tabs-bar {
        gap: 0.35rem;
    }

    .settings-tab {
        padding: 0.6rem 0.9rem;
        font-size: 0.82rem;
    }

    .settings-card-header {
        padding: 1.25rem;
    }

    .settings-card-body {
        padding: 1.25rem;
    }

    .copy-field-row {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-copy {
        justify-content: center;
    }
}

/* ==========================================================================
   Catálogo de Productos y Servicios & Conmutador Demo (ERP vs Autónomo)
   ========================================================================== */
.demo-switch-container {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    background: #f1f5f9;
    padding: 0.35rem 0.6rem;
    border-radius: var(--radius-full);
    border: 1px solid var(--crm-border);
}

.demo-switch-tag {
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--crm-text-muted);
    padding-left: 0.4rem;
}

.demo-toggle-pill {
    display: inline-flex;
    background: #e2e8f0;
    padding: 2px;
    border-radius: var(--radius-full);
    gap: 2px;
}

.btn-demo-mode {
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--crm-text-muted);
    padding: 0.38rem 0.85rem;
    border-radius: var(--radius-full);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: all var(--transition-fast);
}

.btn-demo-mode:hover {
    color: var(--crm-text);
}

.btn-demo-mode.active#btnModoERP {
    background: linear-gradient(135deg, #1e40af, #2563eb);
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

.btn-demo-mode.active#btnModoCRM {
    background: linear-gradient(135deg, #059669, #10b981);
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
}

/* Toolbar de Catálogo */
.catalogo-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.search-box-crm {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1;
    max-width: 450px;
    background: #ffffff;
    border: 1px solid var(--crm-border);
    border-radius: var(--radius-md);
    padding: 0.55rem 0.9rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
    transition: all var(--transition-fast);
}

.search-box-crm:focus-within {
    border-color: var(--crm-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.search-box-crm input {
    border: none;
    outline: none;
    background: transparent;
    width: 100%;
    margin-left: 0.6rem;
    font-size: 0.88rem;
    font-family: inherit;
    color: var(--crm-text);
}

.btn-clear-search {
    background: transparent;
    border: none;
    color: var(--crm-text-muted);
    font-size: 0.82rem;
    cursor: pointer;
    padding: 0.2rem;
}

.badge-total-items {
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--crm-text-muted);
    background: #f1f5f9;
    padding: 0.4rem 0.85rem;
    border-radius: var(--radius-full);
    border: 1px solid var(--crm-border);
}

/* Tabla de Catálogo */
.catalogo-table-card {
    background: #ffffff;
    border: 1px solid var(--crm-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.05);
    overflow: hidden;
}

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

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

.crm-data-table th {
    background: #f8fafc;
    padding: 0.85rem 1.25rem;
    font-weight: 700;
    color: #475569;
    border-bottom: 1px solid var(--crm-border);
    white-space: nowrap;
    text-transform: uppercase;
    font-size: 0.74rem;
    letter-spacing: 0.03em;
}

.crm-data-table td {
    padding: 0.9rem 1.25rem;
    border-bottom: 1px solid var(--crm-border);
    color: var(--crm-text);
    vertical-align: middle;
}

.crm-data-table tbody tr:hover {
    background: #f8fafc;
}

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

.cell-codigo {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-weight: 700;
    color: var(--crm-primary);
    font-size: 0.85rem;
}

.cell-nombre {
    font-weight: 600;
    color: var(--crm-text);
}

.cell-desc {
    font-size: 0.78rem;
    color: var(--crm-text-muted);
    margin-top: 0.15rem;
    max-width: 380px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cell-precio {
    font-size: 0.95rem;
    font-weight: 700;
    color: #0f172a;
    text-align: right;
}

/* Badges de Origen */
.badge-origin {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.74rem;
    font-weight: 700;
    padding: 0.25rem 0.65rem;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-origin.erp {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

.badge-origin.crm {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
}

/* Badges de Estado */
.badge-status-dot {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    font-weight: 600;
}

.badge-status-dot.activo {
    color: #059669;
}

.badge-status-dot.inactivo {
    color: #94a3b8;
}

.badge-status-dot::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

.badge-status-dot.activo::before {
    background: #10b981;
}

.badge-status-dot.inactivo::before {
    background: #cbd5e1;
}

/* Botones de acción en tabla */
.table-actions-cell {
    display: flex;
    justify-content: flex-end;
    gap: 0.35rem;
}

.btn-table-action {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--crm-border);
    background: #ffffff;
    color: var(--crm-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-table-action:hover {
    color: var(--crm-primary);
    border-color: var(--crm-primary);
    background: #f8fafc;
}

.btn-table-action.delete:hover {
    color: #dc2626;
    border-color: #fca5a5;
    background: #fef2f2;
}

/* Estado vacío en catálogo */
.catalogo-empty-state {
    text-align: center;
    padding: 3.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
}

.catalogo-empty-state .empty-icon {
    font-size: 2.75rem;
}

.catalogo-empty-state h4 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--crm-text);
    margin: 0;
}

.catalogo-empty-state p {
    font-size: 0.85rem;
    color: var(--crm-text-muted);
    margin: 0;
}




