/* ============================================================
   CRM Meta Leads V2 — App CSS
   Design system "SaaS Premium" sobre Bootstrap 5.3.
   Requiere tokens.css cargado antes.

   Índice:
   01. Base y tipografía
   02. Loader (barra de progreso superior)
   03. Layout general (page-wrapper / main-container / main-content)
   04. Sidebar (oscuro, colapsable a rail, off-canvas en móvil)
   05. Navbar / page-header
   06. Notificaciones (campana + dropdown)
   07. Cards
   08. KPI cards y stat tiles
   09. Botones
   10. Formularios
   11. Tablas
   12. Badges y estados
   13. Dropdowns, modales, alerts, paginación
   14. Login / auth
   15. Page header de contenido (títulos + breadcrumbs)
   16. Utilidades y compatibilidad con vistas no migradas
   ============================================================ */


/* ============ 01. Base y tipografía ============ */

html {
    scroll-behavior: smooth;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: .875rem;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    letter-spacing: -.015em;
    color: var(--text);
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--primary-600);
}

.text-numeric,
.kpi-value,
table td.numeric {
    font-feature-settings: "tnum";
    font-variant-numeric: tabular-nums;
}

/* Scrollbars finos y elegantes en toda la app */
* {
    scrollbar-width: thin;
    scrollbar-color: #c7cdd9 transparent;
}

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

*::-webkit-scrollbar-thumb {
    background: #c7cdd9;
    border-radius: var(--radius-pill);
}

*::-webkit-scrollbar-thumb:hover {
    background: var(--text-3);
}

*::-webkit-scrollbar-track {
    background: transparent;
}

::selection {
    background: var(--primary);
    color: #fff;
}

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}


/* ============ 02. Loader ============ */

/* Barra de progreso fina arriba, estilo Linear/YouTube */
#loading-wrapper {
    position: fixed;
    inset: 0 0 auto 0;
    height: 3px;
    background: transparent;
    z-index: 2000;
    pointer-events: none;
}

#loading-wrapper .spinner {
    height: 100%;
    width: 40%;
    background: var(--accent-grad);
    border-radius: var(--radius-pill);
    animation: loading-bar 1s ease-in-out infinite;
}

#loading-wrapper .spinner div {
    display: none; /* las .line1-6 del markup heredado no se usan */
}

#loading-wrapper.loaded {
    opacity: 0;
    transition: opacity 300ms ease;
}

@keyframes loading-bar {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(350%); }
}


/* ============ 03. Layout general ============ */

.page-wrapper {
    display: flex;
    min-height: 100vh;
}

.main-container {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    margin-left: var(--sidebar-width);
    transition: margin-left var(--transition-slow);
}

.main-content {
    flex: 1;
    width: 100%;
    max-width: var(--content-max);
    padding: 1.5rem 1.75rem 2.5rem;
    margin-inline: auto;
}

/* Las vistas heredadas envuelven el navbar en un .main-content exterior
   (hijo directo de .page-wrapper): neutralizarlo para que solo el interior
   (dentro de .main-container) reciba padding y ancho máximo. */
.page-wrapper > .main-content {
    flex: 1;
    min-width: 0;
    max-width: none;
    padding: 0;
    margin: 0;
}

@media (max-width: 991.98px) {
    .main-container {
        margin-left: 0;
    }

    .main-content {
        padding: 1rem 1rem 2rem;
    }
}


/* ============ 04. Sidebar ============ */

.sidebar-wrapper {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    background: var(--sidebar-grad);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: width var(--transition-slow), transform var(--transition-slow);
    overflow: hidden;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: var(--navbar-height);
    padding: .75rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.sidebar-brand .logo img {
    max-height: 38px;
    max-width: 170px;
    object-fit: contain;
    transition: transform var(--transition);
}

.sidebar-brand .logo:hover img {
    transform: scale(1.04);
}

.sidebar-menu {
    flex: 1;
    overflow: hidden;
    padding: .85rem .75rem;
}

.sidebarMenuScroll {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-menu ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-menu li a {
    position: relative;
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .62rem .85rem;
    border-radius: var(--radius-sm);
    color: #9aa3bd;
    font-weight: 500;
    font-size: .855rem;
    white-space: nowrap;
    transition: background var(--transition), color var(--transition), transform var(--transition);
}

.sidebar-menu li a i {
    font-size: 1.1rem;
    line-height: 1;
    min-width: 22px;
    text-align: center;
    transition: transform var(--transition);
}

.sidebar-menu li a:hover {
    background: rgba(255, 255, 255, .06);
    color: #fff;
}

.sidebar-menu li a:hover i {
    transform: translateX(2px) scale(1.08);
}

.sidebar-menu li.active a {
    background: linear-gradient(90deg, rgba(99, 91, 255, .22), rgba(139, 92, 246, .10));
    color: #fff;
}

/* Barra indicadora con glow en el item activo */
.sidebar-menu li.active a::before {
    content: "";
    position: absolute;
    left: -0.75rem;
    top: 18%;
    bottom: 18%;
    width: 3px;
    border-radius: var(--radius-pill);
    background: var(--accent-grad);
    box-shadow: 0 0 12px 1px var(--primary-glow);
}

.sidebar-footer {
    padding: .9rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, .06);
}

.sidebar-footer p,
.sidebar-footer a {
    color: #6b7491 !important;
    transition: color var(--transition);
}

.sidebar-footer a:hover {
    color: #fff !important;
}

/* --- Colapsado a rail (desktop) --- */
@media (min-width: 992px) {
    .page-wrapper.sidebar-collapsed .sidebar-wrapper {
        width: var(--sidebar-rail);
    }

    .page-wrapper.sidebar-collapsed .main-container {
        margin-left: var(--sidebar-rail);
    }

    .page-wrapper.sidebar-collapsed .menu-text,
    .page-wrapper.sidebar-collapsed .sidebar-footer {
        display: none;
    }

    .page-wrapper.sidebar-collapsed .sidebar-menu li a {
        justify-content: center;
        padding: .7rem .5rem;
    }

    .page-wrapper.sidebar-collapsed .sidebar-brand .logo img {
        max-width: 44px;
    }
}

/* --- Off-canvas (móvil) --- */
@media (max-width: 991.98px) {
    .sidebar-wrapper {
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }

    .page-wrapper.sidebar-mobile-open .sidebar-wrapper {
        transform: translateX(0);
    }
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .45);
    backdrop-filter: blur(2px);
    z-index: 1035;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-slow);
}

.page-wrapper.sidebar-mobile-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
}


/* ============ 05. Navbar / page-header ============ */

.page-header {
    position: sticky;
    top: 0;
    z-index: 1030;
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: var(--navbar-height);
    padding: 0 1.5rem;
    background: rgba(255, 255, 255, .82);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.toggle-sidebar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-size: 1.3rem;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}

.toggle-sidebar:hover {
    background: var(--primary-soft);
    color: var(--primary);
}

