/* ============================================================================
   PILAR 9 — CRM OMNICANAL, MÜRÖNTÖ AUTOFLOW & ACELERADOR DE EMBUDO SOBERANO
   Sistema de Diseño Institucional Müröntö (Claro Antigravity / Oscuro Táctico)
   Contraste WCAG AA >= 4.5:1 · Cero Dependencias Pesadas · Responsive
   ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500;600;700&family=Plus+Jakarta+Sans:wght@600;700;800&display=swap');

:root,
[data-theme="light"] {
  --bg-main: #f8fafc;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --bg-card-alt: #f1f5f9;
  --bg-hover: #eff6ff;
  --bg-input: #ffffff;

  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #475569;

  --muronto-navy: #0a192f;
  --muronto-blue: #0052b6;
  --muronto-blue-dark: #003d8f;
  --muronto-cyan: #009cde;
  --muronto-cyan-soft: rgba(0, 156, 222, 0.12);
  --muronto-blue-soft: rgba(0, 82, 182, 0.1);

  --border-color: #e2e8f0;
  --border-strong: #cbd5e1;
  --border-focus: #0052b6;

  --emerald: #047857;
  --emerald-bg: #ecfdf5;
  --emerald-border: #a7f3d0;

  --amber: #b45309;
  --amber-bg: #fffbeb;
  --amber-border: #fde68a;

  --crimson: #b91c1c;
  --crimson-bg: #fef2f2;
  --crimson-border: #fecaca;

  --purple: #6d28d9;
  --purple-bg: #f5f3ff;
  --purple-border: #ddd6fe;

  --whatsapp: #128c7e;
  --whatsapp-bg: #e8f8f5;

  --msg-inbound-bg: #f1f5f9;
  --msg-inbound-text: #0f172a;
  --msg-outbound-bg: #0052b6;
  --msg-outbound-text: #ffffff;
  --msg-autoflow-bg: #ecfeff;
  --msg-autoflow-border: #67e8f9;
  --msg-autoflow-text: #0e7490;
  --msg-note-bg: #fef9c3;
  --msg-note-border: #eab308;
  --msg-note-text: #713f12;

  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 4px 12px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 10px 28px rgba(15, 23, 42, 0.09);
  --shadow-lg: 0 20px 45px rgba(0, 82, 182, 0.14);

  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;

  --font-heading: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

[data-theme="dark"] {
  --bg-main: #0a0f1d;
  --bg-surface: #111827;
  --bg-card: #111827;
  --bg-card-alt: #1e293b;
  --bg-hover: #172554;
  --bg-input: #0f172a;

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;

  --muronto-navy: #060b16;
  --muronto-blue: #38bdf8;
  --muronto-blue-dark: #0284c7;
  --muronto-cyan: #00b4d8;
  --muronto-cyan-soft: rgba(0, 180, 216, 0.16);
  --muronto-blue-soft: rgba(56, 189, 248, 0.14);

  --border-color: #1f2937;
  --border-strong: #334155;
  --border-focus: #38bdf8;

  --emerald: #34d399;
  --emerald-bg: rgba(16, 185, 129, 0.14);
  --emerald-border: rgba(52, 211, 153, 0.35);

  --amber: #fbbf24;
  --amber-bg: rgba(245, 158, 11, 0.14);
  --amber-border: rgba(251, 191, 36, 0.35);

  --crimson: #f87171;
  --crimson-bg: rgba(239, 68, 68, 0.15);
  --crimson-border: rgba(248, 113, 113, 0.35);

  --purple: #c4b5fd;
  --purple-bg: rgba(139, 92, 246, 0.16);
  --purple-border: rgba(196, 181, 253, 0.35);

  --whatsapp: #25d366;
  --whatsapp-bg: rgba(37, 211, 102, 0.14);

  --msg-inbound-bg: #1e293b;
  --msg-inbound-text: #f8fafc;
  --msg-outbound-bg: #0052b6;
  --msg-outbound-text: #ffffff;
  --msg-autoflow-bg: rgba(6, 182, 212, 0.14);
  --msg-autoflow-border: rgba(34, 211, 238, 0.4);
  --msg-autoflow-text: #67e8f9;
  --msg-note-bg: rgba(234, 179, 8, 0.16);
  --msg-note-border: rgba(250, 204, 21, 0.5);
  --msg-note-text: #fef08a;

  --shadow-xs: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 22px 50px rgba(0, 0, 0, 0.75);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.55;
  min-height: 100vh;
  transition: background-color 0.2s ease, color 0.2s ease;
}

a {
  color: var(--muronto-blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
}

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

.mono {
  font-family: var(--font-mono);
}

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

/* ============================================================================
   1. BARRA SUPERIOR GLOBAL MÜRÖNTÖ (APP SWITCHER + SESIÓN + TEMA)
   ============================================================================ */
