/* ==========================================================================
   CRM — Front Desk design system
   Todo el CSS va scoped bajo .crm-root para no pisar Bootstrap 3 del admin.
   Tokens por-club se inyectan vía .crm-root.theme--<club>.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Geist+Mono:wght@400;500;600&display=swap');

/* --- Tokens base (tool identity — constantes entre clubs) ------------ */
.crm-root {
  /* paper — alineado con fondo app (body.logged-in = #E6E7E8) */
  --bg:        #E6E7E8;
  --paper:     #FFFFFF;
  --paper-2:   #FFFFFF;
  --paper-sunk:#F1F2F2;

  /* ink — grises neutros, no warm */
  --ink:   #1D2327;
  --ink-2: #3A4147;
  --ink-3: #6A7178;
  --ink-4: #9BA1A7;
  --ink-5: #CBD0D4;

  /* rules */
  --rule:     #DDE0E2;
  --rule-2:   #C7CBD0;
  --rule-ink: #2A2F33;

  /* brand (por club — default = navy neutro, cada club override con su theme) */
  --brand:     #002B49;
  --brand-ink: #003D66;
  --brand-bg:  #D4DEE6;
  --brand-fg:  #FFFFFF;

  /* status semánticos — NO se sobreescriben por club */
  --terracotta:   #B54A36;
  --terracotta-bg:#F1D7CE;
  --mustard:      #B8872A;
  --mustard-bg:   #F0E1B8;
  --sage:         #5E7F5E;
  --sage-bg:      #DDE6D5;
  --ocean:        #2E5266;
  --ocean-bg:     #D1DDE4;

  /* type — alineado con app (Open Sans body) + Geist para headers/mono */
  --font-display: 'Open Sans', -apple-system, sans-serif;
  --font-body:    'Open Sans', -apple-system, sans-serif;
  --font-mono:    'Geist Mono', 'JetBrains Mono', ui-monospace, monospace;

  /* space */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px;

  /* radius */
  --r-1: 3px; --r-2: 6px; --r-3: 10px; --r-4: 14px;

  /* elevation */
  --sh-1: 0 1px 0 rgba(20,19,17,.04), 0 1px 2px rgba(20,19,17,.04);
  --sh-2: 0 2px 0 rgba(20,19,17,.04), 0 8px 24px -12px rgba(20,19,17,.18);

  /* reset tipográfico del wrapper */
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* Page-level wrapper (no aplica a modales ni al timeline embebido en /usernew) */
.crm-root:not(.c-modal):not(.ctl) {
  min-height: 100vh;
  /* 60px = ancho del sidebar fijo del backend admin (.main-menu en el tema del club).
     Le sumamos var(--s-5) para que haya respiro visual entre el sidebar y el contenido. */
  padding: var(--s-6) var(--s-7) var(--s-6) calc(60px + var(--s-5));
  background: var(--bg);
}

/* Timeline embebido en /usernew: fondo transparente, sin franja gris al final */
.crm-root.ctl {
  background: transparent;
}
.crm-root.ctl .ctl-list { padding-bottom: 0; }
.crm-root.ctl .ctl-group:last-child { margin-bottom: 0; }

/* Cuando el sidebar está en hover y se expande a 250px, no cambiamos el padding:
   el sidebar tiene overflow visible y flota por encima. */

/* --- Themes por club (override de la capa brand) --------------------- */
.crm-root.theme--squalus  { --brand:#002B49; --brand-ink:#003D66; --brand-bg:#D4DEE6; --brand-fg:#FFFFFF; }
.crm-root.theme--forest   { --brand:#1E3A32; --brand-ink:#2A4F44; --brand-bg:#DCE4DF; --brand-fg:#F1ECDF; }
.crm-root.theme--burgundy { --brand:#6B1F2D; --brand-ink:#83273A; --brand-bg:#EBD4D8; --brand-fg:#F5E6E3; }
.crm-root.theme--navy     { --brand:#1A2E4A; --brand-ink:#27406B; --brand-bg:#D6DCE8; --brand-fg:#EDEEF3; }
.crm-root.theme--ocre     { --brand:#8A5A14; --brand-ink:#A8711E; --brand-bg:#F0E1C4; --brand-fg:#F6ECD4; }
.crm-root.theme--teal     { --brand:#104E52; --brand-ink:#196269; --brand-bg:#CFE2E2; --brand-fg:#E8F0EE; }

/* --- Reset local para no heredar Bootstrap 3 --- */
.crm-root *, .crm-root *::before, .crm-root *::after { box-sizing: border-box; }
.crm-root a { color: inherit; text-decoration: none; }
.crm-root button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.crm-root input, .crm-root textarea, .crm-root select { font: inherit; color: inherit; }
.crm-root h1, .crm-root h2, .crm-root h3, .crm-root h4 { font-family: var(--font-display); font-weight: 500; letter-spacing: -.015em; margin: 0; }

/* --- Page header --- */
.crm-root .page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-5);
  padding-bottom: var(--s-5); margin-bottom: var(--s-5);
  border-bottom: 1px solid var(--rule);
}
.crm-root .eyebrow {
  font-size: 11px; font-weight: 500; text-transform: uppercase;
  letter-spacing: .18em; color: var(--ink-4); margin-bottom: 8px;
}
.crm-root .page-title {
  font-family: var(--font-display); font-weight: 700;
  font-size: 26px; line-height: 1.15; letter-spacing: -.01em; color: var(--ink);
  margin: 0;
}
.crm-root .page-title em { font-weight: 500; color: var(--ink-3); font-style: normal; }
.crm-root .page-sub { color: var(--ink-3); margin-top: 6px; max-width: 60ch; }
.crm-root .page-actions { display: flex; gap: var(--s-2); flex: 0 0 auto; }
.crm-root .breadcrumb {
  font-size: 12px; color: var(--ink-3); margin-bottom: 8px;
  display: flex; align-items: center; gap: 6px;
  background: transparent; padding: 0;
}
.crm-root .breadcrumb a:hover { color: var(--ink); }
.crm-root .breadcrumb .sep { color: var(--ink-5); }

/* --- Buttons --- */
.crm-root .c-btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 14px; border-radius: var(--r-2);
  font-size: 13px; font-weight: 500; letter-spacing: -.005em;
  border: 1px solid var(--rule); background: var(--paper-2); color: var(--ink);
  transition: all .15s ease; white-space: nowrap;
}
.crm-root .c-btn:hover { border-color: var(--rule-ink); }
.crm-root .c-btn.primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.crm-root .c-btn.primary:hover { background: var(--ink-2); border-color: var(--ink-2); }
.crm-root .c-btn.brand { background: var(--brand); border-color: var(--brand); color: var(--brand-fg); }
.crm-root .c-btn.brand:hover { background: var(--brand-ink); border-color: var(--brand-ink); }
.crm-root .c-btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.crm-root .c-btn.ghost:hover { background: var(--paper-sunk); }
.crm-root .c-btn.sm { height: 26px; padding: 0 10px; font-size: 12px; }
.crm-root .c-btn.xs { height: 22px; padding: 0 8px; font-size: 11.5px; }

/* --- Avatar --- */
.crm-root .c-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-ink), var(--brand));
  color: var(--brand-fg); font-size: 11px; font-weight: 600;
  display: grid; place-items: center; letter-spacing: .02em;
}
.crm-root .c-avatar.sm { width: 22px; height: 22px; font-size: 9.5px; }
.crm-root .c-avatar.ghost {
  background: var(--paper-sunk); color: var(--ink-4);
  border: 1px dashed var(--rule-2);
}

/* --- Stats ---
   Grid 4 columnas idénticas. Todas las cards comparten mismo layout interno
   (display: flex column) para que el contenido se alinee sin importar largo
   del label o delta. Bar izquierdo es neutro por default — solo cambia a
   color cuando hay alert/warn/ok real, así un solo card colorado destaca
   sin que los vecinos se vean "apagados" por contraste. */
.crm-root .c-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--s-3);
  margin-bottom: var(--s-6);
  align-items: stretch;
}
.crm-root .c-stat {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  padding: 14px 16px 14px 18px; /* +2px izquierda: aire respecto al bar */
  position: relative;
  overflow: hidden;
  min-height: 96px;
  box-sizing: border-box;
  min-width: 0; /* grid item: evita que min-content empuje la columna y rompa los 1fr */
  margin: 0; /* anula Bootstrap `.alert{margin-bottom:20px}` cuando la card usa el modifier `.alert` */
}
.crm-root .c-stat::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--rule-2);
  transition: background .15s ease;
}
.crm-root .c-stat.alert::before { background: var(--terracotta); }
.crm-root .c-stat.warn::before  { background: var(--mustard); }
.crm-root .c-stat.ok::before    { background: var(--sage); }
.crm-root .c-stat-label {
  font-size: 10.5px; font-weight: 500;
  text-transform: uppercase; letter-spacing: .14em;
  color: var(--ink-4); margin-bottom: 6px;
}
.crm-root .c-stat-value {
  font-family: var(--font-display); font-weight: 500; font-size: 28px;
  letter-spacing: -.02em; line-height: 1; font-variant-numeric: tabular-nums;
}
.crm-root .c-stat-delta {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--ink-3); margin-top: 4px;
}

/* Stat cards clickables — drill-down a filtros */
.crm-root .c-stat--clickable {
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .1s;
  user-select: none;
}
.crm-root .c-stat--clickable:hover {
  border-color: var(--ink-4);
  box-shadow: 0 4px 12px rgba(0,0,0,.05);
  transform: translateY(-1px);
}
.crm-root .c-stat.active {
  border-color: var(--ink);
  background: var(--ink);
}
.crm-root .c-stat.active::before       { background: rgba(255,255,255,.25); }
.crm-root .c-stat.active.alert::before { background: var(--terracotta); }
.crm-root .c-stat.active.warn::before  { background: var(--mustard); }
.crm-root .c-stat.active.ok::before    { background: var(--sage); }
.crm-root .c-stat.active .c-stat-label,
.crm-root .c-stat.active .c-stat-delta { color: rgba(255,255,255,.7); }
.crm-root .c-stat.active .c-stat-value { color: var(--paper); }

/* Ticket resuelto en bandeja (filter=resolved) */
.crm-root .c-ticket.is-resolved { border-left: 3px solid var(--sage); opacity: .92; }
.crm-root .c-ticket.is-resolved:hover { opacity: 1; }
.crm-root .c-resolved-time {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--sage); font-weight: 500;
  white-space: nowrap;
}

/* --- Group --- */
.crm-root .c-group { margin-bottom: var(--s-6); }
.crm-root .c-group-head {
  display: flex; align-items: baseline; gap: 12px;
  padding: 0 2px var(--s-3);
  border-bottom: 1px solid var(--rule); margin-bottom: var(--s-3);
}
.crm-root .c-group-title {
  font-family: var(--font-display); font-weight: 600; font-size: 16px;
  letter-spacing: -.005em;
}
.crm-root .c-group-title em { color: var(--ink-3); font-style: normal; font-weight: 400; }
.crm-root .c-group-count {
  font-family: var(--font-mono); font-size: 12px; color: var(--ink-4);
  font-variant-numeric: tabular-nums;
}
.crm-root .c-group-meta { margin-left: auto; font-size: 12px; color: var(--ink-3); }

