:root {
  --bg: #0f1115;
  --bg-soft: #161920;
  --bg-hover: #1e222b;
  --border: #2a2f3a;
  --text: #e8eaf0;
  --text-muted: #8b92a8;
  --accent: #0aff9d;
  --accent-dim: #0aff9d22;
  --outbound: #1a5f4a;
  --inbound: #2a2f3a;
  --danger: #ff5c5c;
  --radius: 12px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --header-h: 56px;
  --composer-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overscroll-behavior: none;
}

button {
  font-family: inherit;
  color: inherit;
}

.hidden { display: none !important; }

.mobile-only { display: none; }
.desktop-only { display: block; }

/* App layout: mobile-first single column */
.chat-app {
  display: flex;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}

/* Views */
.chat-app[data-view="inbox"] .sidebar { transform: translateX(0); }
.chat-app[data-view="inbox"] .chat-panel { transform: translateX(100%); }
.chat-app[data-view="chat"] .sidebar { transform: translateX(-100%); }
.chat-app[data-view="chat"] .chat-panel { transform: translateX(0); }
.chat-app[data-view="chat"] .customer360 { transform: translateY(100%); }

.sidebar,
.chat-panel {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transition: transform 0.25s ease;
  will-change: transform;
}

.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--bg-soft);
  z-index: 1;
  position: relative;
}

.new-conv-fab {
  position: fixed;
  bottom: calc(80px + var(--safe-bottom, 0px));
  right: 16px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: #000;
  border: none;
  box-shadow: 0 4px 16px rgba(10, 255, 157, 0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 15;
  transition: transform 0.15s, box-shadow 0.15s;
}
.new-conv-fab:active {
  transform: scale(0.92);
  box-shadow: 0 2px 8px rgba(10, 255, 157, 0.2);
}

.chat-app[data-view="chat"] .new-conv-fab { display: none; }

@media (min-width: 769px) {
  .new-conv-fab {
    position: absolute;
    bottom: 16px;
    right: 16px;
    width: 46px;
    height: 46px;
  }
}

.chat-panel {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  z-index: 2;
}

/* Sidebar header */
.sidebar-header {
  height: var(--header-h);
  min-height: var(--header-h);
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: 6px;
}
/* FIX: los 5 botones de accesos rapidos quedaban amontonados junto al logo,
   con espacio vacio sin usar hasta el borde derecho del sidebar (la linea
   .resizer que separa el panel de chat/composer). Se empuja el grupo hacia
   esa linea, dejando el logo fijo a la izquierda. */
#dashboard-btn {
  margin-left: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  letter-spacing: 0.5px;
  font-size: 0.9rem;
}

.brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Toolbar */
.toolbar {
  display: flex;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  align-items: center;
  flex-shrink: 0;
}

.search-box {
  flex: 1;
}

.search-box input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
}

.search-box input:focus { outline: none; border-color: var(--accent); }

.toolbar-btn,
.composer-btn,
.back-btn,
.header-actions button {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  padding: 0;
}

.toolbar-btn:active,
.composer-btn:active,
.back-btn:active,
.header-actions button:active { background: var(--bg-hover); }

.header-action-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 36px;
  padding: 0 12px;
  border-radius: 18px;
  background: var(--accent);
  color: #000;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.header-action-link:hover { filter: brightness(1.1); }

.back-btn {
  width: 36px;
  height: 36px;
  margin-right: 8px;
}

/* Filter panel */
.filter-panel {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.filter-panel h4 { margin: 0; font-size: 0.8rem; color: var(--accent); }
.filter-panel label { font-size: 0.7rem; color: var(--text-muted); }
.filter-panel select {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px;
  font-size: 0.8rem;
  min-height: 60px;
}

.filter-actions { display: flex; gap: 8px; margin-top: 4px; }
.small-btn {
  flex: 1;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
  cursor: pointer;
  font-size: 0.8rem;
}
.small-btn.secondary { border-color: var(--border); background: var(--bg-soft); color: var(--text-muted); }

/* Tabs */
.inbox-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

/* En móvil: una sola fila con scroll horizontal */
@media (max-width: 768px) {
  .inbox-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .inbox-tabs::-webkit-scrollbar { display: none; }
}

.tab {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 0.75rem;
  cursor: pointer;
  white-space: nowrap;
}

.tab.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent);
}

/* Pull hint */
.pull-hint {
  text-align: center;
  font-size: 0.75rem;
  color: var(--accent);
  padding: 4px;
  background: var(--accent-dim);
}

/* Inbox list */
.inbox-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 0;
  touch-action: pan-y;
}

.inbox-list li {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
  overflow: hidden;
}

.inbox-list li:hover,
.inbox-list li:active { background: var(--bg-hover); }
.inbox-list li.active { background: var(--accent-dim); }
.inbox-list li.loading,
.inbox-list li.empty {
  color: var(--text-muted);
  text-align: center;
  cursor: default;
}

.inbox-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  user-select: none;
}

.inbox-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.inbox-name {
  font-weight: 600;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.inbox-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.inbox-preview {
  font-size: 0.85rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inbox-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.7rem;
  flex-wrap: wrap;
}

.unread-badge {
  background: var(--accent);
  color: #000;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
}

.channel-badge {
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 6px;
}

.channel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  margin-right: 6px;
}