.ecosystem-topbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-xs);
}

.ecosystem-topbar__inner {
  max-width: 1680px;
  margin: 0 auto;
  padding: 0.45rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.ecosystem-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text-primary);
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  text-decoration: none !important;
}

.ecosystem-brand img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  border-radius: 6px;
}

.ecosystem-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.ecosystem-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.32rem 0.62rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none !important;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.ecosystem-link:hover {
  background: var(--bg-card-alt);
  color: var(--text-primary);
}

.ecosystem-link.is-active {
  background: var(--muronto-blue-soft);
  color: var(--muronto-blue);
  border-color: rgba(0, 82, 182, 0.28);
  font-weight: 700;
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.theme-switcher {
  display: inline-flex;
  align-items: center;
  background: var(--bg-card-alt);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 2px;
}

.theme-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.24rem 0.56rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.theme-btn.active {
  background: var(--bg-surface);
  color: var(--muronto-blue);
  box-shadow: var(--shadow-xs);
  font-weight: 700;
}

.operator-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.26rem 0.65rem;
  border-radius: 999px;
  background: var(--emerald-bg);
  border: 1px solid var(--emerald-border);
  color: var(--emerald);
  font-size: 0.74rem;
  font-weight: 700;
}

.btn-logout {
  border: 1px solid var(--crimson-border);
  background: var(--crimson-bg);
  color: var(--crimson);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.26rem 0.6rem;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none !important;
  transition: opacity 0.15s ease;
}

.btn-logout:hover {
  opacity: 0.88;
}

/* ============================================================================
   2. CABECERA OPERATIVA Y PESTAÑAS SPA (5 MÓDULOS)
   ============================================================================ */
.crm-header {
  background: linear-gradient(135deg, #0a192f 0%, #003566 58%, #0052b6 100%);
  color: #ffffff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.crm-header__inner {
  max-width: 1680px;
  margin: 0 auto;
  padding: 0.9rem 1.25rem 0;
}

.crm-header__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding-bottom: 0.85rem;
}

.crm-brand-title {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.crm-brand-title img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.95);
  padding: 4px;
  border-radius: 10px;
}

.crm-brand-kicker {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #7dd3fc;
  font-weight: 700;
}

.crm-brand-title h1 {
  font-family: var(--font-heading);
  font-size: 1.18rem;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.2;
}

.crm-header-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.crm-tabs {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  overflow-x: auto;
  scrollbar-width: thin;
}

.crm-tab-btn {
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.84);
  font-family: var(--font-heading);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.62rem 1rem;
  border-radius: 10px 10px 0 0;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  transition: all 0.16s ease;
  border-bottom: 3px solid transparent;
}

.crm-tab-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
}

.crm-tab-btn.is-active {
  background: var(--bg-main);
  color: var(--muronto-blue);
  border-bottom-color: var(--muronto-cyan);
}

.tab-counter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-family: var(--font-mono);
  background: rgba(0, 156, 222, 0.22);
  color: inherit;
}

/* ============================================================================
   3. CONTENEDORES Y BOTONES UNIVERSALES
   ============================================================================ */
.crm-workspace {
  max-width: 1680px;
  margin: 0 auto;
  padding: 1rem 1.25rem 2.5rem;
}