/* --- Ticket row --- */
.crm-root .c-ticket {
  display: grid;
  grid-template-columns: 28px auto auto 1fr auto;
  gap: 12px; align-items: center;
  padding: 14px 18px;
  background: var(--paper); border: 1px solid var(--rule);
  border-radius: var(--r-3); margin-bottom: 6px;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.crm-root .c-ticket:hover { border-color: var(--rule-2); background: var(--paper-2); }
.crm-root .c-ticket.needs-reply {
  background: linear-gradient(90deg, rgba(46,82,102,.05), transparent 35%);
  border-color: rgba(46,82,102,.25);
}

/* Overdue: acento terracotta claro, sin gradiente ruidoso.
   Borde izquierdo sólido + bg muy sutil — el peso visual vive en la
   pill de "VENCIDO HACE Xm" de la derecha y en el dot rojo, no en el row entero. */
.crm-root .c-ticket.overdue {
  background: var(--paper);
  border-color: rgba(181,74,54,.28);
  box-shadow: inset 3px 0 0 0 var(--terracotta);
}
.crm-root .c-ticket.overdue:hover {
  background: rgba(181,74,54,.03);
  border-color: rgba(181,74,54,.4);
}

/* Tickets de lead — accent violeta. Mismo color que el wide pipeline card del
   dashboard y el badge LEAD del ticket detail. Si el ticket también está
   "overdue", la regla de overdue gana en visual (borde terracotta) — el chip
   LEAD inline al lado del nombre garantiza que la categoría siga siendo obvia. */
.crm-root .c-ticket.is-lead {
  box-shadow: inset 3px 0 0 0 #5e60ce;
}
.crm-root .c-ticket.is-lead:hover {
  background: rgba(94,96,206,.03);
  border-color: rgba(94,96,206,.3);
}
.crm-root .c-tk-lead-badge {
  display: inline-block;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .08em;
  padding: 2px 7px;
  margin-left: 6px;
  border-radius: 999px;
  background: #ece9ff;
  color: #5e60ce;
  vertical-align: 1px;
}

/* Bootstrap 3 cascading: neutralizar el `.alert` default (margin-bottom: 20px +
   padding 15px + border + radius) solo para el pattern Bootstrap — que siempre
   viene con una variante `.alert-*` (success/info/warning/danger). Nuestras
   clases internas `alert` (modifier local en .c-stat, .c-ticket, etc.) NO
   matchean con `.alert[class*=alert-]` y quedan intactas. */
.crm-root [class*="alert-"].alert {
  margin-bottom: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
}

/* Follow-up dot */
.crm-root .c-fu {
  width: 8px; height: 8px; border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(20,19,17,.03);
  flex: 0 0 auto; justify-self: center;
}
.crm-root .c-fu.red {
  background: var(--terracotta);
  box-shadow: 0 0 0 3px rgba(181,74,54,.15);
  animation: crm-pulse-red 2.4s ease-in-out infinite;
}
.crm-root .c-fu.amber  { background: var(--mustard); }
.crm-root .c-fu.green  { background: var(--sage); }
.crm-root .c-fu.grey   { background: var(--ink-5); }
@keyframes crm-pulse-red {
  0%,100% { box-shadow: 0 0 0 3px rgba(181,74,54,.15); }
  50%     { box-shadow: 0 0 0 6px rgba(181,74,54,.05); }
}

.crm-root .c-tk-num {
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 500;
  color: var(--ink-4); letter-spacing: .02em;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.crm-root .c-tk-age {
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 600;
  color: var(--ink-3);
  background: var(--paper-sunk);
  padding: 1px 6px;
  border-radius: 3px;
  letter-spacing: .02em;
  white-space: nowrap;
}
.crm-root .c-ticket.overdue .c-tk-age {
  color: var(--terracotta);
  background: var(--terracotta-bg);
}
.crm-root .c-tk-channel {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-family: var(--font-mono);
}

/* ==========================================================================
   Editorial masthead — header del ticket detail
   Enfoque: tipografía-primera, sin cajas, jerarquía clara.
   - Folio: badge mono con número de ticket (estilo stamp)
   - Título: display grande, hairline tight
   - Meta strip: data inline tipo masthead periodístico
   - Descripción: lead paragraph con accent line, sin fondo
   ========================================================================== */

/* Folio + título juntos */
.crm-root .c-mast {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: start;
  margin-bottom: 10px;
}
.crm-root .c-mast-folio {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 6px 10px 7px;
  border: 1px solid var(--rule-2);
  background: var(--paper);
  border-radius: var(--r-1);
  line-height: 1;
  /* subtle letterpress look */
  box-shadow: inset 0 -1px 0 var(--rule);
}
.crm-root .c-mast-folio-label {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .18em;
  color: var(--ink-4);
  margin-bottom: 3px;
}
.crm-root .c-mast-folio-num {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: .02em;
  font-variant-numeric: tabular-nums;
}
.crm-root .c-mast-title {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.1;
  color: var(--ink);
  margin: 4px 0 0;
  max-width: 860px;
  word-break: break-word;
}

/* Meta strip — línea de data inline */
.crm-root .c-mast-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
  margin-top: 8px;
  padding-bottom: 2px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.4;
}
.crm-root .c-mast-meta-item {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}
.crm-root .c-mast-meta-k {
  color: var(--ink-4);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 10.5px;
}
.crm-root .c-mast-meta-v {
  color: var(--ink-2);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.crm-root .c-mast-link {
  color: var(--brand);
  text-decoration: none;
  cursor: pointer;
  border-bottom: 1px dotted var(--brand);
  transition: color .15s;
}
.crm-root .c-mast-link:hover {
  color: var(--brand-ink);
  border-bottom-color: var(--brand-ink);
}
.crm-root .c-mast-meta-sep {
  color: var(--ink-5);
  font-family: var(--font-body);
  user-select: none;
}

/* Descripción — lead paragraph sin caja */
.crm-root .c-mast-desc {
  margin-top: 18px;
  padding-left: 14px;
  border-left: 2px solid var(--rule-2);
  max-width: 760px;
  transition: border-color .2s;
}
.crm-root .c-mast-desc:hover { border-left-color: var(--brand); }
.crm-root .c-mast-desc-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .16em;
  color: var(--ink-4);
  margin-bottom: 6px;
}
.crm-root .c-mast-desc-body {
  font-family: var(--font-display);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  letter-spacing: -.005em;
}


/* --- Note log (reemplaza chat thread) --- */
.crm-root .c-notelog {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  display: flex;
  flex-direction: column;
  height: calc(100vh - 380px);
  min-height: 480px;
  overflow: hidden;
}
.crm-root .c-notelog-head {
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--rule);
}
.crm-root .c-notelog-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  display: block;
}
.crm-root .c-notelog-hint {
  font-size: 11.5px;
  margin-top: 2px;
  display: block;
}
.crm-root .c-notelog-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.crm-root .c-notelog-scroll::-webkit-scrollbar { width: 8px; }
.crm-root .c-notelog-scroll::-webkit-scrollbar-thumb {
  background: var(--rule-2); border-radius: 4px;
}
.crm-root .c-notelog-empty {
  padding: 32px 16px;
  text-align: center;
}

/* --- Note entry --- */
.crm-root .c-note-entry {
  background: var(--paper-sunk);
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  padding: 10px 14px;
}
.crm-root .c-note-entry-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.crm-root .c-note-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--brand);
  color: var(--brand-fg);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  flex: 0 0 auto;
  text-transform: uppercase;
}
.crm-root .c-note-entry-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}
.crm-root .c-note-author {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.crm-root .c-note-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-4);
}
.crm-root .c-note-entry-body {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
}

/* --- Resolver / Reabrir buttons (toolbar) --- */
.crm-root .c-btn.c-btn-resolve,
.crm-root .c-btn.c-btn-reopen {
  height: 34px;
  padding: 0 18px;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: var(--r-2);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  letter-spacing: .01em;
  transition: all .15s;
}
.crm-root .c-btn.c-btn-resolve {
  background: var(--sage);
  color: #FFF;
  border-color: var(--sage);
  box-shadow: 0 1px 0 rgba(94,127,94,.3);
}
.crm-root .c-btn.c-btn-resolve:hover {
  background: #4E6B4E;
  border-color: #4E6B4E;
  box-shadow: 0 2px 4px rgba(94,127,94,.35);
  transform: translateY(-1px);
}
.crm-root .c-btn.c-btn-reopen {
  background: var(--paper);
  color: var(--terracotta);
  border: 1px solid var(--terracotta);
}
.crm-root .c-btn.c-btn-reopen:hover {
  background: var(--terracotta);
  color: #FFF;
}
.crm-root .c-btn-icon {
  font-size: 16px;
  line-height: 1;
  display: inline-block;
}
.crm-root .c-tk-main { min-width: 0; }
.crm-root .c-tk-title {
  display: flex; align-items: center; gap: 10px;
  font-weight: 500; color: var(--ink); letter-spacing: -.005em;
  margin-bottom: 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.crm-root .c-inbound-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ocean); flex: 0 0 auto;
  box-shadow: 0 0 0 3px rgba(46,82,102,.18);
}
.crm-root .c-tk-meta {
  display: flex; align-items: center; gap: 10px;
  color: var(--ink-3); font-size: 12.5px; min-width: 0;
}
.crm-root .c-tk-meta .c-dot { width: 2px; height: 2px; background: var(--ink-5); border-radius: 50%; flex: 0 0 auto; }
.crm-root .c-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-3); min-width: 0; }
.crm-root .c-tk-right { display: flex; align-items: center; gap: 12px; justify-self: end; flex: 0 0 auto; }
.crm-root .c-fu-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  color: var(--ink-3); white-space: nowrap;
  padding: 3px 8px;
  border-radius: 12px;
  background: var(--paper-sunk);
  border: 1px solid transparent;
}
.crm-root .c-fu-label .c-fu-icon { font-size: 12px; line-height: 1; }
.crm-root .c-fu-label .c-fu-prefix {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 600;
  opacity: .75;
}
.crm-root .c-fu-label .c-fu-delta {
  font-family: var(--font-mono);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.crm-root .c-fu-label.red {
  color: var(--terracotta);
  background: var(--terracotta-bg);
  border-color: rgba(181,74,54,.35);
  font-weight: 600;
}
.crm-root .c-fu-label.red .c-fu-icon { animation: crm-fu-warn-bounce 1.8s ease-in-out infinite; }
@keyframes crm-fu-warn-bounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-1px); }
}
.crm-root .c-fu-label.amber {
  color: #6E5014;
  background: var(--mustard-bg);
  border-color: rgba(184,135,42,.3);
}
.crm-root .c-fu-label.green {
  color: #3E5A3E;
  background: var(--sage-bg);
}

