/* LG SESERFI (fork de whatsapiapp) · estilos base. Solo se permiten colores definidos en :root (§2.2). */

:root {
  /* Marca */
  /* LG SESERFI: azul corporativo #0368A4 y blanco */
  --brand-50:  #E8F2F9;
  --brand-100: #D4E8F6;  /* burbuja saliente */
  --brand-400: #4FB0E8;  /* acento sobre fondo oscuro: punto "online"; nunca texto sobre blanco (3,9:1 sobre 900) */
  --brand-600: #0368A4;  /* color corporativo; botón primario (6,0:1 con texto blanco, AA) */
  --brand-700: #02578A;  /* hover, enlaces */
  --brand-900: #024A75;  /* sidebar (9,4:1 con blanco) */
  --brand-950: #013555;  /* cabeceras de modal, estado activo oscuro, fondo del login */
  --shine:     rgba(79, 176, 232, .30);  /* estela del botón Instalar (brand-400 translúcido) */

  /* Neutros */
  --ink:       #111B21;
  --ink-2:     #3B4A54;
  --ink-3:     #667781;
  --ink-4:     #8696A0;
  --line:      #E9EDEF;
  --line-2:    #D1D7DB;
  --bg:        #F0F2F5;   /* fondo general */
  --bg-chat:   #EFEAE2;   /* fondo de la conversación */
  --surface:   #FFFFFF;
  --surface-2: #F7F8FA;

  /* Mensajes */
  --bubble-in:  #FFFFFF;
  --bubble-out: var(--brand-100);
  --tick-read:  #53BDEB;  /* doble check leído */

  /* Estados */
  --danger:  #C62828;  --danger-soft:  #FDECEA;
  --warning: #B26A00;  --warning-soft: #FFF4D6;
  --success: var(--brand-600); --success-soft: var(--brand-50);
  --info:    #1565C0;  --info-soft:    #E3F2FD;

  /* Gráficos (distinguibles, aptos para daltonismo) */
  --chart-1: #0368A4; --chart-2: #1565C0; --chart-3: #B26A00;
  --chart-4: #8E24AA; --chart-5: #C62828; --chart-6: #546E7A;

  /* Gestor de Tareas: impacto y estados (fuera de la paleta corporativa para leerse de un vistazo) */
  --impact-low: #5B6B7A;      --impact-low-soft: #EEF2F5;
  --impact-medium: #1D63C4;   --impact-medium-soft: #E7F0FC;
  --impact-high: #B45309;     --impact-high-soft: #FFF3E3;
  --impact-critical: #C62828; --impact-critical-soft: #FDECEA;
  --st-todo: #5B6B7A;         --st-todo-soft: #F1F4F7;
  --st-progress: #1D63C4;     --st-progress-soft: #EAF2FD;
  --st-waiting: #7B3FA8;      --st-waiting-soft: #F4ECFA;
  --st-closed: #2E7D32;       --st-closed-soft: #EAF5EB;

  /* Forma */
  --r-xs: 4px; --r-sm: 6px; --r-md: 8px; --r-lg: 12px; --r-xl: 16px; --r-pill: 999px;
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px; --s-7: 32px; --s-8: 48px;
  --shadow-1: 0 1px 2px rgba(17,27,33,.08);
  --shadow-2: 0 2px 6px rgba(17,27,33,.10);
  --shadow-modal: 0 24px 48px rgba(17,27,33,.24);

  /* Tipografía */
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --fs-xs: 11px; --fs-sm: 12px; --fs-base: 14px; --fs-md: 15px; --fs-lg: 16px; --fs-xl: 18px; --fs-2xl: 22px; --fs-3xl: 28px;

  /* Layout y movimiento */
  --sidebar-w: 260px; --topbar-h: 56px; --chatlist-w: 360px;
  --t-fast: 120ms; --t-base: 200ms; --ease: cubic-bezier(.2,.8,.2,1);
  --z-nav: 30; --z-overlay: 50; --z-modal: 60; --z-toast: 70;
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: var(--fs-2xl); font-weight: 700; }
h2 { font-size: var(--fs-md); font-weight: 600; }

p { margin: 0; }

img, svg { display: block; max-width: 100%; }

input, select, textarea, button { font: inherit; }
input, select, textarea { font-size: var(--fs-lg); }

:focus-visible {
  outline: 2px solid var(--brand-600);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; }
}

[hidden] { display: none !important; }

a { color: var(--brand-700); }

.muted { color: var(--ink-3); }

button { cursor: pointer; }
button:disabled { cursor: not-allowed; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------- Iconos ---------- */

.icon {
  width: 20px; height: 20px; flex-shrink: 0; display: inline-block; vertical-align: middle;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 24px; height: 24px; }

/* ---------- Botones ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 40px; padding: 0 var(--s-4);
  border: 1px solid transparent; border-radius: var(--r-md);
  font-size: var(--fs-base); font-weight: 600; line-height: 1;
  text-decoration: none; white-space: nowrap; user-select: none;
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.btn:disabled { opacity: .55; }
.btn-primary { background: var(--brand-600); color: var(--surface); }
.btn-primary:not(:disabled):hover { background: var(--brand-700); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-2); }
.btn-secondary:not(:disabled):hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:not(:disabled):hover { background: var(--surface-2); color: var(--ink); }
.btn-danger { background: var(--danger); color: var(--surface); }
.btn-danger:not(:disabled):hover { filter: brightness(.92); }
.btn-lg { min-height: 48px; padding: 0 var(--s-6); font-size: var(--fs-md); }
.btn-block { width: 100%; }
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ''; position: absolute; width: 18px; height: 18px; border-radius: var(--r-pill);
  border: 2px solid currentColor; border-color: var(--surface) var(--surface) transparent transparent;
  animation: spin .7s linear infinite;
}
.btn-secondary.is-loading::after, .btn-ghost.is-loading::after { border-color: var(--brand-600) var(--brand-600) transparent transparent; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; padding: 0;
  border: 0; border-radius: var(--r-pill); background: transparent; color: var(--ink-2);
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .icon-btn { width: 44px; height: 44px; }
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Formularios ---------- */

.field { display: flex; flex-direction: column; gap: var(--s-1); margin-bottom: var(--s-4); }
.field label { font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: var(--fs-sm); color: var(--ink-3); }
.field .error-text { font-size: var(--fs-sm); color: var(--danger); }

.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 0 var(--s-3);
  border: 1px solid var(--line-2); border-radius: var(--r-md);
  background: var(--surface); color: var(--ink);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.textarea { padding: var(--s-3); min-height: 96px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--ink-3); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand-600);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-600) 18%, transparent);
}
.input[aria-invalid="true"] { border-color: var(--danger); }

.input-group { position: relative; }
.input-group .input { padding-right: 48px; }
.input-group .icon-btn { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); }

.form-error {
  display: flex; gap: var(--s-2); align-items: flex-start;
  padding: var(--s-3); margin-bottom: var(--s-4);
  border-radius: var(--r-md); background: var(--danger-soft); color: var(--danger);
  font-size: var(--fs-sm); font-weight: 500;
}
.form-error[hidden] { display: none; }

.strength { display: flex; gap: var(--s-1); margin-top: var(--s-1); }
.strength span { flex: 1; height: 4px; border-radius: var(--r-pill); background: var(--line); transition: background-color var(--t-base) var(--ease); }
.strength[data-level="1"] span:nth-child(-n+1) { background: var(--danger); }
.strength[data-level="2"] span:nth-child(-n+2) { background: var(--warning); }
.strength[data-level="3"] span:nth-child(-n+3) { background: var(--brand-600); }
.strength[data-level="4"] span:nth-child(-n+4) { background: var(--brand-700); }

/* ---------- Píldoras, chips y avatares ---------- */

.pill {
  display: inline-flex; align-items: center; gap: var(--s-1);
  padding: 2px var(--s-2); border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 600; line-height: 18px; white-space: nowrap;
  background: var(--surface-2); color: var(--ink-2);
}
.pill-success { background: var(--success-soft); color: var(--brand-700); }
.pill-warning { background: var(--warning-soft); color: var(--warning); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }
.pill-info { background: var(--info-soft); color: var(--info); }
.pill-dot { width: 8px; height: 8px; border-radius: var(--r-pill); background: var(--brand-400); }

.tlf-chip {
  display: inline-flex; align-items: center; gap: var(--s-1);
  padding: 2px var(--s-2); border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 600; line-height: 18px; white-space: nowrap;
  border: 1px solid currentColor;
}
.tlf-chip.tlf-1 { color: var(--chart-1); background: color-mix(in srgb, var(--chart-1) 8%, var(--surface)); }
.tlf-chip.tlf-2 { color: var(--chart-2); background: color-mix(in srgb, var(--chart-2) 8%, var(--surface)); }
.tlf-chip.tlf-3 { color: var(--chart-4); background: color-mix(in srgb, var(--chart-4) 8%, var(--surface)); }
.tlf-chip .tlf-off { width: 6px; height: 6px; border-radius: var(--r-pill); background: var(--warning); }

.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 40px; height: 40px; border-radius: var(--r-pill); overflow: hidden;
  font-size: var(--fs-base); font-weight: 600; color: var(--surface); user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 32px; height: 32px; font-size: var(--fs-sm); }
.avatar-lg { width: 56px; height: 56px; font-size: var(--fs-xl); }
.av-c0 { background: var(--chart-1); } .av-c1 { background: var(--chart-2); }
.av-c2 { background: var(--chart-3); } .av-c3 { background: var(--chart-4); }
.av-c4 { background: var(--chart-5); } .av-c5 { background: var(--chart-6); }
.av-c6 { background: var(--brand-700); } .av-c7 { background: var(--brand-950); }

/* ---------- Tarjetas, estados vacíos y esqueletos ---------- */

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.card-body { padding: var(--s-5); }

.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  gap: var(--s-3); padding: var(--s-8) var(--s-5); color: var(--ink-3);
}
.empty-state .empty-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 64px; height: 64px; border-radius: var(--r-pill);
  background: var(--brand-50); color: var(--brand-600);
}
.empty-state .empty-icon .icon { width: 30px; height: 30px; }
.empty-state h2 { color: var(--ink); font-size: var(--fs-lg); }
.empty-state p { max-width: 420px; }

.skeleton {
  display: block; border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--line) 25%, var(--surface-2) 50%, var(--line) 75%);
  background-size: 200% 100%; animation: shimmer 1.2s ease-in-out infinite;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- Tablas responsivas ---------- */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; background: var(--surface); }