.logo-sm {
    max-height: 32px;
}

.header-actions-container {
    margin-left: auto;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: .5rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.user-settings {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .35rem .6rem;
    border-radius: var(--radius-pill);
    color: var(--text);
    cursor: pointer;
    transition: background var(--transition);
}

.user-settings:hover {
    background: var(--surface-2);
    color: var(--text);
}

.user-welcome {
    font-size: .84rem;
    color: var(--text-2);
}

.user-welcome strong {
    color: var(--text);
    font-weight: 600;
}

.header-actions .avatar {
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: visible;
    background: var(--accent-grad);
    padding: 2px;
    box-shadow: var(--shadow-primary);
}

.header-actions .avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: #fff;
    object-fit: cover;
}

.header-actions .avatar .status {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid #fff;
}

.header-actions .avatar .status.online {
    background: var(--success);
    animation: pulse-dot 2.2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, .5); }
    50%      { box-shadow: 0 0 0 4px rgba(16, 185, 129, 0); }
}


/* ============ 06. Notificaciones ============ */

.notification-bell-link {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-2);
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    margin-right: .35rem;
    transition: background var(--transition), color var(--transition), border-color var(--transition), transform var(--transition);
}

.notification-bell-link:hover {
    background: var(--primary-soft);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
}

.notification-count-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    border-radius: var(--radius-pill);
    background: var(--danger);
    color: #fff;
    font-size: .68rem;
    line-height: 18px;
    text-align: center;
    font-weight: 700;
    box-shadow: 0 0 0 2px #fff;
    animation: badge-pop 400ms var(--ease-spring);
}

@keyframes badge-pop {
    0%   { transform: scale(0); }
    100% { transform: scale(1); }
}

.dropdown-menu.notification-dropdown {
    width: min(380px, calc(100vw - 24px));
    max-height: min(620px, calc(100vh - 90px));
    padding: 0;
    overflow: hidden;
    display: none;
    opacity: 0;
    pointer-events: none;
    translate: 0 -8px;
    scale: .98;
    transform-origin: top right;
    animation: none;
    transition:
        opacity 180ms ease,
        translate 180ms ease,
        scale 180ms ease,
        display 180ms allow-discrete;
    will-change: opacity, translate, scale;
}

.dropdown-menu.notification-dropdown.show {
    display: flex;
    flex-direction: column;
    opacity: 1;
    pointer-events: auto;
    translate: 0 0;
    scale: 1;
}

@starting-style {
    .dropdown-menu.notification-dropdown.show {
        opacity: 0;
        translate: 0 -8px;
        scale: .98;
    }
}

.notification-dropdown-header {
    flex: 0 0 auto;
    padding: .9rem 1.1rem;
    border-bottom: 1px solid var(--border-2);
    font-weight: 700;
    font-size: .9rem;
}

.notification-dropdown-list {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.notification-item {
    white-space: normal;
    padding: .85rem 1.1rem;
    border-bottom: 1px solid var(--border-2);
    transition: background var(--transition);
}

.notification-item:hover {
    background: var(--surface-2);
}

.notification-item:last-child {
    border-bottom: 0;
}

.notification-dropdown-footer {
    flex: 0 0 auto;
    padding: .75rem 1rem;
    background: var(--surface-2);
    border-top: 1px solid var(--border-2);
}

@media (prefers-reduced-motion: reduce) {
    .dropdown-menu.notification-dropdown {
        translate: none;
        scale: 1;
        transition-duration: 0.01ms;
    }
}


/* ============ 07. Cards ============ */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-slow), transform var(--transition-slow), border-color var(--transition-slow);
}

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

.card-hover-lift:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: #dcdfe9;
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-2);
    padding: 1rem 1.25rem;
    font-weight: 600;
}

.card-title {
    font-size: .95rem;
    font-weight: 700;
    margin-bottom: 0;
}

.card-body {
    padding: 1.25rem;
}

.card-footer {
    background: var(--surface-2);
    border-top: 1px solid var(--border-2);
}


/* ============ 08. KPI cards y stat tiles ============ */

.kpi-card {
    position: relative;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem .65rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-slow), transform var(--transition-slow);
}

.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.kpi-card .kpi-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
}

.kpi-card .kpi-label {
    font-size: .76rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-3);
}

.kpi-card .kpi-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    font-size: 1.1rem;
    flex-shrink: 0;
}

.kpi-card .kpi-value {
    font-size: 1.65rem;
    font-weight: 800;
    letter-spacing: -.02em;
    margin: .2rem 0 0;
    line-height: 1.2;
}

.kpi-card .kpi-trend {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    font-size: .78rem;
    font-weight: 700;
    border-radius: var(--radius-pill);
    padding: .12rem .55rem;
}

.kpi-card .kpi-trend.up {
    color: var(--success);
    background: var(--success-soft);
}

.kpi-card .kpi-trend.down {
    color: var(--danger);
    background: var(--danger-soft);
}

.kpi-card .kpi-trend.flat {
    color: var(--text-2);
    background: var(--border-2);
}

.kpi-card .kpi-spark {
    margin: .25rem -1.25rem 0;
    min-height: 42px;
}

/* Variantes de color para iconos KPI */
.kpi-icon.primary { background: var(--primary-soft); color: var(--primary); }
.kpi-icon.success { background: var(--success-soft); color: var(--success); }
.kpi-icon.warning { background: var(--warning-soft); color: var(--warning); }
.kpi-icon.danger  { background: var(--danger-soft);  color: var(--danger); }
.kpi-icon.info    { background: var(--info-soft);    color: var(--info); }

/* Compatibilidad con tiles del tema viejo en vistas aún no migradas */
.stat-tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.2rem;
    box-shadow: var(--shadow-sm);
}

.stats-tile {
    display: flex;
    align-items: center;
    gap: .9rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.2rem;
    box-shadow: var(--shadow-sm);
    height: 100%;
    transition: box-shadow var(--transition-slow), transform var(--transition-slow);
}

.stats-tile:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stats-tile .sale-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: var(--radius-sm);
    font-size: 1.25rem;
}

.stats-tile .sale-details h2,
.stats-tile .sale-details h3 {
    font-size: 1.35rem;
    font-weight: 800;
    margin-bottom: .1rem;
    font-feature-settings: "tnum";
}

.stats-tile .sale-details p {
    margin: 0;
    font-size: .76rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-3);
}

.sale-icon.shade-blue   { background: var(--primary-soft); color: var(--primary); }
.sale-icon.shade-green  { background: var(--success-soft); color: var(--success); }
.sale-icon.shade-red    { background: var(--danger-soft);  color: var(--danger); }
.sale-icon.shade-yellow { background: var(--warning-soft); color: var(--warning); }

/* Neutralizar colores de texto del tema viejo dentro de tiles */
.stats-tile .text-blue,
.stats-tile .text-green,
.stats-tile .text-red,
.stats-tile .text-yellow {
    color: var(--text) !important;
}