.score-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 6px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.score-hot { background: rgba(239,68,68,0.15); color: #ef4444; }
.score-warm { background: rgba(245,158,11,0.15); color: #f59e0b; }
.score-cold { background: rgba(148,163,184,0.15); color: #94a3b8; }

.ela-status-badge {
  font-size: 0.75rem;
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--bg-hover);
}
.ela-badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  display: inline-block;
  margin-left: 6px;
  white-space: nowrap;
}
.ela-active { background: rgba(10, 255, 157, 0.15); color: var(--accent); }
.ela-paused { background: rgba(251, 191, 36, 0.15); color: #fbbf24; }
.ela-escalated { background: rgba(255, 92, 92, 0.15); color: var(--danger); }
.ela-off { background: rgba(139, 146, 168, 0.15); }

.human-countdown {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  display: inline-block;
  margin-left: 6px;
  white-space: nowrap;
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  font-variant-numeric: tabular-nums;
}
.human-countdown.expired {
  background: rgba(100, 116, 139, 0.15);
  color: #94a3b8;
}

.user-role-badge {
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
}
.user-role-badge.role-admin { background: rgba(239, 83, 80, 0.15); color: #ef5350; }
.user-role-badge.role-supervisor { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.user-role-badge.role-agent { background: rgba(10, 255, 157, 0.15); color: var(--accent); }

.pin-indicator { color: var(--accent); font-size: 0.7rem; margin-right: 4px; }
.tag-chip {
  display: inline-block;
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 10px;
  padding: 1px 6px;
  font-size: 0.65rem;
  margin-right: 4px;
}

/* Chat header */
.chat-header {
  height: var(--header-h);
  min-height: var(--header-h);
  padding: 0 16px;
  border-bottom: 2px solid var(--border);
  background: var(--bg-soft);
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.contact-info { flex: 1; min-width: 0; }
.contact-name {
  font-weight: 700;
  font-size: 1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.contact-presence {
  font-size: 0.72rem;
  margin-left: 6px;
}
.contact-presence.online { color: #2ecc71; }
.contact-presence.offline { color: var(--text-muted); }

.contact-channel {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-actions { display: flex; gap: 6px; align-items: center; }
.header-actions button,
.header-actions .header-action-btn { width: 36px; height: 36px; line-height: 1; border-radius: 8px; background: var(--bg); border: 1px solid var(--border); color: var(--text); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 1rem; }
.header-actions button:hover,
.header-actions .header-action-btn:hover { background: var(--bg-hover); }
#action-archive { padding-top: 2px; }

/* Timeline */
.timeline {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

/* Fondo de chat personalizable */
.timeline.wallpaper-default { background: var(--bg); }
.timeline.wallpaper-dark-green { background: #0d1f1a; }
.timeline.wallpaper-dark-blue { background: #0d1626; }
.timeline.wallpaper-dots {
  background-color: #0f1115;
  background-image: radial-gradient(circle, #2a2f3a 1px, transparent 1px);
  background-size: 16px 16px;
}
.timeline.wallpaper-grid {
  background-color: #0f1115;
  background-image: linear-gradient(#1e222b 1px, transparent 1px), linear-gradient(90deg, #1e222b 1px, transparent 1px);
  background-size: 20px 20px;
}
.timeline.wallpaper-custom {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.wallpaper-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 8px;
}
.wallpaper-swatch {
  aspect-ratio: 1;
  border-radius: 10px;
  border: 2px solid var(--border) !important;
  cursor: pointer;
  padding: 0 !important;
  transition: border-color 0.15s, transform 0.1s;
}
.wallpaper-swatch:hover { transform: scale(1.05); }
.wallpaper-swatch.active { border-color: var(--accent) !important; }
.wallpaper-upload {
  display: flex !important;
  align-items: center;
  justify-content: center;
  background: var(--bg) !important;
  color: var(--text-muted);
  font-size: 20px;
}
.wallpaper-upload:hover { color: var(--accent); }

.empty-state {
  margin: auto;
  color: var(--text-muted);
  text-align: center;
  max-width: 320px;
  padding: 20px;
}

.message {
  max-width: 82%;
  padding: 0 14px;
  font-size: 0.9rem;
  line-height: 1.4;
  word-break: break-word;
  animation: fadeIn 0.2s ease;
  /* No background here — it goes on .message-bubble for tails to work */
  background: transparent;
  border-radius: 0;
}

.message.inbound {
  align-self: flex-start;
}

.message.outbound {
  align-self: flex-end;
}

.message-meta {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 6px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.typing-indicator {
  color: var(--text-muted);
  font-size: 0.8rem;
  align-self: flex-start;
  margin-left: 4px;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Composer */
.composer {
  padding: 8px 12px calc(8px + var(--safe-bottom));
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
  flex-shrink: 0;
}

.composer-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.composer-input-wrap {
  flex: 1;
  min-width: 0;
}

#message-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  resize: none;
  max-height: 120px;
  min-height: 40px;
  line-height: 1.35;
  font-family: inherit;
}

#message-input:focus { outline: none; border-color: var(--accent); }

.send-btn {
  padding: 10px 18px;
  border-radius: 20px;
  border: none;
  background: var(--accent);
  color: #000;
  font-weight: 700;
  cursor: pointer;
  height: 40px;
  white-space: nowrap;
}

.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Attachment menu */
.attachment-menu {
  position: absolute;
  bottom: 72px;
  left: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 20;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.attachment-menu button {
  background: transparent;
  border: none;
  color: var(--text);
  padding: 12px 16px;
  text-align: left;
  font-size: 0.9rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.attachment-menu button:last-child { border-bottom: none; }
/* FIX: no existia :hover en absoluto (solo :active, que solo se activa al
   clic/soltar) -- por eso nunca se veia sombreado al pasar el mouse. Mismo
   tono --accent-dim usado en el resto del proyecto para consistencia. */
.attachment-menu button:hover { background: var(--accent-dim); }
.attachment-menu button:active { background: var(--accent-dim); }

/* Snippets */
.snippet-panel {
  position: absolute;
  bottom: 72px;
  left: 12px;
  right: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 220px;
  overflow-y: auto;
  z-index: 20;
}

.snippet-panel ul {
  list-style: none;
  margin: 0;
  padding: 8px 0;
}

.snippet-panel li {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}
.snippet-panel li:last-child { border-bottom: none; }
.snippet-panel li:active { background: var(--bg-hover); }
.snippet-panel li strong { display: block; color: var(--accent); margin-bottom: 2px; }

/* Toast / offline banner */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  padding: 12px 20px;
  border-radius: 24px;
  box-shadow: var(--shadow);
  z-index: 1000;
  font-size: 0.85rem;
  max-width: 90vw;
  text-align: center;
}
.toast.error { border-color: var(--danger); color: var(--danger); }

.offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--danger);
  color: #fff;
  text-align: center;
  padding: 8px 12px;
  font-size: 0.8rem;
  z-index: 1001;
}

/* Context menu */
.context-menu {
  position: fixed;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 1000;
  min-width: 180px;
  padding: 6px 0;
}

/* RONDA 3 (funcion Reaccionar) */
.reaction-picker {
  position: fixed;
  display: flex;
  gap: 2px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  z-index: 1000;
  padding: 6px 8px;
}
.reaction-picker.hidden { display: none; }
.reaction-picker-emoji {
  background: transparent !important;
  border: none !important;
  font-size: 20px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.1s, background 0.1s;
}
.reaction-picker-emoji:hover {
  background: var(--accent-dim) !important;
  transform: scale(1.15);
}

.message-react-btn {
  background: var(--bg-soft) !important;
  border: 1px solid var(--border) !important;
  color: var(--text-muted);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
  font-size: 14px;
}
.message-bubble-wrap:hover .message-react-btn { opacity: 1; }
.message-react-btn:hover { background: var(--accent-dim) !important; color: var(--accent); }

/* RONDA 3 (funcion Eliminar) */
.message-delete-btn {
  background: var(--bg-soft) !important;
  border: 1px solid var(--border) !important;
  color: var(--text-muted);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
  font-size: 14px;
}
.message-bubble-wrap:hover .message-delete-btn { opacity: 1; }
.message-delete-btn:hover { background: rgba(255,92,92,0.15) !important; color: var(--danger); }

/* RONDA 3 (funcion Editar) */
.message-edit-btn {
  background: var(--bg-soft) !important;
  border: 1px solid var(--border) !important;
  color: var(--text-muted);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
  font-size: 14px;
}
.message-bubble-wrap:hover .message-edit-btn { opacity: 1; }
.message-edit-btn:hover { background: var(--accent-dim) !important; color: var(--accent); }

/* RONDA 3 (funcion Reenviar) */
.message-forward-btn {
  background: var(--bg-soft) !important;
  border: 1px solid var(--border) !important;
  color: var(--text-muted);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
  font-size: 14px;
}
.message-bubble-wrap:hover .message-forward-btn { opacity: 1; }
.message-forward-btn:hover { background: var(--accent-dim) !important; color: var(--accent); }

/* Mensajes destacados dentro de la conversacion */
.message-star-btn {
  background: var(--bg-soft) !important;
  border: 1px solid var(--border) !important;
  color: var(--text-muted);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
  font-size: 14px;
}
.message-bubble-wrap:hover .message-star-btn { opacity: 1; }
.message-star-btn:hover { background: rgba(255,204,0,0.15) !important; color: #ffcc00; }
/* Si ya esta destacado, queda siempre visible (no solo al pasar el mouse),
   igual que WhatsApp muestra la estrella activa permanentemente. */
.message-star-btn.starred {
  opacity: 1;
  color: #ffcc00;
  border-color: #ffcc00 !important;
}

.message-forwarded-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 3px;
}
.message-forwarded-label i { font-size: 12px; }

.forward-conv-list {
  max-height: 320px;
  overflow-y: auto;
  margin-top: 8px;
}
.forward-conv-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s;
}
.forward-conv-item:hover { background: var(--accent-dim); }
.forward-conv-name { font-size: 0.88rem; color: var(--text); font-weight: 500; }
.forward-conv-phone { font-size: 0.75rem; color: var(--text-muted); }

/* Buscar dentro de la conversacion abierta */
.conv-search-panel {
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
}
.conv-search-panel.hidden { display: none; }
.conv-search-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
}
.conv-search-input-row i { color: var(--text-muted); font-size: 16px; flex-shrink: 0; }
#conv-search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 0.88rem;
  font-family: inherit;
}
.conv-search-close {
  background: transparent !important;
  border: none !important;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  flex-shrink: 0;
}
.conv-search-close:hover { color: var(--text); }
.conv-search-results {
  max-height: 280px;
  overflow-y: auto;
  margin-top: 8px;
}
.conv-search-result {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s;
}
.conv-search-result:hover { background: var(--accent-dim); }
.conv-search-result-text {
  font-size: 0.83rem;
  color: var(--text);
  line-height: 1.4;
  flex: 1;
}
.conv-search-result-text mark {
  background: var(--accent);
  color: #000;
  border-radius: 3px;
  padding: 0 2px;
}
.conv-search-result-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  flex-shrink: 0;
  white-space: nowrap;
}

.scheduled-result {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
}
.scheduled-result:hover { background: var(--bg-hover); }
.scheduled-cancel-btn {
  background: transparent !important;
  border: 1px solid var(--border) !important;
  color: var(--text-muted);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 13px;
}
.scheduled-cancel-btn:hover { background: rgba(255,92,92,0.15) !important; color: var(--danger); border-color: var(--danger) !important; }

.message-edited-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  opacity: 0.7;
  font-style: italic;
  margin-left: 4px;
}

.edit-banner {
  border-left-color: #ff9f43;
}
.edit-banner .reply-banner-icon,
.edit-banner .reply-banner-label {
  color: #ff9f43;
}

.message-bubble-deleted {
  font-style: italic;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0.75;
  animation: deletedFadeIn 0.35s ease 0.35s both;
}
@keyframes deletedFadeIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 0.75; transform: scale(1); }
}

/* Efecto de "destruccion" estilo Telegram: la burbuja se fragmenta en
   pedacitos que se dispersan antes de revelar el placeholder. Los
   fragmentos se generan dinamicamente en JS segun el tamano real de cada
   burbuja (varia con el largo del mensaje). */
.message-bubble.deleting > *:not(.message-delete-shard) {
  transition: opacity 0.18s ease;
  opacity: 0;
}
.message-delete-shard {
  position: absolute;
  border-radius: 3px;
  pointer-events: none;
  animation: deleteShardFly 0.55s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}
@keyframes deleteShardFly {
  0% {
    transform: translate(0, 0) rotate(0deg) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(var(--shard-x), var(--shard-y)) rotate(var(--shard-rot)) scale(0.3);
    opacity: 0;
  }
}

.message-reactions-badge {
  position: absolute;
  bottom: -10px;
  right: 8px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1px 6px;
  font-size: 13px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.message.outbound .message-reactions-badge { right: auto; left: 8px; }

.context-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 10px 14px;
  cursor: pointer;
  font-size: 0.9rem;
}
.context-menu button:active { background: var(--bg-hover); }
.context-menu .separator {
  height: 1px;
  background: var(--border);
  margin: 4px 8px;
}

/* Customer 360 mobile bottom sheet */
.customer360 {
  position: absolute;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  transform: translateY(100%);
  transition: transform 0.25s ease;
}

.customer360.open { transform: translateY(0); pointer-events: auto; }

.customer360-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.customer360.open .customer360-backdrop { opacity: 1; }

.customer360-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 85vh;
  background: var(--bg-soft);
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.25s ease;
}
.customer360.open .customer360-sheet { transform: translateY(0); }

.customer360-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 10px auto 4px;
}

.customer360-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.customer360-header h3 { margin: 0; font-size: 0.95rem; font-weight: 700; }
.customer360-toggle {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  width: 36px;
  height: 36px;
}

.customer360-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  padding-bottom: calc(12px + var(--safe-bottom));
}

.customer360-empty {
  color: var(--text-muted);
  text-align: center;
  margin-top: 40px;
  font-size: 0.85rem;
}

/* ── Customer 360: pestañas Resumen / Historial / Origen ──────────────────
   Mismo markup sirve para el panel lateral de escritorio y el bottom sheet
   de movil (ambos usan #customer360-content). Agrupa 16 secciones por
   frecuencia de uso: lo urgente sin scroll, lo frecuente a 1 toque, lo
   ocasional archivado pero accesible. */
.c360-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin: 0 0 12px;
  position: sticky;
  top: -12px;
  background: var(--bg-soft);
  z-index: 4;
}

.c360-tab {
  flex: 1;
  background: transparent !important;
  border: none !important;
  border-bottom: 2px solid transparent !important;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 10px 4px;
  cursor: pointer;
  border-radius: 0 !important;
  height: auto !important;
  transition: color 0.15s, border-color 0.15s;
}

.c360-tab.active {
  color: var(--accent) !important;
  border-bottom-color: var(--accent) !important;
}

.c360-tab-panel {
  display: none;
}
.c360-tab-panel.active {
  display: block;
}

.c360-section {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
}

.c360-section h4 {
  margin: 0 0 10px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
}

.c360-score-header {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}
.c360-score-header .score-badge {
  font-size: 0.8rem;
  padding: 3px 10px;
}

.c360-field {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}
.c360-field:last-child { border-bottom: none; }
.c360-label { color: var(--text-muted); }
.c360-value { font-weight: 500; text-align: right; }
.c360-required { color: #ef4444; font-weight: 700; margin-left: 3px; }

.c360-editable { align-items: center; flex-wrap: wrap; }
.c360-edit-input {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
  text-align: right;
  padding: 2px 6px;
  flex: 1;
  min-width: 0;
  max-width: none;
  width: auto;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
}
.c360-edit-name {
  text-align: left;
  width: 100%;
  min-width: 100%;
}
.c360-edit-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg);
}

.c360-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.c360-list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.c360-list li:last-child { border-bottom: none; }

.c360-btn {
  width: 100%;
  margin-top: 8px;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
}
.c360-btn:active { background: var(--accent); color: #000; }

.c360-action-btn {
  width: 100%;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--accent);
  background: linear-gradient(135deg, var(--accent-dim), rgba(255, 204, 0, 0.08));
  color: var(--accent);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.08s ease, box-shadow 0.15s ease;
}
.c360-action-btn:hover {
  box-shadow: 0 0 0 3px rgba(255, 204, 0, 0.15);
}
.c360-action-btn:active { transform: scale(0.98); }
.c360-action-btn:disabled { opacity: 0.6; cursor: wait; }
.c360-action-btn.small {
  width: auto;
  padding: 6px 10px;
  font-size: 0.8rem;
  /* FIX: margin-top:0 pegaba botones standalone (Agregar Datos, Guardar
     ubicacion, Vincular canal, Guardar nota) a la linea de arriba, sin
     espacio. Los que van junto a un <select> (.c360-action-row) mantienen
     margin-top:0 con su propia regla mas especifica, abajo. */
  margin-top: 8px;
}
.c360-action-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #000;
  font-size: 1rem;
  line-height: 1;
}

.c360-select {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 0.85rem;
  min-width: 140px;
}
.c360-action-row {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.c360-field.c360-actions {
  align-items: center;
  padding-top: 8px;
  margin-top: 4px;
  border-top: 1px dashed var(--border);
}

.c360-location-edit {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.c360-location-edit label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-top: 4px;
}
.c360-location-edit .c360-input,
.c360-location-edit .c360-select {
  width: 100%;
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 0.85rem;
  font-family: inherit;
}
.c360-location-edit .c360-select {
  appearance: auto;
}
.c360-save-btn {
  background: var(--accent);
  color: #000;
  border: none;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
}
.c360-save-btn:hover { filter: brightness(1.05); }
.c360-save-btn:disabled { opacity: 0.6; cursor: wait; }

.c360-ad-preview {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-soft);
}
.c360-ad-media img,
.c360-ad-media video {
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 260px;
  object-fit: contain;
  display: block;
  background: #000;
}
.c360-ad-title {
  padding: 8px 10px 0;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text);
}
.c360-ad-body {
  padding: 4px 10px 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.35;
}
.c360-ad-link {
  display: block;
  padding: 8px 10px;
  font-size: 0.78rem;
  color: var(--accent);
  border-top: 1px solid var(--border);
  text-decoration: none;
  text-align: center;
}
.c360-ad-link:hover { text-decoration: underline; }

.c360-ad-modal-btn {
  display: block;
  width: 100%;
  padding: 8px 10px;
  font-size: 0.78rem;
  color: var(--accent);
  background: transparent;
  border: none;
  border-top: 1px solid var(--border);
  cursor: pointer;
  text-align: center;
}
.c360-ad-modal-btn:hover { background: var(--bg-hover); }

/* Ad preview modal */
.ad-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
}
.ad-preview-modal.hidden { display: none !important; }
.ad-preview-modal.open { pointer-events: auto; }

.ad-preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.ad-preview-modal.open .ad-preview-backdrop { opacity: 1; }

.ad-preview-sheet {
  position: relative;
  width: 100%;
  max-height: 85vh;
  background: var(--bg-soft);
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.25s ease;
  box-shadow: var(--shadow);
}
.ad-preview-modal.open .ad-preview-sheet { transform: translateY(0); }

.ad-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.ad-preview-header h3 { margin: 0; font-size: 0.95rem; font-weight: 700; }

.ad-preview-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  width: 36px;
  height: 36px;
}