.table th, .table td { padding: var(--s-3) var(--s-4); text-align: left; border-bottom: 1px solid var(--line); }
.table th { font-size: var(--fs-sm); font-weight: 600; color: var(--ink-3); background: var(--surface-2); }
.table tbody tr:hover { background: var(--surface-2); }

@media (max-width: 720px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { margin-bottom: var(--s-3); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
  .table td { display: flex; justify-content: space-between; gap: var(--s-3); border-bottom: 1px solid var(--line); }
  .table td:last-child { border-bottom: 0; }
  .table td::before { content: attr(data-label); font-size: var(--fs-sm); font-weight: 600; color: var(--ink-3); }
}

/* ---------- Modales ---------- */

body.modal-open { overflow: hidden; }

.modal-backdrop {
  position: fixed; inset: 0; z-index: var(--z-modal);
  display: flex; align-items: center; justify-content: center;
  padding: var(--s-4); background: rgba(17,27,33,.5);
  animation: fade-in var(--t-base) var(--ease);
}
.modal {
  display: flex; flex-direction: column; width: 100%; max-width: 480px; max-height: calc(100dvh - 32px);
  background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-modal);
  animation: modal-in var(--t-base) var(--ease);
}
.modal-lg { max-width: 760px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-4) var(--s-4) var(--s-4) var(--s-5); border-bottom: 1px solid var(--line);
}
.modal-header h2 { font-size: var(--fs-lg); font-weight: 600; }
.modal-header.modal-header-brand {
  border-bottom: 0; border-radius: var(--r-xl) var(--r-xl) 0 0;
  background: linear-gradient(135deg, var(--brand-950), var(--brand-900)); color: var(--surface);
}
.modal-header.modal-header-brand .icon-btn { color: var(--surface); }
.modal-header.modal-header-brand .icon-btn:hover { background: rgba(255,255,255,.14); }
.modal-body { padding: var(--s-5); overflow-y: auto; }
.modal-body > p + p { margin-top: var(--s-3); }
.modal-footer {
  display: flex; justify-content: flex-end; gap: var(--s-2); flex-wrap: wrap;
  padding: var(--s-4) var(--s-5); border-top: 1px solid var(--line);
}

@media (max-width: 720px) {
  .modal-backdrop { padding: 0; }
  .modal, .modal-lg {
    max-width: none; height: 100dvh; max-height: none; border-radius: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .modal-header.modal-header-brand { border-radius: 0; padding-top: max(var(--s-4), env(safe-area-inset-top)); }
  .modal-body { flex: 1; }
  .modal-footer .btn { flex: 1; }
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- Toasts ---------- */

.toast-region {
  position: fixed; z-index: var(--z-toast); right: var(--s-4); bottom: max(var(--s-4), env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: var(--s-2); width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-3) var(--s-4); border-radius: var(--r-lg);
  background: var(--ink); color: var(--surface); box-shadow: var(--shadow-modal);
  font-size: var(--fs-base); pointer-events: auto;
  animation: modal-in var(--t-base) var(--ease);
}
.toast .icon { margin-top: 1px; }
.toast-success .icon { color: var(--brand-400); }
.toast-error { background: var(--danger); }
.toast-warning .icon { color: var(--warning-soft); }
.toast.is-leaving { opacity: 0; transform: translateY(8px); transition: opacity var(--t-base) var(--ease), transform var(--t-base) var(--ease); }

@media (max-width: 720px) {
  .toast-region { left: var(--s-4); right: var(--s-4); width: auto; }
}

/* ---------- Login ---------- */

.auth-screen {
  min-height: 100dvh; display: grid; place-items: center;
  padding: max(var(--s-4), env(safe-area-inset-top)) var(--s-4) max(var(--s-4), env(safe-area-inset-bottom));
  background: linear-gradient(160deg, var(--brand-950), var(--brand-900));
}
.auth-card {
  width: 100%; max-width: 400px; padding: var(--s-7) var(--s-6);
  background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-modal);
}
.auth-card .brand { display: flex; align-items: center; justify-content: center; gap: var(--s-3); margin-bottom: var(--s-5); }
.auth-card .brand-logo { width: auto; height: 72px; }
.auth-card .brand-wordmark { font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -0.02em; color: var(--ink); }
.auth-card h1 { text-align: center; font-size: var(--fs-xl); font-weight: 600; margin-bottom: var(--s-6); }
.btn-install {
  position: relative; overflow: hidden; isolation: isolate; margin-top: var(--s-3);
  color: var(--brand-700); border-color: var(--brand-600);
}
.btn-install:not(:disabled):hover { background: var(--brand-50); }
.btn-install .icon { width: 18px; height: 18px; }
/* Estela que cruza el fondo cada pocos segundos. */
.btn-install::after {
  content: ''; position: absolute; inset: 0 auto 0 0; width: 45%; z-index: -1; pointer-events: none;
  background: linear-gradient(100deg, transparent, var(--shine) 45%, var(--surface) 50%, var(--shine) 55%, transparent);
  transform: translateX(-120%) skewX(-18deg);
  animation: install-shine 8s ease-in-out 1s infinite;
}
@keyframes install-shine {
  0%   { transform: translateX(-120%) skewX(-18deg); }
  40%  { transform: translateX(330%) skewX(-18deg); }
  100% { transform: translateX(330%) skewX(-18deg); }
}
@media (prefers-reduced-motion: reduce) {
  .btn-install::after { animation: none; display: none; }
}
.install-help {
  margin-top: var(--s-3); padding: var(--s-3) var(--s-4);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md);
  font-size: var(--fs-sm); color: var(--ink-2);
}
.install-help-title { font-weight: 600; color: var(--ink); margin-bottom: var(--s-1); }
.install-help ol { margin: 0; padding-left: var(--s-5); }
.install-help li + li { margin-top: var(--s-1); }
.auth-help { margin-top: var(--s-5); text-align: center; font-size: var(--fs-sm); color: var(--ink-3); }
.auth-version { margin-top: var(--s-4); text-align: center; font-size: var(--fs-xs); color: var(--ink-3); }

@media (max-width: 480px) {
  .auth-card { padding: var(--s-6) var(--s-5); }
}

/* ---------- Shell de la aplicación ---------- */

/* Con la vista de Chats la página no se desplaza (los paneles tienen scroll propio). */
body:has(.view.view-chats) { overflow: hidden; }

.app-shell { display: flex; min-height: 100dvh; }

.sidebar {
  position: sticky; top: 0; height: 100dvh; width: var(--sidebar-w); flex-shrink: 0;
  display: flex; flex-direction: column;
  background: var(--brand-900); color: rgba(255,255,255,.9);
  padding-top: env(safe-area-inset-top);
}
.sidebar-brand { display: flex; align-items: center; gap: var(--s-3); height: var(--topbar-h); padding: 0 var(--s-5); }
.sidebar-logo { display: block; width: auto; height: 40px; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: var(--s-2) 0; }
.nav-section { padding: var(--s-4) var(--s-5) var(--s-1); font-size: var(--fs-xs); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: rgba(255,255,255,.55); }
.nav-item {
  display: flex; align-items: center; gap: var(--s-3);
  min-height: 44px; padding: 0 var(--s-5); border-left: 3px solid transparent;
  color: rgba(255,255,255,.9); text-decoration: none; font-weight: 500;
  transition: background-color var(--t-fast) var(--ease);
}
.nav-item:hover { background: rgba(255,255,255,.08); }
.nav-item.is-active { background: rgba(255,255,255,.14); border-left-color: var(--brand-400); color: var(--surface); font-weight: 600; }
.nav-item .nav-badge {
  margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: var(--r-pill);
  background: var(--surface); color: var(--brand-900); font-size: var(--fs-xs); font-weight: 700; line-height: 20px; text-align: center;
}
.nav-item .nav-badge[hidden] { display: none; }
.nav-item:focus-visible { outline-color: var(--brand-400); outline-offset: -3px; }

.sidebar-footer { border-top: 1px solid rgba(255,255,255,.12); padding: var(--s-2) 0 max(var(--s-3), env(safe-area-inset-bottom)); }
.user-card { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-5); }
.user-card .user-meta { min-width: 0; flex: 1; }
.user-card .user-name { font-weight: 600; color: var(--surface); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card .user-role { font-size: var(--fs-xs); color: rgba(255,255,255,.65); }
.user-card .icon-btn { color: rgba(255,255,255,.8); }
.user-card .icon-btn:hover { background: rgba(255,255,255,.12); color: var(--surface); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: var(--z-nav);
  display: flex; align-items: center; gap: var(--s-3);
  height: calc(var(--topbar-h) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) var(--s-4) 0;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar h1 { flex: 1; min-width: 0; font-size: var(--fs-xl); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .menu-btn { display: none; }
.conn-dot { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--fs-sm); color: var(--ink-3); }
.conn-dot::before { content: ''; width: 10px; height: 10px; border-radius: var(--r-pill); background: var(--ink-4); transition: background-color var(--t-base) var(--ease); }
.conn-dot.is-online::before { background: var(--brand-400); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-400) 25%, transparent); }

.view { flex: 1; min-width: 0; padding: var(--s-6); }
.view-header { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-5); flex-wrap: wrap; }

.drawer-backdrop { display: none; }

@media (max-width: 1024px) {
  .sidebar {
    position: fixed; z-index: var(--z-overlay); left: 0; top: 0; bottom: 0; height: auto;
    transform: translateX(-100%); transition: transform var(--t-base) var(--ease);
    box-shadow: var(--shadow-modal);
  }
  .app-shell.drawer-open .sidebar { transform: none; }
  .app-shell.drawer-open .drawer-backdrop {
    display: block; position: fixed; inset: 0; z-index: calc(var(--z-overlay) - 1); background: rgba(17,27,33,.45);
  }
  .topbar .menu-btn { display: inline-flex; }
}

@media (max-width: 720px) {
  .view { padding: var(--s-4); }
  .topbar .conn-label { display: none; }
  .topbar .logout-label { display: none; }
}

/* ---------- Vistas: piezas comunes ---------- */

.view-heading { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.view-title { font-size: var(--fs-lg); font-weight: 600; }

.skeleton-row { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) 0; }
.skeleton-avatar { width: 40px; height: 40px; border-radius: var(--r-pill); }
.skeleton-line { flex: 1; height: 14px; max-width: 360px; }

.chip-list { display: flex; flex-wrap: wrap; gap: var(--s-1); }
.cell-actions { white-space: nowrap; text-align: right; }
.icon-btn-danger:hover { background: var(--danger-soft); color: var(--danger); }