/* --- Chips --- */
.crm-root .c-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 20px; padding: 0 8px;
  font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em;
  border-radius: 3px;
  background: var(--paper-sunk); color: var(--ink-2);
  white-space: nowrap;
}
.crm-root .c-chip.cat-INSTALACIONES { background: #E7DECF; color: #5A4830; }
.crm-root .c-chip.cat-SERVICIO      { background: var(--ocean-bg); color: #1F3D4D; }
.crm-root .c-chip.cat-ACTIVIDAD     { background: var(--sage-bg); color: #3E5A3E; }
.crm-root .c-chip.cat-PAGOS         { background: var(--mustard-bg); color: #6E5014; }
.crm-root .c-chip.cat-GENERAL       { background: var(--paper-sunk); color: var(--ink-2); }
.crm-root .c-chip.cat-INTERES       { background: #E6DEF0; color: #4A3C68; }
.crm-root .c-chip.cat-COTIZACION    { background: #F0E6D8; color: #6B4A1F; }
.crm-root .c-chip.cat-INFO          { background: #DCE8E4; color: #2F4F48; }
.crm-root .c-chip.cat-none {
  background: transparent;
  color: var(--terracotta);
  border: 1px dashed var(--terracotta);
  font-style: italic;
}
.crm-root .c-avatar.c-avatar-empty {
  background: transparent;
  border: 1px dashed var(--ink-4);
  color: var(--ink-4);
}

/* --- Follow-up card (rail, reemplaza fubtn del toolbar) --- */
.crm-root .c-followup-card { border-left: 3px solid var(--ink-5); }
.crm-root .c-followup-card.red   { border-left-color: var(--terracotta); }
.crm-root .c-followup-card.amber { border-left-color: var(--mustard); }
.crm-root .c-followup-card.green { border-left-color: var(--sage); }

.crm-root .c-fu-state {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-4);
}
.crm-root .c-fu-state.red   { color: var(--terracotta); }
.crm-root .c-fu-state.amber { color: #6E5014; }
.crm-root .c-fu-state.green { color: #3E5A3E; }
.crm-root .c-fu-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ink-5);
}
.crm-root .c-fu-dot.red   { background: var(--terracotta); box-shadow: 0 0 0 3px rgba(181,74,54,.15); }
.crm-root .c-fu-dot.amber { background: var(--mustard); }
.crm-root .c-fu-dot.green { background: var(--sage); }

/* Flash inline en el header del panel — feedback al cambiar el seguimiento.
   Reemplaza al .c-fu-state mientras está activo y se desvanece al success. */
.crm-root .c-fu-flash {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  animation: c-fu-flash-in .15s ease-out;
}
.crm-root .c-fu-flash.is-saving { color: var(--ink-3); }
.crm-root .c-fu-flash.is-saved  { color: var(--sage); }
.crm-root .c-fu-flash.is-error  { color: var(--terracotta); }
@keyframes c-fu-flash-in {
  from { opacity: 0; transform: translateY(-2px); }
  to   { opacity: 1; transform: translateY(0); }
}

.crm-root .c-fu-when {
  padding: 12px 0;
  border-bottom: 1px dashed var(--rule);
  margin-bottom: 12px;
}
.crm-root .c-fu-when-big {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -.01em;
  margin-bottom: 2px;
}
.crm-root .c-followup-card.red .c-fu-when-big { color: var(--terracotta); }

.crm-root .c-fu-actions .c-fu-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-bottom: 8px;
}
.crm-root .c-followup-card .c-snooze-chips { margin-bottom: 10px; }
.crm-root .c-followup-card .c-snooze-custom {
  display: flex; gap: 6px; align-items: center;
  padding-top: 10px;
  border-top: 1px dashed var(--rule);
}
.crm-root .c-followup-card .c-snooze-custom input {
  flex: 1 1 auto;
  min-width: 0;
  height: 30px;
  padding: 0 8px;
  font-size: 12px;
  border: 1px solid var(--rule-2);
  border-radius: var(--r-1);
  font-family: var(--font-body);
}

.crm-root .c-chip.prio-BAJA    { background: var(--paper-sunk); color: var(--ink-3); }
.crm-root .c-chip.prio-MEDIA   { background: var(--ocean-bg); color: var(--ocean); }
.crm-root .c-chip.prio-ALTA    { background: var(--mustard-bg); color: #6E5014; }
.crm-root .c-chip.prio-URGENTE { background: var(--terracotta); color: #FBF1E4; letter-spacing: .12em; }

.crm-root .c-chip.stt-NUEVO      { background: var(--ink); color: var(--paper); }
.crm-root .c-chip.stt-ASIGNADO   { background: var(--brand-bg); color: var(--brand); }
.crm-root .c-chip.stt-EN_PROCESO { background: var(--ocean-bg); color: var(--ocean); }
.crm-root .c-chip.stt-RESUELTO   { background: var(--sage-bg); color: #3E5A3E; }
.crm-root .c-chip.stt-CERRADO    { background: var(--paper-sunk); color: var(--ink-4); }
.crm-root .c-chip.stt-REABIERTO  { background: var(--terracotta-bg); color: var(--terracotta); }

.crm-root .c-chip.ghost {
  background: transparent; border: 1px solid var(--rule-2); color: var(--ink-3);
}

/* --- Filters --- */
.crm-root .c-filter-row {
  display: flex; align-items: center; gap: var(--s-2);
  margin-bottom: var(--s-4); flex-wrap: wrap;
}
.crm-root .c-filter {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px;
  font-size: 12px; font-weight: 500;
  background: var(--paper); border: 1px solid var(--rule); border-radius: 999px;
  color: var(--ink-2); transition: all .15s;
}
.crm-root .c-filter:hover { border-color: var(--rule-ink); }
.crm-root .c-filter.active {
  background: var(--ink); color: var(--paper); border-color: var(--ink);
}
.crm-root .c-filter .c-dim {
  color: var(--ink-4); font-family: var(--font-mono); font-size: 11px;
}
.crm-root .c-filter.active .c-dim { color: var(--paper); }

/* --- Card (generic) --- */
.crm-root .c-card {
  background: var(--paper); border: 1px solid var(--rule);
  border-radius: var(--r-3); overflow: hidden;
}
.crm-root .c-card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--rule);
  background: var(--paper-sunk);
}
.crm-root .c-card-title {
  font-family: var(--font-display); font-weight: 500; font-size: 13px;
  letter-spacing: .01em;
}
.crm-root .c-card-body { padding: 14px 16px; }
.crm-root .c-kv {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 6px 0; font-size: 12.5px;
}
.crm-root .c-kv + .c-kv { border-top: 1px dashed var(--rule); }
.crm-root .c-kv .k { color: var(--ink-4); }
.crm-root .c-kv .v { color: var(--ink); font-weight: 500; text-align: right; }
.crm-root .c-kv .v.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 400; }

/* --- Message bubbles --- */
.crm-root .c-thread {
  background: var(--paper); border: 1px solid var(--rule);
  border-radius: var(--r-3);
  display: flex; flex-direction: column;
  /* Altura fija derivada del viewport: header (~150px) + toolbar (~85px) +
     page padding. El área interna de mensajes hace scroll, el composer queda
     fijo al fondo. */
  height: calc(100vh - 380px);
  min-height: 480px;
  overflow: hidden;
}
.crm-root .c-thread-scroll {
  flex: 1 1 auto;
  min-height: 0;                /* necesario para que flex permita shrink */
  overflow-y: auto;
  display: flex; flex-direction: column; gap: var(--s-4);
  padding: var(--s-5) var(--s-5) var(--s-5);
}
.crm-root .c-thread-scroll::-webkit-scrollbar { width: 8px; }
.crm-root .c-thread-scroll::-webkit-scrollbar-thumb {
  background: var(--rule-2); border-radius: 4px;
}
.crm-root .c-thread-scroll::-webkit-scrollbar-thumb:hover { background: var(--ink-4); }
.crm-root .c-bubble {
  max-width: 75%;
  padding: 11px 14px;
  font-size: 13.5px; line-height: 1.5;
  border: 1px solid var(--rule);
}
.crm-root .c-bubble.inbound {
  align-self: flex-start;
  background: var(--paper-2); color: var(--ink);
  border-radius: var(--r-3) var(--r-3) var(--r-3) 2px;
}
.crm-root .c-bubble.outbound {
  align-self: flex-end;
  background: var(--brand); color: var(--brand-fg);
  border-color: var(--brand);
  border-radius: var(--r-3) var(--r-3) 2px var(--r-3);
}
.crm-root .c-bubble.internal {
  align-self: flex-end;
  background: var(--mustard-bg); color: #5F4210;
  border-color: #E4CE92;
  border-radius: var(--r-3);
  max-width: 70%; position: relative;
}
.crm-root .c-bubble.internal::before {
  content: "nota interna"; position: absolute; top: -9px; right: 10px;
  font-size: 9.5px; font-weight: 600; letter-spacing: .12em;
  text-transform: uppercase;
  background: var(--mustard); color: #FBF2DF;
  padding: 1px 7px; border-radius: 3px;
}
.crm-root .c-bubble-meta {
  display: flex; align-items: center; gap: 8px; margin-top: 6px;
  font-size: 10.5px; letter-spacing: .02em;
  color: var(--ink-4); font-family: var(--font-mono);
}
.crm-root .c-bubble.outbound .c-bubble-meta { color: rgba(241,236,223,.7); }

/* --- Audit line --- */
.crm-root .c-audit {
  display: flex; align-items: center; gap: var(--s-3);
  margin: 2px 0;
  color: var(--ink-4); font-size: 12px;
}
.crm-root .c-audit::before, .crm-root .c-audit::after {
  content: ""; flex: 1; height: 1px; background: var(--rule);
}
.crm-root .c-audit .c-event {
  white-space: nowrap; font-family: var(--font-mono); font-size: 11px;
  letter-spacing: .02em;
}
.crm-root .c-audit .c-event b { color: var(--ink-2); font-weight: 600; }

/* --- Snooze chips --- */
.crm-root .c-snooze-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.crm-root .c-snooze-chip {
  font-size: 11.5px; font-weight: 500;
  padding: 5px 10px; border-radius: 999px;
  background: var(--paper-sunk); border: 1px solid var(--rule);
  transition: all .15s;
}
.crm-root .c-snooze-chip:hover { border-color: var(--rule-ink); background: var(--paper-2); }
.crm-root .c-snooze-chip b { font-family: var(--font-mono); font-weight: 500; }

/* --- Helpers --- */
.crm-root .c-row { display: flex; align-items: center; gap: var(--s-3); }
.crm-root .c-row.end { justify-content: flex-end; }
.crm-root .c-row.wrap { flex-wrap: wrap; }
.crm-root .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.crm-root .muted { color: var(--ink-3); }
.crm-root .muted-2 { color: var(--ink-4); }

/* --- Ticket detail layout --- */
.crm-root .c-detail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: var(--s-6);
  align-items: start;
}
.crm-root .c-rail {
  display: flex; flex-direction: column; gap: var(--s-4);
  position: sticky; top: 12px;
}
@media (max-width: 1180px) {
  .crm-root .c-detail { grid-template-columns: minmax(0, 1fr); }
  .crm-root .c-rail { position: static; }
}

/* --- Toolbar de acciones rápidas (ticket detail) --- */
.crm-root .c-toolbar {
  display: flex; align-items: center; gap: var(--s-4);
  padding: 10px 14px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  margin-bottom: var(--s-5);
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 10;
}
.crm-root .c-tb-item {
  display: flex; flex-direction: column; gap: 3px;
  min-width: 0;
  position: relative;
}
.crm-root .c-tb-label {
  font-size: 9.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--ink-4);
}
.crm-root .c-tb-select,
.crm-root .c-tb-fubtn {
  height: 32px;
  min-width: 180px;
  width: 180px;
  padding: 0 28px 0 12px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--rule-2);
  background: var(--paper);
  border-radius: var(--r-1);
  color: var(--ink);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%236A7178' d='M0 0l5 6 5-6z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  box-sizing: border-box;
  line-height: 30px;
  text-align: left;
  position: relative;
}
.crm-root .c-tb-select:hover { border-color: var(--ink-4); }
.crm-root .c-tb-select:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-bg); }

/* Status + priority: fondo blanco + stripe izquierdo de color (color-dot) */
.crm-root .c-tb-select.c-tb-status,
.crm-root .c-tb-select.c-tb-priority {
  padding-left: 28px;
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%236A7178' d='M0 0l5 6 5-6z'/></svg>"),
    radial-gradient(circle at 14px 50%, currentColor 0 4px, transparent 5px);
  background-repeat: no-repeat, no-repeat;
  background-position: right 10px center, left 0 top 0;
  background-size: auto, 100% 100%;
}

