/* ============================================================
   Manda Web — Sistema de diseño (misma marca que la extensión)
   púrpura #4C4DC3 · lima #E7F253 · navy #27334D · hueso #FFFDF4
   ground #F1F2FA · Urbane
   ============================================================ */

@font-face { font-family: 'Urbane'; src: url('/fonts/Urbane-Medium.woff2') format('woff2'); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'Urbane'; src: url('/fonts/Urbane-Demi-Bold.woff2') format('woff2'); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: 'Urbane'; src: url('/fonts/Urbane-Bold.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'Urbane'; src: url('/fonts/Urbane-Heavy.woff2') format('woff2'); font-weight: 800; font-style: normal; font-display: swap; }

:root {
  --purpura: #4C4DC3;
  --purpura-600: #4142B2;
  --purpura-050: #EEEEFB;
  --lima: #E7F253;
  --navy: #27334D;
  --hueso: #FFFDF4;
  --ground: #F1F2FA;
  --ink: #27334D;
  --muted: #727B90;
  --line: #E7E9F4;
  --ok: #22A565;
  --sh-sm: 0 1px 2px rgba(39,51,77,.06), 0 1px 3px rgba(39,51,77,.05);
  --sh-md: 0 6px 22px rgba(39,51,77,.10);
  --sh-lg: 0 22px 55px rgba(39,51,77,.20);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Urbane', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink);
  background: var(--ground);
  -webkit-font-smoothing: antialiased;
}

/* ---------- App shell ---------- */
.app { display: flex; height: 100vh; }

/* Barra lateral de marca */
.sidebar {
  width: 84px;
  background: var(--navy);
  color: var(--hueso);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 0;
  gap: 22px;
  flex-shrink: 0;
}
.sidebar .brand {
  width: 46px; height: 46px; border-radius: 13px;
  background: var(--lima);
  display: grid; place-items: center;
  overflow: hidden;
}
.sidebar .brand img { width: 100%; height: 100%; object-fit: cover; }
.sidebar .nav { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.sidebar .nav button {
  width: 46px; height: 46px; border: 0; border-radius: 13px;
  background: transparent; color: rgba(255,253,244,.62);
  cursor: pointer; display: grid; place-items: center;
  transition: background .15s, color .15s;
}
.sidebar .nav button svg { width: 22px; height: 22px; }
.sidebar .nav button:hover { background: rgba(255,255,255,.08); color: var(--hueso); }
.sidebar .nav button.active { background: var(--purpura); color: var(--hueso); }
.sidebar .spacer { flex: 1; }
.sidebar .status-dot {
  width: 11px; height: 11px; border-radius: 50%;
  background: #E23D6D; box-shadow: 0 0 0 4px rgba(226,61,109,.18);
  transition: background .2s, box-shadow .2s;
}
.sidebar .status-dot.on { background: var(--lima); box-shadow: 0 0 0 4px rgba(231,242,83,.22); }

/* ---------- Área principal ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 68px; flex-shrink: 0;
  background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; padding: 0 24px;
}
.topbar .logo { height: 30px; }
.topbar h1 { font-size: 17px; font-weight: 700; margin: 0; }
.topbar .pill {
  margin-left: auto; font-size: 12.5px; font-weight: 700;
  padding: 7px 13px; border-radius: 999px;
  background: var(--purpura-050); color: var(--purpura);
  display: inline-flex; align-items: center; gap: 7px;
}
.topbar .pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.topbar .pill.connected { background: rgba(34,165,101,.12); color: var(--ok); }

.content { flex: 1; min-height: 0; display: flex; }

/* ---------- Pantalla Conectar (QR) ---------- */
.connect {
  flex: 1; display: flex; align-items: center; justify-content: center; padding: 32px;
}
.connect-card {
  width: 100%; max-width: 880px;
  background: #fff; border: 1px solid var(--line);
  border-radius: 24px; box-shadow: var(--sh-lg);
  display: grid; grid-template-columns: 1.05fr .95fr; overflow: hidden;
}
.connect-copy { padding: 46px 44px; }
.connect-copy .kicker {
  font-size: 12px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase;
  color: var(--purpura);
}
.connect-copy h2 { font-size: 30px; line-height: 1.15; margin: 12px 0 14px; font-weight: 800; }
.connect-copy p { color: var(--muted); font-size: 15px; line-height: 1.6; margin: 0 0 26px; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 16px; }
.steps li { display: flex; gap: 13px; align-items: flex-start; font-size: 14.5px; }
.steps .n {
  width: 26px; height: 26px; border-radius: 8px; flex-shrink: 0;
  background: var(--purpura-050); color: var(--purpura);
  font-weight: 800; font-size: 13px; display: grid; place-items: center;
}
.steps b { font-weight: 700; }

.connect-qr {
  background: var(--ground);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px; gap: 18px; border-left: 1px solid var(--line);
}
.qr-frame {
  width: 300px; height: 300px; border-radius: 20px; background: #fff;
  box-shadow: var(--sh-md); display: grid; place-items: center; position: relative;
  padding: 14px;
}
.qr-frame img { width: 100%; height: 100%; border-radius: 10px; image-rendering: pixelated; }
.qr-frame .spinner {
  width: 44px; height: 44px; border-radius: 50%;
  border: 4px solid var(--line); border-top-color: var(--purpura);
  animation: spin 1s linear infinite;
}
.qr-frame .ok-badge { text-align: center; color: var(--ok); }
.qr-frame .ok-badge svg { width: 64px; height: 64px; }
.qr-hint { font-size: 13px; color: var(--muted); font-weight: 600; text-align: center; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Bandeja ---------- */
.inbox { flex: 1; display: flex; min-height: 0; }
.chat-list {
  width: 340px; flex-shrink: 0; border-right: 1px solid var(--line);
  background: #fff; overflow-y: auto;
}
.chat-list .search { padding: 14px; position: sticky; top: 0; background: #fff; z-index: 1; }
.chat-list .search input {
  width: 100%; border: 1.5px solid var(--line); border-radius: 11px;
  padding: 10px 13px; font: inherit; font-size: 14px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.chat-list .search input:focus { border-color: var(--purpura); box-shadow: 0 0 0 3px rgba(76,77,195,.16); }
.chat-row {
  display: flex; gap: 12px; align-items: center; padding: 12px 15px;
  cursor: pointer; border-bottom: 1px solid var(--ground);
  transition: background .12s;
}
.chat-row:hover { background: var(--ground); }
.chat-row.active { background: var(--purpura-050); }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, #5859D4, var(--purpura));
  color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 16px;
  position: relative; overflow: hidden;
}
.avatar .av-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.chat-row .meta { min-width: 0; flex: 1; }
.chat-row .meta .name { font-weight: 700; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-row .meta .last { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-row .chat-right { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; margin-left: auto; flex-shrink: 0; }
.chat-row .time { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.chat-row.active .time { color: var(--purpura); }
.chat-row .badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--purpura); color: #fff; font-size: 11px; font-weight: 800;
  display: grid; place-items: center;
}

/* Panel de conversación */
.thread { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--ground); }
.thread-full { position: relative; }
.th-tag.active { background: var(--purpura); color: #fff; border-color: var(--purpura); }
/* #13 Barra de búsqueda en el chat */
.msg-search { display: flex; align-items: center; gap: 8px; padding: 8px 14px; background: #fff; border-bottom: 1px solid var(--line); color: var(--muted); }
.msg-search input { flex: 1; border: none; outline: none; font: inherit; font-size: 14px; color: var(--ink); background: transparent; }
.msg-search .ms-count { font-size: 12px; color: var(--muted); min-width: 30px; text-align: right; }
.msg-search .ms-nav, .msg-search .ms-x { border: none; background: var(--ground); width: 28px; height: 28px; border-radius: 7px; cursor: pointer; font-size: 12px; color: var(--ink); }
.msg-search .ms-nav:hover, .msg-search .ms-x:hover { background: var(--purpura-050); color: var(--purpura); }
.msg-search .ms-x { font-size: 18px; }
.bubble.search-hit { outline: 2px solid var(--lima); }
.bubble.search-current { outline: 3px solid var(--purpura); box-shadow: 0 0 0 4px rgba(76,77,195,.15); }
.chat-list .name .pin-ic { font-size: 11px; }
.thread-head {
  height: 62px; flex-shrink: 0; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px; padding: 0 18px;
}
.thread-head .name { font-weight: 700; }
.thread-head { position: relative; }
.thread-labels { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.lbl-chip { font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: 999px; color: #fff; }
.th-tag { margin-left: auto; width: 38px; height: 38px; border: 1.5px solid var(--line); background: #fff; border-radius: 10px; cursor: pointer; display: grid; place-items: center; color: var(--muted); }
.th-tag:hover { border-color: var(--purpura); color: var(--purpura); }
.th-tag svg { width: 19px; height: 19px; }
.tag-pop { position: absolute; top: 54px; right: 14px; width: 260px; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--m-sh-md, var(--sh-md)); padding: 8px; z-index: 30; }
.tag-pop .tp-row { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; cursor: pointer; }
.tag-pop .tp-row:hover { background: var(--ground); }
.tag-pop .tp-dot { width: 13px; height: 13px; border-radius: 50%; flex-shrink: 0; }
.tag-pop .tp-name { flex: 1; font-weight: 700; font-size: 13.5px; }
.tag-pop .tp-check { width: 18px; height: 18px; border-radius: 5px; border: 2px solid #C7CBE0; display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 800; }
.tag-pop .tp-row.on .tp-check { background: var(--purpura); border-color: var(--purpura); }
.tag-pop .tp-new { width: 100%; border: 1.5px dashed var(--line); background: #fff; color: var(--purpura); font-weight: 700; border-radius: 9px; padding: 9px; cursor: pointer; font: inherit; font-size: 13px; margin-top: 4px; }
.tag-pop .tp-new:hover { border-color: var(--purpura); background: var(--purpura-050); }
.chat-row .row-dots { display: flex; gap: 3px; margin-top: 3px; }
.chat-row .row-dot { width: 8px; height: 8px; border-radius: 50%; }

/* Programados dentro del modal por-chat */
.sched-row { display: flex; align-items: flex-start; gap: 10px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 7px; background: var(--ground); }
.sched-row .sr-body { flex: 1; min-width: 0; font-size: 13px; }
.sched-row .sr-body b { color: var(--purpura); }
.sched-row .sr-body > div { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sched-row .sr-del { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 15px; }
.sched-row .sr-del:hover { color: #E23D6D; }

/* Bloques de mensaje del agendado */
.sched-block { border: 1.5px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; background: #FBFBFE; }
.sched-block .sb-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.sched-block .sb-num { font-size: 12px; font-weight: 800; color: var(--purpura); background: var(--purpura-050); border-radius: 6px; padding: 2px 8px; }
.sched-block .sb-remove { margin-left: auto; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 15px; }
.sched-block .sb-remove:hover { color: #E23D6D; }
.sched-block textarea { width: 100%; border: 1.5px solid var(--line); border-radius: 10px; padding: 9px 11px; font: inherit; font-size: 14px; outline: none; resize: vertical; }
.sched-block textarea:focus { border-color: var(--purpura); box-shadow: 0 0 0 3px rgba(76,77,195,.16); }
.sched-block .sb-attachrow { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.sched-block .sb-attach { border: 1.5px solid var(--line); background: #fff; border-radius: 9px; padding: 7px 12px; cursor: pointer; font: inherit; font-size: 12.5px; font-weight: 700; color: var(--purpura); display: inline-flex; align-items: center; gap: 6px; }
.sched-block .sb-attach:hover { border-color: var(--purpura); background: var(--purpura-050); }
.sched-block .sb-filename { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.sched-block .sb-filename b { color: var(--ink); }
.sched-block .sb-clearfile { border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.sched-block .sb-clearfile:hover { color: #E23D6D; }
.sched-block .sb-prev img, .sched-block .sb-prev video { max-width: 140px; border-radius: 8px; margin-top: 8px; display: block; }
.sched-block .sb-loaded { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 700; color: var(--ok); }
.up-bar { height: 8px; border-radius: 999px; background: var(--ground); overflow: hidden; margin-top: 8px; }
.up-bar > i { display: block; height: 100%; background: var(--purpura); border-radius: 999px; transition: width .15s; }
.up-status { font-size: 12px; color: var(--muted); font-weight: 700; margin-top: 5px; }

/* Barra de carga del composer (adjuntar en el chat) */
.composer { position: relative; }
.comp-upload { position: absolute; left: 16px; right: 76px; bottom: 60px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--sh-md); padding: 11px 14px; z-index: 25; }
.comp-upload .cu-name { font-size: 13px; font-weight: 700; margin-bottom: 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.comp-upload .up-bar { margin-top: 0; }
.thread-body { flex: 1; overflow-y: auto; padding: 22px; display: flex; flex-direction: column; gap: 9px; }
.bubble {
  position: relative;
  max-width: 62%; padding: 8px 12px 5px; border-radius: 14px; font-size: 14px; line-height: 1.4;
  box-shadow: var(--sh-sm); word-wrap: break-word; overflow-wrap: anywhere;
  user-select: text; -webkit-user-select: text;
}
/* Botón de opciones del mensaje (⋮): flota AL COSTADO de la burbuja (fuera),
   así nunca pisa el contenido. A la izq. en los propios, a la der. en entrantes. */
.bubble .b-menu-btn { position: absolute; top: 50%; transform: translateY(-50%); border: none; cursor: pointer; font-size: 17px; line-height: 1; width: 26px; height: 26px; border-radius: 50%; color: var(--purpura); background: var(--purpura-050); opacity: .35; transition: opacity .12s, background .12s; display: flex; align-items: center; justify-content: center; }
.bubble.out .b-menu-btn { left: -36px; right: auto; }
.bubble.in .b-menu-btn { right: -36px; left: auto; }
.bubble:hover .b-menu-btn { opacity: .9; }
.bubble .b-menu-btn:hover { opacity: 1; background: var(--purpura); color: #fff; }
.msg-menu { position: fixed; z-index: 60; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--sh-lg); padding: 5px; min-width: 190px; }
.msg-menu .mm-item { padding: 9px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--ink); white-space: nowrap; }
.msg-menu .mm-item:hover { background: var(--purpura-050); }
.msg-menu .mm-item.danger { color: #d43b52; }
.msg-menu .mm-item.danger:hover { background: #fdecef; }
/* Visor de imágenes (lightbox) */
.lightbox { position: fixed; inset: 0; z-index: 90; background: rgba(20,25,40,.85); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; padding: 40px; }
.lightbox .lb-img { max-width: 92%; max-height: 92%; border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.5); object-fit: contain; }
.lightbox .lb-close { position: absolute; top: 20px; right: 24px; width: 44px; height: 44px; border: none; border-radius: 50%; background: rgba(255,255,255,.15); color: #fff; font-size: 26px; line-height: 1; cursor: pointer; }
.lightbox .lb-close:hover { background: rgba(255,255,255,.3); }
/* Barra de grabación de nota de voz */
.rec-bar { position: absolute; inset: 8px 12px; display: flex; align-items: center; gap: 10px; background: #fff; border: 1.5px solid var(--purpura); border-radius: 14px; padding: 8px 12px; box-shadow: var(--sh-md); z-index: 5; }
.rec-bar .rec-dot { width: 11px; height: 11px; border-radius: 50%; background: #e23b52; animation: recpulse 1s infinite; }
@keyframes recpulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }
.rec-bar .rec-time { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }
.rec-bar .rec-hint { color: var(--muted); font-size: 12.5px; }
.rec-bar .rec-flex { flex: 1; }
.rec-bar button { border: none; cursor: pointer; border-radius: 50%; width: 40px; height: 40px; font-size: 16px; }
.rec-bar .rec-cancel { background: #f1f2fa; }
.rec-bar .rec-cancel:hover { background: #fdecef; }
.rec-bar .rec-send { background: var(--purpura); color: #fff; font-size: 17px; }

/* ===== Info de contacto (drawer) ===== */
.ci-drawer { position: fixed; top: 0; right: 0; width: 360px; max-width: 92vw; height: 100%; background: var(--ground); border-left: 1px solid var(--line); box-shadow: -8px 0 30px rgba(30,38,58,.12); z-index: 70; display: flex; flex-direction: column; }
.ci-drawer.hidden { display: none; }
.ci-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px; background: #fff; border-bottom: 1px solid var(--line); font-weight: 800; color: var(--ink); }
.ci-close { border: none; background: #f1f2fa; width: 34px; height: 34px; border-radius: 50%; font-size: 20px; cursor: pointer; }
.ci-body { flex: 1; overflow-y: auto; padding: 18px; }
.ci-card { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 0 20px; }
.ci-avatar { position: relative; width: 92px; height: 92px; border-radius: 50%; background: var(--purpura); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 32px; font-weight: 800; overflow: hidden; }
.ci-avatar .av-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ci-name { font-size: 18px; font-weight: 800; color: var(--ink); text-align: center; display: inline-flex; align-items: center; gap: 6px; justify-content: center; }
.ci-name-btn { border: none; background: transparent; color: var(--muted); cursor: pointer; font-size: 13px; padding: 2px 4px; border-radius: 6px; line-height: 1; }
.ci-name-btn:hover { background: var(--ground); color: var(--purpura); }
.ci-name-edit { display: flex; flex-direction: column; gap: 8px; align-items: stretch; margin: 2px auto 0; max-width: 260px; }
.ci-name-edit input { width: 100%; height: 38px; padding: 0 12px; border: 1.5px solid var(--purpura); border-radius: 10px; font: inherit; font-size: 15px; font-weight: 700; text-align: center; color: var(--ink); }
.ci-name-actions { display: flex; gap: 8px; justify-content: center; }
.ci-name-actions button { flex: 1; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font: inherit; font-size: 12.5px; font-weight: 700; cursor: pointer; }
.ci-name-actions button[data-act="save-name"], .ci-name-actions button[data-act="save-phone"] { background: var(--purpura); border-color: var(--purpura); color: #fff; }
.ci-phone-edit { display: flex; flex-direction: column; gap: 8px; align-items: stretch; margin: 6px auto 0; max-width: 260px; }
.ci-phone-edit input { width: 100%; height: 38px; padding: 0 12px; border: 1.5px solid var(--purpura); border-radius: 10px; font: inherit; font-size: 14px; text-align: center; color: var(--ink); }
.ci-add-phone { margin: 6px auto 0; display: block; border: 1.5px dashed var(--line); background: transparent; color: var(--purpura); border-radius: 10px; padding: 8px 14px; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.ci-add-phone:hover { border-color: var(--purpura); background: var(--purpura-050); }
.ci-number .ci-name-btn { margin-left: 4px; }
.ci-number { color: var(--muted); font-size: 13.5px; }
.ci-badge { font-size: 11px; font-weight: 700; color: var(--purpura); background: var(--purpura-050); padding: 2px 10px; border-radius: 999px; }
.ci-section { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 14px; }
.ci-sec-head { display: flex; align-items: center; justify-content: space-between; font-weight: 800; color: var(--ink); font-size: 14px; margin-bottom: 10px; }
.ci-add-btn { border: none; background: var(--purpura-050); color: var(--purpura); font-weight: 700; font-size: 12px; padding: 5px 10px; border-radius: 8px; cursor: pointer; }
.ci-empty { color: var(--muted); font-size: 12.5px; padding: 4px 2px; }
.ci-note { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; background: var(--ground); border-radius: 10px; margin-bottom: 7px; }
.ci-note-text { flex: 1; font-size: 13px; color: var(--ink); white-space: pre-wrap; word-break: break-word; }
.ci-note-actions { display: flex; gap: 4px; }
.ci-note-actions button { border: none; background: transparent; cursor: pointer; font-size: 13px; padding: 2px 4px; border-radius: 6px; }
.ci-note-actions button:hover { background: rgba(0,0,0,.06); }
.ci-note.editing { flex-direction: column; }
.ci-note-edit { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 7px; font: inherit; font-size: 13px; resize: vertical; }
.ci-add-note { display: flex; flex-direction: column; gap: 7px; margin-top: 8px; }
.ci-add-note textarea { border: 1px solid var(--line); border-radius: 10px; padding: 9px; font: inherit; font-size: 13px; resize: vertical; }
.ci-add-note button { align-self: flex-end; border: none; background: var(--purpura); color: #fff; font-weight: 700; padding: 8px 14px; border-radius: 9px; cursor: pointer; font-size: 12.5px; }
.ci-field { display: flex; gap: 7px; align-items: center; margin-bottom: 7px; }
.ci-field-name { width: 38%; border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; font: inherit; font-size: 12.5px; font-weight: 700; background: var(--ground); }
.ci-field-value { flex: 1; border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; font: inherit; font-size: 12.5px; }
.ci-field button { border: none; background: transparent; cursor: pointer; padding: 4px; border-radius: 6px; }
.ci-field button:hover { background: #fdecef; }

/* ===== Reenviar (modal) ===== */
.fwd-search { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font: inherit; margin-bottom: 10px; }
.fwd-list { max-height: 46vh; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.fwd-row { display: flex; align-items: center; gap: 11px; padding: 9px 8px; border-radius: 10px; cursor: pointer; }
.fwd-row:hover { background: var(--ground); }
.fwd-row input { width: 18px; height: 18px; accent-color: var(--purpura); }
.fwd-av { width: 36px; height: 36px; border-radius: 50%; background: var(--purpura); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.fwd-name { font-weight: 600; color: var(--ink); font-size: 14px; }

/* ===== Selección de mensajes ===== */
.sel-toolbar { position: absolute; inset: 0; display: flex; align-items: center; gap: 12px; padding: 0 18px; background: #fff; z-index: 6; }
.sel-toolbar .sel-x { border: none; background: #f1f2fa; width: 34px; height: 34px; border-radius: 50%; font-size: 20px; cursor: pointer; }
.sel-toolbar .sel-count { font-weight: 700; color: var(--ink); }
.sel-toolbar .sel-flex { flex: 1; }
.sel-toolbar .sel-fwd { border: none; background: var(--purpura); color: #fff; font-weight: 700; padding: 9px 16px; border-radius: 10px; cursor: pointer; }
.bubble.selecting { cursor: pointer; }
.bubble.selecting .b-check { position: absolute; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--purpura); background: #fff; color: #fff; font-size: 12px; display: flex; align-items: center; justify-content: center; }
.bubble.selecting.out .b-check { left: -32px; }
.bubble.selecting.in .b-check { right: -32px; }
.bubble.selecting.selected .b-check { background: var(--purpura); }
.bubble.selecting.selected { outline: 2px solid var(--purpura); }

/* ===== Bandeja de stickers ===== */
.sticker-pop { position: absolute; left: 16px; right: 76px; bottom: 60px; max-height: 300px; overflow-y: auto; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--sh-md); padding: 12px; z-index: 25; display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 10px; }
.sticker-pop.hidden { display: none; }
.sticker-pop .stk { width: 100%; aspect-ratio: 1; object-fit: contain; cursor: pointer; border-radius: 8px; padding: 4px; transition: background .12s; }
.sticker-pop .stk:hover { background: var(--purpura-050); }
.sticker-pop { display: block; }
.sticker-pop .stk-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.sticker-pop .stk-tabs button { flex: 1; border: 1px solid var(--line); background: var(--ground); border-radius: 9px; padding: 7px; font: inherit; font-size: 12.5px; font-weight: 700; color: var(--muted); cursor: pointer; }
.sticker-pop .stk-tabs button.on { background: var(--purpura); color: #fff; border-color: var(--purpura); }
.sticker-pop .stk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 10px; }
.sticker-pop .stk-empty { grid-column: 1 / -1; text-align: center; color: var(--muted); font-size: 12.5px; padding: 20px 8px; line-height: 1.5; }
.sticker-pop .stk-pick { position: relative; cursor: pointer; border-radius: 8px; padding: 4px; }
.sticker-pop .stk-pick img { width: 100%; aspect-ratio: 1; object-fit: contain; }
.sticker-pop .stk-pick .stk-star { position: absolute; top: 2px; right: 2px; font-size: 15px; color: #cbd0e0; text-shadow: 0 0 3px #fff; }
.sticker-pop .stk-pick.saved { background: var(--purpura-050); }
.sticker-pop .stk-pick.saved .stk-star { color: #f5b301; }

/* ===== Responder (barra + cita en burbuja) ===== */
.reply-bar { position: absolute; left: 12px; right: 12px; bottom: 60px; display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--purpura); border-radius: 12px; padding: 8px 12px; box-shadow: var(--sh-md); z-index: 6; }
.reply-bar .rb-body { flex: 1; min-width: 0; }
.reply-bar .rb-who { font-weight: 800; font-size: 12.5px; color: var(--purpura); }
.reply-bar .rb-text { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-bar .rb-x { border: none; background: #f1f2fa; width: 30px; height: 30px; border-radius: 50%; font-size: 17px; cursor: pointer; flex: none; }
.bubble .b-quote { border-left: 3px solid var(--purpura); background: rgba(76,77,195,.07); border-radius: 6px; padding: 5px 8px; margin-bottom: 5px; font-size: 12.5px; }
.bubble.out .b-quote { border-left-color: rgba(255,255,255,.8); background: rgba(255,255,255,.16); }
.bubble .b-quote b { display: block; font-size: 11.5px; opacity: .95; }
.bubble .b-quote span { opacity: .8; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bubble .b-quote { cursor: pointer; }
.bubble .b-author { cursor: pointer; }
.bubble .b-author:hover { text-decoration: underline; }
/* Resaltado al saltar a un mensaje citado */
.bubble.flash { animation: bflash 1.4s ease; }
@keyframes bflash { 0%, 40% { box-shadow: 0 0 0 3px var(--lima); } 100% { box-shadow: var(--sh-sm); } }
/* Menú de miembro: encabezado con el nombre */
.msg-menu .mm-head { padding: 7px 12px 8px; font-weight: 800; font-size: 12.5px; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 4px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Flecha ir al final */
.scroll-bottom { position: absolute; right: 22px; bottom: 86px; width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: #fff; color: var(--purpura); box-shadow: var(--sh-md); cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 8; transition: opacity .15s, transform .15s; }
.scroll-bottom:hover { background: var(--purpura); color: #fff; }
.scroll-bottom.hidden { opacity: 0; transform: translateY(8px); pointer-events: none; }
.scroll-bottom svg { width: 20px; height: 20px; }

/* ===== Info de contacto: media / docs / enlaces ===== */
.ci-media-sec { padding: 12px; }
.ci-media-btns { display: flex; gap: 8px; }
.ci-mbtn { flex: 1; border: 1px solid var(--line); background: var(--ground); border-radius: 12px; padding: 10px 4px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.ci-mbtn b { font-size: 17px; color: var(--ink); }
.ci-mbtn span { font-size: 11.5px; color: var(--muted); }
.ci-mbtn.on { border-color: var(--purpura); background: var(--purpura-050); }
.ci-mbtn.on b, .ci-mbtn.on span { color: var(--purpura); }
.ci-media-view { margin-top: 12px; }
.ci-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.ci-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; cursor: pointer; }
.ci-doc-row, .ci-link-row { display: block; padding: 9px 11px; background: var(--ground); border-radius: 10px; margin-bottom: 6px; font-size: 12.5px; color: var(--ink); text-decoration: none; word-break: break-all; }
.ci-link-row { color: var(--purpura); }
.ci-doc-row:hover, .ci-link-row:hover { background: var(--purpura-050); }
.ci-doc-row span { font-weight: 600; }
.bubble.in { background: #fff; align-self: flex-start; border-bottom-left-radius: 5px; }
.bubble.out { background: var(--purpura); color: var(--hueso); align-self: flex-end; border-bottom-right-radius: 5px; }
/* Remitente (grupos) */
.bubble .b-author { font-size: 12px; font-weight: 800; color: var(--purpura); margin-bottom: 2px; }
.bubble.out .b-author { color: rgba(255,255,255,.9); }
/* Hora del mensaje */
.bubble .b-time { display: block; text-align: right; font-size: 10.5px; opacity: .55; margin-top: 3px; user-select: none; }
.bubble.out .b-time { color: rgba(255,255,255,.85); opacity: .85; }
/* Vistos (checks) */
.b-ck { font-weight: 700; letter-spacing: -3px; margin-left: 3px; padding-right: 2px; }
.b-ck.read { color: #48c6ff; }
.chat-list .last .b-ck { letter-spacing: -3px; margin-right: 1px; opacity: .7; }
.chat-list .last .b-ck.read { color: #2aa6e0; opacity: 1; }
/* Enlaces dentro de mensajes */
.bubble .b-link { color: var(--purpura); text-decoration: underline; word-break: break-all; }
.bubble.out .b-link { color: #fff; }
/* Tarjeta de documento estilo WhatsApp */
.bubble .b-doc { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.bubble .b-doc-ic { font-size: 26px; line-height: 1; flex: none; }
.bubble .b-doc-meta { flex: 1; min-width: 0; }
.bubble .b-doc-name { font-weight: 700; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bubble .b-doc-sub { font-size: 11.5px; opacity: .6; margin-top: 1px; }
.bubble.out .b-doc-sub { opacity: .8; }
.bubble .b-doc-bar { height: 4px; border-radius: 3px; margin-top: 6px; overflow: hidden; background: rgba(0,0,0,.1); display: none; }
.bubble.out .b-doc-bar { background: rgba(255,255,255,.25); }
.bubble .b-doc-bar.on { display: block; }
.bubble .b-doc-bar i { display: block; height: 100%; width: 0; background: var(--purpura); transition: width .2s ease; }
.bubble.out .b-doc-bar i { background: #fff; }
.bubble .b-doc-dl { flex: none; width: 34px; height: 34px; border: none; border-radius: 50%; cursor: pointer; font-size: 15px; background: rgba(76,77,195,.1); color: var(--purpura); }
.bubble .b-doc-dl:hover { background: rgba(76,77,195,.2); }
.bubble.out .b-doc-dl { background: rgba(255,255,255,.22); color: #fff; }
.bubble .b-doc-dl:disabled { cursor: default; opacity: .8; }
.load-more { display: block; margin: 4px auto 12px; padding: 8px 16px; border: 1px solid var(--line); background: #fff; border-radius: 999px; font: inherit; font-size: 12.5px; font-weight: 700; color: var(--purpura); cursor: pointer; box-shadow: var(--sh-sm); }
.load-more:hover { background: var(--purpura-050); border-color: var(--purpura); }
.load-more-chats { display: block; width: calc(100% - 24px); margin: 10px 12px 16px; padding: 11px; border: 1.5px dashed var(--line); background: #fff; border-radius: 12px; font: inherit; font-size: 13px; font-weight: 700; color: var(--purpura); cursor: pointer; }
.load-more-chats:hover { border-color: var(--purpura); background: var(--purpura-050); }
.thread-empty { margin: auto; text-align: center; color: var(--muted); }
.thread-empty svg { width: 72px; height: 72px; opacity: .5; margin-bottom: 12px; }
.composer {
  flex-shrink: 0; background: #fff; border-top: 1px solid var(--line);
  padding: 12px 16px; display: flex; gap: 10px; align-items: center;
}
.composer input {
  flex: 1; border: 1.5px solid var(--line); border-radius: 12px;
  padding: 11px 15px; font: inherit; font-size: 14.5px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.composer input:focus { border-color: var(--purpura); box-shadow: 0 0 0 3px rgba(76,77,195,.16); }
.composer button {
  width: 46px; height: 46px; border: 0; border-radius: 12px; cursor: pointer;
  background: var(--purpura); color: #fff; display: grid; place-items: center;
  box-shadow: 0 2px 10px rgba(76,77,195,.30); transition: transform .12s, box-shadow .12s;
}
.composer button:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(76,77,195,.34); }
.composer button:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.composer button svg { width: 20px; height: 20px; }

.hidden { display: none !important; }

/* ---------- Pantalla de carga (sincronización inicial) ---------- */
.sync-screen { position: fixed; inset: 0; z-index: 80; background: var(--ground); display: flex; align-items: center; justify-content: center; padding: 32px; }
.sync-card { width: 100%; max-width: 440px; background: #fff; border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--sh-lg); padding: 40px 38px; text-align: center; }
.sync-logo { width: 66px; height: 66px; border-radius: 18px; background: var(--lima); margin: 0 auto 22px; display: grid; place-items: center; overflow: hidden; }
.sync-logo img { width: 100%; height: 100%; object-fit: cover; }
.sync-card h2 { font-size: 22px; font-weight: 800; margin: 0 0 10px; }
.sync-card p { color: var(--muted); font-size: 14px; line-height: 1.55; margin: 0 0 26px; }
.sync-bar { height: 12px; border-radius: 999px; background: var(--ground); overflow: hidden; margin-bottom: 12px; }
.sync-bar > i { display: block; height: 100%; background: linear-gradient(90deg, #5859D4, var(--purpura)); border-radius: 999px; transition: width .4s ease; min-width: 6%; }
.sync-pct { font-size: 15px; font-weight: 800; color: var(--purpura); }

/* ---------- CRM · Kanban ---------- */
.crm { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.crm-head {
  display: flex; align-items: flex-end; gap: 16px;
  padding: 22px 26px 16px;
}
.crm-head h2 { margin: 0; font-size: 21px; font-weight: 800; }
.crm-head p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }
.crm-actions { margin-left: auto; display: flex; gap: 10px; }

.btn-primary, .btn-ghost, .btn-danger-ghost {
  font: inherit; font-weight: 700; font-size: 13.5px; cursor: pointer;
  border-radius: 11px; padding: 10px 16px; border: 1.5px solid transparent;
  transition: transform .12s, box-shadow .12s, background .12s, border-color .12s;
}
.btn-primary { background: var(--purpura); color: var(--hueso); box-shadow: 0 2px 10px rgba(76,77,195,.28); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(76,77,195,.32); }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: #C7CBE0; background: var(--ground); }
.btn-danger-ghost { background: #fff; color: #E23D6D; border-color: rgba(226,61,109,.3); }
.btn-danger-ghost:hover { background: rgba(226,61,109,.08); }

/* Barra de embudos (tabs) */
.crm-boards { display: flex; gap: 8px; padding: 0 26px 12px; flex-wrap: wrap; align-items: center; }
.crm-tab { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 14px; font: inherit; font-size: 13px; font-weight: 700; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; gap: 7px; }
.crm-tab.on { background: var(--purpura); color: #fff; border-color: var(--purpura); }
.crm-tab.add { border-style: dashed; color: var(--purpura); }
.crm-tab .crm-tab-edit { opacity: .85; font-size: 12px; cursor: pointer; }
.crm-tab .crm-tab-edit:hover { opacity: 1; }
/* Layout: panel de chats + tablero */
.crm-main { flex: 1; min-height: 0; display: flex; gap: 0; overflow: hidden; }
.crm-chats { width: 250px; flex-shrink: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: #fff; padding: 12px; gap: 10px; }
.crm-chat-search { border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; font: inherit; font-size: 13px; }
.crm-chat-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; }
.crm-chat { display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: 10px; cursor: grab; }
.crm-chat[draggable="true"]:hover { background: var(--purpura-050); }
.crm-chat.dragging { opacity: .5; }
.crm-chat.used { opacity: .5; cursor: default; }
.crm-chat-av { position: relative; width: 32px; height: 32px; flex: none; border-radius: 50%; background: var(--purpura); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; overflow: hidden; }
.crm-chat-av img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.crm-chat-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.crm-chat-name { min-width: 0; font-size: 13px; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-chat-last { min-width: 0; font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-chat-tag { font-size: 10px; color: #22A565; font-weight: 800; }
/* Popup de chat (abre el chat real dentro del embudo) */
.chat-popup { position: fixed; inset: 0; z-index: 38; background: rgba(20,25,40,.5); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; padding: 4vh 4vw; }
.chat-popup.hidden { display: none; }
.chat-popup-inner { position: relative; width: 100%; max-width: 900px; height: 100%; max-height: 92vh; background: var(--ground); border-radius: 18px; overflow: hidden; box-shadow: 0 24px 70px rgba(0,0,0,.4); display: flex; flex-direction: column; }
.chat-popup-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-popup-body > .thread-full { flex: 1; min-height: 0; }
.chat-popup-close { position: absolute; top: 14px; right: 14px; z-index: 6; width: 34px; height: 34px; border: none; border-radius: 50%; background: #f1f2fa; color: var(--ink); font-size: 20px; line-height: 1; cursor: pointer; }
.chat-popup-close:hover { background: #e4e6f2; }
/* Dejar lugar para el botón cerrar en el header del chat dentro del popup */
.chat-popup-body .thread-head { padding-right: 54px; }
.crm-chat-empty { color: var(--muted); font-size: 12.5px; padding: 12px; text-align: center; }
.board {
  flex: 1; min-height: 0; display: flex; gap: 16px; overflow-x: auto;
  padding: 6px 26px 26px; align-items: flex-start;
}
.column {
  width: 288px; flex-shrink: 0; background: #fff; border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--sh-sm); display: flex; flex-direction: column;
  max-height: 100%; overflow: hidden;
}
.column-head {
  display: flex; align-items: center; gap: 9px; padding: 13px 14px 12px;
  border-bottom: 1px solid var(--ground); position: relative;
}
.column-head .bar { width: 5px; height: 20px; border-radius: 3px; flex-shrink: 0; }
.column-head .title { font-weight: 800; font-size: 14.5px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.column-head .count {
  font-size: 12px; font-weight: 800; color: var(--muted);
  background: var(--ground); border-radius: 999px; padding: 2px 9px; min-width: 24px; text-align: center;
}
.column-head .edit {
  border: 0; background: transparent; cursor: pointer; color: var(--muted);
  width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center;
}
.column-head .edit:hover { background: var(--ground); color: var(--ink); }
.column-head .edit svg { width: 16px; height: 16px; }
.column-body {
  padding: 10px; display: flex; flex-direction: column; gap: 9px; overflow-y: auto;
  min-height: 60px; flex: 1;
}
.column-body.drop-hint { background: var(--purpura-050); }

.kcard {
  background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--purpura);
  border-radius: 11px; padding: 11px 12px; cursor: grab; box-shadow: var(--sh-sm);
  transition: box-shadow .12s, transform .12s;
}
.kcard:hover { box-shadow: var(--sh-md); }
.kcard.dragging { opacity: .5; }
/* Hueco de inserción al arrastrar un chat a una posición de la columna */
.kcard-ph { height: 46px; border: 2px dashed var(--purpura); background: var(--purpura-050);
  border-radius: 11px; margin: 2px 0; box-sizing: border-box; }
.kcard .kname { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.kcard .kavatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, #5859D4, var(--purpura));
  color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 12px;
}
.kcard .knum { font-size: 12.5px; color: var(--muted); margin-top: 5px; margin-left: 36px; }
.kcard .knote { font-size: 12.5px; color: var(--ink); margin-top: 7px; background: var(--ground); border-radius: 8px; padding: 6px 9px; }
.kcard .kremove {
  float: right; border: 0; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 15px; line-height: 1; padding: 0 2px;
}
.kcard .kremove:hover { color: #E23D6D; }
.column-empty { text-align: center; color: var(--muted); font-size: 12.5px; padding: 14px 6px; }

/* ---------- Modales ---------- */
.overlay { position: fixed; inset: 0; background: rgba(30,38,58,.42); backdrop-filter: blur(4px); z-index: 40; }
.modal {
  position: fixed; z-index: 50; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 420px; max-width: calc(100vw - 40px); background: #fff; border-radius: 20px;
  box-shadow: var(--sh-lg); border: 1px solid var(--line); padding: 24px 24px 20px;
  /* No desbordar la pantalla: alto máximo + scroll interno del modal. */
  max-height: calc(100vh - 28px); overflow-y: auto;
}
/* Título pegado arriba y botones pegados abajo al scrollear contenido largo. */
.modal > h3:first-child { position: sticky; top: -24px; z-index: 2; background: #fff; margin: -24px -24px 14px; padding: 22px 24px 12px; }
.modal.wide { width: 480px; }
.modal h3 { margin: 0 0 18px; font-size: 18px; font-weight: 800; }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 12.5px; font-weight: 700; color: var(--muted); margin-bottom: 7px; }
.field input[type=text], .field select {
  width: 100%; border: 1.5px solid var(--line); border-radius: 11px; padding: 10px 13px;
  font: inherit; font-size: 14px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input[type=text]:focus, .field select:focus { border-color: var(--purpura); box-shadow: 0 0 0 3px rgba(76,77,195,.16); }
.color-row { display: flex; align-items: center; gap: 12px; }
.color-row input[type=color] { width: 46px; height: 40px; border: 1.5px solid var(--line); border-radius: 11px; background: #fff; cursor: pointer; padding: 3px; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatches button { width: 28px; height: 28px; border-radius: 8px; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.swatches button.sel { box-shadow: 0 0 0 2px var(--purpura); }
.modal-foot { display: flex; align-items: center; gap: 10px; position: sticky; bottom: -20px; z-index: 2; background: #fff; margin: 12px -24px -20px; padding: 14px 24px; border-top: 1px solid var(--line); }

.pick-search {
  width: 100%; border: 1.5px solid var(--line); border-radius: 11px; padding: 10px 13px;
  font: inherit; font-size: 14px; outline: none; margin-bottom: 12px;
}
.pick-search:focus { border-color: var(--purpura); box-shadow: 0 0 0 3px rgba(76,77,195,.16); }
.pick-list { max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.pick-row { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 10px; cursor: pointer; }
.pick-row:hover { background: var(--ground); }
.pick-row .avatar { width: 36px; height: 36px; font-size: 13px; }
.pick-row .meta { min-width: 0; flex: 1; }
.pick-row .meta .name { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick-row .meta .num { font-size: 12px; color: var(--muted); }
.pick-row .add { font-size: 12.5px; font-weight: 800; color: var(--purpura); }
.pick-list.small { max-height: 180px; }
.pick-row.sel { background: var(--purpura-050); }
.picked { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.picked .chip { background: var(--purpura-050); color: var(--purpura); font-weight: 700; font-size: 12.5px; padding: 5px 10px; border-radius: 999px; }

.field textarea {
  width: 100%; border: 1.5px solid var(--line); border-radius: 11px; padding: 10px 13px;
  font: inherit; font-size: 14px; outline: none; resize: vertical; transition: border-color .15s, box-shadow .15s;
}
.field textarea:focus, .field input[type=datetime-local]:focus { border-color: var(--purpura); box-shadow: 0 0 0 3px rgba(76,77,195,.16); }
.field input[type=datetime-local] { width: 100%; border: 1.5px solid var(--line); border-radius: 11px; padding: 10px 13px; font: inherit; font-size: 14px; outline: none; }

/* ---------- Páginas genéricas (Fase 3) ---------- */
.page { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.page-head { display: flex; align-items: flex-end; gap: 16px; padding: 22px 26px 16px; }
.page-head h2 { margin: 0; font-size: 21px; font-weight: 800; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }
.page-head .btn-primary, .page-head .crm-actions { margin-left: auto; }
.list { flex: 1; overflow-y: auto; padding: 4px 26px 26px; display: flex; flex-direction: column; gap: 11px; }

.item {
  background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--sh-sm);
  padding: 15px 17px; display: flex; align-items: flex-start; gap: 14px;
}
.item .body { flex: 1; min-width: 0; }
.item .t1 { font-weight: 800; font-size: 15px; display: flex; align-items: center; gap: 9px; }
.item .t2 { color: var(--muted); font-size: 13.5px; margin-top: 4px; white-space: pre-wrap; word-break: break-word; }
.item .chipcode { font-family: ui-monospace, monospace; background: var(--purpura-050); color: var(--purpura); font-weight: 800; font-size: 12.5px; padding: 3px 9px; border-radius: 8px; }
.item .chipcode.alt { background: var(--ground); color: var(--muted); font-weight: 700; }
.item .acts { display: flex; gap: 6px; flex-shrink: 0; }
.item .acts button {
  border: 1.5px solid var(--line); background: #fff; border-radius: 9px; width: 34px; height: 34px;
  cursor: pointer; display: grid; place-items: center; color: var(--muted);
}
.item .acts button:hover { border-color: #C7CBE0; color: var(--ink); }
.item .acts button.danger:hover { color: #E23D6D; border-color: rgba(226,61,109,.3); }
.item .acts button svg { width: 16px; height: 16px; }
.state-badge { font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: 999px; letter-spacing: .02em; }
.state-pending { background: rgba(231,160,8,.14); color: #B67D06; }
.state-sent, .state-done { background: rgba(34,165,101,.14); color: var(--ok); }
.state-failed { background: rgba(226,61,109,.14); color: #E23D6D; }
.state-running { background: var(--purpura-050); color: var(--purpura); }
.list-empty { text-align: center; color: var(--muted); font-size: 14px; padding: 48px 0; }
.progress { height: 7px; border-radius: 999px; background: var(--ground); overflow: hidden; margin-top: 9px; }
.progress > i { display: block; height: 100%; background: var(--purpura); border-radius: 999px; transition: width .3s; }

/* Switch (flujos) */
.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch .track { width: 42px; height: 24px; border-radius: 999px; background: #C7CBE0; position: relative; transition: background .18s; flex-shrink: 0; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .18s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + .track { background: var(--ok); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch .switch-label { font-weight: 700; font-size: 13.5px; }

/* Composer: iconos + adjuntos + popup */
.composer { position: relative; }
.c-icon { width: 42px; height: 46px; border: 0; background: transparent; color: var(--muted); cursor: pointer; display: grid; place-items: center; border-radius: 10px; flex-shrink: 0; }
.c-icon:hover { background: var(--ground); color: var(--purpura); }
.c-icon svg { width: 21px; height: 21px; }
.quick-pop {
  position: absolute; bottom: 62px; left: 12px; width: 320px; max-height: 280px; overflow-y: auto;
  background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--sh-lg); padding: 6px; z-index: 20;
}
.quick-pop .qp { padding: 9px 11px; border-radius: 9px; cursor: pointer; }
.quick-pop .qp:hover { background: var(--ground); }
.quick-pop .qp .code { font-family: ui-monospace, monospace; color: var(--purpura); font-weight: 800; font-size: 12.5px; }
.quick-pop .qp .txt { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quick-pop .qp-empty { padding: 14px; text-align: center; color: var(--muted); font-size: 13px; }

/* Media en burbujas */
.bubble img.b-media { max-width: 240px; border-radius: 10px; display: block; cursor: pointer; }
.bubble audio.b-media { max-width: 240px; display: block; }
.bubble .b-file { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; }
.bubble .b-cap { margin-top: 6px; }
/* Respetar saltos de línea y espacios del texto (como WhatsApp) */
.bubble .b-text, .bubble .b-cap { white-space: pre-wrap; overflow-wrap: anywhere; }
/* Formato tipo WhatsApp */
.bubble .b-text code, .bubble .b-cap code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; background: rgba(0,0,0,.08); padding: 1px 5px; border-radius: 5px; }
.bubble.out .b-text code, .bubble.out .b-cap code { background: rgba(255,255,255,.2); }
.bubble .b-text strong, .bubble .b-cap strong { font-weight: 800; }
.b-media-fail { font-size: 13px; opacity: .75; padding: 4px 2px; }
/* #12 Placeholder de foto/video (descarga opt-in) */
.b-media-ph { position: relative; width: 240px; max-width: 100%; height: 180px; border-radius: 10px; background: #d8dbe8 center/cover no-repeat; cursor: pointer; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.b-media-ph::after { content: ''; position: absolute; inset: 0; background: rgba(20,25,40,.28); }
.b-media-ph .ph-badge { position: relative; z-index: 1; background: rgba(0,0,0,.55); color: #fff; font-size: 12.5px; font-weight: 700; padding: 6px 12px; border-radius: 999px; display: inline-flex; align-items: center; gap: 6px; }
.b-media-ph .ph-ic { font-size: 13px; }
.b-media-ph .ph-play { position: relative; z-index: 1; width: 52px; height: 52px; border-radius: 50%; background: rgba(255,255,255,.92); color: var(--purpura); display: flex; align-items: center; justify-content: center; font-size: 22px; padding-left: 4px; }
.b-media-ph.video .ph-badge { position: absolute; bottom: 8px; left: 8px; }
.b-media-ph:hover::after { background: rgba(20,25,40,.15); }
/* #14 Visor: contenedor principal + tira */
.lightbox .lb-main { display: flex; align-items: center; justify-content: center; max-width: 92%; max-height: 74vh; }
.lightbox .lb-main .lb-img { max-width: 100%; max-height: 74vh; }
.lightbox .lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 50%; border: none; background: rgba(255,255,255,.15); color: #fff; font-size: 30px; cursor: pointer; line-height: 1; }
.lightbox .lb-nav:hover { background: rgba(255,255,255,.3); }
.lightbox .lb-nav.prev { left: 24px; }
.lightbox .lb-nav.next { right: 24px; }
.lightbox .lb-strip { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; padding: 8px; background: rgba(0,0,0,.35); border-radius: 14px; max-width: 90%; overflow-x: auto; }
.lightbox .lb-thumb { position: relative; width: 52px; height: 52px; flex: none; border-radius: 8px; background: #444 center/cover no-repeat; cursor: pointer; opacity: .6; border: 2px solid transparent; display: flex; align-items: center; justify-content: center; font-size: 20px; }
.lightbox .lb-thumb.on { opacity: 1; border-color: #fff; }
.lightbox .lb-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 6px; }
.lightbox .lb-thumb .lb-tplay { position: absolute; z-index: 1; color: #fff; font-size: 14px; text-shadow: 0 0 4px #000; }

@media (max-width: 780px) {
  .connect-card { grid-template-columns: 1fr; max-width: 420px; }
  .connect-copy { padding: 34px 28px 8px; }
  .connect-qr { border-left: 0; border-top: 1px solid var(--line); }
  .chat-list { width: 100%; }
  .inbox.has-active .chat-list { display: none; }
}

/* ============================================================
   Usuarios, sesión y permisos (RBAC)
   ============================================================ */
/* Password/text inputs dentro de campos y modales */
.field input[type=password] {
  width: 100%; border: 1.5px solid var(--line); border-radius: 11px; padding: 10px 13px;
  font: inherit; font-size: 14px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input[type=password]:focus { border-color: var(--purpura); box-shadow: 0 0 0 3px rgba(76,77,195,.16); }
.fld-hint { margin: 8px 2px 0; font-size: 12px; color: var(--muted); }

/* ---- Pantalla de login / creación de cuenta ---- */
.auth-screen {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center;
  background: radial-gradient(1200px 600px at 50% -10%, #35407A 0%, var(--navy) 55%, #1B2436 100%);
  padding: 24px;
}
.auth-screen.hidden { display: none; }
.auth-card {
  width: 380px; max-width: calc(100vw - 40px); background: #fff; border-radius: 22px;
  box-shadow: var(--sh-lg); padding: 32px 30px 28px; text-align: center;
}
.auth-logo { width: 62px; height: 62px; margin: 0 auto 14px; border-radius: 16px; background: var(--navy); display: grid; place-items: center; }
.auth-logo img { width: 40px; height: 40px; }
.auth-card h1 { margin: 0 0 6px; font-size: 22px; font-weight: 800; color: var(--ink); }
.auth-sub { margin: 0 0 22px; color: var(--muted); font-size: 13.5px; }
.auth-card .field { text-align: left; }
.auth-err { background: rgba(226,61,109,.1); color: #E23D6D; font-weight: 700; font-size: 13px; padding: 9px 12px; border-radius: 10px; margin-bottom: 12px; }
.auth-submit { width: 100%; justify-content: center; padding: 12px; font-size: 15px; }

/* ---- Badge de usuario en la topbar ---- */
.user-badge { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.user-badge.hidden { display: none; }
.ub-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, #5859D4, var(--purpura)); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 14px;
}
.ub-info { display: flex; flex-direction: column; line-height: 1.15; }
.ub-name { font-weight: 800; font-size: 13.5px; color: var(--ink); }
.ub-role { font-size: 11px; color: var(--muted); }
.ub-logout { border: 1px solid var(--line); background: #fff; color: var(--muted); width: 34px; height: 34px; border-radius: 10px; cursor: pointer; display: grid; place-items: center; }
.ub-logout:hover { border-color: #E23D6D; color: #E23D6D; }

/* ---- Lista de usuarios ---- */
.users-wrap { flex: 1; overflow-y: auto; padding: 4px 26px 26px; }
.users-list { display: flex; flex-direction: column; gap: 11px; max-width: 760px; }
.user-row {
  background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--sh-sm);
  padding: 15px 17px; display: flex; align-items: center; gap: 14px;
}
.user-row .u-av {
  width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, #5859D4, var(--purpura)); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 15px;
}
.user-row .u-main { flex: 1; min-width: 0; }
.user-row .u-name { font-weight: 800; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.user-row .u-sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.user-row .u-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.u-tag { font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--purpura-050); color: var(--purpura); }
.u-tag.scope { background: rgba(34,165,101,.12); color: var(--ok); }
.u-tag.off { background: rgba(114,123,144,.12); color: var(--muted); }
.badge-master { font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: var(--navy); color: var(--lima); }
.badge-inactive { font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: rgba(226,61,109,.12); color: #E23D6D; }
.user-row .u-actions { display: flex; gap: 8px; }
.user-row .u-actions button { border: 1px solid var(--line); background: #fff; color: var(--muted); border-radius: 9px; padding: 7px 12px; cursor: pointer; font: inherit; font-size: 13px; font-weight: 700; }
.user-row .u-actions button:hover { border-color: var(--purpura); color: var(--purpura); }

/* ---- Segmentos + grilla de permisos en el modal ---- */
.seg.scope-seg { display: flex; gap: 6px; background: var(--ground); padding: 4px; border-radius: 11px; }
.seg.scope-seg button { flex: 1; border: 0; background: transparent; padding: 9px; border-radius: 8px; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; color: var(--muted); }
.seg.scope-seg button.sel { background: #fff; color: var(--purpura); box-shadow: var(--sh-sm); }
/* minmax(0,1fr) permite que las columnas se achiquen y el texto largo (ej.
   "Meta (Facebook/Instagram)") haga wrap en vez de desbordar el panel. */
.perm-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.perm-chip {
  display: flex; align-items: center; gap: 9px; padding: 10px 12px; border: 1.5px solid var(--line);
  border-radius: 11px; cursor: pointer; font-size: 13.5px; font-weight: 700; color: var(--ink); user-select: none;
  min-width: 0;
}
.perm-chip span { min-width: 0; overflow-wrap: anywhere; }
.perm-chip input { flex-shrink: 0; }
.perm-chip input { accent-color: var(--purpura); width: 17px; height: 17px; }
.perm-chip.on { border-color: var(--purpura); background: var(--purpura-050); }

/* ---- Selector "Asignado a" en la info de contacto ---- */
.ci-assign { padding: 14px 18px; border-bottom: 1px solid var(--line); }
.ci-assign .lbl { font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.ci-assign select { width: 100%; border: 1.5px solid var(--line); border-radius: 11px; padding: 10px 13px; font: inherit; font-size: 14px; outline: none; background: #fff; }
.ci-assign select:focus { border-color: var(--purpura); box-shadow: 0 0 0 3px rgba(76,77,195,.16); }

/* ============================================================
   Leads de Meta (Facebook Lead Ads)
   ============================================================ */
.leads-wrap { flex: 1; overflow-y: auto; padding: 4px 26px 26px; }
.meta-panel { max-width: 760px; margin-bottom: 22px; }
.meta-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--sh-sm); padding: 20px; }
.meta-card.connected { padding: 18px 20px; }
.meta-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.meta-head > div { flex: 1; }
.meta-head b { font-size: 16px; font-weight: 800; }
.meta-head p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.meta-fb { width: 40px; height: 40px; border-radius: 11px; background: #1877F2; color: #fff; display: grid; place-items: center; font-weight: 900; font-size: 22px; font-family: Georgia, serif; flex-shrink: 0; }
.meta-fb.sm { width: 22px; height: 22px; font-size: 13px; border-radius: 6px; display: inline-grid; vertical-align: middle; }
.meta-fb.ok { background: #22A565; }
.meta-actions { display: flex; gap: 8px; }
.meta-redirect { background: var(--ground); border-radius: 11px; padding: 12px 14px; font-size: 12.5px; color: var(--muted); margin-bottom: 14px; }
.meta-redirect code { display: block; margin-top: 6px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-family: ui-monospace, monospace; font-size: 12px; color: var(--purpura); word-break: break-all; }
.btn-fb { width: 100%; justify-content: center; display: flex; align-items: center; gap: 10px; background: #1877F2; color: #fff; border: 0; border-radius: 12px; padding: 13px; font: inherit; font-size: 15px; font-weight: 800; cursor: pointer; }
.btn-fb:hover { background: #1466d6; }
.meta-reset { width: 100%; margin-top: 10px; justify-content: center; }
.meta-pages { display: flex; flex-direction: column; gap: 14px; }
.meta-page { border: 1px solid var(--line); border-radius: 13px; padding: 14px; }
.mp-name { font-weight: 800; font-size: 14px; margin-bottom: 10px; }
.meta-form { border: 1.5px solid var(--line); border-radius: 11px; padding: 11px 13px; margin-bottom: 9px; transition: border-color .15s, background .15s; }
.meta-form.on { border-color: var(--purpura); background: var(--purpura-050); }
.mf-top { display: flex; align-items: center; gap: 9px; font-size: 14px; cursor: pointer; }
.mf-top input { width: 17px; height: 17px; accent-color: var(--purpura); }
.mf-count { margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 700; }
.mf-cfg { margin-top: 11px; display: flex; flex-direction: column; gap: 9px; }
.mf-cfg.hidden { display: none; }
.mf-row { display: flex; align-items: center; gap: 10px; }
.mf-row > span { font-size: 12.5px; font-weight: 700; color: var(--muted); min-width: 150px; }
.mf-row.col { flex-direction: column; align-items: stretch; gap: 6px; }
.mf-row select, .mf-row textarea { flex: 1; border: 1.5px solid var(--line); border-radius: 9px; padding: 8px 11px; font: inherit; font-size: 13.5px; outline: none; background: #fff; resize: vertical; }
.mf-row select:focus, .mf-row textarea:focus { border-color: var(--purpura); box-shadow: 0 0 0 3px rgba(76,77,195,.14); }

.leads-head h3 { font-size: 16px; font-weight: 800; margin: 6px 0 12px; }
.leads-list { display: flex; flex-direction: column; gap: 9px; max-width: 760px; }
.lead-row { background: #fff; border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--sh-sm); padding: 13px 15px; display: flex; align-items: center; gap: 13px; }
.lead-av { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; background: linear-gradient(135deg, #1877F2, #4C4DC3); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 14px; }
.lead-main { flex: 1; min-width: 0; }
.lead-name { font-weight: 800; font-size: 14.5px; }
.lead-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lead-when { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.lead-open { border: 1px solid var(--line); background: #fff; color: var(--purpura); border-radius: 9px; padding: 8px 13px; cursor: pointer; font: inherit; font-size: 13px; font-weight: 700; }
.lead-open:hover { border-color: var(--purpura); background: var(--purpura-050); }
.lead-nomatch { font-size: 12px; color: var(--muted); }

/* ---- Webhook genérico de leads ---- */
.meta-fb.tk { background: linear-gradient(135deg, #25F4EE, #FE2C55); color: #111; font-size: 20px; }
.wh-url { margin-bottom: 14px; }
.wh-url > span { display: block; font-size: 12.5px; font-weight: 800; color: var(--muted); margin-bottom: 7px; }
.wh-url-row { display: flex; gap: 8px; }
.wh-url-row input { flex: 1; border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px; font: inherit; font-size: 12.5px; font-family: ui-monospace, monospace; color: var(--purpura); background: var(--ground); outline: none; }
.wh-grid { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.wh-adv { margin-bottom: 12px; }
.wh-adv summary { cursor: pointer; font-size: 13px; font-weight: 700; color: var(--purpura); }
.wh-map { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-top: 10px; }
.wh-map label { display: flex; flex-direction: column; gap: 5px; }
.wh-map label span { font-size: 12px; font-weight: 700; color: var(--muted); }
.wh-map input { border: 1.5px solid var(--line); border-radius: 9px; padding: 8px 10px; font: inherit; font-size: 13px; outline: none; }
.wh-map input:focus { border-color: var(--purpura); box-shadow: 0 0 0 3px rgba(76,77,195,.14); }
.wh-help { background: var(--ground); border-radius: 11px; padding: 12px 14px; font-size: 12.5px; color: var(--muted); line-height: 1.5; margin-bottom: 12px; }
.wh-help b { color: var(--ink); }
.wh-regen { width: 100%; justify-content: center; font-size: 13px; color: #E23D6D; }
.wh-regen:hover { border-color: #E23D6D; }

/* ---- Panel "Probar el flujo" (lead de prueba) ---- */
.lt-grid { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.lt-grid .mf-row input, .lt-grid .mf-row select { flex: 1; border: 1.5px solid var(--line); border-radius: 9px; padding: 9px 11px; font: inherit; font-size: 13.5px; outline: none; background: #fff; }
.lt-grid .mf-row input:focus, .lt-grid .mf-row select:focus { border-color: var(--purpura); box-shadow: 0 0 0 3px rgba(76,77,195,.14); }
.lt-result { margin-top: 12px; font-size: 13px; font-weight: 700; border-radius: 10px; padding: 0; }
.lt-result.ok { background: rgba(34,165,101,.12); color: var(--ok); padding: 10px 13px; }
.lt-result.err { background: rgba(226,61,109,.1); color: #E23D6D; padding: 10px 13px; }

/* ---- Tarjeta del embudo: etiqueta "Nuevo lead" + fecha/hora + origen ---- */
.kcard { position: relative; }
.kcard.is-new { box-shadow: 0 0 0 2px rgba(231,242,83,.55), var(--sh-sm); }
.knew-badge {
  display: inline-block; margin-bottom: 8px;
  background: var(--lima); color: var(--navy); font-size: 10.5px; font-weight: 800;
  padding: 3px 9px; border-radius: 999px; letter-spacing: .02em;
  animation: knewpulse 1.6s ease-in-out infinite;
}
@keyframes knewpulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.kmeta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; margin-left: 36px; }
.kmeta-time { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.kmeta-src { font-size: 10.5px; font-weight: 800; padding: 2px 8px; border-radius: 999px; color: #fff; }
.kmeta-src.src-meta { background: #1877F2; }
.kmeta-src.src-tiktok { background: #111; }
.kmeta-src.src-webhook { background: var(--purpura); }

/* ---- Link registro/login en la pantalla de auth ---- */
.auth-switch { margin-top: 16px; text-align: center; font-size: 13.5px; color: var(--muted); }
.auth-switch a { color: var(--purpura); font-weight: 800; text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }

/* ---- Acciones por campaña (reutilizar / duplicar / lanzar) ---- */
/* Especificidad alta para ganarle a `.item .acts button{width:34px}` (íconos). */
.item .acts.camp-acts { align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; max-width: 320px; }
.item .acts.camp-acts button.camp-reuse,
.item .acts.camp-acts button.camp-dup,
.item .acts.camp-acts button.camp-launch {
  width: auto; height: auto; white-space: nowrap;
  border: 1px solid var(--line); background: #fff; color: var(--purpura);
  border-radius: 9px; padding: 8px 13px; cursor: pointer; font: inherit; font-size: 12.5px; font-weight: 700;
}
.item .acts.camp-acts button.camp-reuse:hover,
.item .acts.camp-acts button.camp-dup:hover { border-color: var(--purpura); background: var(--purpura-050); color: var(--purpura); }
.item .acts.camp-acts button.camp-launch { background: var(--purpura); color: #fff; border-color: var(--purpura); }
.item .acts.camp-acts button.camp-launch:hover { filter: brightness(1.05); background: var(--purpura); color: #fff; }
.item .acts.camp-acts button.danger:hover { border-color: #E23D6D; color: #E23D6D; background: #fff; }
.camp-more { font-size: 11px; font-weight: 800; color: var(--purpura); background: var(--purpura-050); padding: 1px 7px; border-radius: 999px; }
.state-badge.state-paused { background: rgba(231,160,8,.14); color: #B77800; }

/* ---- Filtro por asesor (bandeja / embudo) ---- */
.advisor-filter { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.advisor-filter.hidden { display: none; }
.af-lbl { font-size: 11.5px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-right: 2px; }
.af-chip { border: 1.5px solid var(--line); background: #fff; color: var(--muted); border-radius: 999px; padding: 5px 11px; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.af-chip:hover { border-color: #C7CBE0; }
.af-chip.on { border-color: var(--purpura); background: var(--purpura-050); color: var(--purpura); }

/* Desplegable del filtro por asesor */
.af-dd { position: relative; }
.af-dd-btn { display: inline-flex; align-items: center; gap: 8px; min-width: 130px; justify-content: space-between;
  border: 1.5px solid var(--line); background: #fff; color: var(--ink); border-radius: 999px;
  padding: 6px 12px; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.af-dd-btn:hover { border-color: #C7CBE0; }
.af-caret { width: 15px; height: 15px; color: var(--muted); flex: none; }
.af-dd-menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 40; min-width: 190px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 6px; box-shadow: var(--sh-md);
  max-height: 280px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.af-dd-menu.hidden { display: none; }
.af-opt { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  border: none; background: transparent; border-radius: 8px; padding: 8px 10px; font: inherit; font-size: 13px;
  font-weight: 600; color: var(--ink); cursor: pointer; white-space: nowrap; }
.af-opt:hover { background: var(--ground); }
.af-opt.on { color: var(--purpura); }
.af-check { width: 16px; flex: none; color: var(--purpura); font-weight: 900; font-size: 12px; text-align: center; }
.crm-advisor-filter { padding: 0 26px 12px; }

/* ---- Pertenencia (info de contacto) + transferir (usuarios) ---- */
.ci-assign-ro { font-size: 14px; font-weight: 700; color: var(--ink); padding: 4px 0; }
.ci-unassigned { font-weight: 700; color: #E7A008; font-size: 11.5px; }
.u-tag.count { background: rgba(79,134,247,.14); color: #2F6FE0; }
.user-row .u-actions { flex-wrap: wrap; justify-content: flex-end; max-width: 340px; }

/* ---- Notas de origen (datos del lead en la ficha de contacto) ---- */
.ci-origin { background: linear-gradient(180deg, rgba(231,242,83,.10), transparent); border: 1px solid var(--line); border-radius: 12px; }
.ci-origin .ci-sec-head span:first-child { color: var(--navy); }
.ci-origin-src { font-size: 10.5px; font-weight: 800; padding: 2px 8px; border-radius: 999px; color: #fff; margin-left: auto; }
.ci-origin-src.src-meta { background: #1877F2; } .ci-origin-src.src-tiktok { background: #111; } .ci-origin-src.src-webhook { background: var(--purpura); }
.ci-origin-form { font-size: 12.5px; font-weight: 800; color: var(--purpura); margin-bottom: 10px; }
.ci-origin-fields { display: flex; flex-direction: column; gap: 8px; }
.ci-origin-row { background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px; }
.ci-origin-row .oq { font-size: 11.5px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; }
.ci-origin-row .oa { font-size: 13.5px; color: var(--ink); margin-top: 2px; word-break: break-word; }
.ci-origin-when { font-size: 11.5px; color: var(--muted); margin-top: 10px; }

/* ---- Mención (@alguien) dentro de un mensaje ---- */
.b-mention { font-weight: 800; color: var(--purpura); }
.bubble.out .b-mention { color: #E7F253; }

/* ============================================================
   Dashboard de ventas
   ============================================================ */
.dashboard { padding: 26px 30px; overflow-y: auto; }
.dash-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.dash-head h2 { margin: 0; font-size: 24px; color: var(--navy); }
.dash-head .muted { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.dash-tools { display: flex; align-items: center; gap: 10px; }
.dash-select { height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--navy); font-weight: 600; font-size: 13px; }

.dash-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; box-shadow: var(--sh-sm); display: flex; flex-direction: column; gap: 6px; }
.kpi-lbl { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi-val { font-size: 26px; font-weight: 800; color: var(--purpura); line-height: 1; }

.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.dash-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; box-shadow: var(--sh-sm); }
.dash-card h3 { margin: 0 0 10px; font-size: 15px; color: var(--navy); }
.dash-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.dash-card-head h3 { margin: 0; }

.dash-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); font-size: 13px; }
.dash-row:first-child { border-top: none; }
.dr-name { font-weight: 700; color: var(--navy); }
.dr-count { color: var(--muted); font-size: 12px; white-space: nowrap; }
.dr-money { font-weight: 800; color: var(--ok); white-space: nowrap; }

.dash-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.dash-table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .3px; padding: 6px 10px; border-bottom: 1px solid var(--line); }
.dash-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); color: var(--navy); }
.dash-table .dt-money { font-weight: 800; color: var(--ok); white-space: nowrap; }
.dt-del { border: none; background: transparent; color: var(--muted); cursor: pointer; font-size: 13px; border-radius: 6px; width: 24px; height: 24px; }
.dt-del:hover { background: #FDEAEA; color: #D64545; }
.btn-ghost.sm { height: 32px; padding: 0 12px; font-size: 12.5px; }

/* ---- Modal registrar venta ---- */
.sale-catalog { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: -4px 0 14px; }
.sale-catalog.hidden { display: none; }
.sc-lbl { font-size: 12px; color: var(--muted); font-weight: 600; margin-right: 2px; }
.sc-chip { border: 1px solid var(--line); background: var(--purpura-050); color: var(--purpura); border-radius: 999px; padding: 5px 12px; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.sc-chip:hover { background: var(--purpura); color: #fff; }
.cur-toggle { display: flex; gap: 6px; }
.cur-toggle button { flex: 1; height: 42px; border: 1px solid var(--line); background: #fff; border-radius: 10px; font-weight: 700; font-size: 13px; color: var(--navy); cursor: pointer; }
.cur-toggle button.active { background: var(--purpura); border-color: var(--purpura); color: #fff; }

@media (max-width: 860px) {
  .dash-kpis { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
}

/* ---- Rango de fechas + meta de ventas ---- */
.dash-custom { display: flex; gap: 14px; margin: -8px 0 16px; }
.dash-custom label { font-size: 12px; color: var(--muted); font-weight: 600; display: flex; flex-direction: column; gap: 4px; }
.dash-custom input { height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--navy); font-weight: 600; }

.dash-goal { margin-bottom: 18px; }
.goal-set { border: 1.5px dashed var(--purpura); background: var(--purpura-050); color: var(--purpura); border-radius: 14px; padding: 12px 18px; font-weight: 700; font-size: 13.5px; cursor: pointer; }
.goal-set:hover { background: var(--purpura); color: #fff; }
.goal-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 14px 18px; box-shadow: var(--sh-sm); }
.goal-card.done { border-color: var(--ok); background: #F1FBF6; }
.goal-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.goal-title { font-weight: 700; color: var(--navy); font-size: 14px; }
.goal-pct { font-weight: 800; color: var(--purpura); font-size: 15px; }
.goal-card.done .goal-pct { color: var(--ok); }
.goal-bar { height: 12px; background: var(--ground); border-radius: 999px; overflow: hidden; }
.goal-fill { height: 100%; background: linear-gradient(90deg, var(--purpura), #6C6DE0); border-radius: 999px; transition: width .4s ease; }
.goal-card.done .goal-fill { background: linear-gradient(90deg, var(--ok), #3CC97E); }
.goal-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.goal-edit { border: none; background: transparent; color: var(--purpura); font-weight: 700; cursor: pointer; font-size: 12.5px; }

/* ---- Meta por asesor (fila de la tabla Por asesor) ---- */
.dash-row.urow { grid-template-columns: 1fr auto auto auto; row-gap: 8px; }
.dr-goal-set { border: none; background: var(--purpura-050); color: var(--purpura); border-radius: 8px; width: 26px; height: 26px; cursor: pointer; font-size: 12px; }
.dr-goal-set:hover { background: var(--purpura); color: #fff; }
.dr-goal { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; margin-top: 2px; }
.dr-goal-bar { flex: 1; height: 8px; background: var(--ground); border-radius: 999px; overflow: hidden; }
.dr-goal-fill { height: 100%; background: linear-gradient(90deg, var(--purpura), #6C6DE0); border-radius: 999px; transition: width .4s ease; }
.dr-goal.done .dr-goal-fill { background: linear-gradient(90deg, var(--ok), #3CC97E); }
.dr-goal-lbl { font-size: 11.5px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.dr-goal.done .dr-goal-lbl { color: var(--ok); }