.user-cell { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.user-cell-meta { min-width: 0; }
.user-cell-name { font-weight: 600; }
.user-cell-email { font-size: var(--fs-sm); color: var(--ink-3); overflow-wrap: anywhere; }
.table td .pill + .pill { margin-left: var(--s-1); }

@media (max-width: 720px) {
  .table td.cell-user::before { display: none; }
  .table td.cell-actions { justify-content: flex-end; }
  .table td.cell-actions::before { display: none; }
}

/* ---------- Casillas, interruptores y filas de campo ---------- */

.check-group { border: 0; padding: 0; margin: 0 0 var(--s-4); min-width: 0; }
.check-group legend { padding: 0; margin-bottom: var(--s-2); font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); }
.check-row { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.check-pill {
  display: inline-flex; align-items: center; gap: var(--s-2);
  min-height: 44px; padding: 0 var(--s-4); border: 1px solid var(--line-2); border-radius: var(--r-pill);
  font-weight: 600; cursor: pointer; user-select: none;
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.check-pill input { width: 18px; height: 18px; margin: 0; accent-color: var(--brand-600); }
.check-pill:has(input:checked) { border-color: var(--brand-600); background: var(--brand-50); color: var(--brand-700); }
.check-pill:has(input:focus-visible) { outline: 2px solid var(--brand-600); outline-offset: 2px; }

.input-row { display: flex; gap: var(--s-2); }
.input-row .input-group { flex: 1; }

.switch { position: relative; display: inline-flex; align-items: center; gap: var(--s-3); min-height: 44px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track {
  position: relative; width: 44px; height: 24px; flex-shrink: 0; border-radius: var(--r-pill); background: var(--line-2);
  transition: background-color var(--t-fast) var(--ease);
}
.switch-track::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: var(--r-pill);
  background: var(--surface); box-shadow: var(--shadow-1); transition: transform var(--t-fast) var(--ease);
}
.switch input:checked + .switch-track { background: var(--brand-600); }
.switch input:checked + .switch-track::after { transform: translateX(20px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--brand-600); outline-offset: 2px; }
.switch input:disabled + .switch-track { opacity: .5; }
.switch-label { font-weight: 600; }

/* ---------- Conexiones ---------- */

.phones-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-4); align-items: start; }
@media (max-width: 1200px) { .phones-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .phones-grid { grid-template-columns: 1fr; } }

.phone-card { padding: var(--s-5); display: flex; flex-direction: column; gap: var(--s-4); min-height: 180px; }
.phone-card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); }
.phone-card-head .tlf-chip { font-size: var(--fs-sm); padding: var(--s-1) var(--s-3); }
.phone-card-body { display: flex; flex-direction: column; gap: var(--s-3); }
.phone-card-body .field { margin-bottom: 0; }
.phone-number { font-size: var(--fs-xl); font-weight: 600; letter-spacing: .01em; }
.phone-card-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.phone-later { border-top: 1px solid var(--line); padding-top: var(--s-3); }
.btn-ghost-danger { color: var(--danger); }
.btn-ghost-danger:not(:disabled):hover { background: var(--danger-soft); color: var(--danger); }

.qr-box {
  display: flex; align-items: center; justify-content: center; align-self: center;
  width: 100%; max-width: 280px; aspect-ratio: 1; padding: var(--s-3);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
}
.qr-img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.qr-placeholder { display: flex; flex-direction: column; align-items: center; gap: var(--s-3); width: 100%; height: 100%; justify-content: center; }
.qr-skeleton { width: 70%; aspect-ratio: 1; border-radius: var(--r-md); }
.qr-help { text-align: center; font-size: var(--fs-sm); color: var(--ink-2); }
.qr-countdown {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); align-self: center;
  padding: var(--s-1) var(--s-3); border-radius: var(--r-pill);
  background: var(--warning-soft); color: var(--warning); font-weight: 600; font-variant-numeric: tabular-nums;
}
.qr-countdown.is-expired { background: var(--danger-soft); color: var(--danger); }

.plain-list { margin: var(--s-2) 0; padding-left: var(--s-5); }
.plain-list li + li { margin-top: var(--s-1); }

.disconnected-list { list-style: none; margin: var(--s-4) 0; padding: 0; display: flex; flex-direction: column; gap: var(--s-2); }
.disconnected-item { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); padding: var(--s-3); border: 1px solid var(--line); border-radius: var(--r-md); }

/* ---------- Contactos ---------- */

.header-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3) var(--s-5); margin-bottom: var(--s-3); }
.search-field { position: relative; flex: 1 1 320px; max-width: 560px; }
.search-field > .icon { position: absolute; left: var(--s-3); top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.search-field .input { padding-left: 40px; }

.tag-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); margin-bottom: var(--s-4); }
.tag-bar-label { font-size: var(--fs-sm); font-weight: 600; color: var(--ink-3); margin-right: var(--s-1); }
.filter-chip {
  display: inline-flex; align-items: center; gap: var(--s-2); min-height: 32px; padding: 0 var(--s-3);
  border: 1px solid var(--line-2); border-radius: var(--r-pill); background: var(--surface); color: var(--ink-2);
  font-size: var(--fs-sm); font-weight: 600; transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.filter-chip:hover { background: var(--surface-2); }
.filter-chip.is-active { border-color: var(--brand-600); background: var(--brand-50); color: var(--brand-700); }
.filter-chip-count { color: var(--ink-3); font-weight: 500; font-variant-numeric: tabular-nums; }
@media (pointer: coarse) { .filter-chip { min-height: 40px; } }

.selection-bar {
  position: sticky; top: calc(var(--topbar-h) + env(safe-area-inset-top)); z-index: 5;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-3) var(--s-4); margin-bottom: var(--s-3);
  background: var(--brand-50); border: 1px solid var(--brand-600); border-radius: var(--r-lg);
}
.selection-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }

.tag-chip {
  display: inline-flex; align-items: center; gap: 2px; max-width: 100%;
  padding: 2px var(--s-2); border-radius: var(--r-sm); background: var(--info-soft); color: var(--info);
  font-size: var(--fs-xs); font-weight: 600; line-height: 18px;
}
.tag-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-chip-x { display: inline-flex; padding: 0; border: 0; background: transparent; color: inherit; border-radius: var(--r-xs); }
.tag-chip-x:hover { background: rgba(21,101,192,.15); }

.tags-input {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); min-height: 44px; padding: var(--s-2) var(--s-3);
  border: 1px solid var(--line-2); border-radius: var(--r-md); background: var(--surface); cursor: text;
}
.tags-input:focus-within { border-color: var(--brand-600); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-600) 18%, transparent); }
.tags-input-field { flex: 1 1 140px; min-width: 120px; border: 0; outline: 0; padding: var(--s-1) 0; background: transparent; color: var(--ink); }
.tags-input-field[aria-invalid=true] { color: var(--danger); }

.table-clickable tbody tr { cursor: pointer; }
.table-clickable tbody tr:focus-visible { outline: 2px solid var(--brand-600); outline-offset: -2px; }
.cell-check { width: 44px; }
.cell-check input { width: 18px; height: 18px; accent-color: var(--brand-600); cursor: pointer; }
.nowrap { white-space: nowrap; }
.user-cell-name .pill { margin-left: var(--s-2); vertical-align: middle; }

@media (max-width: 720px) {
  .table td.cell-check { justify-content: flex-start; }
  .table td.cell-check::before { content: none; }
}

.load-more { display: flex; justify-content: center; padding: var(--s-4) 0; }

.contact-head { display: flex; align-items: center; gap: var(--s-4); flex-wrap: wrap; margin-bottom: var(--s-5); }
.contact-head-meta { flex: 1; min-width: 0; }
.contact-head-name { font-size: var(--fs-xl); font-weight: 600; overflow-wrap: anywhere; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--s-4); }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }
.agent-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); margin-bottom: var(--s-2); }
.agent-row .select { width: auto; flex: 1 1 200px; }
.modal-footer-split > .btn-ghost:first-child, .modal-footer-split > .btn-danger { margin-right: auto; }
.modal-footer-split > .btn-ghost:first-child + .btn-danger { margin-right: auto; }

.import-steps { display: flex; flex-direction: column; gap: var(--s-5); }
.import-step h3 { font-size: var(--fs-md); font-weight: 600; margin-bottom: var(--s-2); }
.import-step p { margin-bottom: var(--s-3); }
.import-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-3); }
.stat { display: flex; flex-direction: column; align-items: center; padding: var(--s-4); border-radius: var(--r-lg); background: var(--surface-2); }
.stat-value { font-size: var(--fs-3xl); font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { font-size: var(--fs-sm); color: var(--ink-3); }
.import-errors { max-height: 260px; overflow-y: auto; font-size: var(--fs-sm); }

/* ---------- Media ---------- */

.usage-card { padding: var(--s-5); margin-bottom: var(--s-5); display: flex; flex-direction: column; gap: var(--s-2); }
.usage-main { font-size: var(--fs-lg); font-weight: 600; }
.usage-bar { height: 10px; border-radius: var(--r-pill); background: var(--line); overflow: hidden; }
.usage-fill { display: block; height: 100%; border-radius: var(--r-pill); transition: width var(--t-base) var(--ease); }
.usage-fill.is-ok { background: var(--brand-600); }
.usage-fill.is-warning { background: var(--warning); }
.usage-fill.is-danger { background: var(--danger); }

.media-filters { margin-bottom: var(--s-4); }
.select-auto { width: auto; min-width: 180px; }
.date-filter { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); }
.date-filter .input { width: auto; }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--s-4); }
.media-span { grid-column: 1 / -1; }
.media-card { display: flex; flex-direction: column; overflow: hidden; }
.media-thumb {
  position: relative; display: flex; align-items: center; justify-content: center; aspect-ratio: 4 / 3;
  padding: 0; border: 0; background: var(--surface-2); cursor: pointer; overflow: hidden;
}
.media-thumb img { width: 100%; height: 100%; object-fit: cover; }
.media-thumb-icon { display: flex; flex-direction: column; align-items: center; gap: var(--s-2); color: var(--brand-600); }
.media-ext { font-size: var(--fs-xs); font-weight: 700; color: var(--ink-3); letter-spacing: .04em; }
.media-skeleton { display: block; aspect-ratio: 4 / 3; border-radius: 0; }
.media-info { padding: var(--s-3) var(--s-3) 0; display: flex; flex-direction: column; gap: var(--s-1); min-width: 0; }
.media-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); font-size: var(--fs-sm); color: var(--ink-2); }
.media-actions { display: flex; justify-content: flex-end; gap: var(--s-1); padding: var(--s-1) var(--s-2) var(--s-2); margin-top: auto; }
.media-preview { display: flex; justify-content: center; }
.media-preview img, .media-preview video { max-width: 100%; max-height: 70dvh; border-radius: var(--r-md); }
.media-preview audio { width: 100%; }