.crm-root .c-tb-status.stt-NUEVO      { color: var(--ink); }
.crm-root .c-tb-status.stt-ASIGNADO   { color: var(--brand); }
.crm-root .c-tb-status.stt-EN_PROCESO { color: var(--ocean); }
.crm-root .c-tb-status.stt-RESUELTO   { color: #3E5A3E; }
.crm-root .c-tb-status.stt-CERRADO    { color: var(--ink-3); }
.crm-root .c-tb-status.stt-REABIERTO  { color: var(--terracotta); }

/* Lead status — mismos tonos que .c-chip.lead-stt-* para mantener
   consistencia visual entre tabla (chip readonly) y selector del detalle. */
.crm-root .c-tb-status.stt-EN_CONVERSACION { color: var(--ocean); }
.crm-root .c-tb-status.stt-CALIFICADO      { color: var(--brand); }
.crm-root .c-tb-status.stt-CONVERTIDO      { color: #3E5A3E; }
.crm-root .c-tb-status.stt-DESCARTADO      { color: var(--ink-3); }

.crm-root .c-tb-priority.prio-BAJA    { color: var(--ink-3); }
.crm-root .c-tb-priority.prio-MEDIA   { color: var(--ocean); }
.crm-root .c-tb-priority.prio-ALTA    { color: #6E5014; }
.crm-root .c-tb-priority.prio-URGENTE { color: var(--terracotta); font-weight: 700; }

/* Opciones del native select siempre legibles (fondo blanco, texto ink) */
.crm-root .c-tb-select option { background: var(--paper); color: var(--ink); font-weight: 500; }

/* Follow-up button — reset total + reconstruir idéntico a .c-tb-select con dot */
.crm-root .c-tb-followup { position: relative; }
.crm-root .c-tb-fubtn,
.crm-root button.c-tb-fubtn {
  all: unset !important;
  box-sizing: border-box !important;
  display: block !important;
  cursor: pointer !important;
  height: 32px !important;
  min-width: 180px !important;
  width: 180px !important;
  padding: 0 28px 0 28px !important;
  font-family: var(--font-body) !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  line-height: 30px !important;
  text-align: left !important;
  color: var(--ink-3) !important;
  background-color: var(--paper) !important;
  border: 1px solid var(--rule-2) !important;
  border-radius: var(--r-1) !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%236A7178' d='M0 0l5 6 5-6z'/></svg>"),
    radial-gradient(circle at 14px 50%, currentColor 0 4px, transparent 5px) !important;
  background-repeat: no-repeat, no-repeat !important;
  background-position: right 10px center, left 0 top 0 !important;
  background-size: auto, 100% 100% !important;
  transition: border-color .15s, box-shadow .15s !important;
}
.crm-root .c-tb-fubtn:hover { border-color: var(--ink-4) !important; }
.crm-root .c-tb-fubtn:focus { outline: 0 !important; border-color: var(--brand) !important; box-shadow: 0 0 0 3px var(--brand-bg) !important; }
.crm-root .c-tb-fubtn.red   { color: var(--terracotta) !important; }
.crm-root .c-tb-fubtn.amber { color: #6E5014 !important; }
.crm-root .c-tb-fubtn.green { color: #3E5A3E !important; }
.crm-root .c-tb-popover {
  position: absolute; top: calc(100% + 4px); left: 0;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  padding: 12px 14px;
  box-shadow: 0 8px 24px -12px rgba(20,19,17,.2);
  min-width: 300px;
  z-index: 20;
}

.crm-root .c-tb-spacer { flex: 1; }

@media (max-width: 1100px) {
  .crm-root .c-toolbar { position: static; }
}

/* --- Composer --- */
.crm-root .c-composer {
  border-top: 1px solid var(--rule);
  padding: var(--s-4) var(--s-5);
  background: var(--paper);
  border-radius: 0 0 var(--r-3) var(--r-3);
  flex: 0 0 auto;               /* queda fijo al fondo mientras el thread scrollea */
}
.crm-root .c-canned {
  display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px;
}
.crm-root .c-canned-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 10px;
  font-size: 11.5px; font-weight: 500;
  background: var(--paper-sunk); border: 1px solid var(--rule);
  border-radius: 999px; color: var(--ink-2);
  transition: all .15s;
}
.crm-root .c-canned-chip:hover { background: var(--paper-2); border-color: var(--rule-2); }
.crm-root .c-composer-input {
  width: 100%; min-height: 80px;
  border: 1px solid var(--rule); border-radius: var(--r-2);
  padding: 10px 12px;
  background: var(--paper-2);
  resize: vertical; outline: none;
  font-size: 13.5px; line-height: 1.55;
  font-family: var(--font-body);
  transition: border-color .15s;
}
.crm-root .c-composer-input:focus { border-color: var(--ink); }
.crm-root .c-composer-foot {
  display: flex; align-items: center; gap: var(--s-3);
  margin-top: 10px; flex-wrap: wrap;
}
.crm-root .c-channel-pick {
  display: flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--ink-3);
}
.crm-root .c-channel-pick select {
  font: inherit; font-size: 11.5px;
  border: 1px solid var(--rule); background: var(--paper);
  border-radius: var(--r-1); padding: 3px 24px 3px 7px;
  min-width: 120px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%236A7178' d='M0 0l5 6 5-6z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
}
.crm-root .c-internal-toggle {
  display: flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--ink-3); cursor: pointer;
}
.crm-root .c-internal-toggle input { margin: 0; }
.crm-root .c-composer-foot .c-spacer { flex: 1; }

/* --- Status picker --- */
.crm-root .c-status-set { display: flex; flex-direction: column; gap: 6px; }
.crm-root .c-status-opt {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: var(--r-2);
  cursor: pointer; transition: background .15s;
}
.crm-root .c-status-opt:hover { background: var(--paper-sunk); }
.crm-root .c-status-opt.active {
  background: var(--paper-sunk);
  box-shadow: inset 2px 0 0 var(--ink);
}
.crm-root .c-status-opt .c-sdot { width: 7px; height: 7px; border-radius: 50%; }
.crm-root .c-status-opt .c-sdot.NUEVO      { background: var(--ink); }
.crm-root .c-status-opt .c-sdot.ASIGNADO   { background: var(--brand); }
.crm-root .c-status-opt .c-sdot.EN_PROCESO { background: var(--ocean); }
.crm-root .c-status-opt .c-sdot.RESUELTO   { background: var(--sage); }
.crm-root .c-status-opt .c-sdot.CERRADO    { background: var(--ink-5); }
.crm-root .c-status-opt .c-sdot.REABIERTO  { background: var(--terracotta); }
.crm-root .c-status-opt .c-slbl { font-size: 12.5px; font-weight: 500; }
.crm-root .c-status-opt .c-smeta { margin-left: auto; font-size: 11px; color: var(--ink-4); font-family: var(--font-mono); }

/* --- Snooze custom input --- */
.crm-root .c-snooze-custom {
  display: flex; align-items: center; gap: 8px;
  padding-top: 10px; border-top: 1px dashed var(--rule);
  font-size: 11.5px; color: var(--ink-3); margin-top: 10px;
}
.crm-root .c-snooze-custom input {
  flex: 1; height: 26px; padding: 0 8px;
  background: var(--paper-2); border: 1px solid var(--rule);
  border-radius: var(--r-1);
  font-family: var(--font-mono); font-size: 11.5px;
}

/* --- Detail head — paper card contenedor (da cuerpo al masthead) --- */
.crm-root .c-detail-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--s-5);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  padding: 20px 24px 22px;
  margin-bottom: var(--s-5);
  position: relative;
  /* subtle top accent — como cinta de expediente */
  box-shadow: 0 1px 0 var(--rule-2) inset;
}
.crm-root .c-detail-head::before {
  content: "";
  position: absolute;
  top: 0; left: 24px; right: 24px;
  height: 2px;
  background: linear-gradient(to right, var(--brand) 0%, var(--brand) 40%, transparent 40%, transparent 60%, var(--ink-5) 60%, var(--ink-5) 100%);
  opacity: .35;
}
.crm-root .c-detail-title {
  font-family: var(--font-display); font-weight: 500; font-size: 26px;
  letter-spacing: -.015em; line-height: 1.15; color: var(--ink);
  margin: 0 0 10px;
}
.crm-root .c-detail-title .c-tk-ref {
  font-family: var(--font-mono); font-size: 14px; font-weight: 400;
  color: var(--ink-4); margin-right: 10px; letter-spacing: 0;
}
.crm-root .c-detail-chips { display: flex; gap: 6px; flex-wrap: wrap; }

/* --- Thread day divider --- */
.crm-root .c-thread-day {
  align-self: center;
  font-family: var(--font-mono); font-size: 11px;
  color: var(--ink-4);
  background: var(--paper-sunk);
  border: 1px solid var(--rule);
  padding: 2px 10px; border-radius: 999px;
  letter-spacing: .04em;
}

/* ===============================================================
   MEMBER DETAIL — layout 3 columnas
   =============================================================== */
.crm-root .c-member {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 300px;
  gap: var(--s-5);
  align-items: start;
}
.crm-root .c-member-left,
.crm-root .c-member-right {
  position: sticky; top: 12px;
  display: flex; flex-direction: column; gap: var(--s-4);
}
@media (max-width: 1180px) {
  .crm-root .c-member { grid-template-columns: 240px minmax(0, 1fr); }
  .crm-root .c-member-right { display: none; }
}
@media (max-width: 900px) {
  .crm-root .c-member { grid-template-columns: 1fr; }
  .crm-root .c-member-left { position: static; }
}