/* ============ 09. Botones ============ */

.btn {
    font-weight: 600;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.btn:active {
    transform: scale(.97);
}

.btn-primary {
    --bs-btn-bg: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: var(--primary-600);
    --bs-btn-hover-border-color: var(--primary-600);
    --bs-btn-active-bg: var(--primary-700);
    --bs-btn-active-border-color: var(--primary-700);
    --bs-btn-disabled-bg: var(--primary);
    --bs-btn-disabled-border-color: var(--primary);
    box-shadow: var(--shadow-primary);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px -6px var(--primary-glow);
}

.btn-outline-primary {
    --bs-btn-color: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: var(--primary);
    --bs-btn-hover-border-color: var(--primary);
    --bs-btn-active-bg: var(--primary-600);
    --bs-btn-active-border-color: var(--primary-600);
}

.btn-light {
    --bs-btn-bg: var(--surface);
    --bs-btn-border-color: var(--border);
    --bs-btn-hover-bg: var(--surface-2);
    --bs-btn-hover-border-color: #d8dce6;
    color: var(--text-2);
}

.btn .bi,
.btn .fas,
.btn .far {
    transition: transform var(--transition);
}

.btn:hover .bi-arrow-right,
.btn:hover .bi-arrow-right-circle {
    transform: translateX(3px);
}


/* ============ 10. Formularios ============ */

.form-label {
    font-weight: 600;
    font-size: .82rem;
    color: var(--text);
    margin-bottom: .35rem;
}

.form-control,
.form-select {
    border-color: var(--border);
    border-radius: var(--radius-sm);
    padding: .55rem .8rem;
    font-size: .875rem;
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control::placeholder {
    color: var(--text-3);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 91, 255, .12);
}

.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.form-check-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 91, 255, .12);
}

.form-text {
    color: var(--text-3);
}

.input-group-text {
    background: var(--surface-2);
    border-color: var(--border);
    color: var(--text-2);
}

/* Toggle de contraseña (markup heredado) */
.password-toggle-wrapper {
    position: relative;
}

.password-toggle-wrapper .form-control {
    padding-right: 2.6rem;
}

.password-toggle-icon {
    position: absolute;
    top: 50%;
    right: .9rem;
    transform: translateY(-50%);
    color: var(--text-3);
    cursor: pointer;
    transition: color var(--transition);
}

.password-toggle-icon:hover {
    color: var(--primary);
}


/* ============ 11. Tablas ============ */

.table {
    --bs-table-hover-bg: var(--surface-2);
    margin-bottom: 0;
    font-size: .855rem;
}

.table thead th {
    background: var(--surface-2);
    color: var(--text-3);
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    border-bottom: 1px solid var(--border);
    padding: .7rem 1rem;
    white-space: nowrap;
}

.table tbody td {
    padding: .8rem 1rem;
    vertical-align: middle;
    border-color: var(--border-2);
    color: var(--text);
}

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

.table-responsive {
    border-radius: var(--radius);
}

.card .table-responsive {
    margin: -1px;
}

/* Acciones de fila: iconos que aparecen suaves al hover */
.row-actions {
    display: inline-flex;
    gap: .25rem;
    opacity: .55;
    transition: opacity var(--transition);
}

tr:hover .row-actions {
    opacity: 1;
}

.row-actions .btn {
    width: 30px;
    height: 30px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .85rem;
}


/* ============ 12. Badges y estados ============ */

.badge {
    font-weight: 600;
    letter-spacing: .01em;
    border-radius: var(--radius-pill);
    padding: .32em .7em;
}

/* Pill de estado con dot */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: .42rem;
    font-size: .76rem;
    font-weight: 600;
    border-radius: var(--radius-pill);
    padding: .22rem .7rem;
    white-space: nowrap;
}

.status-pill .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