@media (max-width: 480px) { .media-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2); } }

.field-label { font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); }
.conv-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s-2); }
.conv-item { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); padding: var(--s-2) var(--s-3); border: 1px solid var(--line); border-radius: var(--r-md); }
.conv-item .btn { margin-left: auto; }

/* ---------- Chats ---------- */

/* La vista ocupa exactamente el alto libre bajo la topbar: la página no hace scroll; cada panel tiene el suyo. */
.view.view-chats { flex: 0 0 auto; padding: 0; display: flex; min-height: 0; height: calc(100dvh - var(--topbar-h) - env(safe-area-inset-top)); overflow: hidden; }
.chats-layout { flex: 1; min-width: 0; min-height: 0; height: 100%; display: grid; grid-template-columns: var(--chatlist-w) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); overflow: hidden; background: var(--surface); }

.chat-list-pane { display: flex; flex-direction: column; min-height: 0; overflow: hidden; border-right: 1px solid var(--line); background: var(--surface); }
.chat-list-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); padding: var(--s-3) var(--s-3) var(--s-2); }
.chat-list-actions { display: flex; gap: var(--s-1); }
.chat-list-actions .icon-btn.is-active { background: var(--brand-50); color: var(--brand-700); }
.seg-tabs { display: inline-flex; padding: 3px; border-radius: var(--r-pill); background: var(--surface-2); border: 1px solid var(--line); }
.seg-tab {
  min-height: 34px; padding: 0 var(--s-3); border: 0; border-radius: var(--r-pill); background: transparent;
  color: var(--ink-2); font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; transition: background-color var(--t-fast) var(--ease);
}
.seg-tab.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.chat-search { margin: 0 var(--s-3) var(--s-2); max-width: none; flex: none; }
.chat-filter { margin: 0 var(--s-3) var(--s-2); width: auto; }
.chat-selection-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); margin: 0 var(--s-3) var(--s-2); padding: var(--s-2) var(--s-3);
  border: 1px solid var(--brand-600); border-radius: var(--r-md); background: var(--brand-50); font-size: var(--fs-sm);
}
.chat-selection-bar strong { margin-right: auto; }
.chat-list-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.chat-list { list-style: none; margin: 0; padding: 0; }
.chat-row {
  display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3); border-bottom: 1px solid var(--line);
  cursor: pointer; transition: background-color var(--t-fast) var(--ease);
}
.chat-row:hover { background: var(--surface-2); }
.chat-row.is-active { background: var(--brand-50); }
.chat-row:focus-visible { outline: 2px solid var(--brand-600); outline-offset: -2px; }
.chat-row-check { width: 18px; height: 18px; accent-color: var(--brand-600); flex-shrink: 0; pointer-events: none; }
.chat-row-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.chat-row-top, .chat-row-bottom { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); min-width: 0; }
.chat-row-name { font-size: var(--fs-md); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-row.has-unread .chat-row-name { font-weight: 700; }
.chat-row-time { font-size: var(--fs-xs); color: var(--ink-3); flex-shrink: 0; }
.chat-row.has-unread .chat-row-time { color: var(--brand-700); font-weight: 600; }
.chat-row-tags { display: flex; flex-wrap: wrap; gap: var(--s-1); }
.chat-row-preview { display: inline-flex; align-items: center; gap: 2px; min-width: 0; color: var(--ink-3); font-size: var(--fs-sm); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.chat-row-preview .icon { flex-shrink: 0; }
.preview-you { color: var(--ink-2); font-weight: 600; margin-right: 2px; }
.unread-badge {
  flex-shrink: 0; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-pill);
  background: var(--brand-600); color: var(--surface); font-size: var(--fs-xs); font-weight: 700; line-height: 20px; text-align: center;
}
.chat-list-empty { padding: var(--s-7) var(--s-4); }
.msg-results { border-top: 1px solid var(--line); }
.msg-results-title { padding: var(--s-3) var(--s-3) var(--s-1); font-size: var(--fs-xs); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--brand-700); }
.msg-results-empty { padding: 0 var(--s-3) var(--s-3); }
.msg-result { display: block; width: 100%; padding: var(--s-2) var(--s-3); border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; cursor: pointer; }
.msg-result:hover { background: var(--surface-2); }
.msg-result-snippet { font-size: var(--fs-sm); color: var(--ink-2); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
mark { background: var(--warning-soft); color: var(--ink); border-radius: 2px; padding: 0 1px; }

/* Panel de conversación */
.chat-pane { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; background: var(--bg-chat); }
.conv-head, .conv-search, .conv-notice, .composer, .chat-list-head, .chat-search, .chat-filter, .chat-selection-bar { flex-shrink: 0; }
.chat-pane-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s-4); padding: var(--s-6); color: var(--ink-3); text-align: center; }
.chat-pane-empty .skeleton-line { width: 240px; }
.logo-mark-soft { width: 96px; height: 96px; --logo-bubble: var(--line-2); --logo-check: var(--bg-chat); opacity: .8; }

.conv-head { display: flex; align-items: center; gap: var(--s-2); min-height: 60px; padding: var(--s-2) var(--s-3); background: var(--surface); border-bottom: 1px solid var(--line); }
.conv-back { display: none; }
.conv-who { display: flex; align-items: center; gap: var(--s-3); min-width: 0; padding: var(--s-1) var(--s-2); border: 0; border-radius: var(--r-md); background: transparent; text-align: left; cursor: pointer; }
.conv-who:hover { background: var(--surface-2); }
.conv-who-text { display: flex; flex-direction: column; min-width: 0; }
.conv-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-phone { font-size: var(--fs-sm); color: var(--ink-3); }
.conv-tlf { flex-shrink: 0; }
.conv-actions { margin-left: auto; display: flex; align-items: center; gap: var(--s-1); }
.conv-more { display: none; }

.conv-search { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-2) var(--s-3); background: var(--surface); border-bottom: 1px solid var(--line); }
.conv-search .input { min-height: 38px; }
.conv-search-count { flex-shrink: 0; font-size: var(--fs-sm); color: var(--ink-3); font-variant-numeric: tabular-nums; min-width: 72px; text-align: right; }
.rot-up .icon { transform: rotate(90deg); }
.rot-down .icon { transform: rotate(-90deg); }

.conv-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: var(--s-3) var(--s-5) var(--s-4); }
.conv-older { display: flex; justify-content: center; margin-bottom: var(--s-2); }
.conv-older .btn { background: var(--surface); }
.conv-empty { text-align: center; color: var(--ink-3); padding: var(--s-6); }
.day-sep { position: sticky; top: 0; z-index: 2; display: flex; justify-content: center; margin: var(--s-3) 0; pointer-events: none; }
.day-sep span { padding: var(--s-1) var(--s-3); border-radius: var(--r-md); background: var(--surface); box-shadow: var(--shadow-1); font-size: var(--fs-xs); font-weight: 600; color: var(--ink-2); }
.unread-sep { display: flex; justify-content: center; margin: var(--s-3) 0; }
.unread-sep span { padding: var(--s-1) var(--s-3); border-radius: var(--r-pill); background: var(--brand-100); color: var(--brand-950); font-size: var(--fs-xs); font-weight: 700; }

.msg-row { display: flex; margin: 2px 0; }
.msg-row.is-out { justify-content: flex-end; }
.bubble {
  position: relative; max-width: min(72%, 560px); padding: 6px var(--s-2) 4px; border-radius: var(--r-lg);
  background: var(--bubble-in); box-shadow: var(--shadow-1); color: var(--ink); overflow-wrap: anywhere;
  transition: box-shadow var(--t-base) var(--ease);
}
.msg-row.is-in .bubble { border-top-left-radius: var(--r-xs); }
.msg-row.is-out .bubble { background: var(--bubble-out); border-top-right-radius: var(--r-xs); }
.msg-row.is-focused .bubble { box-shadow: 0 0 0 3px var(--warning); }
.bubble.is-deleted .msg-content { opacity: .55; text-decoration: line-through; }
.bubble.is-sticker { background: transparent; box-shadow: none; }
.msg-text { white-space: pre-wrap; font-size: var(--fs-md); line-height: 1.45; }
.msg-text a { color: var(--info); text-decoration: underline; }
.msg-meta { display: flex; align-items: center; justify-content: flex-end; gap: var(--s-1); margin-top: 2px; font-size: var(--fs-xs); color: var(--ink-3); }
.msg-status { display: inline-flex; color: var(--ink-4); }
.msg-status.status-read { color: var(--tick-read); }
.msg-status.status-failed { color: var(--danger); }
.msg-error { margin-top: 2px; font-size: var(--fs-xs); color: var(--danger); font-weight: 600; }
.msg-forwarded { display: flex; align-items: center; gap: var(--s-1); font-size: var(--fs-xs); font-style: italic; color: var(--ink-3); margin-bottom: 2px; }
.msg-quote {
  display: flex; flex-direction: column; width: 100%; margin-bottom: var(--s-1); padding: var(--s-1) var(--s-2);
  border: 0; border-left: 3px solid var(--brand-600); border-radius: var(--r-sm); background: rgba(17,27,33,.05); text-align: left; cursor: pointer;
}
.msg-quote-author { font-size: var(--fs-xs); font-weight: 700; color: var(--brand-700); }
.msg-quote-text { font-size: var(--fs-sm); color: var(--ink-2); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.msg-media { margin-bottom: var(--s-1); }
.msg-image { display: block; border-radius: var(--r-md); overflow: hidden; }
.msg-image img { display: block; max-width: 100%; max-height: 360px; object-fit: cover; }
.msg-image.is-sticker img { max-width: 160px; max-height: 160px; object-fit: contain; }
.msg-media video { display: block; max-width: 100%; max-height: 360px; border-radius: var(--r-md); }
.msg-media audio { width: 280px; max-width: 100%; }
.msg-media-missing { display: inline-block; padding: var(--s-2) var(--s-3); border-radius: var(--r-md); background: rgba(17,27,33,.05); font-size: var(--fs-sm); font-style: italic; color: var(--ink-3); }
.msg-doc { display: flex; align-items: center; gap: var(--s-2); min-width: 220px; padding: var(--s-2); border-radius: var(--r-md); background: rgba(17,27,33,.05); color: var(--brand-700); }
.msg-doc-info { flex: 1; min-width: 0; display: flex; flex-direction: column; color: var(--ink); }
.msg-doc-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-location, .msg-contact-card { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-2); border-radius: var(--r-md); background: rgba(17,27,33,.05); color: var(--brand-700); font-weight: 600; }
.msg-poll { display: flex; flex-direction: column; gap: var(--s-1); min-width: 240px; padding: var(--s-1) 0; }
.msg-poll-head { display: flex; align-items: center; gap: var(--s-1); font-size: var(--fs-xs); font-weight: 600; color: var(--brand-700); text-transform: uppercase; letter-spacing: .04em; }
.msg-poll-name { font-size: var(--fs-md); line-height: 1.35; }
.msg-poll-mode { font-size: var(--fs-xs); color: var(--ink-3); }
.msg-poll-options { list-style: none; margin: var(--s-1) 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--s-1); }
.msg-poll-option { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-2) var(--s-3); border-radius: var(--r-md); background: rgba(17,27,33,.05); font-size: var(--fs-base); }
.msg-poll-mark { flex-shrink: 0; width: 18px; height: 18px; border: 2px solid var(--ink-4); border-radius: var(--r-pill); }
.msg-poll-mark.is-multi { border-radius: var(--r-xs); }
.msg-poll-note { margin-top: var(--s-1); font-size: var(--fs-xs); font-style: italic; color: var(--ink-3); }
.msg-transcription { margin-top: var(--s-1); font-size: var(--fs-sm); font-style: italic; }
.msg-reactions { position: absolute; bottom: -14px; right: var(--s-2); display: flex; gap: 2px; }
.msg-row:has(.msg-reactions) { margin-bottom: 18px; }
.reaction-chip { padding: 0 6px; border-radius: var(--r-pill); background: var(--surface); box-shadow: var(--shadow-1); font-size: var(--fs-sm); line-height: 22px; }
.reaction-chip.is-mine { box-shadow: 0 0 0 1px var(--brand-600); }