.ad-preview-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  padding-bottom: calc(16px + var(--safe-bottom));
}

.ad-preview-content .c360-ad-media {
  margin-bottom: 10px;
}
.ad-preview-content .c360-ad-media img,
.ad-preview-content .c360-ad-media video {
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 60vh;
  object-fit: contain;
  border-radius: var(--radius);
  display: block;
  background: #000;
}

/* Resizer desktop only */
.resizer {
  display: none;
}

/* Voice recorder (WhatsApp style) */
.voice-recorder {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin: 0 8px 8px;
  background: var(--bg-soft);
  border-radius: 20px;
  border: 1px solid var(--danger);
  animation: fadeIn 0.15s ease;
}

.voice-timer {
  font-family: "SF Mono", monospace;
  font-size: 0.85rem;
  color: var(--danger);
  min-width: 40px;
}

.voice-wave-bars {
  flex: 1;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.voice-wave-bars .bar {
  width: 3px;
  background: var(--accent);
  border-radius: 2px;
  animation: voiceBar 0.6s infinite ease-in-out alternate;
}

@keyframes voiceBar {
  0% { height: 4px; }
  100% { height: 20px; }
}

.voice-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.voice-send {
  background: var(--accent);
  color: #000;
}

.voice-delete {
  background: rgba(255, 92, 92, 0.15);
  color: var(--danger);
}

.voice-hint {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 6px 12px;
  border-radius: 12px;
  font-size: 0.75rem;
  white-space: nowrap;
  z-index: 10;
}

.composer-row { position: relative; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* New conversation modal */
.new-conv-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
}
.new-conv-modal.hidden { display: none !important; }
.new-conv-modal.open { pointer-events: auto; }

.new-conv-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.new-conv-modal.open .new-conv-backdrop { opacity: 1; }

.new-conv-sheet {
  position: relative;
  width: 100%;
  max-height: 90vh;
  background: var(--bg-soft);
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.25s ease;
  box-shadow: var(--shadow);
}
.new-conv-modal.open .new-conv-sheet { transform: translateY(0); }

.new-conv-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.new-conv-header h3 { margin: 0; font-size: 0.95rem; font-weight: 700; }
.new-conv-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  width: 36px;
  height: 36px;
}

.new-conv-tabs {
  display: flex;
  gap: 8px;
  padding: 12px 16px 0;
  border-bottom: 1px solid var(--border);
}
.new-conv-tab {
  flex: 1;
  padding: 8px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
}
.new-conv-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.new-conv-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ephemeral-option.active-option {
  color: var(--accent) !important;
  background: var(--accent-dim) !important;
}
.ephemeral-option.active-option::after {
  content: '✓';
  margin-left: auto;
}

#poll-options-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.poll-option-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 0.85rem;
  font-family: inherit;
}
.poll-add-option-btn {
  background: transparent !important;
  border: 1px dashed var(--border) !important;
  border-radius: 8px;
  color: var(--text-muted);
  padding: 7px 10px;
  font-size: 0.8rem;
  cursor: pointer;
  margin-top: 6px;
  width: 100%;
}
.poll-add-option-btn:hover { border-color: var(--accent) !important; color: var(--accent); }