/* --- Profile card (LEFT) --- */
.crm-root .c-profile-card {
  background: var(--paper); border: 1px solid var(--rule);
  border-radius: var(--r-3); padding: var(--s-5) var(--s-4);
}
.crm-root .c-profile-avatar {
  width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 12px;
  background: linear-gradient(135deg, var(--brand-ink), var(--brand));
  color: var(--brand-fg); font-size: 26px; font-weight: 500;
  display: grid; place-items: center; letter-spacing: .01em;
  font-family: var(--font-display); font-weight: 600;
  border: 2px solid var(--paper);
  box-shadow: 0 0 0 1px var(--rule-2);
}
.crm-root .c-profile-name {
  font-family: var(--font-display); font-weight: 500; font-size: 22px;
  text-align: center; letter-spacing: -.01em; line-height: 1.1;
  margin: 0 0 4px;
}
.crm-root .c-profile-sub {
  text-align: center; color: var(--ink-3);
  font-size: 12px; margin-bottom: 14px;
}
.crm-root .c-profile-marks {
  display: flex; gap: 6px; justify-content: center;
  margin-bottom: var(--s-4); flex-wrap: wrap;
}
.crm-root .c-mark {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.5px; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 3px;
}
.crm-root .c-mark.vip { background: var(--ink); color: #F4E8C6; }
.crm-root .c-mark.vip::before { content: "★"; color: #E8C97B; }
.crm-root .c-mark.risk-ALTO  { background: var(--terracotta-bg); color: var(--terracotta); }
.crm-root .c-mark.risk-MEDIO { background: var(--mustard-bg); color: #6E5014; }
.crm-root .c-mark.risk-BAJO  { background: var(--sage-bg); color: #3E5A3E; }

.crm-root .c-profile-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px 8px;
  padding: var(--s-3) 0;
  border-top: 1px dashed var(--rule);
  border-bottom: 1px dashed var(--rule);
  margin-bottom: var(--s-4);
}
.crm-root .c-pstat { text-align: center; }
.crm-root .c-pstat-value {
  font-family: var(--font-display); font-weight: 500; font-size: 20px;
  font-variant-numeric: tabular-nums; line-height: 1;
  letter-spacing: -.015em;
}
.crm-root .c-pstat-label {
  font-size: 10px; font-weight: 500;
  text-transform: uppercase; letter-spacing: .12em;
  color: var(--ink-4); margin-top: 4px;
}

.crm-root .c-contact-list { display: flex; flex-direction: column; gap: 8px; margin-top: var(--s-3); }
.crm-root .c-contact-row  { display: flex; align-items: center; gap: 10px; font-size: 12.5px; }
.crm-root .c-contact-row .k { color: var(--ink-4); width: 20px; flex: 0 0 auto; }
.crm-root .c-contact-row .v { color: var(--ink); overflow: hidden; text-overflow: ellipsis; }

/* --- Tabs (CENTER) --- */
.crm-root .c-tabs {
  display: flex; gap: 0;
  border-bottom: 1px solid var(--rule);
  margin-bottom: var(--s-4);
}
.crm-root .c-tab {
  padding: 10px 16px;
  font-size: 13px; font-weight: 500;
  color: var(--ink-3);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  letter-spacing: -.005em;
  transition: color .15s, border-color .15s;
}
.crm-root .c-tab:hover { color: var(--ink); }
.crm-root .c-tab.active { color: var(--ink); border-bottom-color: var(--ink); }
.crm-root .c-tab .c-count-inline {
  display: inline-block; margin-left: 6px;
  font-family: var(--font-mono); font-size: 10.5px;
  font-variant-numeric: tabular-nums; color: var(--ink-4);
}

/* --- Pinned notes (RIGHT) --- */
.crm-root .c-pin {
  background: var(--mustard-bg);
  border: 1px solid #E4CE92;
  border-radius: var(--r-3);
  padding: 14px 16px;
  position: relative;
}
.crm-root .c-pin + .c-pin { margin-top: 10px; }
.crm-root .c-pin::before {
  content: ""; position: absolute; top: 10px; left: -1px;
  width: 3px; height: 20px; background: var(--mustard); border-radius: 0 3px 3px 0;
}
.crm-root .c-pin.MEDICA   { background: var(--terracotta-bg); border-color: #E6B8A8; }
.crm-root .c-pin.MEDICA::before   { background: var(--terracotta); }
.crm-root .c-pin.ALERGIAS { background: #F4DED2; border-color: #E6C3A8; }
.crm-root .c-pin.ALERGIAS::before { background: #B8671E; }
.crm-root .c-pin-type {
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .14em;
  color: #6E5014; margin-bottom: 4px;
}
.crm-root .c-pin.MEDICA   .c-pin-type { color: var(--terracotta); }
.crm-root .c-pin.ALERGIAS .c-pin-type { color: #8A4A15; }
.crm-root .c-pin-body { font-size: 12.5px; color: var(--ink); line-height: 1.5; }
.crm-root .c-pin-foot {
  font-size: 10.5px; color: var(--ink-4); margin-top: 8px;
  font-family: var(--font-mono);
}

/* --- Alert item (RIGHT) --- */
.crm-root .c-alert-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px;
  background: var(--paper); border: 1px solid var(--rule);
  border-radius: var(--r-2);
}
.crm-root .c-alert-item + .c-alert-item { margin-top: 6px; }
.crm-root .c-alert-item .c-sev {
  width: 3px; align-self: stretch;
  border-radius: 2px; flex: 0 0 auto;
}
.crm-root .c-alert-item.CRITICAL .c-sev { background: var(--terracotta); }
.crm-root .c-alert-item.WARNING  .c-sev { background: var(--mustard); }
.crm-root .c-alert-item.INFO     .c-sev { background: var(--ocean); }
.crm-root .c-alert-body { flex: 1; min-width: 0; }
.crm-root .c-alert-title { font-weight: 500; font-size: 12.5px; margin-bottom: 2px; }
.crm-root .c-alert-meta  { font-size: 11px; color: var(--ink-4); font-family: var(--font-mono); }

/* --- Member ticket row (compacto dentro del tab Tickets) --- */
.crm-root .c-mticket {
  display: grid;
  grid-template-columns: 10px auto 1fr auto auto;
  gap: 14px; align-items: center;
  padding: 12px 16px;
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  margin-bottom: 6px;
  background: var(--paper);
  cursor: pointer; transition: border-color .15s;
}
.crm-root .c-mticket:hover { border-color: var(--rule-2); }
.crm-root .c-mticket-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.crm-root .c-mticket-title { font-weight: 500; letter-spacing: -.005em; }
.crm-root .c-mticket-meta  { color: var(--ink-3); font-size: 12px; }

/* --- Timeline entry (tab Timeline) --- */
.crm-root .c-tl-entry {
  display: grid; grid-template-columns: 110px 1fr;
  gap: 14px; padding: 10px 4px;
  border-bottom: 1px dashed var(--rule);
}
.crm-root .c-tl-when {
  font-family: var(--font-mono); font-size: 11.5px;
  color: var(--ink-4); padding-top: 2px;
}
.crm-root .c-tl-body { font-size: 13px; }
.crm-root .c-tl-body b { font-weight: 500; }

/* --- Search input (bandeja) --- */
.crm-root .c-search-wrap {
  position: relative;
  margin-bottom: var(--s-3);
}
.crm-root .c-search-input {
  width: 100%;
  height: 36px;
  padding: 0 32px 0 14px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  font-size: 13.5px;
  font-family: var(--font-body);
  color: var(--ink);
  outline: none;
  transition: border-color .15s;
}
.crm-root .c-search-input::placeholder { color: var(--ink-4); }
.crm-root .c-search-input:focus { border-color: var(--ink); background: var(--paper-2); }
.crm-root .c-search-clear {
  position: absolute;
  right: 8px;
  top: 50%; transform: translateY(-50%);
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--paper-sunk); color: var(--ink-3);
  font-size: 14px; line-height: 1;
  display: grid; place-items: center;
}
.crm-root .c-search-clear:hover { background: var(--rule-2); color: var(--ink); }

/* --- "Tomar" button (sin asignar) --- */
.crm-root .c-take {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-fg);
  font-weight: 600;
  letter-spacing: .02em;
}
.crm-root .c-take:hover {
  background: var(--brand-ink);
  border-color: var(--brand-ink);
}

/* ==============================================================
   LEADS — tabla, header card, status pills, mock banner
   ============================================================== */

.crm-root .c-mock-banner {
  background: linear-gradient(90deg, rgba(196,139,44,.12), rgba(196,139,44,.04) 60%);
  border: 1px solid #E4CE92;
  border-left: 3px solid var(--mustard);
  color: #5F4210;
  padding: 10px 16px;
  border-radius: var(--r-2);
  font-size: 12.5px;
  margin-bottom: var(--s-5);
}
.crm-root .c-mock-banner code {
  font-family: var(--font-mono); font-size: 11.5px;
  background: rgba(255,255,255,.6); padding: 1px 6px; border-radius: 3px;
}

/* --- Lead header card --- */
.crm-root .c-lead-header {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  padding: var(--s-5);
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--s-5);
  align-items: center;
  margin-bottom: var(--s-5);
}
.crm-root .c-lead-header-info h3,
.crm-root .c-lead-header-name {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 24px;
  letter-spacing: -.015em;
  margin: 0 0 4px;
}
.crm-root .c-lead-header-row {
  display: flex; gap: 10px;
  color: var(--ink-3); font-size: 12.5px; flex-wrap: wrap;
}

/* --- Lead status pills --- */
.crm-root .c-chip.lead-stt-nuevo      { background: var(--ink); color: var(--paper); }
.crm-root .c-chip.lead-stt-contactado { background: var(--ocean-bg); color: var(--ocean); }
.crm-root .c-chip.lead-stt-calificado { background: var(--brand-bg); color: var(--brand); }
.crm-root .c-chip.lead-stt-convertido { background: var(--sage-bg); color: #3E5A3E; }
.crm-root .c-chip.lead-stt-descartado { background: var(--paper-sunk); color: var(--ink-4); }

/* --- Leads table --- */
.crm-root .c-lead-table {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  overflow: hidden;
}
.crm-root .c-lead-head,
.crm-root .c-lead-row {
  display: grid;
  grid-template-columns: 28px 1.8fr 1.4fr .9fr .9fr .6fr 1.1fr .9fr 1fr;
  gap: 14px; align-items: center;
  padding: 12px 18px;
}
.crm-root .c-lead-system { font-style: italic; opacity: .7; }
.crm-root .c-lead-head {
  background: var(--paper-sunk);
  border-bottom: 1px solid var(--rule);
  font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .12em;
  color: var(--ink-4);
}
.crm-root .c-lead-row {
  border-bottom: 1px solid var(--rule);
  font-size: 13px;
  cursor: pointer;
  transition: background .15s;
}
.crm-root .c-lead-row:last-child { border-bottom: 0; }
.crm-root .c-lead-row:hover { background: var(--paper-2); }
.crm-root .c-lead-name {
  font-weight: 500; letter-spacing: -.005em;
  display: flex; flex-direction: column;
}
.crm-root .c-lead-sub {
  font-size: 11.5px; color: var(--ink-4);
  font-family: var(--font-mono); font-weight: 400;
  letter-spacing: 0; margin-top: 2px;
}
.crm-root .c-lead-src {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px;
  color: var(--ink-2);
}
.crm-root .c-lead-src .c-src-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--ink-5);
}
.crm-root .c-lead-src.chatbot  .c-src-dot { background: var(--ocean); }
.crm-root .c-lead-src.whatsapp .c-src-dot { background: var(--sage); }
.crm-root .c-lead-src.web      .c-src-dot { background: var(--mustard); }
.crm-root .c-lead-src.email    .c-src-dot { background: var(--brand); }

@media (max-width: 980px) {
  .crm-root .c-lead-head,
  .crm-root .c-lead-row {
    grid-template-columns: 28px 1.6fr 1fr .8fr .8fr;
  }
  .crm-root .c-lead-head > :nth-child(6),
  .crm-root .c-lead-head > :nth-child(7),
  .crm-root .c-lead-row  > :nth-child(6),
  .crm-root .c-lead-row  > :nth-child(7) { display: none; }
}

/* ==============================================================
   CONFIG MATRIX — follow-up config UI
   ============================================================== */
.crm-root .c-config-matrix {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  overflow: hidden;
}
.crm-root .c-config-head,
.crm-root .c-config-row {
  display: grid;
  grid-template-columns: 160px repeat(4, 1fr);
  gap: 0;
  align-items: stretch;
}
.crm-root .c-config-head {
  background: var(--paper-sunk);
  border-bottom: 1px solid var(--rule);
  padding: 12px 16px;
  font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .12em;
  color: var(--ink-4);
}
.crm-root .c-config-prio-head { padding-left: 12px; }
.crm-root .c-config-row {
  border-bottom: 1px solid var(--rule);
}
.crm-root .c-config-row:last-child { border-bottom: 0; }
.crm-root .c-config-cat {
  padding: 16px;
  display: flex; align-items: center;
  border-right: 1px solid var(--rule);
  background: var(--paper-sunk);
}
.crm-root .c-config-cell {
  padding: 12px 16px;
  display: flex; flex-direction: column; gap: 6px;
  border-right: 1px solid var(--rule);
}
.crm-root .c-config-cell:last-child { border-right: 0; }
.crm-root .c-config-input-wrap {
  position: relative;
  display: flex; align-items: center;
}
.crm-root .c-config-input {
  width: 100%;
  height: 30px;
  padding: 0 26px 0 10px;
  font-family: var(--font-mono);
  font-size: 13px;
  border: 1px solid var(--rule);
  border-radius: var(--r-1);
  background: var(--paper-2);
  outline: none;
  transition: border-color .15s;
  font-variant-numeric: tabular-nums;
}
.crm-root .c-config-input:focus { border-color: var(--ink); }
.crm-root .c-config-input::placeholder { color: var(--ink-5); }
.crm-root .c-config-unit {
  position: absolute;
  right: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-4);
  pointer-events: none;
}
.crm-root .c-config-toggle {
  display: flex; align-items: center; gap: 5px;
  font-size: 10.5px;
  color: var(--ink-4);
  cursor: pointer;
  letter-spacing: .02em;
}
.crm-root .c-config-toggle input { margin: 0; }

@media (max-width: 980px) {
  .crm-root .c-config-head,
  .crm-root .c-config-row {
    grid-template-columns: 120px repeat(4, 1fr);
  }
}

/* ==============================================================
   GLOBAL SEARCH — ⌘K overlay
   ============================================================== */
.crm-search-overlay,
.c-search-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(20, 19, 17, .55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  animation: c-overlay-in .15s ease;
}
@keyframes c-overlay-in { from { opacity: 0; } to { opacity: 1; } }

.c-search-overlay .c-search-modal {
  width: 720px;
  max-width: calc(100vw - 40px);
  max-height: 70vh;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  box-shadow: 0 20px 60px -20px rgba(20, 19, 17, .4);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: c-modal-in .18s ease;
}
@keyframes c-modal-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: none; }
}

.c-search-overlay .c-search-input-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--rule);
  background: var(--paper-sunk);
}
.c-search-overlay .c-search-input-row input {
  flex: 1;
  border: 0;
  background: transparent;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--ink);
  outline: none;
}
.c-search-overlay .c-search-input-row input::placeholder { color: var(--ink-4); }
.c-search-kbd {
  font-family: var(--font-mono); font-size: 10.5px;
  background: var(--paper-2); border: 1px solid var(--rule);
  border-radius: 3px; padding: 1px 6px;
  color: var(--ink-3);
  letter-spacing: .02em;
}