.conv-new-below { position: absolute; right: var(--s-5); bottom: 90px; z-index: 3; box-shadow: var(--shadow-2); }
.conv-notice { display: flex; align-items: center; justify-content: center; gap: var(--s-2); flex-wrap: wrap; padding: var(--s-2) var(--s-3); background: var(--warning-soft); color: var(--warning); font-size: var(--fs-sm); font-weight: 600; }
.composer { display: flex; align-items: flex-end; gap: var(--s-2); padding: var(--s-2) var(--s-3) max(var(--s-2), env(safe-area-inset-bottom)); background: var(--surface-2); border-top: 1px solid var(--line); }
.composer.is-disabled { opacity: .6; }
.composer-input {
  flex: 1; min-height: 42px; max-height: 152px; padding: 10px var(--s-3); border: 1px solid var(--line-2); border-radius: var(--r-xl);
  background: var(--surface); color: var(--ink); font-size: var(--fs-lg); line-height: 22px; resize: none; overflow-y: auto;
}
.composer-input:focus { outline: none; border-color: var(--brand-600); }
.composer-send { background: var(--brand-600); color: var(--surface); }
.composer-send:hover { background: var(--brand-700); color: var(--surface); }
.composer-send:disabled { background: var(--line-2); }

.popover-menu {
  position: fixed; z-index: var(--z-overlay); min-width: 200px; padding: var(--s-1) 0; border-radius: var(--r-lg);
  background: var(--surface); box-shadow: var(--shadow-modal); border: 1px solid var(--line);
}
.popover-item { display: flex; align-items: center; gap: var(--s-3); width: 100%; min-height: 44px; padding: 0 var(--s-4); border: 0; background: transparent; text-align: left; color: var(--ink); }
.popover-item:hover, .popover-item:focus-visible { background: var(--surface-2); outline: none; }
.popover-item:disabled { color: var(--ink-4); cursor: not-allowed; background: transparent; }
.popover-item.is-danger { color: var(--danger); }
.popover-item.is-danger:hover, .popover-item.is-danger:focus-visible { background: var(--danger-soft); }
.popover-empty { margin: 0; padding: var(--s-3) var(--s-4); font-size: var(--fs-sm); color: var(--ink-3); }
.popover-menu { animation: popover-in var(--t-base) var(--ease); }
@keyframes popover-in { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
.reaction-row { display: flex; gap: 2px; padding: var(--s-1) var(--s-2) var(--s-2); border-bottom: 1px solid var(--line); margin-bottom: var(--s-1); }
.reaction-btn { width: 36px; height: 36px; border: 0; border-radius: var(--r-pill); background: transparent; font-size: 20px; line-height: 1; transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease); }
.reaction-btn:hover, .reaction-btn:focus-visible { background: var(--surface-2); transform: scale(1.15); outline: none; }
.reaction-btn:active { transform: scale(.95); }
.reaction-btn.is-mine { background: var(--brand-50); box-shadow: inset 0 0 0 1px var(--brand-600); }

/* F8 · Menú del mensaje, respuesta, adjuntos y nota de voz */
.msg-menu-btn {
  position: absolute; top: 2px; right: 2px; display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border: 0; border-radius: var(--r-pill); background: inherit; color: var(--ink-3);
  opacity: 0; transition: opacity var(--t-fast) var(--ease);
}
.bubble:hover .msg-menu-btn, .msg-menu-btn:focus-visible, .msg-menu-btn[aria-expanded="true"] { opacity: 1; }
.msg-menu-btn:hover { color: var(--ink); }
@media (hover: none) { .msg-menu-btn { display: none; } }
.bubble { -webkit-touch-callout: none; }

.reply-bar { display: flex; align-items: center; gap: var(--s-2); flex-shrink: 0; padding: var(--s-2) var(--s-3); background: var(--surface-2); border-top: 1px solid var(--line); }
.reply-bar-body { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: var(--s-1) var(--s-2); border-left: 3px solid var(--brand-600); border-radius: var(--r-sm); background: var(--surface); }
.reply-bar-body .msg-quote-text { -webkit-line-clamp: 1; }

.attach-strip { display: flex; gap: var(--s-2); flex-shrink: 0; padding: var(--s-2) var(--s-3); background: var(--surface-2); border-top: 1px solid var(--line); overflow-x: auto; }
.attach-item { position: relative; flex-shrink: 0; display: flex; align-items: center; justify-content: center; width: 64px; height: 64px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line-2); color: var(--ink-3); overflow: hidden; }
.attach-item img { width: 100%; height: 100%; object-fit: cover; }
.attach-remove { position: absolute; top: 2px; right: 2px; display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border: 0; border-radius: var(--r-pill); background: var(--ink); color: var(--surface); }

.composer.is-recording .composer-input, .composer.is-recording > .icon-btn, .composer.is-recording > .composer-ai { display: none; }
.rec-bar { flex: 1; display: flex; align-items: center; gap: var(--s-3); min-height: 42px; }
.rec-dot { width: 10px; height: 10px; border-radius: var(--r-pill); background: var(--danger); animation: rec-pulse 1.2s ease-in-out infinite; }
@keyframes rec-pulse { 50% { opacity: .35; } }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); }
.rec-hint { flex: 1; font-size: var(--fs-sm); }

/* Visor de imágenes */
.lightbox { position: fixed; inset: 0; z-index: var(--z-modal); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s-3); padding: var(--s-8) var(--s-4) var(--s-4); background: rgba(17,27,33,.92); animation: fade-in var(--t-base) var(--ease); }
.lightbox-bar { position: absolute; top: var(--s-2); right: var(--s-2); display: flex; gap: var(--s-1); }
.lightbox-bar .icon-btn { color: var(--surface); }
.lightbox-bar .icon-btn:hover { background: rgba(255,255,255,.12); color: var(--surface); }
.lightbox-img { max-width: 100%; max-height: calc(100% - 64px); object-fit: contain; border-radius: var(--r-md); }
.lightbox-caption { margin: 0; max-width: 720px; color: var(--surface); text-align: center; white-space: pre-wrap; }

/* Modal de envío de archivo */
.media-send { display: flex; flex-direction: column; gap: var(--s-3); }
.media-send-preview { display: block; max-width: 100%; max-height: 50vh; margin: 0 auto; border-radius: var(--r-md); object-fit: contain; background: var(--surface-2); }
.forward-list { margin-top: 0; }
.nc-suggestion.is-picked { background: var(--brand-50); box-shadow: inset 0 0 0 1px var(--brand-600); }

/* Formato de WhatsApp dentro de la burbuja (§9) */
.wa-text strong { font-weight: 700; }
.wa-text code, .wa-text .wa-code { font-family: var(--font-mono); font-size: .9em; background: rgba(17,27,33,.06); border-radius: var(--r-xs); }
.wa-text code { padding: 0 3px; }
.wa-text .wa-code { margin: var(--s-1) 0; padding: var(--s-2); white-space: pre-wrap; overflow-x: auto; }
.wa-text blockquote { margin: var(--s-1) 0; padding: 0 0 0 var(--s-2); border-left: 3px solid var(--line-2); color: var(--ink-2); }
.wa-text ul, .wa-text ol { margin: var(--s-1) 0; padding-left: var(--s-5); }

/* Nuevo chat */
.nc-suggestions { list-style: none; margin: calc(-1 * var(--s-3)) 0 var(--s-3); padding: 0; max-height: 240px; overflow-y: auto; border-radius: var(--r-md); }
.nc-suggestion { display: flex; align-items: center; gap: var(--s-2); width: 100%; min-height: 44px; padding: var(--s-1) var(--s-2); border: 0; background: transparent; text-align: left; border-radius: var(--r-md); }
.nc-suggestion:hover { background: var(--surface-2); }
.nc-suggestion .muted { margin-left: auto; font-size: var(--fs-sm); }
.nc-notice { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); justify-content: space-between; padding: var(--s-3); margin-bottom: var(--s-3); border-radius: var(--r-md); font-size: var(--fs-sm); font-weight: 500; }
.nc-notice.is-warning { background: var(--warning-soft); color: var(--warning); }
.nc-notice.is-info { background: var(--info-soft); color: var(--info); }

/* Selector de emojis */
.emoji-panel {
  position: fixed; z-index: var(--z-overlay); display: flex; flex-direction: column; height: 320px;
  border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-modal); border: 1px solid var(--line); overflow: hidden;
}
.emoji-tabs { display: flex; gap: 2px; padding: var(--s-1); border-bottom: 1px solid var(--line); overflow-x: auto; }
.emoji-tab { flex-shrink: 0; width: 34px; height: 34px; border: 0; border-radius: var(--r-sm); background: transparent; font-size: 18px; }
.emoji-tab:hover { background: var(--surface-2); }
.emoji-grid { flex: 1; overflow-y: auto; padding: 0 var(--s-2) var(--s-2); position: relative; }
.emoji-group-title { padding: var(--s-2) var(--s-1) var(--s-1); font-size: var(--fs-xs); font-weight: 700; color: var(--ink-3); }
.emoji-group { display: grid; grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); }
.emoji-btn { height: 36px; border: 0; border-radius: var(--r-sm); background: transparent; font-size: 22px; line-height: 1; }
.emoji-btn:hover, .emoji-btn:focus-visible { background: var(--surface-2); outline: none; }