.crm-panel {
  display: none;
}

.crm-panel.is-active {
  display: block;
  animation: crmFadeIn 0.18s ease-out;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.42rem;
  padding: 0.52rem 0.95rem;
  border-radius: var(--radius-xs);
  font-weight: 700;
  font-size: 0.82rem;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none !important;
  transition: all 0.15s ease;
  white-space: nowrap;
}

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

.btn-primary {
  background: linear-gradient(135deg, #0052b6 0%, #009cde 100%);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 82, 182, 0.25);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.06);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-card-alt);
}

.btn-ghost-light {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.24);
}

.btn-ghost-light:hover {
  background: rgba(255, 255, 255, 0.2);
}

.btn-whatsapp {
  background: #128c7e;
  color: #ffffff;
}

.btn-whatsapp:hover:not(:disabled) {
  background: #0e7266;
}

.btn-sm {
  padding: 0.34rem 0.68rem;
  font-size: 0.75rem;
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 0.56rem 0.78rem;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 0.86rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--muronto-blue-soft);
  outline: none;
}

.textarea {
  resize: vertical;
  min-height: 88px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  padding: 0.18rem 0.52rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-blue { background: var(--muronto-blue-soft); color: var(--muronto-blue); border-color: rgba(0, 82, 182, 0.22); }
.badge-cyan { background: var(--muronto-cyan-soft); color: var(--muronto-cyan); border-color: rgba(0, 156, 222, 0.28); }
.badge-emerald { background: var(--emerald-bg); color: var(--emerald); border-color: var(--emerald-border); }
.badge-amber { background: var(--amber-bg); color: var(--amber); border-color: var(--amber-border); }
.badge-crimson { background: var(--crimson-bg); color: var(--crimson); border-color: var(--crimson-border); }
.badge-purple { background: var(--purple-bg); color: var(--purple); border-color: var(--purple-border); }

/* ============================================================================
   4. PESTAÑA 1: BANDEJA OMNICANAL (3 COLUMNAS ESTILO ZENDESK / CHATWOOT)
   ============================================================================ */
.inbox-grid {
  display: grid;
  grid-template-columns: 350px minmax(0, 1fr) 320px;
  gap: 1rem;
  align-items: start;
}

@media (max-width: 1260px) {
  .inbox-grid {
    grid-template-columns: 320px minmax(0, 1fr);
  }
  .inbox-col-right {
    grid-column: 1 / -1;
  }
}

@media (max-width: 860px) {
  .inbox-grid {
    grid-template-columns: 1fr;
  }
}

.card-pane {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.inbox-filters {
  padding: 0.85rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  gap: 0.62rem;
}

.inbox-filters__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.inbox-filters__head h2 {
  font-family: var(--font-heading);
  font-size: 0.92rem;
  font-weight: 800;
}

.channel-chips {
  display: flex;
  gap: 0.32rem;
  flex-wrap: wrap;
}

.chip-btn {
  border: 1px solid var(--border-color);
  background: var(--bg-card-alt);
  color: var(--text-secondary);
  font-size: 0.71rem;
  font-weight: 600;
  padding: 0.24rem 0.52rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.14s ease;
}

.chip-btn:hover {
  border-color: var(--muronto-cyan);
  color: var(--text-primary);
}

.chip-btn.is-active {
  background: var(--muronto-blue);
  color: #ffffff;
  border-color: var(--muronto-blue);
}

.quick-switches {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
  padding-top: 0.15rem;
}

.switch-label {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.switch-label input[type="checkbox"] {
  accent-color: var(--muronto-blue);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.ticket-list {
  max-height: calc(100vh - 360px);
  min-height: 420px;
  overflow-y: auto;
}

.ticket-item {
  padding: 0.82rem 0.9rem;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background-color 0.14s ease;
  display: flex;
  flex-direction: column;
  gap: 0.38rem;
  border-left: 3px solid transparent;
}

.ticket-item:hover {
  background: var(--bg-hover);
}

.ticket-item.is-selected {
  background: var(--bg-hover);
  border-left-color: var(--muronto-blue);
}

.ticket-item__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.ticket-code {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muronto-blue);
}

.ticket-subject {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ticket-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  font-size: 0.74rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.score-meter {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
}

.score-bar-mini {
  width: 44px;
  height: 6px;
  border-radius: 999px;
  background: var(--border-color);
  overflow: hidden;
}

.score-bar-mini > span {
  display: block;
  height: 100%;
  border-radius: 999px;
}

/* Columna Central: Conversación y Respuesta Inteligente */
.conversation-pane {
  display: flex;
  flex-direction: column;
  min-height: 670px;
}

.conv-header {
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.conv-header__title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.conv-header__title {
  font-family: var(--font-heading);
  font-size: 1.02rem;
  font-weight: 800;
}

.conv-controls-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
}

@media (max-width: 640px) {
  .conv-controls-row {
    grid-template-columns: 1fr;
  }
}

.control-mini label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.control-mini select {
  padding: 0.36rem 0.55rem;
  font-size: 0.78rem;
}

.conv-messages {
  flex: 1;
  padding: 1rem 1.1rem;
  overflow-y: auto;
  max-height: 410px;
  display: flex;
  flex-direction: column;
  gap: 0.78rem;
  background: var(--bg-main);
}

.msg-row {
  display: flex;
  flex-direction: column;
  max-width: 84%;
}

.msg-row.is-inbound {
  align-self: flex-start;
}

.msg-row.is-outbound {
  align-self: flex-end;
}

.msg-row.is-autoflow {
  align-self: center;
  max-width: 94%;
  width: 100%;
}

.msg-row.is-note {
  align-self: flex-end;
  max-width: 88%;
}

.msg-bubble {
  padding: 0.72rem 0.92rem;
  border-radius: 12px;
  font-size: 0.85rem;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}

.msg-row.is-inbound .msg-bubble {
  background: var(--msg-inbound-bg);
  color: var(--msg-inbound-text);
  border: 1px solid var(--border-color);
  border-bottom-left-radius: 3px;
}

.msg-row.is-outbound .msg-bubble {
  background: var(--msg-outbound-bg);
  color: var(--msg-outbound-text);
  border-bottom-right-radius: 3px;
}

.msg-row.is-autoflow .msg-bubble {
  background: var(--msg-autoflow-bg);
  color: var(--msg-autoflow-text);
  border: 1px dashed var(--msg-autoflow-border);
  font-size: 0.8rem;
}

.msg-row.is-note .msg-bubble {
  background: var(--msg-note-bg);
  color: var(--msg-note-text);
  border: 1px solid var(--msg-note-border);
}

.msg-caption {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 0.22rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.msg-row.is-outbound .msg-caption,
.msg-row.is-note .msg-caption {
  justify-content: flex-end;
}

/* Caja de Respuesta Inteligente */
.reply-composer {
  border-top: 1px solid var(--border-color);
  background: var(--bg-surface);
  padding: 0.85rem 1.05rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.reply-mode-tabs {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.reply-mode-btn {
  border: 1px solid var(--border-color);
  background: var(--bg-card-alt);
  color: var(--text-secondary);
  font-size: 0.74rem;
  font-weight: 700;
  padding: 0.34rem 0.65rem;
  border-radius: var(--radius-xs);
  cursor: pointer;
}

.reply-mode-btn.is-active {
  background: var(--muronto-blue-soft);
  color: var(--muronto-blue);
  border-color: var(--muronto-blue);
}

.reply-mode-btn[data-reply-mode="INTERNAL_NOTE"].is-active {
  background: var(--msg-note-bg);
  color: var(--msg-note-text);
  border-color: var(--msg-note-border);
}

.reply-mode-btn[data-reply-mode="WHATSAPP"].is-active {
  background: var(--whatsapp-bg);
  color: var(--whatsapp);
  border-color: var(--whatsapp);
}

.reply-toolbar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

@media (max-width: 640px) {
  .reply-toolbar {
    grid-template-columns: 1fr;
  }
}

.reply-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
}

/* Columna Derecha: Ficha 360° del Remitente */
.contact360-pane {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.contact360-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.avatar-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0052b6, #009cde);
  color: #ffffff;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.info-list {
  display: flex;
  flex-direction: column;
  gap: 0.52rem;
  font-size: 0.8rem;
}

.info-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  border-bottom: 1px dashed var(--border-color);
  padding-bottom: 0.35rem;
}

.info-row span:first-child {
  color: var(--text-muted);
  font-weight: 600;
}

.info-row span:last-child {
  font-weight: 700;
  text-align: right;
  word-break: break-all;
}

.score-card-box {
  background: var(--bg-card-alt);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
}

.progress-track {
  width: 100%;
  height: 10px;
  background: var(--border-color);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.42rem;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
}

.qr-preview-box {
  background: #ffffff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  text-align: center;
  color: #0f172a;
}

.qr-preview-box svg,
.qr-preview-box img {
  width: 136px;
  height: 136px;
  margin: 0 auto 0.4rem;
  display: block;
}

/* ============================================================================
   5. PESTAÑA 2: EMBUDOS KANBAN (6 COLUMNAS + DRAG & DROP)
   ============================================================================ */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(6, minmax(255px, 1fr));
  gap: 0.85rem;
  overflow-x: auto;
  padding-bottom: 0.75rem;
  align-items: start;
}

.kanban-col {
  background: var(--bg-card-alt);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  min-height: 520px;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.kanban-col.is-drag-over {
  border-color: var(--muronto-cyan);
  background: var(--bg-hover);
  box-shadow: 0 0 0 2px var(--muronto-cyan-soft);
}

.kanban-col__head {
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-surface);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.kanban-col__title {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  font-weight: 800;
}

.kanban-col__body {
  padding: 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  flex: 1;
}

.kanban-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.72rem;
  box-shadow: var(--shadow-xs);
  cursor: grab;
  display: flex;
  flex-direction: column;
  gap: 0.42rem;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.kanban-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.kanban-card:active {
  cursor: grabbing;
}

/* ============================================================================
   6. PESTAÑA 3: CONTACTOS 360° (TABLA RESPONSIVA)
   ============================================================================ */
.section-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  background: var(--bg-surface);
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.table-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow-x: auto;
  box-shadow: var(--shadow-xs);
}

.crm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
}

.crm-table th {
  text-align: left;
  padding: 0.75rem 0.9rem;
  background: var(--bg-card-alt);
  color: var(--text-secondary);
  font-size: 0.73rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border-color);
}

.crm-table td {
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.crm-table tbody tr:hover {
  background: var(--bg-hover);
}

/* ============================================================================
   7. PESTAÑA 4: AUTOFLOW, PLANTILLAS Y CONECTORES OMNICANAL
   ============================================================================ */
.autoflow-layout {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 1rem;
  align-items: start;
}

@media (max-width: 1024px) {
  .autoflow-layout {
    grid-template-columns: 1fr;
  }
}

.rule-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--muronto-cyan);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.9rem;
  margin-bottom: 0.7rem;
}

.rule-flow-pills {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.45rem;
  font-size: 0.77rem;
}

/* Toggle Switch Accesible */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--border-strong);
  border-radius: 999px;
  transition: 0.2s;
}

