/* ===================== OptimOS · Customer Journey Map ===================== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --red: #E31E24;
  --red-dark: #B71C1C;
  --teal: #2d7d8a;
  --teal-dark: #1f5f6a;
  --black: #1a1a1a;
  --dark-gray: #2d2d2d;
  --medium-gray: #555;
  --light-gray: #eef1f4;
  --border: #e5e7eb;
  --white: #ffffff;
  --sidebar: #3a4a54;
  --shadow: 0 2px 14px rgba(0,0,0,0.06);
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--light-gray);
  min-height: 100vh;
  color: var(--black);
}

/* ---- Loader mientras valida sesión ---- */
#authLoader {
  position: fixed; inset: 0; background: #fff; z-index: 99999;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
}
#authLoader .spin {
  width: 46px; height: 46px; border: 4px solid #f0f0f0; border-top-color: var(--red);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#authLoader p { color: var(--medium-gray); font-size: 0.9rem; }
#authLoader.hidden { opacity: 0; pointer-events: none; transition: opacity 0.35s ease; }
/* Editor y visor: el loader (loader-auto) se oculta apenas valida sesión (ya se entró por el index) */
body.auth-ok #authLoader.loader-auto { display: none; }

/* ===================== Layout general ===================== */
.app-shell { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 78px; background: var(--sidebar); flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center; padding-top: 14px; gap: 16px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .side-logo {
  width: 46px; height: 46px; border-radius: 12px; object-fit: cover;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}
.side-nav { display: flex; flex-direction: column; gap: 8px; width: 100%; align-items: center; margin-top: 6px; }
.side-btn {
  width: 62px; padding: 9px 4px; border: none; border-radius: 12px; background: transparent; color: #cbd5db;
  display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; transition: all 0.18s;
  font-family: 'Inter', sans-serif; font-size: 0.66rem; font-weight: 600;
}
.side-btn i { font-size: 1.15rem; }
.side-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }
.side-btn.active { background: var(--red); color: #fff; box-shadow: 0 4px 12px rgba(227,30,36,0.35); }

/* Contenedor principal */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* Barra roja superior */
.topbar-accent { height: 5px; background: var(--red); }

/* Header */
.header {
  background: var(--white); box-shadow: var(--shadow);
  padding: 12px 26px; display: flex; align-items: center; justify-content: space-between; gap: 18px;
}
.header .h-title h1 { font-size: 1.35rem; font-weight: 700; color: var(--black); line-height: 1.1; }
.header .h-title span { font-size: 0.82rem; color: var(--medium-gray); }

/* Buscador del header */
.h-search {
  flex: 1; max-width: 420px; display: flex; align-items: center; gap: 10px;
  background: #fff; border: 1.5px solid var(--border); border-radius: 8px; padding: 0 14px;
  transition: all 0.2s;
}
.h-search:focus-within { border-color: var(--red); box-shadow: 0 0 0 3px rgba(227,30,36,0.08); }
.h-search i { color: #9ca3af; font-size: 0.9rem; }
.h-search input { flex: 1; border: none; outline: none; padding: 10px 0; font-size: 0.9rem; font-family: 'Inter', sans-serif; background: transparent; }

/* Chip de usuario */
.h-user { display: flex; align-items: center; gap: 12px; }
.h-user-info { text-align: right; line-height: 1.25; }
.h-user-info .u-name { font-size: 0.82rem; font-weight: 600; color: var(--black); }
.h-user-info .u-mail { font-size: 0.74rem; color: var(--medium-gray); }
.h-user-avatar {
  width: 40px; height: 40px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border);
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--red), var(--red-dark)); color: #fff; font-weight: 700; font-size: 0.9rem;
}

/* ===================== Cuerpo del menú ===================== */
.content { padding: 26px 32px; flex: 1; }

.content-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }

/* Tarjetas de métricas */
.metrics { display: flex; gap: 22px; justify-content: center; margin-bottom: 26px; }
.metric-card {
  background: #fff; border: 1.5px solid #cdd6db; border-radius: 10px; min-width: 210px;
  text-align: center; overflow: hidden; box-shadow: var(--shadow);
}
.metric-card .m-head {
  background: linear-gradient(135deg, var(--teal), var(--teal-dark)); color: #fff;
  font-style: italic; font-weight: 700; font-size: 0.92rem; padding: 9px 12px;
}
.metric-card .m-value { font-size: 2rem; font-weight: 700; font-style: italic; color: var(--black); padding: 14px 12px; }