.new-conv-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.new-conv-field label {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.new-conv-field input,
.new-conv-field textarea {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
}
.new-conv-field input:focus,
.new-conv-field textarea:focus { outline: none; border-color: var(--accent); }

.new-conv-results {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}
.new-conv-result {
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.new-conv-result:last-child { border-bottom: none; }
.new-conv-result:hover { background: var(--bg-hover); }
.new-conv-result-name { font-weight: 500; font-size: 0.85rem; }
.new-conv-result-phone { color: var(--text-muted); font-size: 0.75rem; }

.new-conv-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px calc(12px + var(--safe-bottom));
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* Tablet and desktop */
@media (min-width: 769px) {
  .mobile-only { display: none !important; }
  .desktop-only { display: block; }

  .chat-app {
    display: grid;
    grid-template-columns: 340px 1fr 6px 320px;
    position: relative;
  }

  .chat-app.customer360-collapsed { grid-template-columns: 340px 1fr 0px 0px; }

  .sidebar,
  .chat-panel {
    position: static;
    transform: none !important;
    width: auto;
    height: 100%;
    min-height: 0;
  }

  .chat-app[data-view] .sidebar,
  .chat-app[data-view] .chat-panel { transform: none !important; }

  .customer360 {
    position: static;
    transform: none !important;
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    background: var(--bg-soft);
    border-left: 1px solid var(--border);
    overflow: hidden;
    height: 100%;
  }

  .chat-app.customer360-collapsed .customer360,
  .chat-app.customer360-collapsed .resizer { display: none; }

  .customer360-sheet {
    position: static;
    transform: none !important;
    border-radius: 0;
    max-height: none;
    height: 100%;
  }

  .customer360-backdrop,
  .customer360-handle { display: none; }

  .resizer {
    display: block;
    background: var(--border);
    cursor: col-resize;
    width: 6px;
    transition: background 0.15s;
  }
  .resizer:hover { background: var(--accent); }

  .ad-preview-modal { align-items: center; }
  .ad-preview-sheet {
    width: 560px;
    max-width: 90vw;
    max-height: 80vh;
    border-radius: var(--radius);
    transform: translateY(20px) scale(0.96);
    opacity: 0;
    transition: transform 0.25s ease, opacity 0.25s ease;
  }
  .ad-preview-modal.open .ad-preview-sheet {
    transform: translateY(0) scale(1);
    opacity: 1;
  }

  .new-conv-modal { align-items: center; }
  .new-conv-sheet {
    width: 480px;
    max-width: 90vw;
    max-height: 85vh;
    border-radius: var(--radius);
    transform: translateY(20px) scale(0.96);
    opacity: 0;
    transition: transform 0.25s ease, opacity 0.25s ease;
  }
  .new-conv-modal.open .new-conv-sheet {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@media (min-width: 1024px) {
  .chat-app { grid-template-columns: 380px 1fr 6px 360px; }
  .chat-app.customer360-collapsed { grid-template-columns: 380px 1fr 0px 0px; }
}

/* Extra small screens */
@media (max-width: 360px) {
  .header-actions button { width: 32px; height: 32px; }
  .composer-btn { width: 36px; height: 36px; }
  .send-btn { padding: 8px 14px; }
}

/* ── Mensajes mejorados (paridad WhatsApp) ─────────────────────────────── */
.message.system,
.message.note {
  align-self: center;
  background: transparent;
  max-width: 92%;
  padding: 4px 0;
}
.message-system-bubble {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.4;
}
.message-note-bubble {
  background: var(--bg-soft);
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.85rem;
  color: var(--text);
  text-align: left;
  line-height: 1.4;
}
.message-note-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.message-meta-center {
  justify-content: center;
}
.message-bubble {
  padding: 8px 12px;
  border-radius: 12px;
  position: relative;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* RONDA 3 (funcion Responder) */
.message-bubble-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
}
.message.outbound .message-bubble-wrap { flex-direction: row-reverse; }

.message-reply-btn {
  background: var(--bg-soft) !important;
  border: 1px solid var(--border) !important;
  color: var(--text-muted);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
  font-size: 14px;
}
.message-bubble-wrap:hover .message-reply-btn { opacity: 1; }
.message-reply-btn:hover { background: var(--accent-dim) !important; color: var(--accent); }

.message-quoted-preview {
  border-left: 3px solid var(--accent);
  background: rgba(255,255,255,0.06);
  padding: 4px 8px;
  margin-bottom: 4px;
  border-radius: 4px;
  font-size: 0.78rem;
  color: var(--text-muted);
  max-height: 40px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.12s;
}
.message-quoted-preview:hover { background: rgba(255,255,255,0.12); }

/* FIX: al tocar una cita, resaltar brevemente el mensaje original al
   saltar hacia el -- mismo comportamiento que WhatsApp real. */
@keyframes messageHighlightFlash {
  0%, 100% { background: transparent; }
  30% { background: var(--accent-dim); }
}
.message-highlight .message-bubble {
  animation: messageHighlightFlash 1.5s ease;
}

.reply-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 8px 10px;
  margin: 0 0 6px;
}
.reply-banner.hidden { display: none; }
.reply-banner-icon { color: var(--accent); font-size: 16px; flex-shrink: 0; }
.reply-banner-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.reply-banner-label { font-size: 0.7rem; color: var(--accent); font-weight: 600; }
.reply-banner-preview {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reply-banner-close {
  background: transparent !important;
  border: none !important;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}
.reply-banner-close:hover { color: var(--text); }
.message.inbound .message-bubble {
  background: var(--inbound);
  border-bottom-left-radius: 4px;
}
.message.outbound .message-bubble {
  background: var(--outbound);
  border-bottom-right-radius: 4px;
}
.message-sender {
  font-size: 0.72rem;
  font-weight: 700;
  margin-bottom: 2px;
  color: var(--text-muted);
}
.message-sender.ela { color: var(--accent); }
.message-sender.operator { color: var(--text); }
.message-sender.client { color: var(--text-muted); }
.message-sender.business { color: var(--accent); text-transform: uppercase; letter-spacing: 0.5px; }

.sender-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.08);
}
.ela-dot { background: #22c55e; box-shadow: 0 0 6px #22c55e; }
.operator-dot { background: #f59e0b; box-shadow: 0 0 6px #f59e0b; }
.client-dot { background: #94a3b8; }
.business-dot { background: #3b82f6; box-shadow: 0 0 6px #3b82f6; }

.message.outbound.ela .message-bubble {
  background: linear-gradient(135deg, #e0f2fe 0%, #dbeafe 100%);
  border: 1px solid #7dd3fc;
  color: #0c4a6e;
}
.message.outbound.ela {
  align-self: flex-end;
}

.message-meta {
  align-items: center;
}
.message-channel {
  opacity: 0.7;
}
.message-checks {
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: -2px;
}
.message-checks.delivered { color: var(--text-muted); }
.message-checks.read { color: #53bdeb; }
.message-checks.failed { color: #ef5350; }

.link-preview {
  margin-top: 6px;
  max-width: 320px;
}
.link-preview-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-soft);
  text-decoration: none;
  color: inherit;
}
.link-preview-img-wrap {
  width: 100%;
  height: 140px;
  background: #000;
}
.link-preview-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.link-preview-body {
  padding: 8px 10px;
}
.link-preview-domain {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 2px;
}
.link-preview-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
  line-height: 1.25;
}
.link-preview-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.link-preview-loading {
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 6px 0;
}

.unread-messages-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
  color: #e67e22;
}
.unread-messages-line::before,
.unread-messages-line::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #e67e22;
  opacity: 0.4;
}
.unread-messages-line span {
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.message-date-separator {
  align-self: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px 12px;
  margin: 12px 0;
  text-transform: capitalize;
}
.message-link {
  color: var(--accent);
  text-decoration: underline;
  word-break: break-all;
}
.message-attachments { margin-top: 6px; }
.message-media-wrap { display: block; }
.message-media {
  max-width: 260px;
  border-radius: 4px;
  display: block;
}
.message-video, .message-audio {
  max-width: 260px;
  border-radius: 4px;
  display: block;
}
.message-location-card {
  max-width: 280px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-soft);
}
.message-location-label {
  padding: 8px 10px 0;
  font-size: 0.82rem;
  color: var(--text);
  font-weight: 600;
}
.message-location-map {
  width: 100%;
  height: 160px;
  border: none;
  display: block;
  margin-top: 6px;
  pointer-events: none; /* evita interactuar/hacer zoom sin querer dentro del bubble */
}
.message-location-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  font-size: 0.8rem;
  color: var(--accent);
  text-decoration: none;
  border-top: 1px solid var(--border);
}
.message-location-link:hover { background: var(--accent-dim); }

.message-sticker-wrap {
  position: relative;
  display: inline-block;
}
.message-sticker {
  max-width: 120px;
  max-height: 120px;
  border-radius: 4px;
  display: block;
}
.message-sticker-placeholder {
  font-size: 2rem;
  line-height: 1;
}
.message-sticker-save-btn {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(0,0,0,0.55) !important;
  border: none !important;
  color: #fff;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.15s;
}
.message-sticker-wrap:hover .message-sticker-save-btn { opacity: 1; }
.message-sticker-save-btn:hover { background: var(--accent-dim) !important; color: var(--accent); }
.message-sticker-save-btn.saved { opacity: 1; color: #ffcc00; }

/* Picker de la biblioteca de stickers */
.sticker-library-picker {
  position: fixed;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 1000;
  padding: 10px;
  width: 260px;
  max-height: 320px;
  overflow-y: auto;
}
.sticker-library-picker.hidden { display: none; }
.sticker-library-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.sticker-library-item {
  cursor: pointer;
  border-radius: 6px;
  overflow: hidden;
  transition: transform 0.1s;
  position: relative;
}
.sticker-library-item:hover { transform: scale(1.05); }
.sticker-library-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: var(--bg);
  border-radius: 6px;
  display: block;
}
.sticker-library-item .sticker-library-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(0,0,0,0.6) !important;
  border: none !important;
  color: #fff;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.sticker-library-upload-btn {
  grid-column: 1 / -1;
  padding: 8px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.75rem;
  background: transparent !important;
}
.sticker-library-upload-btn:hover { border-color: var(--accent); color: var(--accent); }
.message-audio-transcript {
  margin-top: 6px;
  padding: 6px 10px;
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--text-secondary);
  background: var(--bg-soft);
  border-radius: 8px;
}
.message-caption {
  padding: 6px 10px;
  font-size: 0.95rem;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg-soft);
  border-radius: 0 0 10px 10px;
  margin-top: 2px;
}
.message-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
}
.message-file-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.message-file-name {
  font-size: 0.85rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.message-file-type {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ── Emoji panel ────────────────────────────────────────────────────────── */
.emoji-panel {
  position: absolute;
  bottom: 72px;
  left: 12px;
  right: 12px;
  max-height: 220px;
  overflow-y: auto;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 25;
  padding: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.emoji-item {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
}
.emoji-item:hover { background: var(--bg-hover); }

/* ── Composer siempre visible ───────────────────────────────────────────── */
.composer {
  position: relative;
  z-index: 10;
}
.composer-row {
  align-items: flex-end;
}

/* ── Notas en Customer360 ──────────────────────────────────────────────── */
.c360-note-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
  position: relative;
}
.c360-note-form textarea {
  width: 100%;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
  min-height: 50px;
}
.c360-note-form .send-btn.small {
  align-self: flex-end;
  padding: 6px 16px;
  font-size: 0.75rem;
  font-weight: 600;
  height: auto;
  min-width: 100px;
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: 8px;
  background: var(--accent);
  color: #000;
  border: none;
  cursor: pointer;
  letter-spacing: 0.02em;
}

.mention-dropdown {
  position: absolute;
  z-index: 20;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.mention-item {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.mention-item:hover,
.mention-item.active {
  background: var(--bg-hover);
}
.mention-item:first-child { border-top-left-radius: 10px; border-top-right-radius: 10px; }
.mention-item:last-child { border-bottom-left-radius: 10px; border-bottom-right-radius: 10px; }
.mention-name { font-weight: 500; font-size: 0.85rem; }
.mention-login { color: var(--text-muted); font-size: 0.75rem; }

/* ═══════════════════════════════════════════════════════════════════════════
   Customer 360 — Visual Polish (v2)
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Fix: valores largos que se desbordan ───────────────────────────────── */
.c360-value {
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
  min-width: 0;
  max-width: 60%;
}

/* ── Fix: campo flex se adapta mejor a valores largos ──────────────────── */
.c360-field {
  align-items: baseline;
  min-height: 28px;
}

.c360-label {
  flex-shrink: 0;
  white-space: nowrap;
  font-size: 0.8rem;
}

/* ── Fix: ícono "+" del botón Crear cotización, centrado perfecto ───────── */
.c360-action-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: #000;
  font-size: 0.85rem;
  font-weight: 800;
  line-height: 1;
  flex-shrink: 0;
  /* Compensar la métrica del "+" que siempre se ve alto */
  padding-bottom: 1px;
}

/* ── Fix: botón "Crear cotización" no se sale del contenedor ───────────── */
.c360-action-btn {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Fix: fila de acción (select + botón) en panel estrecho ────────────── */
.c360-action-row {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: nowrap;
  min-width: 0;
}

.c360-action-row .c360-select {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.8rem;
  padding: 5px 6px;
}

.c360-action-row .c360-action-btn.small {
  flex-shrink: 0;
  white-space: nowrap;
  padding: 5px 8px;
  font-size: 0.75rem;
  margin-top: 0;
}

/* ── Fix: campo de acciones (Etapa / Asignar a) layout ─────────────────── */
.c360-field.c360-actions {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

.c360-field.c360-actions .c360-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-muted);
}

/* ── Fix: secciones con mejor jerarquía visual ─────────────────────────── */
.c360-section {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
  background: var(--bg);
  transition: border-color 0.15s;
}

.c360-section:hover {
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
}

.c360-section h4 {
  margin: 0 0 8px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Fix: preview del anuncio — imagen cortada ─────────────────────────── */
.c360-ad-preview {
  margin-top: 6px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-soft);
}

.c360-ad-media {
  position: relative;
  background: #0a0a0a;
  overflow: hidden;
}

.c360-ad-media img,
.c360-ad-media video {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  display: block;
}

.c360-ad-title {
  padding: 8px 10px 2px;
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text);
  line-height: 1.3;
}

.c360-ad-body {
  padding: 2px 10px 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.c360-ad-link,
.c360-ad-modal-btn {
  display: block;
  padding: 8px 10px;
  font-size: 0.75rem;
  color: var(--accent);
  text-align: center;
  border-top: 1px solid var(--border);
  text-decoration: none;
  background: transparent;
  border-left: none;
  border-right: none;
  border-bottom: none;
  cursor: pointer;
  width: 100%;
  transition: background 0.15s;
}

.c360-ad-link:hover,
.c360-ad-modal-btn:hover {
  background: var(--bg-hover);
  text-decoration: none;
}

/* ── Fix: listas dentro del C360 — items demasiado apretados ───────────── */
.c360-list li {
  padding: 6px 0;
  font-size: 0.82rem;
  line-height: 1.4;
}

.c360-list li small {
  color: var(--text-muted);
  font-size: 0.72rem;
}

.c360-list li a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.78rem;
}

.c360-list li a:hover {
  text-decoration: underline;
}

/* ── Fix: customer360-empty centrado ───────────────────────────────────── */
.customer360-empty,
.c360-section .customer360-empty {
  color: var(--text-muted);
  text-align: center;
  font-size: 0.8rem;
  padding: 8px 0;
  margin: 0;
}

/* ── Fix: nota form textarea + botón alineados ─────────────────────────── */
.c360-note-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.c360-note-form textarea {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.82rem;
  resize: vertical;
  min-height: 44px;
  max-height: 120px;
  transition: border-color 0.15s;
}

.c360-note-form textarea:focus {
  outline: none;
  border-color: var(--accent);
}



/* ── Fix: scrollbar del panel C360 — más sutil ─────────────────────────── */
.customer360-content::-webkit-scrollbar {
  width: 4px;
}

.customer360-content::-webkit-scrollbar-track {
  background: transparent;
}

.customer360-content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.customer360-content::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ── Fix: header del C360 — más limpio ─────────────────────────────────── */
.customer360-header h3 {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}

/* ── Fix: ad preview modal en desktop — más pulido ─────────────────────── */
@media (min-width: 769px) {
  .ad-preview-sheet {
    border: 1px solid var(--border);
  }

  .c360-action-row .c360-select {
    min-width: 120px;
  }
}

/* ── Fix: mobile — campos C360 en columna cuando es muy estrecho ───────── */
@media (max-width: 360px) {
  .c360-field {
    flex-direction: column;
    gap: 2px;
  }

  .c360-value {
    text-align: left;
    max-width: 100%;
  }

  .c360-action-row {
    flex-wrap: wrap;
  }

  .c360-action-row .c360-select {
    width: 100%;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Composer — WhatsApp-style mobile layout
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Mobile: hide extra buttons, show only + [input] 🎤/➤ ──────────────── */
@media (max-width: 768px) {
  .composer-extra {
    display: none !important;
  }

  .composer-row {
    gap: 6px;
  }

  .composer-plus,
  .composer-mic {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: 50%;
    font-size: 1.1rem;
  }

  .composer-plus {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
  }

  .send-btn {
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 50%;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  /* When input has text: hide mic, show send */
  .composer-row.has-text .composer-mic { display: none !important; }
  .composer-row.has-text .send-btn { display: flex !important; }

  /* When input is empty: show mic, hide send */
  .composer-row:not(.has-text) .composer-mic { display: flex; }
  .composer-row:not(.has-text) .send-btn { display: none; }

  #message-input {
    padding: 9px 14px;
    font-size: 0.95rem;
    min-height: 38px;
    border-radius: 20px;
  }

  .composer {
    padding: 6px 8px calc(6px + var(--safe-bottom));
  }
}

/* ── Expand grid (WhatsApp-style action grid) ──────────────────────────── */
.composer-expand {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 12px 8px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  border-radius: 16px 16px 0 0;
  margin: 8px -8px calc(-6px - var(--safe-bottom, 0px));
  animation: expandUp 0.2s ease;
}

@keyframes expandUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.expand-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
  border-radius: 12px;
  font-size: 0.72rem;
  font-family: inherit;
  transition: background 0.12s;
}

/* FIX: mismo problema que attachment-menu -- sin :hover, solo :active. */
.expand-item:hover {
  background: var(--accent-dim);
}
.expand-item:active {
  background: var(--accent-dim);
  transform: scale(0.95);
}

.expand-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

/* ── Desktop: keep all buttons visible, hide expand grid ───────────────── */
@media (min-width: 769px) {
  .composer-extra {
    display: inline-flex !important;
  }

  .composer-expand {
    display: none !important;
  }

  .composer-mic {
    display: inline-flex;
  }

  .send-btn {
    display: flex;
    width: auto;
    padding: 10px 18px;
    border-radius: 20px;
  }

  /* On desktop, + opens the old attachment-menu */
  .composer-plus {
    background: var(--bg);
    border-color: var(--border);
    color: var(--text);
    border-radius: 10px;
    width: 40px;
    height: 40px;
  }
}

/* ── + button rotation transition ──────────────────────────────────────── */
.composer-plus {
  transition: transform 0.2s ease;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Slash commands — autocomplete de snippets al escribir /
   ═══════════════════════════════════════════════════════════════════════════ */
.slash-autocomplete {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  max-height: 240px;
  overflow-y: auto;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 12px 12px 0 0;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.3);
  z-index: 30;
  padding: 4px 0;
}

.slash-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

.slash-item:last-child { border-bottom: none; }
.slash-item:hover,
.slash-item.active { background: var(--bg-hover); }

.slash-item-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.slash-shortcut {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

.slash-name {
  font-size: 0.82rem;
  color: var(--text);
  font-weight: 500;
}

.slash-preview {
  font-size: 0.75rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.3;
}

.slash-hint {
  padding: 6px 14px;
  font-size: 0.7rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  text-align: center;
}

/* Guide modal */
.guide-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.guide-modal.hidden { display: none; }

.guide-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
}

.guide-sheet {
  position: relative;
  width: 100%;
  max-height: 80vh;
  background: var(--bg-soft);
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  padding: 16px;
  padding-bottom: calc(16px + var(--safe-bottom));
  transform: translateY(0);
  transition: transform 0.25s ease;
  overflow-y: auto;
}

.guide-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.guide-header h3 { margin: 0; font-size: 1rem; }

.guide-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  width: 36px;
  height: 36px;
}

.guide-body section { margin-bottom: 16px; }
.guide-body h4 {
  font-size: 0.9rem;
  margin-bottom: 6px;
  color: var(--accent);
}
.guide-body ul {
  list-style: disc;
  padding-left: 18px;
  font-size: 0.85rem;
  color: var(--text);
}
.guide-body li { margin-bottom: 6px; }
.guide-body code {
  background: var(--bg);
  padding: 2px 5px;
  border-radius: 4px;
  font-family: monospace;
}

/* Guia v2 (12 de julio) -- contenido nuevo, centrado y con ancho maximo
   legible en pantallas grandes sin tocar .guide-sheet (compartida con
   otros modales). */
.guide-body-v2 {
  max-width: 880px;
  margin: 0 auto;
}
.guide-catnav {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 12px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: -16px;
  background: var(--bg-soft);
  z-index: 2;
  padding-top: 4px;
}
.guide-catnav a {
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  transition: all 0.15s;
}
.guide-catnav a:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-dim); }

