/* ============================================================
   Mensajes — Sistema de diseño v2 (app.mensajes.co)
   Moderno, elegante, sin build step. Mismas clases que v1.
   ============================================================ */

:root {
    /* Marca */
    --verde-50: #f0fdf4;
    --verde-100: #dcfce7;
    --verde-200: #bbf7d0;
    --verde-400: #4ade80;
    --verde-500: #22c55e;
    --verde-600: #16a34a;
    --verde-700: #15803d;

    /* Neutros (slate) */
    --gris-50: #f8fafc;
    --gris-100: #f1f5f9;
    --gris-200: #e2e8f0;
    --gris-300: #cbd5e1;
    --gris-400: #94a3b8;
    --gris-500: #64748b;
    --gris-600: #475569;
    --gris-700: #334155;
    --gris-800: #1e293b;
    --gris-900: #0f172a;

    /* Semánticos */
    --rojo-500: #ef4444;
    --rojo-50: #fef2f2;
    --ambar-500: #f59e0b;
    --ambar-50: #fffbeb;
    --azul-500: #3b82f6;

    /* Superficie */
    --fondo: #f4f6fa;
    --superficie: #ffffff;
    --borde: #e6eaf1;
    --texto: var(--gris-800);
    --texto-suave: var(--gris-500);

    /* Sidebar */
    --sidebar-bg: linear-gradient(180deg, #0d1526 0%, #0a1120 100%);
    --sidebar-ancho: 248px;

    --radio: 16px;
    --radio-sm: 12px;
    --sombra-xs: 0 1px 2px rgba(15, 23, 42, .04);
    --sombra-sm: 0 1px 2px rgba(15, 23, 42, .03), 0 2px 6px rgba(15, 23, 42, .04);
    --sombra: 0 2px 6px rgba(15, 23, 42, .04), 0 8px 22px rgba(15, 23, 42, .05);
    --sombra-md: 0 6px 16px rgba(15, 23, 42, .06), 0 22px 48px rgba(15, 23, 42, .10);
    --sombra-verde: 0 3px 10px rgba(34, 197, 94, .24);
    --anillo: 0 0 0 3px rgba(34, 197, 94, .16);
    --fuente: 'Inter', system-ui, -apple-system, sans-serif;
    --transicion: .18s cubic-bezier(.4, 0, .2, 1);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--fuente);
    font-size: 14px;
    line-height: 1.55;
    color: var(--texto);
    background: var(--fondo);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--verde-600); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { font-weight: 700; line-height: 1.25; color: var(--gris-900); letter-spacing: -.01em; }

/* Scrollbars sutiles */
* { scrollbar-width: thin; scrollbar-color: var(--gris-300) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--gris-300); border-radius: 999px; }
*::-webkit-scrollbar-thumb:hover { background: var(--gris-400); }
*::-webkit-scrollbar-track { background: transparent; }

/* Accesibilidad: anillo de foco consistente */
:focus-visible { outline: none; box-shadow: var(--anillo); border-radius: var(--radio-sm); }