.toggle-slider::before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: #ffffff;
  border-radius: 50%;
  transition: 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--emerald);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

.connectors-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.connector-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* ============================================================================
   8. PESTAÑA 5: MÉTRICAS Y SLA DIRECTIVO
   ============================================================================ */
.kpi-grid-6 {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.15rem;
}

@media (max-width: 1280px) {
  .kpi-grid-6 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .kpi-grid-6 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-top: 3px solid var(--muronto-blue);
  border-radius: var(--radius-md);
  padding: 0.95rem 1rem;
  box-shadow: var(--shadow-xs);
}

.kpi-label {
  font-size: 0.73rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.kpi-value {
  font-family: var(--font-heading);
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0.25rem 0;
}

.kpi-sub {
  font-size: 0.73rem;
  color: var(--text-secondary);
}

.charts-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

@media (max-width: 1080px) {
  .charts-grid-3 {
    grid-template-columns: 1fr;
  }
}

.bar-stat-row {
  margin-bottom: 0.68rem;
}

.bar-stat-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.79rem;
  font-weight: 600;
  margin-bottom: 0.24rem;
}

/* ============================================================================
   9. PORTALES PÚBLICOS (LOGIN, SOLICITUD 2 PASOS, SEGUIMIENTO QR)
   ============================================================================ */