.c-search-overlay .c-search-results {
  flex: 1; overflow-y: auto;
  padding: 8px 0;
}
.c-search-section {
  padding: 8px 0;
}
.c-search-section + .c-search-section {
  border-top: 1px dashed var(--rule);
  margin-top: 4px;
}
.c-search-section-head {
  padding: 4px 18px 8px;
  font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .14em;
  color: var(--ink-4);
}
.c-search-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 18px;
  cursor: pointer;
  transition: background .12s;
}
.c-search-item:hover { background: var(--paper-sunk); }
.c-search-empty,
.c-search-hint {
  padding: 20px 18px;
  text-align: center;
  color: var(--ink-4);
  font-size: 13px;
}
.c-search-hint {
  background: var(--paper-sunk);
}

/* --- Loader --- */
.crm-root .c-empty {
  padding: var(--s-7) var(--s-5);
  text-align: center;
  color: var(--ink-3);
  background: var(--paper);
  border: 1px dashed var(--rule-2);
  border-radius: var(--r-3);
}
.crm-root .c-empty h4 {
  font-family: var(--font-display);
  font-size: 20px; font-weight: 500;
  color: var(--ink); margin-bottom: 6px;
}

/* ==========================================================================
   Modal — Ticket nuevo / edición (reemplaza estilos Bootstrap default)
   ========================================================================== */
.crm-root.c-modal {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  border-radius: var(--r-3);
  overflow: hidden;
}

.c-modal .c-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--rule);
}
.c-modal .c-modal-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-4);
  margin-bottom: 4px;
}
.c-modal .c-modal-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
  margin: 0;
  line-height: 1.2;
}
.c-modal .c-modal-close {
  background: transparent;
  border: 0;
  font-size: 26px;
  line-height: 1;
  color: var(--ink-4);
  cursor: pointer;
  padding: 0 4px;
  transition: color .15s;
}
.c-modal .c-modal-close:hover { color: var(--ink); }

.c-modal .c-modal-body {
  padding: 20px 24px;
}

/* ==========================================================================
   WhatsApp thread modal — header + message list
   ========================================================================== */
.c-modal.wa-thread {
  --wa-green:      #25D366;
  --wa-green-soft: #E0F6EA;
}

/* ---- Header ---- */
.c-modal.wa-thread .wa-head {
  position: relative;
  padding: 26px 28px 18px;
  background:
    radial-gradient(120% 80% at 100% 0%, rgba(37,211,102,.06) 0%, transparent 55%),
    linear-gradient(180deg, var(--paper) 0%, var(--paper) 72%, var(--paper-sunk) 100%);
  border-bottom: 1px solid var(--rule);
}

.c-modal.wa-thread .wa-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-4);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: color .15s ease, background .15s ease, border-color .15s ease;
}
.c-modal.wa-thread .wa-close:hover {
  color: var(--ink);
  background: var(--paper-sunk);
  border-color: var(--rule);
}
.c-modal.wa-thread .wa-close:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* Identity row */
.c-modal.wa-thread .wa-id {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-right: 36px; /* deja aire al close */
}

.c-modal.wa-thread .wa-avatar {
  position: relative;
  flex: 0 0 56px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--paper-sunk);
  border: 1px solid var(--rule);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-2);
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: .02em;
  box-shadow: inset 0 -1px 0 rgba(0,0,0,.03);
}
.c-modal.wa-thread .wa-avatar-mark { text-transform: uppercase; }
.c-modal.wa-thread .wa-avatar--skeleton {
  background: linear-gradient(90deg, var(--paper-sunk) 0%, #E8EAEB 50%, var(--paper-sunk) 100%);
  background-size: 200% 100%;
  animation: wa-skeleton 1.4s linear infinite;
}

.c-modal.wa-thread .wa-avatar-badge {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: var(--wa-green);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--paper);
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}

.c-modal.wa-thread .wa-id-text { min-width: 0; flex: 1; }

.c-modal.wa-thread .wa-name {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
  letter-spacing: -.015em;
  margin: 0 0 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.c-modal.wa-thread .wa-name--dim { color: var(--ink-4); }

.c-modal.wa-thread .wa-handle {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: .01em;
  color: var(--ink-3);
}
.c-modal.wa-thread .wa-handle-num  { color: var(--ink-2); font-weight: 500; }
.c-modal.wa-thread .wa-handle-sep  { color: var(--ink-5); }
.c-modal.wa-thread .wa-handle-from { color: var(--ink-4); }

/* Meta / chips row */
.c-modal.wa-thread .wa-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--rule);
}

.c-modal.wa-thread .wa-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  border: 1px solid transparent;
  line-height: 1.5;
  white-space: nowrap;
}

.c-modal.wa-thread .wa-pill--kind-member    { background: var(--brand-bg);    color: var(--brand); }
.c-modal.wa-thread .wa-pill--kind-ex_member { background: var(--paper-sunk);  color: var(--ink-3); border-color: var(--rule); }
.c-modal.wa-thread .wa-pill--kind-prospect  { background: var(--mustard-bg);  color: var(--mustard); }

.c-modal.wa-thread .wa-pill--state { background: transparent; }
.c-modal.wa-thread .wa-pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
  flex-shrink: 0;
}
.c-modal.wa-thread .wa-pill--state-open     { color: var(--mustard); border-color: var(--mustard); }
.c-modal.wa-thread .wa-pill--state-open .wa-pill-dot { animation: wa-pulse 1.9s ease-out infinite; }
.c-modal.wa-thread .wa-pill--state-resolved { color: var(--sage);    border-color: var(--sage); }

.c-modal.wa-thread .wa-pill--warn {
  background: var(--terracotta-bg);
  color: var(--terracotta);
}

.c-modal.wa-thread .wa-meta-sep {
  width: 3px;
  height: 3px;
  border-radius: 999px;
  background: var(--ink-5);
  margin: 0 2px;
  display: inline-block;
}
.c-modal.wa-thread .wa-meta-text {
  font-family: var(--font-mono);
  color: var(--ink-4);
  font-size: 11px;
  letter-spacing: .02em;
}

/* Staggered reveal (sutil, no distrae) */
.c-modal.wa-thread .wa-id        { animation: wa-fadein .32s ease both .04s; }
.c-modal.wa-thread .wa-meta > *  { animation: wa-fadein .36s ease both; }
.c-modal.wa-thread .wa-meta > *:nth-child(1) { animation-delay: .14s; }
.c-modal.wa-thread .wa-meta > *:nth-child(2) { animation-delay: .2s;  }
.c-modal.wa-thread .wa-meta > *:nth-child(3) { animation-delay: .26s; }
.c-modal.wa-thread .wa-meta > *:nth-child(4) { animation-delay: .32s; }
.c-modal.wa-thread .wa-meta > *:nth-child(5) { animation-delay: .38s; }
.c-modal.wa-thread .wa-meta > *:nth-child(6) { animation-delay: .44s; }
.c-modal.wa-thread .wa-meta > *:nth-child(7) { animation-delay: .5s;  }

@keyframes wa-fadein {
  from { opacity: 0; transform: translateY(3px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes wa-pulse {
  0%, 100% { opacity: 1;  transform: scale(1); }
  50%      { opacity: .35; transform: scale(.7); }
}
@keyframes wa-skeleton {
  from { background-position: 100% 0; }
  to   { background-position: -100% 0; }
}

/* ---- Body / messages ---- */
.c-modal.wa-thread .wa-thread-body { max-height: 60vh; overflow-y: auto; }
.c-modal.wa-thread .wa-loading,
.c-modal.wa-thread .wa-error,
.c-modal.wa-thread .wa-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--ink-4);
  font-size: 13px;
}
.c-modal.wa-thread .wa-error { color: var(--terracotta); }
.c-modal.wa-thread .wa-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.c-modal.wa-thread .wa-msg {
  display: flex;
  max-width: 82%;
}
.c-modal.wa-thread .wa-msg--in  { align-self: flex-start; }
.c-modal.wa-thread .wa-msg--out { align-self: flex-end; }
.c-modal.wa-thread .wa-msg-bubble {
  background: var(--paper-sunk);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--ink);
  line-height: 1.45;
}
.c-modal.wa-thread .wa-msg--out .wa-msg-bubble {
  background: var(--brand-bg);
  border-color: var(--brand-bg);
  color: var(--brand-ink);
}
.c-modal.wa-thread .wa-msg-sender {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-3);
  margin-bottom: 3px;
}
.c-modal.wa-thread .wa-msg--out .wa-msg-sender { color: var(--brand); }

/* Botón "Abrir en WhatsApp Manager" — link externo a la SPA full-feature.
   Se renderiza solo si el club tiene URL_WHATSAPP_MANAGER configurada. */
.c-modal.wa-thread .wa-open-mgr {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 600;
  text-decoration: none;
  transition: background .15s, border-color .15s, color .15s;
}
.c-modal.wa-thread .wa-open-mgr:hover {
  background: var(--brand-bg);
  border-color: var(--brand);
  color: var(--brand);
}

/* Variantes por origen del outbound: bot / auto-reply / template tienen
   color propio para que se distingan de los mensajes enviados por un admin. */
.c-modal.wa-thread .wa-msg--src-bot .wa-msg-bubble {
  background: #ede9fe;
  border-color: #ddd6fe;
  color: #4c1d95;
}
.c-modal.wa-thread .wa-msg--src-bot .wa-msg-sender { color: #6d28d9; }

.c-modal.wa-thread .wa-msg--src-auto_reply .wa-msg-bubble {
  background: #f1f5f9;
  border-color: #e2e8f0;
  color: #334155;
}
.c-modal.wa-thread .wa-msg--src-auto_reply .wa-msg-sender { color: #475569; }

.c-modal.wa-thread .wa-msg--src-template .wa-msg-bubble {
  background: #fefce8;
  border-color: #fde68a;
  color: #713f12;
}
.c-modal.wa-thread .wa-msg--src-template .wa-msg-sender { color: #a16207; }

.c-modal.wa-thread .wa-msg-content { white-space: pre-wrap; }
.c-modal.wa-thread .wa-msg-foot {
  margin-top: 4px;
  font-size: 10.5px;
  color: var(--ink-4);
  font-family: var(--font-mono);
}

.c-modal .c-modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 24px;
  border-top: 1px solid var(--rule);
  background: var(--paper-sunk);
}

/* --- Fields --- */
.c-modal .c-field { margin-bottom: 18px; }
.c-modal .c-field:last-child { margin-bottom: 0; }

.c-modal .c-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-3);
  margin-bottom: 6px;
}
.c-modal .c-req { color: var(--terracotta); margin-left: 2px; }
.c-modal .c-helper {
  font-size: 11px;
  color: var(--ink-4);
  margin-top: 4px;
  text-align: right;
  font-family: var(--font-mono);
}

.c-modal .c-input,
.c-modal .c-textarea {
  width: 100%;
  background: var(--paper);
  border: 1px solid var(--rule-2);
  border-radius: var(--r-2);
  padding: 10px 12px;
  font-size: 14px;
  font-family: var(--font-body);
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.c-modal .c-input:focus,
.c-modal .c-textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-bg);
}
.c-modal .c-textarea { resize: vertical; min-height: 100px; line-height: 1.5; }

.c-modal .c-select-wrap {
  position: relative;
  width: 100%;
}
.c-modal .c-select-wrap--narrow { max-width: 240px; }
.c-modal .c-select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: var(--paper) url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236A7178' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 12px center;
  border: 1px solid var(--rule-2);
  border-radius: var(--r-2);
  height: 38px;
  padding: 0 32px 0 12px;
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
}
.c-modal .c-select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-bg);
}

