/* MIRAI — Dashboard de clientes · estilos (sección Inicio)
   Reutiliza variables y tipografía de styles.css (:root, --ink, --muted, etc.) */

.dboard {
  display: flex;
  width: 100%;
  min-height: 100vh;
  background: #f6f6f7;
  color: var(--ink);
  font-family: var(--sans);
  letter-spacing: -0.005em;
}

/* ====== Sidebar ====== */
.dash-sb {
  position: sticky;
  top: 0;
  align-self: flex-start;
  width: 232px;
  flex: none;
  height: 100vh;
  background: #fff;
  border-right: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  padding: 8px 16px 22px;
}
.dash-sb__logo { display: block; padding: 6px 6px 18px; }
.dash-sb__logo img { height: 145px; width: auto; display: block; }
.dash-sb__nav { display: flex; flex-direction: column; gap: 4px; }
.dash-sb__foot { margin-top: auto; }
.dash-sb__item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  color: rgba(0,0,0,0.74);
  text-align: left;
  transition: background 200ms ease, color 200ms ease;
}
.dash-sb__item:hover { background: rgba(0,0,0,0.05); color: #000; }
.dash-sb__item.is-active { background: #000; color: #fff; }
.dash-sb__icon { display: inline-flex; width: 20px; justify-content: center; }
.dash-sb__scrim { display: none; }

/* ====== Main ====== */
.dash-main {
  flex: 1;
  min-width: 0;
  padding: 26px clamp(20px, 3vw, 40px) 56px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* ====== Header ====== */
.dash-head { display: flex; align-items: center; justify-content: space-between; gap: 20px 24px; flex-wrap: wrap; }
.dash-head__left { display: flex; align-items: center; gap: 14px; min-width: 0; }
/* Hamburger: oculto en desktop (mayor especificidad que .dash-iconbtn), visible sólo en mobile */
.dash-iconbtn.dash-head__menu { display: none; }
.dash-head__heading { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.dash-head__titlerow { display: flex; align-items: center; gap: 13px; }
.dash-head__channel-icon { display: inline-flex; align-items: center; flex: none; }
.dash-head__title { font-size: clamp(24px, 2.6vw, 32px); font-weight: 600; letter-spacing: -0.03em; line-height: 1; }
.dash-head__sub { color: var(--muted); font-size: 14px; margin-top: 0; line-height: 1.3; }
.dash-head__right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }

/* ====== Filtros / pastillas ====== */
.dash-filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dash-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  background: #fff;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  color: #000;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 180ms ease, background 180ms ease;
}
.dash-pill:hover { border-color: #000; }
.dash-pill--toggle.is-on { background: #000; color: #fff; border-color: #000; }

/* ====== Dropdown ====== */
.dd { position: relative; }
.dd__menu {
  position: absolute;
  top: calc(100% + 8px);
  min-width: 200px;
  background: #fff;
  border: 1px solid var(--rule-strong);
  border-radius: 14px;
  box-shadow: 0 16px 40px -18px rgba(0,0,0,0.28);
  padding: 6px;
  /* Por encima de drawers/modales (z-index 80) — importante para el modo
     portal, donde el menú se saca de su contenedor y pasa a competir por
     stacking directamente contra el resto de la página. */
  z-index: 200;
}
.dd__menu--left { left: 0; }
.dd__menu--right { right: 0; }
.dd__opt {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border: none;
  background: transparent;
  border-radius: 9px;
  font-family: var(--sans);
  font-size: 13px;
  color: #000;
  cursor: pointer;
  transition: background 160ms ease;
}
.dd__opt:hover { background: rgba(0,0,0,0.05); }
/* Opciones con checkbox (selección múltiple, ej. "Derivado a" del Tablero) */
.dd__opt--check { display: flex; align-items: center; gap: 9px; }
.dd__opt-check {
  flex: none; width: 16px; height: 16px; border-radius: 5px;
  border: 1.5px solid var(--rule-strong); display: inline-flex; align-items: center; justify-content: center;
  color: #fff; transition: background 140ms ease, border-color 140ms ease;
}
.dd__opt--check.is-sel .dd__opt-check { background: #4F46E5; border-color: #4F46E5; }
.dd__opt.is-sel { background: rgba(0,0,0,0.05); font-weight: 600; }

/* ====== Avatar perfil ====== */
.dash-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 999px;
  background: #fff; color: #000; border: 1px solid var(--rule-strong);
  cursor: pointer; transition: background 200ms ease, color 200ms ease, border-color 200ms ease;
}
.dash-avatar:hover { background: #000; color: #fff; border-color: #000; }

/* ====== Cards base ====== */
.dash-card {
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 16px;
  padding: 20px;
}
.dash-card__title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }

/* ====== Métricas ====== */
.dash-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}
.dash-metric {
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 200ms ease, box-shadow 200ms ease;
}
.dash-metric:hover { border-color: var(--rule-strong); box-shadow: 0 10px 26px -20px rgba(0,0,0,0.25); }
.dash-metric__label { font-size: 12.5px; color: var(--muted); }
.dash-metric__value { font-size: 30px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.05; margin-top: 2px; }
.dash-metric__value--text { font-size: 23px; word-break: break-word; }
.dash-metric__delta { font-size: 12.5px; font-weight: 500; }
.dash-metric__delta.is-up { color: #15803d; }
.dash-metric__delta.is-down { color: #b45309; }
.dash-metric__note { font-size: 11.5px; color: var(--muted-soft); }

/* ====== Charts grid ====== */
/* Mismas proporciones de columna que .dash-bottom (791/430/370) para que
   "Resultado de las consultas" quede del mismo ancho que "Zonas más buscadas"
   y "Canales" quede del mismo ancho que "Consultas no resueltas". */
.dash-charts {
  display: grid;
  grid-template-columns: minmax(0, 791fr) minmax(0, 430fr) minmax(0, 370fr);
  gap: 16px;
  align-items: stretch;
}
.dash-card--chart { display: flex; flex-direction: column; }
.dash-legend { display: flex; gap: 16px; margin-top: 10px; }
.dash-legend__item { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 999px; display: inline-block; }
.dot--dark { background: #000; }
.dot--gray { background: #b6b6b6; }

.dash-chart { position: relative; margin-top: 8px; width: 100%; }
.dash-chart svg { display: block; width: 100%; }
.dash-chart__axis { font-size: 10px; fill: var(--muted-soft); font-family: var(--mono); }
.dash-chart__tip {
  position: absolute;
  background: #000; color: #fff;
  border-radius: 10px; padding: 8px 10px;
  font-size: 11.5px; pointer-events: none;
  white-space: nowrap;
}
.dash-chart__tip-row { display: flex; align-items: center; gap: 7px; }
.dash-chart__tip-row b { margin-left: 4px; font-weight: 600; }

/* ====== Donut ====== */
.dash-results { display: flex; align-items: center; gap: 18px; margin-top: 14px; flex-wrap: wrap; }
.dash-results--interactive { justify-content: center; }
.dash-donut { flex: none; }
.dash-donut__total { font-size: 20px; font-weight: 600; fill: #000; transition: font-size 150ms ease; }
.dash-donut__total-label { font-size: 10px; fill: var(--muted); font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.08em; }
.dash-results__legend { flex: 1; min-width: 160px; display: flex; flex-direction: column; gap: 9px; list-style: none; }
.dash-results__legend li { display: flex; align-items: center; gap: 9px; font-size: 12.5px; }
.dash-results__dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.dash-results__name { color: var(--muted-strong); }
.dash-results__pct { margin-left: auto; font-weight: 600; }

/* ---- Fila interactiva (tarjeta "Resultado de las consultas") ---- */
.dash-results__row {
  cursor: pointer; padding: 5px 7px; margin: -5px -7px; border-radius: 7px;
  transition: opacity 180ms ease, background 180ms ease;
}
.dash-results__row:hover, .dash-results__row.is-active { background: rgba(0,0,0,0.045); }
.dash-results__row.is-dim { opacity: 0.4; }
.dash-results__row .dash-results__name { flex: none; }
.dash-results__bar { flex: 1; min-width: 32px; height: 5px; border-radius: 999px; background: rgba(0,0,0,0.07); overflow: hidden; }
.dash-results__bar-fill { display: block; height: 100%; border-radius: 999px; transition: width 700ms cubic-bezier(.65,0,.35,1); }
.mirai-dark .dash-results__row:hover, .mirai-dark .dash-results__row.is-active { background: rgba(255,255,255,0.07); }
.mirai-dark .dash-results__bar { background: rgba(255,255,255,0.1); }

/* ====== Canales ====== */
.dash-channels { display: flex; flex-direction: column; margin-top: 6px; }
.dash-channels__row { display: flex; align-items: center; gap: 14px; padding: 16px 0; }
.dash-channels__row.has-sep { border-top: 1px solid var(--rule); }
.dash-channels__icon { display: inline-flex; }
.dash-channels__body { display: grid; grid-template-columns: 1fr auto; row-gap: 2px; flex: 1; }
.dash-channels__name { font-size: 13px; color: var(--muted-strong); }
.dash-channels__pct { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; grid-row: 2; }
.dash-channels__sub { font-size: 11.5px; color: var(--muted-soft); grid-column: 1 / -1; }

/* ====== Bottom grid ====== */
.dash-bottom {
  display: grid;
  grid-template-columns: minmax(0, 791fr) minmax(0, 430fr) minmax(0, 370fr);
  gap: 16px;
  align-items: stretch;
}

/* ====== Tabla ====== */
.dash-table-wrap { margin-top: 14px; overflow-x: auto; }
.dash-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 600px; }
.dash-table th {
  text-align: left; font-weight: 500; color: var(--muted);
  font-size: 12px; padding: 0 10px 12px 0; white-space: nowrap;
}
.dash-table td { padding: 13px 10px 13px 0; border-top: 1px solid var(--rule); vertical-align: middle; white-space: nowrap; }
.dash-table tbody tr { cursor: pointer; transition: background 160ms ease; }
.dash-table tbody tr:hover { background: rgba(0,0,0,0.025); }
.dash-table__name { font-weight: 500; }
.dash-table__channel { display: inline-flex; align-items: center; gap: 8px; }
.dash-table__date { color: var(--muted); }
.dash-table__empty { text-align: center; color: var(--muted); padding: 30px 0; }

/* ====== Pastillas de estado ====== */
.dash-tag {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 500; white-space: nowrap;
}
.dash-tag.is-waiting    { background: #FEF3C7; color: #92400E; }
.dash-tag.is-qualified  { background: #DCFCE7; color: #166534; }
.dash-tag.is-emma       { background: #DCFCE7; color: #166534; }
.dash-tag.is-talking    { background: #E0F2FE; color: #075985; }
.dash-tag.is-unresolved { background: #FEE2E2; color: #991B1B; }
.dash-tag.is-manual     { background: #F1F1F1; color: #404040; }

/* ====== Listas (zonas / no resueltas) ====== */
.dash-list-card { display: flex; flex-direction: column; }
.dash-rank { list-style: none; display: flex; flex-direction: column; margin: 14px 0 4px; }
.dash-rank__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-top: 1px solid var(--rule); font-size: 13.5px; }
.dash-rank__row:first-child { border-top: none; }
.dash-rank__name { color: var(--ink); }
.dash-rank__val { font-weight: 600; font-variant-numeric: tabular-nums; }
.dash-rank__val--muted { color: var(--muted); }
.dash-rank--full { margin-top: 0; }
.dash-link {
  margin-top: auto; align-self: flex-start;
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: none; cursor: pointer;
  font-family: var(--sans); font-size: 13px; font-weight: 500; color: #000;
  padding: 12px 0 0; transition: gap 180ms ease;
}
.dash-link:hover { gap: 10px; }

/* ====== Iconbtn ====== */
.dash-iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 10px;
  background: transparent; border: 1px solid transparent; color: #000;
  cursor: pointer; transition: background 160ms ease;
}
.dash-iconbtn:hover { background: rgba(0,0,0,0.06); }

/* ====== Drawer ====== */
.dash-drawer { position: fixed; inset: 0; z-index: 80; }
.dash-drawer__scrim { position: absolute; inset: 0; background: rgba(0,0,0,0.4); animation: dashFade 180ms ease; }
.dash-drawer__panel {
  position: absolute; top: 0; right: 0; height: 100%;
  width: min(520px, 100%); background: #fff;
  display: flex; flex-direction: column;
  box-shadow: -20px 0 50px -30px rgba(0,0,0,0.4);
  animation: dashSlide 240ms cubic-bezier(.2,.7,.2,1);
}
@keyframes dashFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes dashSlide { from { transform: translateX(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.dash-drawer__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 22px 22px 16px; border-bottom: 1px solid var(--rule); }
.dash-drawer__head-main { display: flex; gap: 12px; align-items: center; }
.dash-drawer__icon { display: inline-flex; }
.dash-drawer__name { font-size: 19px; font-weight: 600; }
.dash-drawer__meta { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.dash-drawer__time { font-size: 12px; color: var(--muted); }
.dash-drawer__body { padding: 8px 22px 22px; overflow-y: auto; flex: 1; }
.dash-drawer__section { padding: 18px 0; border-bottom: 1px solid var(--rule); }
.dash-drawer__section:last-child { border-bottom: none; }
.dash-drawer__title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 12px; font-family: var(--mono); }
.dash-drawer__summary { font-size: 14px; line-height: 1.6; color: var(--muted-strong); white-space: pre-wrap; }
.dash-drawer__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.dash-drawer__field { display: flex; flex-direction: column; gap: 3px; }
.dash-drawer__field-k { font-size: 11.5px; color: var(--muted-soft); }
.dash-drawer__field-v { font-size: 13.5px; color: var(--ink); }
.dash-drawer__collapse {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  background: transparent; border: none; cursor: pointer; padding: 0;
  font-family: var(--sans); font-size: 14px; font-weight: 500; color: #000;
}
.dash-drawer__chev { display: inline-flex; transition: transform 220ms ease; }
.dash-drawer__chev.is-open { transform: rotate(180deg); }
.dash-drawer__foot { padding: 16px 22px; border-top: 1px solid var(--rule); }

/* ====== Chat (lectura) ====== */
.dash-chat { margin-top: 16px; display: flex; flex-direction: column; gap: 12px; }
.dash-chat__msg { display: flex; flex-direction: column; max-width: 82%; }
.dash-chat__msg.is-lead { align-self: flex-start; align-items: flex-start; }
.dash-chat__msg.is-emma { align-self: flex-end; align-items: flex-end; }
.dash-chat__bubble { padding: 10px 13px; border-radius: 14px; font-size: 13.5px; line-height: 1.45; }
.dash-chat__msg.is-lead .dash-chat__bubble { background: #f1f1f2; color: #000; border-bottom-left-radius: 4px; }
.dash-chat__msg.is-emma .dash-chat__bubble { background: #000; color: #fff; border-bottom-right-radius: 4px; }
.dash-chat__time { font-size: 10.5px; color: var(--muted-soft); margin-top: 4px; }

/* ====== Modal ====== */
.dash-modal { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; padding: 20px; }
.dash-modal__scrim { position: absolute; inset: 0; background: rgba(0,0,0,0.4); animation: dashFade 180ms ease; }
.dash-modal__box {
  position: relative; background: #fff; border-radius: 18px;
  width: min(560px, 100%); max-height: 80vh; display: flex; flex-direction: column;
  box-shadow: 0 30px 70px -30px rgba(0,0,0,0.45); animation: dashPop 200ms cubic-bezier(.2,.7,.2,1);
}
@keyframes dashPop { from { transform: scale(0.97); opacity: 0; } to { transform: none; opacity: 1; } }
.dash-modal__head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--rule); }
.dash-modal__head h3 { font-size: 16px; font-weight: 600; }
.dash-modal__body { padding: 18px 20px; overflow-y: auto; }
.dash-modal-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.dash-modal-table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding-bottom: 10px; }
.dash-modal-table td { padding: 11px 12px 11px 0; border-top: 1px solid var(--rule); vertical-align: top; }
.dash-modal-table__pct { font-weight: 600; white-space: nowrap; }
.dash-modal-table__desc { color: var(--muted); }

/* ====== Toast ====== */
.dash-toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: #000; color: #fff; padding: 11px 18px; border-radius: 999px;
  font-size: 13px; z-index: 90; box-shadow: 0 14px 36px -16px rgba(0,0,0,0.5);
  animation: dashToast 200ms ease;
}
@keyframes dashToast { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ====== Responsive ====== */
@media (max-width: 1180px) {
  .dash-charts { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .dash-card--chart { grid-column: 1 / -1; }
  .dash-bottom { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .dash-card--table { grid-column: 1 / -1; }
}
@media (max-width: 860px) {
  /* Sidebar off-canvas */
  .dash-sb {
    position: fixed; top: 0; left: 0; z-index: 70;
    transform: translateX(-100%); transition: transform 240ms cubic-bezier(.2,.7,.2,1);
    box-shadow: 20px 0 50px -30px rgba(0,0,0,0.4);
  }
  .dash-sb.is-open { transform: none; }
  .dash-sb__scrim {
    display: block; position: fixed; inset: 0; z-index: 65;
    background: rgba(0,0,0,0.4); opacity: 0; pointer-events: none; transition: opacity 220ms ease;
  }
  .dash-sb__scrim.is-open { opacity: 1; pointer-events: auto; }
  .dash-iconbtn.dash-head__menu { display: inline-flex; }
  .dash-head__right { width: 100%; justify-content: flex-end; gap: 10px; }
}
@media (max-width: 620px) {
  /* Evitar que el main desborde horizontalmente */
  .dash-main { padding: 16px 14px 40px; overflow-x: hidden; }
  .dash-main--inbox { padding: 14px 12px 20px; }
  /* Grid: minmax(0) evita que min-content de hijos (tabla 600px) expanda el track */
  .dash-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-charts { grid-template-columns: minmax(0, 1fr); }
  .dash-bottom { grid-template-columns: minmax(0, 1fr); }
  .dash-filters { width: 100%; }
  /* Título más compacto */
  .dash-head__title { font-size: 26px; }
  /* Ocultar tiempo de actualización — deja solo el ícono */
  .dash-refresh__time { display: none; }
  /* Valores de métricas más pequeños para 2 columnas */
  .dash-metric__value { font-size: 24px; }
  /* Config: botón WhatsApp debajo del texto */
  .dash-config__row { flex-wrap: wrap; gap: 10px; }
  .dash-config__wa { width: 100%; justify-content: center; }
  /* Tabla: ocultar columnas secundarias, quitar min-width fija */
  .dash-table { min-width: 0; font-size: 12px; }
  .dash-table td { white-space: normal; }
  /* Ocultar: Intención (3), Zona (4), Presupuesto (5), Fecha (7) */
  .dash-table th:nth-child(3),
  .dash-table td:nth-child(3),
  .dash-table th:nth-child(4),
  .dash-table td:nth-child(4),
  .dash-table th:nth-child(5),
  .dash-table td:nth-child(5),
  .dash-table th:nth-child(7),
  .dash-table td:nth-child(7) { display: none; }
  /* Donut: apilar verticalmente en tarjeta chica */
  .dash-results { flex-direction: column; align-items: flex-start; gap: 12px; }
  .dash-results--interactive { align-items: center; }
  .dash-results__legend { min-width: 0; width: 100%; }
}
@media (max-width: 480px) {
  /* Título aún más compacto en teléfonos pequeños */
  .dash-head__title { font-size: 20px; }
  /* Ocultar subtítulo para ganar espacio vertical */
  .dash-head__sub { display: none; }
  /* Pills de filtro más pequeñas */
  .dash-pill { padding: 7px 10px; font-size: 12px; gap: 5px; }
  /* Valores de métricas compactos */
  .dash-metric__value { font-size: 22px; }
  /* Intenciones: label flexible, cortar con ellipsis si es muy largo */
  .dash-intents__row { grid-template-columns: 20px 1fr minmax(36px, 80px) auto; }
  .dash-intents__label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* Reducir gap del header */
  .dash-head { gap: 12px 16px; }
}

/* ====== Páginas de canal (WhatsApp / Instagram) ====== */
/* Sidebar activo por canal */
.dash-sb__item.is-active.is-whatsapp { background: #25D366; color: #fff; }
.dash-sb__item.is-active.is-instagram { background: linear-gradient(90deg, #8134AF 0%, #C837AB 38%, #F35369 70%, #F58529 100%); color: #fff; }
.dash-sb__item.is-active.is-crm { background: #C0003B; color: #fff; }
.dash-sb__item.is-active.is-crm:hover { background: #A0002E; }
.mirai-dark .dash-sb__item.is-active.is-crm { background: #C0003B; color: #fff; }
.mirai-dark .dash-sb__item.is-active.is-crm:hover { background: #A0002E; }
.dash-sb__item.is-active.is-tablero { background: #4F46E5; color: #fff; }
.dash-sb__item.is-active.is-tablero:hover { background: #4338CA; }
.mirai-dark .dash-sb__item.is-active.is-tablero { background: #4F46E5; color: #fff; }
.mirai-dark .dash-sb__item.is-active.is-tablero:hover { background: #4338CA; }

/* Tendencias por canal */
.dash-cmetrics.is-whatsapp .dash-metric__delta.is-up { color: #1FA855; }
.dash-cmetrics.is-instagram .dash-metric__delta.is-up { color: #E1306C; }

/* Intenciones más frecuentes */
.dash-intents { list-style: none; display: flex; flex-direction: column; gap: 17px; margin-top: 20px; }
.dash-intents__row { display: grid; grid-template-columns: auto auto minmax(40px, 1fr) auto; align-items: center; gap: 12px; font-size: 13.5px; }
.dash-intents__rank { color: var(--muted); }
.dash-intents__label { white-space: nowrap; }
.dash-intents__bar { height: 6px; border-radius: 999px; background: rgba(0,0,0,0.07); overflow: hidden; }
.dash-intents__fill { display: block; height: 100%; border-radius: 999px; transition: width 320ms cubic-bezier(.2,.7,.2,1); }
.dash-intents__pct { font-weight: 600; font-variant-numeric: tabular-nums; }

/* Panel "Más información" (colapsable) */
.dash-more { background: #fff; border: 1px solid var(--rule); border-radius: 16px; overflow: hidden; }
.dash-more__head { display: flex; align-items: center; gap: 18px; width: 100%; padding: 22px 24px; background: transparent; border: none; cursor: pointer; text-align: left; position: relative; font-family: var(--sans); }
.dash-more__strip { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.dash-more__icon { display: inline-flex; align-items: center; justify-content: center; width: 52px; height: 52px; border-radius: 999px; flex: none; margin-left: 8px; }
.dash-more__text { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.dash-more__title { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.dash-more__sub { font-size: 13.5px; color: var(--muted); }
.dash-more__arrow { display: inline-flex; flex: none; transition: transform 260ms ease; }
.dash-more.is-open .dash-more__arrow { transform: rotate(90deg); }
.dash-more__wrap { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 340ms cubic-bezier(.2,.7,.2,1); }
.dash-more.is-open .dash-more__wrap { grid-template-rows: 1fr; }
.dash-more__inner { overflow: hidden; }
.dash-more__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 26px 36px; padding: 6px 24px 26px; border-top: 1px solid var(--rule); }
.dash-more__sectitle { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-family: var(--mono); margin-bottom: 14px; }

.dash-more__list { list-style: none; display: flex; flex-direction: column; }
.dash-more__consult { display: grid; grid-template-columns: 1fr auto; column-gap: 10px; row-gap: 3px; align-items: center; padding: 11px 0; border-top: 1px solid var(--rule); }
.dash-more__consult:first-child { border-top: none; }
.dash-more__cname { grid-column: 1; grid-row: 1; font-weight: 500; font-size: 13.5px; }
.dash-more__cmeta { grid-column: 1; grid-row: 2; font-size: 12px; color: var(--muted); }
.dash-more__consult .dash-tag { grid-column: 2; grid-row: 1; justify-self: end; }
.dash-more__ctime { grid-column: 2; grid-row: 2; justify-self: end; font-size: 11.5px; color: var(--muted-soft); }

.dash-peak { list-style: none; display: flex; flex-direction: column; gap: 14px; }
.dash-peak__row { display: grid; grid-template-columns: 64px 1fr; align-items: center; gap: 12px; font-size: 13px; }
.dash-peak__label { color: var(--muted-strong); white-space: nowrap; font-variant-numeric: tabular-nums; }
.dash-peak__bar { height: 6px; border-radius: 999px; background: rgba(0,0,0,0.07); overflow: hidden; }
.dash-peak__fill { display: block; height: 100%; border-radius: 999px; }

@media (max-width: 760px) {
  .dash-more__grid { grid-template-columns: 1fr; gap: 22px; }
}

/* ============================================================
   MEJORAS v5 — interactividad, refresh, config, empty, dark mode
   ============================================================ */

/* ---- Animaciones de entrada (tarjetas y gráficos) ---- */
@keyframes dashCardIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes dashSpin { to { transform: rotate(360deg); } }

.dash-fade > * { animation: dashCardIn 460ms cubic-bezier(.2,.7,.2,1) both; }
.dash-fade > *:nth-child(2) { animation-delay: 55ms; }
.dash-fade > *:nth-child(3) { animation-delay: 110ms; }
.dash-fade > *:nth-child(4) { animation-delay: 165ms; }
.dash-fade > *:nth-child(5) { animation-delay: 220ms; }
.dash-fade > *:nth-child(6) { animation-delay: 275ms; }
.dash-fade.is-updating { opacity: 0.55; transition: opacity 160ms ease; }

/* ---- Hover sutil en tarjetas (elevación + borde) ---- */
.dash-card, .dash-metric, .dash-more {
  transition: border-color 220ms ease, box-shadow 220ms ease, transform 220ms ease, background 220ms ease;
}
.dash-card:hover { border-color: var(--rule-strong); box-shadow: 0 14px 32px -24px rgba(0,0,0,0.32); transform: translateY(-2px); }
.dash-metric:hover { transform: translateY(-2px); }

/* ---- Transiciones suaves de elementos de datos ---- */
.dash-results__pct, .dash-metric__value { transition: color 200ms ease; }
.dash-donut__seg { transition: opacity 180ms ease; cursor: default; }
.dash-donut:hover .dash-donut__seg { opacity: 0.55; }
.dash-donut .dash-donut__seg:hover { opacity: 1; }

/* ---- Dona interactiva (tarjeta "Resultado de las consultas") ---- */
.dash-results--interactive .dash-donut__seg {
  cursor: pointer;
  transition: opacity 180ms ease,
    stroke-dasharray 700ms cubic-bezier(.65,0,.35,1), stroke-dashoffset 700ms cubic-bezier(.65,0,.35,1);
}
.dash-results--interactive .dash-donut__seg.is-dim { opacity: 0.35; }
.dash-results--interactive .dash-donut__seg.is-active { opacity: 1; }

/* ---- Control de actualización (refresh) ---- */
.dash-refresh { display: inline-flex; align-items: center; gap: 10px; }
.dash-refresh__time { font-size: 12px; color: var(--muted); font-family: var(--mono); white-space: nowrap; }
.dash-refresh__btn { display: inline-flex; align-items: center; justify-content: center; }
.dash-refresh__btn svg { transition: transform 200ms ease; }
.dash-refresh__btn:not(:disabled):hover svg { transform: rotate(-35deg); }
.dash-refresh__btn.is-spinning svg { animation: dashSpin 0.8s linear infinite; }
.dash-refresh__btn:disabled { cursor: default; opacity: 0.85; }

/* ---- Empty state de canal ---- */
.dash-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; text-align: center; padding: 64px 24px;
  background: #fff; border: 1px dashed var(--rule-strong); border-radius: 16px;
  animation: dashCardIn 460ms cubic-bezier(.2,.7,.2,1) both;
}
.dash-empty__icon { display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 56px; border-radius: 16px; }
.dash-empty__text { font-size: 15px; color: var(--muted-strong); margin: 0; max-width: 360px; }

/* ---- Configuración ---- */
.dash-config { display: flex; flex-direction: column; gap: 18px; max-width: 720px; }
.dash-config__card { display: flex; flex-direction: column; gap: 6px; }
.dash-config__row {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 16px 0; border-top: 1px solid var(--rule);
}
.dash-config__card .dash-config__row:first-of-type { border-top: none; }
.dash-config__info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.dash-config__label { font-size: 14px; font-weight: 500; color: var(--ink); }
.dash-config__label--icon { display: inline-flex; align-items: center; gap: 7px; }
.dash-config__ch-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dash-config__value { font-size: 14px; color: var(--muted-strong); font-family: var(--mono); }
.dash-config__hint { font-size: 12.5px; color: var(--muted); max-width: 420px; line-height: 1.45; }
.dash-config__wa { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; flex: none; }

/* Toggles por canal */
.dash-switch--wa.is-on     { background: #25D366; }
.dash-switch--ig.is-on     { background: linear-gradient(90deg, #8134AF 0%, #C837AB 60%, #F58529 100%); }
.dash-switch--crm.is-on    { background: #C0003B; }
.dash-switch--rastreo.is-on { background: #1E90FF; }
.dash-switch--tickets.is-on { background: #1F3A5C; }
.dash-switch--wa.is-on .dash-switch__knob,
.dash-switch--ig.is-on .dash-switch__knob,
.dash-switch--crm.is-on .dash-switch__knob,
.dash-switch--rastreo.is-on .dash-switch__knob,
.dash-switch--tickets.is-on .dash-switch__knob { background: #fff; }

/* Switch (Dark Mode) */
.dash-switch {
  position: relative; width: 50px; height: 28px; border-radius: 999px; flex: none;
  background: rgba(0,0,0,0.16); border: none; cursor: pointer; padding: 0;
  transition: background 220ms ease;
}
.dash-switch.is-on { background: #000; }
.dash-switch__knob {
  position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.3); transition: transform 220ms cubic-bezier(.2,.7,.2,1);
}
.dash-switch.is-on .dash-switch__knob { transform: translateX(22px); }

/* ============================================================
   DARK MODE — se activa con .mirai-dark en <html> (solo dashboard)
   ============================================================ */
.mirai-dark .dboard {
  --ink: #f2f3f5;
  --muted: rgba(255,255,255,0.60);
  --muted-soft: rgba(255,255,255,0.42);
  --muted-strong: rgba(255,255,255,0.84);
  --rule: rgba(255,255,255,0.10);
  --rule-strong: rgba(255,255,255,0.20);
  --chart-ink: #f2f3f5;
  --chart-leads: #6b7280;
  --chart-grid: rgba(255,255,255,0.12);
  background: #0e0f12;
  color: var(--ink);
}
.mirai-dark .dash-sb { background: #15171c; border-right-color: var(--rule); }
.mirai-dark .dash-card,
.mirai-dark .dash-metric,
.mirai-dark .dash-more,
.mirai-dark .dash-empty,
.mirai-dark .dash-drawer__panel,
.mirai-dark .dash-modal__box { background: #15171c; border-color: var(--rule); }
.mirai-dark .dash-empty { border-style: dashed; border-color: var(--rule-strong); }
.mirai-dark .dash-pill,
.mirai-dark .dash-avatar { background: #15171c; color: var(--ink); border-color: var(--rule-strong); }
.mirai-dark .dash-sb__item { color: rgba(255,255,255,0.74); }
.mirai-dark .dash-sb__item:hover { background: rgba(255,255,255,0.07); color: #fff; }
.mirai-dark .dash-sb__item.is-active { background: #fff; color: #000; }
.mirai-dark .dash-pill--toggle.is-on { background: #fff; color: #000; border-color: #fff; }
.mirai-dark .dash-avatar:hover { background: #fff; color: #000; border-color: #fff; }
.mirai-dark .dash-iconbtn:hover { background: rgba(255,255,255,0.09); }
.mirai-dark .dash-table tbody tr:hover { background: rgba(255,255,255,0.04); }
.mirai-dark .dash-switch { background: rgba(255,255,255,0.18); }
.mirai-dark .dash-switch.is-on { background: #fff; }
.mirai-dark .dash-switch.is-on .dash-switch__knob { background: #000; }
.mirai-dark .dash-donut__total { fill: var(--ink); }
.mirai-dark .dot--dark { background: #f2f3f5; }
/* Paleta gris (data-driven inline) -> invertida para leerse en oscuro */
.mirai-dark .dash-intents__fill { filter: invert(1) brightness(1.05); }
.mirai-dark .dash-intents__bar,
.mirai-dark .dash-peak__bar { background: rgba(255,255,255,0.10); }
.mirai-dark .dash-modal__scrim,
.mirai-dark .dash-drawer__scrim { background: rgba(0,0,0,0.6); }

/* ---- Accesibilidad: respeta reduce motion ---- */
@media (prefers-reduced-motion: reduce) {
  .dash-fade > *, .dash-empty { animation: none !important; }
  .dash-refresh__btn.is-spinning svg { animation-duration: 1.6s; }
  .dash-card:hover, .dash-metric:hover { transform: none; }
}

/* ============================================================
   DARK MODE — fix de legibilidad de textos (solo color)
   La regla global `h1..h4 { color:#000 }` y varios botones con
   color:#000 quedaban ilegibles en oscuro. Acá se fuerzan a claro
   SIN tocar layout, tamaños, animaciones ni colores de marca.
   ============================================================ */
.mirai-dark .dboard h1,
.mirai-dark .dboard h2,
.mirai-dark .dboard h3,
.mirai-dark .dboard h4 { color: var(--ink); }
/* Botones e íconos que eran negros */
.mirai-dark .dash-iconbtn,
.mirai-dark .dash-link,
.mirai-dark .dash-drawer__collapse { color: var(--ink); }
.mirai-dark .dash-sb__item:hover { color: #fff; }
/* Menús desplegables (período, canal, perfil) */
.mirai-dark .dd__menu { background: #15171c; border-color: var(--rule-strong); }
.mirai-dark .dd__opt { color: var(--ink); }
.mirai-dark .dd__opt:hover,
.mirai-dark .dd__opt.is-sel { background: rgba(255,255,255,0.08); }
.mirai-dark .dd__opt-check { border-color: var(--rule-strong); }
.mirai-dark .dd__opt--check.is-sel .dd__opt-check { background: #6366F1; border-color: #6366F1; }
/* Burbuja del lead en el detalle (mantiene jerarquía, legible en oscuro) */
.mirai-dark .dash-chat__msg.is-lead .dash-chat__bubble { background: #23262e; color: var(--ink); }

/* ---- Logo del sidebar: claro por defecto, blanco en dark mode ---- */
.dash-sb__logo img.dash-sb__logo-dark { display: none; }
.mirai-dark .dash-sb__logo img.dash-sb__logo-light { display: none; }
.mirai-dark .dash-sb__logo img.dash-sb__logo-dark { display: block; }

/* Dark mode: la opción activa de canal conserva su color distintivo (igual que claro) */
.mirai-dark .dash-sb__item.is-active.is-whatsapp { background: #25D366; color: #fff; }
.mirai-dark .dash-sb__item.is-active.is-instagram { background: linear-gradient(90deg, #8134AF 0%, #C837AB 38%, #F35369 70%, #F58529 100%); color: #fff; }

/* ============================================================
   INBOX EN TIEMPO REAL (WhatsApp / Instagram)
   Vista compartida de 3 columnas: lista · conversación · lead.
   Acento por canal vía --ibx-*: verde WhatsApp / gradiente Instagram.
   ============================================================ */
.dash-main--inbox { height: 100vh; overflow: hidden; padding: 22px 18px 18px 12px; gap: 14px; }

.dash-inbox {
  position: relative;
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: minmax(244px, 284px) minmax(0, 1fr) minmax(280px, 306px);
  gap: 14px;
  /* WhatsApp (default) */
  --ibx-accent: #1FA855;
  --ibx-accent-soft: rgba(37,211,102,0.14);
  --ibx-grad: #25D366;
  --ibx-send: #25D366;
  --ibx-check: #53bdeb;
  --ibx-bubble-sent: #d9fdd3;
  --ibx-knob: #fff;
}
.dash-inbox.is-instagram {
  --ibx-accent: #E1306C;
  --ibx-accent-soft: rgba(225,48,108,0.10);
  --ibx-grad: linear-gradient(135deg, #F58529 0%, #DD2A7B 55%, #8134AF 100%);
  --ibx-send: linear-gradient(135deg, #F58529 0%, #DD2A7B 55%, #8134AF 100%);
  --ibx-check: #E1306C;
  --ibx-bubble-sent: #fdeaf3;
}
.dash-inbox.is-crm {
  --ibx-accent: #C0003B;
  --ibx-accent-soft: rgba(192,0,59,0.09);
  --ibx-grad: #C0003B;
  --ibx-send: #C0003B;
  --ibx-check: #C0003B;
  --ibx-bubble-sent: #fde8ed;
  --ibx-knob: #fff;
}
/* ícono circular CRM en el header */
.dash-head__crm-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: #fff;
}
.dash-inbox.hide-lead { grid-template-columns: minmax(244px, 284px) minmax(0, 1fr); }

/* Columnas tipo card (lista y conversación) */
.dash-ibx__col {
  background: #fff; border: 1px solid var(--rule); border-radius: 18px;
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
}
/* Riel derecho: stack de cards que llena el alto (Acciones rápidas pegada abajo) */
.dash-ibx__rail { display: flex; flex-direction: column; gap: 14px; min-height: 0; overflow: hidden; }
.dash-ibx__card { background: #fff; border: 1px solid var(--rule); border-radius: 18px; }
/* La tarjeta de detalles crece para ocupar el espacio disponible */
.dash-ibx__card--grow { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.dash-ibx__card--grow .dash-ibx__lead-body { flex: 1; min-height: 0; overflow-y: auto; }

/* Puntito de estado (semántico, igual en ambos canales) */
.dash-ibx__dot { width: 8px; height: 8px; border-radius: 999px; display: inline-block; flex: none; }
.dash-ibx__dot.is-bot { background: #22C55E; }
.dash-ibx__dot.is-waiting { background: #F59E0B; }
.dash-ibx__dot.is-agent { background: #94A3B8; }

/* ---- Avatar (iniciales con color determinista) ---- */
.dash-ibx__avatar { position: relative; display: inline-flex; flex: none; border-radius: 50%; }
.dash-ibx__avatar.has-ring { padding: 2px; background: linear-gradient(135deg, #F58529, #DD2A7B 50%, #8134AF); }
.dash-ibx__avatar-circle {
  width: 100%; height: 100%; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; line-height: 1; box-sizing: border-box;
}
.dash-ibx__avatar.has-ring .dash-ibx__avatar-circle { border: 2px solid #fff; }
.dash-ibx__online { position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 999px; background: #22C55E; border: 2px solid #fff; }

/* ====== Columna izquierda: lista ====== */
.dash-ibx__list-head { padding: 18px 18px 0; }
.dash-ibx__list-titlerow { display: flex; align-items: center; gap: 10px; }
.dash-ibx__list-title { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.dash-ibx__count { background: var(--ibx-accent-soft); color: var(--ibx-accent); font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; }
.dash-ibx__list-tools { margin-left: auto; }
.dash-ibx__toolbtn { width: 34px; height: 34px; border-radius: 10px; border: none; background: transparent; color: var(--muted-strong); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.dash-ibx__toolbtn:hover { background: rgba(0,0,0,0.06); }

.dash-ibx__search {
  display: flex; align-items: center; gap: 9px; margin-top: 14px;
  padding: 10px 13px; border-radius: 12px; background: rgba(0,0,0,0.04);
  border: 1px solid transparent; color: var(--muted); transition: border-color 160ms ease, background 160ms ease;
}
.dash-ibx__search:focus-within { border-color: var(--rule-strong); background: #fff; }
.dash-ibx__search input { flex: 1; min-width: 0; border: none; background: transparent; outline: none; font-family: var(--sans); font-size: 13.5px; color: var(--ink); }

.dash-ibx__tabs { display: flex; gap: 18px; margin-top: 14px; border-bottom: 1px solid var(--rule); }
.dash-ibx__tab {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 1px 11px; cursor: pointer;
  background: transparent; border: none; border-bottom: 2px solid transparent; margin-bottom: -1px;
  font-family: var(--sans); font-size: 13px; font-weight: 500; color: var(--muted);
  transition: color 160ms ease, border-color 160ms ease;
}
.dash-ibx__tab:hover { color: var(--ink); }
.dash-ibx__tab.is-on { color: var(--ink); font-weight: 600; border-bottom-color: var(--ibx-accent); }
.dash-ibx__tab-n { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: rgba(0,0,0,0.06); color: var(--muted-strong); }
.dash-ibx__tab.is-on .dash-ibx__tab-n { background: var(--ibx-accent-soft); color: var(--ibx-accent); }

.dash-ibx__items { flex: 1; min-height: 0; overflow-y: auto; padding: 8px; }
.dash-ibx__item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 11px 12px; border-radius: 14px; border: none; background: transparent; cursor: pointer;
  border-left: 3px solid transparent; transition: background 150ms ease;
}
.dash-ibx__item:hover { background: rgba(0,0,0,0.035); }
.dash-ibx__item.is-active { background: var(--ibx-accent-soft); border-left-color: var(--ibx-accent); }
.dash-ibx__item .dash-ibx__avatar { width: 46px; height: 46px; }
.dash-ibx__item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.dash-ibx__item-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.dash-ibx__item-name { font-size: 14px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-ibx__item-time { font-size: 11px; color: var(--muted-soft); flex: none; }
.dash-ibx__item-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dash-ibx__item-last { font-size: 12.5px; color: var(--muted); line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dash-ibx__item-right { display: flex; flex-direction: column; align-items: flex-end; gap: 7px; flex: none; }
.dash-ibx__badge {
  min-width: 19px; height: 19px; padding: 0 6px; border-radius: 999px; background: var(--ibx-accent); color: #fff;
  font-size: 11px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center;
}
.dash-inbox.is-instagram .dash-ibx__badge { background: var(--ibx-grad); }
.dash-ibx__empty-list { padding: 28px 16px; text-align: center; font-size: 13px; color: var(--muted); }

.dash-ibx__list-foot { display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--rule); font-size: 12px; color: var(--muted); }
.dash-ibx__live { width: 7px; height: 7px; border-radius: 999px; background: #22C55E; box-shadow: 0 0 0 0 rgba(34,197,94,0.5); animation: ibxPulse 2s infinite; }
@keyframes ibxPulse { 0% { box-shadow: 0 0 0 0 rgba(34,197,94,0.45); } 70% { box-shadow: 0 0 0 6px rgba(34,197,94,0); } 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); } }

/* ====== Columna central: conversación ====== */
.dash-ibx__conv { min-width: 0; }
.dash-ibx__conv--empty { align-items: center; justify-content: center; gap: 12px; color: var(--muted); padding: 40px; text-align: center; }
.dash-ibx__conv-emptyicon { display: inline-flex; color: var(--muted-soft); }

.dash-ibx__conv-head { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--rule); }
.dash-ibx__back { display: none; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 9px; border: none; background: transparent; color: var(--ink); cursor: pointer; }
.dash-ibx__back svg { transform: rotate(90deg); }
.dash-ibx__conv-id { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.dash-ibx__conv-name { font-size: 15px; font-weight: 600; }
.dash-ibx__conv-sub { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.dash-ibx__conv-handle { color: var(--muted); }

/* Botones del inbox */
.dash-ibx__btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 14px; border-radius: 11px; cursor: pointer; white-space: nowrap;
  background: #fff; border: 1px solid var(--rule-strong); color: var(--ink);
  font-family: var(--sans); font-size: 12.5px; font-weight: 500;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, opacity 160ms ease;
}
.dash-ibx__btn:hover { border-color: #000; }
.dash-ibx__btn--solid { background: #000; color: #fff; border-color: #000; }
.dash-ibx__btn--solid:hover { opacity: 0.88; }
.dash-ibx__btn--accent { background: var(--ibx-grad); color: #fff; border: none; }
.dash-ibx__btn--accent:hover { opacity: 0.92; }
.dash-ibx__btn--block { width: 100%; padding: 11px 14px; }
.dash-ibx__btn--diagnosis { background: #22C55E; color: #fff; border: none; }
.dash-ibx__btn--diagnosis:hover { opacity: 0.9; }
.dash-ibx__kebab { width: 38px; height: 38px; padding: 0; }

/* Banner rojo de control manual (bajo el header) */
.dash-ibx__takeover {
  display: flex; align-items: center; gap: 9px; padding: 11px 18px;
  background: #FEF2F2; color: #DC2626; font-size: 13px; font-weight: 500; border-bottom: 1px solid var(--rule);
}
.dash-ibx__takeover b { font-weight: 700; }
.dash-ibx__pausebars { display: inline-flex; gap: 2px; }
.dash-ibx__pausebars i { width: 3px; height: 12px; background: #DC2626; border-radius: 1px; display: block; }

/* Área de mensajes */
.dash-ibx__msgs { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 22px; display: flex; flex-direction: column; gap: 8px; }
.dash-ibx__msgs--whatsapp {
  background-color: #fff;
  background-image: none;
}
.dash-ibx__datechip { align-self: center; margin: 4px auto 10px; padding: 4px 12px; border-radius: 8px; background: rgba(255,255,255,0.85); color: #5b6b73; font-size: 11.5px; font-weight: 500; box-shadow: 0 1px 2px rgba(0,0,0,0.08); }
.dash-ibx__msgs--instagram .dash-ibx__datechip { background: rgba(0,0,0,0.05); color: var(--muted); box-shadow: none; }

.dash-ibx__event {
  align-self: center; display: flex; align-items: center; gap: 6px; margin: 4px auto;
  padding: 5px 12px; border-radius: 10px; max-width: 85%;
  background: #fef3e2; color: #9a5b12; font-size: 11.5px; font-weight: 500; text-align: center;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.dash-ibx__event svg { flex-shrink: 0; color: #d99a3f; }
.dash-ibx__event-time { color: #b8894a; font-weight: 400; margin-left: 2px; }

.dash-ibx__msg { display: flex; flex-direction: column; max-width: 72%; }
.dash-ibx__msg.is-lead { align-self: flex-start; align-items: flex-start; }
.dash-ibx__msg.is-emma, .dash-ibx__msg.is-agent { align-self: flex-end; align-items: flex-end; }
.dash-ibx__sender { font-size: 10.5px; font-weight: 600; color: var(--ibx-accent); margin: 0 4px 2px; }
.dash-ibx__bubble {
  position: relative; padding: 7px 11px; border-radius: 12px; font-size: 13.5px; line-height: 1.42;
  box-shadow: 0 1px 1px rgba(0,0,0,0.07); word-wrap: break-word;
}
.dash-ibx__msg.is-lead .dash-ibx__bubble { background: #fff; color: #111; border-top-left-radius: 4px; }
.dash-ibx__msg.is-emma .dash-ibx__bubble, .dash-ibx__msg.is-agent .dash-ibx__bubble { background: var(--ibx-bubble-sent); color: #111; border-top-right-radius: 4px; }
.dash-ibx__msgs--instagram .dash-ibx__msg.is-lead .dash-ibx__bubble { background: #f0f0f0; box-shadow: none; }
.dash-ibx__msgs--instagram .dash-ibx__msg.is-emma .dash-ibx__bubble,
.dash-ibx__msgs--instagram .dash-ibx__msg.is-agent .dash-ibx__bubble { box-shadow: none; }
.dash-ibx__btext { white-space: pre-wrap; }
.dash-ibx__bmeta { float: right; margin: 6px 0 -2px 10px; font-size: 10.5px; color: rgba(0,0,0,0.42); display: inline-flex; align-items: center; gap: 3px; }
.dash-ibx__bmeta svg { color: var(--ibx-check); }

/* Composer */
.dash-ibx__composer { display: flex; align-items: flex-end; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--rule); background: #fff; }
.dash-ibx__inputwrap { flex: 1; display: flex; align-items: center; gap: 6px; padding: 4px 6px 4px 8px; border-radius: 24px; border: 1px solid var(--rule-strong); background: #fff; transition: border-color 160ms ease; }
.dash-ibx__inputwrap:focus-within { border-color: var(--ibx-accent); }
.dash-ibx__composer-icon { flex: none; width: 34px; height: 34px; border-radius: 999px; border: none; background: transparent; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.dash-ibx__composer-icon:hover { color: var(--ink); background: rgba(0,0,0,0.05); }
.dash-ibx__input {
  flex: 1; resize: none; max-height: 110px; padding: 8px 4px; border: none; background: transparent; outline: none;
  font-family: var(--sans); font-size: 14px; line-height: 1.4; color: var(--ink);
}
.dash-ibx__send {
  flex: none; width: 44px; height: 44px; border-radius: 999px; cursor: pointer; background: var(--ibx-send); color: #fff; border: none;
  display: inline-flex; align-items: center; justify-content: center; transition: opacity 160ms ease, transform 160ms ease;
}
.dash-ibx__send svg { transform: translateX(-1px); }
.dash-ibx__send:disabled { opacity: 0.45; cursor: not-allowed; }
.dash-ibx__send:not(:disabled):hover { opacity: 0.92; }

.dash-ibx__composer-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 18px; border-top: 1px solid var(--rule); font-size: 12.5px; color: var(--muted); background: #fff; }
.dash-ibx__reactivate { display: inline-flex; align-items: center; gap: 6px; background: transparent; border: none; cursor: pointer; font-family: var(--sans); font-size: 12.5px; font-weight: 600; color: var(--ibx-accent); padding: 0; }
.dash-inbox.is-instagram .dash-ibx__reactivate { color: #E1306C; }

/* ====== Columna derecha: lead (fijo, sin acordeones) ====== */
.dash-ibx__lead-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 8px; }
.dash-ibx__lead-title { font-size: 15px; font-weight: 600; flex: 1; }
.dash-ibx__lead-close { display: none; }
.dash-ibx__lead-body { padding: 2px 16px 16px; display: flex; flex-direction: column; gap: 15px; }
.dash-ibx__lead-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; }
.dash-ibx__kv { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.dash-ibx__kv.is-wide { grid-column: 1 / -1; }
.dash-ibx__kv-k { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; color: var(--muted-soft); }
.dash-ibx__kv-v { font-size: 13.5px; font-weight: 500; color: var(--ink); line-height: 1.4; word-break: break-word; }

.dash-ibx__lead-block { display: flex; flex-direction: column; gap: 8px; }
.dash-ibx__lead-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted-soft); }
.dash-ibx__tags { display: flex; flex-wrap: wrap; gap: 6px; }
.dash-ibx__tag { padding: 3px 10px; border-radius: 999px; font-size: 11.5px; background: var(--ibx-accent-soft); color: var(--ibx-accent); font-weight: 500; }
.dash-ibx__tag--add { background: transparent; border: 1px dashed var(--rule-strong); color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; padding: 3px 7px; }
.dash-ibx__notes { font-size: 12.5px; line-height: 1.5; color: var(--muted-strong); margin: 0; }

.dash-ibx__diagnosis { display: flex; flex-direction: column; gap: 11px; padding: 14px 15px; border-radius: 12px; background: rgba(34,197,94,0.08); border: 1px solid rgba(34,197,94,0.25); }
.dash-ibx__diagnosis-flag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: #17914d; padding-bottom: 9px; border-bottom: 1px solid rgba(34,197,94,0.22); }
.dash-ibx__diagnosis-text { margin: 0; font-size: 12.5px; line-height: 1.6; color: var(--muted-strong); white-space: pre-wrap; }

/* Acciones rápidas */
.dash-ibx__card-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 2px; }
.dash-ibx__card-title { font-size: 14px; font-weight: 600; flex: 1; }
.dash-ibx__statechip { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 500; padding: 3px 9px; border-radius: 999px; background: rgba(0,0,0,0.05); color: var(--muted-strong); white-space: nowrap; }
.dash-ibx__actions { display: flex; flex-direction: column; gap: 8px; padding: 10px 16px 16px; }
.dash-ibx__assign { width: 100%; }
.dash-ibx__assign .dd__menu { width: 100%; min-width: 0; }

/* ====== Responsive ====== */
@media (max-width: 1240px) {
  .dash-inbox, .dash-inbox.hide-lead { grid-template-columns: minmax(280px, 340px) minmax(0, 1fr); }
  .dash-ibx__rail {
    position: absolute; top: 0; right: 0; bottom: 0; width: min(340px, 88%); z-index: 20;
    background: #f6f6f7; padding: 4px; border-radius: 18px; box-shadow: -18px 0 44px -26px rgba(0,0,0,0.45);
  }
  .dash-ibx__lead-close { display: inline-flex; }
}
@media (max-width: 860px) {
  .dash-main--inbox { height: auto; min-height: 100vh; overflow: visible; }
  .dash-inbox { min-height: calc(100vh - 140px); }
  .dash-inbox, .dash-inbox.hide-lead { grid-template-columns: 1fr; }
  .dash-inbox.has-selection .dash-ibx__list { display: none; }
  .dash-inbox:not(.has-selection) .dash-ibx__conv { display: none; }
  .dash-ibx__back { display: inline-flex; }
  .dash-ibx__rail { width: min(360px, 100%); }
  .dash-ibx__conv-actions .dash-ibx__btn span { display: none; }
  .dash-ibx__conv-actions .dash-ibx__btn { padding: 9px; }
}

/* ====== Dark mode ====== */
.mirai-dark .dash-ibx__col, .mirai-dark .dash-ibx__card { background: #15171c; border-color: var(--rule); }
.mirai-dark .dash-ibx__search { background: rgba(255,255,255,0.05); }
.mirai-dark .dash-ibx__search:focus-within { background: rgba(255,255,255,0.08); }
.mirai-dark .dash-ibx__toolbtn:hover, .mirai-dark .dash-ibx__item:hover { background: rgba(255,255,255,0.05); }
.mirai-dark .dash-ibx__tab-n { background: rgba(255,255,255,0.10); }
.mirai-dark .dash-ibx__statechip { background: rgba(255,255,255,0.07); }
.mirai-dark .dash-ibx__btn { background: #15171c; color: var(--ink); border-color: var(--rule-strong); }
.mirai-dark .dash-ibx__btn:hover { border-color: #fff; }
.mirai-dark .dash-ibx__btn--solid { background: #fff; color: #000; border-color: #fff; }
.mirai-dark .dash-ibx__btn--accent { background: var(--ibx-grad); color: #fff; border: none; }
.mirai-dark .dash-ibx__btn--diagnosis { background: #22C55E; color: #fff; }
.mirai-dark .dash-ibx__diagnosis { background: rgba(34,197,94,0.14); border-color: rgba(34,197,94,0.3); }
.mirai-dark .dash-ibx__diagnosis-flag { color: #4ade80; }
.mirai-dark .dash-ibx__takeover { background: rgba(220,38,38,0.14); color: #f87171; border-bottom-color: var(--rule); }
.mirai-dark .dash-ibx__pausebars i { background: #f87171; }
.mirai-dark .dash-ibx__msgs--whatsapp { background-color: #15171c; background-image: none; }
.mirai-dark .dash-ibx__msgs--instagram { background: #15171c; }
.mirai-dark .dash-ibx__datechip { background: rgba(255,255,255,0.10); color: var(--muted-strong); box-shadow: none; }
.mirai-dark .dash-ibx__event { background: rgba(217,154,63,0.16); color: #e7b374; box-shadow: none; }
.mirai-dark .dash-ibx__event svg { color: #e7b374; }
.mirai-dark .dash-ibx__event-time { color: rgba(231,179,116,0.75); }
.mirai-dark .dash-ibx__msg.is-lead .dash-ibx__bubble { background: #21262e; color: var(--ink); box-shadow: none; }
.mirai-dark .dash-ibx__msg.is-emma .dash-ibx__bubble, .mirai-dark .dash-ibx__msg.is-agent .dash-ibx__bubble { color: #fff; }
.mirai-dark .dash-inbox.is-whatsapp .dash-ibx__msg.is-emma .dash-ibx__bubble,
.mirai-dark .dash-inbox.is-whatsapp .dash-ibx__msg.is-agent .dash-ibx__bubble { background: #144d37; }
.mirai-dark .dash-inbox.is-instagram .dash-ibx__msg.is-emma .dash-ibx__bubble,
.mirai-dark .dash-inbox.is-instagram .dash-ibx__msg.is-agent .dash-ibx__bubble { background: #3a1b2c; }
.mirai-dark .dash-ibx__bmeta { color: rgba(255,255,255,0.5); }
.mirai-dark .dash-ibx__composer, .mirai-dark .dash-ibx__composer-foot { background: #15171c; }
.mirai-dark .dash-ibx__inputwrap { background: #1b1e24; border-color: var(--rule-strong); }
.mirai-dark .dash-ibx__composer-icon:hover { background: rgba(255,255,255,0.07); }
.mirai-dark .dash-ibx__edit:hover { background: rgba(255,255,255,0.08); }
.mirai-dark .dash-ibx__rail { background: transparent; }
.mirai-dark .dash-ibx__online, .mirai-dark .dash-ibx__avatar.has-ring .dash-ibx__avatar-circle { border-color: #15171c; }

@media (max-width: 1240px) { .mirai-dark .dash-ibx__rail { background: #0e0f12; } }
@media (prefers-reduced-motion: reduce) { .dash-ibx__live { animation: none; } .dash-ibx__btn, .dash-ibx__send, .dash-ibx__item { transition: none; } }

/* ============================================================
   RASTREO IA — pantalla de rastreo de propiedades
   Reutiliza .dash-card, .dash-head, .dash-switch, etc.
   Acento verde MirAI (--rt-green).
   ============================================================ */
:root { --rt-green: #1E90FF; --rt-green-soft: rgba(30,144,255,0.1); }

/* Sidebar: opción activa Rastreo */
.dash-sb__item.is-active.is-rastreo { background: #1E90FF; color: #fff; }
.dash-sb__item.is-active.is-rastreo:hover { background: #1877D9; }
.mirai-dark .dash-sb__item.is-active.is-rastreo { background: #1E90FF; color: #fff; }
.mirai-dark .dash-sb__item.is-active.is-rastreo:hover { background: #1877D9; }

/* Layout superior: formulario (izq) + resumen/Emma (der) */
.dash-rt__top { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.dash-rt__side { display: flex; flex-direction: column; gap: 18px; }

/* ---- Formulario ---- */
.dash-rt__formcard { display: flex; flex-direction: column; gap: 18px; }
.dash-rt__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.dash-rt__field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.dash-rt__field.is-wide { grid-column: 1 / -1; }
.dash-rt__label { font-size: 12.5px; color: var(--muted-strong); font-weight: 500; }
.dash-rt__sublabel { font-size: 12.5px; color: var(--muted-strong); font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.dash-rt__sublabel svg { color: var(--muted-soft); }

.dash-rt__input, .dash-rt__textarea, .dash-rt__select {
  width: 100%; box-sizing: border-box; font-family: var(--sans); font-size: 14px; color: var(--ink);
  background: #fff; border: 1px solid var(--rule-strong); border-radius: 11px; padding: 11px 13px; outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.dash-rt__input:focus, .dash-rt__textarea:focus, .dash-rt__select:focus { border-color: var(--rt-green); box-shadow: 0 0 0 3px var(--rt-green-soft); }
.dash-rt__textarea { resize: vertical; line-height: 1.5; min-height: 64px; }
.dash-rt__selectwrap { position: relative; }
.dash-rt__select { appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer; }
.dash-rt__selectchev { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--muted); display: inline-flex; }

/* Chips */
.dash-rt__chips { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; min-height: 44px; padding: 7px 40px 7px 10px; position: relative; background: #fff; border: 1px solid var(--rule-strong); border-radius: 11px; }
.dash-rt__chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 11px; border-radius: 999px; background: var(--soft, rgba(0,0,0,0.05)); font-size: 12.5px; color: var(--ink); }
.dash-rt__chip button { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border: none; background: transparent; color: var(--muted); cursor: pointer; border-radius: 999px; }
.dash-rt__chip button:hover { background: rgba(0,0,0,0.08); color: var(--ink); }
.dash-rt__chips-ph { font-size: 13px; color: var(--muted-soft); }
.dash-rt__chips-dd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); }
.dash-rt__chips-add { width: 26px; height: 26px; border-radius: 8px; border: none; background: transparent; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.dash-rt__chips-add:hover { background: rgba(0,0,0,0.06); color: var(--ink); }
.dash-rt__dd-empty { padding: 9px 12px; font-size: 12.5px; color: var(--muted); }

/* Fila inferior: imágenes / fuentes / toggles */
.dash-rt__lower { display: grid; grid-template-columns: 1.25fr 1fr; gap: 22px; padding-top: 4px; border-top: 1px solid var(--rule); }
.dash-rt__lower-col { display: flex; flex-direction: column; gap: 11px; }

.dash-rt__imgs { display: flex; flex-wrap: wrap; gap: 10px; }
.dash-rt__img { position: relative; width: 70px; height: 70px; border-radius: 12px; overflow: hidden; background: linear-gradient(135deg, #e9eaec, #f4f4f5); flex: none; }
.dash-rt__img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dash-rt__img-x { position: absolute; top: 3px; right: 3px; width: 19px; height: 19px; border-radius: 999px; border: none; background: rgba(0,0,0,0.55); color: #fff; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.dash-rt__addimg { width: 70px; height: 70px; border-radius: 12px; border: 1px dashed var(--rule-strong); background: transparent; color: var(--muted); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 10px; text-align: center; line-height: 1.1; }
.dash-rt__addimg span { padding: 0 4px; }
.dash-rt__addimg:hover { border-color: var(--rt-green); color: var(--rt-green); }

.dash-rt__sources { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.dash-rt__source { display: inline-flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 11px; border: 1px solid var(--rule-strong); background: #fff; cursor: pointer; font-family: var(--sans); font-size: 12px; font-weight: 500; color: var(--ink); transition: border-color 160ms ease, background 160ms ease; }
.dash-rt__source.is-on { border-color: var(--rt-green); background: var(--rt-green-soft); }
.dash-rt__source-logo { width: 22px; height: 22px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex: none; }
.dash-rt__source-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-rt__source-check { color: var(--rt-green); display: inline-flex; flex: none; }

.dash-rt__toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dash-rt__toggle-txt { font-size: 12.5px; color: var(--muted-strong); line-height: 1.35; }
.dash-switch--green.is-on { background: var(--rt-green); }
.mirai-dark .dash-switch--green.is-on { background: var(--rt-green); }
.mirai-dark .dash-switch--green.is-on .dash-switch__knob { background: #fff; }

/* CTA */
.dash-rt__cta { display: inline-flex; align-items: center; justify-content: center; gap: 9px; width: 100%; padding: 14px; border-radius: 13px; border: none; cursor: pointer; background: var(--rt-green); color: #fff; font-family: var(--sans); font-size: 15px; font-weight: 600; transition: opacity 160ms ease; }
.dash-rt__cta:hover { opacity: 0.92; }
.dash-rt__cta:disabled { opacity: 0.7; cursor: default; }
.dash-rt__cta svg { }
.dash-rt__cta:disabled svg { animation: dashSpin 0.8s linear infinite; }

/* ---- Resumen ---- */
.dash-rt__summary-list { display: flex; flex-direction: column; margin: 14px 0 0; }
.dash-rt__summary-row { display: grid; grid-template-columns: 22px auto 1fr; align-items: start; gap: 10px; padding: 9px 0; border-top: 1px solid var(--rule); }
.dash-rt__summary-row:first-child { border-top: none; }
.dash-rt__summary-ico { color: var(--muted-soft); display: inline-flex; padding-top: 1px; }
.dash-rt__summary-k { font-size: 13px; color: var(--muted); white-space: nowrap; }
.dash-rt__summary-v { font-size: 13px; color: var(--ink); text-align: right; font-weight: 500; }

/* ---- Qué hará Emma ---- */
.dash-rt__steps { list-style: none; display: flex; flex-direction: column; gap: 16px; margin: 16px 0 0; }
.dash-rt__step { display: flex; align-items: flex-start; gap: 12px; }
.dash-rt__step-n { flex: none; width: 26px; height: 26px; border-radius: 999px; border: 1.5px solid var(--rule-strong); color: var(--muted); display: inline-flex; align-items: center; justify-content: center; font-size: 12.5px; font-weight: 600; transition: all 200ms ease; }
.dash-rt__step-txt { font-size: 13.5px; color: var(--muted-strong); line-height: 1.4; padding-top: 3px; }
.dash-rt__step.is-active .dash-rt__step-n { border-color: var(--rt-green); color: var(--rt-green); box-shadow: 0 0 0 4px var(--rt-green-soft); }
.dash-rt__step.is-done .dash-rt__step-n { background: var(--rt-green); border-color: var(--rt-green); color: #fff; }
.dash-rt__step.is-done .dash-rt__step-txt, .dash-rt__step.is-active .dash-rt__step-txt { color: var(--ink); }

/* ---- Resultados ---- */
.dash-rt__results-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.dash-rt__results-status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; color: var(--rt-green); }
.dash-rt__results-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 48px 24px; text-align: center; color: var(--muted); }
.dash-rt__results-empty-ico { color: var(--muted-soft); display: inline-flex; }
.dash-rt__results-empty-ico.is-spin { animation: dashSpin 0.9s linear infinite; color: var(--rt-green); }
.dash-rt__results { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }

.dash-rt__prop { border: 1px solid var(--rule); border-radius: 14px; overflow: hidden; background: #fff; display: flex; flex-direction: column; transition: border-color 200ms ease, box-shadow 200ms ease, transform 200ms ease; }
.dash-rt__prop:hover { border-color: var(--rule-strong); box-shadow: 0 14px 32px -24px rgba(0,0,0,0.32); transform: translateY(-2px); }
.dash-rt__prop-media { position: relative; height: 150px; background: linear-gradient(135deg, #e9eaec, #f4f4f5); }
.dash-rt__prop-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dash-rt__portal { position: absolute; top: 10px; left: 10px; display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px 4px 5px; border-radius: 8px; font-size: 11px; font-weight: 600; box-shadow: 0 2px 6px rgba(0,0,0,0.18); }
.dash-rt__portal-logo { width: 16px; height: 16px; border-radius: 4px; background: rgba(255,255,255,0.35); display: inline-flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 800; }
.dash-rt__fav { position: absolute; top: 9px; right: 9px; width: 32px; height: 32px; border-radius: 999px; border: none; background: rgba(255,255,255,0.9); color: #444; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: color 160ms ease; }
.dash-rt__fav.is-on { color: #e0245e; }
.dash-rt__prop-body { padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.dash-rt__prop-title { font-size: 14px; font-weight: 600; line-height: 1.3; }
.dash-rt__prop-loc { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--muted); }
.dash-rt__prop-price { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; margin-top: 2px; }
.dash-rt__prop-specs { font-size: 12.5px; color: var(--muted-strong); }
.dash-rt__match { align-self: flex-start; padding: 3px 10px; border-radius: 999px; background: var(--rt-green-soft); color: #1565C0; font-size: 11.5px; font-weight: 600; margin: 2px 0 4px; }
.dash-rt__prop-actions { display: flex; gap: 8px; margin-top: 4px; }
.dash-rt__btn { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 8px; border-radius: 10px; border: 1px solid var(--rule-strong); background: #fff; color: var(--ink); cursor: pointer; font-family: var(--sans); font-size: 12px; font-weight: 500; white-space: nowrap; transition: border-color 160ms ease, background 160ms ease; }
.dash-rt__btn:hover { border-color: #000; }

/* ---- Responsive ---- */
@media (max-width: 1100px) {
  .dash-rt__top { grid-template-columns: 1fr; }
  .dash-rt__side { flex-direction: row; }
  .dash-rt__side > * { flex: 1; }
  .dash-rt__results { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .dash-rt__grid { grid-template-columns: 1fr; }
  .dash-rt__lower { grid-template-columns: 1fr; gap: 18px; }
  .dash-rt__side { flex-direction: column; }
  .dash-rt__results { grid-template-columns: 1fr; }
}

/* ---- Dark mode ---- */
.mirai-dark .dash-rt__input, .mirai-dark .dash-rt__textarea, .mirai-dark .dash-rt__select,
.mirai-dark .dash-rt__chips, .mirai-dark .dash-rt__source { background: #1b1e24; border-color: var(--rule-strong); color: var(--ink); }
.mirai-dark .dash-rt__source.is-on { background: var(--rt-green-soft); border-color: var(--rt-green); }
.mirai-dark .dash-rt__chip { background: rgba(255,255,255,0.08); }
.mirai-dark .dash-rt__prop { background: #15171c; border-color: var(--rule); }
.mirai-dark .dash-rt__btn { background: #15171c; color: var(--ink); border-color: var(--rule-strong); }
.mirai-dark .dash-rt__btn:hover { border-color: #fff; }
.mirai-dark .dash-rt__fav { background: rgba(0,0,0,0.45); color: #ddd; }
.mirai-dark .dash-rt__match { color: #4ade80; }
.mirai-dark .dash-rt__step-n { border-color: var(--rule-strong); }

/* ============================
   TICKETS
   ============================ */

/* ---- Keyframes ---- */
@keyframes tkColIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes tkDetailIn {
  from { opacity: 0; transform: translateX(10px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes tkCardPop {
  0%   { transform: scale(1); }
  45%  { transform: scale(0.97); }
  100% { transform: scale(1); }
}

/* ---- Filtros ---- */
.dash-tk__filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 0 4px;
}

.dash-tk__tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: transparent;
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 180ms ease, color 180ms ease,
              background 180ms ease, box-shadow 180ms ease,
              transform 120ms ease;
}
.dash-tk__tab:hover { border-color: rgba(0,0,0,0.45); color: var(--ink); }
.dash-tk__tab:active { transform: scale(0.95); }
.dash-tk__tab.is-on {
  background: #fff;
  border-color: #000;
  color: #000;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

/* ---- Botón crear ---- */
.dash-tk__create-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  background: #1F3A5C;
  color: #fff;
  border: none;
  border-radius: 12px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 150ms ease, transform 120ms ease, box-shadow 150ms ease;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(31,58,92,0.25);
}
.dash-tk__create-btn:hover { opacity: 0.9; box-shadow: 0 4px 14px rgba(31,58,92,0.3); }
.dash-tk__create-btn:active { transform: scale(0.97); }

/* ---- Layout: tablero + panel ---- */
.dash-tk__layout {
  display: flex;
  gap: 18px;
  align-items: flex-start;
}

/* ---- Tablero kanban ---- */
.dash-tk__board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  flex: 1;
  min-width: 0;
}

/* ---- Columna ---- */
.dash-tk__column {
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: tkColIn 300ms ease both;
}
.dash-tk__column-head { display: flex; align-items: center; gap: 8px; }
.dash-tk__column-title { font-size: 14px; font-weight: 600; color: var(--ink); }
.dash-tk__column-count {
  background: rgba(0,0,0,0.07);
  color: var(--muted-strong);
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  transition: background 200ms ease;
}
.dash-tk__column-body { display: flex; flex-direction: column; gap: 10px; }
.dash-tk__empty-col {
  font-size: 12.5px;
  color: var(--muted);
  padding: 10px 0;
  text-align: center;
}

/* ---- Tarjeta ---- */
.dash-tk__card {
  background: #fff;
  border: 1.5px solid var(--rule-strong);
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 7px;
  transition: border-color 200ms ease,
              box-shadow 200ms ease,
              transform 200ms ease;
  outline: none;
  will-change: transform, box-shadow;
}
.dash-tk__card:hover {
  border-color: rgba(31,58,92,0.3);
  box-shadow: 0 6px 18px -8px rgba(31,58,92,0.22);
  transform: translateY(-2px);
}
.dash-tk__card:active { transform: scale(0.98) translateY(0); }
.dash-tk__card.is-selected {
  border-color: #1F3A5C;
  box-shadow: 0 0 0 3px rgba(31,58,92,0.1), 0 4px 14px -6px rgba(31,58,92,0.18);
  transform: translateY(-1px);
}
.dash-tk__card-id { font-size: 12.5px; font-weight: 600; color: var(--ink); line-height: 1.35; }
.dash-tk__card-desc { font-size: 12.5px; color: var(--muted); line-height: 1.45; margin: 0; }

/* ---- Badges ---- */
.dash-tk__badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
  align-self: flex-start;
  transition: opacity 150ms ease;
}
.dash-tk__badge.is-pending  { background: #F1F5F9; color: #64748B; }
.dash-tk__badge.is-progress { background: #EFF6FF; color: #2563EB; }
.dash-tk__badge.is-done     { background: #DCFCE7; color: #166534; }

/* ---- Panel de detalle ---- */
.dash-tk__detail {
  width: 300px;
  flex: none;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  animation: tkDetailIn 280ms ease both;
}
.dash-tk__detail--empty {
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--muted);
  min-height: 200px;
  gap: 12px;
}
.dash-tk__detail-head { display: flex; flex-direction: column; gap: 8px; }
.dash-tk__detail-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  margin: 0;
}
.dash-tk__detail-desc {
  font-size: 13px;
  color: var(--muted-strong);
  line-height: 1.6;
  margin: 0;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--rule);
}

/* ---- Pasos de progreso ---- */
.dash-tk__steps { list-style: none; display: flex; flex-direction: column; gap: 0; flex: 1; padding: 0; margin: 0; }
.dash-tk__step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  position: relative;
}
.dash-tk__step:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 9px;
  top: 30px;
  width: 2px;
  height: 20px;
  background: #E5E7EB;
}
.dash-tk__step-icon { width: 20px; height: 20px; flex: none; display: inline-flex; }
.dash-tk__step-icon svg { width: 100%; height: 100%; }
.dash-tk__step-label { font-size: 13px; color: var(--muted); }
.dash-tk__step-label.is-active { color: var(--ink); font-weight: 600; }
.dash-tk__step-label.is-done   { color: var(--muted-strong); }

/* ---- Pie del panel: botones apilados ---- */
.dash-tk__detail-foot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px solid var(--rule);
  margin-top: 4px;
}
.dash-tk__foot-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 14px;
  border-radius: 11px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 150ms ease,
              background 150ms ease,
              opacity 150ms ease,
              transform 120ms ease,
              box-shadow 150ms ease;
  border: 1px solid var(--rule-strong);
  background: #fff;
  color: var(--ink);
  white-space: nowrap;
  box-sizing: border-box;
}
.dash-tk__foot-btn:hover { border-color: rgba(0,0,0,0.5); background: #fafafa; }
.dash-tk__foot-btn:active { transform: scale(0.97); }
.dash-tk__foot-btn--primary {
  background: #1F3A5C;
  color: #fff;
  border-color: #1F3A5C;
  box-shadow: 0 2px 8px rgba(31,58,92,0.2);
}
.dash-tk__foot-btn--primary:hover { opacity: 0.9; background: #1F3A5C; box-shadow: 0 4px 12px rgba(31,58,92,0.28); }

/* ---- Responsive ---- */
@media (max-width: 1100px) {
  .dash-tk__layout { flex-direction: column; }
  .dash-tk__detail { width: 100%; position: static; max-height: none; }
}
@media (max-width: 760px) {
  .dash-tk__board { grid-template-columns: 1fr !important; }
}

/* ---- Dark mode ---- */
.mirai-dark .dash-tk__tab.is-on { background: #1e2029; border-color: #fff; color: #fff; }
.mirai-dark .dash-tk__tab:hover { border-color: rgba(255,255,255,0.5); color: var(--ink); }
.mirai-dark .dash-tk__column,
.mirai-dark .dash-tk__card,
.mirai-dark .dash-tk__detail { background: #15171c; border-color: var(--rule); }
.mirai-dark .dash-tk__card:hover { box-shadow: 0 6px 18px -8px rgba(0,0,0,0.5); }
.mirai-dark .dash-tk__card.is-selected { border-color: #4B7DB0; box-shadow: 0 0 0 3px rgba(75,125,176,0.15); }
.mirai-dark .dash-tk__badge.is-pending  { background: rgba(255,255,255,0.07); color: #94A3B8; }
.mirai-dark .dash-tk__badge.is-progress { background: rgba(59,130,246,0.15); color: #60A5FA; }
.mirai-dark .dash-tk__badge.is-done     { background: rgba(34,197,94,0.12); color: #4ADE80; }
.mirai-dark .dash-tk__create-btn        { background: #2C5282; box-shadow: 0 2px 8px rgba(0,0,0,0.3); }
.mirai-dark .dash-tk__foot-btn          { background: #1e2029; border-color: var(--rule-strong); color: var(--ink); }
.mirai-dark .dash-tk__foot-btn:hover    { border-color: rgba(255,255,255,0.4); background: #23262f; }
.mirai-dark .dash-tk__foot-btn--primary { background: #2C5282; border-color: #2C5282; color: #fff; }
.mirai-dark .dash-tk__foot-btn--primary:hover { background: #2C5282; }
.mirai-dark .dash-tk__step:not(:last-child)::after { background: var(--rule-strong); }
.mirai-dark .dash-tk__detail-foot { border-color: var(--rule); }

/* ============================
   TABLERO
   ============================ */

.dash-tb__search {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px; border-radius: 999px;
  background: #fff; border: 1px solid var(--rule-strong);
  color: var(--muted); width: 250px;
  transition: border-color 160ms ease;
}
.dash-tb__search:focus-within { border-color: #000; color: var(--ink); }
.dash-tb__search input { flex: 1; min-width: 0; border: none; background: transparent; outline: none; font-family: var(--sans); font-size: 13px; color: var(--ink); }

.dash-tb__card { padding: 0; overflow: hidden; }
.dash-tb__cardhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 20px 0; }
.dash-tb__count { font-size: 12.5px; color: var(--muted); white-space: nowrap; }

.dash-tb__wrap { margin-top: 14px; overflow-x: auto; }
.dash-tb__table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 720px; }
.dash-tb__table thead th {
  position: sticky; top: 0; z-index: 1;
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  font-weight: 600; color: var(--muted-soft); background: var(--rule-soft, #fafafa);
  padding: 12px 14px; border-bottom: 1px solid var(--rule-strong); border-right: 1px solid var(--rule);
}
.dash-tb__table thead th:last-child { border-right: none; }
.dash-tb__table td {
  padding: 12px 14px; border-bottom: 1px solid var(--rule); border-right: 1px solid var(--rule);
  vertical-align: middle; white-space: nowrap;
}
.dash-tb__table td:last-child { border-right: none; }
.dash-tb__table tbody tr { cursor: pointer; transition: background 140ms ease; }
.dash-tb__table tbody tr:nth-child(even) { background: rgba(0,0,0,0.015); }
.dash-tb__table tbody tr:hover { background: rgba(79,70,229,0.06); }
.dash-tb__name { font-weight: 600; }
.dash-tb__channel { display: inline-flex; align-items: center; gap: 8px; }
.dash-tb__date { color: var(--muted); }
.dash-tb__broker {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--sans); font-size: 12.5px; font-weight: 500; color: var(--ink);
  background: transparent; border: 1px solid transparent; border-radius: 8px;
  padding: 5px 8px; margin: -5px -8px; cursor: pointer; white-space: nowrap;
  transition: background 140ms ease, border-color 140ms ease;
}
.dash-tb__broker:hover { background: rgba(79,70,229,0.08); border-color: rgba(79,70,229,0.25); }
.dash-tb__broker.is-empty { color: var(--muted-soft); font-weight: 400; font-style: italic; }
.dash-tb__derivedfield { margin-bottom: 14px; }
.dash-tb__derivedfield .dash-tb__broker { margin: -5px 0 0 -8px; }
.dash-tb__empty { text-align: center; color: var(--muted); padding: 34px 0 !important; border-right: none !important; }

/* Acciones del detalle: ir a la conversación / copiar diagnóstico */
.dash-tb__quickactions { display: flex; flex-wrap: wrap; gap: 10px; }
.dash-tb__gochat {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  flex: 1 1 220px; padding: 11px 14px; border-radius: 11px; border: none; cursor: pointer;
  font-family: var(--sans); font-size: 13px; font-weight: 600; color: #fff;
  transition: opacity 160ms ease;
}
.dash-tb__gochat:hover { opacity: 0.9; }
.dash-tb__gochat.is-whatsapp { background: #25D366; }
.dash-tb__gochat.is-instagram { background: linear-gradient(135deg, #F58529 0%, #DD2A7B 55%, #8134AF 100%); }
.dash-tb__quickactions .dash-ibx__btn--diagnosis { flex: 1 1 220px; }

@media (max-width: 720px) {
  .dash-tb__search { width: 170px; }
  .dash-tb__table { min-width: 0; font-size: 12px; }
  .dash-tb__table td, .dash-tb__table th { white-space: normal; }
}

.mirai-dark .dash-tb__search { background: #15171c; border-color: var(--rule-strong); }
.mirai-dark .dash-tb__search:focus-within { border-color: #fff; }
.mirai-dark .dash-tb__table thead th { background: #1b1e24; border-color: var(--rule); }
.mirai-dark .dash-tb__table td { border-color: var(--rule); }
.mirai-dark .dash-tb__table tbody tr:nth-child(even) { background: rgba(255,255,255,0.02); }
.mirai-dark .dash-tb__table tbody tr:hover { background: rgba(129,140,248,0.1); }
.mirai-dark .dash-tb__broker:hover { background: rgba(129,140,248,0.14); border-color: rgba(129,140,248,0.35); }
