/* Mercado · interfaz de tiendas. Sin compilación ni dependencias. */
:root {
  --fondo: #f7f7f5;
  --papel: #ffffff;
  --tinta: #1d1d1b;
  --suave: #6b6b66;
  --linea: #e6e5e0;
  --acento: #2f7d1e;
  --acento-suave: #e7f3df;
  --ventas: #16a34a;
  --trafico: #16a34a;
  --meta: #7c3aed;
  --unidades: #0891b2;
  --otra: #2563eb;
  --radio: 10px;
  --sombra: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--tinta);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--fondo); }
img { display: block; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; color: inherit; }
a { color: inherit; }

/* ── barra superior ── */
.barra {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px; background: var(--papel); border-bottom: 1px solid var(--linea);
}
.marca { font-weight: 700; font-size: 16px; white-space: nowrap; }
.marca-sub { font-weight: 500; color: var(--suave); }
.buscador {
  flex: 1; max-width: 460px; margin: 0 auto;
  display: flex; align-items: center; gap: 8px;
  background: #efefec; border-radius: 10px; padding: 7px 12px;
}
.buscador svg { width: 16px; height: 16px; fill: none; stroke: var(--suave); stroke-width: 2; flex: none; }
.buscador input { border: 0; background: transparent; outline: none; width: 100%; }
.salud { color: var(--suave); font-size: 12px; white-space: nowrap; }

main { padding: 14px 20px 40px; }