/* Botón principal */
.btn-primary {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border: none; border-radius: 7px;
  background: linear-gradient(135deg, var(--red), var(--red-dark)); color: #fff; font-weight: 600; font-size: 0.85rem;
  cursor: pointer; font-family: 'Inter', sans-serif; transition: all 0.2s; box-shadow: 0 4px 12px rgba(227,30,36,0.25);
  white-space: nowrap;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(227,30,36,0.35); }
.btn-primary.hidden { display: none; }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 7px;
  background: #fff; border: 1.5px solid var(--border); color: var(--dark-gray); font-weight: 600; font-size: 0.85rem;
  cursor: pointer; font-family: 'Inter', sans-serif; transition: all 0.2s;
}
.btn-ghost:hover { border-color: var(--red); color: var(--red); }

/* ===================== Tabla de cuentas ===================== */
.table-wrap { background: #fff; border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; border: 1px solid var(--border); }
.cjm-table { width: 100%; border-collapse: collapse; }
.cjm-table thead th {
  background: #f3f5f7; color: var(--dark-gray); font-size: 0.82rem; font-weight: 700; text-align: center;
  padding: 14px 16px; border-right: 1px solid #e8ebee;
}
.cjm-table thead th:last-child { border-right: none; }
.cjm-table thead th.th-left { text-align: center; }
.cjm-table tbody td { padding: 14px 16px; border-bottom: 1px solid #f0f2f4; font-size: 0.88rem; text-align: center; vertical-align: middle; }
.cjm-table tbody tr:hover { background: #fafbfc; }
.cjm-table .td-cuenta { text-align: left; }
.td-cuenta-wrap { display: flex; align-items: center; gap: 12px; }
.td-cuenta-logo {
  width: 38px; height: 38px; border-radius: 9px; object-fit: cover; flex-shrink: 0; background: #f0f2f4;
  display: inline-flex; align-items: center; justify-content: center; color: var(--teal); font-weight: 700; border: 1px solid var(--border);
}
.td-cuenta-name { font-weight: 600; color: var(--black); }
.seg-badge { display: inline-block; padding: 3px 12px; border-radius: 20px; background: #eef2ff; color: #3730a3; font-size: 0.76rem; font-weight: 600; }

.table-empty { padding: 60px 20px; text-align: center; color: #9ca3af; }
.table-empty i { font-size: 2.4rem; margin-bottom: 12px; display: block; opacity: 0.5; }
.table-empty p { font-size: 0.95rem; }

/* Filas de empresa (grupo) */
.cjm-table .td-cuenta-logo img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }
.group-row { cursor: pointer; background: #f8fafb; transition: background 0.15s; }
.group-row:hover { background: #f1f5f7; }
.group-row .td-cuenta-name { font-weight: 700; }
.group-caret { color: var(--teal); font-size: 0.8rem; width: 14px; transition: transform 0.15s; }
.group-count {
  margin-left: 10px; font-size: 0.72rem; font-weight: 600; color: var(--teal-dark);
  background: #e4f0f2; padding: 2px 10px; border-radius: 20px;
}
.group-dim { color: #9ca3af; font-size: 0.82rem; }
.td-acc-group { text-align: right; }

/* Filas hijas (cada CJM) */
.child-row { background: #fff; }
.child-row:hover { background: #fafbfc; }
.child-cuenta { padding-left: 46px !important; font-weight: 500; color: var(--medium-gray); text-align: left; }
.child-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--teal); margin-right: 10px; vertical-align: middle; }
.estado-badge { margin-left: 10px; font-size: 0.64rem; font-weight: 700; padding: 2px 9px; border-radius: 20px; text-transform: uppercase; letter-spacing: 0.4px; }
.estado-badge.borrador { background: #fef3c7; color: #92400e; }

/* Botones de acción en tabla */
.act-btn { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border); background: #fff; cursor: pointer; font-size: 0.8rem; transition: all 0.2s; margin: 0 3px; }
.act-btn.view { color: var(--teal); }
.act-btn.view:hover { background: var(--teal); color: #fff; border-color: var(--teal); }
.act-btn.edit { color: #2563eb; }
.act-btn.edit:hover { background: #2563eb; color: #fff; border-color: #2563eb; }
.act-btn.dup { color: #7c3aed; }
.act-btn.dup:hover { background: #7c3aed; color: #fff; border-color: #7c3aed; }
.act-btn.del { color: var(--red); }
.act-btn.del:hover { background: var(--red); color: #fff; border-color: var(--red); }

/* ===================== Footer ===================== */
.footer { padding: 14px 32px; display: flex; align-items: center; justify-content: flex-end; gap: 18px; }
.footer img { height: 52px; opacity: 0.9; }
.footer .footer-sep { color: #c8ced4; font-size: 1.6rem; font-weight: 300; }
.footer .footer-optimos { height: 50px; }

/* Contenedor de acciones del top (Volver + Refrescar + Agregar) */
.top-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-bottom: 18px; }

/* Botón de refrescar (solo icono) */
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px;
  border-radius: 8px; border: 1.5px solid var(--border); background: #fff; color: var(--teal);
  cursor: pointer; transition: all 0.2s; font-size: 0.95rem;
}
.btn-icon:hover { border-color: var(--teal); background: rgba(45,125,138,0.06); transform: translateY(-1px); }
.btn-icon.spinning i { animation: spin 0.7s linear infinite; }

/* ===================== Modal ===================== */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(15,15,20,0.55); backdrop-filter: blur(4px);
  z-index: 10000; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: #fff; border-radius: 16px; width: 100%; max-width: 460px; overflow: hidden;
  box-shadow: 0 30px 90px rgba(0,0,0,0.35); animation: modalIn 0.25s cubic-bezier(0.16,1,0.3,1);
}
@keyframes modalIn { from { transform: translateY(16px) scale(0.98); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }
.modal-head {
  background: linear-gradient(135deg, var(--red), var(--red-dark)); color: #fff;
  padding: 18px 22px; display: flex; align-items: center; justify-content: space-between;
}
.modal-head h3 { font-size: 1.05rem; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.modal-close { background: rgba(255,255,255,0.15); border: none; color: #fff; width: 34px; height: 34px; border-radius: 9px; cursor: pointer; transition: all 0.2s; }
.modal-close:hover { background: rgba(255,255,255,0.3); transform: rotate(90deg); }
.modal-body { padding: 22px; }
.form-field { margin-bottom: 16px; }
.form-field label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--dark-gray); margin-bottom: 7px; }
.form-field input[type="text"] {
  width: 100%; padding: 11px 14px; border: 1.5px solid var(--border); border-radius: 9px; font-size: 0.88rem;
  font-family: 'Inter', sans-serif; outline: none; transition: all 0.2s;
}
.form-field input:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(227,30,36,0.08); }

/* Dropzone del logo */
.logo-drop {
  border: 2px dashed var(--border); border-radius: 12px; padding: 18px; text-align: center; cursor: pointer;
  transition: all 0.2s; background: #fafbfc;
}
.logo-drop:hover { border-color: var(--red); background: rgba(227,30,36,0.03); }
.logo-drop i { font-size: 1.8rem; color: #c0c5cc; margin-bottom: 8px; display: block; }
.logo-drop p { font-size: 0.82rem; color: var(--medium-gray); }
.logo-drop small { font-size: 0.72rem; color: #9ca3af; }
.logo-preview { max-height: 90px; max-width: 100%; border-radius: 10px; margin-bottom: 8px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ===================== Responsive ===================== */
@media (max-width: 860px) {
  .content-top { flex-direction: column; }
  .metrics { flex-direction: column; align-items: stretch; width: 100%; }
  .metric-card { min-width: 0; }
  .header .h-title h1 { font-size: 1.1rem; }
}
@media (max-width: 640px) {
  .sidebar { display: none; }
  .header { flex-wrap: wrap; padding: 12px 16px; }
  .h-search { order: 3; max-width: 100%; flex-basis: 100%; }
  .content { padding: 18px 14px; }
  .h-user-info { display: none; }

  /* Tabla como tarjetas */
  .cjm-table thead { display: none; }
  .cjm-table, .cjm-table tbody, .cjm-table tr, .cjm-table td { display: block; width: 100%; }
  .cjm-table tbody tr { border: 1px solid var(--border); border-radius: 12px; margin-bottom: 12px; padding: 6px 4px; box-shadow: var(--shadow); }
  .cjm-table tbody td { border: none; text-align: right; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 14px; }
  .cjm-table tbody td::before { content: attr(data-label); font-size: 0.68rem; font-weight: 700; color: #9ca3af; text-transform: uppercase; letter-spacing: 0.5px; }
  .cjm-table .td-cuenta { text-align: left; }
  .cjm-table .td-cuenta::before { display: none; }
  .footer { justify-content: center; }
}

/* ============================================================
 * EDITOR DEL JOURNEY
 * ============================================================ */
.editor-header {
  background: #fff; box-shadow: var(--shadow); padding: 12px 26px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; position: sticky; top: 0; z-index: 50;
}
.editor-brand { display: flex; align-items: center; gap: 14px; }
.editor-brand img { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; }
.editor-brand h1 { font-size: 1.25rem; font-weight: 700; color: var(--black); }
.editor-header-right { display: flex; align-items: center; gap: 14px; }
.btn-back {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border: none; border-radius: 7px;
  background: linear-gradient(135deg, var(--red), var(--red-dark)); color: #fff; font-weight: 600; font-size: 0.85rem;
  cursor: pointer; font-family: 'Inter', sans-serif; transition: all 0.2s;
}
.btn-back:hover { transform: translateY(-1px); }

/* Botón Exportar a PowerPoint (visor) */
.btn-ppt {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border: 1.5px solid #fed7aa;
  border-radius: 7px; background: #fff7ed; color: #b45309; font-weight: 700; font-size: 0.85rem;
  cursor: pointer; font-family: 'Inter', sans-serif; transition: all 0.2s;
}
.btn-ppt:hover { background: #ffedd5; border-color: #fdba74; transform: translateY(-1px); }
.btn-ppt.spinning i { animation: spin 0.7s linear infinite; }

/* Barra superior de datos */
.editor-meta {
  display: flex; align-items: flex-end; gap: 20px; padding: 20px 26px 6px; flex-wrap: wrap;
}
.editor-meta .meta-field { display: flex; flex-direction: column; gap: 6px; }
.editor-meta .meta-field label { font-size: 0.82rem; font-weight: 600; color: var(--dark-gray); }
.editor-meta .meta-field select,
.editor-meta .meta-field input {
  padding: 9px 12px; border: 1.5px solid #cfd6db; border-radius: 6px; font-size: 0.85rem;
  font-family: 'Inter', sans-serif; outline: none; min-width: 190px; background: #fff;
}
.editor-meta .meta-field select:focus,
.editor-meta .meta-field input:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(227,30,36,0.08); }
.editor-meta .meta-spacer { flex: 1; }
.btn-finalizar {
  display: inline-flex; align-items: center; gap: 8px; padding: 11px 22px; border: none; border-radius: 6px;
  background: linear-gradient(135deg, var(--red), var(--red-dark)); color: #fff; font-weight: 700; font-size: 0.88rem;
  cursor: pointer; font-family: 'Inter', sans-serif; transition: all 0.2s; box-shadow: 0 4px 12px rgba(227,30,36,0.25);
}
.btn-finalizar:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(227,30,36,0.35); }

.editor-toolbar { display: flex; gap: 10px; padding: 10px 26px; align-items: center; }

/* Indicador de estado de guardado */
.save-status {
  display: inline-flex; align-items: center; gap: 7px; font-size: 0.8rem; font-weight: 600;
  padding: 8px 14px; border-radius: 8px; background: #f1f5f7; color: var(--medium-gray); white-space: nowrap;
  transition: all 0.2s;
}
.save-status.local { background: #fef3c7; color: #92400e; }
.save-status.saving { background: #dbeafe; color: #1e40af; }
.save-status.saved { background: #dcfce7; color: #166534; }
.save-status.error { background: #fee2e2; color: #991b1b; }
.save-status i { font-size: 0.85rem; }
body.readonly .save-status, body.readonly .save-status + .btn-finalizar { display: none; }

/* ---- Matriz ---- */
.matrix-scroll { overflow-x: auto; padding: 10px 26px 30px; -webkit-overflow-scrolling: touch; }
.matrix {
  border-collapse: separate; border-spacing: 8px 6px; min-width: 900px;
}
.matrix td.row-label {
  font-size: 0.72rem; font-weight: 700; color: var(--dark-gray); text-align: left;
  width: 230px; min-width: 230px; max-width: 230px; padding: 0;
  height: 1px;               /* permite que el hijo con height:100% tome el alto de la fila */
  vertical-align: top;
}
/* Celda de etiqueta como mini-panel tipo tabla: nombre arriba, acciones abajo */
.row-label-wrap {
  display: flex; flex-direction: column; gap: 8px;
  background: linear-gradient(180deg, #ffffff, #f7f9fb);
  border: 1px solid #e6eaf0; border-left: 3px solid var(--teal);
  border-radius: 10px; padding: 10px 10px 8px;
  height: 100%; box-sizing: border-box;
}
.row-label-text { display: block; line-height: 1.25; word-break: break-word; }
/* Panel de etiqueta sin botones (Nombre del Momento): ocupa todo el alto de su celda */
.row-label-wrap-plain { justify-content: center; align-items: flex-start; }
/* Filas fijas (Criticidad/Sentimiento): nombre y flechas en la misma línea, alto compacto */
.row-label-wrap-inline {
  flex-direction: row; align-items: center; justify-content: space-between; gap: 6px;
}
/* Solo estas 2 filas: menos altas y su panel al alto natural (no estirado) */
.matrix tr.fila-fija td.row-label { vertical-align: middle; height: auto; }
.matrix tr.fila-fija .row-label-wrap { height: auto; }
.matrix tr.fila-fija .moment-cell { vertical-align: middle; }
.row-label-actions-inline {
  padding-top: 0; border-top: none; flex-shrink: 0;
}
/* Celda de etiqueta vacía (fila de agregar) sin panel */
.matrix td.row-label-plain { display: table-cell; padding: 8px 6px 8px 2px; vertical-align: middle; }
.row-label-title { display: inline-block; }
.row-label-actions {
  display: flex; align-items: center; gap: 4px;
  padding-top: 7px; border-top: 1px solid #eef1f5; opacity: 1;
}
/* flechas de mover a la izquierda; editar/eliminar empujados a la derecha */
.row-label-actions .row-btn.move + .row-btn.edit,
.row-label-actions .row-btn.move + .row-btn.del { margin-left: auto; }

.row-btn {
  border: 1px solid transparent; background: #fff; cursor: pointer; width: 26px; height: 26px;
  border-radius: 7px; font-size: 0.68rem; transition: all 0.15s; padding: 0;
  display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.row-btn.edit { color: #2563eb; border-color: #dbe4f5; }
.row-btn.edit:hover { background: #2563eb; color: #fff; border-color: #2563eb; }
.row-btn.del { color: var(--red); border-color: #f2d4d4; }
.row-btn.del:hover { background: var(--red); color: #fff; border-color: var(--red); }
.row-btn.move { color: #64748b; border-color: #e2e6ee; }
.row-btn.move:hover:not(:disabled) { background: #334155; color: #fff; border-color: #334155; }
.row-btn.chips { color: var(--teal); border-color: #cfe6ea; }
.row-btn.chips:hover { background: var(--teal); color: #fff; border-color: var(--teal); }
.row-btn.chips.on { background: var(--teal); color: #fff; border-color: var(--teal); }
.row-btn:disabled { opacity: 0.3; cursor: default; }

/* Botón agregar fila */
.add-row-cell { padding: 6px 0 !important; }
.btn-add-row {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 16px; border-radius: 8px;
  border: 1.5px dashed #c8ced4; background: #fff; color: var(--teal); font-weight: 600; font-size: 0.78rem;
  font-family: 'Inter', sans-serif; cursor: pointer; transition: all 0.18s;
}
.btn-add-row:hover { border-color: var(--teal); background: rgba(45,125,138,0.06); }
body.readonly .row-label-actions, body.readonly .btn-add-row { display: none !important; }
.matrix .moment-cell { min-width: 150px; vertical-align: top; }

/* Colores por columna (borde) — se asignan por data-col en JS via clases */
.mcol-0 { --c: #9aa3ab; } .mcol-1 { --c: #3b82f6; } .mcol-2 { --c: #f97316; }
.mcol-3 { --c: #8b5cf6; } .mcol-4 { --c: #ef4444; } .mcol-5 { --c: #14b8a6; }
.mcol-6 { --c: #64748b; } .mcol-7 { --c: #22c55e; }

.cell-input, .cell-area, .cell-select {
  width: 100%; border: 1.5px solid var(--c, #d5dbe0); border-radius: 8px; padding: 8px 10px;
  font-size: 0.8rem; font-family: 'Inter', sans-serif; outline: none; background: #fff; color: var(--black); resize: none;
}
.cell-input:focus, .cell-area:focus, .cell-select:focus { box-shadow: 0 0 0 3px rgba(0,0,0,0.05); }
.cell-area { min-height: 88px; }
.cell-area.tall { min-height: 110px; }

/* Wrapper para el botón flotante de canales */
.cell-area-wrap { position: relative; }
.cell-area-wrap .cell-area { padding-right: 34px; }
.btn-canales {
  position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 7px;
  border: 1.5px solid var(--c, #d5dbe0); background: #fff; color: var(--teal); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; font-size: 0.72rem; transition: all 0.15s; z-index: 2;
}
.btn-canales:hover { background: var(--teal); color: #fff; border-color: var(--teal); }
body.readonly .btn-canales { display: none; }

/* Menú desplegable de canales */
.canales-menu {
  position: absolute; z-index: 10001; background: #fff; border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 12px 34px rgba(0,0,0,0.18); padding: 8px; min-width: 210px; animation: modalIn 0.15s ease;
}
.canales-menu-title { font-size: 0.7rem; font-weight: 700; color: #9ca3af; text-transform: uppercase; letter-spacing: 0.5px; padding: 4px 8px 8px; }
.canales-item {
  display: flex; align-items: center; gap: 9px; padding: 8px 8px; border-radius: 7px; cursor: pointer;
  font-size: 0.84rem; color: var(--dark-gray); transition: background 0.12s;
}
.canales-item:hover { background: #f3f5f7; }
.canales-item input { accent-color: var(--red); width: 15px; height: 15px; cursor: pointer; }

/* Sentimiento (emojis) */
.sentiment { display: flex; gap: 4px; justify-content: space-between; border: 1.5px solid var(--c, #d5dbe0); border-radius: 8px; padding: 6px 6px; background: #fff; }
.sentiment button {
  border: none; background: transparent; font-size: 1.15rem; cursor: pointer; line-height: 1; padding: 2px; border-radius: 6px;
  filter: grayscale(0.6); opacity: 0.6; transition: all 0.15s;
}
.sentiment button:hover { transform: scale(1.15); }
.sentiment button.active { filter: none; opacity: 1; transform: scale(1.2); background: rgba(0,0,0,0.04); }

/* Cabecera de columna: nombre del momento arriba + barra de acciones abajo */
.moment-head {
  display: flex; flex-direction: column; gap: 8px;
  background: linear-gradient(180deg, #ffffff, #f7f9fb);
  border: 1px solid #e6eaf0; border-radius: 10px; padding: 8px;
}
.moment-head .cell-input { width: 100%; box-sizing: border-box; }
.moment-head-actions {
  display: flex; align-items: center; gap: 4px;
  padding-bottom: 7px; border-bottom: 1px solid #eef1f5;
}
/* botón X (eliminar) empujado a la derecha, separado de las flechas */
.moment-head-actions .col-btn.del { margin-left: auto; }
.col-btn {
  border: 1px solid transparent; background: #fff; cursor: pointer; width: 28px; height: 28px;
  border-radius: 7px; font-size: 0.72rem; transition: all 0.15s; padding: 0;
  display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.col-btn.move { color: #64748b; border-color: #e2e6ee; }
.col-btn.move:hover:not(:disabled) { background: #334155; color: #fff; border-color: #334155; }
.col-btn.del { color: var(--red); border-color: #f2d4d4; }
.col-btn.del:hover { background: var(--red); color: #fff; border-color: var(--red); }
.col-btn:disabled { opacity: 0.3; cursor: default; }

/* Botón agregar momento (columna extra) */
.add-col-cell { vertical-align: middle; }
.btn-add-col {
  width: 46px; height: 46px; border-radius: 50%; border: 2px dashed #c8ced4; background: #fff; color: var(--teal);
  font-size: 1.1rem; cursor: pointer; transition: all 0.2s;
}
.btn-add-col:hover { border-color: var(--teal); background: rgba(45,125,138,0.06); }

/* Modo solo lectura */
body.readonly .cell-input, body.readonly .cell-area, body.readonly .cell-select,
body.readonly .sentiment button, body.readonly .col-btn, body.readonly .btn-add-col,
body.readonly .btn-finalizar, body.readonly .meta-field select, body.readonly .meta-field input {
  pointer-events: none; opacity: 0.92;
}
body.readonly .btn-finalizar, body.readonly .col-btn, body.readonly .btn-add-col { display: none; }

@media (max-width: 640px) {
  .editor-meta { padding: 16px 14px 4px; }
  .editor-meta .meta-field select, .editor-meta .meta-field input { min-width: 150px; }
  .matrix-scroll { padding: 10px 14px 24px; }
  .editor-header { padding: 12px 16px; }
}

/* ============================================================
 * VISOR (vista de presentación profesional del CJM)
 * ============================================================ */
.visor-body { background: #f4f6f8; }

.visor-main { padding: 28px 30px 40px; overflow: auto; }

/* Bloque exportable (banner + tablero) */
.jmap-export { display: inline-block; min-width: 900px; background: #fff; border-radius: 16px; overflow: hidden; box-shadow: 0 6px 30px rgba(0,0,0,0.08); border: 1px solid #d5dade; }

/* Banner dentro del visual: izquierda cuenta, derecha Outsourcing */
.visor-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 20px 26px; background: #fff; border-bottom: 2px solid #e3e7ea; box-sizing: border-box;
}
.vb-left { display: flex; align-items: center; gap: 16px; }
/* Contenedor del logo: la imagen escala por dentro sin object-fit (compatible con html2canvas) */
.vb-logo-box {
  width: 64px; height: 64px; border-radius: 12px; border: 1px solid var(--border); background: #fff;
  display: flex; align-items: center; justify-content: center; padding: 5px; flex-shrink: 0; box-sizing: border-box;
}
.vb-logo { max-width: 100%; max-height: 100%; width: auto; height: auto; display: block; }
.vb-logo-fb {
  width: 58px; height: 58px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--teal), var(--teal-dark)); color: #fff; font-weight: 700; font-size: 1.4rem;
}
.vb-titles h2 { font-size: 1.5rem; font-weight: 800; color: var(--black); line-height: 1.15; }
.vb-titles span { font-size: 0.88rem; color: var(--medium-gray); font-weight: 500; }
.vb-right { display: flex; align-items: center; }
.vb-out { height: 48px; }

/* El tablero dentro del export ya no lleva su propio borde/sombra */
.jmap-export .jmap { min-width: 0; border: none; border-radius: 0; box-shadow: none; }

/* Tablero — un solo grid, todas las celdas alineadas */
.jmap {
  display: grid; gap: 0; min-width: 900px; background: #fff; border-radius: 16px; overflow: hidden;
  box-shadow: 0 6px 30px rgba(0,0,0,0.08); border: 1px solid #ebeef1;
}

/* Primera columna (etiqueta de fila) */
.jmap-label {
  display: flex; align-items: center; gap: 10px; padding: 16px 16px;
  font-size: 0.78rem; font-weight: 700; color: var(--dark-gray); background: #f3f5f7;
  border-right: 1px solid #d5dade; border-bottom: 1px solid #d5dade;
}
.jmap-label.zebra { background: #eef1f4; }
.jmap-label .jl-icon {
  width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: #f0f2f4; color: var(--red); font-size: 0.85rem;
}

/* Cabecera de fases (fila superior, fondo oscuro) */
.jmap-label.head-label { background: #2b3840; color: #fff; border-right-color: rgba(255,255,255,0.08); border-bottom: none; }
.jmap-phase {
  padding: 18px 16px; text-align: center; color: #fff; background: var(--sidebar);
  border-right: 1px solid rgba(255,255,255,0.08);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
}
.jmap-phase .phase-num {
  width: 30px; height: 30px; border-radius: 50%; background: var(--red); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.85rem;
  box-shadow: 0 3px 10px rgba(227,30,36,0.4);
}
.jmap-phase .phase-name { font-size: 0.9rem; font-weight: 700; line-height: 1.25; }

/* Celdas de contenido */
.jmap-cell {
  padding: 15px 16px; border-right: 1px solid #d5dade; border-bottom: 1px solid #d5dade;
  font-size: 0.82rem; color: #444; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
}
.jmap-cell.zebra { background: #f9fafb; }
.jmap-cell.empty { color: #c8ced4; }

/* Canales como chips */
.chan-chips { display: flex; flex-direction: column; gap: 6px; }
.chan-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 8px;
  background: #f3f5f7; color: var(--dark-gray); font-size: 0.76rem; font-weight: 500; width: fit-content;
}
.chan-chip i { color: var(--teal); font-size: 0.72rem; }

/* Fila de emoción */
.emo-box { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.emo-face { font-size: 1.7rem; line-height: 1; }
.emo-label { font-size: 0.78rem; font-weight: 700; color: var(--dark-gray); }

/* Prefijo destacado (AS-IS / TO-BE) */
.tag-prefix {
  display: inline-block; font-size: 0.6rem; font-weight: 800; letter-spacing: 0.4px;
  padding: 2px 7px; border-radius: 6px; margin-right: 6px; vertical-align: middle;
}
.tag-prefix.asis { background: #fee2e2; color: #991b1b; }
.tag-prefix.tobe { background: #fee2e2; color: var(--red); }

/* Criticidad badge */
.crit-badge { display: inline-block; padding: 4px 14px; border-radius: 20px; font-size: 0.78rem; font-weight: 700; }
.crit-baja { background: #dcfce7; color: #166534; }
.crit-media { background: #fef9c3; color: #854d0e; }
.crit-alta { background: #ffedd5; color: #9a3412; }
.crit-critica { background: #fee2e2; color: #991b1b; }
.crit-none { color: #c8ced4; }

@media (max-width: 640px) {
  .visor-header { padding: 12px 16px; }
  .visor-titles h1 { font-size: 1.1rem; }
  .visor-main { padding: 16px 12px 30px; }
}

/* ===================== Módulo de Permisos ===================== */
.side-btn-admin { margin-top: 6px; }
.perm-intro { color: var(--medium-gray); font-size: 0.92rem; line-height: 1.55; margin-bottom: 18px; max-width: 780px; }
#permScopeNote { display: block; margin-top: 4px; font-size: 0.84rem; color: var(--red); }
.perm-subtitle { font-size: 1.05rem; font-weight: 700; color: var(--dark-gray); margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.perm-subtitle i { color: var(--red); }
.perm-hint { color: var(--medium-gray); font-size: 0.86rem; margin-bottom: 14px; max-width: 780px; }

.perm-table td { padding-top: 8px; padding-bottom: 8px; }
.perm-user { display: flex; align-items: center; gap: 10px; }
.perm-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--teal); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.72rem; flex-shrink: 0;
  background-size: cover; background-position: center;
}
.perm-user-info { display: flex; flex-direction: column; gap: 0; min-width: 0; line-height: 1.25; }
.perm-user-name { font-weight: 600; color: var(--black); font-size: 0.88rem; }
.perm-user-mail { font-size: 0.74rem; color: var(--medium-gray); }
.perm-user-rol { font-size: 0.66rem; color: var(--red); font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.perm-cell { text-align: center; }
.perm-row-dirty { background: rgba(214,151,6,0.06); }

/* Switch */
.perm-switch { position: relative; display: inline-block; width: 38px; height: 20px; }
.perm-switch input { opacity: 0; width: 0; height: 0; }
.perm-slider { position: absolute; cursor: pointer; inset: 0; background: #cfd4da; border-radius: 24px; transition: 0.25s; }
.perm-slider::before { content: ''; position: absolute; height: 14px; width: 14px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: 0.25s; box-shadow: 0 1px 3px rgba(0,0,0,0.25); }
.perm-switch input:checked + .perm-slider { background: #16a34a; }
.perm-switch input:checked + .perm-slider::before { transform: translateX(18px); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }

/* Restricciones por CJM */
.perm-block { background: var(--white); border: 1px solid var(--border); border-radius: 14px; padding: 18px; box-shadow: var(--shadow); }
.perm-selectors { display: flex; gap: 16px; flex-wrap: wrap; }
.perm-selectors .form-field { flex: 1; min-width: 220px; }
.perm-selectors label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--medium-gray); margin-bottom: 6px; }
.perm-selectors select { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; font-family: inherit; font-size: 0.9rem; background: #fff; }
.rest-usuarios { margin-top: 18px; border-top: 1px dashed var(--border); padding-top: 16px; }
.rest-usuarios-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.rest-usuarios-head span { font-size: 0.88rem; color: var(--dark-gray); }
.rest-head-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.rest-marcar-todos { display: flex; align-items: center; gap: 6px; font-size: 0.84rem; font-weight: 600; color: var(--dark-gray); cursor: pointer; user-select: none; }
.rest-marcar-todos input { width: 16px; height: 16px; accent-color: var(--red); cursor: pointer; }

/* Buscador en permisos por usuario */
.perm-search { position: relative; max-width: 360px; margin-bottom: 14px; }
.perm-search i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #9aa1a9; font-size: 0.85rem; }
.perm-search input { width: 100%; padding: 10px 12px 10px 34px; border: 1px solid var(--border); border-radius: 10px; font-family: inherit; font-size: 0.9rem; background: #fff; }
.perm-search input:focus { outline: none; border-color: var(--red); }
.rest-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.rest-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; transition: 0.15s; }
.rest-item:hover { border-color: var(--red); }
.rest-item input { width: 16px; height: 16px; accent-color: var(--red); }
.rest-item .ri-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--teal); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 0.7rem; font-weight: 700; flex-shrink: 0; }
.rest-item .ri-info { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.rest-item .ri-name { font-size: 0.84rem; font-weight: 600; }
.rest-item .ri-mail { font-size: 0.72rem; color: var(--medium-gray); }

/* Botones de módulo deshabilitados por permiso */
.side-btn.disabled-perm { opacity: 0.4; position: relative; }
.side-btn.disabled-perm::after { content: '\f023'; font-family: 'Font Awesome 6 Free'; font-weight: 900; position: absolute; top: 6px; right: 8px; font-size: 0.7rem; }

@media (max-width: 820px) {
  .perm-table thead { display: none; }
  .perm-table tbody td { display: flex; justify-content: space-between; align-items: center; border: none; padding: 8px 16px; }
  .perm-table tbody td::before { content: attr(data-label); font-weight: 600; color: var(--medium-gray); font-size: 0.85rem; }
  .perm-table tbody tr { display: block; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 14px; padding: 8px 0; }
  .perm-table tbody td:first-child { border-bottom: 1px solid var(--border); padding-bottom: 12px; }
  .perm-table tbody td:first-child::before { content: ''; }
}
