/* =========================================================
   WhatsApp Dashboard — estilo GoHighLevel
   ========================================================= */
:root {
  --bg:           #f4f6f8;
  --panel:        #ffffff;
  --border:       #e6e9ef;
  --border-soft:  #eef1f5;
  --text:         #1c2434;
  --text-soft:    #5b6577;
  --text-mute:    #9aa3b2;
  --brand:        #2f6df6;   /* azul GHL */
  --brand-dark:   #1f54cc;
  --wa:           #25d366;   /* verde WhatsApp */
  --wa-bubble:    #e7ffdb;   /* burbuja saliente */
  --in-bubble:    #ffffff;
  --rail:         #16203a;   /* navy oscuro del rail */
  --rail-soft:    #28324d;
  --read:         #34b7f1;   /* ticks leídos */
  --danger:       #e5484d;
  --shadow:       0 1px 3px rgba(18,28,45,.08), 0 4px 16px rgba(18,28,45,.06);
  --radius:       12px;
  --thread-bg:    #efeae2;
  --thread-tint:  rgba(239,234,226,.96);
  --hover:        #f9fafc;
  --active:       #eef4ff;
  --input-bg:     #ffffff;
}

/* ============ TEMA OSCURO ============ */
[data-theme="dark"] {
  --bg:           #0d1420;
  --panel:        #151d2c;
  --border:       #25304a;
  --border-soft:  #1d2638;
  --text:         #e6e9f0;
  --text-soft:    #9aa6bd;
  --text-mute:    #6b7689;
  --brand:        #4d83ff;
  --brand-dark:   #3a6ae6;
  --wa-bubble:    #144d3c;   /* burbuja saliente (WhatsApp dark) */
  --in-bubble:    #1f2a37;   /* burbuja entrante */
  --rail:         #0a0f18;
  --rail-soft:    #1c2434;
  --shadow:       0 1px 3px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
  --thread-bg:    #0b141a;
  --thread-tint:  rgba(11,20,26,.94);
  --hover:        #1b2433;
  --active:       #1d2c47;
  --input-bg:     #1f2a37;
}
[data-theme="dark"] .conv__chan { border-color: var(--panel); }
[data-theme="dark"] .date-sep { background: #1f2c33cc; color: var(--text-soft); }
[data-theme="dark"] .msg { box-shadow: 0 1px 1px rgba(0,0,0,.2); }
[data-theme="dark"] .window-warn { background: #2a2310; border-top-color: #4a3d12; color: #e8c66a; }
[data-theme="dark"] .tag { background: #1d2c47; }
[data-theme="dark"] .qa { background: var(--bg); }
[data-theme="dark"] .qa:hover { background: #1d2c47; }
[data-theme="dark"] .radio:has(input:checked) { background: #17223a; }
[data-theme="dark"] .tpl:hover { background: #17223a; }
[data-theme="dark"] code, [data-theme="dark"] .hint code { background: #0d1420; }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #2c3850; }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: #3a496a; }

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
svg { width: 20px; height: 20px; fill: currentColor; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; font-size: 14px; }

/* ============ SHELL ============ */
.app {
  display: grid;
  /* Panel de detalles oculto: Valentina/Bloquear viven en el header del chat. */
  grid-template-columns: 64px 340px 1fr;
  height: 100vh;
  overflow: hidden;
}
.details { display: none !important; }   /* panel lateral de detalles oculto */

/* ============ RAIL ============ */
.rail {
  background: var(--rail);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 0;
  gap: 6px;
}
.rail__logo {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--brand);
  color: #fff; font-weight: 700; font-size: 20px;
  display: grid; place-items: center; margin-bottom: 10px;
}
.rail__btn {
  width: 42px; height: 42px; border-radius: 10px;
  color: #9aa6c4; display: grid; place-items: center;
  transition: background .15s, color .15s;
}
.rail__btn:hover { background: var(--rail-soft); color: #fff; }
.rail__btn--active { background: var(--rail-soft); color: #fff; }
/* accesos a otras plataformas (emoji) */
.rail__plat { font-size: 21px; text-decoration: none; line-height: 1; }
.rail__plat:hover { background: var(--rail-soft); }
.rail__spacer { flex: 1; }
#btnTheme .icon-sun { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.rail__avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 600; font-size: 13px;
  margin-top: 6px;
}

/* ============ LISTA DE CONVERSACIONES ============ */
.list {
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
}
.list__head { padding: 18px 16px 0; border-bottom: 1px solid var(--border-soft); }
.list__title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.list__title-actions { display: flex; align-items: center; gap: 8px; }
.list__head h1 { font-size: 18px; font-weight: 700; }
/* botón prender/apagar chatbot */
.bot-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 700;
  border: 1px solid transparent; cursor: pointer; transition: background .12s, color .12s, opacity .12s;
}
.bot-toggle svg { width: 15px; height: 15px; fill: currentColor; }
.bot-toggle--on { background: #d8f5e3; color: #0f7a3d; }
.bot-toggle--on:hover { background: #bdeecd; }
.bot-toggle--off { background: var(--bg); color: var(--text-mute); }
.bot-toggle--off:hover { background: var(--border); }
[data-theme="dark"] .bot-toggle--on { background: rgba(26,161,121,.2); color: #34d399; }
[data-theme="dark"] .bot-toggle--off { background: rgba(255,255,255,.06); color: var(--text-mute); }
.bot-toggle.is-loading { opacity: .55; pointer-events: none; }
/* Solo-lectura: lo ve pero no lo puede cambiar quien no es admin/super_admin */
.bot-toggle--readonly { cursor: default; opacity: .85; }

/* cargando mensajes (evita que el hilo se vea vacío mientras llega la respuesta) */
.thread__loading {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  margin: auto; padding: 20px; font-size: 13px; color: var(--text-soft);
}
.spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--brand);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.conn {
  font-size: 10px; font-weight: 700; letter-spacing: .5px;
  padding: 3px 8px; border-radius: 20px;
}
.conn--demo { background: #fff3d6; color: #9a6b00; }
.conn--live { background: #d8f5e3; color: #0f7a3d; }
.conn--error { background: #fde2e2; color: #b42318; }

.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border-radius: 10px;
  padding: 9px 12px; margin: 14px 0 12px;
}
.search svg { width: 18px; height: 18px; color: var(--text-mute); }
.search input { flex: 1; border: none; background: none; outline: none; color: var(--text); }

/* pestañas de la lista: solo iconos (todas, no leídas, canales, handoff) */
.tabs { display: flex; gap: 2px; }
.tab {
  position: relative; flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 9px 0; color: var(--text-soft); opacity: .55;
  border-bottom: 2px solid transparent; border-radius: 8px 8px 0 0;
  transition: opacity .15s, color .15s, border-color .15s, background .12s;
}
.tab svg { width: 18px; height: 18px; fill: currentColor; }
.tab:hover { opacity: 1; background: var(--hover); }
.tab--active { opacity: 1; color: var(--brand); border-color: var(--brand); }
/* cada canal con su color de marca, para reconocerlos de un vistazo */
.tab--wa   { color: #25d366; }
.tab--ig   { color: #e1306c; }
.tab--fb   { color: #0084ff; }
.tab--web  { color: #6b7cff; }
.tab--ch.tab--active { border-color: currentColor; }
/* contadores (no leídas / handoff) */
.tab__count {
  position: absolute; top: 2px; right: 50%; transform: translateX(20px);
  min-width: 15px; height: 15px; padding: 0 4px; border-radius: 8px;
  background: var(--brand); color: #fff; font-size: 9px; font-weight: 800;
  display: none; place-items: center; line-height: 1;
}
.tab--has .tab__count { display: grid; }

.list__body { flex: 1; overflow-y: auto; }

.conv {
  display: flex; gap: 12px; padding: 13px 16px;
  border-bottom: 1px solid var(--border-soft); cursor: pointer;
  transition: background .12s;
}
.conv:hover { background: var(--hover); }
.conv--active { background: var(--active); }
.conv--active:hover { background: var(--active); }
.conv__avatar { position: relative; flex-shrink: 0; }
.conv__chan {
  position: absolute; right: -2px; bottom: -2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--wa); border: 2px solid #fff;
  display: grid; place-items: center;
}
.conv__chan svg { width: 9px; height: 9px; fill: #fff; }
.conv__main { flex: 1; min-width: 0; }
.conv__top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.conv__name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv__time { font-size: 11px; color: var(--text-mute); flex-shrink: 0; }
.conv__bottom { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 3px; }
.conv__preview { font-size: 13px; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv__preview .tick { color: var(--text-mute); }
.conv__badge {
  background: var(--wa); color: #fff; font-size: 11px; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 9px; padding: 0 5px;
  display: grid; place-items: center; flex-shrink: 0;
}
.conv--unread .conv__name { font-weight: 700; }
.conv--unread .conv__preview { color: var(--text); font-weight: 500; }
/* botón "cargar más chats" (paginación de la lista) */
.conv-more {
  display: block; width: calc(100% - 24px); margin: 8px 12px 14px;
  padding: 9px 12px; border: 1px solid var(--border, #2a3040); border-radius: 8px;
  background: transparent; color: var(--text-soft); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background .15s, color .15s;
}
.conv-more:hover { background: var(--hover, rgba(255,255,255,.05)); color: var(--text); }
/* handoff — se fija arriba y se pinta en rojo (requiere atención humana) */
.conv__bottom .conv__preview { flex: 1; min-width: 0; }
.conv__handoff {
  font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .3px;
  color: #fff; background: #dc2626; padding: 1px 6px; border-radius: 5px; flex-shrink: 0;
}
[data-theme="dark"] .conv__handoff { background: #ef4444; color: #fff; }
.conv--handoff {
  box-shadow: inset 4px 0 0 #dc2626;
  background: rgba(220, 38, 38, .07);
}
.conv--handoff:hover { background: rgba(220, 38, 38, .12); }
.conv--handoff.conv--active { background: rgba(220, 38, 38, .15); }
.conv--handoff .conv__name { color: #b91c1c; font-weight: 700; }
[data-theme="dark"] .conv--handoff { background: rgba(239, 68, 68, .12); }
[data-theme="dark"] .conv--handoff:hover { background: rgba(239, 68, 68, .18); }
[data-theme="dark"] .conv--handoff.conv--active { background: rgba(239, 68, 68, .22); }
[data-theme="dark"] .conv--handoff .conv__name { color: #fca5a5; }
.conv__pin { font-size: 11px; }
.tab__count { font-weight: 700; }
.tab--handoff.tab--has { color: #dc2626; opacity: 1; }
.tab--handoff.tab--has .tab__count { background: #dc2626; }
.tab--handoff.tab--active { border-color: #dc2626; color: #dc2626; }
[data-theme="dark"] .tab--handoff.tab--has { color: #f87171; }

/* aviso rojo en la cabecera del hilo cuando la conversación está en handoff */
.handoff-banner { display: none; }
.thread--handoff .handoff-banner {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 18px; font-size: 12.5px; color: #b91c1c;
  background: rgba(220, 38, 38, .10); border-bottom: 1px solid rgba(220, 38, 38, .25);
}
.handoff-banner svg { width: 16px; height: 16px; fill: #dc2626; flex-shrink: 0; }
[data-theme="dark"] .thread--handoff .handoff-banner { color: #fca5a5; background: rgba(239, 68, 68, .14); }

/* ============ NOTIFICACIONES ============ */
.notif { position: relative; }
/* botón "Nuevo chat" en la cabecera */
.newchat-btn {
  display: grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 9px;
  background: var(--wa); color: #fff; cursor: pointer; transition: transform .1s ease, filter .1s ease;
}
.newchat-btn svg { width: 20px; height: 20px; stroke: currentColor; }
.newchat-btn:hover { filter: brightness(1.08); }
.newchat-btn:active { transform: scale(.93); }
.nc-err { color: #dc2626; font-size: 13px; margin: 6px 0 0; }
.nc-tpl-form { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.nc-tpl-form .nc-var { width: 100%; }
#ncTplPreview { white-space: pre-wrap; background: var(--hover); border-radius: 8px; padding: 8px 10px; margin-top: 8px; }

.notif__btn {
  position: relative; display: grid; place-items: center;
  width: 32px; height: 32px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--panel); color: var(--text-soft); cursor: pointer;
}
.notif__btn:hover { background: var(--hover); color: var(--text); }
.notif__btn svg { width: 17px; height: 17px; fill: currentColor; }
.notif__btn--has { color: #dc2626; border-color: rgba(220, 38, 38, .45); }
.notif__count {
  position: absolute; top: -5px; right: -5px;
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: #dc2626; color: #fff; font-size: 9.5px; font-weight: 800;
  display: grid; place-items: center; box-shadow: 0 0 0 2px var(--panel);
}
/* Posición fija (la calcula notifications.js): así no la recorta el overflow
   de la lista ni se sale de la pantalla. */
.notif__panel {
  position: fixed; top: 0; left: 0; z-index: 200; width: 340px;
  max-height: calc(100vh - 90px);
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, .16); overflow: hidden;
}
.notif__head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 11px 13px; border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 700; color: var(--text); flex-shrink: 0;
}
.notif__readall { border: 0; background: none; color: var(--brand); font-size: 11.5px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.notif__readall:hover { text-decoration: underline; }
.notif__list { flex: 1; min-height: 0; overflow-y: auto; }
.notif__empty { padding: 26px 14px; text-align: center; color: var(--text-soft); font-size: 13px; }
.notif__item {
  display: flex; gap: 10px; padding: 10px 13px; cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.notif__item:hover { background: var(--hover); }
.notif__item--unread { background: rgba(47, 109, 246, .06); }
.notif__item--unread:hover { background: rgba(47, 109, 246, .11); }
.notif__item--handoff.notif__item--unread { background: rgba(220, 38, 38, .08); }
.notif__item--handoff.notif__item--unread:hover { background: rgba(220, 38, 38, .13); }
.notif__icon { font-size: 15px; line-height: 1.3; flex-shrink: 0; }
.notif__body { min-width: 0; flex: 1; }
.notif__title { font-size: 12.8px; font-weight: 600; color: var(--text); }
.notif__item--unread .notif__title { font-weight: 700; }
.notif__text { font-size: 11.8px; color: var(--text-soft); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif__time { font-size: 10.5px; color: var(--text-soft); margin-top: 3px; }
.notif__foot { padding: 9px 13px; border-top: 1px solid var(--border); flex-shrink: 0; }
.notif__perm { width: 100%; padding: 7px; border: 1px dashed var(--border); border-radius: 8px; background: none; color: var(--text-soft); font-size: 11.5px; font-weight: 600; cursor: pointer; }
.notif__perm:hover { color: var(--text); border-color: var(--text-soft); }

/* ============ AVATAR ============ */
.avatar {
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center; color: #fff;
  font-weight: 600; font-size: 15px; flex-shrink: 0;
}
.avatar--lg { width: 72px; height: 72px; font-size: 24px; }

/* ============ HILO DE CHAT ============ */
.thread {
  background: var(--thread-bg); /* fondo tipo WhatsApp */
  background-image: linear-gradient(var(--thread-tint), var(--thread-tint));
  display: flex; flex-direction: column; overflow: hidden; position: relative;
}
.thread__empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--text-mute); gap: 14px;
}
.thread__empty-icon { width: 70px; height: 70px; border-radius: 50%; background: var(--panel); display: grid; place-items: center; box-shadow: var(--shadow); }
.thread__empty-icon svg { width: 34px; height: 34px; color: var(--text-mute); }

.thread__inner { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.thread__head {
  background: var(--panel); border-bottom: 1px solid var(--border);
  padding: 11px 18px; display: flex; align-items: center; justify-content: space-between;
}
.thread__head-contact { display: flex; align-items: center; gap: 12px; }
.thread__head .avatar { width: 42px; height: 42px; font-size: 14px; }
.thread__name { font-weight: 600; font-size: 15px; }
.thread__namerow { display: flex; align-items: center; gap: 6px; }
.thread__rename { display: grid; place-items: center; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--text-mute); cursor: pointer; }
.thread__rename:hover { background: var(--hover); color: var(--text); }
.thread__rename svg { width: 14px; height: 14px; fill: currentColor; }
.thread__nameinput { font: inherit; color: var(--text); background: var(--input-bg); border: 1px solid var(--brand); border-radius: 6px; padding: 2px 6px; width: min(260px, 50vw); outline: none; }
.thread__sub { font-size: 12px; color: var(--text-soft); display: flex; align-items: center; gap: 4px; }
.chan-badge { display: inline-flex; align-items: center; gap: 3px; color: var(--wa); font-weight: 600; }
.chan-badge svg { width: 12px; height: 12px; fill: currentColor; }
.thread__head-actions { display: flex; align-items: center; gap: 8px; }
/* Saldo fijo arriba a la derecha; la cabecera del chat le deja su hueco. */
.saldo-chip { position: absolute; top: 15px; right: 18px; z-index: 5; display: inline-flex; align-items: baseline; gap: 7px; height: 34px; padding: 0 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--panel); color: var(--text); font: inherit; cursor: pointer; box-shadow: var(--shadow); }
.saldo-chip:hover { border-color: var(--brand); }
.saldo-chip__lbl { font-size: 11.5px; font-weight: 600; color: var(--text-soft); }
.saldo-chip__num { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 32px; }
.saldo-chip--bajo { border-color: #f59e0b; }
.saldo-chip--bajo .saldo-chip__num { color: #d97706; }
.saldo-chip--agotado { border-color: var(--danger); }
.saldo-chip--agotado .saldo-chip__num { color: var(--danger); }
.thread--saldo .thread__head { padding-right: calc(var(--saldo-w, 120px) + 30px); }

.thread__messages { flex: 1; overflow-y: auto; padding: 20px 8% 12px; display: flex; flex-direction: column; gap: 4px; }

.date-sep { align-self: center; background: #ffffffcc; color: var(--text-soft); font-size: 12px; font-weight: 500; padding: 5px 12px; border-radius: 8px; margin: 10px 0; box-shadow: 0 1px 1px rgba(0,0,0,.04); }

.msg { max-width: 65%; padding: 7px 10px 5px; border-radius: 9px; position: relative; box-shadow: 0 1px 1px rgba(0,0,0,.06); font-size: 14px; line-height: 1.4; word-wrap: break-word; }
.msg--in  { align-self: flex-start; background: var(--in-bubble); border-top-left-radius: 2px; }
.msg--out { align-self: flex-end; background: var(--wa-bubble); border-top-right-radius: 2px; }
.msg__text { white-space: pre-wrap; }
.msg__sender { font-size: 11px; font-weight: 700; color: var(--brand); margin-bottom: 2px; opacity: .9; }
/* cita (reply estilo WhatsApp): barra de color + autor + snippet, clicable */
.msg__quote { display: flex; align-items: stretch; gap: 8px; margin-bottom: 4px; padding: 4px 8px; background: rgba(0,0,0,.05); border-radius: 6px; border-left: 4px solid #1fa855; cursor: pointer; max-width: 100%; overflow: hidden; }
.msg__quote--out { border-left-color: var(--brand); }
[data-theme="dark"] .msg__quote { background: rgba(255,255,255,.07); }
.msg__quote-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.msg__quote-author { font-size: 12px; font-weight: 700; color: #1fa855; line-height: 1.35; }
.msg__quote--out .msg__quote-author { color: var(--brand); }
.msg__quote-text { font-size: 12.5px; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg__quote-thumb { width: 38px; height: 38px; border-radius: 4px; object-fit: cover; flex-shrink: 0; }
@keyframes msgFlash { 0% { box-shadow: 0 0 0 0 rgba(47,109,246,.55); } 100% { box-shadow: 0 0 0 8px rgba(47,109,246,0); } }
.msg--flash { animation: msgFlash 1.1s ease-out; }
.msg__meta { display: flex; align-items: center; gap: 4px; justify-content: flex-end; margin-top: 2px; }
.msg__time { font-size: 10.5px; color: var(--text-mute); }
.msg__tick { width: 16px; height: 16px; color: var(--text-mute); }
.msg__tick.read { color: var(--read); }
.msg__tick svg { width: 16px; height: 16px; }
.msg__chan { display: inline-flex; align-items: center; opacity: .85; }
.msg__chan svg { width: 13px; height: 13px; fill: currentColor; }
.msg--template { border-left: 3px solid var(--brand); }
.msg__tplflag { font-size: 10px; font-weight: 700; color: var(--brand); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 2px; }
.msg--failed { background: #fde6e6; }
.msg--failed .msg__time { color: var(--danger); }
.msg--media { max-width: 320px; }
.msg__media { margin-bottom: 4px; }
.msg__media img,
.msg__media video { max-width: 100%; border-radius: 6px; display: block; }
.js-media-open { cursor: pointer; }
.msg__media--audio { min-width: 230px; }
.msg__media--audio audio { width: 100%; height: 38px; display: block; }
/* miniatura de video con overlay de play */
.msg__media--video { position: relative; }
.msg__media--video video { pointer-events: none; }
.msg__play {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 46px; height: 46px; border-radius: 50%; background: rgba(0,0,0,.55);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 18px; padding-left: 3px; pointer-events: none;
}
.msg__doc {
  display: flex; align-items: center; gap: 9px; margin-bottom: 4px;
  padding: 9px 11px; border-radius: 8px; text-decoration: none;
  background: rgba(0,0,0,.05); color: var(--text); min-width: 180px; max-width: 260px;
}
[data-theme="dark"] .msg__doc { background: rgba(255,255,255,.08); }
.msg__doc:hover { background: rgba(0,0,0,.09); }
[data-theme="dark"] .msg__doc:hover { background: rgba(255,255,255,.13); }
.msg__doc svg { flex-shrink: 0; color: var(--brand); }
.msg__doc-name { font-size: 13px; font-weight: 500; word-break: break-word; overflow-wrap: anywhere; }
.msg__doc-hint { margin-left: auto; flex-shrink: 0; font-size: 11px; font-weight: 700; color: var(--brand); text-transform: uppercase; letter-spacing: .3px; }

/* ===== Visor de media (lightbox) ===== */
.media-modal { position: fixed; inset: 0; z-index: 1000; display: flex; flex-direction: column; }
.media-modal[hidden] { display: none; }
.media-modal__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.88); }
.media-modal__bar {
  position: relative; z-index: 2; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px;
}
.media-modal__name { color: #fff; font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-modal__actions { display: flex; gap: 6px; flex-shrink: 0; }
.media-modal__btn {
  width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; background: rgba(255,255,255,.14); color: #fff; text-decoration: none;
  border: none; cursor: pointer; font-size: 17px; line-height: 1;
}
.media-modal__btn:hover { background: rgba(255,255,255,.28); }
.media-modal__body {
  position: relative; z-index: 2; flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center; padding: 0 16px 16px;
}
.media-modal__img { max-width: 96%; max-height: 100%; object-fit: contain; border-radius: 6px; }
.media-modal__media { max-width: 96%; max-height: 100%; }
.media-modal__frame { width: min(1000px, 96%); height: 100%; border: none; border-radius: 6px; background: #fff; }
.media-modal__noprev {
  background: var(--panel); border-radius: 12px; padding: 28px 32px; text-align: center;
  color: var(--text); display: flex; flex-direction: column; align-items: center; gap: 14px; max-width: 360px;
}
.media-modal__noprev svg { width: 48px; height: 48px; color: var(--brand); }
.media-modal__noprev p { font-size: 14px; color: var(--text-mute); }

/* ===== Detalles: GHL (nota, oportunidades, custom fields) ===== */
.details__ghlnote { margin: 6px 18px 0; font-size: 12px; color: var(--text-mute); }
.opp {
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px;
  background: var(--panel);
}
.opp__top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.opp__name { font-size: 13px; font-weight: 600; color: var(--text); word-break: break-word; }
.opp__status {
  flex-shrink: 0; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px;
  padding: 2px 7px; border-radius: 999px; background: rgba(0,0,0,.08); color: var(--text-soft);
}
[data-theme="dark"] .opp__status { background: rgba(255,255,255,.12); }
.opp__status--open { background: rgba(47,109,246,.15); color: #2f6df6; }
.opp__status--won  { background: rgba(26,161,121,.16); color: #1aa179; }
.opp__status--lost,
.opp__status--abandoned { background: rgba(239,68,68,.14); color: var(--danger); }
.opp__path { font-size: 12px; color: var(--text-mute); margin-top: 4px; }
.opp__value { font-size: 13px; font-weight: 700; color: var(--text); margin-top: 4px; }
/* valores largos de custom fields: no romper el layout */
#detCustom dd { white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; max-height: 160px; overflow: auto; }

/* aviso ventana 24h */
.window-warn {
  background: #fff7e6; border-top: 1px solid #ffe3a3; color: #8a5a00;
  display: flex; align-items: center; gap: 8px; padding: 9px 18px; font-size: 13px;
}
.window-warn svg { width: 18px; height: 18px; fill: #d99100; flex-shrink: 0; }
/* Variante informativa (verde): fuera de 24h pero SÍ puedes responder (agente humano) */
.window-warn--info { background: #eaf7ef; border-top-color: #b7e4c7; color: #1a7a43; }
.window-warn--info svg { fill: #1aa179; }
[data-theme="dark"] .window-warn--info { background: #10241a; border-top-color: #1f4a33; color: #6ee7a8; }

/* ============ COMPOSER ============ */
.composer { background: var(--panel); border-top: 1px solid var(--border); padding: 8px 16px 12px; }
.composer__tools { display: flex; align-items: center; gap: 4px; margin-bottom: 6px; }
.composer__spacer { flex: 1; }
.composer__hint { font-size: 11px; color: var(--text-mute); }
.composer__row { display: flex; align-items: flex-end; gap: 8px; }
/* barra de grabación de voz */
.composer__rec { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.composer__rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); flex-shrink: 0; animation: recpulse 1s infinite; }
@keyframes recpulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
.composer__rec-time { font-size: 14px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.composer__rec-hint { font-size: 13px; color: var(--text-mute); }
.composer__rec-cancel { color: var(--danger); }
.composer__rec-cancel:hover { background: rgba(239,68,68,.12); }
.composer textarea {
  flex: 1; resize: none; max-height: 140px; border: 1px solid var(--border);
  border-radius: 22px; padding: 11px 16px; outline: none; line-height: 1.4;
  transition: border-color .15s; background: var(--input-bg); color: var(--text);
}
.composer textarea:focus { border-color: var(--brand); }
.btn-send {
  width: 44px; height: 44px; border-radius: 50%; background: var(--brand); color: #fff;
  display: grid; place-items: center; flex-shrink: 0; transition: background .15s, transform .1s;
}
.btn-send:hover { background: var(--brand-dark); }
.btn-send:active { transform: scale(.94); }

/* ============ BOTONES ============ */
.btn-icon { width: 34px; height: 34px; border-radius: 8px; color: var(--text-soft); display: grid; place-items: center; transition: background .12s, color .12s; }
.btn-icon:hover { background: var(--bg); color: var(--text); }
.btn-icon--danger:hover { background: rgba(239,68,68,.12); color: var(--danger); }
.btn-ghost { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 8px; font-size: 13px; font-weight: 500; color: var(--text-soft); border: 1px solid var(--border); transition: background .12s; }
.btn-ghost:hover { background: var(--bg); }
.btn-ghost svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 2; fill: none; }
.btn-primary { padding: 9px 18px; border-radius: 8px; background: var(--brand); color: #fff; font-weight: 600; transition: background .15s; }
.btn-primary:hover { background: var(--brand-dark); }

/* ============ DETALLES DE CONTACTO ============ */
.details { background: var(--panel); border-left: 1px solid var(--border); overflow-y: auto; }
.details__head { padding: 26px 20px 20px; text-align: center; border-bottom: 1px solid var(--border-soft); }
.details__head .avatar { margin: 0 auto 12px; }
.details__name { font-size: 17px; font-weight: 700; }
/* toggle Abierta/Cerrada (estilo pastilla, como el del bot) */
.pill-toggle {
  display: inline-flex; align-items: center; gap: 7px;
  margin: 8px auto 2px; padding: 5px 14px; border-radius: 20px;
  font-size: 12.5px; font-weight: 700; cursor: pointer; border: 1px solid transparent;
  transition: background .12s, color .12s;
}
.pill-toggle__dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.pill-toggle--on { background: #d8f5e3; color: #0f7a3d; }
.pill-toggle--on:hover { background: #bdeecd; }
.pill-toggle--off { background: #fde2e2; color: #b42318; }
.pill-toggle--off:hover { background: #f9cccc; }
[data-theme="dark"] .pill-toggle--on { background: rgba(26,161,121,.2); color: #34d399; }
[data-theme="dark"] .pill-toggle--off { background: rgba(239,68,68,.18); color: #f87171; }
.details__phone { font-size: 13px; color: var(--text-soft); margin-top: 2px; }
.details__quick { display: flex; gap: 10px; justify-content: center; margin-top: 14px; }
.qa { width: 40px; height: 40px; border-radius: 10px; background: var(--bg); color: var(--brand); display: grid; place-items: center; cursor: pointer; transition: background .12s; }
.qa:hover { background: #e6eeff; }
.details__section { padding: 18px 20px; border-bottom: 1px solid var(--border-soft); }
.details__section h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-mute); margin-bottom: 12px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { background: #eef4ff; color: var(--brand); font-size: 12px; font-weight: 500; padding: 4px 10px; border-radius: 20px; }
.fields { display: flex; flex-direction: column; gap: 10px; }
.fields div { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.fields dt { color: var(--text-soft); }
.fields dd { font-weight: 500; text-align: right; }
.status-pills { display: flex; gap: 8px; }
.pill { flex: 1; padding: 8px; border-radius: 8px; border: 1px solid var(--border); font-weight: 500; color: var(--text-soft); transition: all .12s; }
.pill--active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ============ MODALES ============ */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; }
.modal[hidden] { display: none; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(18,28,45,.45); backdrop-filter: blur(2px); }
.modal__card { position: relative; background: var(--panel); border-radius: 16px; width: 540px; max-width: 92vw; max-height: 88vh; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal__card--sm { width: 420px; }
/* El modal de Tickets es más grande: la lista y el detalle piden más aire. */
#ticketsModal .modal__card { width: 760px; max-width: 94vw; max-height: 92vh; }
#ticketsModal .modal__body { padding: 22px 26px; }
.modal__head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal__head h2 { font-size: 17px; font-weight: 700; }
.modal__body { padding: 20px 22px; overflow-y: auto; }
.pagos__frame { display: block; width: 100%; height: 620px; max-height: calc(88vh - 60px); border: 0; }
.modal__foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

.mode-switch { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.radio { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; font-size: 13px; transition: border-color .12s, background .12s; }
.radio:has(input:checked) { border-color: var(--brand); background: #f4f8ff; }
.radio input { width: 16px; height: 16px; accent-color: var(--brand); }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.form-group label small { font-weight: 400; color: var(--text-mute); }
.form-group input, .form-group select { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; outline: none; transition: border-color .12s; background: var(--input-bg); color: var(--text); }
.form-group input:focus, .form-group select:focus { border-color: var(--brand); }
.hint { font-size: 12px; color: var(--text-mute); margin-top: 6px; line-height: 1.45; }
.inline-field { display: flex; gap: 8px; align-items: center; }
.hint code, code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: 12px; font-family: ui-monospace, Menlo, Consolas, monospace; }

/* plantillas */
.tpl { padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; cursor: pointer; transition: border-color .12s, background .12s; }
.tpl:hover { border-color: var(--brand); background: #f4f8ff; }
.tpl__name { font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.tpl__cat { font-size: 10px; font-weight: 700; color: var(--brand); background: #eef4ff; padding: 2px 7px; border-radius: 10px; text-transform: uppercase; }
.tpl__body { font-size: 13px; color: var(--text-soft); margin-top: 5px; white-space: pre-wrap; }
.tpl__lang { font-size: 10px; font-weight: 700; color: var(--text-mute); background: var(--bg); padding: 2px 7px; border-radius: 10px; text-transform: uppercase; }
.tpl__meta { font-size: 11px; color: var(--text-mute); margin-top: 6px; }
.tpl__empty { padding: 24px 6px; text-align: center; color: var(--text-soft); font-size: 13px; }
.tpl__var { background: #fff3d6; color: #9a6b00; padding: 0 4px; border-radius: 4px; font-weight: 600; }
[data-theme="dark"] .tpl__var { background: #3a2f10; color: #e8c66a; }
.tpl__fill { color: var(--text); font-weight: 700; }
/* formulario de variables */
.tpl__back { border: 0; background: none; color: var(--brand); font-size: 12.5px; font-weight: 600; cursor: pointer; padding: 0 0 10px; }
.tpl__card { background: var(--wa-bubble); border-radius: 10px; padding: 11px 13px; margin-bottom: 14px; }
.tpl__head-txt { font-weight: 700; font-size: 13.5px; margin-bottom: 5px; }
.tpl__media { font-size: 11.5px; font-weight: 600; color: var(--text-soft); background: rgba(0,0,0,.05); border-radius: 6px; padding: 6px 8px; margin-bottom: 6px; }
.tpl__prev { font-size: 13.5px; white-space: pre-wrap; line-height: 1.45; }
.tpl__foot { font-size: 11.5px; color: var(--text-soft); margin-top: 6px; }
.tpl__btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; border-top: 1px solid rgba(0,0,0,.08); padding-top: 8px; }
.tpl__btns span { font-size: 12px; font-weight: 600; color: var(--brand); }
.tpl__field { display: block; margin-bottom: 10px; }
.tpl__field span { display: block; font-size: 11.5px; font-weight: 600; color: var(--text-soft); margin-bottom: 4px; }
.tpl__field input { width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px; background: var(--input-bg); color: var(--text); outline: none; }
.tpl__field input:focus { border-color: var(--brand); }
.tpl__send { width: 100%; margin-top: 6px; padding: 11px; border-radius: 10px; font-weight: 700; font-size: 13.5px; color: #fff; background: var(--brand); border: 0; cursor: pointer; }
.tpl__send:hover { background: var(--brand-dark); }
.tpl__send:disabled { opacity: .6; cursor: default; }

/* toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #1c2434; color: #fff; padding: 11px 20px; border-radius: 10px; font-size: 13px; font-weight: 500; box-shadow: var(--shadow); z-index: 200; animation: toastIn .2s ease; }
.toast[hidden] { display: none; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #cfd6e0; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #b6bfcd; }

/* responsive básico */
@media (max-width: 1100px) { .app { grid-template-columns: 64px 300px 1fr; } .details { display: none; } }
@media (max-width: 820px)  { .app { grid-template-columns: 64px 1fr; } .list { display: none; } }

/* ============ DISPOSITIVOS (sesiones de WhatsApp por QR) ============ */
.devbadge {
  margin-left: 8px; padding: 3px 9px; border-radius: 20px;
  font-size: 10.5px; font-weight: 700; cursor: pointer;
  background: #eef4ff; color: var(--brand); border: 1px solid transparent;
}
.devbadge:hover { border-color: var(--brand); }
[data-theme="dark"] .devbadge { background: #17223a; }

.dev__nota { font-size: 12.5px; color: var(--text-soft); margin-bottom: 14px; line-height: 1.45; }
.dev {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px; margin-bottom: 8px;
  border: 1px solid var(--border); border-radius: 10px; cursor: pointer;
}
.dev:hover { border-color: var(--brand); background: var(--hover); }
.dev--activo { border-color: var(--brand); background: var(--active); }
.dev__main { flex: 1; min-width: 0; }
.dev__nombre { font-size: 13.5px; font-weight: 600; }
.dev__aqui { font-size: 9.5px; font-weight: 800; text-transform: uppercase; color: var(--brand); }
.dev__sub { font-size: 11.5px; color: var(--text-mute); margin-top: 1px; }
.dev__estado { font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.dev__estado--ok { background: #d8f5e3; color: #0f7a3d; }
.dev__estado--medio { background: #fff3d6; color: #9a6b00; }
.dev__estado--mal { background: #fde2e2; color: #b42318; }
.dev__acc { display: flex; gap: 4px; }
.dev__btn { padding: 4px 9px; border: 1px solid var(--border); border-radius: 7px; font-size: 11px; font-weight: 600; color: var(--text-soft); }
.dev__btn:hover { border-color: var(--brand); color: var(--brand); }
.dev__btn--x:hover { border-color: var(--danger); color: var(--danger); }
.dev__vacio, .dev__err { font-size: 12.5px; color: var(--text-mute); padding: 10px 0; text-align: center; }
.dev__err { color: var(--danger); }
.dev__cfg { display: block; margin: 8px auto 0; padding: 6px 12px; border-radius: 8px; background: var(--brand); color: #fff; font-size: 12px; font-weight: 600; }
.dev__nuevo {
  width: 100%; margin-top: 6px; padding: 11px; border: 1px dashed var(--border); border-radius: 10px;
  font-size: 13px; font-weight: 600; color: var(--text-soft);
}
.dev__nuevo:hover { border-color: var(--brand); color: var(--brand); }
.qr { margin-top: 16px; padding: 16px; border: 1px solid var(--border); border-radius: 12px; text-align: center; }
.qr img { width: 240px; max-width: 100%; border-radius: 8px; background: #fff; }
.qr p { font-size: 12.5px; color: var(--text-soft); margin-top: 12px; line-height: 1.5; }

/* ============ TICKETS ============ */
.tk__lbl { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-soft); margin-bottom: 12px; }
.tk__inp { display: block; width: 100%; margin-top: 5px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--input-bg); color: var(--text); outline: none; font-size: 14px; }
.tk__inp:focus { border-color: var(--brand); }
.tk__area { resize: vertical; min-height: 90px; line-height: 1.45; }
.tk__row { display: flex; gap: 10px; }
.tk__row .tk__lbl { flex: 1; }
.tk__err { color: var(--danger); font-size: 13px; margin: 0 0 10px; }
/* --- adjuntos --- */
.tk__hint { font-weight: 400; color: var(--text-mute); }
.tk__area--drop { border-color: var(--brand); background: rgba(47,109,246,.06); }
.tk__adj { display: block; width: 100%; margin-top: 6px; padding: 9px 12px; border: 1px dashed var(--border); border-radius: 9px; background: var(--input-bg); color: var(--text-soft); font-size: 13px; font-weight: 600; cursor: pointer; }
.tk__adj:hover { border-color: var(--brand); color: var(--brand); }
.tk__chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tk__chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 5px 6px 5px 9px; border-radius: 8px; background: var(--bg); border: 1px solid var(--border); font-size: 12px; font-weight: 500; color: var(--text); }
.tk__chip-n { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk__chip-p { color: var(--text-mute); font-size: 11px; }
.tk__chip-x { width: 18px; height: 18px; border-radius: 4px; color: var(--text-mute); font-size: 15px; line-height: 1; cursor: pointer; }
.tk__chip-x:hover { background: var(--danger); color: #fff; }
.tk__enviar { width: 100%; padding: 12px; border-radius: 10px; background: var(--brand); color: #fff; font-weight: 700; font-size: 14px; cursor: pointer; }
.tk__enviar:hover { background: var(--brand-dark); }
.tk__enviar:disabled { opacity: .6; cursor: default; }
.tk__cfg-link { display: block; margin: 14px auto 0; color: var(--text-mute); font-size: 12px; text-decoration: underline; }
.tk__ok { text-align: center; padding: 20px 8px; }
.tk__ok-ic { width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 50%; background: #d8f5e3; color: #0f7a3d; font-size: 26px; font-weight: 800; display: grid; place-items: center; }
[data-theme="dark"] .tk__ok-ic { background: rgba(26,161,121,.2); color: #34d399; }
.tk__ok p { font-size: 14px; color: var(--text-soft); }
.tk__otro { margin-top: 16px; padding: 9px 18px; border: 1px solid var(--border); border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--text-soft); }
.tk__otro:hover { border-color: var(--brand); color: var(--brand); }

/* ============ SIN ACCESO A LA PLATAFORMA ============ */
.noacc { max-width: 420px; margin: 12vh auto; padding: 40px 28px; text-align: center; font-family: 'Inter', system-ui, sans-serif; color: var(--text); }
.noacc__ic { font-size: 46px; margin-bottom: 14px; }
.noacc h1 { font-size: 22px; font-weight: 700; margin-bottom: 10px; }
.noacc p { color: var(--text-soft); font-size: 14.5px; line-height: 1.5; }
.noacc__links { display: flex; flex-direction: column; gap: 10px; margin: 22px 0; }
.noacc__link { padding: 12px; border: 1px solid var(--border); border-radius: 10px; text-decoration: none; color: var(--brand); font-weight: 600; }
.noacc__link:hover { background: var(--hover); }
.noacc__out { margin-top: 8px; padding: 10px 20px; border: 1px solid var(--border); border-radius: 10px; color: var(--text-soft); font-weight: 600; cursor: pointer; }

/* casillas de plataforma en el panel de usuarios */
.plats { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 5px; }
.plat { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border: 1px solid var(--border); border-radius: 9px; font-size: 13px; cursor: pointer; user-select: none; }
.plat input { margin: 0; }
.plat--on { border-color: var(--brand); background: rgba(47,109,246,.08); color: var(--brand); font-weight: 600; }
.plat--lock { opacity: .6; cursor: default; }
.plats__nota { font-size: 12px; color: var(--text-mute); margin-top: 6px; }
.pill--plat { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 8px; background: var(--bg); color: var(--text-soft); margin-right: 3px; }

/* tickets: pestañas y lista */
.tk__tabs { display: flex; gap: 4px; padding: 0 22px; border-bottom: 1px solid var(--border); }
.tk__tab { padding: 10px 14px; font-size: 13.5px; font-weight: 600; color: var(--text-soft); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tk__tab--on { color: var(--brand); border-color: var(--brand); }
.tk__cargando, .tk__vacio, .tk__err { padding: 26px 8px; text-align: center; color: var(--text-mute); font-size: 13.5px; }
.tk__err { color: var(--danger); }
.tkitem__adjs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.tkitem__adj { display: inline-block; max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 3px 8px; border-radius: 7px; background: var(--bg); border: 1px solid var(--border); font-size: 11.5px; color: var(--text-soft); text-decoration: none; }
.tkitem__adj:hover { border-color: var(--brand); color: var(--brand); }
.tkitem__est { font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.tkitem__est--nuevo { background: var(--bg); color: var(--text-soft); }
.tkitem__est--prog { background: #fff3d6; color: #9a6b00; }
.tkitem__est--ok { background: #d8f5e3; color: #0f7a3d; }
.tkitem__est--espera { background: #e6ecff; color: #3b52b4; }
[data-theme="dark"] .tkitem__est--ok { background: rgba(26,161,121,.2); color: #34d399; }
[data-theme="dark"] .tkitem__est--prog { background: #3a2f10; color: #e8c66a; }
[data-theme="dark"] .tkitem__est--espera { background: #1b2350; color: #9db2ff; }

/* --- barra: filtros con contador + buscador --- */
.tklist__bar { display: flex; flex-direction: column; gap: 9px; padding: 4px 0 10px; }
/* interruptor Míos / Todos (solo admin) */
.tkscope { display: inline-flex; align-self: flex-start; padding: 3px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; }
.tkscope__b { padding: 5px 14px; font-size: 12.5px; font-weight: 700; color: var(--text-soft); border-radius: 7px; cursor: pointer; }
.tkscope__b--on { background: var(--panel); color: var(--brand); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
/* fila de selects de filtro */
.tkfilters { display: flex; flex-wrap: wrap; gap: 6px; }
.tksel { flex: 1; min-width: 120px; padding: 7px 9px; font-size: 12.5px; font-weight: 500; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 9px; outline: none; cursor: pointer; }
.tksel:focus { border-color: var(--brand); }
.tkfils { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.tkfils::-webkit-scrollbar { display: none; }
.tkfil { flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border: 1px solid var(--border); border-radius: 20px; font-size: 12.5px; font-weight: 600; color: var(--text-soft); background: var(--panel); cursor: pointer; white-space: nowrap; }
.tkfil:hover { border-color: var(--brand); }
.tkfil--on { background: var(--brand); border-color: var(--brand); color: #fff; }
.tkfil__n { font-size: 11px; font-weight: 800; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--bg); color: var(--text-soft); display: grid; place-items: center; }
.tkfil--on .tkfil__n { background: rgba(255,255,255,.25); color: #fff; }
.tksearch { display: flex; align-items: center; gap: 8px; padding: 8px 11px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; }
.tksearch svg { width: 16px; height: 16px; fill: var(--text-mute); flex-shrink: 0; }
.tksearch__inp { flex: 1; border: 0; background: none; outline: none; color: var(--text); font-size: 13.5px; min-width: 0; }

/* --- filas de la lista --- */
.tklist { display: flex; flex-direction: column; }
.tkrow { display: flex; align-items: stretch; gap: 11px; width: 100%; padding: 11px 6px 11px 0; text-align: left; border-bottom: 1px solid var(--border-soft); cursor: pointer; background: none; }
.tkrow:hover { background: var(--hover); }
.tkrow__pri { width: 4px; border-radius: 3px; flex-shrink: 0; background: var(--text-mute); }
.tkrow__pri--baja { background: #94a3b8; }
.tkrow__pri--media { background: var(--brand); }
.tkrow__pri--alta { background: #f59e0b; }
.tkrow__pri--urgente { background: var(--danger); }
.tkrow__main { flex: 1; min-width: 0; }
.tkrow__top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tkrow__title { font-weight: 600; font-size: 14px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tkrow__meta { display: block; font-size: 12px; color: var(--text-mute); margin-top: 3px; }
.tkrow__go { align-self: center; color: var(--text-mute); font-size: 20px; flex-shrink: 0; }

/* --- detalle de un ticket --- */
.tkdet { padding: 4px 2px 8px; }
.tkdet__back { display: inline-flex; align-items: center; font-size: 13px; font-weight: 600; color: var(--text-soft); padding: 6px 0; margin-bottom: 6px; cursor: pointer; background: none; }
.tkdet__back:hover { color: var(--brand); }
.tkdet__title { font-size: 17px; font-weight: 700; line-height: 1.3; margin-bottom: 10px; }
.tkdet__badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.tkbadge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px; background: var(--bg); border: 1px solid var(--border); color: var(--text-soft); }
.tkbadge--baja { border-color: #94a3b8; color: #64748b; }
.tkbadge--media { border-color: var(--brand); color: var(--brand); }
.tkbadge--alta { border-color: #f59e0b; color: #b45309; }
.tkbadge--urgente { border-color: var(--danger); color: var(--danger); }
.tkdet__meta { font-size: 12px; color: var(--text-mute); margin-bottom: 14px; }
.tkdet__desc { font-size: 14px; line-height: 1.6; color: var(--text); background: var(--bg); border: 1px solid var(--border-soft); border-radius: 10px; padding: 13px 15px; white-space: normal; word-break: break-word; }
.tkdet__sec { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-mute); margin: 16px 0 8px; }
.tkdet__imgs { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.tkdet__img { display: block; aspect-ratio: 1; border-radius: 9px; overflow: hidden; border: 1px solid var(--border); }
.tkdet__img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tkdet__img:hover { border-color: var(--brand); }

/* ── Bloqueo de contactos ─────────────────────────────────────────────────── */
.conv__blocked { display:inline-block; font-size:11px; font-weight:700; padding:1px 7px; border-radius:999px; background:#e5e7eb; color:#374151; margin-right:6px; }
[data-theme="dark"] .conv__blocked { background:#374151; color:#e5e7eb; }
.conv--blocked .conv__name { color:#6b7280; text-decoration:line-through; text-decoration-thickness:1px; }
[data-theme="dark"] .conv--blocked .conv__name { color:#9ca3af; }
.tab--blocked.tab--has { color:#4b5563; opacity:1; }
.tab--blocked.tab--has .tab__count { background:#4b5563; }
.tab--blocked.tab--active { border-color:#4b5563; color:#4b5563; }
[data-theme="dark"] .tab--blocked.tab--has { color:#9ca3af; }
[data-theme="dark"] .tab--blocked.tab--active { border-color:#9ca3af; color:#9ca3af; }

/* Botón Bloquear/Desbloquear en el header del contacto */
#convBlock { margin-top:6px; }
.pill-toggle--blockbtn { background:#eef1f4; color:#4b5563; }
.pill-toggle--blockbtn:hover { background:#e2e6ea; }
.pill-toggle--blocked { background:#374151; color:#fff; }
.pill-toggle--blocked:hover { background:#1f2937; }
[data-theme="dark"] .pill-toggle--blockbtn { background:#2a2f3a; color:#cbd5e1; }
[data-theme="dark"] .pill-toggle--blockbtn:hover { background:#333a47; }
[data-theme="dark"] .pill-toggle--blocked { background:#b91c1c; color:#fff; }

/* ── Sección Bloqueados: alta manual de números + lista ───────────────────── */
.blk-add { display:flex; gap:8px; padding:12px 12px 4px; }
.blk-add__input { flex:1; min-width:0; padding:9px 11px; border:1px solid var(--border,#d9dde3); border-radius:9px; font-size:14px; background:#fff; color:#111; }
[data-theme="dark"] .blk-add__input { background:#1b1f27; color:#e5e7eb; border-color:#333a47; }
.blk-add__btn { padding:9px 14px; border:none; border-radius:9px; background:#374151; color:#fff; font-weight:600; font-size:13px; cursor:pointer; white-space:nowrap; }
.blk-add__btn:hover { background:#1f2937; }
.blk-hint { padding:0 12px 10px; font-size:12px; color:#9aa3b2; }
.blk-list { padding:0 6px 12px; }
.blk-empty { padding:24px 16px; text-align:center; color:#9aa3b2; font-size:13.5px; }
.blk-row { display:flex; align-items:center; gap:10px; padding:9px 10px; border-radius:10px; }
.blk-row--conv { cursor:pointer; }
.blk-row:hover { background:rgba(0,0,0,.04); }
[data-theme="dark"] .blk-row:hover { background:rgba(255,255,255,.05); }
.blk-row__main { flex:1; min-width:0; }
.blk-row__name { font-weight:600; font-size:14px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.blk-row__sub { font-size:12px; color:#9aa3b2; }
.blk-row__btn { padding:6px 11px; border:1px solid var(--border,#d9dde3); border-radius:8px; background:transparent; color:#4b5563; font-size:12.5px; font-weight:600; cursor:pointer; white-space:nowrap; }
.blk-row__btn:hover { border-color:#dc2626; color:#dc2626; }
[data-theme="dark"] .blk-row__btn { color:#cbd5e1; border-color:#333a47; }

/* Respuestas / comentarios de un ticket */
.tkcoms { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.tkcom { background: var(--bg); border: 1px solid var(--border-soft); border-radius: 10px; padding: 9px 12px; }
.tkcom__h { font-size: 11.5px; font-weight: 600; color: var(--text-mute); margin-bottom: 3px; }
.tkcom__b { font-size: 13.5px; line-height: 1.45; color: var(--text); white-space: normal; }

/* Estrellas de calificación de la resolución */
.tkrate { display: flex; align-items: center; gap: 10px; }
.tkstars { display: inline-flex; gap: 2px; font-size: 26px; line-height: 1; }
.tkstar { color: var(--border); transition: color .12s, transform .12s; }
.tkstar--on { color: #f5b301; }
.tkstars--edit .tkstar { cursor: pointer; }
.tkstars--edit:hover .tkstar { color: #f5b301; }
.tkstars--edit .tkstar:hover ~ .tkstar { color: var(--border); }
.tkstars--edit .tkstar:hover { transform: scale(1.15); }
.tkrate__val { font-size: 13px; font-weight: 700; color: var(--text); }
.tkrate__hint { font-size: 12.5px; color: var(--text-mute); }
/* Comentario del propio creador (después de calificar) */
.tkmycom { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.tkmycom__ta { width: 100%; resize: vertical; min-height: 44px; font: inherit; font-size: 13.5px; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); }
.tkstaff { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.tkstaff__wait { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-soft); cursor: pointer; }
.tkstaff__row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tkstaff__attach { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; font: inherit; font-size: 12.5px; cursor: pointer; color: var(--text); }
.tkstaff__attach:hover { background: var(--hover); }
.tkstaff__files { font-size: 12px; color: var(--text-mute); overflow: hidden; text-overflow: ellipsis; }
.tkcom__files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.tkcom__img { display: block; width: 64px; height: 64px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border-soft); }
.tkcom__img img { width: 100%; height: 100%; object-fit: cover; }
.tkcom__file { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; padding: 5px 9px; border: 1px solid var(--border-soft); border-radius: 8px; color: var(--brand); text-decoration: none; }
.tkmycom__btn { background: var(--brand); color: #fff; border: 0; border-radius: 8px; padding: 8px 16px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.tkmycom__btn:hover { filter: brightness(1.05); }
.tkcom--mine { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 8%, var(--bg)); }

/* Borrar ticket (solo super admin) */
.tkdet__danger { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border); }
.tkdel { background: none; border: 1px solid #ef4444; color: #ef4444; border-radius: 8px; padding: 8px 14px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; transition: background .12s, color .12s; }
.tkdel:hover { background: #ef4444; color: #fff; }

/* Selector de categoría en el detalle del ticket (solo super admin) */
select.tkcat-sel { padding: 3px 8px; border-radius: 999px; cursor: pointer; border: 1px dashed var(--border); background: var(--bg); color: var(--text); font: inherit; font-size: 12px; }
/* Selector de estado del ticket (solo super admin) */
select.tkest-sel { padding: 2px 8px; border-radius: 10px; cursor: pointer; border: 1px dashed var(--border); background: var(--bg); color: var(--text); font: inherit; font-size: 11px; font-weight: 700; }
/* Aviso "están esperando tu respuesta" en el detalle del cliente */
.tkmycom__wait { font-size: 12.5px; color: #3b52b4; background: #e6ecff; border-radius: 8px; padding: 8px 11px; margin: 4px 0 8px; }
[data-theme="dark"] .tkmycom__wait { color: #9db2ff; background: #1b2350; }
