/* ==================================================================
   crm.css — Piezas propias de Pixelia Vínculo, sobre estilo.css (Norte).
   Mismas reglas de la casa: el token VIVO para puntos, barras e iconos;
   el derivado *-txt para el texto. Radio de tarjeta 14-18px, sin emojis.
   ================================================================== */

:root {
  --px-lila:      #7B61D9;
  --px-lila-txt:  #5A43B0;   /* sobre su chapa 5.6:1 */
  --px-rosa:      #D65A93;
  --px-rosa-txt:  #A3366B;   /* sobre su chapa 5.2:1 */
  --px-noche-txt: #0C5E96;
}

/* ---------- Marca: producto + nombre de la tienda ---------- */
.marca-pila { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.marca-tienda { font-size: 11.5px; color: var(--px-text-muted); font-weight: 600;
                white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; }

/* ---------- Asistente de primer uso (marco del login, mas ancho) ---------- */
.tarjeta-login.ancha { max-width: 480px; }
.tarjeta-login .mini-tit { margin: 20px 0 0; }
.form-primer-uso .form-grid { gap: 0 14px; margin-top: 14px; }

/* ---------- Velo del menu en movil (toca fuera para cerrar) ---------- */
.velo-menu { display: none; }
/* .btn-menu es un <button>: sin el aspecto de boton del navegador, con area
   tactil de 40px y foco visible (el display lo pone estilo.css) */
button.btn-menu { align-items: center; justify-content: center; min-width: 40px; min-height: 40px;
                  margin-left: -10px; padding: 0; border: 0; border-radius: 10px; background: none; font: inherit; }
button.btn-menu:focus-visible { outline: 2px solid var(--px-teal-dark); outline-offset: 0; }
@media (max-width: 860px) {
  .toggle-menu:checked ~ .velo-menu { display: block; position: fixed; inset: 0; z-index: 25;
                                      background: rgba(0, 18, 46, .35); }
  /* Cerrado, el lateral esta fuera de pantalla pero sus enlaces seguian
     recibiendo el Tab (foco invisible). visibility lo saca del orden de foco;
     se retrasa al cerrar para no cortar la animacion de salida. */
  .toggle-menu:not(:checked) ~ .lateral { visibility: hidden; transition: transform .2s ease, visibility 0s linear .2s; }
  .toggle-menu:checked ~ .lateral { visibility: visible; transition: transform .2s ease; }
}

/* ---------- Cabecera: que nunca aplaste el titulo ni tape lo que tiene el foco ---------- */
/* El titulo pide un minimo y, si no cabe con el buscador y las acciones, estos
   bajan de linea (entre 860 y 1000px el titulo se quedaba en 14px de ancho). */
.topbar { flex-wrap: wrap; }
.topbar-tit { min-width: min(100%, 260px); }
/* La cabecera es fija al desplazar: al navegar con Tab el elemento enfocado
   no debe quedar escondido debajo (WCAG 2.4.11). */
html { scroll-padding-top: 130px; }
/* En movil la cabecera fija llegaba a ocupar un cuarto de la pantalla: ahi se va con el contenido */
@media (max-width: 860px) {
  .topbar { position: static; }
  html { scroll-padding-top: 0; }
}
.lateral-cerrar { display: none; margin-left: auto; }
@media (max-width: 860px) { .lateral-cerrar { display: inline-flex; } }

/* Una tabla dentro de su .tabla-wrap NO es la tabla suelta de la red de seguridad
   de estilo.css (display:block + scroll propio): con las dos reglas a la vez
   salian dos barras de desplazamiento anidadas. */
.panel-cuerpo.tabla-wrap > .tabla, .tabla-wrap > .tabla { display: table; overflow: visible; }

/* ---------- Buscador global de la topbar ---------- */
.topbar-buscar { position: relative; width: clamp(200px, 22vw, 300px); }
.topbar-buscar .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
                      color: var(--gris-suave); pointer-events: none; }
.topbar-buscar input { min-height: 40px !important; padding: 8px 12px 8px 36px !important;
                       font-size: 14px !important; border-radius: 12px; background: rgba(255,255,255,.9) !important; }
@media (max-width: 860px) { .topbar-buscar { order: 3; width: 100%; } }