.status-pill.success { color: #0b815a; background: var(--success-soft); }
.status-pill.warning { color: #b45309; background: var(--warning-soft); }
.status-pill.danger  { color: #b91c1c; background: var(--danger-soft); }
.status-pill.info    { color: #0369a1; background: var(--info-soft); }
.status-pill.primary { color: var(--primary-700); background: var(--primary-soft); }
.status-pill.neutral { color: var(--text-2); background: var(--border-2); }

/* Soft backgrounds heredados del tema viejo */
.bg-soft-primary { background: var(--primary-soft) !important; color: var(--primary) !important; }
.bg-soft-success { background: var(--success-soft) !important; color: var(--success) !important; }
.bg-soft-danger  { background: var(--danger-soft) !important;  color: var(--danger) !important; }
.bg-soft-warning { background: var(--warning-soft) !important; color: var(--warning) !important; }

.primer-contacto-alert-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 50%;
    line-height: 1;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
}

.primer-contacto-alert-btn i {
    font-size: 1rem;
    line-height: 1;
}

.primer-contacto-alert-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.primer-contacto-alert-btn.is-green,
.primer-contacto-alert-btn.is-resolved {
    color: #0b815a;
    background: var(--success-soft);
    border-color: rgba(16, 185, 129, .28);
}

.primer-contacto-alert-btn.is-yellow {
    color: #b45309;
    background: var(--warning-soft);
    border-color: rgba(245, 158, 11, .32);
}

.primer-contacto-alert-btn.is-red {
    color: #b91c1c;
    background: var(--danger-soft);
    border-color: rgba(239, 68, 68, .3);
}

.primer-contacto-alert-btn.is-neutral {
    color: var(--text-2);
    background: var(--surface-2);
    border-color: var(--border);
}
.bg-soft-info    { background: var(--info-soft) !important;    color: var(--info) !important; }


/* ============ 13. Dropdowns, modales, alerts, paginación ============ */

.dropdown-menu {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: .4rem;
    font-size: .855rem;
    animation: dropdown-in 160ms var(--ease-spring);
}

@keyframes dropdown-in {
    from { opacity: 0; transform: translateY(-6px) scale(.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.dropdown-item {
    border-radius: var(--radius-sm);
    padding: .5rem .75rem;
    transition: background var(--transition), color var(--transition);
}

.dropdown-item:hover {
    background: var(--primary-soft);
    color: var(--primary-700);
}

.modal-content {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.modal-header {
    border-bottom: 1px solid var(--border-2);
}

.modal-footer {
    border-top: 1px solid var(--border-2);
    background: var(--surface-2);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.alert {
    border: none;
    border-radius: var(--radius);
}

.alert-success { background: var(--success-soft); color: #0b815a; }
.alert-danger  { background: var(--danger-soft);  color: #b91c1c; }
.alert-warning { background: var(--warning-soft); color: #b45309; }
.alert-info    { background: var(--info-soft);    color: #0369a1; }

.pagination {
    --bs-pagination-color: var(--text-2);
    --bs-pagination-border-color: var(--border);
    --bs-pagination-hover-color: var(--primary);
    --bs-pagination-hover-bg: var(--primary-soft);
    --bs-pagination-hover-border-color: var(--border);
    --bs-pagination-active-bg: var(--primary);
    --bs-pagination-active-border-color: var(--primary);
    --bs-pagination-focus-color: var(--primary);
    --bs-pagination-focus-box-shadow: 0 0 0 4px rgba(99, 91, 255, .12);
    gap: .25rem;
}

.pagination .page-link {
    border-radius: var(--radius-sm) !important;
    font-weight: 600;
    transition: all var(--transition);
}

.nav-tabs {
    border-bottom: 1px solid var(--border);
    gap: .25rem;
}

.nav-tabs .nav-link {
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-2);
    font-weight: 600;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    transition: all var(--transition);
}

.nav-tabs .nav-link:hover {
    color: var(--primary);
    background: var(--primary-soft);
}

.nav-tabs .nav-link.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: transparent;
}

.tooltip {
    --bs-tooltip-bg: var(--text);
    --bs-tooltip-border-radius: var(--radius-sm);
    font-family: var(--font-sans);
}


/* ============ 14. Login / auth ============ */

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: stretch;
    background: var(--bg);
}

.auth-split {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

.auth-branding {
    flex: 1.1;
    position: relative;
    display: none;
    flex-direction: column;
    justify-content: center;
    padding: 4rem;
    background:
        radial-gradient(1000px 600px at 15% 20%, rgba(139, 92, 246, .35), transparent 60%),
        radial-gradient(800px 500px at 85% 85%, rgba(99, 91, 255, .4), transparent 55%),
        var(--sidebar-grad);
    color: #fff;
    overflow: hidden;
}

@media (min-width: 992px) {
    .auth-branding {
        display: flex;
    }
}

.auth-branding h1 {
    color: #fff;
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: -.03em;
    line-height: 1.2;
}

.auth-branding p {
    color: #b6bdd4;
    font-size: 1rem;
    max-width: 420px;
}

.auth-branding .auth-feature {
    display: flex;
    align-items: center;
    gap: .8rem;
    color: #cdd3e6;
    font-size: .9rem;
    font-weight: 500;
}

.auth-branding .auth-feature i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, .08);
    color: #a5b4fc;
    font-size: 1rem;
}

/* Orbes decorativos animados */
.auth-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: .5;
    animation: orb-float 9s ease-in-out infinite alternate;
}

.auth-orb.one {
    width: 320px;
    height: 320px;
    background: #635bff;
    top: -80px;
    right: -60px;
}

.auth-orb.two {
    width: 260px;
    height: 260px;
    background: #8b5cf6;
    bottom: -70px;
    left: -50px;
    animation-delay: 2s;
}

@keyframes orb-float {
    from { transform: translateY(0) scale(1); }
    to   { transform: translateY(28px) scale(1.08); }
}

.auth-panel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.25rem;
}

.login-box {
    width: 100%;
    max-width: 420px;
}

.login-form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2.25rem 2rem;
}

.login-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.login-logo img {
    max-height: 48px;
}

.login-welcome {
    text-align: center;
    color: var(--text-2);
    font-size: .92rem;
    margin-bottom: 1.6rem;
}

.login-form-actions {
    margin-top: 1.4rem;
}

.login-form-footer a {
    color: var(--text-3);
    font-size: .82rem;
}

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


/* ============ 15. Page header de contenido ============ */

.content-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .75rem;
    margin-bottom: 1.4rem;
}

.content-header .page-title {
    font-size: 1.45rem;
    font-weight: 800;
    letter-spacing: -.02em;
    margin: 0;
}

.content-header .page-subtitle {
    color: var(--text-2);
    font-size: .86rem;
    margin: .15rem 0 0;
}

.breadcrumb {
    --bs-breadcrumb-divider-color: var(--text-3);
    margin-bottom: .35rem;
    font-size: .78rem;
}

.breadcrumb .breadcrumb-item a {
    color: var(--text-3);
    font-weight: 500;
}

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

.breadcrumb .breadcrumb-item.active {
    color: var(--text-2);
    font-weight: 600;
}


/* ============ 16. Utilidades y compatibilidad ============ */

/* Avatar con iniciales */
.avatar-initials {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    font-size: .75rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    text-transform: uppercase;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-2);
}

.empty-state .empty-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 1.9rem;
    margin-bottom: 1rem;
    animation: float-soft 3.5s ease-in-out infinite;
}

@keyframes float-soft {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-6px); }
}

.empty-state h5 {
    font-weight: 700;
    margin-bottom: .35rem;
}

.empty-state p {
    font-size: .85rem;
    color: var(--text-3);
    max-width: 380px;
    margin-inline: auto;
}

/* Skeleton shimmer */
.skeleton {
    position: relative;
    overflow: hidden;
    background: var(--border-2);
    border-radius: var(--radius-sm);
}

.skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .65), transparent);
    animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
    100% { transform: translateX(100%); }
}

/* Contenedor de gráficos */
.chart-card .card-body {
    min-height: 280px;
}

/* Texto auxiliar */
.text-secondary-2 {
    color: var(--text-2) !important;
}

.text-tertiary {
    color: var(--text-3) !important;
}

/* Footer móvil */
.mobile-footer {
    border-top: 1px solid var(--border-2);
}

/* Divisor con etiqueta */
.divider-label {
    display: flex;
    align-items: center;
    gap: .75rem;
    color: var(--text-3);
    font-size: .76rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    margin: 1.25rem 0 .9rem;
}

.divider-label::before,
.divider-label::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}


/* ============ 17. Sidebar: secciones agrupadas ============ */

.sidebar-section-label {
    display: block;
    padding: 1rem .85rem .35rem;
    font-size: .66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: #5d6685;
    white-space: nowrap;
}

.sidebar-menu ul + .sidebar-section-label {
    margin-top: .25rem;
}

@media (min-width: 992px) {
    .page-wrapper.sidebar-collapsed .sidebar-section-label {
        padding: .6rem 0 .25rem;
        margin: 0 .5rem;
        font-size: 0;
        border-top: 1px solid rgba(255, 255, 255, .08);
    }
}


/* ============ 18. Table toolbar y panel de filtros ============ */

.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 1rem;
    padding: 1rem 1.1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border-2);
}

.table-toolbar-main,
.table-toolbar-actions {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: .65rem;
    min-width: 0;
}

.table-toolbar-main {
    flex: 1 1 auto;
}

.table-toolbar-actions {
    flex: 0 0 auto;
}

.toolbar-search {
    position: relative;
    flex: 1 1 320px;
    width: min(420px, 100%);
    max-width: 420px;
}

.toolbar-search .bi-search {
    position: absolute;
    left: .8rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-3);
    font-size: .85rem;
    pointer-events: none;
}