/* ── filtros ── */
.panel-filtros {
  background: var(--papel); border: 1px solid var(--linea); border-radius: var(--radio);
  padding: 12px 14px; box-shadow: var(--sombra);
}
.filtros { display: flex; flex-wrap: wrap; gap: 8px; }
.filtro { position: relative; }
.pastilla {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--linea); background: var(--papel); border-radius: 8px;
  padding: 6px 10px; white-space: nowrap;
}
.pastilla:hover { border-color: #c9c8c1; }
.pastilla.activa { background: var(--acento); border-color: var(--acento); color: #fff; }
.pastilla .flecha { font-size: 10px; opacity: .7; }
.pop {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 30;
  min-width: 240px; background: var(--papel); border: 1px solid var(--linea);
  border-radius: var(--radio); box-shadow: 0 8px 30px rgba(0,0,0,.12); padding: 12px;
}
.pop label { display: block; font-size: 12px; color: var(--suave); margin-bottom: 8px; }
.pop input, .pop select {
  display: block; width: 100%; margin-top: 3px;
  border: 1px solid var(--linea); border-radius: 6px; padding: 6px 8px; background: #fff;
}
.pop .par { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pop .acciones { display: flex; justify-content: space-between; gap: 8px; margin-top: 4px; }
.activos { display: flex; align-items: center; gap: 10px; margin-top: 10px; min-height: 0; }
.activos:has(.chips:empty) { margin-top: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--acento-suave); color: #23561a; border-radius: 6px; padding: 4px 8px; font-size: 13px;
}
.chip button { border: 0; background: none; padding: 0 2px; font-size: 15px; line-height: 1; color: inherit; }

.btn {
  border: 1px solid var(--acento); background: var(--acento); color: #fff;
  border-radius: 8px; padding: 6px 14px;
}
.btn.sec { background: #fff; color: var(--tinta); border-color: var(--linea); }
.btn-icono { border: 1px solid var(--linea); background: #fff; border-radius: 6px; padding: 3px 8px; }
.enlace { border: 0; background: none; color: var(--suave); text-decoration: underline; }

/* ── orden y contador ── */
.barra-orden { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 14px 2px 10px; }
.orden { display: flex; align-items: center; gap: 8px; color: var(--suave); }
.orden select { border: 1px solid var(--linea); border-radius: 6px; padding: 4px 6px; background: #fff; color: var(--tinta); font-weight: 600; }
.contador { text-align: right; color: var(--suave); font-size: 13px; }
.contador b { color: var(--tinta); }

/* ── tabla ── */
.tabla-envoltura {
  background: var(--papel); border: 1px solid var(--linea); border-radius: var(--radio);
  overflow-x: auto; box-shadow: var(--sombra);
}
.tabla { width: 100%; border-collapse: collapse; min-width: 1320px; }
.tabla th {
  position: sticky; top: 0; background: #fafaf8; text-align: left; font-weight: 500; color: var(--suave);
  padding: 10px 12px; border-bottom: 1px solid var(--linea); white-space: nowrap; font-size: 13px;
}
.tabla td { padding: 10px 12px; border-bottom: 1px solid var(--linea); vertical-align: middle; }
.tabla tbody tr { cursor: pointer; }
.tabla tbody tr:hover td { background: #fbfbf9; }
.c-tienda { width: 250px; border-right: 1px solid var(--linea); }
.c-nicho { width: 170px; }
.c-vendidos { width: 290px; }
.c-ingresos, .c-visitas { width: 170px; }
.c-meta { width: 190px; }
.c-actividad { width: 260px; }

.tienda { display: flex; align-items: center; gap: 10px; }
.tienda-img { position: relative; flex: none; width: 76px; height: 50px; }
.tienda-img .pantalla { width: 76px; height: 50px; object-fit: cover; object-position: top; border-radius: 6px; border: 1px solid var(--linea); background: #f0f0ed; }
.tienda-img .logo { position: absolute; right: -6px; bottom: -6px; width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff; background: #fff; object-fit: contain; }
.tienda-txt { min-width: 0; }
.tienda-nombre { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.tienda-dominio { color: var(--suave); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; text-decoration: none; display: block; }
.tienda-dominio:hover { text-decoration: underline; }
.tienda-meta { color: var(--suave); font-size: 12px; margin-top: 2px; white-space: nowrap; }
.bandera { font-size: 14px; }

.etiquetas { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; }
.etiqueta { border: 1px solid var(--linea); border-radius: 999px; padding: 3px 10px; font-size: 12px; white-space: nowrap; }
.vacio { color: #b3b2ab; }

.vendidos { display: flex; gap: 6px; }
.producto { position: relative; width: 84px; height: 84px; border-radius: 6px; overflow: hidden; background: #f0f0ed; border: 1px solid var(--linea); }
.producto img { width: 100%; height: 100%; object-fit: cover; }
.producto .precio { position: absolute; left: 4px; bottom: 4px; background: rgba(255,255,255,.92); border-radius: 4px; padding: 1px 5px; font-size: 11px; font-weight: 600; }
.nota { color: var(--suave); font-size: 12px; margin-top: 5px; }
.nota b { color: var(--tinta); }

.metrica { display: flex; align-items: center; gap: 10px; }
.metrica-num { min-width: 70px; }
.cifra { font-size: 15px; font-weight: 600; white-space: nowrap; }
.cifra .punto { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--ventas); margin-right: 5px; vertical-align: middle; }
.sub { color: var(--suave); font-size: 12px; margin-top: 2px; white-space: nowrap; }
.banderas { font-size: 13px; margin-top: 3px; letter-spacing: 1px; white-space: nowrap; }
svg.curva { width: 72px; height: 40px; flex: none; overflow: visible; }

.recientes { display: flex; gap: 6px; }
.anuncio {
  position: relative; width: 76px; height: 100px; border-radius: 6px; overflow: hidden;
  border: 1px solid var(--linea); background: #f0f0ed; padding: 0;
}
.anuncio img { width: 100%; height: 100%; object-fit: cover; }
.anuncio .play {
  position: absolute; right: 4px; bottom: 4px; width: 20px; height: 20px; border-radius: 50%;
  background: rgba(255,255,255,.9); display: grid; place-items: center; font-size: 9px;
}

.pie-lista { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 14px; }
.estado { color: var(--suave); font-size: 13px; }
.estado.error { color: #b42318; }
#centinela { height: 1px; }

/* ── ficha ── */
.ficha, .visor { position: fixed; inset: 0; z-index: 50; }
.ficha-fondo, .visor-fondo { position: absolute; inset: 0; background: rgba(20,20,18,.35); }
.ficha-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(980px, 100%);
  background: var(--fondo); overflow-y: auto; padding: 22px 26px 40px; box-shadow: -8px 0 30px rgba(0,0,0,.15);
}
.cerrar {
  position: absolute; top: 12px; right: 14px; border: 0; background: #fff; width: 32px; height: 32px;
  border-radius: 50%; font-size: 20px; line-height: 1; box-shadow: var(--sombra); z-index: 2;
}
.ficha-cabeza { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 18px; padding-right: 40px; }
.ficha-cabeza .pantalla { width: 200px; height: 125px; object-fit: cover; object-position: top; border-radius: 8px; border: 1px solid var(--linea); background: #f0f0ed; flex: none; }
.ficha-cabeza h2 { margin: 0 0 4px; font-size: 22px; display: flex; align-items: center; gap: 8px; }
.ficha-cabeza h2 img { width: 26px; height: 26px; border-radius: 50%; }
.ficha-datos { color: var(--suave); line-height: 1.7; font-size: 13px; }
.ficha-datos a { color: var(--acento); }
.insignia { display: inline-block; background: #efefec; border-radius: 4px; padding: 0 6px; margin-right: 4px; font-size: 12px; color: var(--tinta); }
.bloque { background: var(--papel); border: 1px solid var(--linea); border-radius: var(--radio); padding: 14px 16px; margin-bottom: 14px; }
.bloque h3 { margin: 0 0 10px; font-size: 14px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--papel); border: 1px solid var(--linea); border-radius: var(--radio); padding: 10px 12px; }
.kpi .t { color: var(--suave); font-size: 12px; }
.kpi .v { font-size: 18px; font-weight: 600; margin-top: 2px; }
.graficos { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.grafico h4 { margin: 0 0 4px; font-size: 13px; font-weight: 600; }
.grafico .rango { color: var(--suave); font-size: 11px; }
svg.grande { width: 100%; height: auto; display: block; }
svg.grande text { font-size: 11px; fill: var(--suave); }
.lista-productos { width: 100%; border-collapse: collapse; }
.lista-productos td, .lista-productos th { padding: 6px 8px; border-bottom: 1px solid var(--linea); text-align: left; font-size: 13px; }
.lista-productos th { color: var(--suave); font-weight: 500; }
.lista-productos img { width: 48px; height: 48px; object-fit: cover; border-radius: 5px; background: #f0f0ed; }
.num { text-align: right !important; white-space: nowrap; }
.grilla-anuncios { display: flex; flex-wrap: wrap; gap: 8px; }
.grilla-anuncios .anuncio { width: 110px; height: 146px; }
.plataforma { font-size: 12px; color: var(--suave); margin: 10px 0 6px; text-transform: capitalize; }
.barras .fila { display: grid; grid-template-columns: 70px 1fr 70px; gap: 8px; align-items: center; margin: 4px 0; font-size: 13px; }
.barras .fondo-barra { background: #efefec; border-radius: 3px; height: 8px; overflow: hidden; }
.barras .barra-val { background: var(--acento); height: 100%; }
.dos { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ── visor de anuncios ── */
.visor-caja {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: #000; border-radius: 10px; padding: 0; max-width: 92vw; max-height: 92vh;
}
.visor-caja video, .visor-caja img { max-width: 92vw; max-height: 88vh; display: block; border-radius: 10px; }
.visor-caja .cerrar { top: -14px; right: -14px; }
.visor-pie { color: #ddd; font-size: 12px; padding: 6px 10px; }
.visor-pie a { color: #fff; }

@media (max-width: 760px) {
  .barra { flex-wrap: wrap; padding: 10px 16px; }
  .buscador { order: 3; max-width: none; flex-basis: 100%; }
  main { padding: 12px 16px 30px; }
  .barra-orden { flex-wrap: wrap; }
  .ficha-panel { padding: 18px 16px 30px; }
  .ficha-cabeza { flex-direction: column; }
  .dos { grid-template-columns: 1fr; }
}

/* ── universo: el filtro con que se capturó ── */
.universo {
  background: var(--papel); border: 1px solid var(--linea); border-radius: var(--radio);
  padding: 14px 16px; box-shadow: var(--sombra); margin-bottom: 14px;
}
.u-cabeza { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.u-titulo { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.u-titulo h2 { margin: 0; font-size: 17px; }
.u-frases { display: flex; flex-wrap: wrap; gap: 6px; }
.u-frase { background: var(--acento-suave); color: #23561a; border-radius: 6px; padding: 4px 9px; font-size: 13px; font-weight: 500; }
.u-selector { display: flex; align-items: center; gap: 8px; color: var(--suave); font-size: 12px; }
.u-selector select { border: 1px solid var(--linea); border-radius: 6px; padding: 4px 6px; background: #fff; color: var(--tinta); max-width: 360px; }
.u-tamano { margin: 10px 0 12px; font-size: 14px; }
.u-nota { display: inline-block; background: #fff4e5; color: #8a4b00; border-radius: 5px; padding: 1px 7px; font-size: 12px; margin-left: 4px; }
.u-gris { color: var(--suave); font-size: 12px; }
.u-kpis { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); margin-bottom: 12px; }
.u-kpis .sub { white-space: normal; }
.u-tres { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.u-tres .bloque { margin-bottom: 0; }
.u-tres h3 small { font-weight: 400; color: var(--suave); margin-left: 4px; }
.barras-u .fila-u {
  width: 100%; display: grid; grid-template-columns: 185px 1fr 120px; gap: 8px; align-items: center;
  margin: 1px 0; padding: 4px 6px; font-size: 13px; text-align: left; border: 1px solid transparent; border-radius: 6px; background: none;
}
.barras-u .fila-u:hover { background: var(--acento-suave); border-color: #cfe5c2; }
.barras-u .fila-u:hover .nombre-u { text-decoration: underline; }
.barras-u .fila-u.elegida { background: var(--acento-suave); border-color: var(--acento); font-weight: 600; }
.barras-u .fondo-barra, .barras-u .barra-val { display: block; }
.barras-u .nombre-u { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barras-u .fondo-barra { background: #efefec; border-radius: 3px; height: 8px; overflow: hidden; }
.barras-u .barra-val { background: var(--acento); height: 100%; }
.lideres { margin: 0; padding: 0; list-style: none; counter-reset: l; }
.lideres li { counter-increment: l; }
.lideres button {
  width: 100%; display: flex; align-items: center; gap: 8px; border: 0; background: none;
  padding: 5px 4px; border-radius: 6px; text-align: left;
}
.lideres button::before { content: counter(l); color: var(--suave); width: 14px; font-size: 12px; }
.lideres button:hover { background: #f4f4f1; }
.u-logo { width: 22px; height: 22px; border-radius: 50%; object-fit: contain; background: #fff; border: 1px solid var(--linea); flex: none; }
.u-dom { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.u-dom small { color: var(--suave); font-size: 11px; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1100px) { .u-tres { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .barras-u .fila-u { grid-template-columns: 110px 1fr 100px; } }

/* ── favoritos ── */
.tienda-linea { display: flex; align-items: center; gap: 4px; }
.corazon {
  border: 0; background: none; padding: 0 3px; font-size: 17px; line-height: 1; color: #b3b2ab; cursor: pointer;
  border-radius: 4px;
}
.corazon:hover { color: #e11d48; background: #fff1f3; }
.corazon.on { color: #e11d48; }
.ficha-cabeza h2 .corazon { font-size: 22px; }
.derecha { display: flex; align-items: center; gap: 14px; }
.btn-fav { border: 1px solid var(--linea); background: #fff; border-radius: 8px; padding: 5px 12px; color: #e11d48; font-weight: 600; }
.btn-fav:hover { background: #fff1f3; }
.btn-fav.activa { background: #e11d48; border-color: #e11d48; color: #fff; }
.chip-fav { background: #ffe4e8; color: #9f1239; font-weight: 600; }
.nota-fav { color: var(--suave); font-size: 13px; align-self: center; }
body.vista-favoritos #universo, body.vista-favoritos .filtros { display: none; }
body.vista-favoritos .activos { margin-top: 0; }

/* Navegación de drophelper: ir a la home o cambiar de herramienta */
.dh-nav { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.dh-home { font-weight: 800; font-size: 16px; text-decoration: none; color: inherit; }
.dh-home:hover { text-decoration: underline; text-underline-offset: 3px; }
.dh-herr { display: inline-flex; border: 1px solid #d6d6d0; border-radius: 8px; overflow: hidden; }
.dh-herr a { padding: 5px 11px; font-size: 14px; font-weight: 600; text-decoration: none; color: var(--suave, #555); }
.dh-herr a + a { border-left: 1px solid #d6d6d0; }
.dh-herr a[aria-current="page"] { background: #13203b; color: #fff; }
.dh-herr a:not([aria-current]):hover { background: #f0f0ec; color: inherit; }

.aviso-rastro { color: var(--suave); font-size: 12px; margin-top: 18px; text-align: center; }