/* --- ui-select override scoped al modal (use !important — ui-select.min.css carga tarde) --- */
.crm-root.c-modal .ui-select-container,
.crm-root.c-modal .ui-select-bootstrap { display: block !important; width: 100% !important; padding: 6px 0 !important; }
.crm-root.c-modal .ui-select-bootstrap > .ui-select-match > .btn,
.crm-root.c-modal .ui-select-bootstrap > .ui-select-match > .btn.btn-default.form-control {
  display: flex !important;
  align-items: center !important;
  width: 100% !important;
  border: 1px solid var(--rule-2) !important;
  border-radius: var(--r-2) !important;
  height: 38px !important;
  min-height: 38px !important;
  line-height: 1.2 !important;
  padding: 0 32px 0 12px !important;
  margin: 0 !important;
  font-size: 14px !important;
  color: var(--ink) !important;
  background: var(--paper) !important;
  text-align: left !important;
  box-shadow: none !important;
  position: relative !important;
}
.crm-root.c-modal .ui-select-bootstrap > .ui-select-match > .btn .caret {
  position: absolute !important;
  right: 12px !important;
  top: 50% !important;
  margin-top: -2px !important;
  color: var(--ink-4) !important;
}
.crm-root.c-modal .ui-select-bootstrap .ui-select-search.form-control {
  width: 100% !important;
  height: 38px !important;
  padding: 0 12px !important;
  margin: 0 !important;
  border: 1px solid var(--rule-2) !important;
  border-radius: var(--r-2) !important;
  font-size: 14px !important;
  box-shadow: none !important;
}
.crm-root.c-modal .ui-select-bootstrap .ui-select-search[aria-expanded="false"],
.crm-root.c-modal .ui-select-bootstrap .ng-hide {
  display: none !important;
}
.crm-root.c-modal .ui-select-bootstrap .ui-select-choices {
  margin-top: 4px;
  border: 1px solid var(--rule-2);
  border-radius: var(--r-2);
  box-shadow: 0 4px 12px rgba(0,0,0,.08);
}
.crm-root.c-modal .ui-select-bootstrap .ui-select-choices-row.active > span {
  background: var(--brand-bg);
  color: var(--brand-ink);
}

.c-modal .c-user-opt { display: flex; flex-direction: column; padding: 4px 0; }
.c-modal .c-user-opt-name { font-weight: 600; color: var(--ink); }
.c-modal .c-user-opt-meta { font-size: 12px; color: var(--ink-4); margin-top: 2px; }

/* --- User chip (post selección) --- */
.c-modal .c-user-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--brand-bg);
  border: 1px solid var(--brand);
  border-radius: var(--r-2);
}
.c-modal .c-user-chip-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--brand);
  color: var(--brand-fg);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.c-modal .c-user-chip-body { flex: 1 1 auto; min-width: 0; }
.c-modal .c-user-chip-name { font-weight: 600; color: var(--ink); }
.c-modal .c-user-chip-meta { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.c-modal .c-user-chip-clear {
  background: transparent;
  border: 1px solid var(--brand);
  color: var(--brand-ink);
  border-radius: var(--r-1);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.c-modal .c-user-chip-clear:hover { background: var(--brand); color: var(--brand-fg); }

/* --- Divider --- */
.c-modal .c-divider {
  height: 1px;
  background: var(--rule);
  margin: 20px 0;
}

/* --- Pills (prioridad) --- */
.c-modal .c-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.c-modal .c-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--rule-2);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
}
.c-modal .c-pill:hover { border-color: var(--ink-4); color: var(--ink); }
.c-modal .c-pill-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--ink-5);
}
.c-modal .c-pill.is-active {
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}
.c-modal .c-pill.is-active .c-pill-dot { background: rgba(255,255,255,.85); }
.c-modal .c-pill.prio-BAJA     { background: var(--sage); }
.c-modal .c-pill.prio-MEDIA    { background: var(--ocean); }
.c-modal .c-pill.prio-ALTA     { background: var(--mustard); }
.c-modal .c-pill.prio-URGENTE  { background: var(--terracotta); }

/* --- Grid 3 col --- */
.c-modal .c-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}
.c-modal .c-grid-3 .c-field { margin-bottom: 0; }
@media (max-width: 720px) {
  .c-modal .c-grid-3 { grid-template-columns: 1fr; }
}

/* --- Buttons --- */
.c-modal .c-btn {
  padding: 9px 18px;
  border-radius: var(--r-2);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .15s;
  font-family: var(--font-body);
}
.c-modal .c-btn--ghost {
  background: transparent;
  color: var(--ink-2);
  border-color: var(--rule-2);
}
.c-modal .c-btn--ghost:hover { background: var(--paper); border-color: var(--ink-4); color: var(--ink); }
.c-modal .c-btn--primary {
  background: var(--brand);
  color: var(--brand-fg);
  border-color: var(--brand);
}
.c-modal .c-btn--primary:hover { background: var(--brand-ink); border-color: var(--brand-ink); }
.c-modal .c-btn--primary:disabled { opacity: .6; cursor: not-allowed; }
.c-modal .c-btn--success {
  background: var(--sage);
  color: #FFF;
  border-color: var(--sage);
}
.c-modal .c-btn--success:hover { background: #4E6B4E; border-color: #4E6B4E; }
.c-modal .c-btn--success:disabled { opacity: .6; cursor: not-allowed; }
.c-modal .c-btn--danger {
  background: var(--terracotta);
  color: #FFF;
  border-color: var(--terracotta);
}
.c-modal .c-btn--danger:hover { background: #9A3E2D; border-color: #9A3E2D; }
.c-modal .c-btn--danger:disabled { opacity: .6; cursor: not-allowed; }

/* ==========================================================================
   CRM Timeline — tab Timeline de /usernew/:id (ctl = Customer Timeline)
   ========================================================================== */
.crm-root.ctl {
  font-family: var(--font-body);
  color: var(--ink);
  padding: 0;
}

/* --- Insights (Stage F) --- */
.crm-root.ctl .ctl-insights {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  padding: 12px 16px;
  margin-bottom: 16px;
}
.crm-root.ctl .ctl-insights-head {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--ink-4);
  margin-bottom: 8px;
}
.crm-root.ctl .ctl-insights-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.crm-root.ctl .ctl-insight {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: var(--r-2);
  font-size: 13px;
  line-height: 1.4;
}
.crm-root.ctl .ctl-insight-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.crm-root.ctl .ctl-insight-text { color: var(--ink); }
.crm-root.ctl .ctl-insight--warn {
  background: var(--terracotta-bg);
  border-left: 3px solid var(--terracotta);
}
.crm-root.ctl .ctl-insight--warn .ctl-insight-dot { background: var(--terracotta); }
.crm-root.ctl .ctl-insight--warn .ctl-insight-text { color: var(--terracotta); font-weight: 500; }
.crm-root.ctl .ctl-insight--info {
  background: var(--mustard-bg);
  border-left: 3px solid var(--mustard);
}
.crm-root.ctl .ctl-insight--info .ctl-insight-dot { background: var(--mustard); }
.crm-root.ctl .ctl-insight--info .ctl-insight-text { color: #6E5014; font-weight: 500; }
.crm-root.ctl .ctl-insight--neutral {
  background: var(--paper-sunk);
  border-left: 3px solid var(--ink-4);
}
.crm-root.ctl .ctl-insight--neutral .ctl-insight-dot { background: var(--ink-4); }
.crm-root.ctl .ctl-insight--neutral .ctl-insight-text { color: var(--ink-2); }

/* --- Mini stats --- */
.crm-root.ctl .ctl-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
.crm-root.ctl .ctl-stat {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r-3);
  padding: 14px 16px;
}
.crm-root.ctl .ctl-stat-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-4);
  margin-bottom: 6px;
}
.crm-root.ctl .ctl-stat-value {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -.01em;
}
.crm-root.ctl .ctl-stat-value.warn { color: var(--mustard); }
.crm-root.ctl .ctl-stat .muted { color: var(--ink-4); font-weight: 400; font-size: 16px; }

/* --- Filtros --- */
.crm-root.ctl .ctl-filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rule);
}
.crm-root.ctl .ctl-filter {
  height: 32px;
  padding: 0 14px;
  border: 1px solid var(--rule-2);
  background: var(--paper);
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  transition: all .15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.crm-root.ctl .ctl-filter:hover { border-color: var(--ink-4); }
.crm-root.ctl .ctl-filter.active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.crm-root.ctl .ctl-dim {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  opacity: .7;
}

/* --- Empty / loading --- */
.crm-root.ctl .ctl-empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--ink-4);
}
.crm-root.ctl .ctl-empty i { font-size: 28px; margin-bottom: 12px; display: block; }

/* --- Lista general --- */
.crm-root.ctl .ctl-item { margin-bottom: 10px; }

/* --- Grupos por período (Stage E) --- */
.crm-root.ctl .ctl-group { margin-bottom: 18px; }
.crm-root.ctl .ctl-group-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 10px;
  padding: 0 0 6px 10px;
  border-bottom: 1px solid var(--rule);
}
.crm-root.ctl .ctl-group-title {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--ink-3);
}
.crm-root.ctl .ctl-group-count {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-4);
  background: var(--paper-sunk);
  padding: 1px 7px;
  border-radius: 999px;
}

/* --- TICKET (dense ledger row) ---
   Mismo patrón que .ctl-inter: [priority-dot | main 2-line | end meta].
   Prioridad como dot (URGENTE=terracotta pulse, ALTA=mustard, MEDIA=ink, BAJA=sage).
   Resueltos/cerrados bajan saturación para visual demote. */
.crm-root.ctl .ctl-ticket {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  padding: 10px 14px 10px 12px;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, transform .1s ease;
}
.crm-root.ctl .ctl-ticket:hover {
  background: var(--paper-sunk);
  border-color: var(--rule-2);
}
.crm-root.ctl .ctl-ticket:hover .ctl-ticket-chev {
  opacity: 1; transform: translateX(2px); color: var(--ink-2);
}
.crm-root.ctl .ctl-ticket:active { transform: translateY(1px); }
.crm-root.ctl .ctl-ticket:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

/* Priority dot */
.crm-root.ctl .ctl-ticket-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  justify-self: center;
  background: var(--ink-4);
  flex-shrink: 0;
}
.crm-root.ctl .ctl-ticket.pri-URGENTE .ctl-ticket-dot {
  background: var(--terracotta);
  box-shadow: 0 0 0 3px rgba(181,74,54,.14);
  animation: ctl-ticket-pulse-red 1.6s ease-out infinite;
}
.crm-root.ctl .ctl-ticket.pri-ALTA .ctl-ticket-dot {
  background: var(--mustard);
  box-shadow: 0 0 0 3px rgba(184,135,42,.12);
}
.crm-root.ctl .ctl-ticket.pri-MEDIA .ctl-ticket-dot { background: var(--ink-3); }
.crm-root.ctl .ctl-ticket.pri-BAJA  .ctl-ticket-dot { background: var(--sage); }

.crm-root.ctl .ctl-ticket.is-resolved .ctl-ticket-dot {
  background: var(--sage);
  opacity: .7;
  animation: none;
  box-shadow: none;
}
.crm-root.ctl .ctl-ticket.is-closed .ctl-ticket-dot {
  background: var(--ink-5);
  animation: none;
  box-shadow: none;
}

/* Main */
.crm-root.ctl .ctl-ticket-main { min-width: 0; }
.crm-root.ctl .ctl-ticket-row1 {
  display: flex;
  align-items: baseline;
  gap: 8px;
  overflow: hidden;
}
.crm-root.ctl .ctl-ticket-num {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  color: var(--ink-4);
  letter-spacing: .02em;
  flex-shrink: 0;
}
.crm-root.ctl .ctl-ticket-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.crm-root.ctl .ctl-ticket.is-resolved .ctl-ticket-title,
.crm-root.ctl .ctl-ticket.is-closed   .ctl-ticket-title {
  color: var(--ink-2);
}

.crm-root.ctl .ctl-ticket-row2 {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.4;
}

.crm-root.ctl .ctl-ticket-chip {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 3px;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  line-height: 1.5;
  flex-shrink: 0;
}
.crm-root.ctl .ctl-ticket-chip.cat {
  background: var(--paper-sunk);
  color: var(--ink-3);
  border: 1px solid var(--rule);
}
/* Los .stt-* heredan colores desde .c-chip global */