.toolbar-search .form-control {
    min-height: 38px;
    padding-left: 2.3rem;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}

.toolbar-search .form-control:focus {
    background: var(--surface);
}

.filters-panel {
    padding: 1rem 1.1rem;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border-2);
}

.filters-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    border-radius: var(--radius-pill);
    background: var(--primary);
    color: #fff;
    font-size: .68rem;
    line-height: 18px;
    font-weight: 700;
    padding: 0 .35rem;
}

.toolbar-filter-btn {
    min-height: 38px;
    white-space: nowrap;
}

.toolbar-result-count {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    min-height: 36px;
    padding: 0 .7rem;
    color: var(--text-2);
    background: var(--surface-2);
    border: 1px solid var(--border-2);
    border-radius: var(--radius-sm);
    font-size: .78rem;
    font-weight: 600;
    white-space: nowrap;
}

.toolbar-result-count i {
    color: var(--text-3);
}

/* Toggle de vista (Tabla / Kanban) */
.view-toggle {
    display: inline-flex;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 3px;
    gap: 2px;
    min-height: 38px;
}

.view-toggle .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    min-width: 84px;
    border: none;
    background: transparent;
    color: var(--text-2);
    font-size: .8rem;
    font-weight: 600;
    padding: .35rem .7rem;
    border-radius: calc(var(--radius-sm) - 3px);
    box-shadow: none;
    white-space: nowrap;
}

.view-toggle .btn i {
    font-size: .95rem;
    line-height: 1;
}

.view-toggle .btn.active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

@media (max-width: 767.98px) {
    .table-toolbar {
        align-items: stretch;
        flex-direction: column;
        gap: .75rem;
    }

    .table-toolbar-main,
    .table-toolbar-actions {
        width: 100%;
    }

    .toolbar-search {
        max-width: none;
    }

    .table-toolbar-actions {
        justify-content: space-between;
    }
}

@media (max-width: 479.98px) {
    .table-toolbar-main {
        align-items: stretch;
        flex-direction: column;
    }

    .toolbar-search {
        flex: 0 0 auto;
        width: 100%;
    }

    .toolbar-filter-btn {
        width: 100%;
    }

    .toolbar-result-count {
        padding: 0 .55rem;
    }

    .view-toggle {
        flex: 1 1 auto;
    }

    .view-toggle .btn {
        flex: 1 1 50%;
        min-width: 0;
    }
}


/* ============ 19. Bulk bar y kebab menu ============ */

.bulk-bar {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem 1.1rem;
    background: var(--primary-soft);
    border-bottom: 1px solid var(--border-2);
    font-size: .84rem;
    font-weight: 600;
    color: var(--primary-700);
}

.kebab-btn {
    width: 30px;
    height: 30px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    color: var(--text-3);
    transition: background var(--transition), color var(--transition);
}

.kebab-btn:hover,
.kebab-btn[aria-expanded="true"] {
    background: var(--border-2);
    color: var(--text);
}

.table-responsive tbody tr.is-dropdown-open {
    position: relative;
    z-index: 20;
}

.table-responsive tbody .dropdown-menu {
    z-index: 1080;
}

@media (min-width: 992px) {
    .table-responsive.has-open-dropdown {
        overflow: visible;
    }
}


/* ============ 20. Dashboard: grid asimétrico, listas compactas, feed ============ */

.dash-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1rem;
    align-items: stretch;
}

@media (max-width: 1199.98px) {
    .dash-grid {
        grid-template-columns: 1fr;
    }
}

/* Lista compacta tipo "Recent Transactions" */
.list-compact {
    list-style: none;
    margin: 0;
    padding: 0;
}

.list-compact-item {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: .75rem 1.25rem;
    border-bottom: 1px solid var(--border-2);
    transition: background var(--transition);
}

.list-compact-item:last-child {
    border-bottom: 0;
}

.list-compact-item:hover {
    background: var(--surface-2);
}

.list-compact-item .item-body {
    flex: 1;
    min-width: 0;
}

.list-compact-item .item-title {
    font-weight: 600;
    font-size: .855rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-compact-item .item-sub {
    font-size: .76rem;
    color: var(--text-3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-compact-item .item-meta {
    text-align: right;
    flex-shrink: 0;
}

/* Mini-stat apilado (columna lateral del dashboard) */
.mini-stat {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .8rem 1.25rem;
    border-bottom: 1px solid var(--border-2);
}

.mini-stat:last-child {
    border-bottom: 0;
}

.mini-stat .mini-label {
    font-size: .78rem;
    font-weight: 600;
    color: var(--text-2);
    display: flex;
    align-items: center;
    gap: .5rem;
}

.mini-stat .mini-value {
    font-size: 1.05rem;
    font-weight: 800;
    font-feature-settings: "tnum";
}

/* Timeline / activity feed */
.feed-timeline {
    list-style: none;
    margin: 0;
    padding: 0;
}

.feed-item {
    position: relative;
    display: flex;
    gap: .9rem;
    padding: .85rem 1.25rem;
}

.feed-item .feed-icon {
    position: relative;
    z-index: 1;
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .95rem;
    background: var(--primary-soft);
    color: var(--primary);
}

/* Línea conectora entre items */
.feed-item:not(:last-child)::after {
    content: "";
    position: absolute;
    left: calc(1.25rem + 17px);
    top: 3.1rem;
    bottom: -0.5rem;
    width: 2px;
    background: var(--border);
}

.feed-item .feed-body {
    flex: 1;
    min-width: 0;
}

.feed-item .feed-title {
    font-weight: 600;
    font-size: .855rem;
}

.feed-item .feed-text {
    font-size: .8rem;
    color: var(--text-2);
}

.feed-item .feed-time {
    font-size: .73rem;
    color: var(--text-3);
    white-space: nowrap;
}

/* Leyenda de donut */
.donut-legend {
    list-style: none;
    margin: 0;
    padding: 0;
}

.donut-legend li {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .4rem 0;
    font-size: .82rem;
}

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

.donut-legend .legend-value {
    margin-left: auto;
    font-weight: 700;
    font-feature-settings: "tnum";
}


/* ============ 21. Settings tabs e inbox ============ */

.settings-tabs {
    overflow-x: auto;
    margin-bottom: 1.25rem;
    scrollbar-width: none;       /* Firefox */
    -ms-overflow-style: none;    /* IE/Edge */
}

.settings-tabs::-webkit-scrollbar {
    display: none;               /* Chrome/Safari */
}

.settings-tabs .nav-tabs {
    flex-wrap: nowrap;
    white-space: nowrap;
}

.settings-tabs .nav-link {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
}

.inbox-item {
    display: flex;
    gap: .9rem;
    padding: .95rem 1.25rem;
    border-bottom: 1px solid var(--border-2);
    border-left: 3px solid transparent;
    transition: background var(--transition);
}

.inbox-item:hover {
    background: var(--surface-2);
}

.inbox-item.unread {
    border-left-color: var(--primary);
    background: linear-gradient(90deg, var(--primary-soft), transparent 35%);
}

.inbox-item.unread .item-title {
    font-weight: 700;
}


/* ============ 22. Entity cards (grid de clientes/guiones) ============ */

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

.entity-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1.1rem 1.2rem;
    display: flex;
    flex-direction: column;
    gap: .85rem;
    transition: box-shadow var(--transition-slow), transform var(--transition-slow), border-color var(--transition-slow);
}

.entity-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: #dcdfe9;
}

.entity-card .entity-head {
    display: flex;
    align-items: flex-start;
    gap: .7rem;
}

.entity-card .entity-name {
    font-weight: 700;
    font-size: .92rem;
    color: var(--text);
    line-height: 1.3;
}

.entity-card .entity-sub {
    font-size: .78rem;
    color: var(--text-3);
    overflow-wrap: anywhere;
}

.entity-card .entity-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-top: 1px solid var(--border-2);
    padding-top: .8rem;
    margin-top: auto;
}

