/* Métricas (pantallas/metricas.js): cruzar todos los eventos. Usa las piezas y la escala de verdes de
   Eventos (la raíz lleva también .ev-raiz); aquí solo lo propio: el buscador con IA, la bandeja de la
   consulta, el cruce por series y la tabla. */

.mt-raiz { container-type: inline-size; }

/* ---------- Buscador con IA ---------- */
.mt-ia { padding: 18px 20px; display: grid; gap: 14px; overflow: visible; }
.mt-preguntar { display: flex; align-items: center; gap: 10px; min-height: 54px; padding: 6px 6px 6px 16px; border: 1px solid var(--fc-border); border-radius: 16px; background: var(--fc-card); transition: border-color var(--arc-fast, 160ms) ease, box-shadow var(--arc-fast, 160ms) ease; }
.mt-preguntar:focus-within { border-color: var(--fc-ink); box-shadow: 0 0 0 3px oklch(0% 0 0 / .06); }
.mt-lupa { display: inline-flex; flex: none; color: var(--fc-muted); }
.mt-preguntar input { flex: 1; min-width: 0; height: 42px; border: 0; background: transparent; color: var(--fc-ink); font: inherit; font-size: 16px; outline: none; }
.mt-preguntar input::placeholder { color: var(--fc-muted); }
.mt-preguntar .ev-btn { flex: none; min-height: 42px; }
.mt-ejemplos { display: flex; flex-wrap: wrap; gap: 8px; }
.mt-ejemplos button { min-height: 34px; padding: 0 12px; border: 1px solid var(--fc-border); border-radius: 999px; background: transparent; color: var(--fc-muted); font: inherit; font-size: 13px; cursor: pointer; transition: background-color var(--arc-fast, 160ms) ease, color var(--arc-fast, 160ms) ease, border-color var(--arc-fast, 160ms) ease; }
.mt-ejemplos button:hover { background: var(--fc-selected); color: var(--fc-ink); }
.mt-respuesta { display: grid; gap: 4px; padding: 14px 16px; border: 1px solid var(--ev-v1); border-radius: 14px; background: var(--ev-v0); animation: arc-entrada var(--arc-considered, 480ms) var(--arc-ease-enter, ease) both; }
.mt-respuesta small { color: var(--fc-muted); font-size: 12px; }
.mt-respuesta p { margin: 0; font-size: 15.5px; line-height: 1.5; color: var(--fc-ink); text-wrap: pretty; }
.mt-respuesta .mt-pie { margin-top: 4px; }
.mt-respuesta.mal { background: color-mix(in oklab, var(--fc-error, #c0392b) 6%, var(--fc-card)); border-color: color-mix(in oklab, var(--fc-error, #c0392b) 25%, var(--fc-border)); }
.mt-respuesta.pensando { display: flex; gap: 6px; padding: 18px 16px; }
.mt-respuesta.pensando span { width: 7px; height: 7px; border-radius: 50%; background: var(--fc-muted); animation: mt-punto 1s ease-in-out infinite; }
.mt-respuesta.pensando span:nth-child(2) { animation-delay: .15s; }
.mt-respuesta.pensando span:nth-child(3) { animation-delay: .3s; }
@keyframes mt-punto { 50% { opacity: .25; transform: translateY(-3px); } }

/* ---------- La consulta: medir, agrupar, comparar y los filtros ---------- */
.mt-controles .ev-filtro > button { max-width: none; }
.mt-controles .ev-filtro > button small { margin-right: 2px; white-space: nowrap; }
.mt-chip > button:first-child span { max-width: 220px; }
.mt-separa { width: 1px; height: 26px; margin: 0 4px; background: var(--fc-border); }
.mt-chip { display: inline-flex; align-items: stretch; }
.mt-chip > button:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; padding-right: 8px; }
.mt-chip .mt-quitar { display: inline-flex; align-items: center; justify-content: center; width: 32px; min-height: 38px; padding: 0; border: 0; border-left: 1px solid color-mix(in oklab, var(--ev-sobre-fuerte) 25%, transparent); border-radius: 0 12px 12px 0; background: var(--ev-v5); color: var(--ev-sobre-fuerte); cursor: pointer; }
.mt-chip .mt-quitar:hover { filter: brightness(1.1); }
.ev-raiz .ev-menu.mt-menu { width: 300px; }
.mt-menu-cab { display: grid; gap: 1px; padding: 6px 10px 8px; }
.mt-menu-cab b { font-size: 13.5px; font-weight: 600; }
.mt-menu-cab small { font-size: 12px; color: var(--fc-muted); }
.ev-raiz .ev-menu.mt-menu li button { justify-content: flex-start; gap: 10px; }
.mt-check { flex: none; width: 16px; height: 16px; border: 1.5px solid var(--fc-border); border-radius: 5px; transition: background-color var(--arc-fast, 160ms) ease, border-color var(--arc-fast, 160ms) ease; }
.mt-check.si { border-color: var(--ev-g); background: var(--ev-g) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 8.5l2.5 2.5L12 5.5'/%3E%3C/svg%3E") center / 14px no-repeat; }

/* ---------- Resultado ---------- */
.mt-zona { display: grid; gap: var(--ev-gap); transition: opacity var(--arc-fast, 160ms) ease; }
.mt-zona.cargando { opacity: .55; pointer-events: none; }
.mt-cargando { height: 220px; border-radius: var(--ev-r); background: linear-gradient(90deg, var(--fc-selected), color-mix(in oklab, var(--fc-selected) 40%, var(--fc-card)), var(--fc-selected)); background-size: 200% 100%; animation: mt-brillo 1.3s ease-in-out infinite; }
@keyframes mt-brillo { to { background-position: -200% 0; } }
.mt-vacio { display: grid; justify-items: center; gap: 8px; padding: 48px 24px; text-align: center; border-style: dashed; }
.mt-vacio h2 { margin: 6px 0 0; font-family: var(--arc-display, inherit); font-size: 20px; font-weight: 500; }
.mt-vacio p { margin: 0 0 6px; max-width: 460px; color: var(--fc-muted); font-size: 14px; }
.mt-vacio .ico { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 16px; background: var(--ev-v0); color: var(--ev-tinta-verde); }
.mt-resultado .ev-seg button { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; }
.mt-descargar { min-height: 38px; }
.mt-total { display: grid; gap: 4px; padding: 18px 0 8px; }
.mt-total b { font-family: var(--arc-display, inherit); font-size: 44px; font-weight: 400; letter-spacing: -.045em; font-variant-numeric: tabular-nums; }
.mt-total span { color: var(--fc-muted); font-size: 14px; }
.mt-resto { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 0 22px 18px; color: var(--fc-muted); font-size: 13px; }
.mt-resto .ev-mas { width: auto; margin: 0; padding: 6px 12px; }
.mt-nota { margin: 10px 0 0; color: var(--fc-muted); font-size: 12.5px; }
.mt-columnas { height: 280px; }

/* Leyenda de las series */
.mt-leyenda { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 12px; font-size: 13px; color: var(--fc-muted); }
.mt-leyenda span { display: inline-flex; align-items: center; gap: 7px; }
.mt-leyenda i { width: 10px; height: 10px; border-radius: 3px; }

/* Cruce con lo demás: cada fila con una barra por serie */
.mt-grupos { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.mt-grupos li { display: grid; grid-template-columns: minmax(120px, 200px) minmax(0, 1fr); gap: 16px; align-items: center; padding: 10px 8px; border-radius: 14px; animation: arc-entrada var(--arc-considered, 480ms) var(--arc-ease-enter, ease) both; animation-delay: calc(var(--i) * 40ms); }
.mt-grupos li:hover { background: var(--fc-row-hover); }
.mt-grupo-nombre { display: grid; gap: 2px; min-width: 0; }
.mt-grupo-nombre b { font-weight: 500; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-grupo-nombre small { color: var(--fc-muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.mt-grupo-barras { display: grid; gap: 3px; min-width: 0; }
.mt-gb { display: grid; grid-template-columns: minmax(0, 1fr) 76px; align-items: center; gap: 10px; }
.mt-gb i { display: block; height: 7px; width: calc(var(--w) * 100%); min-width: 2px; border-radius: 4px; transform-origin: left; animation: arc-barra-crece 800ms var(--arc-ease-enter, ease) both; }
.mt-gb small { font-size: 11.5px; color: var(--fc-muted); font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }

/* Tiempo cruzado: una línea por serie */
.mt-lineas { height: 300px; padding-top: 10px; }
.mt-lienzo { position: relative; height: 100%; }
.mt-lienzo svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.mt-lienzo path { stroke-dasharray: 3000; stroke-dashoffset: 3000; animation: mt-traza 1.1s var(--arc-ease-enter, ease) forwards; animation-delay: calc(var(--j) * 90ms); }
@keyframes mt-traza { to { stroke-dashoffset: 0; } }
.mt-punto { position: absolute; width: 7px; height: 7px; margin: 0 0 -3.5px -3.5px; border-radius: 50%; box-shadow: 0 0 0 2px var(--fc-card); pointer-events: none; animation: arc-entrada 400ms ease both; animation-delay: calc(var(--j) * 90ms + 500ms); }
.mt-rejilla { stroke: var(--fc-border); stroke-width: 1; }
.mt-lienzo::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; border-top: 1px solid var(--fc-border); }
.mt-col { position: absolute; top: 0; bottom: 0; width: 28px; margin-left: -14px; padding: 0; border: 0; background: transparent; cursor: default; font: inherit; color: inherit; }
.mt-col:hover::before, .mt-col:focus-visible::before { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; border-left: 1px dashed var(--ev-v3); }
.mt-col:focus { outline: none; }
.mt-col .etq { position: absolute; left: 50%; bottom: -24px; transform: translateX(-50%); font-size: 11.5px; color: var(--fc-muted); white-space: nowrap; }
.mt-globo-series { display: grid; gap: 3px; margin-top: 4px; }
.mt-globo-series span { display: grid; grid-template-columns: 9px auto auto; align-items: center; gap: 7px; font-size: 12px; }
.mt-globo-series i { width: 9px; height: 9px; border-radius: 3px; }
.mt-globo-series b { justify-self: end; padding-left: 10px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Tabla ---------- */
.mt-tabla-caja { padding: 8px 14px 14px; }
.mt-tabla { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.mt-tabla th { padding: 10px; border-bottom: 1px solid var(--fc-border); color: var(--fc-muted); font-size: 12px; font-weight: 500; text-align: right; white-space: nowrap; }
.mt-tabla td { padding: 10px; border-bottom: 1px solid var(--fc-border); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mt-tabla th:first-child, .mt-tabla td:first-child { text-align: left; white-space: normal; }
.mt-tabla td:first-child { font-weight: 500; }
.mt-tabla tbody tr:hover td { background: var(--fc-row-hover); }
.mt-tabla tfoot td { border-bottom: 0; font-weight: 600; }

/* Ancho justo: la tabla suelta las columnas menos importantes antes que hacer scroll de lado */
@container (max-width: 900px) {
  .mt-tabla:not(.cruce) th:nth-child(6), .mt-tabla:not(.cruce) td:nth-child(6),
  .mt-tabla:not(.cruce) th:nth-child(7), .mt-tabla:not(.cruce) td:nth-child(7) { display: none; }
}
@container (max-width: 640px) {
  .mt-tabla:not(.cruce) th:nth-child(4), .mt-tabla:not(.cruce) td:nth-child(4),
  .mt-tabla:not(.cruce) th:nth-child(5), .mt-tabla:not(.cruce) td:nth-child(5) { display: none; }
  .mt-tabla-caja { overflow-x: auto; }
  .mt-ia { padding: 14px; }
  .mt-preguntar { flex-wrap: wrap; padding: 6px; }
  .mt-preguntar input { flex-basis: calc(100% - 40px); }
  .mt-preguntar .ev-btn { width: 100%; justify-content: center; }
  .mt-separa { display: none; }
  .mt-grupos li { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .mt-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mt-kpis .ev-kpi:nth-child(2) { border-right: 0; }
  .mt-kpis .ev-kpi:nth-child(-n + 2) { border-bottom: 1px solid var(--fc-border); }
  .mt-resultado .ev-bloque-cab { align-items: flex-start; }
}
@media (max-width: 800px) {
  .mt-controles [data-campo="nuevo-filtro"] > button { flex-direction: row; align-items: center; justify-content: center; gap: 8px; }
  .mt-chip > button:first-child { flex: 1; }
  .mt-ejemplos button { text-align: left; padding: 6px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .mt-lienzo path { animation: none; stroke-dashoffset: 0; }
  .mt-respuesta.pensando span, .mt-gb i, .mt-grupos li { animation: none; }
}