/* ---------- Chapas extra ---------- */
.badge .punto { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.badge-noche { background: #EAF4FD; color: var(--px-noche-txt); }
.badge-lila  { background: #F1ECFB; color: var(--px-lila-txt); }
.badge-rosa  { background: #FDECF3; color: var(--px-rosa-txt); }

/* ---------- Nivel del cliente ---------- */
.nivel {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase;
  padding: 3px 8px 3px 6px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap;
}
.nivel .ico { width: 12px; height: 12px; }
.nivel-bronce { background: #F7EEE7; color: #8A5532; border-color: #EEDCCD; }
.nivel-plata  { background: #EEF2F5; color: #4F5D6A; border-color: #DCE3E9; }
.nivel-oro    { background: #FFF4DF; color: var(--px-warning-txt); border-color: #F6DFAE; }
.nivel-oro .ico { fill: #E9A72A; stroke: #C58315; }
.nivel-vip    { background: var(--px-teal-solid); color: #fff; }
.nivel-vip .ico { fill: #fff; }

/* ---------- Puntaje en tabla ---------- */
.puntaje-mini { display: inline-flex; align-items: center; gap: 8px; min-width: 96px; }
.puntaje-mini b { font-size: 14px; font-weight: 800; min-width: 22px; text-align: right;
                  font-variant-numeric: tabular-nums; color: var(--px-ink); }
.puntaje-mini i { flex: 1; height: 6px; border-radius: 999px; background: var(--px-teal-soft); overflow: hidden; min-width: 56px; }
.puntaje-mini i span { display: block; height: 100%; border-radius: 999px; }

/* ---------- Avatar de cliente ---------- */
.avatar-cli {
  width: 38px; height: 38px; border-radius: 12px; flex-shrink: 0;
  display: inline-grid; place-items: center; font-weight: 800; font-size: 13.5px; letter-spacing: .02em;
}
.avatar-cli.grande { width: 64px; height: 64px; border-radius: 18px; font-size: 22px; }
.avatar-sm { width: 34px; height: 34px; font-size: 13px; }
.cli-celda { display: flex; align-items: center; gap: 11px; min-width: 0; }
.cli-celda a { color: var(--px-ink); font-weight: 700; text-decoration: none; }
.cli-celda a:hover { color: var(--px-teal-txt); text-decoration: underline; }
.cli-celda .sub { display: block; font-size: 12.5px; color: var(--px-text-muted); }

/* En TODAS las tablas (vive aqui y no en clientes.css: configuracion tambien
   desbordaba). El <span class="visualmente-oculto"> de la columna Acciones es absolute: sin
   un ancestro posicionado se colocaba respecto al documento, fuera del
   overflow del contenedor, y ensanchaba la pagina en movil (906px a 375). */
.tabla-wrap, .panel-cuerpo > .tabla { position: relative; }

/* ---------- Paginacion ---------- */
.paginacion { display: flex; gap: 4px; justify-content: center; padding: 14px; flex-wrap: wrap; }
.paginacion a, .paginacion span {
  min-width: 34px; height: 34px; display: inline-grid; place-items: center; padding: 0 8px;
  border-radius: 10px; font-size: 13.5px; font-weight: 600; text-decoration: none; color: var(--px-ink);
  border: 1px solid var(--px-border); background: #fff;
}
.paginacion a:hover { background: var(--px-teal-soft); }
.paginacion .es-activa { background: var(--px-teal-solid); color: #fff; border-color: var(--px-teal-solid); }
.paginacion .off { color: var(--gris-suave); border-color: transparent; background: transparent; }

/* ---------- Modal: ancho util y redactor de WhatsApp ---------- */
.modal.ancho { max-width: 720px; }
.modal-cab h3 .ico { color: var(--px-teal-dark); }
.modal-wa .modal-cab h3 .ico { color: #188741; }
.modal-cuerpo > label:first-child, .modal-cuerpo > .campo:first-child label { margin-top: 0; }
.wa-destino { display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin-bottom: 6px;
              background: var(--px-teal-soft); border-radius: 12px; }
.wa-destino strong { display: block; font-size: 14.5px; }
.wa-destino .secundario { font-size: 13px; }
.wa-aviso { color: var(--px-warning-txt); margin: 8px 0 0; }
.modal-pie { flex-wrap: wrap; }

/* ---------- Tonos de icono (chips de sugerencias y KPIs) ---------- */
.chip.lila { background: #F1ECFB; color: var(--px-lila-txt); }
.chip.rosa { background: #FDECF3; color: var(--px-rosa-txt); }
.tono { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; }
.tono.azul  { background: var(--px-teal-soft); color: #06655F; }
.tono.verde { background: #E4F6EE; color: #0B7A4F; }
.tono.ambar { background: #FFF4DF; color: #9A6410; }
.tono.rojo  { background: #FDECEC; color: #A93F3F; }
.tono.lila  { background: #F1ECFB; color: var(--px-lila-txt); }
.tono.rosa  { background: #FDECF3; color: var(--px-rosa-txt); }
.tono.noche { background: #EAF4FD; color: #0C5E96; }

/* ---------- Sugerencias inteligentes ---------- */
.sugerencias { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.sugerencia { display: flex; align-items: center; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--px-border); }
.sugerencia:last-child { border-bottom: 0; }
.sugerencia-txt { flex: 1; min-width: 0; }
.sugerencia-txt strong { font-size: 14.5px; color: var(--px-ink); }
.sugerencia-txt strong b { font-size: 17px; font-weight: 800; margin-right: 3px; }
.sugerencia-txt p { margin: 2px 0 0; font-size: 13px; color: var(--px-text-muted); line-height: 1.4; }
.sugerencia-acc { display: flex; gap: 6px; flex-shrink: 0; }
@media (max-width: 640px) {
  .sugerencia { flex-wrap: wrap; }
  .sugerencia-acc { width: 100%; padding-left: 54px; }
}

/* ---------- Agenda (filas de recordatorio) ---------- */
.agenda { list-style: none; margin: 0; padding: 0; }
.agenda-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--px-border); }
.agenda-item:last-child { border-bottom: 0; }
.agenda-txt { flex: 1; min-width: 0; }
.agenda-txt a { color: var(--px-ink); font-weight: 700; text-decoration: none; font-size: 14px; }
.agenda-txt a:hover { text-decoration: underline; }
.agenda-txt .sub { display: block; font-size: 12.5px; color: var(--px-text-muted);
                   white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agenda-acc { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }
/* En movil la columna de texto es estrecha: mejor dos lineas que cortar la chapa a la mitad */
@media (max-width: 520px) {
  .agenda-txt .sub { white-space: normal; overflow: visible; }
}
.fecha-chip { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 8px; white-space: nowrap;
              background: var(--px-teal-soft); color: var(--px-teal-txt); }
.fecha-chip.vencida { background: #FDECEC; color: var(--px-danger-txt); }
.fecha-chip.hoy { background: #FFF4DF; color: var(--px-warning-txt); }

/* ---------- Graficos de barras horizontales (HTML puro) ---------- */
.barras { display: flex; flex-direction: column; gap: 9px; }
.barra-fila { display: grid; grid-template-columns: minmax(90px, 150px) minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.barra-etq { font-size: 13.5px; font-weight: 600; color: var(--px-ink); display: flex; align-items: center; gap: 8px; min-width: 0; }
.barra-etq span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barra-etq .ico { color: var(--px-teal-dark); }
.barra-pista { height: 10px; background: var(--px-teal-soft); border-radius: 999px; overflow: hidden; }
.barra-pista span { display: block; height: 100%; border-radius: 999px; background: var(--px-teal); }
.barra-num { font-size: 13.5px; font-weight: 700; color: var(--px-ink); text-align: right;
             font-variant-numeric: tabular-nums; white-space: nowrap; }
.barra-num small { font-weight: 500; color: var(--px-text-muted); margin-left: 4px; }

/* ---------- SVG de graficos (columnas, lineas, anillos) ---------- */
.graf { width: 100%; height: auto; display: block; overflow: visible; }
.graf .eje  { stroke: var(--px-border); stroke-width: 1; }
.graf .guia { stroke: var(--px-border); stroke-width: 1; stroke-dasharray: 3 4; }
.graf text  { font-family: var(--px-texto); font-size: 11px; fill: var(--px-text-muted); }
.graf text.fuerte { fill: var(--px-ink); font-weight: 700; }
.graf .col  { fill: var(--px-teal); }
.graf .col:hover { fill: var(--px-teal-dark); }
.graf .linea { fill: none; stroke: var(--px-teal-dark); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.graf .area  { fill: rgba(18, 169, 159, .12); }
.graf .pt    { fill: #fff; stroke: var(--px-teal-dark); stroke-width: 2; }

.leyenda { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; font-size: 12.5px; color: var(--px-text-muted); }
.leyenda i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.leyenda b { color: var(--px-ink); margin-left: 4px; }

/* ---------- Donut + su leyenda ---------- */
.donut-caja { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.donut-caja svg { width: 140px; height: 140px; flex-shrink: 0; }
.donut-caja .leyenda { flex-direction: column; margin: 0; flex: 1; min-width: 140px; }

/* ---------- Mapa de calor: categoria x rango de edad ---------- */
.calor-wrap { overflow-x: auto; }
table.calor { width: 100%; border-collapse: separate; border-spacing: 4px; font-size: 13px; min-width: 620px; }
.calor th { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
            color: var(--gris-cabecera); padding: 4px 6px; text-align: center; }
.calor th.fila { text-align: left; text-transform: none; font-size: 13.5px; color: var(--px-ink); letter-spacing: 0; white-space: nowrap; }
.calor td { text-align: center; border-radius: 8px; padding: 0; height: 44px; }
.calor td a { display: grid; place-items: center; height: 100%; min-height: 44px; border-radius: 8px;
              text-decoration: none; color: inherit; font-weight: 700; font-variant-numeric: tabular-nums; }
.calor td a:hover { outline: 2px solid var(--px-teal-dark); outline-offset: -2px; }
/* Sin opacidad: calor_color() mide el contraste con la tinta tal cual, y al
   85% el porcentaje bajaba a 2.6:1 */
.calor td small { display: block; font-size: 10.5px; font-weight: 600; }
.calor td.top a { box-shadow: inset 0 0 0 2px rgba(255,255,255,.75); }

/* ---------- Ficha del cliente ---------- */
.ficha-cab { display: flex; align-items: center; gap: 16px; }
.ficha-cab h2 { margin: 0; font-size: 21px; font-weight: 800; letter-spacing: -.01em; }
.ficha-cab .sub { color: var(--px-text-muted); font-size: 13.5px; margin-top: 3px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.datos-lista { list-style: none; margin: 0; padding: 0; }
.datos-lista li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--px-border); font-size: 13.5px; }
.datos-lista li:last-child { border-bottom: 0; }
.datos-lista li > span:first-child { color: var(--px-text-muted); display: inline-flex; align-items: center; gap: 7px; }
.datos-lista li > span:first-child .ico { color: var(--px-teal-dark); }
.datos-lista li > :last-child { text-align: right; font-weight: 600; color: var(--px-ink); word-break: break-word; }

/* Anillo de puntaje */
.anillo-caja { display: flex; align-items: center; gap: 18px; }
.anillo { position: relative; width: 112px; height: 112px; flex-shrink: 0; }
.anillo svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.anillo .fondo { stroke: var(--px-teal-soft); }
.anillo-num { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; line-height: 1; }
.anillo-num b { font-size: 32px; font-weight: 800; letter-spacing: -.03em; color: var(--px-ink); display: block; }
.anillo-num small { font-size: 11px; color: var(--px-text-muted); font-weight: 600; }
.pilares { display: flex; flex-direction: column; gap: 9px; margin-top: 16px; }
.pilar-cab { display: flex; justify-content: space-between; font-size: 12.5px; }
.pilar-cab strong { color: var(--px-ink); }
.pilar-cab span { color: var(--px-text-muted); font-variant-numeric: tabular-nums; }
.pilar-barra { height: 6px; background: var(--px-teal-soft); border-radius: 999px; overflow: hidden; margin-top: 4px; }
.pilar-barra span { display: block; height: 100%; background: var(--px-teal); border-radius: 999px; }
.pilar-txt { font-size: 11.5px; color: var(--px-text-muted); margin-top: 2px; }

/* Linea de tiempo de comunicacion */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li { position: relative; padding: 0 0 18px 42px; }
.timeline li::before { content: ""; position: absolute; left: 15px; top: 30px; bottom: 0; width: 2px; background: var(--px-border); }
.timeline li:last-child { padding-bottom: 0; }
.timeline li:last-child::before { display: none; }
.tl-ico { position: absolute; left: 0; top: 0; width: 32px; height: 32px; border-radius: 10px;
          display: grid; place-items: center; background: var(--px-teal-soft); color: #06655F; }
.tl-ico.wa { background: #E4F6EE; color: #188741; }
.tl-cab { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13.5px; }
.tl-cab strong { color: var(--px-ink); }
.tl-cab time { margin-left: auto; font-size: 12px; color: var(--px-text-muted); white-space: nowrap; }
.tl-nota { margin: 5px 0 0; font-size: 13.5px; color: var(--px-ink); white-space: pre-line;
           background: #FBFDFC; border: 1px solid var(--px-border); border-radius: 10px; padding: 8px 11px; }

/* Ideas para un cliente */
.ideas { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.idea { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; line-height: 1.4; }
.idea .tono { width: 30px; height: 30px; border-radius: 9px; }
/* > div: el texto de la idea, NO el rotulo del boton que va al lado */
.idea > div strong { display: block; color: var(--px-ink); }
.idea > div span { color: var(--px-text-muted); font-size: 12.5px; }
.tabla .badge, .tabla .nivel { white-space: nowrap; }

/* Rejilla de 3 columnas que baja a 1 */
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; align-items: stretch; }
.grid-3 > .panel { margin-bottom: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: stretch; }
.grid-2 > .panel { margin-bottom: 0; }
.fila-paneles { margin-bottom: 20px; }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 900px)  { .grid-2 { grid-template-columns: minmax(0, 1fr); } }

/* Seleccion de periodo / filtros pequenos */
.filtros-linea { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filtros-linea select { width: auto; min-height: 38px; padding-top: 7px; padding-bottom: 7px; font-size: 14px; }

/* Chips de seleccion multiple (audiencias) */
.chips-sel { display: flex; flex-wrap: wrap; gap: 6px; }
.chips-sel label { margin: 0; display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px;
                   border: 1px solid var(--gris-borde); border-radius: 999px; background: #fff;
                   font-size: 13px; font-weight: 600; color: var(--px-ink); cursor: pointer; user-select: none; }
.chips-sel label:hover { background: var(--px-teal-soft); }
.chips-sel input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.chips-sel label:has(input:checked) { background: var(--px-teal-solid); border-color: var(--px-teal-solid); color: #fff; }
.chips-sel label:has(input:focus-visible) { box-shadow: 0 0 0 3px rgba(18, 169, 159, .25); }

/* Cifra grande en tarjeta de texto */
.cifra { font-size: 28px; font-weight: 800; letter-spacing: -.02em; color: var(--px-ink); line-height: 1.1; }
.cifra-lab { font-size: 12.5px; color: var(--px-text-muted); }

/* Cajita de recomendacion (inteligencia) */
.reco { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 14px;
        background: linear-gradient(0deg, #F3FBF9, #F3FBF9); border: 1px solid #CDEBE4; }
.reco .tono { width: 36px; height: 36px; }
.reco p { margin: 0; font-size: 14px; line-height: 1.55; color: var(--px-ink); }
.reco strong { color: var(--px-teal-txt); }

/* Acciones de tabla con iconos */
.acciones-ico { display: inline-flex; gap: 2px; align-items: center; }
.tabla td.acciones .btn-mini { vertical-align: middle; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; z-index: 80;
  transform: translate(-50%, 16px); opacity: 0; transition: opacity .2s, transform .2s;
  background: var(--px-ink); color: #fff; padding: 11px 18px; border-radius: 12px;
  font-size: 14px; font-weight: 600; box-shadow: 0 12px 30px rgba(0, 18, 46, .28);
  max-width: min(92%, 520px); text-align: center;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast-error { background: #8E2F2F; }
.wa-hecho { opacity: .55; }

/* ---------- Icono de categoria (color propio de cada linea) ---------- */
.cat-ico { width: 28px; height: 28px; border-radius: 8px; display: inline-grid; place-items: center; flex-shrink: 0;
           background: color-mix(in srgb, var(--c, #12A99F) 14%, #fff);
           color: color-mix(in srgb, var(--c, #12A99F) 78%, #000); }
.cats-mini { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.cats-mini .cat-ico { width: 26px; height: 26px; }

/* Boton de WhatsApp solo icono: el verde de marca en el icono, no de fondo */
.btn-wa-ico { color: #188741 !important; }
.btn-wa-ico:hover { background: #E4F6EE !important; }

.check-linea { display: flex; align-items: flex-start; gap: 10px; font-weight: 500; margin: 6px 0 0; cursor: pointer; }
.check-linea input { margin-top: 2px; }
.en-linea { display: inline; margin: 0; }
.d-bloque { display: block; }
.txt-sube { color: #0B7A4F; font-weight: 700; }
.txt-baja { color: var(--px-danger-txt); font-weight: 700; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }

.texto-derecha { text-align: right; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.gap-8 { gap: 8px; }
.ancho-auto { width: auto !important; }