.entity-card .entity-stats > div + div {
    border-left: 1px solid var(--border-2);
    padding-left: .9rem;
}

.entity-card .entity-stat-label {
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-3);
}

.entity-card .entity-stat-value {
    font-size: 1.1rem;
    font-weight: 800;
    font-feature-settings: "tnum";
}


/* ============ 23. Novedades UNIO (detalle + editor) ============ */

.crm-news-detail-cover {
    width: 100%;
    height: auto;
    display: block;
    background: #f1f5f9;
}

.crm-news-content {
    font-size: 1rem;
    line-height: 1.65;
}

.crm-news-content h2,
.crm-news-content h3,
.crm-news-content h4 {
    margin-top: 1.25rem;
    margin-bottom: .75rem;
}

.crm-news-content blockquote {
    margin: 1rem 0;
    padding: .75rem 1rem;
    border-left: 4px solid var(--primary);
    background: #f8fafc;
    color: #475569;
}

.rich-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    padding: .65rem;
    border: 1px solid #ced4da;
    border-bottom: 0;
    border-radius: .375rem .375rem 0 0;
    background: #f8fafc;
}

.rich-editor-toolbar .btn {
    min-width: 36px;
}

.rich-editor-area {
    min-height: 260px;
    padding: 1rem;
    border: 1px solid #ced4da;
    border-radius: 0 0 .375rem .375rem;
    background: #fff;
    outline: 0;
    line-height: 1.6;
}

.rich-editor-area:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 .25rem rgba(13, 110, 253, .15);
}

.rich-editor-area:empty::before {
    content: attr(data-placeholder);
    color: #94a3b8;
}


/* ============ 24. Campaigns misc ============ */

.campaign-edit-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.campaign-edit-actions-left {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.campaign-edit-actions-right {
    width: auto;
}

.campaign-edit-actions .action-plantilla-wrap {
    margin: 0 !important;
}

@media (max-width: 991.98px) {
    .campaign-edit-actions-right {
        width: 100%;
    }

    .campaign-edit-actions-right .btn {
        width: 100%;
    }
}

.stat-card { transition: all 0.2s ease; }
.stat-clickable:hover { transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0,0,0,.1); }
.stat-disabled { opacity: .6; cursor: not-allowed !important; }


/* ============ 25. Lead detail workspace ============ */

.lead-detail-container {
    padding: 0 14px 28px;
}

.lead-record-summary {
    border-color: #dce4f3;
    background: #f7f9fd;
}

.lead-record-summary .card-body {
    padding: 18px 20px 0;
}

.lead-record-summary-main {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 14px;
    align-items: center;
    padding-bottom: 18px;
}

.lead-record-avatar {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 1.25rem;
    font-weight: 800;
}

.lead-record-identity {
    min-width: 0;
}

.lead-record-state,
.lead-record-contact,
.lead-record-relations {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.lead-record-state {
    gap: 10px;
    margin-bottom: 8px;
}

.lead-record-id {
    color: var(--text-3);
    font-size: .8rem;
    font-weight: 700;
}

.lead-record-contact {
    gap: 6px 20px;
    color: var(--text-2);
    font-size: .875rem;
}

.lead-record-contact span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.lead-record-contact i {
    margin-right: 5px;
    color: var(--text-3);
}

.lead-record-relations {
    margin: 0 -20px;
    border-top: 1px solid var(--border-2);
}

.lead-record-relations > a,
.lead-record-relations > span {
    min-width: 260px;
    flex: 1 1 0;
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) 16px;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    color: var(--text);
    text-decoration: none;
}

.lead-record-relations > * + * {
    border-left: 1px solid var(--border-2);
}

.lead-record-relations > a:hover {
    background: var(--surface-2);
}

.lead-record-relations > span {
    grid-template-columns: 28px minmax(0, 1fr);
}

.lead-record-relations > a > i:first-child,
.lead-record-relations > span > i:first-child {
    color: var(--primary);
    font-size: 1rem;
}

.lead-record-relations .lead-record-ad > i:first-child {
    color: var(--success);
}