@keyframes aparecer { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Layout: shell de la app ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-ancho);
    flex-shrink: 0;
    background: var(--sidebar-bg);
    color: var(--gris-300);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    border-right: 1px solid rgba(255, 255, 255, .04);
}
.sidebar-logo {
    display: flex; align-items: center; gap: 9px;
    padding: 22px 20px 18px;
    color: #fff; font-weight: 800; font-size: 17.5px; letter-spacing: -.02em;
}
.sidebar-logo .logo-icono { width: 30px; height: 30px; filter: drop-shadow(0 0 8px rgba(34, 197, 94, .45)); }
.sidebar-logo .logo-co { color: var(--verde-400); }
.sidebar-nav { flex: 1; padding: 6px 14px; display: flex; flex-direction: column; gap: 3px; }
.sidebar-nav a {
    position: relative;
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radio-sm);
    color: var(--gris-400);
    font-weight: 500; font-size: 13.5px;
    transition: background var(--transicion), color var(--transicion);
}
.sidebar-nav a:hover { background: rgba(255, 255, 255, .05); color: #fff; text-decoration: none; }
.sidebar-nav a.activo {
    background: rgba(34, 197, 94, .12);
    color: var(--verde-400);
    font-weight: 600;
}
.sidebar-nav a.activo::before {
    content: '';
    position: absolute; left: -14px; top: 20%; bottom: 20%;
    width: 3px; border-radius: 0 3px 3px 0;
    background: var(--verde-500);
}
.sidebar-nav a.deshabilitado { opacity: .32; pointer-events: none; }
.sidebar-nav .icono { width: 20px; text-align: center; font-size: 15px; filter: grayscale(.2); }
.sidebar-pie { padding: 14px; border-top: 1px solid rgba(255, 255, 255, .06); }

.contenido { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 15px 32px;
    background: rgba(255, 255, 255, .85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--borde);
    position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-toggle { display: none; border: none; background: transparent; font-size: 22px; line-height: 1; color: var(--gris-700); padding: 4px 6px; border-radius: 8px; }
.menu-toggle:hover { background: var(--gris-100); }
.sidebar-backdrop { display: none; }
.main { padding: 30px 34px; flex: 1; animation: aparecer .25s ease both; }

/* ---------- Layout: páginas de auth ---------- */
.auth-pagina {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background:
        radial-gradient(600px 400px at 85% 10%, rgba(34, 197, 94, .10), transparent 60%),
        radial-gradient(500px 380px at 10% 90%, rgba(59, 130, 246, .07), transparent 60%),
        var(--fondo);
    padding: 24px;
}
.auth-caja { width: 100%; max-width: 424px; animation: aparecer .35s ease both; }
.auth-logo {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    font-size: 26px; font-weight: 800; color: var(--verde-600);
    margin-bottom: 26px; letter-spacing: -.02em;
}
.auth-logo .logo-icono { width: 40px; height: 40px; filter: drop-shadow(0 4px 10px rgba(34, 197, 94, .3)); }
.auth-logo .logo-co { color: #16306e; }
.auth-card {
    background: var(--superficie);
    border: 1px solid var(--borde);
    border-radius: 18px;
    box-shadow: var(--sombra-md);
    padding: 34px;
}
.auth-card h1 { font-size: 21px; margin-bottom: 4px; }
.auth-card .subtitulo { color: var(--texto-suave); margin-bottom: 24px; font-size: 13.5px; }
.auth-alternativa { text-align: center; margin-top: 22px; color: var(--texto-suave); }
/* Acceso con Google (botón oficial de GIS) + separador + formulario de email plegable */
.auth-google { display: flex; justify-content: center; margin: 2px 0 18px; min-height: 44px; }
.auth-divisor { display: flex; align-items: center; gap: 12px; margin: 0 0 18px; color: var(--texto-suave); font-size: 12.5px; }
.auth-divisor::before, .auth-divisor::after { content: ''; flex: 1; height: 1px; background: var(--gris-200); }
.auth-plegable summary { cursor: pointer; list-style: none; text-align: center; font-size: 13.5px; font-weight: 500; color: var(--verde-600); padding: 6px 0; }
.auth-plegable summary::-webkit-details-marker { display: none; }
.auth-plegable[open] summary { color: var(--texto-suave); font-weight: 400; }

/* ===== Onboarding (/bienvenida): wizard de 4 pasos ===== */
.ob-pagina { align-items: flex-start; padding-top: 32px; }
.ob-caja { width: 100%; max-width: 640px; animation: aparecer .35s ease both; }
.ob-card h1 { font-size: 22px; margin-bottom: 4px; }
.ob-progreso { display: flex; gap: 6px; margin: 0 0 18px; }
.ob-progreso span { flex: 1; text-align: center; font-size: 11.5px; font-weight: 600; color: var(--texto-suave); padding: 8px 4px 10px; border-bottom: 3px solid var(--gris-200); transition: all .2s; }
.ob-progreso span.activo { color: var(--verde-600); border-color: var(--verde-500, #22c55e); }
.ob-progreso span.hecho { color: var(--verde-600); border-color: var(--verde-200, #bbf7d0); }
.ob-paso { display: none; }
.ob-paso.activo { display: block; animation: aparecer .25s ease both; }
.ob-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ob-chip { border: 1.5px solid var(--gris-200); background: #fff; border-radius: 999px; padding: 9px 14px; font-size: 13px; font-weight: 500; color: var(--texto); cursor: pointer; transition: all .15s; font-family: inherit; }
.ob-chip:hover { border-color: var(--gris-300); background: var(--gris-50); }
.ob-chip.sel { border-color: var(--verde-500, #22c55e); background: var(--verde-50, #f0fdf4); color: var(--verde-700, #15803d); box-shadow: 0 0 0 3px rgba(34,197,94,.12); }
.ob-chips-grande { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ob-chips-grande .ob-chip { border-radius: 14px; padding: 14px; text-align: left; display: flex; align-items: center; gap: 10px; font-size: 14px; }
.ob-chip-icono { font-size: 20px; }
.ob-check { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; line-height: 1.45; cursor: pointer; padding: 6px 0; }
.ob-check input { margin-top: 3px; flex: 0 0 auto; }
.ob-plegable { margin-top: 4px; }
.ob-plegable summary { cursor: pointer; font-size: 13.5px; font-weight: 500; color: var(--verde-600); padding: 6px 0; list-style: none; }
.ob-plegable summary::-webkit-details-marker { display: none; }
/* FAQs del onboarding: tarjeta por pregunta (sugerida por IA o manual), con campos con estilo propio
   porque están fuera de .campo */
.ob-faq { display: grid; gap: 4px; margin-bottom: 12px; padding: 12px 14px; background: #fff; border: 1px solid var(--gris-200); border-radius: 12px; }
.ob-faq.revisar { border-color: #fbbf24; background: #fffbeb; }
.ob-faq-cab { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; font-size: 12px; color: var(--texto-suave); }
.ob-faq-cab em { font-style: normal; color: #d97706; font-weight: 600; }
.ob-faq-quitar { border: none; background: transparent; cursor: pointer; color: var(--texto-suave); font-size: 14px; padding: 2px 6px; border-radius: 6px; }
.ob-faq-quitar:hover { background: var(--gris-100, #f1f5f9); color: var(--texto); }
.ob-faq-etq { font-size: 11.5px; font-weight: 600; color: var(--texto-suave); margin-top: 4px; }
.ob-faq input, .ob-faq textarea, .ob-prompt {
    width: 100%; padding: 9px 12px; border: 1px solid var(--gris-200); border-radius: var(--radio-sm);
    background: var(--superficie); outline: none; font: inherit; color: inherit;
    transition: border-color var(--transicion), box-shadow var(--transicion);
}
.ob-faq input:focus, .ob-faq textarea:focus, .ob-prompt:focus { border-color: var(--verde-500); box-shadow: var(--anillo); }
.ob-prompt { font-size: 13px; line-height: 1.5; resize: vertical; min-height: 220px; }
.ob-sugerir-estado { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--texto-suave); padding: 10px 12px; background: var(--gris-50); border-radius: 10px; margin-bottom: 10px; }
.ob-sugerir-estado .spinner { width: 16px; height: 16px; border-width: 2px; }
.ob-preview { background: #e5ddd5; border-radius: 14px; padding: 14px; }
.ob-burbuja { background: #fff; border-radius: 0 12px 12px 12px; padding: 10px 12px; font-size: 13.5px; line-height: 1.45; max-width: 88%; box-shadow: 0 1px 1px rgba(0,0,0,.08); }
.ob-acciones { display: flex; justify-content: space-between; gap: 12px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--gris-100, #f1f5f9); }
@media (max-width: 560px) { .ob-chips-grande { grid-template-columns: 1fr; } .ob-progreso span { font-size: 10px; } }

/* ===== Chat de prueba del asistente (parcial views/chatbot/_prueba.php) ===== */
.prueba-chat { border: 1px solid var(--gris-200); border-radius: 14px; overflow: hidden; background: #fff; }
.prueba-cabecera { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--gris-100, #f1f5f9); background: var(--gris-50); }
.prueba-punto { width: 9px; height: 9px; border-radius: 50%; background: var(--verde-500, #22c55e); box-shadow: 0 0 0 3px rgba(34,197,94,.18); flex: 0 0 auto; }
.prueba-msgs { height: 280px; overflow-y: auto; padding: 14px; background: #e5ddd5; display: flex; flex-direction: column; gap: 8px; }
.prueba-burbuja { max-width: 82%; padding: 9px 12px; border-radius: 12px; font-size: 13.5px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; box-shadow: 0 1px 1px rgba(0,0,0,.08); }
.prueba-burbuja.bot { background: #fff; align-self: flex-start; border-top-left-radius: 2px; }
.prueba-burbuja.yo { background: #dcf8c6; align-self: flex-end; border-top-right-radius: 2px; }
.prueba-burbuja.escribiendo { color: var(--texto-suave); letter-spacing: 2px; }
.prueba-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--gris-100, #f1f5f9); }
.prueba-form input { flex: 1; }

/* ===== Checklist de arranque (inbox, estado vacío del chat) ===== */
.checklist-arranque { text-align: left; background: #fff; border: 1px solid var(--gris-200); border-radius: 14px; padding: 18px 20px; max-width: 360px; box-shadow: 0 6px 24px rgba(15,23,42,.06); }
.checklist-arranque strong { display: block; font-size: 14px; margin-bottom: 10px; }
.checklist-arranque ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.checklist-arranque li { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--texto); }
.checklist-arranque li.hecho { color: var(--texto-suave); text-decoration: line-through; }
.checklist-arranque li a { margin-left: auto; font-size: 12px; font-weight: 600; text-decoration: none; }
.checklist-arranque li em { margin-left: auto; font-size: 11.5px; color: var(--texto-suave); font-style: normal; }

/* ---------- Componentes ---------- */
.card {
    background: var(--superficie);
    border: 1px solid var(--borde);
    border-radius: var(--radio);
    box-shadow: var(--sombra-sm);
    padding: 24px;
}

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radio-sm);
    border: 1px solid transparent;
    font-weight: 600; font-size: 13.5px;
    transition: all var(--transicion);
    text-decoration: none !important;
    white-space: nowrap;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primario {
    background: linear-gradient(180deg, var(--verde-500), var(--verde-600));
    color: #fff;
    box-shadow: var(--sombra-verde), inset 0 1px 0 rgba(255, 255, 255, .18);
}
.btn-primario:hover { filter: brightness(1.05); transform: translateY(-1px); color: #fff; }
.btn-secundario {
    background: var(--superficie);
    color: var(--gris-700);
    border-color: var(--gris-200);
    box-shadow: var(--sombra-xs);
}
.btn-secundario:hover { background: var(--gris-50); border-color: var(--gris-300); }
.btn-peligro { background: var(--rojo-500); color: #fff; }
.btn-peligro:hover { filter: brightness(1.08); color: #fff; }
.btn-bloque { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none !important; }

.campo { margin-bottom: 16px; }
.campo label { display: block; font-weight: 600; margin-bottom: 6px; color: var(--gris-700); font-size: 13px; }
.campo input:not([type="radio"]):not([type="checkbox"]), .campo select, .campo textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gris-200);
    border-radius: var(--radio-sm);
    background: var(--superficie);
    outline: none;
    box-shadow: var(--sombra-xs);
    transition: border-color var(--transicion), box-shadow var(--transicion);
}
.campo input:not([type="radio"]):not([type="checkbox"]):hover, .campo select:hover, .campo textarea:hover { border-color: var(--gris-300); }
.campo input:not([type="radio"]):not([type="checkbox"]):focus, .campo select:focus, .campo textarea:focus {
    border-color: var(--verde-500);
    box-shadow: var(--anillo);
}

/* Radios y checkboxes: nativos, compactos, en verde de marca (nunca full-width ni con borde de caja) */
input[type="radio"], input[type="checkbox"] {
    -webkit-appearance: auto; appearance: auto;
    width: 16px; height: 16px; flex: 0 0 auto; margin: 0;
    accent-color: var(--verde-600); cursor: pointer;
    box-shadow: none;
}
.campo .ayuda { font-size: 12.5px; color: var(--texto-suave); margin-top: 5px; }

/* Opciones seleccionables tipo píldora (radios/checkboxes con mejor UX) */
.segmento-opciones { display: flex; gap: 8px; flex-wrap: wrap; }
.segmento-opcion {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 9px 14px; border: 1px solid var(--gris-200); border-radius: 999px;
    cursor: pointer; font-size: 13px; font-weight: 500; background: var(--superficie);
    transition: border-color var(--transicion), background var(--transicion), color var(--transicion);
}
.segmento-opcion:hover { border-color: var(--gris-300); }
.segmento-opcion:has(input:checked) { border-color: var(--verde-500); background: var(--verde-50); color: var(--verde-700); }

.alerta { padding: 12px 16px; border-radius: var(--radio-sm); margin-bottom: 16px; font-weight: 500; font-size: 13.5px; }
.alerta-error { background: var(--rojo-50); color: #b91c1c; border: 1px solid #fecaca; }
.alerta-ok { background: var(--verde-50); color: var(--verde-700); border: 1px solid var(--verde-200); }
.alerta-aviso { background: var(--ambar-50); color: #92400e; border: 1px solid #fde68a; }

.badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 11px; border-radius: 999px;
    font-size: 11.5px; font-weight: 600; letter-spacing: .01em;
    border: 1px solid transparent;
}
.badge-verde { background: var(--verde-50); color: var(--verde-700); border-color: var(--verde-200); }
.badge-gris { background: var(--gris-100); color: var(--gris-600); border-color: var(--gris-200); }
.badge-ambar { background: var(--ambar-50); color: #92400e; border-color: #fde68a; }
.badge-rojo { background: var(--rojo-50); color: #b91c1c; border-color: #fecaca; }

/* ---------- Onboarding: conectar WhatsApp ---------- */
.conectar-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; max-width: 880px; margin: 0 auto; }
.qr-marco {
    display: flex; align-items: center; justify-content: center;
    background: var(--superficie);
    border: 2px dashed var(--gris-200);
    border-radius: 18px;
    min-height: 330px;
    box-shadow: var(--sombra-xs);
}
.qr-marco img { width: 260px; height: 260px; border-radius: 10px; }
.qr-estado { text-align: center; color: var(--texto-suave); padding: 24px; }
.spinner {
    width: 38px; height: 38px; margin: 0 auto 14px;
    border: 3px solid var(--gris-200);
    border-top-color: var(--verde-500);
    border-radius: 50%;
    animation: girar .8s linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }
.pasos-lista { display: flex; flex-direction: column; gap: 15px; }
.paso { display: flex; gap: 13px; align-items: flex-start; }
.paso-num {
    width: 27px; height: 27px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--verde-100); color: var(--verde-700);
    border-radius: 50%; font-weight: 700; font-size: 13px;
}

/* ---------- Inbox ---------- */
.inbox-grid {
    display: grid;
    grid-template-columns: 350px 1fr auto; /* 3ª col colapsa a 0 cuando la ficha está oculta */
    height: calc(100vh - 62px);
    background: var(--superficie);
    animation: none;
}
.conv-lista { border-right: 1px solid var(--borde); overflow-y: auto; background: var(--superficie); }

/* Ficha del contacto (3ª columna del inbox) */
.ficha-panel {
    width: 320px;
    border-left: 1px solid var(--borde);
    background: var(--superficie);
    overflow-y: auto;
    padding: 20px 18px;
}
.ficha-cab { padding-bottom: 18px; border-bottom: 1px solid var(--gris-100); margin-bottom: 16px; }
.ficha-seccion { margin-bottom: 20px; }
.ficha-titulo {
    display: flex; align-items: center; justify-content: space-between;
    font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
    color: var(--texto-suave); margin-bottom: 10px;
}
.ficha-mas {
    width: 24px; height: 24px; border-radius: 7px;
    border: 1px solid var(--gris-200); background: var(--superficie);
    color: var(--verde-600); font-size: 16px; font-weight: 700; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    transition: all var(--transicion);
}
.ficha-mas:hover { background: var(--verde-50); border-color: var(--verde-200); }
.ficha-item {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 10px 12px; margin-bottom: 8px;
    background: var(--gris-50); border: 1px solid var(--borde);
    border-radius: 10px; text-decoration: none !important;
    transition: border-color var(--transicion);
}
.ficha-item:hover { border-color: var(--gris-300); }
.ficha-item-titulo { font-weight: 600; color: var(--gris-900); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ficha-item .tarjeta-valor { flex-shrink: 0; font-size: 11.5px; }
.conv-item {
    display: flex; gap: 12px; align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid var(--gris-100);
    cursor: pointer;
    transition: background var(--transicion);
}
.conv-item:hover { background: var(--gris-50); }
.conv-item.activo { background: var(--verde-50); box-shadow: inset 3px 0 0 var(--verde-500); }
.conv-avatar {
    width: 44px; height: 44px; flex-shrink: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--verde-100), var(--verde-200));
    color: var(--verde-700);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 16px;
}
.conv-datos { min-width: 0; flex: 1; }
.conv-nombre { font-weight: 600; color: var(--gris-900); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-preview { font-size: 12.5px; color: var(--texto-suave); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.conv-meta { text-align: right; flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.conv-hora { font-size: 11px; color: var(--texto-suave); }
.conv-noleidos {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 19px; height: 19px; padding: 0 6px;
    background: var(--verde-500); color: #fff;
    border-radius: 999px; font-size: 11px; font-weight: 700;
    box-shadow: var(--sombra-verde);
}

.chat-panel {
    display: flex; flex-direction: column; min-width: 0;
    position: relative;
    background:
        radial-gradient(circle at 20% 20%, rgba(34, 197, 94, .025) 0, transparent 50%),
        var(--gris-50);
}
.plantillas-pop {
    position: absolute; left: 18px; right: 18px; bottom: 78px; z-index: 20;
    max-height: 300px; overflow-y: auto;
    background: #fff; border: 1px solid var(--borde); border-radius: 12px;
    box-shadow: 0 12px 34px rgba(15, 23, 42, .16); padding: 6px;
}
.plantilla-item {
    display: block; width: 100%; text-align: left; cursor: pointer;
    padding: 9px 12px; border: none; background: transparent; border-radius: 8px;
    font-size: 13.5px; transition: background var(--transicion);
}
.plantilla-item:hover { background: var(--gris-100); }
.plantilla-cuerpo { font-size: 12px; color: var(--texto-suave); margin-top: 3px; white-space: pre-wrap; }
.plantilla-vacia { padding: 14px; font-size: 13px; color: var(--texto-suave); text-align: center; }
.chat-cabecera {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 22px;
    background: rgba(255, 255, 255, .9);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--borde);
}
.chat-mensajes { flex: 1; overflow-y: auto; padding: 22px; display: flex; flex-direction: column; gap: 6px; }
.burbuja {
    max-width: 62%;
    padding: 9px 14px;
    border-radius: 16px;
    box-shadow: var(--sombra-xs);
    word-wrap: break-word;
    white-space: pre-wrap;
    font-size: 13.5px;
    animation: aparecer .2s ease both;
}
.burbuja-in { align-self: flex-start; background: var(--superficie); border: 1px solid var(--gris-100); border-bottom-left-radius: 5px; }
.burbuja-out {
    align-self: flex-end;
    background: linear-gradient(180deg, #d9fbe5, var(--verde-100));
    border: 1px solid var(--verde-200);
    border-bottom-right-radius: 5px;
}
.burbuja .hora { display: block; font-size: 10px; color: var(--texto-suave); text-align: right; margin-top: 3px; }
.burbuja-media { max-width: 240px; max-height: 280px; border-radius: 10px; display: block; }
.msg-sistema { align-self: center; margin: 4px 0; max-width: 78%; text-align: center; }
.msg-sistema span {
    display: inline-block; padding: 4px 12px; border-radius: 999px;
    background: var(--gris-100);
    background: color-mix(in srgb, var(--gris-100) 70%, #fff);
    border: 1px solid var(--borde); color: var(--gris-500);
    font-size: 11.5px; font-weight: 500;
}
.burbuja-doc { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--verde-700); text-decoration: none; }
.burbuja-doc:hover { text-decoration: underline; }
.chat-envio {
    display: flex; gap: 10px; align-items: flex-end;
    padding: 14px 22px;
    background: var(--superficie);
    border-top: 1px solid var(--borde);
}
.chat-envio textarea {
    flex: 1; resize: none;
    padding: 11px 16px;
    border: 1px solid var(--gris-200);
    border-radius: 22px;
    max-height: 120px;
    outline: none;
    background: var(--gris-50);
    transition: border-color var(--transicion), box-shadow var(--transicion), background var(--transicion);
}
.chat-envio textarea:focus { border-color: var(--verde-500); background: #fff; box-shadow: var(--anillo); }
.chat-adjuntar {
    display: flex; align-items: center; justify-content: center;
    width: 42px; height: 42px; flex: 0 0 auto;
    border-radius: 50%; cursor: pointer; font-size: 19px;
    background: var(--gris-50); border: 1px solid var(--gris-200);
    transition: background var(--transicion), border-color var(--transicion);
}
.chat-adjuntar:hover { background: var(--gris-100); border-color: var(--verde-500); }
.chat-adjuntar.cargando { opacity: .5; pointer-events: none; }
.bot-horario-grid { display: flex; flex-direction: column; gap: 8px; }
.bot-dia { display: flex; align-items: center; gap: 10px; }
.bot-dia-check { flex: 0 0 90px; display: flex; align-items: center; gap: 6px; font-size: 13.5px; cursor: pointer; }
.bot-dia input[type="time"] { padding: 6px 8px; border: 1px solid var(--gris-200); border-radius: 8px; }
.bot-dia input[type="time"]:disabled { opacity: .45; }
.bot-dia span { color: var(--texto-suave); font-size: 12.5px; }

.vacio { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; color: var(--texto-suave); gap: 8px; padding: 40px; text-align: center; }
.vacio .icono-grande { font-size: 46px; opacity: .35; }

/* ---------- Medidores (sidebar) ---------- */
.medidor { margin-bottom: 13px; }
.medidor-etiqueta { display: flex; justify-content: space-between; font-size: 11.5px; margin-bottom: 5px; color: var(--gris-400); font-weight: 500; }
.medidor-barra { height: 5px; background: rgba(255, 255, 255, .08); border-radius: 999px; overflow: hidden; }
.medidor-progreso {
    height: 100%;
    background: linear-gradient(90deg, var(--verde-600), var(--verde-400));
    border-radius: 999px;
    transition: width .4s ease;
}
.medidor-progreso.alto { background: linear-gradient(90deg, #d97706, var(--ambar-500)); }
.medidor-progreso.tope { background: linear-gradient(90deg, #dc2626, var(--rojo-500)); }

/* ---------- CRM: barra de filtros ---------- */
.crm-filtros {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    margin-bottom: 18px;
}
.crm-buscador {
    display: flex; align-items: center; gap: 8px;
    flex: 1 1 260px; min-width: 220px;
    padding: 0 14px; height: 40px;
    background: var(--superficie);
    border: 1px solid var(--gris-200); border-radius: 999px;
    box-shadow: var(--sombra-xs);
    transition: border-color var(--transicion), box-shadow var(--transicion);
}
.crm-buscador:focus-within { border-color: var(--verde-500); box-shadow: var(--anillo); }
.crm-buscador span { color: var(--gris-400); font-size: 14px; }
.crm-buscador input { flex: 1; border: none; outline: none; background: transparent; font-size: 13.5px; color: var(--texto); }
.crm-chips { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.crm-chip {
    display: inline-flex; align-items: center; gap: 5px;
    height: 34px; padding: 0 14px;
    border: 1px solid var(--gris-200); border-radius: 999px;
    background: var(--superficie); color: var(--gris-500);
    font-size: 12.5px; font-weight: 600; cursor: pointer;
    transition: color var(--transicion), background var(--transicion), border-color var(--transicion);
}
.crm-chip:hover { color: var(--gris-700); border-color: var(--gris-300); }
.crm-chip.activo { background: var(--verde-500); border-color: var(--verde-500); color: #fff; box-shadow: var(--sombra-verde); }
.crm-select {
    height: 40px; padding: 0 32px 0 14px;
    border: 1px solid var(--gris-200); border-radius: 999px;
    background: var(--superficie) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
    -webkit-appearance: none; appearance: none;
    font-size: 13px; font-weight: 500; color: var(--gris-600); cursor: pointer;
    box-shadow: var(--sombra-xs);
}
.crm-select:hover { border-color: var(--gris-300); }
.crm-select:focus { outline: none; border-color: var(--verde-500); box-shadow: var(--anillo); }
.kanban-col-alerta {
    display: inline-flex; align-items: center; gap: 3px;
    font-size: 10.5px; font-weight: 700; letter-spacing: 0;
    color: #b91c1c; background: var(--rojo-50);
    border: 1px solid #fecaca; border-radius: 999px; padding: 2px 7px;
    text-transform: none;
}

/* ---------- CRM Kanban ---------- */
.kanban {
    display: flex; gap: 18px;
    overflow-x: auto;
    padding-bottom: 14px;
    align-items: flex-start;
    min-height: calc(100vh - 228px);
}
.kanban-col {
    width: 296px; flex-shrink: 0;
    background: rgba(226, 232, 240, .45);
    border: 1px solid var(--borde);
    border-radius: var(--radio);
    display: flex; flex-direction: column;
    max-height: calc(100vh - 228px);
    backdrop-filter: blur(2px);
}
.kanban-col-cabecera {
    display: flex; align-items: center; justify-content: space-between;
    padding: 13px 15px 9px;
    font-weight: 700; font-size: 12.5px;
    color: var(--gris-700);
    text-transform: uppercase; letter-spacing: .04em;
}
.kanban-col-cabecera .punto-color { width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; box-shadow: 0 0 6px currentColor; }
.kanban-col-cuenta {
    font-weight: 700; font-size: 11px;
    color: var(--gris-500);
    background: var(--superficie);
    border: 1px solid var(--borde);
    padding: 1px 9px; border-radius: 999px;
}
.kanban-cartas { flex: 1; overflow-y: auto; padding: 4px 11px 11px; display: flex; flex-direction: column; gap: 9px; min-height: 60px; }
.kanban-col.arrastrando-sobre { border-color: var(--verde-500); background: var(--verde-50); }
.tarjeta {
    background: var(--superficie);
    border: 1px solid var(--borde);
    border-radius: 12px;
    padding: 13px 14px;
    box-shadow: var(--sombra-xs);
    cursor: grab;
    transition: box-shadow var(--transicion), transform var(--transicion), border-color var(--transicion);
    animation: aparecer .2s ease both;
}
.tarjeta:hover { box-shadow: var(--sombra-md); transform: translateY(-2px); border-color: var(--gris-300); }
.tarjeta.arrastrando { opacity: .4; transform: rotate(2deg) scale(.98); cursor: grabbing; }
.tarjeta-nombre { font-weight: 600; color: var(--gris-900); margin-bottom: 7px; font-size: 13.5px; }
.tarjeta-meta { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--texto-suave); }
.tarjeta-valor {
    font-weight: 700; color: var(--verde-700);
    background: var(--verde-50);
    padding: 1px 8px; border-radius: 6px;
}
.btn-agregar-tarjeta {
    margin: 0 11px 11px;
    padding: 9px;
    border: 1px dashed var(--gris-300);
    border-radius: var(--radio-sm);
    background: transparent;
    color: var(--texto-suave);
    font-weight: 600; font-size: 12.5px;
    transition: all var(--transicion);
}
.btn-agregar-tarjeta:hover { border-color: var(--verde-500); color: var(--verde-600); background: var(--verde-50); }

/* ---------- Kanban v2: extras ---------- */
.tarjeta-avatar {
    width: 30px; height: 30px; flex-shrink: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--verde-100), var(--verde-200));
    color: var(--verde-700);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 12.5px;
}
.punto-prioridad { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.chip {
    display: inline-flex; align-items: center;
    padding: 1px 8px;
    background: var(--gris-100);
    border: 1px solid var(--gris-200);
    border-radius: 999px;
    font-size: 10.5px; font-weight: 600;
    color: var(--gris-600);
    max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chip-verde { background: var(--verde-50); border-color: var(--verde-200); color: var(--verde-700); }
.btn-menu-col {
    border: none; background: transparent;
    color: var(--gris-400);
    font-size: 15px; font-weight: 700;
    padding: 0 4px; border-radius: 6px;
    line-height: 1;
}
.btn-menu-col:hover { background: var(--gris-200); color: var(--gris-700); }
.menu-flotante {
    position: fixed; z-index: 200;
    background: var(--superficie);
    border: 1px solid var(--borde);
    border-radius: 12px;
    box-shadow: var(--sombra-md);
    padding: 6px;
    min-width: 200px;
    animation: aparecer .12s ease both;
}
.menu-flotante button {
    display: block; width: 100%;
    text-align: left;
    padding: 9px 12px;
    border: none; background: transparent;
    border-radius: 8px;
    font-weight: 500; font-size: 13px;
}
.menu-flotante button:hover { background: var(--gris-50); }
.selector-funnel {
    padding: 9px 36px 9px 14px;
    border: 1px solid var(--gris-200);
    border-radius: var(--radio-sm);
    background: var(--superficie);
    font-weight: 700; font-size: 14px;
    color: var(--gris-900);
    box-shadow: var(--sombra-xs);
    outline: none;
    cursor: pointer;
}
.selector-funnel:focus { border-color: var(--verde-500); box-shadow: var(--anillo); }

/* ---------- Inbox v2: acciones del chat ---------- */
.chat-acciones { display: flex; gap: 6px; margin-left: auto; }
.btn-chat-accion {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px;
    border: 1px solid var(--gris-200);
    background: var(--superficie);
    border-radius: 10px;
    font-size: 15px;
    transition: all var(--transicion);
}
.btn-chat-accion:hover { background: var(--gris-50); border-color: var(--gris-300); }
.btn-chat-accion.activo { background: var(--verde-50); border-color: var(--verde-200); }
.conv-chips { display: flex; gap: 4px; margin-top: 3px; flex-wrap: wrap; }

/* ---------- Modal ---------- */
.modal-fondo {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(13, 21, 38, .5);
    backdrop-filter: blur(3px);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    animation: aparecer .15s ease both;
}
.modal {
    background: var(--superficie);
    border: 1px solid var(--borde);
    border-radius: 20px;
    box-shadow: var(--sombra-md);
    width: 100%; max-width: 530px;
    max-height: 90vh; overflow-y: auto;
    padding: 30px;
    animation: aparecer .22s ease both;
}
.modal h3 { margin-bottom: 20px; font-size: 17px; }
.modal-acciones { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }
.fila-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ---------- Tabla ---------- */
.tabla {
    width: 100%;
    border-collapse: separate; border-spacing: 0;
    background: var(--superficie);
    border: 1px solid var(--borde);
    border-radius: var(--radio);
    overflow: hidden;
    box-shadow: var(--sombra-sm);
}
.tabla th {
    text-align: left; padding: 13px 20px;
    background: var(--gris-50);
    background: color-mix(in srgb, var(--gris-50) 65%, #fff);
    border-bottom: 1px solid var(--borde);
    font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
    color: var(--gris-400); font-weight: 700;
}
.tabla td { padding: 15px 20px; border-bottom: 1px solid var(--gris-100); vertical-align: middle; }
.tabla tr:last-child td { border-bottom: none; }
.tabla tbody tr { transition: background var(--transicion); }
.tabla tbody tr:hover { background: var(--gris-50); background: color-mix(in srgb, var(--gris-50) 70%, #fff); }
.tabla .btn { padding: 6px 13px; font-size: 12.5px; }

/* ---------- Tabs (segmented control) ---------- */
.tabs {
    display: inline-flex; gap: 3px; flex-wrap: wrap;
    background: var(--gris-100);
    border: 1px solid var(--borde);
    padding: 4px;
    border-radius: 14px;
    margin-bottom: 26px;
}
.tab {
    padding: 8px 18px;
    border: none; background: transparent;
    font-weight: 600; font-size: 13px;
    color: var(--texto-suave);
    border-radius: 10px;
    cursor: pointer;
    transition: color var(--transicion), background var(--transicion), box-shadow var(--transicion);
}
.tab:hover { color: var(--gris-800); background: rgba(255, 255, 255, .55); }
.tab.activo {
    color: var(--gris-900);
    background: var(--superficie);
    box-shadow: var(--sombra-sm);
}
.tab.activo:hover { background: var(--superficie); }
.tab-panel { display: none; animation: aparecer .2s ease both; }
.tab-panel.activo { display: block; }

/* ---------- Switch (toggle) ---------- */
.switch { position: relative; display: inline-block; width: 44px; height: 25px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .pista {
    position: absolute; inset: 0; cursor: pointer;
    background: var(--gris-300); border-radius: 999px;
    transition: background .2s;
}
.switch .pista::before {
    content: ''; position: absolute;
    width: 19px; height: 19px; left: 3px; top: 3px;
    background: #fff; border-radius: 50%;
    transition: transform .2s cubic-bezier(.34, 1.56, .64, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
}
.switch input:checked + .pista { background: var(--verde-500); }
.switch input:checked + .pista::before { transform: translateX(19px); }
.switch input:focus-visible + .pista { box-shadow: var(--anillo); }

/* ---------- Encabezado de página + buscador ---------- */
.pagina-cabecera { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; gap: 12px; flex-wrap: wrap; }
.buscador { position: relative; }
.buscador input {
    padding: 10px 16px 10px 38px;
    border: 1px solid var(--gris-200);
    border-radius: 999px;
    width: 280px;
    outline: none;
    background: var(--superficie);
    box-shadow: var(--sombra-xs);
    transition: border-color var(--transicion), box-shadow var(--transicion), width .25s ease;
}
.buscador input:focus { border-color: var(--verde-500); box-shadow: var(--anillo); width: 320px; }
.buscador::before { content: '🔍'; position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-size: 12px; opacity: .45; pointer-events: none; }

/* ---------- Informes / cuadro de mando ---------- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}
.kpi-card {
    background: var(--superficie);
    border: 1px solid var(--borde);
    border-radius: var(--radio);
    box-shadow: var(--sombra-xs);
    padding: 18px 20px;
    animation: aparecer .25s ease both;
}
.kpi-icono { font-size: 22px; margin-bottom: 8px; }
.kpi-valor { font-size: 26px; font-weight: 800; color: var(--gris-900); letter-spacing: -.02em; line-height: 1.1; }
.kpi-label { font-size: 12.5px; color: var(--texto-suave); font-weight: 600; margin-top: 4px; }
.kpi-sub { font-size: 11.5px; color: var(--verde-600); font-weight: 600; margin-top: 2px; }

.grafico-svg { display: block; }
.grafico-svg .eje-x { font-size: 10px; fill: var(--texto-suave); text-anchor: middle; }
.grafico-svg rect { transition: opacity .15s; }
.grafico-svg rect:hover { opacity: .8; }
.leyenda { display: inline-flex; align-items: center; gap: 6px; color: var(--texto-suave); font-weight: 600; }
.leyenda-punto { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.embudo-fila { margin-bottom: 16px; }
.embudo-barra { height: 8px; background: var(--gris-100); border-radius: 999px; overflow: hidden; }
.embudo-barra > div { height: 100%; border-radius: 999px; transition: width .4s ease; }

/* Editor de horarios (colas) */
.hr-dia { padding: 10px 0; border-bottom: 1px solid var(--gris-100); }
.hr-dia:last-child { border-bottom: none; }
.hr-franjas:empty::before { content: 'Sin franjas (disponible todo el día)'; color: var(--texto-suave); font-size: 12px; }

/* Calendario mensual */
.cal-grid-cabecera { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; margin-bottom: 8px; }
.cal-grid-cabecera > div { text-align: center; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--texto-suave); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.cal-celda {
    background: var(--superficie);
    border: 1px solid var(--borde);
    border-radius: 10px;
    min-height: 96px;
    padding: 6px 7px;
    cursor: pointer;
    transition: border-color var(--transicion), box-shadow var(--transicion);
    overflow: hidden;
}
.cal-celda:hover { border-color: var(--verde-300); box-shadow: var(--sombra-xs); }
.cal-celda.otro-mes { background: var(--gris-50); }
.cal-celda.otro-mes .cal-num { color: var(--gris-300); }
.cal-celda.hoy { border-color: var(--verde-500); box-shadow: var(--anillo); }
.cal-num { font-size: 12.5px; font-weight: 700; color: var(--gris-700); margin-bottom: 4px; }
.cal-evento {
    background: var(--verde-100); color: var(--verde-700);
    border-radius: 6px; padding: 2px 6px; margin-bottom: 3px;
    font-size: 11px; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-evento:hover { background: var(--verde-200); }
@media (max-width: 700px) {
    .cal-celda { min-height: 60px; }
    .cal-evento { font-size: 10px; padding: 1px 4px; }
}

/* ---------- Utilidades ---------- */
.texto-suave { color: var(--texto-suave); }
.texto-centro { text-align: center; }
.mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; } .gap-4 { gap: 16px; }
.oculto { display: none !important; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    /* Debajo de este ancho la ficha del contacto no cabe cómoda: se oculta */
    .ficha-panel { display: none !important; }
    #btn-ficha { display: none; }
}
@media (max-width: 900px) {
    .menu-toggle { display: inline-flex; align-items: center; }
    /* Sidebar como panel deslizante sobre el contenido */
    .sidebar {
        position: fixed; top: 0; left: 0; bottom: 0; z-index: 60;
        transform: translateX(-100%);
        transition: transform .22s cubic-bezier(.4, 0, .2, 1);
        box-shadow: 4px 0 24px rgba(15, 23, 42, .18);
    }
    .sidebar.abierto { transform: none; }
    .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 55;
        background: rgba(13, 21, 38, .5); opacity: 0; pointer-events: none; transition: opacity .2s; }
    .sidebar-backdrop.visible { opacity: 1; pointer-events: auto; }
    .main { padding: 20px 16px; }
    .conectar-grid { grid-template-columns: 1fr; }
    .inbox-grid { grid-template-columns: 1fr; }
    .inbox-grid.viendo-chat .conv-lista { display: none; }
    .inbox-grid:not(.viendo-chat) .chat-panel { display: none; }
    .burbuja { max-width: 85%; }
    .buscador input, .buscador input:focus { width: 100%; }
    .fila-2 { grid-template-columns: 1fr; }
    .tabs { width: 100%; overflow-x: auto; }
}