@media (max-width: 1024px) {
  .chats-layout { grid-template-columns: 300px minmax(0, 1fr); }
  .conv-contact-btn span, .conv-close-btn span { display: none; }
}
@media (max-width: 720px) {
  .chats-layout { grid-template-columns: 1fr; }
  .chats-layout .chat-pane { display: none; }
  .chats-layout.has-chat .chat-list-pane { display: none; }
  .chats-layout.has-chat .chat-pane { display: flex; }
  .conv-back { display: inline-flex; }
  .conv-tlf, .conv-contact-btn, .conv-close-btn { display: none; }
  .conv-more { display: inline-flex; }
  .conv-scroll { padding: var(--s-2) var(--s-3) var(--s-3); }
  .bubble { max-width: 86%; }
  .conv-new-below { right: var(--s-3); }
}

/* ---------- F9 · Agentes IA ---------- */
.agents-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--s-4); }
.agents-grid > .empty-state { grid-column: 1 / -1; }
.agent-card {
  display: flex; flex-direction: column; gap: var(--s-3); padding: var(--s-4) var(--s-5); min-height: 180px;
  border: 1px solid var(--line); text-align: left; color: var(--ink); cursor: pointer;
  transition: box-shadow var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.agent-card:hover { border-color: var(--brand-600); box-shadow: var(--shadow-2); }
.agent-card:active { transform: scale(.99); }
.agent-card.is-inactive { opacity: .72; }
.agent-card.skeleton { cursor: default; border: 0; }
.agent-card-top { display: flex; align-items: flex-start; gap: var(--s-3); }
.agent-icon { flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: var(--r-md); background: var(--brand-50); color: var(--brand-700); }
.agent-card-titles { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.agent-card-name { font-size: var(--fs-lg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-card-titles .muted { font-size: var(--fs-sm); }
.agent-card-desc { margin: 0; font-size: var(--fs-sm); color: var(--ink-2); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.agent-card-model { font-size: var(--fs-sm); color: var(--ink-3); }
.agent-card-usage { margin-top: auto; display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-2); padding-top: var(--s-3); border-top: 1px solid var(--line); font-size: var(--fs-sm); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.agent-card-usage strong { color: var(--ink); }
.agents-note { margin-top: var(--s-4); }

.agent-tabs { margin-bottom: var(--s-4); }
.agent-tabs .seg-tab { display: inline-flex; align-items: center; gap: var(--s-1); }
.agent-tabs .seg-tab:disabled { opacity: .5; cursor: not-allowed; }
.tab-soon { font-size: 10px; padding: 0 6px; }
.agent-advanced { margin: 0 0 var(--s-4); }
.agent-advanced summary { cursor: pointer; font-weight: 600; color: var(--ink-2); min-height: 32px; }
.agent-advanced[open] summary { margin-bottom: var(--s-3); }
.prompt-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-2); }
.prompt-count { font-variant-numeric: tabular-nums; }
.prompt-area { min-height: 240px; font-family: var(--font-mono); font-size: var(--fs-sm); line-height: 1.5; }
.prompt-head + .prompt-area + .btn, .field > .btn { align-self: flex-start; margin-top: var(--s-2); }
.prompt-notes { margin-top: var(--s-3); padding: var(--s-3) var(--s-4); border-radius: var(--r-md); background: var(--info-soft); color: var(--ink); font-size: var(--fs-sm); white-space: pre-wrap; }
.prompt-notes p { margin: var(--s-1) 0 0; }
.schedule-body { margin-top: var(--s-2); }
.day-pill { min-width: 44px; justify-content: center; padding: 0 var(--s-3); }
.agent-footer-left { display: flex; gap: var(--s-2); margin-right: auto; }

.docs-intro { margin: 0 0 var(--s-3); }
.doc-list { display: flex; flex-direction: column; gap: var(--s-2); margin-top: var(--s-4); }
.doc-row { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.doc-row[open] { border-color: var(--line-2); box-shadow: var(--shadow-1); }
.doc-summary { display: flex; align-items: center; gap: var(--s-3); min-height: 56px; padding: var(--s-2) var(--s-3); cursor: pointer; list-style: none; }
.doc-summary::-webkit-details-marker { display: none; }
.doc-icon { flex-shrink: 0; color: var(--brand-700); }
.doc-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.doc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-info .muted { font-size: var(--fs-sm); }
.doc-body { padding: 0 var(--s-4) var(--s-4); border-top: 1px solid var(--line); padding-top: var(--s-3); }
.doc-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); justify-content: flex-end; margin-top: var(--s-3); }
.doc-actions .btn-ghost-danger { margin-right: auto; }
.doc-empty { margin: 0; padding: var(--s-4); text-align: center; }

/* Claves API (Gestión IA) */
.ai-intro { margin: 0 0 var(--s-4); max-width: 760px; }
.key-list { margin: 0; }
.key-row { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--line); }
.key-row:last-child { border-bottom: 0; }
.key-row.is-inactive .key-main { opacity: .65; }
.key-main { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: var(--s-1); }
.key-title { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.key-main .muted { font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.key-actions { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }

/* Agente en chats */
.pill-agent { background: var(--brand-50); color: var(--brand-700); max-width: 160px; }
.pill-agent span { overflow: hidden; text-overflow: ellipsis; }
.pill-agent.is-inactive { background: var(--surface-2); color: var(--ink-3); }
.conv-agent {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: var(--s-1); max-width: 200px; min-height: 32px;
  padding: 0 var(--s-3); border: 1px solid var(--brand-600); border-radius: var(--r-pill);
  background: var(--brand-50); color: var(--brand-700); font-size: var(--fs-sm); font-weight: 600; cursor: pointer;
}
.conv-agent:hover { background: var(--brand-100); }
.conv-agent.is-manual { border-color: var(--line-2); background: var(--surface); color: var(--ink-2); }
.conv-agent-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-agent { display: flex; align-items: center; gap: var(--s-1); margin-bottom: 2px; font-size: var(--fs-xs); font-weight: 600; color: var(--brand-700); }
.popover-title { margin: 0; padding: var(--s-2) var(--s-4) var(--s-1); font-size: var(--fs-xs); color: var(--ink-3); }
.popover-item.is-current { font-weight: 700; color: var(--brand-700); }
.popover-item.is-current::after { content: '✓'; margin-left: auto; }

@media (max-width: 720px) {
  .agents-grid { grid-template-columns: 1fr; }
  .conv-agent { max-width: 44px; padding: 0; width: 36px; justify-content: center; }
  .conv-agent-name { display: none; }
  .agent-footer-left { width: 100%; margin-right: 0; }
}

/* ---------- F10 · Intenciones y "Generar respuesta IA" ---------- */
.intent-list { display: flex; flex-direction: column; gap: var(--s-3); margin: var(--s-3) 0; }
.intent-card { padding: var(--s-4); border: 1px solid var(--line); }
.intent-head { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-3); flex-wrap: wrap; }
.intent-head .input { flex: 1 1 220px; font-weight: 600; }
.intent-num {
  flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px;
  border-radius: var(--r-pill); background: var(--brand-50); color: var(--brand-700); font-weight: 700; font-size: var(--fs-sm);
}
.intent-tools { display: flex; gap: 2px; margin-left: auto; }
.intent-params { padding: var(--s-3); margin-bottom: var(--s-3); border-radius: var(--r-md); background: var(--surface-2); }
.intent-params .field:last-child { margin-bottom: 0; }
.intent-empty { margin: 0; padding: var(--s-4); text-align: center; }
.var-buttons { display: flex; flex-wrap: wrap; gap: var(--s-1); margin-top: var(--s-1); }
.var-btn { min-height: 28px; padding: 0 var(--s-2); font-family: var(--font-mono); font-size: var(--fs-xs); border: 1px dashed var(--line-2); }

.composer-ai {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: var(--s-1); min-height: 42px; padding: 0 var(--s-3);
  border: 1px solid var(--brand-600); border-radius: var(--r-pill); background: var(--brand-50); color: var(--brand-700);
  font-size: var(--fs-sm); font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.composer-ai:hover { background: var(--brand-100); }
.composer-ai:active { transform: scale(.97); }
.composer-ai:disabled { opacity: .5; cursor: not-allowed; }
.check-line { display: flex; align-items: flex-start; gap: var(--s-3); margin: 0 0 var(--s-4); cursor: pointer; }
.check-line input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--brand-600); flex-shrink: 0; }
.check-line > span { display: flex; flex-direction: column; gap: 2px; }
.suggest-modal > .btn { margin-bottom: var(--s-4); }
.suggest-area { min-height: 140px; }
.suggest-meta { font-variant-numeric: tabular-nums; }

@media (max-width: 720px) {
  .composer-ai { padding: 0; width: 42px; justify-content: center; }
  .composer-ai span { display: none; }
}
.doc-body .switch + .hint { display: block; margin: calc(-1 * var(--s-2)) 0 var(--s-2); }

/* ---------- F11 · Gestión IA, Avisos, vacaciones y fuera de horario ---------- */
.chart-c1 { --c: var(--chart-1); } .chart-c2 { --c: var(--chart-2); } .chart-c3 { --c: var(--chart-3); }
.chart-c4 { --c: var(--chart-4); } .chart-c5 { --c: var(--chart-5); } .chart-c6 { --c: var(--chart-6); }
.chart-other { --c: var(--ink-4); }

.usage-controls { display: flex; flex-direction: column; gap: var(--s-3); padding: var(--s-4); margin-bottom: var(--s-4); }
.usage-controls .seg-tabs { align-self: flex-start; flex-wrap: wrap; }
.usage-custom { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.usage-custom .input { width: auto; }
.usage-filters { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.usage-filters .select { max-width: 240px; }

.usage-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-3); margin-bottom: var(--s-4); }
.usage-stat { display: flex; flex-direction: column; gap: var(--s-1); padding: var(--s-4); min-height: 104px; }
.usage-stat-label { font-size: var(--fs-sm); color: var(--ink-3); font-weight: 600; }
.usage-stat-value { font-size: var(--fs-2xl); font-variant-numeric: tabular-nums; letter-spacing: -.01em; line-height: 1.2; }
.usage-stat-sub { font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }

.usage-group, .usage-events, .usage-rate { padding: var(--s-4); margin-bottom: var(--s-4); }
.usage-group-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; margin-bottom: var(--s-4); }
.usage-group-head h3, .usage-events h3, .usage-rate h3 { margin: 0; font-size: var(--fs-lg); }
.usage-events h3, .usage-rate h3 { margin-bottom: var(--s-3); }
.usage-group-head .seg-tabs { flex-wrap: wrap; }
.usage-charts { display: grid; grid-template-columns: 200px minmax(0, 1.4fr) minmax(0, 1fr); gap: var(--s-5); align-items: center; margin-bottom: var(--s-4); }
.chart { margin: 0; display: flex; flex-direction: column; gap: var(--s-2); min-width: 0; }
.chart figcaption { font-size: var(--fs-xs); color: var(--ink-3); text-align: center; }
.chart-donut svg { width: 180px; height: 180px; margin: 0 auto; }
.chart-track { fill: none; stroke: var(--line); stroke-width: 16; }
.chart-slice { fill: none; stroke: var(--c); stroke-width: 16; }
.chart-center { font-size: 11px; font-weight: 700; fill: var(--ink); font-variant-numeric: tabular-nums; }
.chart-lines svg { width: 100%; height: 160px; }
.chart-grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-line { fill: none; stroke: var(--c); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.bar-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s-2); }
.bar-list li { display: grid; grid-template-columns: minmax(0, 1fr) 2fr auto; align-items: center; gap: var(--s-2); font-size: var(--fs-sm); }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 10px; border-radius: var(--r-pill); background: var(--surface-2); overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: var(--r-pill); background: var(--c); }
.bar-value { color: var(--ink-2); }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.usage-table td, .usage-table th { white-space: nowrap; }
.legend-swatch { display: inline-block; width: 10px; height: 10px; margin-right: var(--s-2); border-radius: var(--r-xs); background: var(--c); vertical-align: middle; }
.usage-pct { display: flex; align-items: center; gap: var(--s-2); min-width: 160px; }
.usage-pct-bar { flex: 1; height: 8px; border-radius: var(--r-pill); background: var(--surface-2); overflow: hidden; }
.usage-pct-fill { display: block; height: 100%; background: var(--c); }
.usage-empty { margin: 0; padding: var(--s-4); text-align: center; }
.usage-rate-row { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.usage-rate-row .input { width: 120px; }
.keys-header { margin-top: var(--s-6); }

.avisos-card { padding: var(--s-5); margin-bottom: var(--s-4); max-width: 820px; }
.avisos-card h3 { margin: 0 0 var(--s-1); font-size: var(--fs-lg); }
.avisos-card > .hint { margin: 0 0 var(--s-4); }
.avisos-actions { display: flex; gap: var(--s-2); justify-content: flex-end; flex-wrap: wrap; margin-top: var(--s-4); }
.avisos-actions .btn-ghost-danger { margin-right: auto; }
.form-hint-error { color: var(--danger); min-height: 1em; }

.auto-reply { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); padding: var(--s-3); margin-bottom: var(--s-3); border: 1px solid var(--line); border-radius: var(--r-md); }
.auto-reply.is-on { border-color: var(--brand-600); background: var(--brand-50); }
.auto-reply-body { flex-basis: 100%; }
.auto-reply-actions { display: flex; align-items: center; justify-content: flex-end; gap: var(--s-3); }