.guide-body-v2 section { margin-bottom: 32px; scroll-margin-top: 60px; }
.guide-cat-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.guide-icon-badge {
  width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-dim); color: var(--accent); font-size: 15px;
  flex-shrink: 0;
}
.guide-cat-head h4 { font-size: 1.02rem; margin: 0; font-weight: 700; color: var(--text); }
.guide-cat-sub { color: var(--text-muted); font-size: 0.8rem; margin: 0 0 14px 40px; }

.guide-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (max-width: 640px) { .guide-grid { grid-template-columns: 1fr; } }

.guide-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  position: relative;
}
.guide-card .guide-row { display: flex; align-items: flex-start; gap: 9px; }
.guide-card .guide-row > i.ti { font-size: 16px; color: var(--accent); margin-top: 2px; flex-shrink: 0; }
.guide-card h5 { font-size: 0.84rem; margin: 0 0 3px; font-weight: 600; color: var(--text); }
.guide-card p { font-size: 0.76rem; color: var(--text-muted); margin: 0; line-height: 1.4; }
.guide-card.guide-new { border-color: var(--accent); }
.guide-badge-new {
  position: absolute; top: -8px; right: 10px;
  font-size: 0.6rem; font-weight: 700; color: #06231a;
  background: var(--accent); padding: 2px 7px; border-radius: 10px;
}

.guide-status-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 14px; margin-bottom: 8px;
}
.guide-status-row .guide-emoji { font-size: 1.2rem; }
.guide-status-row b { font-size: 0.82rem; color: var(--text); display: block; }
.guide-status-row span { display: block; font-size: 0.75rem; color: var(--text-muted); }