.lead-record-relations small {
    display: block;
    margin-bottom: 2px;
    color: var(--text-3);
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.lead-record-relations span span,
.lead-record-relations a span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.lead-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.lead-section-header .card-title {
    margin: 2px 0 0;
    font-size: 1rem;
}

.lead-section-eyebrow {
    display: block;
    color: var(--text-3);
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.lead-qualification-card {
    border-color: #dfe3e8;
    background: #f3f5f7;
}

.lead-qualification-card .card-header,
.lead-qualification-card .card-body {
    background: transparent;
}

.lead-qualification-list {
    display: grid;
}

.lead-qualification-item {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 12px;
    padding: 16px 20px;
}

.lead-qualification-item + .lead-qualification-item {
    border-top: 1px solid var(--border-2);
}

.lead-question-number {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 6px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: .75rem;
    font-weight: 800;
}

.lead-qualification-item h3 {
    margin: 1px 0 6px;
    color: var(--text-2);
    font-size: .78rem;
    font-weight: 700;
    line-height: 1.4;
}

.lead-answer-text {
    margin: 0;
    color: var(--text);
    font-size: .95rem;
    font-weight: 600;
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.lead-empty-state {
    min-height: 180px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 28px;
    color: var(--text-3);
    text-align: center;
}

.lead-empty-state i {
    margin-bottom: 6px;
    font-size: 1.75rem;
}

.lead-empty-state strong {
    color: var(--text-2);
}

.lead-journey-card {
    overflow: hidden;
    border-color: #d7e7f5;
    background: #f1f8fd;
}

.lead-journey-card .card-header,
.lead-journey-card .card-body {
    background: transparent;
}

.lead-journey-card .card-body {
    padding: 18px 20px 14px;
}

.lead-journey-scroll {
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px 2px 12px;
    cursor: grab;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
    touch-action: pan-y;
    user-select: none;
    -webkit-overflow-scrolling: touch;
}

.lead-journey-scroll::-webkit-scrollbar {
    display: none;
}

.lead-journey-scroll.is-dragging {
    cursor: grabbing;
}

.lead-journey-scroll.is-dragging * {
    pointer-events: none;
}

.lead-journey-scroll:focus-visible {
    outline: 3px solid rgba(99, 91, 255, .18);
    outline-offset: 2px;
}

.lead-journey-track {
    min-width: max-content;
    display: flex;
    align-items: flex-start;
    margin: 0;
    padding: 0;
    list-style: none;
}

.lead-journey-event {
    --journey-event-width: 190px;
    position: relative;
    width: var(--journey-event-width);
    flex: 0 0 var(--journey-event-width);
    padding-right: 22px;
}

.lead-journey-event:not(:last-child)::after {
    content: "";
    position: absolute;
    z-index: 0;
    top: 17px;
    left: 34px;
    right: 0;
    height: 2px;
    background: var(--border);
}

.lead-journey-duration {
    position: absolute;
    z-index: 2;
    top: 7px;
    left: calc(18px - (var(--journey-event-width) / 2));
    transform: translateX(-50%);
    min-width: 74px;
    padding: 2px 6px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-2);
    font-size: .64rem;
    font-weight: 700;
    line-height: 1.35;
    text-align: center;
    white-space: nowrap;
}

.lead-journey-point {
    position: relative;
    z-index: 1;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    margin-bottom: 10px;
    border: 3px solid var(--surface);
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    box-shadow: 0 0 0 1px var(--border);
    font-size: .82rem;
}

.lead-journey-content {
    max-width: 164px;
}

.lead-journey-content time,
.lead-journey-content strong,
.lead-journey-content span {
    display: block;
}

.lead-journey-content time {
    margin-bottom: 2px;
    color: var(--text-3);
    font-size: .68rem;
    font-weight: 600;
}

.lead-journey-content strong {
    margin-bottom: 3px;
    color: var(--text);
    font-size: .82rem;
    line-height: 1.35;
}

.lead-journey-content span {
    display: -webkit-box;
    overflow: hidden;
    color: var(--text-2);
    font-size: .74rem;
    line-height: 1.4;
    overflow-wrap: anywhere;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.lead-journey-event.is-registration .lead-journey-point {
    background: var(--primary);
}

.lead-journey-event.is-contact .lead-journey-point {
    background: #2563eb;
}

.lead-journey-event.is-contact.is-whatsapp .lead-journey-point {
    background: #25d366;
}

.lead-journey-event.is-gap {
    --journey-event-width: 165px;
}

.lead-journey-event.is-gap .lead-journey-point {
    background: var(--text-3);
}

.lead-journey-event.is-semaphore .lead-journey-point {
    background: #64748b;
}

.lead-journey-event.is-semaphore.is-green .lead-journey-point {
    background: var(--success);
}

.lead-journey-event.is-semaphore.is-yellow .lead-journey-point {
    background: var(--warning);
    color: #3d2d00;
}

.lead-journey-event.is-semaphore.is-red .lead-journey-point {
    background: var(--danger);
}

.lead-detail-sidebar {
    position: sticky;
    top: calc(var(--navbar-height) + 16px);
    max-height: calc(100vh - var(--navbar-height) - 32px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
}

.lead-detail-container > .row > aside {
    align-self: stretch;
}

.lead-attention-card {
    border-width: 1px !important;
    background: #f5f7fa;
}

.lead-attention-card.border-success {
    border-color: #cce8dc !important;
    background: #eff9f5;
}

.lead-attention-card.border-warning {
    border-color: #f1dfb8 !important;
    background: #fff9e9;
}

.lead-attention-card.border-danger {
    border-color: #efd0d4 !important;
    background: #fff3f4;
}

.lead-attention-card.border-secondary {
    border-color: #dde2e8 !important;
    background: #f5f7fa;
}

.lead-attention-card .card-header,
.lead-attention-card .card-body {
    background: transparent;
}

.lead-contact-card {
    border-color: #cfe9df;
    background: #eef9f5;
}

.lead-contact-card .card-header,
.lead-contact-card .collapse .card-body {
    background: transparent;
}

.lead-contact-toggle {
    width: 100%;
    min-height: 62px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 16px;
    border: 0;
    background: transparent;
    color: var(--text);
    text-align: left;
}

.lead-contact-toggle:hover {
    background: var(--surface-2);
}

.lead-contact-toggle:focus-visible {
    outline: 3px solid rgba(99, 91, 255, .2);
    outline-offset: -3px;
}

.lead-contact-toggle-title {
    display: block;
    margin-top: 2px;
    font-size: 1rem;
    font-weight: 700;
}

.lead-contact-toggle-icon {
    flex: 0 0 auto;
    transition: transform var(--transition);
}

.lead-contact-toggle[aria-expanded="true"] .lead-contact-toggle-icon {
    transform: rotate(180deg);
}

.lead-contact-card .collapse .card-body {
    border-top: 1px solid var(--border-2);
}

.lead-followup-card {
    border-color: #dddaf7;
    background: #f6f4fc;
}

.lead-followup-card .card-header,
.lead-followup-card .card-body {
    background: transparent;
}

.lead-followup-card .form-control,
.lead-followup-card .form-select {
    background-color: #fff;
}

.lead-activity-card {
    border-color: #e5dfd5;
    background: #faf8f4;
}

.lead-activity-card .card-header,
.lead-activity-card .card-body {
    background: transparent;
}

.lead-contact-details {
    margin: 0 0 16px;
}

.lead-contact-details > div {
    padding: 10px 0;
    border-bottom: 1px solid var(--border-2);
}

.lead-contact-details > div:first-child {
    padding-top: 0;
}

.lead-contact-details dt {
    margin-bottom: 3px;
    color: var(--text-3);
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.lead-contact-details dt i {
    margin-right: 4px;
}

.lead-contact-details dd {
    margin: 0;
    color: var(--text);
    font-size: .9rem;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.lead-contact-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.lead-contact-actions .btn {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.lead-contact-unavailable {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--text-2);
    font-size: .82rem;
}

.lead-attention-traffic {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
}

.traffic-light {
    width: 52px;
    min-width: 52px;
    padding: 8px;
    border-radius: 8px;
    background: #20262d;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.traffic-light-dot {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #737983;
    opacity: .22;
    box-shadow: inset 0 2px 7px rgba(0,0,0,.48);
}

.traffic-light-dot.is-active {
    opacity: 1;
}

.traffic-light-dot.red.is-active {
    background: #dc3545;
    box-shadow: 0 0 0 3px rgba(220,53,69,.15), 0 0 12px rgba(220,53,69,.6);
}

.traffic-light-dot.yellow.is-active {
    background: #ffc107;
    box-shadow: 0 0 0 3px rgba(255,193,7,.16), 0 0 12px rgba(255,193,7,.58);
}

.traffic-light-dot.green.is-active {
    background: #198754;
    box-shadow: 0 0 0 3px rgba(25,135,84,.15), 0 0 12px rgba(25,135,84,.55);
}

.lead-attention-state-title {
    font-size: 1.05rem;
    font-weight: 800;
}

.lead-attention-status {
    margin: 2px 0;
    color: var(--text);
    font-size: .9rem;
    font-weight: 700;
}

.lead-attention-details {
    margin: 0;
}

.lead-attention-details > div {
    display: grid;
    grid-template-columns: minmax(110px, .8fr) minmax(0, 1.2fr);
    gap: 12px;
    padding: 10px 0;
    border-top: 1px solid var(--border-2);
}

.lead-attention-details dt {
    color: var(--text-3);
    font-size: .75rem;
    font-weight: 600;
}

.lead-attention-details dd {
    min-width: 0;
    margin: 0;
    color: var(--text);
    font-size: .82rem;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.lead-detail-container .timeline {
    position: relative;
    padding: 4px 0;
}

.lead-detail-container .timeline-item {
    position: relative;
    padding: 0 0 24px 48px;
}

.lead-detail-container .timeline-item:last-child {
    padding-bottom: 0;
}

.lead-detail-container .timeline-icon {
    position: absolute;
    left: 0;
    top: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: #fff;
    font-size: .85rem;
}

.lead-detail-container .timeline-icon.llamada { background: #198754; }
.lead-detail-container .timeline-icon.email { background: #0d6efd; }
.lead-detail-container .timeline-icon.whatsapp { background: #128c5e; }
.lead-detail-container .timeline-icon.reunion { background: #d97706; }
.lead-detail-container .timeline-icon.nota { background: #64748b; }
.lead-detail-container .timeline-icon.cambio-estado { background: #7c3aed; }

.lead-detail-container .timeline-line {
    position: absolute;
    left: 16px;
    top: 34px;
    bottom: 0;
    width: 2px;
    background: var(--border-2);
}

.lead-detail-container .timeline-content {
    padding: 13px 15px;
    border: 1px solid var(--border-2);
    border-radius: 6px;
    background: var(--surface-2);
}

.timeline-status-change-badge {
    border: 1px solid #d6a000;
    background: #fff7cc !important;
    color: #624900 !important;
    font-weight: 700;
}

@media (max-width: 991.98px) {
    .lead-detail-container > .row > aside,
    .lead-detail-container .lead-detail-sidebar {
        display: contents;
    }

    .lead-detail-container .lead-contact-card {
        width: 100%;
        order: -1;
        margin-top: 1.5rem;
    }

    .lead-detail-container .lead-attention-card {
        width: 100%;
        order: 0;
    }

    .lead-detail-container > .row > main {
        order: 1;
    }

    .lead-detail-container .lead-tareas-card {
        width: 100%;
        order: 0;
    }

    .lead-detail-container .lead-assign-card {
        width: 100%;
        order: 0;
    }

    .lead-detail-sidebar {
        position: static;
        max-height: none;
        overflow: visible;
    }
}

@media (max-width: 767.98px) {
    .lead-detail-container {
        padding: 0 8px 20px;
    }

    .lead-record-summary .card-body {
        padding: 16px 16px 0;
    }

    .lead-record-summary-main {
        grid-template-columns: 42px minmax(0, 1fr);
    }

    .lead-record-avatar {
        width: 42px;
        height: 42px;
    }

    .lead-record-relations {
        margin: 0 -16px;
    }

    .lead-record-relations > a,
    .lead-record-relations > span {
        min-width: 100%;
        padding: 11px 16px;
    }

    .lead-record-relations > * + * {
        border-top: 1px solid var(--border-2);
        border-left: 0;
    }

    .lead-qualification-item {
        padding: 14px 16px;
    }

    .lead-journey-card .card-body {
        padding-inline: 16px;
    }

    .lead-journey-event {
        --journey-event-width: 170px;
    }

    .lead-journey-content {
        max-width: 145px;
    }

    .lead-contact-actions {
        grid-template-columns: 1fr;
    }

    .lead-detail-container .timeline-content > .d-flex {
        flex-direction: column;
        gap: 6px;
    }
}

/* ============ 26. Perfil de usuario ============ */

/* ── Sidebar de identidad ── */
.profile-id-card {
    position: sticky;
    top: calc(var(--navbar-height, 64px) + 16px);
}

/* Avatar con overlay de cámara al hover */
.profile-avatar-label {
    display: inline-block;
    position: relative;
    cursor: pointer;
    border-radius: 50%;
}

.profile-avatar-img {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--border, #e2e8f0);
    display: block;
    transition: filter 0.2s;
}

.profile-avatar-label .avatar-initials {
    width: 96px !important;
    height: 96px !important;
    font-size: 2rem !important;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
    transition: filter 0.2s;
}

/* Overlay oscuro con icono al hover */
.profile-avatar-overlay {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(0,0,0,.45);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    opacity: 0;
    transition: opacity 0.2s;
    font-size: .8rem;
    gap: 3px;
}

.profile-avatar-overlay i {
    font-size: 1.25rem;
}

.profile-avatar-overlay-text {
    font-size: .7rem;
    font-weight: 500;
    white-space: nowrap;
}

.profile-avatar-label:hover .profile-avatar-overlay {
    opacity: 1;
}

.profile-avatar-label:hover .profile-avatar-img,
.profile-avatar-label:hover .avatar-initials {
    filter: brightness(.65);
}

/* Nombre del usuario en el sidebar */
.profile-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}

/* Tabla de metadata */
.profile-meta {
    border-top: 1px solid var(--border, #e2e8f0);
    padding-top: .875rem;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.profile-meta-item {
    display: grid;
    grid-template-columns: 1rem auto 1fr;
    align-items: baseline;
    gap: .4rem;
    font-size: .8rem;
}

.profile-meta-item span.text-muted {
    color: var(--text-3);
}

.profile-meta-item strong {
    text-align: right;
    font-weight: 600;
    color: var(--text);
    font-size: .8rem;
}

/* ── Panel de formularios ── */
.profile-section-header {
    display: flex;
    align-items: flex-start;
    gap: .875rem;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border, #e2e8f0);
}

.profile-section-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--primary-soft, rgba(99,91,255,.1));
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.profile-section-icon--warning {
    background: rgba(245,158,11,.12);
    color: #d97706;
}

.profile-section-title {
    font-size: .9rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: .15rem;
}

.profile-section-sub {
    font-size: .8rem;
    color: var(--text-3);
    margin-bottom: 0;
}

.profile-toggle-row {
    background: var(--surface-2, #f8fafc);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: var(--radius, 8px);
    padding: .75rem 1rem;
}

/* ── Foto en el navbar ── */
.nav-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,.25);
}