@media (max-width: 1024px) {
  .usage-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .usage-charts { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .usage-filters .select { max-width: none; flex: 1 1 100%; }
  .usage-stat-value { font-size: var(--fs-xl); }
}

/* ---------- F12 · Logs, Guía y Manual ---------- */
.logs-controls { display: flex; flex-direction: column; gap: var(--s-3); padding: var(--s-4); margin-bottom: var(--s-4); }
.logs-controls .seg-tabs { align-self: flex-start; }
.logs-filters { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.logs-filters .select { max-width: 220px; }
.logs-filters .input[type=date] { width: auto; }
.logs-filters .input[type=search] { flex: 1 1 220px; }
.logs-table td { vertical-align: top; }
.log-row { cursor: pointer; }
.log-row:hover, .log-row:focus-visible { background: var(--surface-2); outline: none; }
.log-row.is-open { background: var(--surface-2); }
.log-row td:first-child { white-space: nowrap; font-variant-numeric: tabular-nums; }
.log-msg { max-width: 520px; overflow-wrap: anywhere; }
.log-detail td { background: var(--surface-2); }
.log-meta { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-4); margin-bottom: var(--s-2); font-size: var(--fs-xs); color: var(--ink-3); font-family: var(--font-mono); }
.log-json { margin: 0; padding: var(--s-3); max-height: 360px; overflow: auto; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); font-family: var(--font-mono); font-size: var(--fs-xs); white-space: pre-wrap; overflow-wrap: anywhere; }

.guide-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: var(--s-5); align-items: start; }
.guide-toc { position: sticky; top: var(--s-4); padding: var(--s-4); }
.guide-toc ul { list-style: none; margin: var(--s-2) 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.guide-toc a { display: block; padding: var(--s-1) var(--s-2); border-radius: var(--r-sm); color: var(--ink-2); text-decoration: none; font-size: var(--fs-sm); }
.guide-toc a:hover { background: var(--surface-2); color: var(--brand-700); }
.guide-body { display: flex; flex-direction: column; gap: var(--s-4); max-width: 820px; }
.guide-section { padding: var(--s-5); scroll-margin-top: var(--s-4); }
.guide-section h2 { margin: 0 0 var(--s-3); font-size: var(--fs-xl); }
.guide-section ul { margin: 0; padding-left: var(--s-5); display: flex; flex-direction: column; gap: var(--s-2); }
.guide-section li p, .guide-section > p { margin: 0; line-height: 1.55; }
.guide-section > p + ul, .guide-section > ul + p { margin-top: var(--s-3); }
.guide-code { margin: var(--s-3) 0; padding: var(--s-3); border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--line); font-family: var(--font-mono); font-size: var(--fs-xs); white-space: pre-wrap; overflow-x: auto; }
.manual-frame { width: 100%; height: calc(100dvh - var(--topbar-h) - var(--s-8)); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }

@media (max-width: 1024px) {
  .guide-layout { grid-template-columns: 1fr; }
  .guide-toc { position: static; }
}
.logs-retention { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; font-size: var(--fs-sm); }
.logs-retention .input { width: 90px; }

/* ---------- F13 · Móvil y accesibilidad ---------- */
/* iOS amplía la página al enfocar campos de menos de 16 px; en táctil todos los campos van a 16 px. */
@media (pointer: coarse) {
  .input, .select, .textarea, .tags-input-field, .composer-input { font-size: var(--fs-lg); }
  .seg-tab { min-height: 44px; }
  .reaction-btn { width: 44px; height: 44px; }
  .conv-agent, .composer-ai { min-height: 44px; }
  .tag-chip-x { min-width: 28px; min-height: 28px; justify-content: center; align-items: center; }
  .var-btn { min-height: 40px; }
  .doc-summary { min-height: 48px; }
  .log-row td { height: 48px; }
}

/* ---------- Gestor de Tareas ---------- */

.toast { pointer-events: auto; }
.toast-action {
  margin-left: auto; padding: 0 var(--s-2); min-height: 28px; border: 0; border-radius: var(--r-sm);
  background: rgba(255,255,255,.14); color: var(--surface); font-weight: 600; cursor: pointer;
}
.toast-action:hover { background: rgba(255,255,255,.24); }

.btn-sm { min-height: 32px; padding: 0 var(--s-3); font-size: var(--fs-sm); }
.icon-btn-sm { width: 32px; height: 32px; }

.seg-control { display: inline-flex; padding: 3px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--line); }
.seg-control .seg-btn { min-height: 34px; border-radius: var(--r-sm); }
.seg-control .seg-btn[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

.task-settings .btn-sm { align-self: flex-start; }
.task-contact-filter { display: inline-flex; align-items: center; gap: var(--s-2); margin-bottom: var(--s-3); padding: var(--s-1) var(--s-1) var(--s-1) var(--s-3); border-radius: var(--r-pill); background: var(--brand-50); color: var(--brand-700); font-size: var(--fs-sm); }
.task-contact-filter[hidden] { display: none; }
.task-empty-hint { margin-bottom: var(--s-3); color: var(--ink-3); font-size: var(--fs-sm); }
.task-truncated { margin-top: var(--s-3); color: var(--ink-3); font-size: var(--fs-sm); text-align: center; }

/* Píldoras de impacto y estado */
.impact-pill, .status-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px var(--s-2); border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 700; line-height: 18px; white-space: nowrap;
}
.impact-dot, .status-dot { width: 8px; height: 8px; border-radius: var(--r-pill); background: currentColor; flex-shrink: 0; }
.impact-pill.impact-low { color: var(--impact-low); background: var(--impact-low-soft); }
.impact-pill.impact-medium { color: var(--impact-medium); background: var(--impact-medium-soft); }
.impact-pill.impact-high { color: var(--impact-high); background: var(--impact-high-soft); }
.impact-pill.impact-critical { color: var(--surface); background: var(--impact-critical); }
.status-pill.status-todo, .status-todo .status-dot { color: var(--st-todo); }
.status-pill.status-in_progress, .status-in_progress .status-dot { color: var(--st-progress); }
.status-pill.status-waiting_client, .status-waiting_client .status-dot { color: var(--st-waiting); }
.status-pill.status-closed, .status-closed .status-dot { color: var(--st-closed); }
.status-pill.status-todo { background: var(--st-todo-soft); }
.status-pill.status-in_progress { background: var(--st-progress-soft); }
.status-pill.status-waiting_client { background: var(--st-waiting-soft); }
.status-pill.status-closed { background: var(--st-closed-soft); }

