  :root{
    --brand:#1E3A8A;
    --brand-dark:#172554;
    --brand-light:#EFF6FF;
    --brand-accent:#3B82F6;
    --accent:#F59E0B;
    --bg:#F8FAFC;
  }
  html{ background:#FFFFFF; }
  body{ background:var(--bg); font-family: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif; color:#0F172A;}
  /* Títulos de la app en Stack Sans (fallback a Poppins si el navegador no la sirve) */
  h1, h2, h3, h4, h5, h6{ font-family: 'Stack Sans', 'Poppins', sans-serif; }
  /* Garantiza que loginScreen quede totalmente oculto tras login (sin franja azul residual) */
  #loginScreen.hidden{ display:none !important; }

  /* ============================================================
     CAJAS DE TEXTO — tirador de tamaño (abajo a la derecha)
     ============================================================
     Todas las <textarea> se pueden agrandar en vertical arrastrando el
     tirador de la esquina inferior derecha, para ver/escribir más contenido.
     La especificidad (0,1,1) de este selector supera a la utilidad
     `.resize-none` de Tailwind (0,1,0), así que no hace falta !important.
     Las deshabilitadas se dejan fijas. */
  textarea:not([disabled]){ resize: vertical; }

  /* ============================================================
     MODO CLIENTE — Layout limpio para usuarios con role='cliente'
     ============================================================
     Se aplica añadiendo la clase `client-mode` al <body> al hacer login.
     Oculta el chrome de admin (sidebar CRM, navegación principal, botones
     de notificaciones / config / status) y deja la "Vista cliente" como
     pantalla completa con solo el logo + nombre + logout en la cabecera. */
  body.client-mode #topNav,
  body.client-mode #crmSidebar,
  body.client-mode #crmSidebarBackdrop,
  body.client-mode #configBtn,
  body.client-mode #statusBtn,
  body.client-mode #chatFab,
  body.client-mode header.bg-white > div:first-child > a + nav,
  body.client-mode .adminOnly,
  body.client-mode .managerOnly{ display:none !important; }

  /* ============================================================
     MODO REDACTOR — Usuarios externos (role='redactor'): solo ven el
     panel de Contenido/Redacción. Oculta sidebar, nav, cabecera de
     Proyectos, notificaciones y búsqueda. Clase `redactor-mode` en <body>.
     ============================================================ */
  body.redactor-mode #topNav,
  body.redactor-mode #crmSidebar,
  body.redactor-mode #crmSidebarBackdrop,
  body.redactor-mode #configBtn,
  body.redactor-mode #statusBtn,
  body.redactor-mode #chatFab,
  body.redactor-mode header.bg-white > div:first-child > a + nav,
  body.redactor-mode .adminOnly,
  body.redactor-mode .managerOnly,
  body.redactor-mode #pHeader,
  body.redactor-mode header.bg-white .relative > button[onclick*="toggleNotifs"],
  body.redactor-mode #notifDropdown,
  body.redactor-mode #proyectosQuickBtn,
  body.redactor-mode #misTareasQuickBtn,
  body.redactor-mode #ficharQuickBtn,
  body.redactor-mode header.bg-white button[onclick*="openGlobalSearch"]{ display:none !important; }
  /* El redactor ve su nombre pero NO puede entrar a "Mi perfil" (solo su contenido). */
  body.redactor-mode #userMenuBtn{ pointer-events:none !important; cursor:default !important; }
  body.redactor-mode #userMenuBtn:hover{ background:transparent !important; }

  /* ============================================================
     MODO COMERCIAL — Comerciales sin rango admin/manager no pueden
     crear leads, importar, configurar lead scoring, gestionar
     pipelines ni acceder a herramientas administrativas.
     Se aplica con la clase `comercial-mode` en <body>.
     ============================================================ */
  body.comercial-mode .adminManagerOnly{ display:none !important; }

  /* En modo cliente, el botón de notificaciones se oculta (el cliente no
     usa el sistema interno de notificaciones del equipo) */
  body.client-mode header.bg-white .relative > button[onclick*="toggleNotifs"]{ display:none !important; }
  body.client-mode #notifDropdown{ display:none !important; }

  /* Ocultar la barra de búsqueda global a clientes (es para staff) */
  body.client-mode header.bg-white button[onclick*="openGlobalSearch"]{ display:none !important; }

  /* El botón "Fichar" de la cabecera es solo para staff (los clientes no fichan) */
  body.client-mode #ficharQuickBtn{ display:none !important; }

  /* Jornada abierta: el botón pasa de "Fichar" (suave) a "Fichando" (verde sólido + puntito) */
  #ficharQuickBtn.fichando-activo{
    background:#059669 !important; border-color:#059669 !important; color:#fff !important;
  }
  #ficharQuickBtn.fichando-activo:hover{ background:#047857 !important; }
  #ficharQuickBtn.fichando-activo::before{
    content:""; width:7px; height:7px; border-radius:9999px; background:#fff;
    animation:fichandoPulse 1.4s ease-in-out infinite;
  }
  @keyframes fichandoPulse{ 0%,100%{opacity:1;} 50%{opacity:.25;} }

  /* Los botones "Proyectos" y "Mis tareas" de la cabecera son solo para staff */
  body.client-mode #misTareasQuickBtn,
  body.client-mode #proyectosQuickBtn{ display:none !important; }

  /* La vista CRM ocupa todo el ancho cuando no hay sidebar */
  body.client-mode #crmMain{ margin-left:0 !important; }
  body.client-mode #crmContent{ padding:24px !important; max-width:1400px; margin:0 auto; }

  /* El header se queda más compacto: solo logo + nombre + logout */
  body.client-mode header.bg-white{ box-shadow:0 1px 3px rgba(15,23,42,0.06); }
  body.client-mode header.bg-white .text-[10px]{ font-size:10px; }

  /* Esconder toggles internos del sidebar (búsqueda interna, filtros, etc.) */
  body.client-mode #togProximamente,
  body.client-mode .sb-cat-title{ display:none !important; }

  /* ============================================================
     RESPONSIVE MÓVIL — portal cliente
     ============================================================
     El cliente abre el portal mucho desde el móvil. Adaptamos el
     layout para que se vea bien en pantallas pequeñas. */

  /* Tablet / móvil grande (< 768px) */
  @media (max-width: 768px){
    /* Header del cliente: logo más pequeño */
    body.client-mode #clienteVistaHeader .w-20{ width:56px !important; height:56px !important; }
    body.client-mode #clienteVistaHeader .rounded-2xl{ border-radius:12px !important; }
    body.client-mode #clienteVistaHeader .text-xl{ font-size:17px !important; }
    body.client-mode #clienteVistaHeader .text-2xl{ font-size:20px !important; }

    /* Header de la app (top-bar) compactado para clientes */
    body.client-mode header.bg-white{ padding:10px 14px !important; }
    body.client-mode header.bg-white .logo-img{ height:24px !important; }
    body.client-mode #userName{ font-size:11px; max-width:120px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
    body.client-mode #userRole{ font-size:9px; max-width:120px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

    /* Contenido CRM: padding lateral menor para aprovechar todo el ancho */
    body.client-mode #crmContent,
    body.client-mode .crm-view { padding:12px !important; }

    /* Embudo: labels más estrechos en móvil */
    body.client-mode #clienteVistaBody .w-40{ width:96px !important; min-width:96px; font-size:10px; }

    /* Cards de llamadas: padding interno más compacto */
    body.client-mode #clVCallsCards > div{ padding:12px !important; }
    body.client-mode #clVCallsCards audio{ height:32px !important; }

    /* Charts: alturas menores para que entren bien */
    body.client-mode #clVChartByDay { max-height:200px; }
    body.client-mode #clVChartByDispo { max-height:220px; }
    body.client-mode #clVChartByUser { max-height:240px; }

    /* Modal "Establece tu contraseña" y "Ficha del lead": ocupar todo el alto */
    body.client-mode #_setClientePasswordModal > div,
    body.client-mode #_clVLeadModal > div{
      max-height:96vh !important;
      width:100% !important;
      margin:8px;
    }

    /* Filtros: stack vertical de cada control (no se quedan medio-cortados) */
    body.client-mode #clienteVistaFilters .flex.items-end > div{
      width:100% !important;
    }
    body.client-mode #clienteVistaFilters select,
    body.client-mode #clienteVistaFilters input[type="date"]{
      width:100% !important;
    }

    /* Tabla de reuniones del periodo en columna estrecha → scroll horizontal */
    body.client-mode .app-table { font-size:11px; }
  }

  /* Móvil pequeño (< 480px) */
  @media (max-width: 480px){
    /* KPIs: 2 columnas en vez de 4 */
    body.client-mode .grid.grid-cols-2.md\:grid-cols-4 { grid-template-columns:repeat(2, 1fr) !important; }

    /* Logo y nombre cliente apilados (no en línea) */
    body.client-mode #clienteVistaHeader .flex.items-center.justify-between{ flex-direction:column; align-items:flex-start !important; }
    body.client-mode #clienteVistaHeader .text-right{ text-align:left !important; margin-top:8px; }

    /* Botón "Exportar Excel" se contrae */
    body.client-mode #clienteVistaFilters button{ font-size:11px !important; padding:6px 10px !important; }
  }

  /* ============================================================
     PRINT — Informe en PDF
     ============================================================
     Cuando se pulsa "Descargar PDF" añadimos clase `printing` al body
     y lanzamos window.print(). Estas reglas limpian la página para
     que el PDF salga sin chrome (header app, sidebar, filtros, botones)
     y solo con el informe legible. */
  .print-only{ display:none !important; }

  @media print{
    /* Forzar colores de fondo (necesario en algunos navegadores) */
    *{ -webkit-print-color-adjust:exact !important; print-color-adjust:exact !important; color-adjust:exact !important; }

    /* Tamaño de página y márgenes razonables */
    @page { size: A4; margin: 14mm 12mm; }
    html, body{ background:#FFFFFF !important; }

    /* Ocultar todo el chrome de la app */
    header.bg-white, #crmSidebar, #crmSidebarBackdrop, #topNav,
    #notifDropdown, #configBtn, #chatFab, #statusBtn,
    #clienteVistaFilters, /* la barra de filtros no se imprime */
    .modal-backdrop, /* modales abiertos */
    audio /* reproductores de audio no van al papel */ {
      display:none !important;
    }

    /* Solo se muestran las secciones del dashboard del cliente */
    .crm-view{ padding:0 !important; }
    #crmClientesCrm{ display:block !important; }

    /* Header de impresión visible solo al imprimir */
    .print-only{ display:block !important; }

    /* Cards: sin sombra (no se imprime bien) y con borde gris suave */
    .card{
      box-shadow:none !important;
      border:1px solid #E2E8F0 !important;
      page-break-inside:avoid;
      break-inside:avoid;
    }

    /* Evitar que las cards se partan a mitad de página */
    #clVCallsCards > div{ page-break-inside:avoid; break-inside:avoid; }
    canvas{ max-width:100% !important; }

    /* Esconder los botones de acción dentro del dashboard */
    #clienteVistaBody button{ display:none !important; }

    /* La cabecera de la Vista cliente (con logo + nombre) se reemplaza
       por nuestro header de impresión bonito, así que la ocultamos */
    #clienteVistaHeader{ display:none !important; }

    /* Embudo: barras gruesas que se vean bien en papel */
    #clienteVistaBody .h-7{ height:24px !important; }

    /* Anotaciones del SEO: ocultar textarea editable y mostrar texto formateado */
    .iseo-annotation .iseo-annot-input { display:none !important; }
    .iseo-annotation .iseo-annot-print { display:block !important; }
    /* Controles de edición del informe (botón "Editar valores", chips "✎ manual"):
       nunca en el PDF que ve el cliente */
    .iseo-edit-ui { display:none !important; }
    /* Tarjetas de conversión sin evento clave declarado: en pantalla el SEO lee
       qué configurar en GA4; en el PDF del cliente, solo el texto neutro. */
    .iseo-conv-neutral { display:inline !important; }
    .iseo-annotation .card {
      border:1px solid #CBD5E1 !important;
      background:#F8FAFC !important;
      page-break-inside:avoid;
      break-inside:avoid;
    }
  }

  /* Por defecto (pantalla): ocultar la versión imprimible y mostrar el textarea */
  .iseo-annotation .iseo-annot-print { display:none; }
  .iseo-annotation .iseo-annot-input { display:block; }
  /* Visor completo interno del informe: anotaciones en modo lectura
     (mostrar texto formateado, ocultar el textarea editable) */
  .iseo-readonly .iseo-annotation .iseo-annot-input { display:none !important; }
  .iseo-readonly .iseo-annotation .iseo-annot-print { display:block !important; }
  .iseo-readonly .iseo-edit-ui { display:none !important; }
  /* Al cargar el documento, ocultamos por defecto el login Y el app hasta que sepamos si hay sesión.
     Esto evita el "flash" donde la pantalla de login se ve un segundo y luego desaparece. */
  body.auth-checking #loginScreen,
  body.auth-checking #app { display:none !important; }
  body.auth-checking::before {
    content: ""; position: fixed; inset: 0;
    background: #DBEAFE url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='44' height='44' viewBox='0 0 44 44'><circle cx='22' cy='22' r='18' fill='none' stroke='%231E3A8A' stroke-width='4' stroke-linecap='round' stroke-dasharray='28 90' transform='rotate(-90 22 22)'><animateTransform attributeName='transform' type='rotate' from='0 22 22' to='360 22 22' dur='1s' repeatCount='indefinite'/></circle></svg>") center center no-repeat;
    z-index: 9999;
  }

  /* Toast para undo */
  .toast{ position:fixed; bottom:24px; left:50%; transform:translateX(-50%); background:#0F172A; color:white;
    padding:12px 20px; border-radius:10px; font-size:13px; font-weight:500; z-index:99999;
    box-shadow:0 10px 30px rgba(0,0,0,0.25); animation: toastIn .3s ease-out;}
  @keyframes toastIn{ from{opacity:0; transform:translate(-50%, 10px);} to{opacity:1; transform:translate(-50%, 0);} }
  .brand-bg{ background:var(--brand); }
  .brand-text{ color:var(--brand); }
  .brand-border{ border-color:var(--brand); }
  .brand-light-bg{ background:var(--brand-light); }
  .accent-bg{ background:var(--brand-accent); }
  .chip{ display:inline-flex; align-items:center; gap:6px; padding:2px 10px; border-radius:999px; font-size:11px; font-weight:600; }
  .card{ background:white; border-radius:14px; box-shadow: 0 1px 2px rgba(15,23,42,0.04), 0 1px 3px rgba(15,23,42,0.06); }

  /* ============================================================
     DESPLEGABLES BONITOS para la barra de filtros del CRM
     - Sin flecha nativa del navegador (varía por SO).
     - Flecha SVG custom inline alineada a la derecha.
     - Hover suave + focus ring corporativo.
     ============================================================ */
  .filter-select{
    appearance:none;
    -webkit-appearance:none;
    -moz-appearance:none;
    background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'></polyline></svg>");
    background-repeat:no-repeat;
    background-position:right 10px center;
    padding-right:32px !important;
    cursor:pointer;
    transition:border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
  }
  .filter-select:hover{ border-color:#94A3B8; background-color:#F8FAFC; }
  .filter-select:focus{ outline:none; border-color:#1E3A8A; box-shadow:0 0 0 3px rgba(30,58,138,0.12); }
  .filter-select option{ padding:8px 12px; font-size:13px; }
  /* Input search del filtro: mismo lenguaje visual */
  .filter-input{ transition:border-color .15s ease, box-shadow .15s ease; }
  .filter-input:hover{ border-color:#94A3B8; }
  .filter-input:focus{ outline:none; border-color:#1E3A8A; box-shadow:0 0 0 3px rgba(30,58,138,0.12); }

  .kanban-col{ background:#F1F5F9; border-radius:12px; min-height:300px; width:290px; flex-shrink:0; display:flex; flex-direction:column; height:100%; max-height:100%; }
  .kanban-col .col-drop{ flex:1 1 auto; overflow-y:scroll; overflow-x:hidden; scrollbar-width: thin; scrollbar-color: #93C5FD #EFF6FF; }
  .kanban-col .col-drop::-webkit-scrollbar{ width:8px; -webkit-appearance:none; }
  .kanban-col .col-drop::-webkit-scrollbar-track{ background:#EFF6FF; border-radius:6px; }
  .kanban-col .col-drop::-webkit-scrollbar-thumb{ background:#93C5FD; border-radius:6px; min-height:30px; }
  .kanban-col .col-drop::-webkit-scrollbar-thumb:hover{ background:#60A5FA; }
  /* Scrollbar siempre visible para el pipeline */
  #kanbanScrollWrap{ scrollbar-width: thin; scrollbar-color: #93C5FD #EFF6FF; }
  #kanbanScrollWrap::-webkit-scrollbar{ height:8px; -webkit-appearance:none; }
  #kanbanScrollWrap::-webkit-scrollbar-track{ background:#EFF6FF; border-radius:6px; }
  #kanbanScrollWrap::-webkit-scrollbar-thumb{ background:#93C5FD; border-radius:6px; min-width:40px;}
  #kanbanScrollWrap::-webkit-scrollbar-thumb:hover{ background:#60A5FA; }
  #crmPipeline{ max-width:100%; min-width:0; overflow:hidden; }

  /* ===== Date pickers elegantes (botón disparador + popup custom) ===== */
  .cl-datepicker-btn{
    /* Idéntico a los <select> de la barra (px-2 py-1.5 text-xs):
       altura fija 32px, padding, tipografía y line-height pensados para que se
       alineen verticalmente sin holgura. !important para vencer reglas globales
       de buttons que pudieran ensanchar la altura. */
    display: inline-flex !important;
    align-items: center;
    gap: 4px;
    background: #fff !important;
    border: 1px solid #CBD5E1 !important;
    border-radius: 8px !important;
    padding: 0 8px !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    color: #0F172A !important;
    cursor: pointer;
    transition: all 0.15s;
    width: 140px !important;
    height: 32px !important;
    box-sizing: border-box;
    font-family: inherit;
    line-height: 1 !important;
    margin: 0;
  }
  .cl-datepicker-btn .cl-dp-placeholder{
    font-size: 12px;
    color: #94A3B8;
    font-weight: 500;
    white-space: nowrap;
    line-height: 1;
  }
  .cl-datepicker-btn .cl-dp-icon{
    flex-shrink: 0;
    color: #64748B;
    width: 12px;
    height: 12px;
  }
  .cl-datepicker-btn:hover{
    border-color: #94A3B8;
    background: #F8FAFC;
  }
  .cl-datepicker-btn.is-open,
  .cl-datepicker-btn:focus{
    outline: none;
    border-color: #1E3A8A;
    box-shadow: 0 0 0 3px rgba(30,58,138,0.1);
  }
  .cl-datepicker-btn .cl-dp-placeholder{ color:#94A3B8; font-weight:500; }
  .cl-datepicker-btn .cl-dp-icon{ color:#64748B; }

  /* Popup del calendario */
  .cl-calendar{
    position: absolute;
    z-index: 100;
    background: #fff;
    border: 1px solid #E2E8F0;
    border-radius: 14px;
    box-shadow: 0 20px 50px rgba(15,23,42,0.18);
    padding: 14px;
    width: 280px;
    user-select: none;
    animation: cl-cal-in 0.15s ease-out;
  }
  @keyframes cl-cal-in{
    from{ opacity:0; transform:translateY(-4px); }
    to{ opacity:1; transform:translateY(0); }
  }
  .cl-cal-header{
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
  }
  .cl-cal-monthlabel{
    font-weight: 800;
    font-size: 14px;
    color: #0F172A;
    text-transform: capitalize;
    letter-spacing: 0.02em;
  }
  .cl-cal-navbtn{
    width: 28px; height: 28px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    color: #64748B;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
  }
  .cl-cal-navbtn:hover{
    background: #F1F5F9;
    color: #0F172A;
  }
  .cl-cal-weekdays{
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    margin-bottom: 4px;
  }
  .cl-cal-weekdays > div{
    text-align: center;
    font-size: 10px;
    font-weight: 800;
    color: #94A3B8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 4px 0;
  }
  .cl-cal-days{
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
  }
  .cl-cal-day{
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #334155;
    cursor: pointer;
    transition: all 0.12s;
    background: transparent;
    border: none;
    font-family: inherit;
  }
  .cl-cal-day:hover{
    background: #EFF6FF;
    color: #1E3A8A;
  }
  .cl-cal-day.is-other-month{ color: #CBD5E1; }
  .cl-cal-day.is-today{
    color: #1E3A8A;
    font-weight: 800;
    box-shadow: inset 0 0 0 1px #BFDBFE;
  }
  .cl-cal-day.is-selected{
    background: #1E3A8A;
    color: #fff;
    font-weight: 800;
    box-shadow: 0 2px 6px rgba(30,58,138,0.3);
  }
  .cl-cal-day.is-selected:hover{
    background: #1E40AF;
    color: #fff;
  }
  .cl-cal-day.is-disabled{
    color: #E2E8F0;
    cursor: not-allowed;
    pointer-events: none;
  }
  .cl-cal-footer{
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #F1F5F9;
  }
  .cl-cal-footer button{
    background: transparent;
    border: none;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 6px;
    transition: all 0.12s;
    font-family: inherit;
  }
  .cl-cal-footer .cl-cal-clear{ color: #94A3B8; }
  .cl-cal-footer .cl-cal-clear:hover{ background: #F1F5F9; color: #475569; }
  .cl-cal-footer .cl-cal-today{ color: #1E3A8A; }
  .cl-cal-footer .cl-cal-today:hover{ background: #EFF6FF; }

  /* ===== Vista cliente / Informes — responsive ===== */
  @media (max-width: 768px){
    #clienteVistaHeader .card{ padding: 16px !important; }
    #clienteVistaHeader .w-20.h-20{ width: 56px !important; height: 56px !important; }
    #clienteVistaHeader .text-xl{ font-size: 16px !important; }
    #clienteVistaFilters .card{ padding: 12px !important; }
    #clienteVistaFilters .flex.items-end{ gap: 10px !important; }
    #clienteVistaFilters select,
    #clienteVistaFilters input[type="date"]{
      width: 100%;
      min-width: 0;
    }
    #clienteVistaFilters > div > div > div{
      flex: 1 1 calc(50% - 5px);
      min-width: 140px;
    }
    /* KPI cards en 2 columnas en móvil */
    #clienteVistaBody .grid-cols-4{
      grid-template-columns: repeat(2, 1fr) !important;
    }
    /* Charts apilados */
    #clienteVistaBody .grid.grid-cols-2{
      grid-template-columns: 1fr !important;
    }
    /* Funnel labels más pequeños */
    .cl-funnel-label{ font-size: 10px !important; }
  }
  @media (max-width: 480px){
    #clienteVistaHeader{ font-size: 13px; }
    #clienteVistaHeader .w-20.h-20{ width: 48px !important; height: 48px !important; }
    /* Botones de export apilados */
    #clienteVistaFilters button{ flex: 1 1 auto; min-width: 0; }
  }

  /* ===== Sticky header en columnas del kanban ===== */
  .kanban-col .col-header-sticky{
    position:sticky; top:0; z-index:10; background:#F8FAFC;
    padding:8px; margin:-8px -8px 8px -8px; border-radius:6px 6px 0 0;
    backdrop-filter:blur(6px);
  }

  /* ===== Modo compacto (toggle desde botón densidad) ===== */
  body.kanban-compact .lead-card{ padding:8px 10px !important; }
  body.kanban-compact .lead-card .lead-empresa{ display:none; }
  body.kanban-compact .lead-card .lead-tel{ display:none; }
  body.kanban-compact .lead-card .lead-tags{ display:none; }
  body.kanban-compact .kanban-col{ padding:8px !important; }

  /* ===== Quick actions SIEMPRE visibles en tarjetas (antes solo en hover) ===== */
  .lead-card{ position:relative; }
  .lead-card .quick-actions{
    position:absolute; top:6px; right:6px; display:flex; gap:4px;
    background:rgba(255,255,255,0.96); border-radius:8px; padding:3px;
    box-shadow:0 2px 6px rgba(15,23,42,0.08); border:1px solid #E2E8F0;
    z-index:2;
  }
  .lead-card .qa-btn{
    width:26px; height:26px; border-radius:6px; display:flex; align-items:center; justify-content:center;
    background:#F8FAFC; cursor:pointer; transition:all 0.15s;
  }
  .lead-card .qa-btn:hover{ background:#EFF6FF; transform:scale(1.08); }
  .lead-card .qa-btn svg{ width:13px; height:13px; }

  /* ===== Aging indicator ===== */
  .lead-card.aging-warn{ border-left:3px solid #F59E0B; }
  .lead-card.aging-danger{ border-left:3px solid #EF4444; animation:pulseRed 2s ease-in-out infinite; }
  @keyframes pulseRed{ 0%,100%{ box-shadow:0 0 0 0 rgba(239,68,68,0); } 50%{ box-shadow:0 0 0 3px rgba(239,68,68,0.15); } }
  .lead-card .aging-badge{
    font-size:9px; font-weight:800; padding:1px 5px; border-radius:9999px;
    display:inline-flex; align-items:center; gap:3px;
  }

  /* ===== WIP limit warning ===== */
  .kanban-col.wip-exceeded{ background:rgba(239,68,68,0.04); border:1px solid #FCA5A5; }
  .wip-counter{ font-size:10px; font-weight:700; padding:2px 6px; border-radius:9999px; }
  .wip-counter.ok{ background:#DCFCE7; color:#15803D; }
  .wip-counter.warn{ background:#FEF3C7; color:#92400E; }
  .wip-counter.over{ background:#FEE2E2; color:#B91C1C; }

  /* ===== Bulk selection en kanban ===== */
  .lead-card.selected{ outline:2px solid #1E3A8A; outline-offset:-1px; background:#EFF6FF !important; }
  #kanbanBulkBar{
    position:fixed; bottom:20px; left:50%; transform:translateX(-50%); z-index:50;
    background:#0F172A; color:white; border-radius:12px; padding:10px 16px;
    display:flex; align-items:center; gap:10px; box-shadow:0 10px 30px rgba(0,0,0,0.3);
  }

  /* ===== Banner flotante de SCRAPING en background ===== */
  #scrapeFloatBanner{
    position:fixed; bottom:20px; right:20px; z-index:60;
    background:#0F172A; color:white; border-radius:14px; padding:12px 14px 12px 16px;
    display:flex; align-items:center; gap:12px;
    box-shadow:0 10px 30px rgba(0,0,0,0.3), 0 0 0 1px rgba(255,255,255,0.08);
    max-width:340px; min-width:260px;
    animation: scrape-in 0.25s ease-out;
  }
  @keyframes scrape-in{
    from{ opacity:0; transform:translateY(8px); }
    to{ opacity:1; transform:translateY(0); }
  }
  #scrapeFloatBanner .scrape-spinner{
    width:18px; height:18px; flex-shrink:0;
    border:2.5px solid rgba(255,255,255,0.18);
    border-top-color:#10B981;
    border-radius:50%;
    animation: scrape-spin 0.9s linear infinite;
  }
  @keyframes scrape-spin{
    to { transform: rotate(360deg); }
  }
  #scrapeFloatBanner .scrape-title{
    font-size:11px; font-weight:800; letter-spacing:0.04em;
    text-transform:uppercase; color:#10B981; margin-bottom:2px;
  }
  #scrapeFloatBanner .scrape-progress{
    font-size:12px; color:rgba(255,255,255,0.9); line-height:1.3;
  }
  #scrapeFloatBanner .scrape-link{
    background:none; border:0; color:#93C5FD; font-size:11px; font-weight:700; cursor:pointer;
    padding:4px 0; text-align:left;
  }
  #scrapeFloatBanner .scrape-link:hover{ color:white; }
  #scrapeFloatBanner .scrape-stop{
    background:#DC2626; color:white; border:0; border-radius:8px; padding:6px 10px;
    font-size:11px; font-weight:800; cursor:pointer; transition:background 0.15s;
    flex-shrink:0;
  }
  #scrapeFloatBanner .scrape-stop:hover{ background:#B91C1C; }
  @media (max-width: 480px){
    #scrapeFloatBanner{ left:20px; right:20px; max-width:none; min-width:0; }
  }
  /* Botones de navegación Kanban */
  .kanban-nav-btn{ position:absolute; top:50%; transform:translateY(-50%); z-index:5;
    width:40px; height:40px; border-radius:50%; background:white; border:1px solid #E2E8F0;
    box-shadow:0 4px 12px rgba(15,23,42,0.12); cursor:pointer;
    display:flex; align-items:center; justify-content:center; color:#1E3A8A;}
  .kanban-nav-btn:hover{ background:#EFF6FF; transform:translateY(-50%) scale(1.1); }
  .lead-card{ background:white; border-radius:10px; padding:10px 12px; margin-bottom:8px; cursor:grab; border:1px solid #E2E8F0; transition:all .15s; }
  .lead-card:hover{ transform:translateY(-1px); box-shadow: 0 4px 10px rgba(15,23,42,0.06); }
  .lead-card.dragging{ opacity:.4; }
  .lead-card.drop-before{ border-top:3px solid var(--brand); }
  .lead-card.drop-after{ border-bottom:3px solid var(--brand); }
  .kanban-col.drag-over .col-drop{ background:#DBEAFE; border:2px dashed var(--brand); }
  .kanban-col.col-drop-target{ background:#EFF6FF; box-shadow:0 0 0 3px var(--brand); }
  .kanban-col.dragging-col{ opacity:.5; }
  .col-handle:hover{ background:#E2E8F0; border-radius:4px; cursor:grab; }
  .col-handle:active{ cursor:grabbing; }
  .col-drop{ min-height:200px; padding:8px; border-radius:8px; border:2px dashed transparent; transition:all .15s; }
  .side-link{ display:flex; align-items:center; gap:10px; padding:10px 14px; border-radius:10px; color:#475569; font-weight:500; cursor:pointer; }
  /* Sidebar categorías colapsables */
  .sb-cat-title{ display:flex; align-items:center; justify-content:space-between; padding:4px 12px 4px 12px; cursor:pointer; user-select:none; }
  .sb-cat-title:hover{ color:#334155; }
  .sb-cat-title .sb-chev{ font-size:10px; color:#94A3B8; transition:transform .2s; }
  .sb-cat.collapsed .sb-cat-title .sb-chev{ transform:rotate(-90deg); }
  .sb-cat-content{ transition:max-height .25s ease, opacity .2s ease; overflow:hidden; }
  .sb-cat.collapsed .sb-cat-content{ max-height:0 !important; opacity:0; pointer-events:none; }
  .side-link:hover{ background:#F1F5F9; }
  .side-link.active{ background:var(--brand-light); color:var(--brand); font-weight:600; }
  .fade-in{ animation: fade .25s ease-out; }
  @keyframes fade { from{opacity:0; transform:translateY(6px);} to{opacity:1; transform:none;} }
  @keyframes lbPulse { 0%,100%{ transform:scale(1); opacity:1; } 50%{ transform:scale(1.4); opacity:.6; } }
  @keyframes confettiFall { 0%{ transform:translateY(0) rotate(0); opacity:1; } 100%{ transform:translateY(110vh) rotate(720deg); opacity:0; } }
  @keyframes fadeInScale { 0%{ transform:scale(0.85); opacity:0; } 100%{ transform:scale(1); opacity:1; } }
  /* Lesson editor blocks */
  .lb-block{ position:relative; padding:8px 12px; margin-bottom:4px; border-radius:6px; border:1px dashed transparent; transition:border .15s; }
  .lb-block.editable:hover{ border-color:#CBD5E1; background:#FAFBFC; }
  .lb-block .lb-actions{ position:absolute; top:6px; right:6px; display:none; gap:4px; }
  .lb-block:hover .lb-actions{ display:flex; }
  .lb-block .lb-actions button{ background:white; border:1px solid #E2E8F0; color:#64748B; font-size:11px; padding:2px 6px; border-radius:4px; cursor:pointer; }
  .lb-block .lb-actions button:hover{ background:#F1F5F9; color:#0F172A; }
  .lb-block .lb-actions button.danger:hover{ background:#FEE2E2; color:#DC2626; }
  .lb-block [contenteditable="true"]:empty:before{ content:attr(data-placeholder); color:#94A3B8; pointer-events:none; }
  .lb-block [contenteditable="true"]:focus{ outline:none; }
  .lb-toolbar button{ background:white; border:1px solid #E2E8F0; color:#475569; font-size:12px; padding:6px 10px; border-radius:6px; font-weight:600; cursor:pointer; transition:all .15s; }
  .lb-toolbar button:hover{ background:#EFF6FF; border-color:#3B82F6; color:#1E40AF; }
  .lb-toolbar button.rec{ background:#FEE2E2; border-color:#FCA5A5; color:#B91C1C; }
  .lb-toolbar button.rec:hover{ background:#FECACA; }
  /* Drag handle (Notion-style) */
  .lb-block .lb-drag{ position:absolute; top:8px; left:-22px; cursor:grab; opacity:0; color:#94A3B8; font-size:18px; line-height:1; user-select:none; padding:2px; }
  .lb-block:hover .lb-drag{ opacity:1; }
  .lb-block .lb-drag:active{ cursor:grabbing; }
  .lb-block.dragging{ opacity:.4; }
  .lb-block.drag-over-top{ border-top:2px solid #3B82F6 !important; }
  .lb-block.drag-over-bot{ border-bottom:2px solid #3B82F6 !important; }
  /* Cover block a ancho completo dentro de la lección */
  .lb-block.cover-fullwidth{ padding:0 !important; border-radius:0 !important; }
  .lb-block.cover-fullwidth.editable:hover{ border-color:transparent !important; background:transparent !important; }
  .lb-block.cover-normal{ padding:0 !important; }
  /* Floating selection toolbar */
  .lb-sel-toolbar{ position:absolute; z-index:300; background:#0F172A; color:white; border-radius:8px; box-shadow:0 8px 24px rgba(0,0,0,0.3); padding:4px; display:flex; gap:2px; }
  .lb-sel-toolbar button{ background:transparent; border:none; color:white; font-size:13px; padding:6px 10px; border-radius:4px; cursor:pointer; min-width:30px; font-weight:600; }
  .lb-sel-toolbar button:hover{ background:#1E293B; }
  .lb-sel-toolbar button.active{ background:#3B82F6; }
  .lb-sel-toolbar .sep{ width:1px; background:#334155; margin:4px 2px; }
  /* Headings within blocks */
  .lb-block h1{ font-size:32px; font-weight:900; line-height:1.2; }
  .lb-block h2{ font-size:24px; font-weight:800; line-height:1.25; }
  .lb-block h3{ font-size:20px; font-weight:700; line-height:1.3; }
  .lb-block h4{ font-size:16px; font-weight:700; line-height:1.4; }
  .lb-block ul{ list-style:disc; padding-left:24px; }
  .lb-block ol{ list-style:decimal; padding-left:24px; }
  .lb-block a{ color:#3B82F6; text-decoration:underline; }
  /* Lesson row reorder */
  .lesson-row{ position:relative; }
  .lesson-row .lesson-actions{ display:flex; gap:2px; opacity:0; transition:opacity .15s; }
  .lesson-row:hover .lesson-actions{ opacity:1; }
  /* Modo presentación */
  .card.presentation-mode{ position:fixed !important; top:0 !important; left:0 !important; right:0 !important; bottom:0 !important; border-radius:0 !important; z-index:100; }
  .card.presentation-mode #lessonContent{ background:white !important; }
  .card.presentation-mode #lessonContent h1{ font-size:42px !important; }
  .card.presentation-mode #lessonContent h2{ font-size:32px !important; }
  .card.presentation-mode #lessonContent h3{ font-size:26px !important; }
  .card.presentation-mode #lessonContent .text-base{ font-size:18px !important; line-height:1.7 !important; }
  .module-card{ transition: all .2s; }
  .module-card:hover{ transform:translateY(-3px); box-shadow: 0 10px 24px rgba(15,23,42,0.08); }
  .coming-soon{ opacity:.6; }
  .module-soon{ position:relative; opacity:.85; cursor:not-allowed !important; }
  .module-soon:hover{ transform:none !important; box-shadow: 0 1px 2px rgba(15,23,42,0.04), 0 1px 3px rgba(15,23,42,0.06) !important; }
  .module-soon::after{ content:''; position:absolute; inset:0; background:repeating-linear-gradient(45deg, transparent 0 14px, rgba(220,38,38,0.04) 14px 16px); pointer-events:none; border-radius:inherit; opacity:0; transition:opacity .2s; }
  .module-soon:hover::after{ opacity:1; }
  .chip-soon{ background:#FEE2E2 !important; color:#B91C1C !important; }
  /* Animación shake "no se puede" cuando se pulsa una card próximamente */
  @keyframes shakeNo { 0%,100%{ transform:translateX(0);} 15%,45%,75%{ transform:translateX(-6px);} 30%,60%,90%{ transform:translateX(6px);} }
  .shake-no{ animation: shakeNo .45s cubic-bezier(.36,.07,.19,.97); }
  @keyframes notifBar { from{ width:100%; } to{ width:0%; } }
  .chat-notif-toast .truncate{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  /* Drag & drop de módulos del hub entre Activos y Próximamente */
  .modulo-custom-card.dragging, .prox-builtin.dragging{ opacity:.4; cursor:grabbing !important; }
  .modulo-custom-card[draggable="true"], .prox-builtin[draggable="true"]{ cursor:grab !important; }
  .module-soon[draggable="true"]{ cursor:grab !important; }
  /* Indicador de inserción al reordenar: SOLO una línea azul en el lado donde se insertará */
  .module-card.card-drop-before, .module-card.card-drop-after,
  .curso-card-draggable.curso-drop-before, .curso-card-draggable.curso-drop-after{ position:relative; }
  .module-card.card-drop-before::before,
  .curso-card-draggable.curso-drop-before::before{
    content:''; position:absolute; top:8px; bottom:8px; left:-8px; width:4px; border-radius:4px; background:#1E3A8A; box-shadow:0 0 8px rgba(30,58,138,0.5);
  }
  .module-card.card-drop-after::after,
  .curso-card-draggable.curso-drop-after::after{
    content:''; position:absolute; top:8px; bottom:8px; right:-8px; width:4px; border-radius:4px; background:#1E3A8A; box-shadow:0 0 8px rgba(30,58,138,0.5);
  }
  .curso-card-draggable.dragging{ opacity:.4; cursor:grabbing !important; }
  .hub-dropzone{ transition: all .15s; border-radius:12px; }
  .hub-dropzone.hub-dropzone-armed{ outline:2px dashed #93C5FD; outline-offset:6px; background:rgba(219,234,254,0.25); }
  .hub-dropzone.hub-dropzone-over{ outline:2px dashed #1E3A8A; outline-offset:6px; background:rgba(219,234,254,0.55); }
  table.app-table th{ background:#F8FAFC; font-size:11px; text-transform:uppercase; letter-spacing:.5px; color:#64748B; padding:10px 14px; text-align:left; font-weight:700;}
  table.app-table td{ padding:10px 14px; border-top:1px solid #F1F5F9; font-size:14px; }
  .modal-backdrop{ background:rgba(15,23,42,0.55); backdrop-filter: blur(3px); }
  .pill-estado{ padding:2px 10px; border-radius:999px; font-size:11px; font-weight:600; white-space:nowrap; display:inline-block;}
  .badge-nuevo{ background:#DBEAFE; color:#1E40AF;}
  .badge-contactado{ background:#FEF3C7; color:#92400E;}
  .badge-agendado{ background:#E0E7FF; color:#3730A3;}
  .badge-llamar-luego{ background:#E0F2FE; color:#075985;}
  .badge-secretaria-dura{ background:#FFE4E6; color:#BE123C;}
  .badge-no-interesado{ background:#F3F4F6; color:#475569;}
  .badge-ganado{ background:#D1FAE5; color:#065F46;}
  .badge-perdido{ background:#FEE2E2; color:#991B1B;}
  .badge-interesado{ background:#E0F2FE; color:#075985;}
  .ring-avatar{ width:28px; height:28px; border-radius:999px; display:inline-flex; align-items:center; justify-content:center; color:white; font-weight:700; font-size:11px;}

  /* ===== Sección "Speeches" — rediseño premium ===== */
  .speech-hero{ background:linear-gradient(135deg,#F59E0B 0%,#EA580C 55%,#BE185D 100%); box-shadow:0 10px 30px -10px rgba(234,88,12,.45); }
  .speech-hero-bg{ position:absolute; inset:0; opacity:.25; background-image:radial-gradient(circle at 20% 30%, rgba(255,255,255,.5) 0, transparent 40%), radial-gradient(circle at 80% 70%, rgba(255,255,255,.35) 0, transparent 35%); pointer-events:none; }
  .speech-kpi{ background:white; border:1px solid #E2E8F0; border-radius:14px; padding:14px 16px; transition:all .15s; }
  .speech-kpi:hover{ border-color:#CBD5E1; transform:translateY(-1px); box-shadow:0 4px 12px -4px rgba(15,23,42,.08); }
  .speech-kpi-icon{ width:36px; height:36px; border-radius:10px; display:flex; align-items:center; justify-content:center; font-size:18px; margin-bottom:8px; }
  .speech-kpi-val{ font-size:24px; font-weight:900; color:#0F172A; line-height:1; }
  .speech-kpi-lbl{ font-size:11px; font-weight:600; color:#64748B; text-transform:uppercase; letter-spacing:.05em; margin-top:4px; }

  .speech-cli-group{ background:white; border:1px solid #E2E8F0; border-radius:16px; overflow:hidden; margin-bottom:16px; transition:border-color .15s; }
  .speech-cli-group:hover{ border-color:#CBD5E1; }
  .speech-cli-head{ display:flex; align-items:center; justify-content:space-between; padding:14px 18px; gap:12px; background:linear-gradient(180deg,#FFFBEB 0%, #FFFFFF 100%); border-bottom:1px solid #F1F5F9; flex-wrap:wrap; }
  .speech-cli-avatar{ width:38px; height:38px; border-radius:10px; background:linear-gradient(135deg,#F59E0B,#EA580C); color:white; font-weight:800; font-size:14px; display:flex; align-items:center; justify-content:center; flex-shrink:0; box-shadow:0 4px 12px -4px rgba(234,88,12,.5); }
  /* Wrapper para el logo del cliente — fuerza el tamaño y radio redondeado */
  .speech-cli-avatar-wrap{ width:38px; height:38px; flex-shrink:0; display:flex; align-items:center; justify-content:center; }
  .speech-cli-avatar-wrap > *{ width:38px !important; height:38px !important; border-radius:10px !important; box-shadow:0 4px 12px -4px rgba(15,23,42,.15); }
  .speech-cli-avatar-wrap img{ object-fit:contain !important; background:#fff !important; }

  .speech-grid{ display:grid; grid-template-columns:repeat(auto-fill,minmax(320px,1fr)); gap:12px; padding:14px; }

  .speech-card{ position:relative; background:white; border:1px solid #E2E8F0; border-radius:12px; padding:16px 16px 14px; transition:all .15s; overflow:hidden; }
  .speech-card::before{ content:""; position:absolute; left:0; top:0; bottom:0; width:4px; background:var(--cat-color,#94A3B8); }
  .speech-card:hover{ border-color:#CBD5E1; transform:translateY(-2px); box-shadow:0 8px 24px -8px rgba(15,23,42,.12); }
  .speech-card-title{ font-weight:700; color:#0F172A; font-size:15px; line-height:1.3; margin-bottom:2px; word-break:break-word; }
  .speech-card-meta{ display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin-bottom:10px; }
  .speech-card-preview{ font-size:12px; color:#475569; line-height:1.55; min-height:48px; max-height:96px; overflow:hidden; position:relative; }
  .speech-card-preview::after{ content:""; position:absolute; bottom:0; left:0; right:0; height:32px; background:linear-gradient(transparent, white); pointer-events:none; }
  .speech-card-actions{ display:flex; gap:6px; margin-top:12px; padding-top:10px; border-top:1px dashed #E2E8F0; }
  .speech-card-actions button{ flex:1; height:30px; border-radius:8px; font-size:12px; font-weight:600; border:1px solid #E2E8F0; background:white; color:#475569; transition:all .12s; display:inline-flex; align-items:center; justify-content:center; gap:4px; cursor:pointer; }
  .speech-card-actions button:hover{ background:#F8FAFC; border-color:#CBD5E1; color:#0F172A; }
  .speech-card-actions button.primary{ background:linear-gradient(135deg,#F59E0B,#EA580C); color:white; border-color:transparent; }
  .speech-card-actions button.primary:hover{ box-shadow:0 4px 12px -4px rgba(234,88,12,.5); transform:translateY(-1px); color:white; }
  .speech-card-actions button.danger:hover{ background:#FEF2F2; border-color:#FCA5A5; color:#B91C1C; }

  .speech-cat-chip{ display:inline-flex; align-items:center; gap:4px; padding:2px 8px; border-radius:6px; font-size:10px; font-weight:700; text-transform:uppercase; letter-spacing:.04em; background:var(--cat-bg,#F1F5F9); color:var(--cat-fg,#475569); }
  .speech-meta-dot{ font-size:11px; color:#94A3B8; }

  .speech-empty{ text-align:center; padding:48px 24px; background:white; border:2px dashed #E2E8F0; border-radius:16px; color:#64748B; }
  .speech-empty-icon{ font-size:48px; margin-bottom:12px; opacity:.4; }

  .speech-add-card{ display:flex; align-items:center; justify-content:center; min-height:170px; border:2px dashed #FCD34D; background:#FFFBEB; border-radius:12px; color:#92400E; font-weight:700; font-size:14px; cursor:pointer; transition:all .15s; }
  .speech-add-card:hover{ background:#FEF3C7; border-color:#F59E0B; transform:translateY(-2px); }

  /* ===== Próxima acción · pills de tipo y atajos rápidos ===== */
  .next-tipo-pill{
    display:inline-flex; align-items:center; gap:4px;
    padding:6px 12px; border-radius:999px; font-size:13px; font-weight:600;
    background:#F8FAFC; color:#475569; border:1px solid #E2E8F0;
    cursor:pointer; transition:all .12s;
  }
  .next-tipo-pill:hover{ background:#F1F5F9; border-color:#CBD5E1; }
  .next-tipo-pill.active{
    background:linear-gradient(135deg,#F59E0B 0%,#EA580C 100%);
    color:white; border-color:transparent;
    box-shadow:0 2px 8px -2px rgba(234,88,12,.45);
  }
  .next-quick-pill{
    display:inline-flex; align-items:center;
    padding:5px 11px; border-radius:8px; font-size:12px; font-weight:600;
    background:#F1F5F9; color:#475569; border:1px solid transparent;
    cursor:pointer; transition:all .12s;
  }
  .next-quick-pill:hover{ background:#FEF3C7; color:#92400E; border-color:#FCD34D; }

  /* ===== Editor & visor de speeches (HTML/Word) ===== */
  .speech-editor:empty::before{ content:attr(data-placeholder); color:#94A3B8; pointer-events:none; }
  .speech-editor h1, .speech-content h1{ font-size:1.5rem; font-weight:800; margin:0.6em 0 0.4em; color:#0F172A; }
  .speech-editor h2, .speech-content h2{ font-size:1.25rem; font-weight:800; margin:0.6em 0 0.3em; color:#0F172A; }
  .speech-editor h3, .speech-content h3{ font-size:1.05rem; font-weight:700; margin:0.5em 0 0.25em; color:#0F172A; }
  .speech-editor h4, .speech-content h4{ font-size:0.95rem; font-weight:700; margin:0.4em 0 0.2em; color:#1E293B; }
  .speech-editor p,  .speech-content p { margin:0.35em 0; }
  .speech-editor ul, .speech-content ul{ list-style:disc; padding-left:1.6em; margin:0.4em 0; }
  .speech-editor ol, .speech-content ol{ list-style:decimal; padding-left:1.6em; margin:0.4em 0; }
  .speech-editor li, .speech-content li{ margin:0.15em 0; }
  .speech-editor strong, .speech-content strong{ font-weight:700; }
  .speech-editor em, .speech-content em{ font-style:italic; }
  .speech-editor a, .speech-content a{ color:#2563EB; text-decoration:underline; }
  .speech-editor table, .speech-content table{ border-collapse:collapse; margin:0.5em 0; }
  .speech-editor td, .speech-editor th, .speech-content td, .speech-content th{ border:1px solid #CBD5E1; padding:4px 8px; }
  .logo-img{ height:32px; width:auto; }
  .logo-img-lg{ height:44px; width:auto; }
  .service-tag{ padding:3px 10px; border-radius:6px; font-size:11px; font-weight:600; display:inline-block; margin:2px; }
  .tag-seo{ background:#D1FAE5; color:#065F46; }
  .tag-gads{ background:#FEF3C7; color:#92400E; }
  .tag-meta{ background:#DBEAFE; color:#1E40AF; }
  .tag-email{ background:#E0E7FF; color:#3730A3; }
  .tag-cold{ background:#FCE7F3; color:#9D174D; }
  .kpi-up{ color:#059669; font-weight:700; }
  .kpi-down{ color:#DC2626; font-weight:700; }
  .cal-day{ aspect-ratio:1; background:white; border:1px solid #E2E8F0; padding:6px; font-size:11px; cursor:pointer; border-radius:6px; min-height:80px; overflow:hidden; }
  .cal-day.other{ background:#F8FAFC; color:#94A3B8; }
  .cal-day.today{ background:var(--brand-light); border-color:var(--brand); font-weight:700;}
  .cal-event{ background:var(--brand-accent); color:white; padding:1px 5px; border-radius:4px; margin-top:2px; font-size:10px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
  .course-thumb{ aspect-ratio: 16/9; border-radius:10px; display:flex; align-items:center; justify-content:center; color:white;}
  .task-col { min-width:260px; }

  /* Activity timeline */
  .timeline{ position:relative; padding-left:22px;}
  .timeline::before{ content:''; position:absolute; left:7px; top:4px; bottom:4px; width:2px; background:#E2E8F0;}
  .tl-item{ position:relative; padding-bottom:14px; }
  .tl-item::before{ content:''; position:absolute; left:-22px; top:4px; width:14px; height:14px; border-radius:50%; border:2px solid white; box-shadow: 0 0 0 2px #E2E8F0;}
  .tl-call::before{ background:#10B981;}
  .tl-email::before{ background:#3B82F6;}
  .tl-wa::before{ background:#25D366;}
  .tl-nota::before{ background:#F59E0B;}
  .tl-estado::before{ background:#8B5CF6;}
  .tl-reunion::before{ background:#EF4444;}

  /* Tabs */
  .tab-btn{ padding:8px 14px; font-size:13px; font-weight:600; color:#64748B; border-bottom:2px solid transparent; cursor:pointer;}
  .tab-btn.active{ color:var(--brand); border-bottom-color:var(--brand);}

  /* Buttons comunicación */
  .btn-call{ background:#10B981; color:white; padding:8px 12px; border-radius:8px; font-size:12px; font-weight:600; display:inline-flex; align-items:center; gap:6px; border:0; cursor:pointer;}
  .btn-call:hover{ background:#059669;}
  .btn-wa{ background:#25D366; color:white; padding:8px 12px; border-radius:8px; font-size:12px; font-weight:600; display:inline-flex; align-items:center; gap:6px; border:0; cursor:pointer;}
  .btn-email{ background:#3B82F6; color:white; padding:8px 12px; border-radius:8px; font-size:12px; font-weight:600; display:inline-flex; align-items:center; gap:6px; border:0; cursor:pointer;}

  /* Funnel bars */
  .funnel-bar{ height:40px; border-radius:8px; display:flex; align-items:center; padding:0 14px; color:white; font-weight:600; font-size:13px; margin-bottom:4px;}

  /* Progress bar */
  .progress-bar{ background:#E2E8F0; height:8px; border-radius:4px; overflow:hidden;}
  .progress-fill{ height:100%; background:var(--brand); border-radius:4px; transition:width .3s;}

  /* Visual del modal de llamada Zadarma (avatar circular + número de teléfono grande) */
  .dialer-avatar{ width:80px; height:80px; border-radius:50%; margin:0 auto 12px; display:flex; align-items:center; justify-content:center; background:var(--brand-light); font-size:28px; font-weight:800; color:var(--brand);}
  .dialer-phone{ font-size:28px; font-weight:800; color:var(--brand); margin:10px 0;}

  /* Tag */
  .tag-lead{ display:inline-block; background:#F1F5F9; color:#475569; padding:2px 8px; border-radius:6px; font-size:11px; font-weight:600; margin-right:4px; margin-bottom:4px;}
  .tag-hot{ background:#FEE2E2; color:#B91C1C;}
  .tag-warm{ background:#FEF3C7; color:#92400E;}
  .tag-cold{ background:#DBEAFE; color:#1E40AF;}

  /* Stale lead warning */
  .stale{ background:#FEF3C7 !important; border-left:3px solid #F59E0B;}

  /* Disposition buttons */
  .disp-btn{ background:white; border:2px solid #E2E8F0; padding:12px; border-radius:10px; cursor:pointer; font-weight:600; font-size:13px; transition:all .15s;}
  .disp-btn:hover{ border-color:var(--brand); background:var(--brand-light);}

  /* Lead scoring */
  .score-badge{ display:inline-flex; align-items:center; justify-content:center; min-width:32px; height:22px;
    border-radius:6px; font-size:11px; font-weight:800; padding:0 6px;}

  /* Global search (Cmd+K) */
  #globalSearch{ display:none; position:fixed; inset:0; z-index:60; padding-top:80px;
    background:rgba(15,23,42,0.55); backdrop-filter:blur(4px); }
  #globalSearch.open{ display:block; }
  #globalSearch .gs-box{ max-width:640px; margin:0 auto; background:white; border-radius:14px;
    overflow:hidden; box-shadow:0 20px 60px rgba(0,0,0,0.3);}
  #globalSearch input{ width:100%; border:0; outline:0; padding:18px 22px; font-size:16px; border-bottom:1px solid #E5E7EB;}
  #gsResults{ max-height:440px; overflow-y:auto;}
  .gs-item{ display:flex; align-items:center; gap:12px; padding:12px 20px; cursor:pointer; border-bottom:1px solid #F3F4F6;}
  .gs-item:hover, .gs-item.active{ background:#EFF6FF;}
  .gs-type{ font-size:10px; font-weight:700; padding:2px 8px; border-radius:4px; background:#F1F5F9; color:#475569; text-transform:uppercase;}
  .gs-hint{ display:flex; gap:10px; padding:10px 20px; background:#F8FAFC; font-size:11px; color:#64748B; border-top:1px solid #E5E7EB;}
  kbd{ background:white; border:1px solid #E2E8F0; padding:1px 6px; border-radius:4px; font-size:10px; font-family:inherit;}

  /* Dashboard */
  .dash-card{ background:white; border-radius:14px; padding:20px; box-shadow: 0 1px 2px rgba(15,23,42,0.04), 0 1px 3px rgba(15,23,42,0.06);}
  .dash-progress{ background:#E2E8F0; height:6px; border-radius:3px; overflow:hidden;}
  .dash-progress > div{ background:var(--brand); height:100%; transition:width .3s;}

  /* Chat interno */
  .chat-fab{ position:fixed; bottom:24px; right:24px; width:56px; height:56px; border-radius:50%;
    background:var(--brand); color:white; display:flex; align-items:center; justify-content:center;
    box-shadow:0 10px 30px rgba(30,58,138,0.35); cursor:pointer; z-index:45; border:0;}
  .chat-fab:hover{ transform:scale(1.05); }
  .chat-fab .unread{ position:absolute; top:-2px; right:-2px; background:#DC2626; color:white; font-size:10px;
    font-weight:700; border-radius:999px; min-width:20px; height:20px; padding:0 5px; display:flex; align-items:center; justify-content:center; border:2px solid white;}
  .chat-panel{ position:fixed; bottom:96px; right:24px; width:760px; height:600px; max-height:calc(100vh - 120px); max-width:calc(100vw - 48px);
    background:white; border-radius:16px; box-shadow:0 20px 60px rgba(15,23,42,0.25); z-index:44;
    display:none; overflow:hidden; flex-direction:column;}
  .chat-panel.open{ display:flex; }
  .chat-inner{ flex:1; display:flex; overflow:hidden; min-height:0;}
  .chat-sidebar{ width:240px; background:#F8FAFC; border-right:1px solid #E2E8F0; overflow-y:auto; flex-shrink:0;}
  .chat-main{ flex:1; display:flex; flex-direction:column; min-width:0;}
  .chat-section-title{ padding:12px 16px 6px; font-size:10px; font-weight:700; color:#64748B; text-transform:uppercase; letter-spacing:.5px; display:flex; align-items:center; justify-content:space-between;}
  .chat-msg{ max-width:min(70%, 520px); padding:8px 12px; border-radius:14px; font-size:13px; line-height:1.4; word-wrap:break-word; overflow-wrap:anywhere; white-space:pre-wrap; min-width:0; }
  .chat-msg-wrap{ max-width:100%; }
  .chat-msg-wrap > div.flex-1{ min-width:0; max-width:calc(100% - 48px); }
  .chat-msg.mine{ background:var(--brand); color:white; border-bottom-right-radius:4px;}
  .chat-msg.theirs{ background:#F1F5F9; color:#0F172A; border-bottom-left-radius:4px;}
  .chat-conv-item{ padding:8px 14px; display:flex; gap:10px; cursor:pointer; align-items:center; position:relative;}
  .chat-conv-item:hover{ background:#EFF6FF;}
  .chat-conv-item.active{ background:#DBEAFE;}
  .chat-conv-item .conv-name{ flex:1; min-width:0; font-size:13px; font-weight:500; color:#0F172A; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
  .chat-conv-item.unread .conv-name{ font-weight:700; }
  .chat-conv-item.muted .conv-name{ color:#94A3B8; font-weight:400;}
  .chat-conv-item .unread-dot{ background:#DC2626; color:white; font-size:10px; font-weight:700; min-width:18px; height:18px; border-radius:999px; display:flex; align-items:center; justify-content:center; padding:0 5px;}
  .chat-conv-item .conv-menu{ opacity:0; background:transparent; border:none; color:#64748B; padding:2px 8px; border-radius:6px; cursor:pointer; font-size:18px; line-height:1; letter-spacing:1px; transition: background .15s; }
  .chat-conv-item:hover .conv-menu{ opacity:1; }
  .chat-conv-item .conv-menu:hover{ background:#DBEAFE; color:#1E3A8A; }
  .chat-item-menu{ position:fixed; z-index:80; background:white; border:1px solid #E2E8F0; border-radius:10px; box-shadow:0 12px 32px rgba(15,23,42,0.15); padding:4px; min-width:220px; }
  .chat-item-menu button{ display:block; width:100%; text-align:left; padding:9px 12px; border-radius:6px; font-size:13px; color:#334155; background:transparent; border:none; cursor:pointer; display:flex; align-items:center; gap:8px; }
  .chat-item-menu button:hover{ background:#F1F5F9; }
  .chat-item-menu button.danger{ color:#DC2626; }
  .chat-item-menu button.danger:hover{ background:#FEE2E2; }
  .chat-item-menu .sep{ height:1px; background:#E2E8F0; margin:4px 0; }
  /* Chat notifications panel */
  #chatNotifPanel{ position:fixed; width:360px; max-height:500px; z-index:90; background:white; border:1px solid #E2E8F0; border-radius:12px; box-shadow:0 20px 50px rgba(15,23,42,0.18); overflow:hidden; display:flex; flex-direction:column; }
  #chatNotifPanel .cn-header{ padding:12px 14px; border-bottom:1px solid #E2E8F0; display:flex; justify-content:space-between; align-items:center; background:#F8FAFC; }
  #chatNotifPanel .cn-list{ flex:1; overflow-y:auto; }
  #chatNotifPanel .cn-item{ padding:10px 12px; border-bottom:1px solid #F1F5F9; cursor:pointer; position:relative; }
  #chatNotifPanel .cn-item:hover{ background:#EFF6FF; }
  #chatNotifPanel .cn-item.unread{ background:#FEF9C3; }
  #chatNotifPanel .cn-item.unread:hover{ background:#FEF3C7; }
  #chatNotifPanel .cn-icon{ width:22px; height:22px; display:inline-flex; align-items:center; justify-content:center; font-size:14px; background:#E0E7FF; color:#3730A3; border-radius:50%; flex-shrink:0; }
  #chatNotifPanel .cn-dot{ width:8px; height:8px; background:#DC2626; border-radius:50%; flex-shrink:0; }
  .chat-notif-btn{ position:relative; background:transparent; border:none; padding:6px 8px; cursor:pointer; color:#64748B; border-radius:6px; }
  .chat-notif-btn:hover{ background:#EFF6FF; color:#1E3A8A; }
  .chat-notif-btn .cnb-badge{ position:absolute; top:0; right:0; background:#DC2626; color:white; font-size:9px; font-weight:700; min-width:16px; height:16px; border-radius:999px; padding:0 4px; display:none; align-items:center; justify-content:center; }
  .chat-channel-icon{ width:24px; height:24px; border-radius:6px; display:flex; align-items:center; justify-content:center; background:#E2E8F0; color:#475569; font-weight:700; font-size:13px;}
  .chat-presence{ position:absolute; bottom:-2px; right:-2px; width:10px; height:10px; border-radius:50%; border:2px solid white;}
  .chat-presence.online{ background:#10B981;}
  .chat-presence.away{ background:#F59E0B;}
  .chat-presence.offline{ background:#94A3B8;}
  .chat-presence.busy{ background:#DC2626;}
  .chat-presence.dnd{ background:#7C2D12; position:relative; }
  .chat-presence.dnd::after{ content:''; position:absolute; top:50%; left:1px; right:1px; height:2px; background:white; transform:translateY(-50%); border-radius:1px;}
  .presence-dot{ display:inline-block; width:9px; height:9px; border-radius:50%; flex-shrink:0;}
  .presence-dot.online{ background:#10B981;}
  .presence-dot.away{ background:#F59E0B;}
  .presence-dot.offline{ background:#94A3B8;}
  .presence-dot.busy{ background:#DC2626;}
  .presence-dot.dnd{ background:#7C2D12; position:relative;}
  .presence-dot.dnd::after{ content:''; position:absolute; top:50%; left:1px; right:1px; height:1.5px; background:white; transform:translateY(-50%); border-radius:1px;}
  .chat-reactions{ display:flex; gap:4px; margin-top:4px; flex-wrap:wrap;}
  .chat-reaction{ background:white; border:1px solid #E2E8F0; border-radius:12px; padding:1px 6px; font-size:11px; cursor:pointer;}
  .chat-reaction.mine{ background:#DBEAFE; border-color:#3B82F6; color:#1E40AF;}
  .chat-reaction:hover{ background:#F1F5F9;}
  .chat-add-react{ opacity:.35; transition:opacity .15s; cursor:pointer; font-size:14px; padding:0 4px; background:white; border:1px solid #E2E8F0; border-radius:999px; width:22px; height:22px; display:inline-flex; align-items:center; justify-content:center;}
  .chat-add-react:hover{ opacity:1; background:#F1F5F9;}
  .chat-msg-wrap:hover .chat-add-react{ opacity:1; }
  .chat-input-area{ border-top:1px solid #E2E8F0; padding:10px; display:flex; gap:8px; align-items:center;}
  .chat-search-wrap{ padding:10px 12px; border-bottom:1px solid #E2E8F0;}
  .chat-search-wrap input{ width:100%; background:#F1F5F9; border:0; border-radius:8px; padding:8px 12px; font-size:13px; outline:none;}
  @media (max-width: 768px){
    .chat-panel{ right:0; left:0; bottom:0; width:auto; max-width:none; height:100vh; max-height:100vh; border-radius:0;}
    .chat-fab{ bottom:16px; right:16px; }
    .chat-sidebar{ width:100%; }
    .chat-panel.chat-active-mobile .chat-sidebar{ display:none; }
    .chat-panel:not(.chat-active-mobile) .chat-main{ display:none; }
  }

  /* Team drag & drop */
  .team-card{ transition: all .15s; }
  .team-card.drag-over{ background:#EFF6FF !important; border-color:var(--brand) !important; box-shadow:0 0 0 2px var(--brand);}
  .team-member-wrap{ cursor:grab; position:relative; display:inline-block; transition:transform .1s; border-radius:50%;}
  .team-member-wrap:hover{ transform:scale(1.1); }
  .team-member-wrap:hover::after{ content:attr(data-name); position:absolute; bottom:-22px; left:50%; transform:translateX(-50%);
    background:#0F172A; color:white; font-size:10px; padding:2px 8px; border-radius:4px; white-space:nowrap; z-index:10; font-weight:600;}
  .team-member-wrap.dragging{ opacity:.3; }
  .sin-equipo-card{ background:#FEF3C7; border:2px dashed #F59E0B;}

  /* ===== Mobile menu ===== */
  .mobile-menu-btn{ display:none; }
  .crm-sidebar-backdrop{ display:none; }

  /* ===== RESPONSIVE ===== */

  /* Tablet y hacia abajo */
  @media (max-width: 1024px){
    .view#view-crm .w-60{ width:220px; }
    .cal-day{ min-height:60px; font-size:10px; padding:4px; }
    .cal-event{ font-size:9px; padding:1px 3px; }
    /* Dialer en tablet: pasa a 1 columna si no cabe */
  }

  /* Móvil (< 768px) */
  @media (max-width: 768px){
    /* Evitar el auto-zoom de iOS al focar inputs: forzar font-size mínimo 16px */
    input, textarea, select{ font-size:16px !important; }
    /* Excepción: chips, tags y textos pequeños de la UI no son inputs */
    .chip, .tag-lead, kbd { font-size:11px !important; }
    /* Login en móvil — centrado perfecto vertical y horizontal */
    #loginScreen{
      display:flex !important;
      align-items:center !important;
      justify-content:center !important;
      min-height:100vh !important;
      min-height:100dvh !important;
      padding:16px !important;
    }
    #loginScreen > .card{ padding:22px !important; margin:auto !important; width:100% !important; max-width:420px !important; }
    #loginScreen .logo-img-lg{ height:36px !important; }
    #loginScreen h1{ font-size:18px !important; margin-top:12px !important; margin-bottom:2px !important; }
    #loginScreen > .card label{ font-size:11px !important; }
    #loginScreen > .card p.text-sm{ font-size:12px !important; margin-bottom:14px !important; }
    /* ===== Header compact ===== */
    header.bg-white{ padding:10px 12px !important; }
    .logo-img{ height:24px; }
    #userName, #userRole{ display:none !important; }
    #topNav{ display:none !important; }
    header .flex.items-center.gap-8{ gap:10px !important; }
    header .flex.items-center.gap-4{ gap:6px !important; }

    /* Notificaciones dropdown en mobile: ancho completo. SOLO visible cuando NO tiene la clase hidden */
    #notifDropdown:not(.hidden){ position:fixed !important; top:56px !important; right:8px !important; left:8px !important; width:auto !important; max-height:calc(100vh - 80px); overflow:hidden; display:flex; flex-direction:column;}
    #notifDropdown.hidden{ display:none !important; }
    #notifDropdown #notifList{ flex:1; }

    /* ===== Hub ===== */
    #view-hub{ padding:16px !important; }
    #view-hub h1{ font-size:22px; line-height:1.2; }
    #view-hub .grid{ gap:12px !important; }

    /* ===== CRM sidebar becomes drawer ===== */
    #view-crm > .flex{ flex-direction:column; }
    #view-crm aside{ position:fixed; left:-100%; top:57px; bottom:0; width:270px; z-index:30;
      transition:left .25s ease; box-shadow: 2px 0 12px rgba(0,0,0,0.1); overflow-y:auto; }
    #view-crm aside.open{ left:0; }
    .crm-sidebar-backdrop{ display:none; position:fixed; inset:57px 0 0 0; background:rgba(0,0,0,0.4); z-index:25; }
    .crm-sidebar-backdrop.show{ display:block; }
    .mobile-menu-btn{ display:inline-flex; align-items:center; gap:6px; background:white;
      border:1px solid #E2E8F0; border-radius:8px; padding:8px 14px; font-size:13px; font-weight:600; margin-bottom:12px;}
    #view-crm main{ padding:16px !important; }
    #view-crm h2{ font-size:20px; }

    /* ===== Kanban scroll ===== */
    .kanban-col{ width:84vw !important; max-width:300px; min-width:260px; }

    /* ===== Tables overflow ===== */
    .card.overflow-hidden{ overflow-x:auto; -webkit-overflow-scrolling:touch; }
    table.app-table{ min-width:600px; }
    table.app-table th, table.app-table td{ padding:8px 10px; font-size:13px;}
    table.leads-table{ min-width:600px; }

    /* ===== Sections ===== */
    section.view{ padding:16px !important; }
    section.view h2{ font-size:20px; line-height:1.2; }

    /* ===== Flexes que se deben envolver ===== */
    .flex.items-center.justify-between.flex-wrap{ gap:10px !important; }
    .flex.items-center.justify-between{ flex-wrap:wrap; gap:10px; }

    /* ===== Hub module cards ===== */
    .module-card{ padding:18px !important; }
    .module-card h3{ font-size:15px; }
    .module-card p{ font-size:12px; }

    /* ===== Modales ===== */
    .modal-backdrop{ padding:0 !important; align-items:flex-end !important; }
    .modal-backdrop > .card{ max-width:100% !important; width:100% !important; max-height:94vh !important;
      border-radius:14px 14px 0 0 !important; margin:0 !important; }

    /* ===== Modal de lección — full-screen en móvil con dvh =====
       En iOS Safari, vh incluye el alto del barra de URL, por eso el título de
       la lección quedaba tapado arriba y los botones se cortaban abajo. dvh
       ajusta al área realmente visible. Forzamos altura completa, sin redondeo
       y permitiendo que los botones de acción envuelvan en lugar de scroll. */
    #lessonModalWrap{ padding:0 !important; align-items:stretch !important; }
    #lessonModalWrap > .card{
      width:100% !important;
      max-width:100% !important;
      height:100dvh !important;
      max-height:100dvh !important;
      border-radius:0 !important;
      margin:0 !important;
    }
    /* Header compacto */
    #lessonModalWrap > .card > div.p-5{
      padding:12px 14px !important;
      padding-top: max(12px, env(safe-area-inset-top)) !important;
    }
    #lessonModalWrap .text-2xl{ font-size:18px !important; line-height:1.25 !important; }
    #lessonModalWrap .text-xs.font-semibold.uppercase{ font-size:10px !important; }
    /* Barra de acciones: 2 filas en lugar de scroll horizontal */
    #lessonModalWrap .lesson-actions-bar{
      flex-wrap:wrap !important;
      overflow-x:visible !important;
      white-space:normal !important;
      gap:6px !important;
    }
    #lessonModalWrap .lesson-actions-bar > button{
      padding:6px 10px !important;
      font-size:12px !important;
    }
    /* El separador vertical no tiene sentido cuando los botones envuelven */
    #lessonModalWrap .lesson-actions-bar > div.w-px{ display:none !important; }
    /* Contenido: un poquito menos padding */
    #lessonModalWrap > .card > div#lessonContent,
    #lessonModalWrap > .card > div#lessonNotes,
    #lessonModalWrap > .card > div#lessonComments{
      padding:14px !important;
    }
    /* Toolbar inferior "Añadir bloque" — compactar y dejar safe-area abajo */
    #lessonModalWrap > .card > div.p-3.border-t{
      padding:10px 12px !important;
      padding-bottom: max(10px, env(safe-area-inset-bottom)) !important;
      flex-wrap:wrap !important;
      gap:8px !important;
    }
    #lessonModalWrap > .card > div.p-3.border-t > span{ font-size:11px !important; }
    /* Cerrar (×) — más fácil de pulsar con el dedo */
    #lessonModalWrap > .card > div.p-5 > button.text-2xl{
      font-size:28px !important; min-width:36px; min-height:36px;
    }
    /* Form grids → 1 col */
    #leadModal .grid-cols-2, #clienteModal .grid-cols-2, #empresaModal .grid-cols-2,
    #profileModal .grid-cols-2, .modal-backdrop .grid-cols-2{ grid-template-columns:1fr !important; }
    /* Tabs del lead modal: scroll horizontal */
    .tab-btn{ white-space:nowrap; }

    /* ===== Login ===== */
    #loginScreen{ padding:16px !important; }
    #loginScreen > .card{ padding:24px !important; }

    /* ===== Calendar ===== */
    .cal-day{ min-height:52px; font-size:9px; padding:3px; }
    .cal-event{ font-size:8px; padding:1px 3px;}
    .cal-day > div:first-child{ font-size:11px; font-weight:700;}

    /* ===== Formularios ===== */
    .grid.grid-cols-2.gap-4{ grid-template-columns:1fr !important; }

    /* ===== Tareas board ===== */
    .task-col{ min-width:80vw; max-width:300px; }

    /* ===== Empresas filtros ===== */
    #empLista .flex.gap-2.mb-4{ flex-direction:column; align-items:stretch; }
    #empLista .flex.gap-2.mb-4 > *{ width:100% !important; }

    /* ===== Biblioteca ===== */
    #bibliotecaFiltros{ overflow-x:auto; flex-wrap:nowrap; padding-bottom:4px; -webkit-overflow-scrolling:touch;}
    #bibliotecaFiltros > button{ flex-shrink:0; }
    #bibliotecaContent .grid{ gap:10px !important; }
    #bibliotecaContent .card p-4{ padding:14px !important; }

    /* ===== Funnel ===== */
    .funnel-bar{ height:36px; font-size:12px; padding:0 10px; }

    /* ===== Modal de llamada Zadarma (responsive) ===== */
    .dialer-avatar{ width:64px !important; height:64px !important; font-size:22px !important; }
    .dialer-phone{ font-size:22px !important; }

    /* ===== Course thumbs ===== */
    .course-thumb svg{ width:36px; height:36px; }

    /* ===== Portal cliente ===== */
    #view-portal .max-w-5xl{ padding:16px !important; }
    #view-portal .grid-cols-3{ grid-template-columns:1fr !important; }

    /* ===== Touch targets ===== */
    button:not(.chip):not(.text-xs):not(.tab-btn), .side-link, input, select, textarea { min-height:40px; }
    .chip, .tab-btn, button.text-xs { min-height:auto; }

    /* ===== Timeline ===== */
    .timeline{ padding-left:18px; }

    /* ===== Ring avatars ===== */
    .ring-avatar{ font-size:10px !important; }

    /* Titulos en ranking */
    #rankContent .grid.grid-cols-1.md\:grid-cols-3{ grid-template-columns:1fr !important; }
  }

  /* Móvil pequeño (< 480px) */
  @media (max-width: 480px){
    .grid.md\:grid-cols-2.lg\:grid-cols-3{ grid-template-columns:1fr !important; }
    .grid.grid-cols-2.md\:grid-cols-4{ grid-template-columns:repeat(2, minmax(0, 1fr)) !important; gap:8px !important; }
    #loginScreen > .card{ padding:20px !important; }
    #loginScreen h1{ font-size:20px; }
    .module-card .flex.gap-4{ flex-wrap:wrap; gap:8px; }

    /* KPIs en 2 cols con menos padding */
    .card.p-4{ padding:14px !important; }
    .card.p-5{ padding:16px !important; }
    .card.p-6{ padding:18px !important; }

    /* Calendar: días abreviados */
    #view-calendario .grid.grid-cols-7.mb-1 > div{ font-size:9px; }
    .cal-day{ min-height:44px; padding:2px; font-size:8px;}
    .cal-event{ display:none; } /* Ocultar eventos en ultra pequeño, solo el número */
    .cal-day > div:first-child{ font-size:10px;}

    /* Portal cliente */
    #view-portal .max-w-5xl{ padding:14px !important; }

    /* Header ultra-compact */
    header.bg-white .logo-img{ height:22px; }
    header .flex.items-center.gap-2.cursor-pointer > div{ display:none; }

    /* Modales: padding menor */
    .modal-backdrop > .card > .p-5{ padding:16px !important; }
    .modal-backdrop > .card > .p-6{ padding:18px !important; }

    /* Formacion cursos */
    #formacionAreas .course-thumb{ height:80px !important; }
    #formacionAreas .course-thumb svg{ width:28px; height:28px; }


    /* Plantillas: cuerpo reducido */
    #crmPlantillas pre{ max-height:100px !important; font-size:11px; }

    /* Hub: título y descripción más compactos */
    #view-hub .mb-8 p{ font-size:13px; }

    /* Empresa card en biblioteca */
    #bibliotecaContent .module-card{ padding:14px !important; }
  }

  /* Overflow safety general */
  img, svg, video, canvas, pre{ max-width:100%; }
  *, *::before, *::after{ min-width:0; }

  /* Scrollbars: por defecto gris suave en TODA la app (excepto pipeline, que se queda azul) */
  *{ scrollbar-width: thin; scrollbar-color: #CBD5E1 #F1F5F9; }
  *::-webkit-scrollbar{ width:10px; height:10px; }
  *::-webkit-scrollbar-track{ background:#F1F5F9; border-radius:8px; }
  *::-webkit-scrollbar-thumb{ background:#CBD5E1; border-radius:8px; border:2px solid #F1F5F9; }
  *::-webkit-scrollbar-thumb:hover{ background:#94A3B8; }
  *::-webkit-scrollbar-corner{ background:#F1F5F9; }

  /* ===== MI PERFIL ===== */
  /* Barra de pestañas: en móvil no debe desbordar la página, sino deslizarse
     dentro de su ancho (scroll horizontal con inercia y sin barra visible). */
  .perfil-tabs{ -webkit-overflow-scrolling:touch; scrollbar-width:none; scroll-snap-type:x proximity; }
  .perfil-tabs::-webkit-scrollbar{ display:none; }
  .perfil-tab{ padding:9px 18px; border-radius:8px; cursor:pointer; font-weight:500; font-size:13px; color:#64748B; transition:all .15s; white-space:nowrap; flex-shrink:0; scroll-snap-align:start; }
  @media (max-width:640px){
    .perfil-tab{ padding:8px 13px; font-size:12px; }
  }
  .perfil-tab:hover{ background:#F1F5F9; }
  .perfil-tab.active{ background:var(--brand-light); color:var(--brand); font-weight:700; }
  .nomina-row{ display:flex; align-items:center; justify-content:space-between; padding:12px 16px; border-radius:10px; background:#F8FAFC; border:1px solid #E2E8F0; transition:background .12s; }
  .nomina-row:hover{ background:#F1F5F9; }

  /* ===== FICHAJE ===== */
  .fichaje-clock{ font-size:3rem; font-weight:900; font-variant-numeric:tabular-nums; letter-spacing:-2px; color:#0F172A; }
  .fichaje-clock-sm{ font-size:1rem; font-weight:600; font-variant-numeric:tabular-nums; color:#64748B; }
  .fichaje-worked{ font-size:3.25rem; font-weight:900; font-variant-numeric:tabular-nums; letter-spacing:-2px; color:#0F172A; line-height:1; }
  .fichaje-worked .unit{ font-size:1.5rem; font-weight:700; color:#475569; margin:0 4px 0 2px; }
  .fichaje-btn-entrada{ background:#16A34A; color:white; border-radius:16px; padding:18px 44px; font-size:1.1rem; font-weight:800; border:none; cursor:pointer; transition:all .2s; box-shadow:0 4px 20px rgba(22,163,74,.35); }
  .fichaje-btn-entrada:hover{ transform:translateY(-2px); box-shadow:0 8px 28px rgba(22,163,74,.45); }
  .fichaje-btn-salida{ background:#DC2626; color:white; border-radius:16px; padding:18px 44px; font-size:1.1rem; font-weight:800; border:none; cursor:pointer; transition:all .2s; box-shadow:0 4px 20px rgba(220,38,38,.35); }
  .fichaje-btn-salida:hover{ transform:translateY(-2px); box-shadow:0 8px 28px rgba(220,38,38,.45); }
  .fichaje-btn-pausa{ background:#F59E0B; color:white; border-radius:12px; padding:12px 28px; font-size:.95rem; font-weight:700; border:none; cursor:pointer; transition:all .15s; }
  .fichaje-btn-pausa:hover{ background:#D97706; }
  .fichaje-timeline-dot{ width:10px; height:10px; border-radius:50%; flex-shrink:0; margin-top:3px; }

  /* ===== AUDIO RECORDER ===== */
  @keyframes recPulse{ 0%,100%{ opacity:1; transform:scale(1); } 50%{ opacity:.45; transform:scale(1.2); } }
  .rec-dot{ width:12px; height:12px; border-radius:50%; background:#DC2626; display:inline-block; animation:recPulse 1.2s ease-in-out infinite; }
  @keyframes audioWave{ 0%,100%{ transform:scaleY(1); opacity:.7; } 50%{ transform:scaleY(.25); opacity:1; } }
  .audio-wave{ display:flex; align-items:center; gap:3px; height:44px; }
  .audio-wave span{ display:block; width:5px; border-radius:3px; background:var(--brand-accent); animation:audioWave 1s ease-in-out infinite; }
  .audio-wave span:nth-child(1){ height:10px; animation-delay:0s; }
  .audio-wave span:nth-child(2){ height:26px; animation-delay:.1s; }
  .audio-wave span:nth-child(3){ height:16px; animation-delay:.2s; }
  .audio-wave span:nth-child(4){ height:36px; animation-delay:.3s; }
  .audio-wave span:nth-child(5){ height:22px; animation-delay:.4s; }
  .audio-wave span:nth-child(6){ height:30px; animation-delay:.3s; }
  .audio-wave span:nth-child(7){ height:14px; animation-delay:.2s; }