.public-hero {
  background: linear-gradient(135deg, #0a192f 0%, #003566 55%, #0052b6 100%);
  color: #ffffff;
  padding: 2.2rem 1.25rem;
  text-align: center;
}

.public-hero h1 {
  font-family: var(--font-heading);
  font-size: clamp(1.35rem, 2.6vw, 2rem);
  font-weight: 800;
  margin-bottom: 0.45rem;
}

.public-hero p {
  max-width: 720px;
  margin: 0 auto;
  color: rgba(255, 255, 255, 0.88);
  font-size: 0.94rem;
}

.public-container {
  max-width: 1120px;
  margin: -1.4rem auto 3rem;
  padding: 0 1.25rem;
}

.solicitud-grid {
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 880px) {
  .solicitud-grid {
    grid-template-columns: 1fr;
  }
}

.stepper-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.2rem;
}

.step-pill {
  flex: 1;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--bg-card-alt);
  border: 1px solid var(--border-color);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.step-pill.is-active {
  background: var(--muronto-blue-soft);
  border-color: var(--muronto-blue);
  color: var(--muronto-blue);
}

.step-pill.is-done {
  background: var(--emerald-bg);
  border-color: var(--emerald-border);
  color: var(--emerald);
}

.form-group {
  margin-bottom: 0.95rem;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
}