.guide-kbd-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.guide-kbd-table td { padding: 9px 0; border-bottom: 1px solid var(--border); color: var(--text); }
.guide-kbd-table td:first-child { color: var(--text-muted); }
.guide-kbd code {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 5px; padding: 2px 7px; font-family: monospace; font-size: 0.76rem;
  color: var(--accent);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Customer 360 — Ronda 5 fixes
   ═══════════════════════════════════════════════════════════════════════════ */



/* Notas internas con scroll */
.c360-notes-list,
.c360-list {
  max-height: 200px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.c360-notes-list::-webkit-scrollbar,
.c360-list::-webkit-scrollbar {
  width: 4px;
}

.c360-notes-list::-webkit-scrollbar-thumb,
.c360-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* Chat header — limpiar el desorden del badge */
.chat-header .contact-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  overflow: hidden;
}

.chat-header .contact-name {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header .contact-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
}

.ela-badge {
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Timer countdown más discreto */
.ela-timer {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.65rem;
  color: var(--text-muted);
  opacity: 0.7;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Chat Header — Clean professional layout
   ═══════════════════════════════════════════════════════════════════════════ */

/* Role badge — tiny, inline with metadata */
.user-role-badge {
  font-size: 0.6rem;
  padding: 0px 5px;
  border-radius: 6px;
  background: rgba(100,116,139,0.15);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  vertical-align: middle;
  display: none !important; /* Hide role badge - vendors don't need to see their own role */
}

/* Conversation ID / phone in channel line */
.contact-channel {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ELA badge — compact */
.ela-badge {
  font-size: 0.68rem;
  padding: 2px 7px;
  border-radius: 10px;
  white-space: nowrap;
  flex-shrink: 0;
  font-weight: 600;
}

.ela-active { background: rgba(10,255,157,0.12); color: var(--accent); }
.ela-paused { background: rgba(251,191,36,0.12); color: #fbbf24; }
.ela-escalated { background: rgba(239,68,68,0.12); color: #ef4444; }

/* Timer — subtle monospace */
.ela-timer, .human-countdown {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.62rem;
  color: var(--text-muted);
  opacity: 0.6;
}



/* ── Customer 360: email + name alignment fix ──────────────────────────── */
/* All editable fields: label left, input right — same as non-editable */
.c360-edit-input {
  text-align: right;
  max-width: 60%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Email specifically: allow seeing full email on focus/hover */
.c360-edit-input[data-field="email"] {
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.c360-edit-input[data-field="email"]:focus,
.c360-edit-input[data-field="email"]:hover {
  white-space: normal;
  word-break: break-all;
  overflow: visible;
  position: relative;
  z-index: 2;
  max-width: 100%;
  text-align: right;
  background: var(--bg);
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* ═══════════════════════════════════════════════════════════════════════════
   DESIGN OVERHAUL — Professional Chat UI
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Brand logo ────────────────────────────────────────────────────────── */
.brand-logo {
  height: 24px;
  width: auto;
  object-fit: contain;
  /* Let browser do smooth downscaling from full-res */
  image-rendering: auto;
}

.brand-dot { display: none; } /* Replaced by logo */

/* ── Sidebar depth ─────────────────────────────────────────────────────── */
@media (min-width: 769px) {
  .sidebar {
    border-right: 1px solid var(--border);
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
    z-index: 3;
  }
}

/* ── Inbox tabs: horizontal scroll + active indicator ──────────────────── */
.inbox-tabs {
  display: flex;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.inbox-tabs::-webkit-scrollbar { display: none; }

.tab {
  padding: 10px 14px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── Inbox items: avatar + 3 column layout ─────────────────────────────── */
.inbox-item {
  display: grid !important;
  grid-template-columns: 44px 1fr auto;
  grid-template-rows: auto auto;
  gap: 0 10px;
  padding: 12px 14px !important;
  cursor: pointer;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
  transition: background 0.1s;
  align-items: center;
}
.inbox-item:hover { background: var(--bg-hover); }
.inbox-item.active { background: var(--accent-dim); border-left: 3px solid var(--accent); }
.inbox-item.pending-contact {
  background: rgba(255, 165, 0, 0.06);
  border-left: 3px solid orange;
}
.inbox-item.pending-contact .inbox-preview {
  color: var(--text-secondary);
  font-style: italic;
}
.inbox-item-internal {
  background: rgba(255, 204, 0, 0.04);
  border-left: 3px solid var(--accent);
}
.badge-pending {
  background: rgba(255, 165, 0, 0.15);
  color: orange;
  font-size: 0.62rem;
  padding: 2px 6px;
  border-radius: 6px;
  font-weight: 700;
  margin-left: 6px;
  white-space: nowrap;
}

.channel-badge {
  font-size: 0.6rem;
  padding: 2px 6px;
  border-radius: 6px;
  font-weight: 600;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  vertical-align: middle;
  flex-shrink: 0;
}
.ch-wa { background: rgba(37, 211, 102, 0.12); color: #25D366; }
.ch-ig { background: rgba(225, 48, 108, 0.12); color: #E1306C; }
.ch-ig-c { background: rgba(225, 48, 108, 0.08); color: #E1306C; border: 1px dashed rgba(225,48,108,0.3); }
.ch-fb { background: rgba(24, 119, 242, 0.12); color: #1877F2; }
.ch-fb-c { background: rgba(24, 119, 242, 0.08); color: #1877F2; border: 1px dashed rgba(24,119,242,0.3); }
.ch-x { background: rgba(255, 255, 255, 0.08); color: var(--text); border: 1px solid rgba(255,255,255,0.15); }
.ch-email { background: rgba(234, 67, 53, 0.12); color: #EA4335; }
.ch-web { background: rgba(255, 204, 0, 0.12); color: var(--accent); }
.ch-default { background: rgba(148, 163, 184, 0.12); color: #94a3b8; }

.composer-hint {
  font-size: 0.75rem;
  padding: 6px 10px;
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.08);
  border-left: 3px solid #f59e0b;
  margin: 0 12px 6px;
  border-radius: 4px;
}

/* Avatar circle */
.inbox-avatar {
  grid-row: 1 / 3;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: #fff;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.inbox-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.inbox-contact-name {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.inbox-time {
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.inbox-preview-row {
  grid-column: 2 / 4;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.inbox-preview {
  font-size: 0.78rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
  line-height: 1.3;
}

.inbox-unread-badge {
  background: var(--accent);
  color: #000;
  font-size: 0.65rem;
  font-weight: 800;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  flex-shrink: 0;
}

.inbox-ela-icon {
  font-size: 0.72rem;
  flex-shrink: 0;
}

/* ── Message bubbles: tails + polish ───────────────────────────────────── */
.message {
  display: flex;
  flex-direction: column;
  margin-bottom: 2px;
  padding: 0 14px;
  max-width: 85%;
}

.message.inbound { align-self: flex-start; }
.message.outbound { align-self: flex-end; }

.message-bubble {
  position: relative;
  padding: 8px 12px;
  border-radius: 12px;
  line-height: 1.45;
  font-size: 0.9rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Bubble tails */
.message.inbound .message-bubble::before {
  content: '';
  position: absolute;
  left: -6px;
  bottom: 8px;
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 6px solid var(--inbound);
}

.message.outbound .message-bubble::after {
  content: '';
  position: absolute;
  right: -6px;
  bottom: 8px;
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 6px solid var(--outbound);
}

/* ELA bubble tail matches its gradient */
.message.outbound.ela .message-bubble::after {
  border-left-color: #dbeafe;
}

/* ELA sender label */
.message-sender.ela {
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}

/* Robot emoji is already in the sender text, no ::before needed */

/* Client sender */
.message-sender.client {
  color: #60a5fa;
  font-weight: 600;
}

/* Operator sender */
.message-sender.operator {
  color: #c084fc;
  font-weight: 600;
}

/* Date separator — clean pill */
.message-date-separator {
  text-align: center;
  padding: 14px 0 10px;
  display: flex;
  justify-content: center;
}

.message-date-separator span {
  background: rgba(30, 34, 43, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 5px 16px;
  border-radius: 20px;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.15px;
  border: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

/* ── Header actions: overflow menu ─────────────────────────────────────── */
.overflow-menu-wrap {
  position: relative;
}

.overflow-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  /* FIX: sin esto, el sombreado cuadrado de .overflow-item al pasar el
     mouse sobresalia de las esquinas redondeadas del contenedor en el
     primer/ultimo item -- se veia "cortado". */
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
  z-index: 50;
  min-width: 240px;
  padding: 4px 0;
  animation: menuFadeIn 0.12s ease;
}

@keyframes menuFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.overflow-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  color: var(--text);
  font-size: 0.82rem;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background 0.1s;
  height: auto !important;
  justify-content: flex-start !important;
  /* FIX: "Cerrar conversación" y otros labels largos se partian en 2 lineas
     dentro de un menu de 180px. Con white-space:nowrap + min-width:240px
     (arriba) el texto siempre queda en una sola linea. */
  white-space: nowrap;
}
.overflow-item:hover { background: var(--accent-dim) !important; }
.overflow-item span { font-size: 0.9rem; width: 20px; text-align: center; flex-shrink: 0; }
.overflow-item i {
  font-size: 16px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  color: var(--text-muted);
}
/* FIX: notif-toggle antes sobrescribia textContent completo con un emoji,
   borrando el label. Ahora el icono y el texto son elementos separados
   (#notif-icon, #notif-label) para poder actualizar solo el icono. */
#notif-label { flex: 1; }

.overflow-item.danger { color: var(--danger); }
.overflow-item.danger i { color: var(--danger); }
.overflow-item.danger:hover { background: rgba(255,92,92,0.1) !important; }

.overflow-item.muted { color: var(--text-muted); }

.overflow-section-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 14px 4px;
  margin: 0;
  font-weight: 600;
}

.overflow-sheet-handle {
  display: none;
}

.overflow-menu-backdrop {
  display: none;
}

.overflow-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 4px 0;
}

.header-action-btn {
  background: transparent !important;
  border: none !important;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: background 0.1s;
}
.header-action-btn:hover { background: var(--bg-hover) !important; }

.header-action-link {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--accent-dim);
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.1s;
  border: 1px solid rgba(10,255,157,0.2);
}
.header-action-link:hover {
  background: rgba(10,255,157,0.15);
}

/* ── Composer polish ───────────────────────────────────────────────────── */
.composer {
  background: var(--bg-soft);
  border-top: 1px solid var(--border);
}

#message-input {
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  background: var(--bg);
  transition: border-color 0.15s;
  line-height: 1.4;
}
#message-input:focus {
  border-color: var(--accent);
  outline: none;
}

.send-btn {
  border-radius: 50% !important;
  width: 40px !important;
  height: 40px !important;
  padding: 0 !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  background: var(--accent) !important;
  color: #000 !important;
  border: none !important;
  transition: transform 0.1s, opacity 0.15s;
}
.send-btn:disabled { opacity: 0.3; }
.send-btn:not(:disabled):active { transform: scale(0.9); }

/* ── Empty state ───────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 16px;
  opacity: 0.5;
}
.empty-state p {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ── Customer 360 subtle shadow ────────────────────────────────────────── */
@media (min-width: 769px) {
  .customer360 {
    box-shadow: -4px 0 20px rgba(0,0,0,0.1);
  }
}

/* ── Chat header clean ─────────────────────────────────────────────────── */
.chat-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  z-index: 5;
  padding: 4px 12px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE POLISH — Professional mobile chat experience
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {

  /* ── Sidebar header: logo + compact ──────────────────────────────────── */
  .sidebar-header {
    height: 50px;
    min-height: 50px;
    padding: 0 12px;
  }

  .brand-logo {
    height: 20px;
  }

  /* ── Search bar tighter ──────────────────────────────────────────────── */
  .toolbar {
    padding: 6px 10px;
    gap: 6px;
  }

  .search-box input {
    padding: 7px 10px;
    font-size: 0.85rem;
    border-radius: 20px;
  }

  /* ── Tabs: smaller, scrollable ───────────────────────────────────────── */
  .inbox-tabs {
    padding: 0 8px;
    gap: 0;
  }

  .tab {
    padding: 8px 10px;
    font-size: 0.7rem;
  }

  /* ── Inbox items: compact but clear ──────────────────────────────────── */
  .inbox-item {
    grid-template-columns: 40px 1fr auto !important;
    padding: 10px 12px !important;
    gap: 0 8px !important;
  }

  .inbox-avatar {
    width: 40px !important;
    height: 40px !important;
    font-size: 0.78rem !important;
  }

  .inbox-contact-name {
    font-size: 0.84rem;
  }

  .inbox-time {
    font-size: 0.64rem;
  }

  .inbox-preview {
    font-size: 0.75rem;
  }

  /* ── FAB position ────────────────────────────────────────────────────── */
  .new-conv-fab {
    bottom: calc(20px + var(--safe-bottom, 0px));
    right: 14px;
    width: 50px;
    height: 50px;
  }

  /* ── Chat header: compact + safe for iframe ──────────────────────────── */
  .chat-header {
    height: auto;
    min-height: 46px;
    padding: 6px 8px;
    gap: 4px;
  }

  .back-btn {
    width: 32px;
    height: 32px;
    font-size: 1.1rem;
    background: transparent !important;
    border: none !important;
  }

  .contact-name {
    font-size: 0.88rem;
  }

  .contact-meta {
    font-size: 0.68rem;
    gap: 4px;
  }

  .header-actions {
    gap: 0;
  }

  .header-action-link {
    font-size: 0.68rem;
    padding: 3px 7px;
  }

  .header-action-btn {
    width: 32px;
    height: 32px;
    font-size: 0.95rem;
  }

  /* ── Timeline: tighter bubbles ───────────────────────────────────────── */
  .timeline {
    padding: 12px 4px;
  }

  .message {
    max-width: 88%;
    padding: 0 8px;
    margin-bottom: 1px;
  }

  .message-bubble {
    padding: 7px 10px;
    font-size: 0.88rem;
    border-radius: 10px;
  }

  .message.inbound .message-bubble { border-bottom-left-radius: 3px; }
  .message.outbound .message-bubble { border-bottom-right-radius: 3px; }

  .message-sender {
    font-size: 0.68rem;
    margin-bottom: 1px;
  }

  .message-meta {
    font-size: 0.6rem;
    margin-top: 3px;
  }

  .message-date-separator {
    padding: 12px 0 6px;
  }

  .message-date-separator span {
    font-size: 0.68rem;
    padding: 3px 12px;
  }

  /* ── Bubble tails on mobile ──────────────────────────────────────────── */
  .message.inbound .message-bubble::before {
    left: -5px;
    bottom: 6px;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-right: 5px solid var(--inbound);
  }

  .message.outbound .message-bubble::after {
    right: -5px;
    bottom: 6px;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-left: 5px solid var(--outbound);
  }

  .message.outbound.ela .message-bubble::after {
    border-left-color: #dbeafe;
  }

  /* ── Composer mobile refinements ─────────────────────────────────────── */
  .composer {
    padding: 5px 6px calc(5px + var(--safe-bottom));
  }

  #message-input {
    padding: 8px 14px;
    font-size: 0.9rem;
    min-height: 36px;
    border-radius: 20px;
  }

  .composer-plus {
    width: 36px !important;
    height: 36px !important;
  }

  .composer-mic {
    width: 36px !important;
    height: 36px !important;
  }

  .send-btn {
    width: 36px !important;
    height: 36px !important;
  }

  /* ── Customer 360: Full-screen bottom sheet ──────────────────────────── */
  .customer360-sheet {
    max-height: 92vh;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    box-shadow: 0 -8px 40px rgba(0,0,0,0.5);
  }

  .customer360-header {
    padding: 6px 14px 10px;
    position: sticky;
    top: 0;
    background: var(--bg-soft);
    z-index: 5;
  }

  .customer360-header h3 {
    font-size: 0.88rem;
  }

  .customer360-handle {
    width: 36px;
    height: 4px;
    margin: 8px auto 4px;
  }

  .customer360-content {
    padding: 8px 12px 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    min-height: 0;
  }

  /* C360 sections more compact on mobile */
  .c360-section {
    padding: 8px 10px;
    margin-bottom: 8px;
    border-radius: 10px;
  }

  .c360-section h4 {
    font-size: 0.65rem;
    margin-bottom: 6px;
  }

  .c360-field {
    min-height: 26px;
    padding: 2px 0;
  }

  .c360-label {
    font-size: 0.72rem;
  }

  .c360-value,
  .c360-edit-input {
    font-size: 0.78rem;
  }

  /* Ad preview card on mobile */
  .c360-ad-preview {
    border-radius: 8px;
  }

  .c360-ad-media img,
  .c360-ad-media video {
    max-height: 150px;
  }

  .c360-ad-title {
    font-size: 0.78rem;
    padding: 6px 8px 2px;
  }

  .c360-ad-body {
    font-size: 0.72rem;
    padding: 2px 8px 6px;
  }

  /* Action buttons compact */
  .c360-action-row {
    gap: 4px;
  }

  .c360-action-row .c360-select {
    font-size: 0.72rem;
    padding: 4px 5px;
  }

  .c360-action-row .c360-action-btn.small {
    font-size: 0.68rem;
    padding: 4px 6px;
    margin-top: 0;
  }

  /* Notes list */
  .c360-notes-list,
  .c360-list {
    max-height: 160px;
  }

  /* Save contact button */
  #save-contact-btn {
    font-size: 0.78rem;
    padding: 8px 12px;
    border-radius: 8px;
    width: 100%;
    margin-top: 6px;
  }

  /* ── Overflow menu on mobile: bottom sheet ───────────────────────────────
     Un dropdown angosto pegado a la esquina es un patron de mouse (cursor
     preciso). En movil el dedo necesita objetivos de ~44px+ de alto -- se
     reutiliza el mismo lenguaje visual que .guide-modal (ya existente en
     este proyecto) para consistencia: sube desde abajo, se cierra tocando
     el fondo o deslizando hacia abajo. */
  .overflow-menu-backdrop.visible {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
  }

  .overflow-menu {
    position: fixed;
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    min-width: 0;
    width: 100%;
    border-radius: 18px 18px 0 0;
    border: none;
    border-top: 1px solid var(--border);
    padding: 8px 0 calc(10px + var(--safe-bottom));
    max-height: 75vh;
    overflow-y: auto;
    z-index: 100;
    transform: translateY(100%);
    transition: transform 0.25s ease;
    animation: none;
  }
  .overflow-menu:not(.hidden) {
    transform: translateY(0);
  }

  .overflow-sheet-handle {
    display: block;
    width: 32px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 2px auto 8px;
  }

  .overflow-item {
    padding: 13px 18px;
    font-size: 0.88rem;
    min-height: 44px;
  }
  .overflow-item i { font-size: 18px; width: 22px; }

  .overflow-section-label {
    padding: 12px 18px 4px;
  }

  /* ── Expand grid: tighter on small screens ───────────────────────────── */
  .composer-expand {
    padding: 10px 6px;
    gap: 2px;
  }

  .expand-item {
    padding: 10px 6px;
    font-size: 0.68rem;
  }

  .expand-icon {
    width: 42px;
    height: 42px;
    font-size: 1.2rem;
  }

  /* ── Voice recorder compact ──────────────────────────────────────────── */
  .voice-recorder {
    padding: 6px 10px;
  }

  .voice-timer {
    font-size: 0.78rem;
  }

  .voice-btn {
    width: 30px;
    height: 30px;
    font-size: 0.85rem;
  }

  /* ── Modals: full width on mobile ────────────────────────────────────── */
  .new-conv-sheet,
  .guide-sheet,
  .ad-preview-sheet {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 90vh;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 40px rgba(0,0,0,0.5);
  }

  .new-conv-header h3,
  .guide-header h3,
  .ad-preview-header h3 {
    font-size: 0.9rem;
  }

  /* ── Slash autocomplete on mobile ────────────────────────────────────── */
  .slash-autocomplete {
    max-height: 200px;
    border-radius: 10px 10px 0 0;
  }

  .slash-item {
    padding: 8px 12px;
  }

  .slash-shortcut {
    font-size: 0.78rem;
  }

  .slash-name {
    font-size: 0.78rem;
  }

  .slash-preview {
    font-size: 0.7rem;
  }

  /* ── Empty state on mobile ───────────────────────────────────────────── */
  .empty-state {
    padding: 20px;
  }

  .empty-state p {
    font-size: 0.85rem;
  }

  /* ── Toast compact ───────────────────────────────────────────────────── */
  .toast {
    font-size: 0.8rem;
    bottom: calc(70px + var(--safe-bottom, 0px));
    left: 12px;
    right: 12px;
    max-width: none;
  }

  /* ── Score badges compact ────────────────────────────────────────────── */
  .score-badge {
    font-size: 0.6rem;
    padding: 0px 5px;
  }

  /* ── ELA badge compact ───────────────────────────────────────────────── */
  .ela-badge {
    font-size: 0.62rem;
    padding: 1px 5px;
  }
}

/* ── Extra small (iPhone SE, etc.) ─────────────────────────────────────── */
@media (max-width: 374px) {
  .inbox-item {
    grid-template-columns: 36px 1fr auto !important;
    padding: 8px 10px !important;
  }

  .inbox-avatar {
    width: 36px !important;
    height: 36px !important;
    font-size: 0.72rem !important;
  }

  .inbox-contact-name {
    font-size: 0.8rem;
  }

  .message {
    max-width: 90%;
  }

  .message-bubble {
    font-size: 0.85rem;
    padding: 6px 9px;
  }

  .tab {
    padding: 7px 8px;
    font-size: 0.65rem;
  }

  .customer360-sheet {
    max-height: 95vh;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   System Status Indicator — green = OK, red = ELA down
   ═══════════════════════════════════════════════════════════════════════════ */
.system-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.3s, box-shadow 0.3s;
}

.system-status-dot.status-ok {
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.6);
}

.system-status-dot.status-degraded {
  background: #f59e0b;
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.6);
  animation: pulse-warn 2s ease infinite;
}

.system-status-dot.status-down {
  background: #ef4444;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.7);
  animation: pulse-danger 1.5s ease infinite;
}

.silence-incidents-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  margin-left: 6px;
  cursor: help;
  white-space: nowrap;
  animation: pulse-danger 2s ease infinite;
}

.silence-incidents-badge.hidden {
  display: none;
}

@keyframes pulse-danger {
  0%, 100% { box-shadow: 0 0 4px rgba(239, 68, 68, 0.5); }
  50% { box-shadow: 0 0 12px rgba(239, 68, 68, 0.9); }
}

@keyframes pulse-warn {
  0%, 100% { box-shadow: 0 0 4px rgba(245, 158, 11, 0.4); }
  50% { box-shadow: 0 0 10px rgba(245, 158, 11, 0.7); }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Mobile header + Lead button fix
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Header wraps content instead of fixed height */
  .chat-header {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    min-height: 44px;
    padding: 4px 6px;
    gap: 4px;
  }

  /* Contact info takes available space */
  .contact-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
  }

  .contact-name {
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .contact-meta {
    font-size: 0.65rem;
    gap: 3px;
    overflow: hidden;
  }

  /* Lead button: compact, never cut */
  .header-action-link {
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
    flex-shrink: 0;
  }

  /* Back button tight */
  .back-btn {
    width: 28px;
    height: 28px;
    font-size: 1rem;
    flex-shrink: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent !important;
    border: none !important;
  }

  /* Overflow button tight */
  .header-action-btn {
    width: 28px;
    height: 28px;
    font-size: 0.9rem;
    flex-shrink: 0;
  }

  /* Actions container */
  .header-actions {
    flex-shrink: 0;
    gap: 0;
  }
}

/* ── Copilot suggestion panel ─────────────────────────────────────────────── */

.copilot-panel {
  background: linear-gradient(135deg, rgba(10, 255, 157, 0.05) 0%, rgba(10, 255, 157, 0.02) 100%);
  border-top: 1px solid rgba(10, 255, 157, 0.2);
  padding: 8px 14px;
  animation: copilotSlideIn 0.2s ease;
}

@keyframes copilotSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.copilot-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.copilot-icon { font-size: 0.9rem; }

.copilot-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
  flex: 1;
}

.copilot-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 2px 4px;
  border-radius: 4px;
}

.copilot-btn:hover { color: var(--text); background: var(--bg-hover); }

.copilot-text {
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.45;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-bottom: 6px;
  white-space: pre-wrap;
}

.copilot-actions {
  display: flex;
  justify-content: flex-end;
}

.copilot-use-btn {
  background: var(--accent);
  color: #000;
  border: none;
  padding: 5px 14px;
  border-radius: 16px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.1s;
}

.copilot-use-btn:active { transform: scale(0.95); }

.copilot-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.copilot-loading::before {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid var(--accent);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* Mobile */
@media (max-width: 768px) {
  .copilot-panel { padding: 6px 10px; }
  .copilot-text { font-size: 0.82rem; padding: 6px 8px; }
}

/* ── Dashboard Ejecutivo ──────────────────────────────────────────────────── */

.dashboard-panel {
  position: absolute;
  inset: 0;
  background: var(--bg);
  z-index: 60;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.dashboard-header h2 { font-size: 1rem; margin: 0; }

.dashboard-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

.dashboard-close-btn:hover { color: var(--text); background: var(--bg-hover); }

.dashboard-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dashboard-loading,
.dashboard-error {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.dash-card {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}

.dash-card h4 {
  margin: 0 0 10px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
}

.dash-channels { display: flex; flex-direction: column; gap: 6px; }
.dash-channel-row { display: flex; justify-content: space-between; font-size: 0.78rem; padding: 4px 0; }
.dash-channel-detail { color: var(--text-muted); font-size: 0.72rem; }

/* Company Score circle */
.dash-score {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
}

.dash-score-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.dash-score-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}

.dash-score-label {
  font-size: 0.6rem;
  color: var(--text-muted);
}

.dash-health {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 8px;
  font-weight: 600;
  text-transform: uppercase;
}

.dash-health-healthy { background: rgba(34,197,94,0.15); color: #22c55e; }
.dash-health-moderate { background: rgba(245,158,11,0.15); color: #f59e0b; }
.dash-health-critical { background: rgba(239,68,68,0.15); color: #ef4444; }

/* KPI cards */
.dash-kpis {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.dash-kpi {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
}

.dash-kpi-value {
  display: block;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text);
}

.dash-kpi-label {
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* ELA stats */
.dash-ela-stats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.dash-ela-stat {
  font-size: 0.82rem;
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--bg);
}

/* Next Best Action */
.dash-nba {
  border-color: var(--accent);
  border-left: 3px solid var(--accent);
}

.dash-nba p {
  font-size: 0.88rem;
  margin: 0 0 4px;
  color: var(--text);
}

.dash-nba small {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Engines grid */
.dash-engines {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.dash-engine {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  padding: 4px 6px;
  border-radius: 6px;
  background: var(--bg);
}

.dash-engine-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dash-engine-name {
  flex: 1;
  font-weight: 600;
  font-size: 0.68rem;
}

.dash-engine-score {
  font-weight: 700;
  color: var(--text-muted);
  font-size: 0.68rem;
}

/* Funnel */
.dash-funnel-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.dash-funnel-label {
  font-size: 0.72rem;
  width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 0;
}

.dash-funnel-bar-wrap {
  flex: 1;
  height: 14px;
  background: var(--bg);
  border-radius: 7px;
  overflow: hidden;
}

.dash-funnel-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 7px;
  min-width: 2px;
  transition: width 0.5s ease;
}

.dash-funnel-count {
  font-size: 0.72rem;
  font-weight: 700;
  min-width: 30px;
  text-align: right;
}

/* Scores detail */
.dash-scores-detail {
  display: flex;
  justify-content: space-around;
}

.dash-score-item {
  text-align: center;
}

.dash-score-item span {
  display: block;
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.dash-score-item strong {
  font-size: 1.1rem;
  color: var(--accent);
}


/* ═══ Rediseño Dashboard Ejecutivo (12 de julio) — jerarquia real,
   agrupacion por categoria, multi-columna ═══ */
.hero { display:grid; grid-template-columns:1.1fr 1fr 1.3fr; gap:12px; }
@media (max-width:900px) { .hero { grid-template-columns:1fr; } }
.hero-card {
  background:var(--bg-soft); border:1px solid var(--border); border-radius:14px; padding:18px;
  display:flex; align-items:center; gap:14px;
}
.gauge { position:relative; width:88px; height:88px; flex-shrink:0; }
.gauge-val { position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; }
.gauge-val b { font-size:1.4rem; line-height:1; color:var(--accent); }
.gauge-val span { font-size:0.58rem; color:var(--text-muted); }
.hero-meta h3 { margin:0 0 4px; font-size:0.85rem; }
.hero-health { display:inline-flex; align-items:center; gap:5px; font-size:0.68rem; padding:2px 9px; border-radius:8px; font-weight:600; }
.hero-health-healthy { background:rgba(34,197,94,0.15); color:#22c55e; }
.hero-health-moderate { background:rgba(245,158,11,0.15); color:#f59e0b; }
.hero-health-critical { background:rgba(239,68,68,0.15); color:#ef4444; }
.forecast-card { flex-direction:column; align-items:flex-start; gap:4px; }
.forecast-card .label { font-size:0.7rem; color:var(--text-muted); text-transform:uppercase; letter-spacing:0.4px; display:flex; align-items:center; gap:5px; }
.forecast-card .value { font-size:1.7rem; font-weight:800; color:#f59e0b; }
.forecast-card .sub { font-size:0.7rem; color:var(--text-muted); }
.nba-card { background:linear-gradient(135deg, var(--accent-dim), var(--bg-soft)); border-color:var(--accent); flex-direction:column; align-items:flex-start; }
.nba-card .label { font-size:0.66rem; color:var(--accent); text-transform:uppercase; letter-spacing:0.5px; font-weight:700; display:flex; align-items:center; gap:5px; }
.nba-card p { font-size:0.85rem; margin:8px 0 4px; line-height:1.4; }
.nba-card small { font-size:0.68rem; color:var(--text-muted); }

.section { margin:20px 0; }
.section-head { display:flex; align-items:center; gap:8px; margin-bottom:10px; }
.section-head i { color:var(--accent); font-size:15px; }
.section-head h2 { font-size:0.8rem; text-transform:uppercase; letter-spacing:0.5px; margin:0; color:var(--text-muted); font-weight:700; }
.section-head .count { font-size:0.62rem; color:var(--text-muted); background:var(--bg-soft); border:1px solid var(--border); padding:1px 7px; border-radius:8px; }
.section.dim { opacity:0.6; }

.kgrid { display:grid; gap:8px; }
.kgrid.c4 { grid-template-columns:repeat(4,1fr); }
.kgrid.c3 { grid-template-columns:repeat(3,1fr); }
@media (max-width:900px) { .kgrid.c4,.kgrid.c3 { grid-template-columns:repeat(2,1fr); } }
.kcard { background:var(--bg-soft); border:1px solid var(--border); border-radius:10px; padding:11px 13px; }
.kcard .kval { font-size:1.2rem; font-weight:800; color:var(--text); }
.kcard .klabel { font-size:0.66rem; color:var(--text-muted); margin-top:2px; }
.ktrend { font-size:0.62rem; margin-left:5px; }
.ktrend.up { color:var(--accent); }
.ktrend.down { color:#ef4444; }

.wide-card { background:var(--bg-soft); border:1px solid var(--border); border-radius:10px; padding:13px 15px; }
.wide-card h4 { margin:0 0 10px; font-size:0.74rem; text-transform:uppercase; letter-spacing:0.4px; color:var(--text-muted); font-weight:700; }

.funnel-row { display:flex; align-items:center; gap:8px; margin-bottom:6px; }
.funnel-label { font-size:0.72rem; width:150px; flex-shrink:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.funnel-track { flex:1; height:18px; background:var(--bg); border-radius:6px; overflow:hidden; }
.funnel-fill { height:100%; background:linear-gradient(90deg, var(--accent), #06d97a); border-radius:6px; display:flex; align-items:center; padding:0 7px; min-width:20px; }
.funnel-fill span { font-size:0.64rem; font-weight:700; color:#06231a; }
.funnel-conv { font-size:0.6rem; width:34px; text-align:right; flex-shrink:0; }

.split { display:grid; grid-template-columns:1.4fr 1fr; gap:10px; }
@media (max-width:900px) { .split { grid-template-columns:1fr; } }
.pred-bars { display:flex; gap:8px; height:100px; align-items:flex-end; margin-top:4px; }
.pred-bar-wrap { flex:1; display:flex; flex-direction:column; align-items:center; gap:5px; }
.pred-bar { width:100%; border-radius:6px 6px 0 0; }
.pred-bar-label { font-size:0.6rem; color:var(--text-muted); text-align:center; }
.pred-bar-val { font-size:0.8rem; font-weight:800; }

.sys-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:7px; }
@media (max-width:900px) { .sys-grid { grid-template-columns:repeat(2,1fr); } }
.sys-row { display:flex; align-items:center; gap:8px; background:var(--bg); border-radius:8px; padding:7px 9px; }
.sys-dot { width:6px; height:6px; border-radius:50%; flex-shrink:0; }
.sys-name { flex:1; font-size:0.68rem; font-weight:600; }
.sys-score { font-size:0.68rem; color:var(--text-muted); font-weight:700; }

.dashboard-toggle {
  background: transparent !important;
  border: none !important;
  font-size: 1rem;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
}

.dashboard-toggle:hover { background: var(--accent-dim) !important; }

/* Mobile */
@media (max-width: 768px) {
  .dash-engines { grid-template-columns: repeat(2, 1fr); }
  .dash-kpis { grid-template-columns: repeat(2, 1fr); }
  .dash-funnel-label { width: 100px; font-size: 0.68rem; }
  .dash-score-circle { width: 64px; height: 64px; }
  .dash-score-value { font-size: 1.3rem; }
}

/* ── Ronda 10: filtro por vendedor ───────────────────────────────────────── */
.inbox-filters-bar {
  display: flex;
  gap: 4px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.inbox-filters-bar select {
  flex: 1;
  min-width: 0;
  max-width: 25%;
  font-size: 0.7rem;
  padding: 4px 6px;
  text-overflow: ellipsis;
}

.filter-vendor-select {
  flex: 1.2;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 24px;
}

.filter-vendor-select:focus {
  border-color: var(--accent);
  outline: none;
}

.filter-channel-select {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.78rem;
  padding: 6px 8px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
}

/* ── Ronda 10: SLA breach indicator ──────────────────────────────────────── */
.sla-alert {
  animation: pulse-danger 1.5s ease infinite;
  font-size: 0.8rem;
  margin-left: 4px;
}

@keyframes pulse-danger {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.15); }
}

/* ── Ronda 11: Analítica avanzada ────────────────────────────────────────── */

/* Tabla de conversión */
.dash-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.72rem;
}
.dash-table th,
.dash-table td {
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.dash-table th {
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.6rem;
  letter-spacing: 0.03em;
}
.dash-conv-cell.good { color: #10b981; font-weight: 700; }
.dash-conv-cell.bad { color: #ef4444; font-weight: 700; }

/* Funnel mejorado */
.dash-funnel-delta {
  font-size: 0.6rem;
  margin-left: 6px;
  font-weight: 600;
}
.dash-funnel-delta.up { color: #10b981; }
.dash-funnel-delta.down { color: #ef4444; }
.dash-funnel-conversion {
  font-size: 0.6rem;
  color: var(--text-muted);
  margin-left: 6px;
}

/* Leaderboard vendedores */
.dash-vendors {
  display: grid;
  gap: 10px;
}
.dash-vendor-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  background: var(--bg-hover);
}
.dash-vendor-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}
.dash-vendor-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.72rem;
  color: var(--text-muted);
}
.dash-vendor-info strong { color: var(--text); font-size: 0.8rem; }

/* Heatmap */
.heatmap-grid {
  display: grid;
  grid-template-columns: 36px repeat(17, 1fr);
  gap: 2px;
  font-size: 0.6rem;
}
.heatmap-cell {
  aspect-ratio: 1;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.55rem;
  min-height: 18px;
}
.heatmap-day,
.heatmap-hour,
.heatmap-label {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--text-muted);
}

/* Predicciones */
.dash-predictions {
  display: grid;
  gap: 8px;
}
.dash-prediction {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg-hover);
  font-size: 0.72rem;
}
.pred-type {
  color: var(--text-muted);
  min-width: 90px;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.pred-value {
  flex: 1;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pred-conf {
  font-weight: 700;
  font-size: 0.7rem;
}
.pred-conf.high { color: #10b981; }
.pred-conf.medium { color: #f59e0b; }
.pred-conf.low { color: #ef4444; }

.c360-prediction {
  text-align: center;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.c360-prediction .pred-prob {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
}
.c360-prediction .pred-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.c360-prediction .pred-rec {
  font-size: 0.85rem;
  color: var(--text-primary);
}

.dash-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}
.dash-list-item {
  font-size: 0.8rem;
  color: var(--text-primary);
  background: rgba(255,255,255,0.03);
  border-radius: 8px;
  padding: 6px 8px;
}
.dash-list-item small {
  color: var(--text-secondary);
}

@media (max-width: 768px) {
  .dash-table { font-size: 0.65rem; }
  .dash-table th, .dash-table td { padding: 4px; }
  .heatmap-grid { grid-template-columns: 28px repeat(17, 1fr); }
}


/* ── Campañas multicanal ───────────────────────────────────────────── */
.campaign-actions { margin-bottom: 12px; }
.campaigns-list { display: flex; flex-direction: column; gap: 12px; }
.campaign-empty { color: var(--text-secondary); text-align: center; padding: 24px; }
.campaign-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.campaign-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.campaign-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.campaign-name { font-weight: 600; color: var(--text); word-break: break-word; }
.campaign-status {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px;
  padding: 3px 8px; border-radius: 999px; background: var(--bg-hover); color: var(--text-secondary);
  white-space: nowrap;
}
.campaign-status.status-sending { background: rgba(59,130,246,0.18); color: #60a5fa; }
.campaign-status.status-completed { background: rgba(10,255,157,0.12); color: var(--accent); }
.campaign-status.status-paused { background: rgba(245,158,11,0.15); color: #fbbf24; }
.campaign-status.status-draft { background: rgba(148,163,184,0.15); color: #cbd5e1; }
.campaign-meta { font-size: 12px; color: var(--text-secondary); }
.campaign-stats { display: flex; gap: 10px; font-size: 13px; color: var(--text-secondary); flex-wrap: wrap; }
.campaign-actions-row { display: flex; gap: 8px; margin-top: 4px; }

.modal-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%; max-width: 480px;
  max-height: 90vh; overflow-y: auto;
  display: flex; flex-direction: column;
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 17px; }
.modal-close { background: transparent; border: none; color: var(--text-secondary); font-size: 18px; cursor: pointer; }
.modal-body { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.modal-body label { font-size: 12px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.4px; }
.modal-body input, .modal-body select, .modal-body textarea {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; color: var(--text); font-size: 14px;
}
.modal-body textarea { resize: vertical; }
.camp-hint { font-size: 12px; color: var(--text-secondary); margin: 0; }
.camp-preview-count { font-weight: 600; color: var(--accent); margin: 0; }
.modal-footer {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 14px 18px; border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.btn-primary { background: var(--accent); color: #0b0d10; border: none; border-radius: 8px; padding: 9px 14px; font-weight: 600; cursor: pointer; }
.btn-secondary { background: var(--bg-hover); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 9px 14px; cursor: pointer; }
.btn-sm { font-size: 12px; padding: 6px 10px; border-radius: 6px; border: none; cursor: pointer; }
.btn-send { background: var(--accent); color: #0b0d10; font-weight: 600; }
.btn-pause { background: var(--bg-hover); color: var(--text); border: 1px solid var(--border); }

/* ── Automatizaciones ───────────────────────────────────────────────── */
.automations-list { display: flex; flex-direction: column; gap: 12px; }
.automation-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.automation-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.automation-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.automation-name { font-weight: 600; color: var(--text); }
.automation-toggle { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); cursor: pointer; }
.automation-toggle input { cursor: pointer; }
.automation-meta { font-size: 12px; color: var(--text-secondary); }
.automation-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  background: var(--bg);
  padding: 8px;
  border-radius: 6px;
  color: var(--text-secondary);
  word-break: break-word;
  white-space: pre-wrap;
}

/* ── Workflows multi-paso ─────────────────────────────────────────────── */
.workflows-list { display: flex; flex-direction: column; gap: 14px; }
.workflow-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.workflow-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.workflow-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.workflow-name { font-weight: 600; color: var(--text); }
.workflow-meta { font-size: 12px; color: var(--text-secondary); display: flex; gap: 12px; flex-wrap: wrap; }
.wf-flowchart {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  background: var(--bg);
  padding: 10px;
  border-radius: 8px;
}
.wf-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  color: var(--text-secondary);
  min-width: 50px;
}
.wf-step-icon { font-size: 16px; }
.wf-step-name { text-transform: capitalize; font-weight: 500; color: var(--text); }
.wf-step-detail { max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; }
.wf-arrow { color: var(--text-secondary); font-size: 12px; }
.wf-empty-steps { font-size: 12px; color: var(--text-secondary); margin: 0; }

/* A/B Tests dashboard */
.dash-experiments {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.exp-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  background: var(--bg);
  border-radius: 8px;
}
.exp-name {
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text);
}
.exp-status {
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 600;
}
.exp-variants {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.exp-variant {
  font-size: 0.72rem;
  background: var(--bg-soft);
  padding: 2px 6px;
  border-radius: 6px;
  color: var(--text-secondary);
}

/* Commercial Context admin panel */
.commercial-context-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.cc-card {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.cc-category {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
  font-weight: 700;
}
.cc-toggle {
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}
.cc-title, .cc-content {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
}
.cc-content {
  resize: vertical;
}
.cc-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* Customer 360 linked channels */
.c360-channels {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.channel-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 12px;
  color: var(--text-secondary);
}
.c360-linked-ids {
  display: block;
  color: var(--text-muted);
  font-size: 0.7rem;
  margin-bottom: 8px;
  word-break: break-all;
}
.c360-action-btn.small {
  padding: 4px 10px;
  font-size: 0.72rem;
}

/* Customer 360 memory */
.mem-category {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
  font-weight: 700;
  margin-top: 8px;
  margin-bottom: 4px;
}
.mem-category:first-child {
  margin-top: 0;
}

/* Provincial analytics dashboard */
.dash-province-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  font-size: 0.78rem;
  border-bottom: 1px solid var(--border);
}
.dash-province-row:last-child {
  border-bottom: none;
}
.prov-name { flex: 2; font-weight: 600; }
.prov-dist { flex: 1; color: var(--text-muted); font-size: 0.68rem; }
.prov-leads, .prov-closed, .prov-conv { flex: 1; text-align: right; }
.prov-conv { color: var(--accent); font-weight: 700; }
.prov-toggle {
  flex: 0 0 34px;
  text-align: center;
}
.prov-toggle input[type="checkbox"] {
  accent-color: var(--accent);
  cursor: pointer;
}

/* ── Drag & drop overlay ─────────────────────────────────────────────────── */
.drag-drop-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  transition: opacity 0.15s ease;
  opacity: 0;
  pointer-events: none;
}
.drag-drop-overlay:not(.hidden) {
  opacity: 1;
  pointer-events: auto;
}
.drag-drop-box {
  background: var(--bg-soft);
  border: 2px dashed var(--accent);
  border-radius: 16px;
  padding: 40px 32px;
  text-align: center;
  max-width: 320px;
  margin: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  animation: popIn 0.2s ease;
}
.drag-drop-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}
.drag-drop-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
.drag-drop-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
}
@keyframes popIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

/* WebRTC call panel */
.webrtc-call-panel {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  color: #fff;
  border-radius: 20px;
  padding: 18px 28px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  gap: 24px;
  min-width: 280px;
  max-width: 90vw;
}
.webrtc-call-panel.hidden {
  display: none;
}
.webrtc-call-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.webrtc-call-status {
  font-size: 0.9rem;
  font-weight: 600;
  color: #00e3aa;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.webrtc-call-status.ringing {
  animation: pulse 1.2s infinite;
}
.webrtc-call-number {
  font-size: 1.05rem;
  font-weight: 500;
  color: #fff;
}
.webrtc-call-timer {
  font-size: 0.95rem;
  color: rgba(255,255,255,0.75);
  font-variant-numeric: tabular-nums;
}
.webrtc-hangup-btn {
  background: #e63946;
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 10px 18px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.2s, transform 0.1s;
}
.webrtc-hangup-btn:hover {
  background: #d62839;
}
.webrtc-hangup-btn:active {
  transform: scale(0.97);
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ── Geo Intelligence ─────────────────────────────────────────────────── */
.geo-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.geo-toolbar label { color: var(--text-muted); font-size: 0.8rem; letter-spacing: 0.02em; text-transform: uppercase; }

.geo-toolbar select {
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s;
}
.geo-toolbar select:hover, .geo-toolbar select:focus {
  border-color: #e8a13a;
  outline: none;
}

.geo-data-quality {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  padding: 5px 10px;
  border-radius: 999px;
  letter-spacing: 0.01em;
}

.geo-layout {
  display: flex;
  flex: 1;
  gap: 12px;
  min-height: 0;
}

.geo-map-container {
  flex: 1;
  min-height: 420px;
  background: radial-gradient(ellipse at 50% 35%, #171b23 0%, #101319 70%, #0c0e12 100%);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px;
  box-shadow: inset 0 0 60px rgba(0,0,0,0.25);
  position: relative;
}

.geo-side-panel {
  width: 320px;
  flex-shrink: 0;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  overflow-y: auto;
}

.geo-side-panel h3 {
  margin: 0 0 14px;
  font-size: 1.05rem;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.geo-side-panel h4 { margin: 18px 0 8px; font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }

.geo-side-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.geo-metric {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 8px;
  text-align: center;
  transition: border-color 0.15s;
}
.geo-metric:hover { border-color: #e8a13a55; }

.geo-metric-value {
  display: block;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

.geo-metric-label {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.geo-municipality {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
}

.geo-municipality:last-child { border-bottom: none; }

.geo-private-badge {
  display: inline-block;
  background: #ffcf5c22;
  color: #ffcf5c;
  border: 1px solid #ffcf5c44;
  font-size: 0.62rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  margin-left: 6px;
  letter-spacing: 0.02em;
}

.geo-export-btn {
  width: 100%;
  margin: 12px 0 4px;
  padding: 8px 12px;
  border: 1px solid var(--border-color, #d1d5db);
  border-radius: 6px;
  background: var(--bg-secondary, #f8fafc);
  color: var(--text-primary, #1e293b);
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s;
}
.geo-export-btn:hover:not(:disabled) { background: var(--bg-hover, #eef2f7); }
.geo-export-btn:disabled { opacity: 0.6; cursor: default; }

.geo-export-note {
  font-size: 0.72rem;
  color: var(--text-muted, #64748b);
  margin: 4px 0 0;
  line-height: 1.4;
}

@media (max-width: 900px) {
  .geo-layout { flex-direction: column; }
  .geo-side-panel { width: 100%; }
}