/* Tablero: 4 columnas fijas (sin auto-cols); en pantallas medianas se desplaza en horizontal desde la primera. */
.task-board { display: grid; grid-template-columns: repeat(4, minmax(250px, 1fr)); gap: var(--s-4); align-items: start; overflow-x: auto; padding-bottom: var(--s-2); }
.task-col {
  display: flex; flex-direction: column; min-height: 240px; border-radius: var(--r-lg);
  background: var(--surface-2); border: 1px solid var(--line); border-top: 3px solid var(--st-todo);
  transition: background-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.task-col.status-in_progress { border-top-color: var(--st-progress); }
.task-col.status-waiting_client { border-top-color: var(--st-waiting); }
.task-col.status-closed { border-top-color: var(--st-closed); }
.task-col-head { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-3) var(--s-3) var(--s-2); }
.task-col-title { font-size: var(--fs-md); font-weight: 600; color: var(--ink); }
.task-col-count { margin-left: auto; min-width: 24px; padding: 0 var(--s-2); border-radius: var(--r-pill); background: var(--surface); border: 1px solid var(--line); font-size: var(--fs-xs); font-weight: 700; line-height: 20px; text-align: center; color: var(--ink-2); }
.task-col-hint { margin: 0 var(--s-3) var(--s-2); font-size: var(--fs-xs); color: var(--ink-3); }
.task-col-body { display: flex; flex-direction: column; gap: var(--s-2); padding: 0 var(--s-2) var(--s-2); }
.task-col-empty { padding: var(--s-5) var(--s-3); border: 1px dashed var(--line-2); border-radius: var(--r-md); color: var(--ink-3); font-size: var(--fs-sm); text-align: center; }
.task-col.is-drop-target { background: color-mix(in srgb, var(--brand-600) 7%, var(--surface-2)); box-shadow: inset 0 0 0 2px var(--brand-600); }
.task-col.status-closed.is-drop-target { background: var(--st-closed-soft); box-shadow: inset 0 0 0 2px var(--st-closed); }
.task-skeleton { height: 96px; margin: var(--s-2); border-radius: var(--r-md); }

/* Tarjeta */
.task-card {
  position: relative; display: flex; flex-direction: column; gap: var(--s-2);
  padding: var(--s-3); padding-left: calc(var(--s-3) + 3px); border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1);
  cursor: grab; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: box-shadow var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), opacity var(--t-fast) var(--ease);
}
.task-card::before { content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--impact-low); }
.task-card.impact-medium::before { background: var(--impact-medium); }
.task-card.impact-high::before { background: var(--impact-high); }
.task-card.impact-critical::before { background: var(--impact-critical); }
.task-card:hover { box-shadow: var(--shadow-2); }
.task-card:active { transform: scale(.99); }
.task-card:focus-visible { outline: 2px solid var(--brand-600); outline-offset: 2px; }
.task-card.is-closed { opacity: .72; }
.task-card.is-closed .task-title { text-decoration: line-through; text-decoration-color: var(--ink-4); }
.task-card.is-drag-source { opacity: .35; box-shadow: none; }
.task-card.is-landed { animation: task-land 600ms var(--ease); }
@keyframes task-land { 0% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-600) 45%, transparent); } 100% { box-shadow: var(--shadow-1); } }
.task-ghost {
  position: fixed; left: 0; top: 0; z-index: var(--z-overlay); margin: 0; pointer-events: none; cursor: grabbing;
  box-shadow: var(--shadow-modal); will-change: transform; opacity: .96;
}
body.is-task-dragging, body.is-task-dragging * { cursor: grabbing !important; user-select: none; }

.task-card-top { display: flex; align-items: center; gap: var(--s-2); min-height: 24px; }
.task-num { font-size: var(--fs-xs); font-weight: 700; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.task-repeat { padding: 0 6px; border-radius: var(--r-pill); background: var(--impact-critical-soft); color: var(--impact-critical); font-size: var(--fs-xs); font-weight: 700; line-height: 18px; }
.task-ai { padding: 0 6px; border-radius: var(--r-pill); border: 1px solid var(--line-2); color: var(--ink-3); font-size: 10px; font-weight: 700; letter-spacing: .04em; line-height: 16px; }
.task-card .task-more { margin-left: auto; margin-right: -6px; color: var(--ink-3); }
.task-title {
  font-size: var(--fs-base); font-weight: 600; line-height: 1.35; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere;
}
.task-client { display: flex; flex-wrap: wrap; gap: 0 var(--s-2); font-size: var(--fs-sm); color: var(--ink-2); min-width: 0; }
.task-client-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.task-client-company { color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.task-card-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); }
.task-due { display: inline-flex; align-items: center; gap: 4px; padding: 1px 6px; border-radius: var(--r-sm); font-size: var(--fs-xs); font-weight: 600; color: var(--ink-2); background: var(--surface-2); }
.task-due.is-soon { color: var(--impact-high); background: var(--impact-high-soft); }
.task-due.is-overdue { color: var(--impact-critical); background: var(--impact-critical-soft); }
.task-requested { font-size: var(--fs-xs); color: var(--ink-3); }
.task-unassigned { font-size: var(--fs-xs); color: var(--ink-3); font-style: italic; }
.task-assignee { width: 26px; height: 26px; font-size: 11px; }

/* Pestañas de columnas (móvil) */
.task-tabs { display: none; }
@media (max-width: 767px) {
  .view-tareas.is-board .task-tabs {
    display: flex; gap: var(--s-1); margin-bottom: var(--s-3);
    overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none;
  }
  .view-tareas .task-tabs[hidden] { display: none; }
  .task-tabs::-webkit-scrollbar { display: none; }
  .task-tab {
    display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; min-height: 40px; padding: 0 var(--s-3);
    border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--surface); color: var(--ink-2);
    font-size: var(--fs-sm); font-weight: 600; scroll-snap-align: start;
  }
  .task-tab[aria-selected="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
  .task-tab[aria-selected="true"] .status-dot { color: var(--surface); }
  .task-tab-count { opacity: .75; font-variant-numeric: tabular-nums; }
  .task-board { display: block; overflow: visible; }
  .task-col { display: none; min-height: 0; }
  .task-col.is-mobile-active { display: flex; }
  .task-col-head { display: none; }
  .task-col-hint { margin-top: var(--s-2); }
  .task-col-body { padding-top: var(--s-2); }
  .task-card { cursor: pointer; }
  .header-actions { width: 100%; }
  .header-actions .seg-control { flex: 1; }
  .header-actions .seg-control .seg-btn { flex: 1; }
}

/* Lista */
.task-table td { vertical-align: middle; }
.task-table-title { font-weight: 600; max-width: 360px; }
.task-table-title > span:first-child { margin-right: var(--s-2); }
.task-table tr.is-closed td { color: var(--ink-3); }
.task-table tr.is-closed .task-table-title > span:first-child { text-decoration: line-through; }

/* Detalle */
.modal-task.modal-lg { max-width: 1040px; }
.task-detail { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: var(--s-6); }
.task-detail-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); margin-bottom: var(--s-3); font-size: var(--fs-sm); }
.task-client-box { margin: 0 0 var(--s-4); padding: var(--s-3) var(--s-4) 0; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface-2); min-width: 0; }
.task-client-box legend { padding: 0 var(--s-1); font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); }
.task-client-who { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-3); }
.task-client-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.task-client-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.field-tight { margin-bottom: var(--s-3); }
.task-detail-side { display: flex; flex-direction: column; min-width: 0; padding-left: var(--s-5); border-left: 1px solid var(--line); }
.task-side-title { font-size: var(--fs-md); font-weight: 600; margin-bottom: var(--s-3); }
.task-note-box { display: flex; flex-direction: column; align-items: flex-end; gap: var(--s-2); margin-bottom: var(--s-4); }
.task-note-box .textarea { min-height: 64px; }
.task-timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s-4); }
.tl-item { display: flex; gap: var(--s-3); position: relative; }
.tl-item:not(:last-child)::after { content: ''; position: absolute; left: 13px; top: 30px; bottom: calc(var(--s-4) * -1); width: 2px; background: var(--line); }
.tl-icon { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 28px; height: 28px; border-radius: var(--r-pill); background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-3); }
.tl-ai_message .tl-icon, .tl-created .tl-icon { color: var(--st-progress); background: var(--st-progress-soft); border-color: transparent; }
.tl-repeat .tl-icon { color: var(--impact-critical); background: var(--impact-critical-soft); border-color: transparent; }
.tl-note .tl-icon { color: var(--brand-700); background: var(--brand-50); border-color: transparent; }
.tl-body { flex: 1; min-width: 0; }
.tl-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0 var(--s-2); }
.tl-title { font-size: var(--fs-sm); font-weight: 600; color: var(--ink); }
.tl-time { font-size: var(--fs-xs); color: var(--ink-3); white-space: nowrap; }
.tl-summary { margin-top: 2px; font-size: var(--fs-sm); color: var(--ink-2); }
.tl-quote, .tl-note {
  margin: var(--s-2) 0 0; padding: var(--s-2) var(--s-3); border-radius: var(--r-md);
  font-size: var(--fs-sm); white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink);
}
.tl-quote { background: var(--bubble-in); border: 1px solid var(--line); border-left: 3px solid var(--st-progress); }
.tl-note { background: var(--brand-50); }
@media (max-width: 900px) {
  .task-detail { grid-template-columns: 1fr; gap: var(--s-4); }
  .task-detail-side { padding-left: 0; border-left: 0; border-top: 1px solid var(--line); padding-top: var(--s-4); }
}

/* Nueva tarea: buscador de cliente */
.contact-pick-results { list-style: none; margin: var(--s-1) 0 0; padding: 0; border-radius: var(--r-md); overflow: hidden; }
.contact-pick-results:not(:empty) { border: 1px solid var(--line); }
.contact-pick-item { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; min-height: 44px; padding: var(--s-2) var(--s-3); border: 0; background: var(--surface); text-align: left; cursor: pointer; }
.contact-pick-item:hover, .contact-pick-item:focus-visible { background: var(--surface-2); }
.contact-pick-none { padding: var(--s-2) var(--s-3); font-size: var(--fs-sm); }
.contact-pick-chosen { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-3); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); }
.contact-pick-chosen[hidden] { display: none; }
.contact-pick-chosen .btn { margin-left: auto; }

/* Chip de tareas abiertas en la cabecera del chat */
.conv-tasks { display: inline-flex; align-items: center; gap: 4px; min-height: 28px; padding: 0 var(--s-2); border-radius: var(--r-pill); background: var(--st-progress-soft); color: var(--st-progress); font-size: var(--fs-xs); font-weight: 700; text-decoration: none; white-space: nowrap; }
.conv-tasks:hover { background: color-mix(in srgb, var(--st-progress) 16%, var(--surface)); }
.conv-tasks[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  .task-card, .task-col { transition: none; }
  .task-card:active { transform: none; }
}
.switch[hidden] { display: none; }
.task-new-busy { margin: 0 0 var(--s-4); padding: var(--s-2) var(--s-3); border-radius: var(--r-md); background: var(--brand-50); color: var(--brand-700); font-size: var(--fs-sm); font-weight: 600; }
.task-new-busy[hidden] { display: none; }
.usage-full { margin-top: var(--s-2); color: var(--danger); font-size: var(--fs-sm); font-weight: 600; }