.intent-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

@media (max-width: 560px) {
  .intent-grid {
    grid-template-columns: 1fr;
  }
}

.intent-option {
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  font-weight: 700;
  transition: all 0.14s ease;
}

.intent-option:hover {
  border-color: var(--muronto-cyan);
}

.intent-option.is-selected {
  border-color: var(--muronto-blue);
  background: var(--muronto-blue-soft);
  color: var(--muronto-blue);
}

.timeline-list {
  position: relative;
  padding-left: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.timeline-list::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--border-strong);
}

.timeline-item {
  position: relative;
  background: var(--bg-card-alt);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.95rem;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -1.35rem;
  top: 0.9rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muronto-blue);
  border: 2px solid var(--bg-surface);
}

/* ============================================================================
   10. MODALES, SKELETONS, EMPTY STATES Y TOASTS
   ============================================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(10, 15, 29, 0.65);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop.is-open {
  display: flex;
}

.modal-card {
  width: 100%;
  max-width: 540px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-top: 4px solid var(--muronto-blue);
  border-radius: var(--radius-md);
  padding: 1.35rem;
  box-shadow: var(--shadow-lg);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.modal-head h3 {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 800;
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-card-alt) 25%, var(--border-color) 50%, var(--bg-card-alt) 75%);
  background-size: 200% 100%;
  animation: crmShimmer 1.4s infinite;
  border-radius: var(--radius-xs);
}

@keyframes crmShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.empty-state {
  padding: 2.2rem 1.2rem;
  text-align: center;
  color: var(--text-muted);
}

.empty-state__icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.toast-stack {
  position: fixed;
  bottom: 1.2rem;
  right: 1.2rem;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--emerald);
  border-radius: var(--radius-sm);
  padding: 0.72rem 1rem;
  font-size: 0.82rem;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  max-width: 360px;
}

.toast.is-error {
  border-left-color: var(--crimson);
}

@media print {
  .ecosystem-topbar,
  .no-print {
    display: none !important;
  }
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
}