.crm-root.ctl .ctl-ticket-sep { color: var(--ink-5); flex-shrink: 0; }
.crm-root.ctl .ctl-ticket-assignee {
  color: var(--ink-2);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
}
.crm-root.ctl .ctl-ticket-assignee.muted {
  color: var(--ink-4);
  font-weight: 400;
  font-style: italic;
}

.crm-root.ctl .ctl-ticket-sla {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: .02em;
  flex-shrink: 0;
  white-space: nowrap;
}
.crm-root.ctl .ctl-ticket-sla.sla-red    { color: var(--terracotta); font-weight: 600; }
.crm-root.ctl .ctl-ticket-sla.sla-yellow { color: var(--mustard);    font-weight: 500; }
.crm-root.ctl .ctl-ticket-sla.sla-green  { color: var(--sage); }

.crm-root.ctl .ctl-ticket-resolved {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--sage);
  font-weight: 500;
  letter-spacing: .02em;
  flex-shrink: 0;
  white-space: nowrap;
}

/* End */
.crm-root.ctl .ctl-ticket-end {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.crm-root.ctl .ctl-ticket-time {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-3);
  letter-spacing: .02em;
  white-space: nowrap;
}
.crm-root.ctl .ctl-ticket-chev {
  color: var(--ink-5);
  opacity: .6;
  transition: opacity .12s ease, transform .15s ease, color .12s ease;
  flex-shrink: 0;
}

@keyframes ctl-ticket-pulse-red {
  0%, 100% { box-shadow: 0 0 0 3px rgba(181,74,54,.14); }
  50%      { box-shadow: 0 0 0 6px rgba(181,74,54,.04); }
}

/* Contenedor de lista de conversaciones en lead-detail — mismo rhythm que el
   timeline del socio (gap entre rows 10px para respirar visualmente). */
.crm-root .c-lead-convos > .ctl-inter + .ctl-inter { margin-top: 10px; }

/* --- INTERACTION (dense ledger row) ---
   Grid: [state dot | main | end-meta]. Compact height ~52px.
   Estado abierto/resuelto se señaliza con un dot (mustard pulse / sage).
   Hover: levanta con paper-sunk + chevron se desliza.
   Se usa tanto en /usernew timeline como en /crm/leads/:id detalle. */
.crm-root .ctl-inter {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  padding: 10px 14px 10px 12px;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, transform .1s ease;
}
.crm-root .ctl-inter:hover {
  background: var(--paper-sunk);
  border-color: var(--rule-2);
}
.crm-root .ctl-inter:hover .ctl-inter-chev {
  opacity: 1;
  transform: translateX(2px);
  color: var(--ink-2);
}
.crm-root .ctl-inter:active { transform: translateY(1px); }
.crm-root .ctl-inter:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

/* State dot */
.crm-root .ctl-inter-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  justify-self: center;
  flex-shrink: 0;
}
.crm-root .ctl-inter.is-open .ctl-inter-dot {
  background: var(--mustard);
  box-shadow: 0 0 0 3px rgba(184,135,42,.14);
  animation: ctl-inter-pulse 2s ease-out infinite;
}
.crm-root .ctl-inter.is-resolved .ctl-inter-dot {
  background: var(--sage);
  box-shadow: 0 0 0 3px rgba(94,127,94,.10);
}

/* Main (name + preview) */
.crm-root .ctl-inter-main { min-width: 0; }
.crm-root .ctl-inter-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.crm-root .ctl-inter-preview {
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.35;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.crm-root .ctl-inter-quote {
  color: var(--ink-5);
  font-family: var(--font-display);
  font-size: 15px;
  line-height: 0;
  vertical-align: -2px;
  margin: 0 1px;
}

/* End (meta right-aligned) */
.crm-root .ctl-inter-end {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  text-align: right;
  flex-shrink: 0;
}
.crm-root .ctl-inter-time {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-3);
  letter-spacing: .02em;
  white-space: nowrap;
}
.crm-root .ctl-inter-end-row2 {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.crm-root .ctl-inter-count {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-4);
  text-transform: lowercase;
  letter-spacing: .04em;
  white-space: nowrap;
}
.crm-root .ctl-inter-chev {
  color: var(--ink-5);
  opacity: .6;
  transition: opacity .12s ease, transform .15s ease, color .12s ease;
  flex-shrink: 0;
}

@keyframes ctl-inter-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(184,135,42,.14); }
  50%      { box-shadow: 0 0 0 6px rgba(184,135,42,.04); }
}

/* --- NOTE --- */
.crm-root.ctl .ctl-note {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  padding: 10px 14px;
}
.crm-root.ctl .ctl-note--pinned {
  background: var(--mustard-bg);
  border-color: var(--mustard);
}
.crm-root.ctl .ctl-note-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 4px;
}
.crm-root.ctl .ctl-note-type {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-3);
  background: var(--paper-sunk);
  padding: 2px 8px;
  border-radius: 3px;
}
.crm-root.ctl .ctl-note--pinned .ctl-note-type {
  background: var(--mustard);
  color: #FFF;
}
.crm-root.ctl .ctl-note-date {
  margin-left: auto;
  font-size: 11px;
  color: var(--ink-4);
  font-family: var(--font-mono);
}
.crm-root.ctl .ctl-note-subject { font-weight: 600; font-size: 13px; color: var(--ink); margin-bottom: 3px; }
.crm-root.ctl .ctl-note-body    { font-size: 12.5px; color: var(--ink-2); line-height: 1.45; }
.crm-root.ctl .ctl-note-foot    { font-size: 11px; color: var(--ink-4); margin-top: 4px; }

/* Severidad implícita por tipo de nota.
   Alta = alergias/médica (riesgo clínico) → terracotta.
   Media = importante (staff alert) → mustard.
   Baja = preferencias (contexto blando) → rosa. */
.crm-root.ctl .ctl-note--sev-alta {
  border-left: 4px solid var(--terracotta, #c0392b);
  background: rgba(192, 57, 43, .04);
}
.crm-root.ctl .ctl-note--sev-alta .ctl-note-type {
  background: var(--terracotta, #c0392b);
  color: #FFF;
}
.crm-root.ctl .ctl-note--sev-media {
  border-left: 4px solid var(--mustard, #b8872a);
  background: var(--mustard-bg, rgba(184, 135, 42, .06));
}
.crm-root.ctl .ctl-note--sev-media .ctl-note-type {
  background: var(--mustard, #b8872a);
  color: #FFF;
}
.crm-root.ctl .ctl-note--sev-baja {
  border-left: 4px solid #d68fa6;
  background: rgba(214, 143, 166, .06);
}
.crm-root.ctl .ctl-note--sev-baja .ctl-note-type {
  background: #d68fa6;
  color: #FFF;
}

/* Botón borrar — sólo aparece visible al hover de la card */
.crm-root.ctl .ctl-note-del {
  background: transparent;
  border: 0;
  color: var(--ink-4);
  cursor: pointer;
  padding: 2px 6px;
  font-size: 12px;
  opacity: 0;
  transition: opacity .12s, color .12s;
}
.crm-root.ctl .ctl-note:hover .ctl-note-del { opacity: 1; }
.crm-root.ctl .ctl-note-del:hover { color: var(--terracotta, #c0392b); }

/* Botón "Agregar nota" en la filter row del timeline */
.crm-root.ctl .ctl-add-note {
  padding: 5px 12px;
  font-size: 12.5px;
  font-weight: 500;
  border: 1px solid var(--rule);
  border-radius: var(--r-1, 4px);
  background: var(--paper);
  color: var(--ink-2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background .12s, border-color .12s, color .12s;
}
.crm-root.ctl .ctl-add-note:hover {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.crm-root.ctl .ctl-add-note i { font-size: 10px; }

/* Pin badge en card de nota (vista flat) */
.crm-root.ctl .ctl-note-pin {
  font-size: 10px;
  color: var(--mustard, #b8872a);
}

/* --- Row (reservation / status_change / edit / account) --- */
.crm-root.ctl .ctl-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r-2);
  font-size: 12.5px;
  color: var(--ink-2);
  flex-wrap: wrap;
}
.crm-root.ctl .ctl-row-type {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-4);
  background: var(--paper-sunk);
  padding: 2px 8px;
  border-radius: 3px;
  white-space: nowrap;
}
.crm-root.ctl .ctl-row-text { flex: 1 1 auto; color: var(--ink); }
.crm-root.ctl .ctl-row-meta { color: var(--ink-4); font-size: 11.5px; }
.crm-root.ctl .ctl-row-date {
  margin-left: auto;
  font-size: 11px;
  color: var(--ink-4);
  font-family: var(--font-mono);
}
.crm-root.ctl .ctl-row-amount {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--ink);
}
.crm-root.ctl .ctl-row--account.credit { border-left: 3px solid var(--sage); }
.crm-root.ctl .ctl-row--account.credit .ctl-row-amount { color: var(--sage); }
.crm-root.ctl .ctl-row--account.debit  { border-left: 3px solid var(--terracotta); }
.crm-root.ctl .ctl-row--account.debit  .ctl-row-amount { color: var(--terracotta); }

/* --- Edit changes --- */
.crm-root.ctl .ctl-edit-changes {
  flex-basis: 100%;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--rule);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.crm-root.ctl .ctl-edit-change {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  font-family: var(--font-mono);
}
.crm-root.ctl .ctl-edit-field { min-width: 120px; color: var(--ink-3); font-weight: 600; }
.crm-root.ctl .ctl-edit-from  { color: var(--terracotta); text-decoration: line-through; }
.crm-root.ctl .ctl-edit-arrow { color: var(--ink-4); }
.crm-root.ctl .ctl-edit-to    { color: var(--sage); font-weight: 600; }

/* Responsive */
@media (max-width: 768px) {
  .crm-root.ctl .ctl-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ============ Historial del ticket — card en el right rail ============ */
/* Lista compacta de eventos de auditoría (ASSIGNEE, STATUS, PRIORITY, etc).
   Reusa la misma fuente y paleta del rail; el ícono coloreado por tipo da
   barrido visual rápido sin meter ruido. Items separados por dashed rule. */
.crm-root .c-history-list { display: flex; flex-direction: column; }
.crm-root .c-history-item {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  padding: 10px 14px;
  border-top: 1px dashed var(--rule);
}
.crm-root .c-history-item:first-child { border-top: none; }
.crm-root .c-history-icon {
  width: 26px; height: 26px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  background: var(--paper-sunk);
  color: var(--ink-3);
  flex-shrink: 0;
}
/* Color por tipo — alineado con el resto de la app (sage, terracotta, mustard) */
.crm-root .c-history-icon.is-CREATED  { background: #e8eef4; color: #4c7fbf; }
.crm-root .c-history-icon.is-STATUS   { background: #e7f5f0; color: var(--sage); }
.crm-root .c-history-icon.is-RESOLVED { background: #e7f5f0; color: var(--sage); }
.crm-root .c-history-icon.is-REOPENED { background: #fbede1; color: var(--mustard); }
.crm-root .c-history-icon.is-PRIORITY { background: #fbede1; color: var(--mustard); }
.crm-root .c-history-icon.is-ASSIGNEE { background: #ece9ff; color: #5e60ce; }
.crm-root .c-history-icon.is-FOLLOWUP { background: #ece9ff; color: #5e60ce; }
.crm-root .c-history-icon.is-CATEGORY { background: var(--paper-sunk); color: var(--ink-3); }
.crm-root .c-history-line { font-size: 12.5px; color: var(--ink-2); line-height: 1.4; }
.crm-root .c-history-line b { font-weight: 600; color: var(--ink-1); }
.crm-root .c-history-meta { font-size: 11px; margin-top: 2px; }
.crm-root .c-history-note { font-size: 11.5px; margin-top: 4px; padding-left: 8px; border-left: 2px solid var(--rule); font-style: italic; }

