:root {
  --bg-base: #F5F0EB;
  --bg-card: rgba(255, 255, 255, 0.70);
  --bg-card-2: rgba(255, 255, 255, 0.90);
  --bg-input: rgba(255, 255, 255, 0.80);
  --border: rgba(45, 42, 38, 0.08);
  --border-light: rgba(45, 42, 38, 0.05);
  --text-primary: #2D2A26;
  --text-secondary: rgba(45, 42, 38, 0.60);
  --text-muted: rgba(45, 42, 38, 0.35);
  --accent-a: #7947F8;
  --accent-a-end: #A855F7;
  --accent-a-grad: linear-gradient(135deg, #7947F8, #A855F7);
  --accent-a-soft: rgba(121, 71, 248, 0.10);
  --accent-b: #4A9EFF;
  --green: #5C8A6C;
  --green-soft: rgba(92, 138, 108, 0.12);
  --red: #E05252;
  --red-soft: rgba(224, 82, 82, 0.12);
  --radius-sm: 8px;
  --radius: 16px;
  --radius-lg: 20px;
  --shadow: 0 1px 4px rgba(45, 42, 38, 0.06);
  --shadow-md: 0 4px 16px rgba(45, 42, 38, 0.08);
  --font: 'Poppins', system-ui, sans-serif;
  --nav-height: 60px;
}

* { box-sizing: border-box; }
/* overflow-x: clip (no 'hidden'): evita la barra de scroll horizontal en cualquier
   ancho sin convertir el body en contenedor de scroll ni forzar el eje vertical.
   Necesario porque los tooltips de ayuda (position:absolute) podían desbordar en
   anchos intermedios. */
html { max-width: 100%; overflow-x: clip; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 14px;
  max-width: 100%;
  overflow-x: clip;
}

nav {
  position: fixed; top: 0; width: 100%; height: var(--nav-height);
  padding: 0 32px; background: rgba(245, 240, 235, 0.85);
  backdrop-filter: blur(16px); border-bottom: 1px solid var(--border);
  z-index: 100; display: flex; align-items: center; gap: 6px;
}
.brand { font-weight: 700; color: var(--text-primary); margin-right: 18px; }
.brand::before { content: "● "; color: var(--accent-a); }
.tab {
  font-size: 13px; font-weight: 600; color: var(--text-secondary);
  padding: 6px 14px; border-radius: var(--radius-sm); cursor: pointer; border: none;
  background: transparent;
}
.tab.active { color: var(--accent-a); background: var(--accent-a-soft); }
.tab:disabled { opacity: .4; cursor: default; color: var(--text-muted); background: transparent; }
.nav-sep { width: 1px; height: 20px; background: var(--border); margin: 0 8px; }
/* En escritorio la barra puede encoger y hacer scroll horizontal interno si hay muchas
   páginas, para no desbordar ni empujar el menú de usuario (nav-right queda siempre visible). */
.nav-tabs { display: flex; align-items: center; gap: 6px; min-width: 0;
  overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.nav-tabs::-webkit-scrollbar { display: none; }
.nav-tabs .tab { flex: 0 0 auto; white-space: nowrap; }
.nav-tabs .nav-switch { flex: 0 0 auto; }
.nav-tabs .nav-subrow { flex: 0 0 auto; }
.nav-tabs .nav-subtab { flex: 0 0 auto; white-space: nowrap; }

/* Objetos de entidad como INTERRUPTOR (segmented slider): Tienda | Web dentro de una
   "pista" (track) redondeada; el segmento activo es el "knob" resaltado. Las sub-páginas del
   objeto activo salen en .nav-subrow, en línea tras el interruptor. */
.nav-switch {
  position: relative; display: inline-flex; align-items: center; gap: 0;
  background: rgba(45, 42, 38, 0.05); border-radius: 999px; padding: 3px;
}
/* Knob: una sola pieza que se DESLIZA al segmento activo. Segmentos de igual ancho, así que
   su posición es índice × ancho-de-segmento (translateX en múltiplos de su propio ancho). */
.nav-switch-knob {
  position: absolute; top: 3px; bottom: 3px; left: 3px;
  width: calc((100% - 6px) / var(--knob-count, 2));
  transform: translateX(calc(var(--knob-index, 0) * 100%));
  background: var(--bg-card-2); border-radius: 999px; box-shadow: var(--shadow);
  transition: transform .24s cubic-bezier(.4, 0, .2, 1); pointer-events: none;
}
.nav-switch.nav-switch-noknob .nav-switch-knob { opacity: 0; }
.nav-switch .nav-obj {
  position: relative; z-index: 1; flex: 1 1 0; text-align: center;
  font-size: 13px; font-weight: 700; color: var(--text-secondary);
  padding: 6px 16px; border-radius: 999px; cursor: pointer; border: none;
  background: transparent; white-space: nowrap; transition: color .18s ease;
}
.nav-switch .nav-obj:hover { color: var(--text-primary); }
.nav-switch .nav-obj.active { color: var(--accent-a); }
.nav-switch .nav-obj.nav-obj-web.active { color: #0379D9; }
/* Sub-páginas del objeto activo, en línea tras el interruptor (separadas por un divisor sutil). */
.nav-subrow { display: inline-flex; align-items: center; gap: 4px;
  margin-left: 10px; padding-left: 12px; border-left: 1px solid var(--border); }
.nav-subrow.nav-group-web .nav-subtab.active { color: #0379D9; background: rgba(3, 121, 217, 0.10); }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 16px; flex: 0 0 auto; }
/* Menú de hamburguesa (oculto en escritorio; visible en móvil por media query) */
.nav-toggle { display: none; flex-direction: column; justify-content: center; gap: 5px;
  width: 38px; height: 34px; padding: 7px 8px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: transparent; cursor: pointer; margin-right: 2px; }
.nav-toggle[hidden] { display: none !important; }
.nav-toggle-bar { display: block; width: 100%; height: 2px; border-radius: 2px;
  background: var(--text-primary); transition: transform .2s ease, opacity .2s ease; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
@media (max-width: 860px) {
  .nav-toggle { display: flex; }
  .nav-tabs {
    position: absolute; top: var(--nav-height); left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 2px; padding: 8px; margin: 0;
    background: rgba(245, 240, 235, 0.97); backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border); box-shadow: 0 12px 26px rgba(45,42,38,.14);
    overflow: visible; -webkit-mask-image: none; mask-image: none;
    display: none;
  }
  .nav-tabs.open { display: flex; }
  .nav-tabs .tab { width: 100%; text-align: left; padding: 11px 14px; font-size: 14px; border-radius: 10px; }
  /* En móvil, dentro del desplegable: el interruptor ocupa el ancho (segmentos al 50%) y las
     sub-páginas del objeto activo quedan debajo, indentadas (acordeón). */
  .nav-tabs .nav-switch { width: 100%; }
  .nav-tabs .nav-switch .nav-obj { flex: 1 1 0; text-align: center; padding: 9px 12px; }
  .nav-tabs .nav-subrow { flex-direction: column; align-items: stretch; width: 100%;
    margin: 4px 0 0; padding: 0; border-left: none; gap: 2px; }
  .nav-tabs .nav-subtab { width: 100%; text-align: left; padding: 9px 14px 9px 26px; font-size: 14px; border-radius: 10px; }
}
.period-tabs { display: inline-flex; gap: 4px; background: rgba(45,42,38,0.05); padding: 4px; border-radius: 999px; }
.period-tabs .ptab { border: none; background: transparent; font-size: 13px; font-weight: 600;
  color: var(--text-secondary); padding: 6px 16px; border-radius: 999px; cursor: pointer; }
.period-tabs .ptab.active { background: var(--accent-a-grad); color: #fff; }

/* Barra de filtros compacta (estilo Analytics) */
.filterbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.filterbar .period { display: flex; align-items: center; gap: 6px; }
.filterbar .dash { color: var(--text-muted); font-weight: 600; }
.filterbar .fb-sep { width: 1px; align-self: stretch; background: var(--border); margin: 2px 4px; }
.sel-sm, .inp-sm { width: auto; min-width: 0; font-size: 13px; background: var(--bg-input);
  border: 1px solid var(--border); border-radius: 999px; padding: 7px 14px; color: var(--text-primary); }
.sel-sm { padding-right: 28px; }
.inp-sm { min-width: 160px; }

/* Tiendas: modos arriba; periodo y comparacion debajo ocupando el ancho. */
.analysis-view .card { padding: 14px 22px 16px; }
.analysis-view .cmp-periodbar { display: grid; grid-template-columns: 1fr; gap: 10px; align-items: stretch; }
.analysis-view .cmp-period-top { display: grid; grid-template-columns: auto minmax(320px, 1fr); gap: 12px; align-items: center; }
.analysis-view .cmp-mode-tabs { justify-self: start; }
.analysis-view .cmp-period-details { display: grid; grid-template-columns: minmax(250px, .55fr) minmax(430px, 1.45fr); gap: 12px; align-items: center; }
.analysis-view .cmp-period-details.advanced { grid-template-columns: 1fr; }
.analysis-view .cmp-period-details.advanced .cmp-chip { display: none; }
.analysis-view .period-tabs { padding: 3px; }
.analysis-view .period-tabs .ptab { padding: 5px 14px; }
.analysis-view .navperiod { width: 100%; min-height: 32px; justify-content: center; gap: 10px; padding: 0; background: transparent; border: 0; border-radius: 0; }
.analysis-view .cmp-chip {
  width: 100%; min-height: 32px; justify-content: center; background: var(--bg-card-2);
  border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px;
}
.analysis-view .navbtn { width: 28px; height: 28px; }
.analysis-view .navlbl { min-width: 170px; }
.analysis-view .navtop { font-size: 9px; line-height: 1; }
.analysis-view .navmain { font-size: 12px; font-weight: 800; }
.analysis-view .cmp-chip { font-size: 12px; gap: 7px; white-space: nowrap; overflow: hidden; }
.analysis-view .cmp-chip b { font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.analysis-view .cmp-adv-range {
  width: 100%; min-height: 32px; display: flex; align-items: center; justify-content: center;
  gap: 7px; padding: 4px 14px; border: 1px solid var(--border);
  border-radius: 999px; background: rgba(255,255,255,.72); font-size: 12px;
  white-space: nowrap; overflow: hidden;
}
.analysis-view .cmp-adv-range .dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.analysis-view .cmp-adv-range .dot-a { background: var(--accent-a); }
.analysis-view .cmp-adv-range .dot-b { background: var(--accent-b); }
.analysis-view .cmp-adv-range .vs {
  font-size: 10px; letter-spacing: .5px; color: var(--text-muted); text-transform: uppercase;
  flex: 0 0 auto;
}
.analysis-view .cmp-adv-range b { font-weight: 800; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; }
.analysis-view .cmp-adv-a { display: inline-flex; align-items: center; gap: 5px; min-width: 0; }
.analysis-view .cmp-range-arrow { color: var(--text-primary); font-weight: 800; }
.analysis-view .cmp-adv-field {
  display: inline-flex; align-items: center; gap: 5px; min-width: 0; height: 24px;
  padding: 2px 8px; border: 0; border-radius: 999px;
  background: rgba(255,255,255,.82); cursor: text; transition: background .15s, box-shadow .15s;
}
.analysis-view .cmp-adv-field:hover {
  background: #fff; box-shadow: 0 1px 4px rgba(45,42,38,.06);
}
.analysis-view .cmp-adv-field:focus-within {
  background: #fff; box-shadow: 0 0 0 3px rgba(121,71,248,.10);
}
.analysis-view .cmp-adv-field > span {
  font-size: 9px; font-weight: 800; color: var(--text-muted); letter-spacing: .06em; text-transform: uppercase;
}
/* El icono de calendario lo aporta el botón .cal-field (::before); el campo
   contenedor ya no añade otro para no duplicarlo. */
.analysis-view .cmp-date-inline {
  width: 84px; min-width: 0; height: 18px; border: 0; background: transparent; padding: 0;
  color: var(--text-primary); font-family: var(--font); font-size: 12px; font-weight: 800;
  outline: none; text-align: left; letter-spacing: 0;
}
.analysis-view .cmp-date-inline:focus { color: var(--accent-a); }

/* Campo de fecha clicable (abre el calendario propio). Sustituye a los inputs
   de texto del modo Avanzado y se usa como disparador en Día/Semana/Finde. */
.cal-field {
  display: inline-flex; align-items: center; gap: 6px; min-width: 92px; height: 24px;
  padding: 2px 10px; border: 0; border-radius: 999px; background: rgba(255,255,255,.82);
  color: var(--text-primary); font-family: var(--font); font-size: 12px; font-weight: 800;
  cursor: pointer; transition: background .15s, box-shadow .15s;
}
.cal-field::before {
  content: ""; width: 12px; height: 12px; flex: 0 0 auto; opacity: .5;
  border: 1.4px solid currentColor; border-top-width: 3px; border-radius: 2px; color: var(--text-muted);
}
.cal-field:hover { background: #fff; box-shadow: 0 1px 4px rgba(45,42,38,.08); color: var(--accent-a); }
.navlbl.cal-trigger { cursor: pointer; border-radius: 10px; padding: 2px 8px; transition: background .15s; }
.navlbl.cal-trigger:hover { background: var(--accent-a-soft); }

/* Calendario flotante (date-picker propio, formato DD/MM/YYYY). */
.cal-pop {
  position: fixed; z-index: 200; display: none; width: 268px; padding: 12px;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-md); font-family: var(--font); color: var(--text-primary);
}
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-title { font-size: 13px; font-weight: 800; text-transform: capitalize; }
.cal-nav { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--bg-card-2); color: var(--text-secondary); font-size: 15px; line-height: 1; cursor: pointer; }
.cal-nav:hover { color: var(--accent-a); border-color: var(--accent-a); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-dow { font-size: 10px; font-weight: 700; color: var(--text-muted); text-align: center; padding: 4px 0; }
.cal-cell {
  height: 32px; display: grid; place-items: center; border: 0; background: transparent;
  border-radius: 8px; font-family: var(--font); font-size: 12px; font-weight: 600;
  color: var(--text-primary); cursor: pointer;
}
.cal-cell.muted-day { color: var(--text-muted); opacity: .5; }
.cal-cell:hover { background: var(--accent-a-soft); }
.cal-cell.in-range { background: var(--accent-a-soft); border-radius: 0; }
.cal-cell.sel { background: var(--accent-a-grad); color: #fff; }
.cal-cell.range-start { border-radius: 8px 0 0 8px; }
.cal-cell.range-end { border-radius: 0 8px 8px 0; }
.cal-cell.range-start.range-end { border-radius: 8px; }
.cal-foot { margin-top: 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cal-hint { font-size: 10px; color: var(--text-muted); }
.cal-today { background: transparent; border: 0; color: var(--accent-a); font-size: 11px; font-weight: 700; cursor: pointer; }
.cal-today:hover { text-decoration: underline; }
@media (max-width: 640px) { .cal-pop { width: calc(100vw - 24px); } }

/* Multiselección (chips + desplegable). Campo .ms que sustituye a los input+datalist. */
.analysis-view .cmp-filter .ms { width: 100%; }
.ms {
  box-sizing: border-box; min-height: 34px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--bg-input);
  padding: 3px 8px; font-family: var(--font); font-size: 13px; color: var(--text-primary); cursor: pointer;
}
.ms:hover { border-color: var(--accent-a); }
.ms.has-sel { background: var(--accent-a-soft); }
.ms .ms-ph { color: var(--text-muted); }
.ms .ms-chip {
  display: inline-flex; align-items: center; gap: 4px; max-width: 100%;
  background: #fff; border: 1px solid var(--border); color: var(--accent-a);
  border-radius: 999px; padding: 2px 6px 2px 9px; font-size: 12px; font-weight: 600;
  white-space: nowrap; overflow: hidden;
}
.ms .ms-x {
  border: 0; background: transparent; color: var(--text-muted); cursor: pointer;
  font-size: 14px; line-height: 1; padding: 0 2px;
}
.ms .ms-x:hover { color: var(--accent-a); }

.ms-pop {
  position: fixed; z-index: 300; display: none; width: 264px; max-width: calc(100vw - 16px); padding: 8px;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-md); font-family: var(--font); color: var(--text-primary);
}
.ms-pop .ms-search {
  width: 100%; box-sizing: border-box; padding: 6px 8px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 13px; background: var(--bg-input); font-family: var(--font);
}
.ms-pop .ms-list { max-height: 240px; overflow-y: auto; margin: 6px 0; }
.ms-pop .ms-opt {
  display: flex; align-items: flex-start; gap: 8px; padding: 6px 8px; border-radius: 6px;
  font-size: 13px; line-height: 1.35; cursor: pointer; text-align: left;
}
.ms-pop .ms-opt:hover { background: var(--accent-a-soft); }
.ms-pop .ms-opt input[type="checkbox"] {
  flex: 0 0 auto; width: 16px; height: 16px; min-width: 16px; margin: 1px 0 0; accent-color: var(--accent-a);
}
.ms-pop .ms-opt span {
  flex: 1 1 auto; min-width: 0; text-align: left; white-space: normal; overflow-wrap: anywhere;
}
.ms-pop .ms-empty { padding: 10px; color: var(--text-muted); font-size: 12px; text-align: center; }
.ms-pop .ms-foot {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  border-top: 1px solid var(--border); padding-top: 6px;
}
.ms-pop .ms-clear { flex: 0 0 auto; border: 0; background: transparent; color: var(--accent-a); font-weight: 700; font-size: 12px; cursor: pointer; }
.ms-pop .ms-count { flex: 1 1 auto; min-width: 0; text-align: right; font-size: 11px; line-height: 1.3; color: var(--text-muted); }
@media (max-width: 640px) { .ms-pop { width: calc(100vw - 24px); } }

/* Herramientas de filtrado: buscador general + limpieza rápida. */
.analysis-view .cmp-filter-tools {
  display: grid; grid-template-columns: minmax(360px, 1fr) auto; gap: 12px; align-items: end; margin-top: 12px;
}
.analysis-view .cmp-global-search { min-width: 0; }
.analysis-view .cmp-global-search .inp-sm { width: 100%; min-width: 0; }
.analysis-view .cmp-clear-btn {
  min-height: 34px; padding-inline: 16px; background: rgba(255,255,255,.55); white-space: nowrap;
}
.analysis-view .cmp-clear-btn:hover { color: var(--accent-a); border-color: rgba(121,71,248,.28); background: var(--accent-a-soft); }

/* Filtros de Tiendas: 5 arriba y el resto debajo. */
.analysis-view .cmp-filter-grid {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px 12px; align-items: end;
}
.analysis-view .cmp-filter { min-width: 0; }
.analysis-view .cmp-filter .sel-sm,
.analysis-view .cmp-filter .inp-sm { width: 100%; min-width: 0; }
.analysis-view .cmp-filter .field { margin: 0 0 4px; }
.analysis-view .sel-sm,
.analysis-view .inp-sm { padding-top: 6px; padding-bottom: 6px; min-height: 34px; }
.analysis-view .cmp-filter-extra { grid-column: span 1; }
.cmp-slicer {
  position: relative; width: 100%; height: 34px; display: inline-flex; align-items: center; justify-content: flex-start; gap: 8px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--bg-input);
  color: var(--text-primary); font-family: var(--font); font-size: 13px; font-weight: 700; cursor: pointer;
  padding: 0 12px 0 52px;
}
.cmp-slicer::before {
  content: ""; position: absolute; left: 12px; width: 30px; height: 18px; border-radius: 999px;
  background: rgba(45,42,38,.16); transition: background .15s;
}
.cmp-slicer .switch-dot {
  position: absolute; left: 14px; width: 14px; height: 14px; border-radius: 999px;
  background: #fff; box-shadow: 0 1px 3px rgba(45,42,38,.22); transition: transform .15s;
}
.cmp-slicer.on { color: var(--accent-a); border-color: rgba(121,71,248,.22); background: rgba(121,71,248,.06); }
.cmp-slicer.on::before { background: var(--accent-a-grad); }
.cmp-slicer.on .switch-dot { transform: translateX(12px); }
.cmp-slicer .switch-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmp-slicer:hover { border-color: var(--accent-a); }
.analysis-export-tools {
  display: flex; justify-content: flex-end; align-items: center;
  gap: 10px; margin: -8px 2px 18px;
}
.analysis-export-tools .cmp-slicer { width: auto; min-width: 190px; background-color: var(--bg-card); }

@media (max-width: 640px) {
  .analysis-export-tools { align-items: stretch; flex-direction: column; }
  .analysis-export-tools .cmp-slicer,
  .analysis-export-tools .export-btn { width: 100%; }
}
.export-btn { min-height: 34px; padding-inline: 18px; white-space: nowrap; }
.export-btn:disabled { opacity: .62; cursor: wait; }
.analysis-view .cmp-period-msg .msg { margin-top: 10px; padding-top: 7px; padding-bottom: 7px; }
.cmp-period-msg { justify-self: end; max-width: 100%; width: fit-content; text-align: right; }
.cmp-period-msg .msg { margin-top: 0 !important; padding: 7px 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Barra de periodo estilo Analytics */
.periodbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.periodbar .period-tabs { flex-wrap: wrap; }
.sel-mini { width: auto; min-width: 0; border: none; background: transparent; font-size: 13px;
  font-weight: 600; color: var(--accent-a); padding: 4px 4px; cursor: pointer; }
.cmp-chip { display: flex; align-items: center; gap: 8px; background: var(--bg-card-2);
  border: 1px solid var(--border); border-radius: 999px; padding: 7px 16px; font-size: 13px; }
.cmp-chip b { font-weight: 700; color: var(--text-primary); }
.cmp-chip .vs { font-size: 10px; letter-spacing: .5px; color: var(--text-muted); text-transform: uppercase; }
.cmp-chip .dot { width: 9px; height: 9px; border-radius: 50%; }
.cmp-chip .dot-a { background: var(--accent-a); }
.cmp-chip .dot-b { background: var(--accent-b); }

/* Navegador de periodo con flechas (estilo Analytics) */
.navperiod { display: flex; align-items: center; gap: 12px; }
.navbtn { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--bg-card-2); color: var(--text-secondary); font-size: 16px; line-height: 1; cursor: pointer; }
.navbtn:hover { color: var(--accent-a); border-color: var(--accent-a); }
.navlbl { display: flex; flex-direction: column; align-items: center; min-width: 150px; }
.navtop { font-size: 10px; font-weight: 600; letter-spacing: 1px; color: var(--text-muted); text-transform: uppercase; }
.navmain { font-size: 16px; font-weight: 800; color: var(--text-primary); letter-spacing: -.3px; }
.token-box { display: flex; align-items: center; gap: 8px; }
.token-box input { width: 200px; }
.nav-status { display: grid; place-items: center; width: 24px; height: 30px; flex: 0 0 auto; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); flex: 0 0 auto; }
.status-dot.err { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.nav-user { position: relative; display: flex; align-items: center; gap: 8px; min-width: 0; }
.nav-user[hidden] { display: none !important; }
.nav-profile {
  width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--border);
  display: grid; place-items: center; background: rgba(255,255,255,.68);
  color: var(--text-secondary); cursor: pointer; padding: 0; flex: 0 0 auto;
}
.nav-profile:hover { color: var(--accent-a); border-color: rgba(121,71,248,.35); background: var(--accent-a-soft); }
.nav-profile svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-logout { min-height: 28px; padding: 4px 10px; font-size: 11px; }

/* ── Cuadro de usuario con menú desplegable (perfil / accesos admin / salir) ── */
.user-trigger {
  display: flex; align-items: center; gap: 9px; padding: 4px 8px 4px 4px; font: inherit;
  border: 1px solid var(--border); border-radius: 999px; background: rgba(255,255,255,.68);
  color: var(--text-primary); cursor: pointer; max-width: 210px;
}
.user-trigger:hover { border-color: rgba(121,71,248,.35); background: var(--accent-a-soft); }
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: 0 0 auto; display: grid; place-items: center;
  background: var(--accent-a-grad); color: #fff; font-weight: 600; font-size: 13px;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; text-align: left; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: 9.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.user-chev { width: 16px; height: 16px; flex: 0 0 auto; fill: none; stroke: var(--text-muted);
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
.user-trigger[aria-expanded="true"] .user-chev { transform: rotate(180deg); }

.user-menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 120; min-width: 214px; padding: 6px;
  background: rgba(255,255,255,.97); backdrop-filter: blur(16px); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: 0 12px 26px rgba(45,42,38,.14);
  display: flex; flex-direction: column; gap: 2px;
}
.user-menu[hidden] { display: none; }
.user-menu-item {
  display: block; width: 100%; text-align: left; padding: 9px 12px; font: inherit; font-size: 13px;
  border: none; background: transparent; border-radius: 9px; color: var(--text-primary); cursor: pointer;
}
.user-menu-item:hover { background: var(--accent-a-soft); color: var(--accent-a); }
.user-menu-item[hidden] { display: none; }
.user-menu-danger { margin-top: 2px; border-top: 1px solid var(--border-light); padding-top: 10px; }
.user-menu-danger:hover { background: var(--red-soft); color: var(--red); }

.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-head .section-title { margin-bottom: 0; }
.card-head-actions { display: flex; align-items: center; gap: 8px; }

.kpi-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.kpi { flex: 1; min-width: 150px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.kpi-label { font-size: 10px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 1px; }
.kpi-value { font-size: 28px; font-weight: 800; color: var(--accent-a); letter-spacing: -1px; margin-top: 6px; }
.kpi-value.pos { color: var(--green); }
.kpi-value.neg { color: var(--red); }
.product-kpi-grid {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px; align-items: stretch; margin-bottom: 20px;
}
/* Las tarjetas de Producto usan el MISMO estilo que las de Tiendas: flujo normal
   (etiqueta · valor · subtexto con badge). La rejilla externa (align-items:stretch)
   iguala la altura de las tarjetas de cada fila, así que no hace falta alto fijo
   —que era lo que recortaba el badge de %—. */
.product-kpi-grid .kpi {
  min-width: 0; min-height: 150px; padding: 18px 20px;
  overflow: visible; position: relative;
}
.kpi.has-help {
  cursor: help;
}
.kpi.has-help .kpi-label::after {
  content: "?"; display: inline-grid; place-items: center;
  width: 15px; height: 15px; margin-left: 6px; border-radius: 999px;
  background: var(--accent-a-soft); color: var(--accent-a);
  font-size: 10px; font-weight: 800; letter-spacing: 0; vertical-align: 1px;
}
.kpi.has-help:hover {
  border-color: rgba(121,71,248,.30);
  box-shadow: var(--shadow-md);
  background: rgba(255,255,255,.86);
  z-index: 50;
}
.product-kpi-grid .kpi-value {
  font-size: 28px; line-height: 1.1; letter-spacing: -1px; margin-top: 6px;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}
/* Subtexto (ant. … + badge) en flujo normal y sin recorte, igual que en Tiendas. */
.product-kpi-grid .adv-sub {
  margin-top: 8px; color: var(--text-muted); font-size: 11px; line-height: 1.35;
}
.has-help { position: relative; }
.has-help::after {
  content: attr(data-help); position: absolute; left: 12px; bottom: calc(100% + 8px);
  width: min(320px, 72vw); background: var(--text-primary); color: #fff; border-radius: var(--radius-sm);
  padding: 9px 11px; font-size: 11px; font-weight: 500; line-height: 1.35; letter-spacing: 0;
  text-transform: none; box-shadow: var(--shadow-md); opacity: 0; visibility: hidden; pointer-events: none;
  transform: translateY(4px); transition: opacity .12s, transform .12s; z-index: 40; text-align: left;
}
.has-help::before {
  content: ""; position: absolute; left: 22px; bottom: calc(100% + 2px); border: 6px solid transparent;
  border-top-color: var(--text-primary); opacity: 0; visibility: hidden; transition: opacity .12s; z-index: 41;
}
.has-help:hover::after, .has-help:hover::before,
.has-help:focus-visible::after, .has-help:focus-visible::before {
  opacity: 1; visibility: visible; transform: translateY(0);
}
th.has-help::after { left: auto; right: 0; bottom: calc(100% + 7px); }
th.has-help::before { left: auto; right: 16px; }
/* En la tabla, el tooltip CSS se desactiva: lo gestiona un bocadillo flotante
   por JS (.col-tip) con position:fixed, para que no lo recorte el contenedor con
   scroll ni infle el ancho scrollable de la matriz. */
table.matrix th.has-help::after, table.matrix th.has-help::before { content: none; }
.col-tip {
  position: fixed; z-index: 100; max-width: 320px; background: var(--text-primary);
  color: #fff; border-radius: var(--radius-sm); padding: 9px 11px; font-size: 11px;
  font-weight: 500; line-height: 1.35; box-shadow: var(--shadow-md); display: none;
  pointer-events: none; text-align: left;
}
.hier-note {
  margin: 0 0 10px; padding: 9px 12px; border-radius: var(--radius-sm); font-size: 12px;
  color: #8a5a00; background: rgba(214, 158, 46, 0.12); border: 1px solid rgba(214, 158, 46, 0.3);
}

.advanced-kpis {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  margin: -4px 0 20px; box-shadow: var(--shadow);
}
.advanced-kpis summary {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  list-style: none; cursor: pointer; padding: 12px 16px; color: var(--text-primary);
  font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px;
}
.advanced-kpis summary::-webkit-details-marker { display: none; }
.advanced-kpis summary::before {
  content: "▸"; color: var(--accent-a); font-size: 12px; transition: transform .12s;
}
.advanced-kpis[open] summary::before { transform: rotate(90deg); }
.advanced-hint { margin-left: auto; color: var(--text-muted); font-size: 11px; font-weight: 600; text-transform: none; letter-spacing: 0; }
.advanced-explain { margin: 0 16px 12px; color: var(--text-secondary); font-size: 12px; line-height: 1.5; }
.advanced-kpi-row { padding: 0 12px 12px; margin-bottom: 0; gap: 10px; }
.advanced-kpi-row .adv-kpi { min-width: 170px; padding: 12px 14px; border-radius: var(--radius-sm); box-shadow: none; }
.advanced-kpi-row .kpi-value { font-size: 20px; letter-spacing: -.4px; }
.adv-sub { margin-top: 4px; color: var(--text-muted); font-size: 11px; line-height: 1.3; }
.kpi-value.adv-unreliable { opacity: .45; }
.adv-kpi .kpi-value.adv-unreliable + .adv-sub { color: var(--warn, #b8860b); opacity: .9; }
.advanced-section { padding: 0 12px 12px; }
.advanced-section-title {
  display: flex; align-items: center; gap: 8px; margin: 4px 0 10px;
  font-size: 10px; font-weight: 800; color: var(--text-muted); text-transform: uppercase; letter-spacing: .9px;
}
.advanced-section-title::before { content: ""; width: 18px; height: 3px; border-radius: 3px; background: var(--accent-a); }
.advanced-section.stock .advanced-section-title::before { background: var(--accent-b); }
.advanced-section .kpi-row { padding: 0; margin-bottom: 0; }

.info-panel {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  margin: 0 0 20px; box-shadow: var(--shadow);
}
.info-panel.inline-info { margin: -4px 0 12px; box-shadow: none; background: rgba(255,255,255,.50); }
.info-panel summary {
  cursor: pointer; padding: 11px 14px; font-size: 12px; font-weight: 800; color: var(--text-primary);
  text-transform: uppercase; letter-spacing: .5px; list-style: none;
}
.info-panel summary::-webkit-details-marker { display: none; }
.info-panel summary::before { content: "▸"; color: var(--accent-a); margin-right: 8px; }
.info-panel[open] summary::before { content: "▾"; }
.info-panel-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; padding: 0 14px 14px; color: var(--text-secondary); font-size: 12px; line-height: 1.45; }
/* Sección "Información de los cálculos": nota + tabla de linaje (campo → origen).
   Es un panel largo y denso: le damos su propio aire (no el ritmo compacto de inline-info corto). */
.info-panel.inline-info.calc-info { margin: 16px 0 20px; }
.calc-info[open] summary { padding-bottom: 6px; }
.calc-info code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; background: rgba(121,71,248,.08); color: var(--text-primary); padding: 1px 5px; border-radius: 5px; word-break: break-word; }
.calc-info .calc-note { margin: 0 16px 14px; color: var(--text-secondary); font-size: 12px; line-height: 1.5; }
.calc-info .calc-note:last-child { margin-bottom: 16px; }
.calc-table-wrap { padding: 0 16px 16px; overflow-x: auto; }
.calc-table { width: 100%; border-collapse: collapse; font-size: 11.5px; line-height: 1.4; }
.calc-table th, .calc-table td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--border); vertical-align: top; color: var(--text-secondary); }
.calc-table thead th { color: var(--text-primary); font-weight: 800; text-transform: uppercase; letter-spacing: .4px; font-size: 10px; white-space: nowrap; }
.calc-table td:first-child { color: var(--text-primary); font-weight: 600; }
.calc-table tbody tr:last-child td { border-bottom: none; }
/* Rejilla de tablas de ranking (Top diseños / Top colores) lado a lado. */
.rank-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 980px) { .rank-grid { grid-template-columns: 1fr; } }
.cmp-table-card { overflow: hidden; }
.cmp-table-card .card-head { align-items: flex-start; margin-bottom: 12px; }

main { padding: calc(var(--nav-height) + 24px) 32px 48px; max-width: 1200px; margin: 0 auto; }
#view-graph {
  width: min(1760px, calc(100vw - 64px));
  max-width: calc(100vw - 64px);
  margin-left: 50%;
  transform: translateX(-50%);
}
#view-graph .page-desc { max-width: 920px; }
#view-graph .graphify-card { padding: 16px 18px 18px; }
#view-graph .graph-canvas { overflow: auto; }
#view-graph .graph-board {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
#view-graph .schema-db-grid {
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
}
.app-shell[hidden], .auth-shell[hidden] { display: none !important; }
.auth-shell {
  min-height: calc(100vh - var(--nav-height) - 72px);
  display: grid; place-items: center;
}
.auth-card {
  width: min(440px, 100%); background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 26px 28px; box-shadow: var(--shadow-md);
}
.auth-form { display: grid; gap: 10px; margin-top: 18px; }
.auth-form .btn-primary { margin-top: 6px; width: 100%; min-height: 38px; }
.password-field { position: relative; display: flex; align-items: center; }
.password-field input { padding-right: 42px; }
.password-toggle {
  position: absolute; right: 6px; width: 30px; height: 30px; border: none; border-radius: 50%;
  background: transparent; color: var(--text-muted); display: grid; place-items: center; cursor: pointer;
}
.password-toggle:hover, .password-toggle.active { color: var(--accent-a); background: var(--accent-a-soft); }
.password-toggle svg {
  width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.auth-linkbar { display: grid; gap: 8px; margin-top: 14px; text-align: center; }
.auth-switch {
  color: var(--accent-a); font-size: 12px; font-weight: 700; text-decoration: none;
  justify-self: center;
}
.auth-switch:hover { text-decoration: underline; }
.admin-subtabs {
  display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; margin: 8px 0 18px;
  border: 1px solid var(--border); border-radius: 999px; background: rgba(255,255,255,.58);
}
.admin-subtab {
  border: none; background: transparent; color: var(--text-secondary);
  border-radius: 999px; padding: 8px 14px; font-size: 12px; font-weight: 700; cursor: pointer;
}
.admin-subtab.active { background: var(--accent-a-grad); color: #fff; }
.admin-pane { display: none; }
.admin-pane.active { display: block; }
.admin-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(320px, .8fr); gap: 20px; align-items: start; }
.profile-stack { display: grid; gap: 20px; }
.admin-filters {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; align-items: center; margin-bottom: 12px;
}
/* Formularios en línea que definen sus propias columnas (crear página / crear token).
   El display:grid vivía en .admin-create-user, que se retiró al refactorizar usuarios. */
.admin-create-user { display: grid; gap: 8px; align-items: center; margin-bottom: 12px; }
/* Alta de página nueva (gestor de páginas): nombre, descripción, visibilidad, botón. */
.admin-create-page {
  grid-template-columns: minmax(150px, 1fr) minmax(180px, 1.6fr) minmax(120px, .7fr) auto;
}
.admin-create-panel {
  margin: 0 0 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: rgba(255,255,255,.54); overflow: hidden;
}
.admin-create-panel summary {
  list-style: none; cursor: pointer; display: flex; justify-content: space-between; gap: 12px; align-items: center;
  padding: 10px 12px; color: var(--text-primary); font-size: 12px; font-weight: 800;
}
.admin-create-panel summary::-webkit-details-marker { display: none; }
.admin-create-panel summary > span {
  display: inline-flex; align-items: center; min-height: 26px; padding: 4px 10px;
  border-radius: 999px; background: rgba(255,255,255,.72); color: var(--accent-a);
}
.admin-create-panel[open] summary { border-bottom: 1px solid var(--border-light); }
.admin-create-panel summary small {
  color: var(--text-muted); font-size: 11px; font-weight: 700; text-align: right;
}
.admin-create-grid {
  display: grid; grid-template-columns: minmax(220px, 1.2fr) minmax(180px, .9fr) minmax(120px, .45fr) minmax(150px, .55fr) auto;
  gap: 8px; align-items: end; padding: 0 12px 12px;
}
.admin-create-field { display: grid; gap: 4px; min-width: 0; }
.admin-create-field span {
  color: var(--text-muted); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px;
}
.admin-create-field input, .admin-create-field select {
  width: 100%; min-width: 0; border: 1px solid var(--border); border-radius: 999px;
  background: var(--bg-input); color: var(--text-primary); padding: 7px 12px; font-family: var(--font); font-size: 13px;
}
.admin-create-submit { min-height: 35px; white-space: nowrap; }
.admin-reset-box {
  display: grid; grid-template-columns: minmax(220px, 1fr) minmax(220px, .7fr) auto auto;
  gap: 8px; align-items: center; margin: 0 0 12px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: rgba(255,255,255,.62);
}
.admin-reset-box[hidden] { display: none; }
.admin-reset-box .section-title { margin-bottom: 2px; }
.token-create { grid-template-columns: minmax(0, 1fr) auto; }
.profile-password-form {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 8px; align-items: center; margin-top: 12px;
}
.profile-password-form .btn-primary { min-height: 36px; white-space: nowrap; }
.admin-filters { grid-template-columns: minmax(120px, .2fr) minmax(120px, .2fr) minmax(220px, 1fr); }
.admin-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.admin-scroll { max-height: 420px; }
.admin-table .btn-ghost { padding: 4px 10px; white-space: nowrap; }
.admin-users-toolbar {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; margin: 12px 0 10px;
}
.admin-users-filters {
  display: grid; grid-template-columns: minmax(220px, 1fr) minmax(140px, .35fr) minmax(170px, .45fr);
  gap: 8px; min-width: 0;
}
.admin-users-filters .inp-sm, .admin-users-filters .sel-sm { width: 100%; min-width: 0; }
.admin-users-summary { justify-self: end; font-size: 12px; font-weight: 700; white-space: nowrap; }
.admin-pending { font-size: 12px; font-weight: 700; white-space: nowrap; }
.admin-pending[hidden] { display: none; }
#admin_users_msg {
  display: flex; align-items: center; min-height: 0; margin: 0 0 8px;
}
#admin_users_msg:empty { display: none; }
#admin_users_msg .msg {
  display: inline-flex; align-items: center; width: auto; max-width: 100%; min-height: 24px;
  margin: 0; padding: 4px 10px; border-radius: 999px; font-weight: 700;
  overflow-wrap: anywhere;
}
.admin-users-stats {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 10px;
}
.admin-stat-chip {
  display: inline-flex; align-items: center; gap: 5px; min-height: 24px; padding: 3px 9px;
  border-radius: 999px; background: rgba(255,255,255,.62); border: 1px solid var(--border);
  color: var(--text-secondary); font-family: var(--font); font-size: 11px; font-weight: 800; white-space: nowrap;
}
.admin-stat-chip b { color: var(--text-primary); font-size: 12px; }
.admin-stat-chip.is-clickable { cursor: pointer; }
.admin-stat-chip.is-clickable:hover, .admin-stat-chip.is-selected {
  border-color: rgba(121,71,248,.28); box-shadow: 0 0 0 3px var(--accent-a-soft);
}
.admin-stat-chip.is-active { background: var(--green-soft); border-color: rgba(92,138,108,.18); color: var(--green); }
.admin-stat-chip.is-pending { background: rgba(219,161,34,.13); border-color: rgba(219,161,34,.2); color: #8A6A1C; }
.admin-stat-chip.is-disabled { background: var(--red-soft); border-color: rgba(224,82,82,.18); color: var(--red); }
.admin-stat-chip.is-never { background: rgba(45,42,38,.055); color: var(--text-muted); }
.admin-table th:last-child, .admin-table td.admin-user-actions { text-align: right; }
.admin-table td { vertical-align: middle; }
#admin_users .admin-table thead th {
  position: sticky; top: 0; z-index: 4; background: rgba(255,255,255,.94);
  backdrop-filter: blur(10px); box-shadow: 0 1px 0 var(--border);
}
.admin-user-actions { min-width: 80px; white-space: nowrap; }
.admin-table tbody tr.row-dirty > td { background: var(--accent-a-soft); }
.admin-table tbody tr.is-self > td { background: rgba(92,138,108,.06); }
.admin-table tbody tr.is-admin-risk > td { background: rgba(219,161,34,.045); }
#admin_users_save { min-width: 88px; padding-inline: 18px; white-space: nowrap; }
#admin_users_save.has-changes { box-shadow: 0 0 0 3px var(--accent-a-soft); }
#admin_users_save:disabled {
  background: rgba(255,255,255,.48); color: var(--text-muted); border: 1px solid var(--border);
}
.btn-primary:disabled, .btn-ghost:disabled { opacity: .48; cursor: not-allowed; box-shadow: none; }
.btn-ghost.danger { color: var(--red); border-color: rgba(193,71,77,.28); }
.btn-ghost.danger:hover { background: var(--red-soft); border-color: rgba(193,71,77,.42); }
/* Gestor de páginas: orden ↑/↓, interruptor de activación */
/* Usa .matrix pero SIN columna fija: si la 1ª celda es sticky no se estira a la
   altura de la fila y el ↑/↓ queda descuadrado respecto a la columna Página. */
#admin_pages table.matrix td:first-child,
#admin_pages table.matrix th:first-child { position: static; background: transparent; }
#admin_pages table.matrix td { vertical-align: middle; }
.admin-page-order { display: flex; gap: 4px; align-items: center; }
.btn-ghost.btn-icon { padding: 2px 8px; line-height: 1; font-size: 14px; min-width: 28px; }
.btn-ghost.btn-icon:disabled { opacity: .35; cursor: default; }
.admin-toggle { position: relative; display: inline-block; width: 34px; height: 20px; cursor: pointer; }
.admin-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.admin-toggle span {
  position: absolute; inset: 0; border-radius: 999px; background: rgba(45,42,38,.16); transition: background .15s;
}
.admin-toggle span::before {
  content: ""; position: absolute; left: 3px; top: 3px; width: 14px; height: 14px; border-radius: 999px;
  background: #fff; box-shadow: 0 1px 3px rgba(45,42,38,.22); transition: transform .15s;
}
.admin-toggle input:checked + span { background: var(--accent-a-grad); }
.admin-toggle input:checked + span::before { transform: translateX(14px); }
.admin-toggle input:disabled + span { opacity: .5; cursor: default; }

/* ── Páginas 'custom': maquetador de bloques ── */
.cp-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.cp-head h1 { margin: 0; }
.pb-grid { display: flex; flex-wrap: wrap; gap: 16px; align-items: stretch; margin-top: 8px; }
.pb-block { flex: 1 1 100%; min-width: 0; }
.pb-block > .card { height: 100%; }
.pb-w-full { flex-basis: 100%; }
.pb-w-half { flex-basis: calc(50% - 8px); }
.pb-w-third { flex-basis: calc(33.333% - 11px); }
.pb-w-quarter { flex-basis: calc(25% - 12px); }
.pb-heading { margin: 8px 0 2px; font-size: 20px; font-weight: 800; color: var(--text-primary); }
.pb-section { display: flex; align-items: center; gap: 10px; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .6px; color: var(--accent-a); margin: 6px 0; }
.pb-sep { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }
.pb-text { color: var(--text-primary); line-height: 1.5; }
.pb-kpi { display: flex; flex-direction: column; gap: 6px; }
.pb-kpi-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--text-muted); }
.pb-kpi-val { font-size: 30px; font-weight: 800; color: var(--accent-a); font-variant-numeric: tabular-nums; }
.pb-databox { overflow-x: auto; }
.pb-bars { display: flex; flex-direction: column; gap: 8px; }
.pb-bar-row { display: grid; grid-template-columns: minmax(90px, 1fr) 3fr auto; gap: 10px; align-items: center; font-size: 12.5px; }
.pb-bar-lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pb-bar-track { height: 10px; border-radius: 999px; background: rgba(45,42,38,.08); overflow: hidden; }
.pb-bar-fill { display: block; height: 100%; border-radius: 999px; background: var(--accent-a-grad); }
.pb-bar-val { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--text-primary); white-space: nowrap; }
/* Acentos por bloque */
.pb-accent-violet .pb-kpi-val { color: #7947F8; } .pb-accent-violet .pb-bar-fill { background: #7947F8; }
.pb-accent-green  .pb-kpi-val { color: #2F9E6B; } .pb-accent-green  .pb-bar-fill { background: #2F9E6B; }
.pb-accent-amber  .pb-kpi-val { color: #C98A00; } .pb-accent-amber  .pb-bar-fill { background: #C98A00; }
.pb-accent-red    .pb-kpi-val { color: #C1474D; } .pb-accent-red    .pb-bar-fill { background: #C1474D; }
.pb-accent-blue   .pb-kpi-val { color: #2F73C4; } .pb-accent-blue   .pb-bar-fill { background: #2F73C4; }
.pb-block[class*="pb-accent-"] > .card { border-left: 3px solid currentColor; }
.pb-accent-violet > .card { border-left-color: #7947F8; }
.pb-accent-green  > .card { border-left-color: #2F9E6B; }
.pb-accent-amber  > .card { border-left-color: #C98A00; }
.pb-accent-red    > .card { border-left-color: #C1474D; }
.pb-accent-blue   > .card { border-left-color: #2F73C4; }
/* Arrastrar y soltar (modo edición): cada bloque es agarrable y muestra la pista */
.pb-editing .pb-block { cursor: grab; position: relative; }
.pb-editing .pb-block > .card,
.pb-editing .pb-block > .pb-heading,
.pb-editing .pb-block > .pb-section,
.pb-editing .pb-block > .pb-text,
.pb-editing .pb-block > .pb-sep { outline: 1px dashed var(--border); outline-offset: 3px; border-radius: 12px; }
.pb-editing .pb-block::after { content: "⠿"; position: absolute; top: 6px; right: 10px; font-size: 14px;
  color: var(--text-muted); opacity: .5; pointer-events: none; z-index: 2; }
.pb-block.pb-dragging { opacity: .4; cursor: grabbing; }
.pb-block.pb-dragging * { pointer-events: none; }
/* Editor de la página */
.cp-head-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.cp-editor-card { margin-bottom: 14px; }
.cp-editing-card { outline: 2px solid var(--accent-a); outline-offset: -2px; }
.cp-blockrow.editing { background: color-mix(in srgb, var(--accent-a) 8%, transparent); border-radius: 8px; }
/* Formulario del editor: rejilla de columnas IGUALES para que todos los campos alineen,
   con controles al 100% de su celda y la misma altura (input = select = fecha = número). */
.cp-addform { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px 14px; align-items: end; margin-top: 12px; }
.cp-fld { display: flex; flex-direction: column; gap: 5px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .4px; color: var(--text-muted); min-width: 0; }
.cp-fld input, .cp-fld textarea, .cp-fld select { width: 100%; box-sizing: border-box;
  font-family: var(--font); font-size: 13px; padding: 8px 10px; min-width: 0;
  text-transform: none; letter-spacing: 0; font-weight: 500; }
.cp-fld textarea { min-height: 40px; resize: vertical; }
.cp-fld-wide { grid-column: 1 / -1; }
.cp-actions { grid-column: 1 / -1; display: flex; gap: 10px; align-items: center; margin-top: 2px; }
.cp-chks { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.cp-chk { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500;
  text-transform: none; letter-spacing: 0; color: var(--text-primary); }
/* Filtros del bloque: fila filtro→valor→quitar, alineada y a la misma altura */
.cp-filters { display: flex; flex-direction: column; gap: 8px; }
.cp-filter-row { display: flex; gap: 8px; align-items: center; }
.cp-filter-row select { flex: 1 1 42%; min-width: 0; }
.cp-filter-row input { flex: 1 1 58%; min-width: 0; }
.cp-filter-row select, .cp-filter-row input { padding: 8px 10px; font-size: 13px; box-sizing: border-box; }
.cp-filter-row .btn-icon { flex: 0 0 auto; }
.cp-addfilter { align-self: flex-start; font-size: 12px; }
.cp-blocklist { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.cp-blockrow { display: flex; align-items: center; gap: 10px; padding: 6px 8px;
  border: 1px solid var(--border-light); border-radius: var(--radius-sm); background: rgba(255,255,255,.5); }
.cp-brow-type { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  color: var(--accent-a); min-width: 70px; }
.cp-brow-title { flex: 1 1 auto; min-width: 60px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-primary); }
.cp-blockrow .admin-row-select { flex: 0 0 130px; width: 130px; }
@media (max-width: 640px) {
  .pb-w-half, .pb-w-third, .pb-w-quarter { flex-basis: 100%; }
}

.admin-sort {
  display: inline-flex; align-items: center; gap: 5px; border: none; background: transparent;
  color: var(--text-secondary); padding: 0; font-family: var(--font); font-size: 11px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .5px; cursor: pointer;
}
.admin-sort b { color: var(--text-muted); font-size: 11px; min-width: 12px; }
.admin-sort.active, .admin-sort:hover { color: var(--accent-a); }
.admin-email-cell { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.admin-email-cell span:first-child { overflow-wrap: anywhere; }
.user-self-badge, .admin-self-note, .admin-last-access {
  display: inline-flex; align-items: center; min-height: 22px; border-radius: 999px; padding: 2px 8px;
  background: rgba(255,255,255,.72); color: var(--text-secondary); font-size: 11px; font-weight: 800;
}
.user-self-badge { background: var(--green-soft); color: var(--green); }
.admin-risk-badge {
  display: inline-flex; align-items: center; min-height: 22px; border-radius: 999px; padding: 2px 8px;
  background: rgba(219,161,34,.13); border: 1px solid rgba(219,161,34,.22);
  color: #8A6A1C; font-size: 11px; font-weight: 800;
}
.admin-risk-badge.is-stale { background: rgba(45,42,38,.055); border-color: rgba(45,42,38,.08); color: var(--text-muted); }
.admin-self-note {
  background: rgba(92,138,108,.12); color: var(--green);
  border: 1px solid rgba(92,138,108,.16); white-space: nowrap;
}
.admin-last-access { background: transparent; padding-left: 0; color: var(--text-primary); }
.admin-last-access.is-never {
  background: rgba(45,42,38,.055); color: var(--text-muted);
  border: 1px solid rgba(45,42,38,.06); padding-left: 8px;
}
.admin-row-select {
  min-width: 118px; padding: 5px 24px 5px 10px; font-size: 12px; border-radius: 999px;
  border: 1px solid var(--border); font-weight: 700;
}
.admin-row-select.is-role-admin { color: var(--accent-a); background: var(--accent-a-soft); border-color: rgba(121,71,248,.22); }
.admin-row-select.is-status-active { color: var(--green); background: var(--green-soft); border-color: rgba(92,138,108,.22); }
.admin-row-select.is-status-pending { color: #8A6A1C; background: rgba(219,161,34,.13); border-color: rgba(219,161,34,.22); }
.admin-row-select.is-status-disabled { color: var(--red); background: var(--red-soft); border-color: rgba(224,82,82,.22); }
.admin-row-select:disabled { opacity: .68; cursor: not-allowed; }
.admin-action-menu { display: inline-block; position: relative; text-align: left; }
.admin-action-menu summary {
  width: 30px; height: 26px; display: inline-grid; place-items: center;
  list-style: none; cursor: pointer; border: 1px solid var(--border); border-radius: 999px;
  background: rgba(255,255,255,.68); color: var(--text-secondary); padding: 0; font-size: 17px; font-weight: 800;
  line-height: 1;
}
.admin-action-menu summary::-webkit-details-marker { display: none; }
.admin-action-menu[open] summary { color: var(--accent-a); border-color: rgba(121,71,248,.22); background: var(--accent-a-soft); }
.admin-action-list {
  position: fixed; z-index: 200; left: 0; top: 0;
  display: none; gap: 6px; min-width: 168px; margin-top: 0; padding: 7px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: rgba(255,255,255,.9);
  box-shadow: var(--shadow); max-height: 132px; overflow-y: auto; overflow-x: hidden;
  scrollbar-gutter: stable;
}
.admin-action-menu[open] .admin-action-list { display: grid; }
.admin-action-list .btn-ghost { justify-content: flex-start; text-align: left; }
.admin-event-action {
  display: inline-flex; align-items: center; min-height: 22px; padding: 2px 8px; border-radius: 999px;
  background: rgba(121,71,248,.075); color: var(--accent-a); font-size: 11px; font-weight: 800;
  white-space: nowrap;
}
.admin-empty-state {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 18px 14px; border: 1px dashed var(--border); border-radius: var(--radius-sm);
  color: var(--text-muted); background: rgba(255,255,255,.42); font-weight: 700;
}
.admin-empty-filter { color: var(--text-secondary); }
.admin-empty-clear { min-height: 28px; padding: 5px 10px; font-size: 12px; }
/* Resumen de estado de los datos en Admin (2026-08-20). Sustituye a `.coverage-grid`, que
   pintaba cinco fechas sin severidad. Prefijo `ah-` (admin health) igual que `.tk-`/`.cx-`.
   Los colores de severidad se reutilizan del indicador de frescura para que el mismo estado
   se vea igual en las dos pantallas; y como allí, el color NUNCA va solo: icono + texto. */
.admin-health { display: grid; gap: 14px; }
.ah-summary { display: flex; }
.ah-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px;
  border-radius: 100px; font-size: 12px; font-weight: 700;
  border: 1px solid var(--border); background: rgba(255,255,255,.62);
  color: var(--text-primary);
}
.ah-chip b {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; border-radius: 50%; font-size: 10px;
  color: #fff; background: var(--text-muted);
}
.ah-chip.is-ok b        { background: var(--green); }
.ah-chip.is-attention b { background: #C08A2E; }
.ah-chip.is-incident b  { background: var(--red); }
.ah-summary .ah-chip { font-size: 13px; padding: 7px 14px; }
.ah-chip.is-bf-ok, .ah-chip.is-bf-off, .ah-chip.is-bf-warn, .ah-chip.is-bf-err { gap: 0; }
.ah-chip.is-bf-warn { color: #8A6520; border-color: rgba(192,138,46,.45); }
.ah-chip.is-bf-err  { color: var(--red); border-color: rgba(224,82,82,.45); }
.ah-chip.is-bf-off  { color: var(--text-muted); }

.ah-scroll { overflow-x: auto; }
.ah-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ah-table th {
  text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border);
  color: var(--text-muted); font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .6px; white-space: nowrap;
}
.ah-table td {
  padding: 9px 10px; border-bottom: 1px solid var(--border-light);
  color: var(--text-primary); vertical-align: middle;
}
.ah-table tr:last-child td { border-bottom: 0; }
.ah-table td.num {
  font-family: 'JetBrains Mono', monospace; font-size: 12px;
  color: var(--text-secondary); white-space: nowrap;
}
.ah-pages { color: var(--text-secondary); font-size: 12px; }

.ah-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.ah-box {
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: rgba(255,255,255,.62); min-width: 0;
}
.ah-box-t {
  color: var(--text-muted); font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .6px;
}
.ah-box-v { margin-top: 8px; }
.ah-box-n { margin-top: 8px; color: var(--text-secondary); font-size: 12px; line-height: 1.5; }
.ah-list { margin: 8px 0 0; padding-left: 18px; color: var(--text-secondary); font-size: 12px; }
.ah-list li { margin-top: 3px; }
.ah-list b { color: var(--text-primary); }

@media (max-width: 640px) {
  .ah-grid { grid-template-columns: 1fr; }
  .ah-table td, .ah-table th { padding: 7px 8px; }
  .ah-pages { font-size: 11px; }
}
.admin-pre {
  max-height: 220px; overflow: auto; margin: 12px 0 0; padding: 10px 12px;
  background: rgba(45,42,38,.04); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-secondary); font-family: 'JetBrains Mono', monospace; font-size: 11px; white-space: pre-wrap;
}
.admin-detail {
  max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.admin-delete-modal {
  position: fixed; inset: 0; z-index: 300; display: grid; place-items: center;
  padding: 18px; background: rgba(45,42,38,.2); backdrop-filter: blur(8px);
}
.admin-delete-modal[hidden] { display: none; }
.admin-delete-dialog {
  width: min(420px, 100%); display: grid; gap: 12px; padding: 16px;
  border: 1px solid rgba(193,71,77,.18); border-radius: var(--radius-sm);
  background: rgba(255,255,255,.96); box-shadow: var(--shadow);
}
.admin-delete-target {
  padding: 9px 11px; border-radius: var(--radius-sm); background: var(--red-soft);
  color: var(--red); font-size: 13px; font-weight: 800; overflow-wrap: anywhere;
}
.admin-delete-dialog input {
  width: 100%; border: 1px solid var(--border); border-radius: 999px;
  background: var(--bg-input); color: var(--text-primary); padding: 8px 12px;
  font-family: var(--font); font-size: 13px; box-sizing: border-box;
}
.admin-delete-actions { display: flex; justify-content: flex-end; gap: 8px; }
.api-example { display: grid; gap: 8px; }
.api-example code {
  display: block; padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: rgba(255,255,255,.62); color: var(--text-primary); font-family: 'JetBrains Mono', monospace;
  font-size: 12px; overflow-wrap: anywhere;
}
.etl-jobs { margin-top: 12px; display: grid; gap: 8px; }
.etl-job {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center;
  padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: rgba(255,255,255,.62);
}
.etl-job b { color: var(--text-primary); }
.etl-job .pill { justify-self: end; }
.store-sales-card .scroll { max-height: 340px; }
.graphify-card { padding: 14px; overflow: hidden; }
.graphify-card .card-head { padding: 6px 8px 0; margin-bottom: 12px; }
.graph-mode-tabs {
  display: flex; flex-wrap: wrap; gap: 8px; margin: 0 8px 12px;
}
.graph-mode-tabs .ptab, .graph-er-tabs .ptab {
  font-family: var(--font); font-size: 12px; font-weight: 700; cursor: pointer;
  padding: 7px 16px; border-radius: 999px; border: 1px solid var(--border);
  background: rgba(255,255,255,.7); color: var(--text-secondary);
  transition: color .15s ease, border-color .15s ease, background .15s ease;
}
.graph-mode-tabs .ptab:hover, .graph-er-tabs .ptab:hover {
  color: var(--accent-a); border-color: var(--accent-a);
}
.graph-mode-tabs .ptab.active, .graph-er-tabs .ptab.active {
  background: var(--accent-a-grad); color: #fff; border-color: transparent;
}
.graph-toolbar {
  display: grid; grid-template-columns: minmax(220px, 1fr) minmax(180px, 260px);
  gap: 10px; margin: 0 8px 12px;
}
.graph-map-shell {
  display: grid; grid-template-columns: 1fr; gap: 12px; align-items: stretch;
}
.graph-canvas {
  overflow: visible; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: linear-gradient(180deg, rgba(255,255,255,.88), rgba(255,255,255,.62));
  padding: 12px;
}
.graph-board {
  display: grid; grid-template-columns: repeat(3, minmax(230px, 1fr)); gap: 12px;
  align-items: start;
}
.graph-column {
  display: grid; gap: 8px; min-width: 0;
}
.graph-column-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 34px; padding: 7px 9px; border-radius: 999px;
  background: rgba(45,42,38,.045); color: var(--text-muted);
  font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .7px;
}
.graph-column-head b {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; border-radius: 999px;
  background: rgba(255,255,255,.8); color: var(--text-primary); font-size: 11px;
}
.graph-card-list { display: grid; gap: 8px; }
.graph-card {
  width: 100%; min-height: 132px; display: grid; grid-template-rows: auto auto auto 1fr auto; gap: 5px;
  text-align: left; border: 1px solid rgba(45,42,38,.12); border-radius: var(--radius-sm);
  background: rgba(255,255,255,.86); color: var(--text-primary); padding: 10px;
  cursor: pointer; transition: transform .12s ease, box-shadow .12s ease, opacity .12s ease, border-color .12s ease;
}
.graph-card:hover, .graph-card.selected {
  transform: translateY(-1px); border-color: var(--accent-a);
  box-shadow: 0 10px 18px rgba(45,42,38,.1);
}
.graph-card.dimmed { opacity: .34; }
.graph-card.source { background: #eef7ff; }
.graph-card.process { background: #fff5df; }
.graph-card.fact { background: #eefaf3; }
.graph-card.dimension { background: #f4f0ff; }
.graph-card.report { background: #fff0f5; }
.graph-card.config { background: #f5f5f2; }
.graph-card-kind {
  width: max-content; max-width: 100%; padding: 2px 7px; border-radius: 999px;
  background: rgba(255,255,255,.72); color: var(--text-muted);
  font-size: 8.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .7px;
}
.graph-card strong {
  min-width: 0; color: var(--text-primary); font-size: 13px; line-height: 1.18;
}
.graph-card em {
  color: var(--text-secondary); font-size: 10.5px; font-style: normal; font-weight: 700;
}
.graph-card small {
  color: var(--text-secondary); font-size: 10.5px; line-height: 1.35;
}
.graph-card-meta {
  display: flex; flex-wrap: wrap; gap: 5px; margin-top: 2px;
}
.graph-card-meta i {
  padding: 2px 6px; border-radius: 999px; background: rgba(255,255,255,.72);
  color: var(--text-muted); font-size: 9.5px; font-style: normal; font-weight: 800;
}
.graph-detail {
  min-height: 0; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: rgba(255,255,255,.65); padding: 14px;
}
.graph-detail h3 { margin: 0 0 8px; font-size: 18px; letter-spacing: 0; }
.graph-detail p { margin: 8px 0 14px; color: var(--text-secondary); font-size: 13px; line-height: 1.45; }
.graph-detail-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.graph-detail-relations { display: grid; gap: 10px; }
.graph-relation-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.graph-detail-relations ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.graph-detail-relations li {
  display: grid; gap: 2px; padding: 9px 10px; border: 1px solid var(--border-light);
  border-radius: var(--radius-sm); background: rgba(255,255,255,.72);
}
.graph-detail-relations li b { color: var(--accent-a); font-size: 10px; text-transform: uppercase; letter-spacing: .8px; }
.graph-detail-relations li span { color: var(--text-primary); font-size: 12px; font-weight: 700; }
.graph-detail-relations li em { color: var(--text-muted); font-style: normal; font-size: 11px; overflow-wrap: anywhere; }
/* Esquema técnico y Diagrama comparten el mismo marco para que se vean hermanos. */
.graph-schema, .graph-er-render {
  border: 1px solid var(--border-light); border-radius: var(--radius-sm);
  background: rgba(255,255,255,.76); padding: 14px;
}
.graph-schema { display: grid; gap: 14px; }
.graph-er { display: grid; gap: 12px; }
.graph-er-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.graph-er-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.graph-er-zoom { display: flex; gap: 6px; }
.graph-er-zoom button {
  width: auto; min-width: 34px; height: 32px; padding: 0 12px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 999px; background: rgba(255,255,255,.7);
  color: var(--text-secondary); font-family: var(--font); font-size: 13px; font-weight: 700;
  transition: color .15s ease, border-color .15s ease;
}
.graph-er-zoom button:hover { color: var(--accent-a); border-color: var(--accent-a); }
.graph-er-render { padding: 0; overflow: hidden; }
.graph-er-loading {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 48px 14px; min-height: min(70vh, 420px);
}
.spinner {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid var(--accent-a-soft); border-top-color: var(--accent-a);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner-sm { width: 16px; height: 16px; border-width: 2px; }

/* Espera del export: modal con cronómetro. El export de General tarda de 6 s a varios minutos
   (medido), y sin referencia esa espera se lee como «se ha colgado» → la gente cierra la
   pestaña y pierde la descarga. Reutiliza .spinner y el patrón de .admin-delete-modal; NO
   lleva barra de porcentaje porque el backend responde de una vez y cualquier porcentaje
   estaría inventado. */
.export-wait {
  position: fixed; inset: 0; z-index: 1300; display: grid; place-items: center;
  padding: 18px; background: rgba(45,42,38,.2); backdrop-filter: blur(8px);
}
.export-wait[hidden] { display: none; }
.export-wait-dialog {
  width: min(400px, 100%); display: grid; gap: 10px; justify-items: center;
  padding: 22px 18px; text-align: center;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-card); box-shadow: var(--shadow);
}
.export-wait-t { font-size: 15px; font-weight: 800; color: var(--text-primary); }
.export-wait-n { font-size: 12px; color: var(--text-secondary); line-height: 1.5; }
.export-wait-slow { color: var(--text-primary); font-weight: 600; }

/* Indicador global de carga: píldora flotante mientras hay peticiones en curso (no bloquea la UI). */
.global-loading {
  position: fixed; top: calc(var(--nav-height) + 12px); left: 50%;
  transform: translateX(-50%) translateY(-8px); z-index: 1200;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px; border-radius: 999px;
  background: var(--bg-card); border: 1px solid var(--border); box-shadow: var(--shadow);
  color: var(--text-secondary); font-size: 13px; font-weight: 600;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .18s ease, transform .18s ease, visibility .18s;
}
.global-loading.on { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); }
@media (prefers-reduced-motion: reduce) {
  .spinner, .spinner-sm { animation-duration: 1.4s; }
  .global-loading { transition: opacity .18s ease; }
}
.graph-er-viewport {
  position: relative; height: min(70vh, 640px); overflow: hidden;
  border-radius: var(--radius-sm); cursor: grab; touch-action: none;
  background:
    radial-gradient(circle at 1px 1px, rgba(45,42,38,.08) 1px, transparent 0) 0 0 / 22px 22px;
}
.graph-er-viewport.grabbing { cursor: grabbing; }
.graph-er-stage { position: absolute; top: 0; left: 0; transform-origin: 0 0; }
.graph-er-stage svg { display: block; max-width: none; }
.graph-er-render svg { max-width: 100%; height: auto; }
.schema-bridges {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px;
}
.schema-bridge {
  display: grid; gap: 4px; padding: 10px; border: 1px solid var(--border-light);
  border-radius: var(--radius-sm); background: rgba(255,255,255,.76);
}
.schema-bridge b { color: var(--accent-a); font-size: 13px; }
.schema-bridge span { color: var(--text-primary); font-size: 12px; font-weight: 800; }
.schema-bridge small { color: var(--text-secondary); font-size: 11px; line-height: 1.35; }
.schema-bridge em { color: var(--text-muted); font-size: 10px; font-style: normal; overflow-wrap: anywhere; }
.schema-toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between;
}
.schema-toolbar > span { color: var(--text-muted); font-size: 11px; font-weight: 700; }
.schema-db-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px;
  align-items: start;
}
.schema-db {
  min-width: 0; display: grid; gap: 9px; padding: 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: rgba(255,255,255,.68);
}
.schema-db-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.schema-db-head h3 { margin: 0; font-size: 16px; letter-spacing: 0; }
.schema-db-head span { color: var(--text-secondary); font-size: 11px; font-weight: 700; }
.schema-db-head b {
  flex: 0 0 auto; padding: 4px 8px; border-radius: 999px; background: rgba(121,71,248,.08);
  color: var(--accent-a); font-size: 11px;
}
/* Contexto del borrador dbdiagram.io, solo visible con la vista «ERP PMP Web ·
   completo» seleccionada en Graphify > Diagrama (enlace al proyecto original +
   notas de negocio por tabla, extraídas de los bloques Note del DBML). Vive
   dentro de .graph-er-bar, entre las pestañas de vista y los botones de zoom;
   flex-basis:100% la fuerza a su propia fila (el gap del bar da el espaciado). */
.graph-er-context { flex: 1 1 100%; margin: 0; }
.graph-er-context-link {
  display: flex; align-items: center; gap: 6px; margin: 0 0 10px;
  font-size: 12px; color: var(--text-secondary);
}
.graph-er-context-link a { color: var(--accent-a); font-weight: 700; word-break: break-all; }
.graph-er-note-text { margin: 0; white-space: pre-wrap; font-size: 11.5px; line-height: 1.5; color: var(--text-secondary); }

.schema-table-list { display: grid; gap: 8px; }
.schema-table {
  border: 1px solid var(--border-light); border-radius: var(--radius-sm);
  background: rgba(255,255,255,.78); overflow: hidden;
}
.schema-table summary {
  cursor: pointer; display: grid; grid-template-columns: auto minmax(90px, .8fr) minmax(110px, 1.2fr) auto;
  gap: 8px; align-items: center; padding: 7px 10px; list-style: none;
}
.schema-table summary:hover { background: rgba(121,71,248,.04); }
.schema-table summary::-webkit-details-marker { display: none; }
.schema-table summary strong { color: var(--text-primary); font-size: 12px; overflow-wrap: anywhere; }
.schema-table summary span { color: var(--text-secondary); font-size: 11px; overflow-wrap: anywhere; }
.schema-table summary em { color: var(--text-muted); font-size: 10px; font-style: normal; text-align: right; white-space: nowrap; }
.schema-table summary::before {
  content: "▸"; color: var(--text-muted); font-size: 10px; transition: transform .12s ease;
}
.schema-table[open] summary::before { transform: rotate(90deg); }
.schema-table[open] summary { border-bottom: 1px solid var(--border-light); }
.schema-table-body { padding: 8px 10px 10px; }
.schema-table p { margin: 0 0 8px; color: var(--text-secondary); font-size: 11px; line-height: 1.35; }
.schema-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.schema-chip {
  padding: 2px 8px; border-radius: 999px; background: rgba(45,42,38,.05);
  color: var(--text-secondary); font-size: 10.5px; font-weight: 600; cursor: default;
  font-family: "JetBrains Mono", monospace;
}
.schema-chip.is-rel { background: var(--accent-a-soft); color: var(--accent-a); font-weight: 700; }
.schema-origin { display: flex; flex-wrap: wrap; gap: 5px; padding: 8px 0 0; }
.schema-origin span {
  padding: 2px 7px; border-radius: 999px; background: rgba(255,255,255,.8);
  color: var(--text-muted); font-size: 9.5px; font-weight: 800;
}
.schema-relations { display: grid; gap: 8px; }
.schema-rel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.schema-rel-head span { color: var(--text-muted); font-size: 11px; font-weight: 800; }
.schema-relations .scroll { max-height: 420px; overflow: auto; }
.schema-relations code {
  padding: 2px 5px; border-radius: 4px; background: rgba(45,42,38,.06);
  color: var(--text-primary); font-family: "JetBrains Mono", monospace; font-size: 11px;
}
.view { display: none; }
.view.active { display: block; }

.section-tag { display: flex; align-items: center; gap: 10px; font-size: 14px;
  font-weight: 600; color: var(--accent-a); margin-bottom: 6px; }
.tag-bar { width: 24px; height: 3px; background: var(--accent-a); border-radius: 2px; }
h1 { font-size: 32px; font-weight: 800; letter-spacing: -1px; margin: 0 0 4px; }
.page-desc { font-size: 14px; color: var(--text-secondary); margin-top: 0; }

/* ── Indicador de frescura y calidad del dato ──────────────────────────────────────────
   Banda compacta de una línea bajo la descripción de cada página de análisis. El color
   NUNCA es el único portador del significado: siempre va acompañado de icono y etiqueta
   de texto ("Datos al día", "Atención", "Incidencia de calidad", "Estado no disponible"),
   para que se entienda en escala de grises y con lector de pantalla (FR-011). */
.freshness { margin: -4px 0 14px; max-width: 100%; }
.freshness[hidden] { display: none; }
.fresh-box { border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-card); box-shadow: var(--shadow); }
.fresh-head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 7px 12px; font-size: 12.5px; font-weight: 600; cursor: pointer;
  color: var(--text-secondary); list-style: none;
}
.fresh-head::-webkit-details-marker { display: none; }   /* triángulo nativo fuera */
.fresh-box > .fresh-head:focus-visible {
  outline: 2px solid var(--accent-a); outline-offset: 2px; border-radius: var(--radius-sm); }
/* Sin detalle desplegable la banda no es un <details>: mismo aspecto, sin cursor de clic. */
div.fresh-head { border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-card); cursor: default; }
.fresh-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 17px; height: 17px; flex: 0 0 17px; border-radius: 50%;
  font-size: 11px; font-weight: 700; line-height: 1; color: #fff;
}
.fresh-label { font-weight: 700; color: var(--text-primary); }
.fresh-date { color: var(--text-secondary); font-weight: 500; }
.fresh-more { margin-left: auto; font-weight: 600; color: var(--accent-a); font-size: 12px; }
.fresh-body {
  padding: 2px 12px 11px; border-top: 1px solid var(--border-light);
  font-size: 12.5px; color: var(--text-secondary); line-height: 1.5;
}
.fresh-body p { margin: 8px 0 0; }
details.fresh-box[open] .fresh-more::after { content: " ▴"; }
details.fresh-box:not([open]) .fresh-more::after { content: " ▾"; }

.freshness.is-ok .fresh-icon { background: var(--green); }
.freshness.is-ok .fresh-box, .freshness.is-ok div.fresh-head { border-color: var(--border); }
.freshness.is-attention .fresh-icon { background: #C08A2E; }
.freshness.is-attention .fresh-box,
.freshness.is-attention div.fresh-head {
  border-color: rgba(192, 138, 46, .35); background: rgba(192, 138, 46, .07); }
.freshness.is-incident .fresh-icon { background: var(--red); }
.freshness.is-incident .fresh-box,
.freshness.is-incident div.fresh-head {
  border-color: rgba(224, 82, 82, .38); background: var(--red-soft); }
.freshness.is-unknown .fresh-icon { background: var(--text-muted); }

@media (max-width: 640px) {
  /* min-width:0 en el hijo flexible: sin él una fecha larga desbordaría el eje X, y el
     body de esta app no debe hacer scroll horizontal a 375 px (SC-005). */
  .fresh-head { padding: 7px 10px; font-size: 12px; }
  .fresh-date { min-width: 0; flex: 1 1 100%; }
  .fresh-more { margin-left: 0; }
}

/* ── Web: identidad visual propia (entidad distinta de Tiendas/Producto/Diseño) ──
   .web-view comparte el esqueleto de .analysis-view (para no duplicar cientos de reglas),
   pero es su scope propio: redefine el acento al azul de Pampling (#0379D9). Como los
   componentes usan las variables --accent-a*, esto recolorea cabecera, barra, dots y acentos
   de toda la página Web sin tocar cada regla, dejando claro a simple vista que es otro negocio.
   (A futuro, otras marcas Web tendrán su propio color; hoy solo está Pampling.) */
.web-view {
  --accent-a: #0379D9;
  --accent-a-end: #3B9EEA;
  --accent-a-grad: linear-gradient(135deg, #0379D9, #3B9EEA);
  --accent-a-soft: rgba(3, 121, 217, 0.10);
}
/* El acento teal de Web en la navegación se aplica en el objeto Tienda/Web (.nav-obj) y en
   su sub-barra (.subnav-web) — ver la sección de navegación de 2 niveles más arriba. */

.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.section-title { font-size: 10px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 1px; margin-bottom: 16px; }

label.field { display: block; font-size: 10px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 1px; margin: 10px 0 4px; }
input, select, textarea {
  font-family: var(--font); font-size: 13px; background: var(--bg-input);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px;
  color: var(--text-primary); width: 100%;
}
textarea { min-height: 120px; font-family: 'JetBrains Mono', monospace; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > div { flex: 1; min-width: 140px; }

.btn-primary { background: var(--accent-a-grad); color: #fff; font-size: 13px;
  font-weight: 600; padding: 8px 22px; border: none; border-radius: 999px; cursor: pointer; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text-secondary);
  padding: 6px 14px; border-radius: 999px; cursor: pointer; font-size: 12px; font-weight: 600; }

table { width: 100%; border-collapse: collapse; }
th { font-size: 10px; font-weight: 600; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.5px; padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; }
td { font-size: 13px; padding: 12px; border-bottom: 1px solid var(--border-light); }
.scroll { overflow: auto; max-height: 460px; max-width: 100%; min-width: 0; }
#admin_users.admin-scroll {
  max-height: min(420px, 52vh); overflow-y: auto; overflow-x: auto;
  scrollbar-gutter: stable; overscroll-behavior: contain;
}
.web-products-table { overflow-x: auto; max-width: 100%; min-width: 0; }
.web-products-table.scroll { overflow: auto; }

.msg { font-size: 12px; padding: 8px 12px; border-radius: var(--radius-sm); margin-top: 10px; }
.msg.ok { color: var(--green); background: var(--green-soft); }
.msg.err { color: var(--red); background: var(--red-soft); }
/* Aviso (ni error ni éxito): p.ej. tokens personales sin usar desde hace meses.
   Sigue la convención del resto del fichero con --warn y su color de reserva. */
.msg.warn { color: var(--warn, #b8860b); background: rgba(184, 134, 11, .12); }
.muted { color: var(--text-muted); font-size: 12px; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 20px;
  background: var(--accent-a-soft); color: var(--accent-a); font-size: 11px; font-weight: 600; }
.delta { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 20px; white-space: nowrap; }
.delta.pos { color: var(--green); background: var(--green-soft); }
.delta.neg { color: var(--red); background: var(--red-soft); }

/* Gráfico de barras día de la semana */
.dow-bar { position: relative; width: 24px; border-radius: 5px 5px 0 0; transition: filter .12s; }
.dow-bar:hover { filter: brightness(1.08); }
.dow-tip { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%) translateY(-6px);
  background: var(--text-primary); color: #fff; font-size: 11px; font-weight: 600; line-height: 1.3;
  padding: 5px 9px; border-radius: 8px; white-space: nowrap; box-shadow: var(--shadow-md);
  opacity: 0; visibility: hidden; transition: opacity .12s; pointer-events: none; z-index: 10; }
.dow-tip::after { content: ""; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: var(--text-primary); }
.dow-tip .tip-day { color: rgba(255,255,255,.6); font-weight: 500; }
.dow-bar:hover .dow-tip { opacity: 1; visibility: visible; }

/* Contribución al crecimiento: dos paneles suaves (Impulsan / Frenan) con barras tenues */
.wf-caption { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: 13px;
  color: var(--text-secondary); margin-bottom: 10px; }
.wf-caption b { color: var(--text-primary); }
.wf-caption-arrow { color: var(--text-muted); }
.wf-explain { font-size: 12px; color: var(--text-muted); margin-bottom: 14px; }
.wf-explain b { color: var(--text-primary); }
.wf-groups { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.wf-group { border-radius: 14px; padding: 12px 14px; display: grid; gap: 8px; }
.wf-group.pos { background: color-mix(in srgb, var(--green) 7%, transparent); }
.wf-group.neg { background: color-mix(in srgb, var(--red) 6%, transparent); }
.wf-group-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; margin-bottom: 2px; }
.wf-group.pos .wf-group-head { color: var(--green); }
.wf-group.neg .wf-group-head { color: var(--red); }
.wf-item { display: grid; grid-template-columns: minmax(90px, 150px) minmax(0, 1fr) minmax(76px, auto);
  gap: 10px; align-items: center; }
.wf-item-name { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; }
.wf-item-track { position: relative; height: 7px; border-radius: 5px; overflow: hidden;
  background: color-mix(in srgb, var(--text-muted) 12%, transparent); }
.wf-item-fill { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 5px; transition: width .2s; }
.wf-group.pos .wf-item-fill { background: color-mix(in srgb, var(--green) 55%, transparent); }
.wf-group.neg .wf-item-fill { background: color-mix(in srgb, var(--red) 45%, transparent); }
.wf-item-val { font-size: 12px; font-weight: 700; text-align: right; white-space: nowrap; }
.wf-item-val.pos { color: var(--green); }
.wf-item-val.neg { color: var(--red); }
.wf-empty { font-size: 12px; color: var(--text-muted); padding: 4px 0; }

/* Gráficos de producto: ranking compacto colapsable */
.product-chart-card { overflow: hidden; }
.product-chart-card summary {
  display: flex; align-items: center; gap: 12px;
}
.product-chart-card summary > span:first-child {
  color: var(--text-primary);
}
.chart-summary {
  margin-left: auto; color: var(--text-secondary); font-size: 12px; font-weight: 600; text-align: right;
  text-transform: none; letter-spacing: 0;
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.family-chart { display: grid; gap: 9px; padding: 2px 0 0; }
.product-chart-card .family-chart { padding: 0 18px 16px; }
.compact-rank { gap: 7px; }
.family-legend { display: flex; gap: 16px; align-items: center; justify-content: flex-end; margin-bottom: 6px; color: var(--text-muted); font-size: 11px; }
.family-legend span { display: inline-flex; align-items: center; gap: 6px; }
.family-legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.family-row { display: grid; grid-template-columns: minmax(110px, 170px) minmax(0, 1fr) minmax(110px, auto); gap: 12px; align-items: center; min-height: 38px; }
.compact-rank .family-row { grid-template-columns: minmax(160px, 240px) minmax(0, 1fr) minmax(96px, auto); min-height: 30px; }
.family-label { color: var(--text-primary); font-size: 11px; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.compact-rank .family-label {
  display: flex; align-items: center; gap: 7px; min-width: 0; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; overflow-wrap: normal;
}
.rank-n {
  flex: 0 0 auto; width: 20px; height: 20px; display: inline-grid; place-items: center;
  border-radius: 999px; background: var(--accent-a-soft); color: var(--accent-a);
  font-size: 10px; font-weight: 800;
}
.family-barset { display: grid; gap: 5px; min-width: 0; }
.family-track { height: 13px; background: rgba(45,42,38,.05); border-radius: 999px; overflow: hidden; }
.compact-rank .family-track { height: 9px; }
.family-bar { height: 100%; min-width: 2px; border-radius: 999px; }
.family-values { color: var(--text-secondary); font-size: 11px; line-height: 1.25; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.family-empty { color: var(--text-muted); font-size: 12px; }
.product-chart-grid { gap: 10px; }
.product-chart-tiles {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}
.product-chart-tile {
  min-width: 0; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: rgba(255,255,255,.62);
}
.product-tile-head {
  display: flex; align-items: center; gap: 8px; min-width: 0;
}
.product-tile-label {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text-primary); font-size: 11px; font-weight: 800; line-height: 1.2;
}
.product-tile-values {
  display: flex; justify-content: space-between; gap: 10px; margin-top: 8px;
  color: var(--text-secondary); font-size: 11px; font-variant-numeric: tabular-nums;
}
.product-tile-values b { color: var(--accent-a); font-size: 13px; }
.product-tile-bars { display: grid; gap: 4px; margin-top: 8px; }
.product-tile-bars span {
  display: block; height: 7px; min-width: 2px; border-radius: 999px;
}
.product-tile-delta {
  width: max-content; margin-top: 8px; padding: 2px 7px; border-radius: 999px;
  background: rgba(45,42,38,.05); color: var(--text-secondary);
  font-size: 10px; font-weight: 800; line-height: 1.2;
}
.product-tile-delta.cmp-pos { color: var(--green); background: var(--green-soft); }
.product-tile-delta.cmp-neg { color: var(--red); background: var(--red-soft); }

/* Matriz tipo Power BI */
table.matrix { width: max-content; min-width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.matrix th { font-size: 10px; font-weight: 600; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.4px; padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
table.matrix td { padding: 7px 10px; border-bottom: 1px solid var(--border-light); }
table.matrix td.num, table.matrix th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.matrix th:first-child, table.matrix td:first-child {
  position: sticky; left: 0; background: var(--bg-card-2); z-index: 1; }
table.matrix th:first-child { z-index: 2; }
table.matrix .mx-row:hover { background: var(--accent-a-soft); }
table.matrix .mx-row:hover td:first-child { background: var(--accent-a-soft); }
table.matrix .mx-total td { font-weight: 700; border-bottom: 2px solid var(--border); background: rgba(45,42,38,0.03); }
.mx-caret { display: inline-block; width: 12px; color: var(--accent-a); font-size: 10px; }

/* Scroll lateral: la 1ª columna fija necesita fondo OPACO; si es translúcido,
   el contenido de las demás columnas se transparenta por debajo al desplazar. */
table.matrix th:first-child, table.matrix td:first-child { background: #FBF9F6; }
table.matrix tr.mx-row:hover td:first-child { background: #ECE4FB; }

/* Matriz compacta (jerarquía): menos alto de fila y celdas más juntas. */
table.matrix.compact td { padding: 4px 10px; }
table.matrix.compact th { padding: 6px 10px; }
table.matrix.compact .mx-caret { width: 11px; }

/* Fila desplegada: resáltala para no confundir qué está abierto. */
table.matrix tr.hier-open > td { background: var(--accent-a-soft); font-weight: 600; }
table.matrix tr.hier-open td:first-child {
  background: #ECE4FB;   /* opaco: tapa las columnas que se desplazan por debajo */
  box-shadow: inset 3px 0 0 var(--accent-a);
}
table.matrix tr.hier-open .mx-caret { font-size: 12px; font-weight: 700; }
/* Filas hijas (anidadas): guía sutil a la izquierda para ver la profundidad. */
table.matrix tr.hier-child td:first-child { box-shadow: inset 2px 0 0 var(--border); }
table.matrix tr.hier-child.hier-open td:first-child { box-shadow: inset 3px 0 0 var(--accent-a); }
td.cmp-pos { color: var(--green); background: var(--green-soft); }
td.cmp-neg { color: var(--red); background: var(--red-soft); }

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

@media (max-width: 980px) {
  #view-graph {
    width: auto; max-width: none; margin-left: 0; transform: none;
  }
  .analysis-view .cmp-period-details { grid-template-columns: 1fr; }
  .analysis-view .cmp-period-top { grid-template-columns: 1fr; }
  .cmp-period-msg { justify-self: stretch; max-width: none; text-align: left; }
  /* En tablet el mensaje del periodo ya no va forzado a una sola línea. */
  .cmp-period-msg .msg { white-space: normal; overflow: visible; text-overflow: clip; }
  .admin-grid { grid-template-columns: 1fr; }
  .admin-create-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-create-submit { width: 100%; }
  .admin-users-toolbar { grid-template-columns: 1fr; }
  .admin-users-summary { justify-self: start; }
  .profile-password-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .analysis-view .cmp-filter-tools { grid-template-columns: 1fr auto; }
  .analysis-view .cmp-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .info-panel-grid { grid-template-columns: 1fr; }
  .product-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #view-graph .graph-board { grid-template-columns: repeat(2, minmax(220px, 1fr)); }
  .graph-relation-grid { grid-template-columns: 1fr; }
  .schema-bridges { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #view-graph .schema-db-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  main { padding-left: 16px; padding-right: 16px; }
  h1 { font-size: 26px; }
  nav { padding: 0 14px; gap: 4px; }
  .brand { margin-right: 6px; font-size: 13px; white-space: nowrap; }
  .tab { padding-left: 10px; padding-right: 10px; }
  /* En móvil los indicadores de estado se reducen a su punto de color
     (verde/rojo) para que la navegación quepa sin desbordar. */
  .nav-right { gap: 10px; margin-left: auto; }
  .nav-status { width: 20px; }
  .nav-logout { padding-left: 9px; padding-right: 9px; }
  /* En móvil el cuadro de usuario se reduce al avatar (nombre/rol/chevron ocultos)
     para no desbordar; el menú desplegable sigue funcionando igual. */
  .user-meta, .user-chev { display: none; }
  .user-trigger { max-width: none; padding: 3px; border-radius: 50%; }
  .user-menu { min-width: 200px; }
  .auth-card { padding: 22px 18px; }
  .card-head { align-items: flex-start; flex-direction: column; gap: 12px; }
  .card-head > div:first-child { min-width: 0; width: 100%; }
  .admin-create-panel summary { align-items: flex-start; flex-direction: column; }
  .admin-create-panel summary small { text-align: left; }
  .admin-create-grid, .admin-users-filters, .admin-filters, .admin-create-page { grid-template-columns: 1fr; }
  .card-head-actions { width: 100%; justify-content: flex-start; }
  .card-head-actions .btn-primary,
  .card-head-actions .btn-ghost { flex: 1 1 0; min-width: 0; padding-left: 10px; padding-right: 10px; }
  #admin-pane-users .card-head-actions {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px;
  }
  #admin-pane-users .card-head-actions .btn-primary,
  #admin-pane-users .card-head-actions .btn-ghost { width: 100%; }
  #admin-pane-users .admin-pending { grid-column: 1 / -1; width: auto; }
  .admin-pending { width: 100%; }
  .admin-reset-box { grid-template-columns: 1fr; }
  .admin-subtabs { display: flex; width: 100%; border-radius: 16px; }
  .admin-subtab { flex: 1 1 0; min-width: 0; padding-left: 8px; padding-right: 8px; }
  .admin-user-actions { min-width: 0; text-align: left; white-space: normal; }
  .admin-scroll { max-height: none; overflow: visible; }
  .admin-table thead { display: none; }
  .admin-table, .admin-table tbody, .admin-table tr, .admin-table td {
    display: block; width: 100%; max-width: 100%; box-sizing: border-box;
  }
  .admin-table tbody tr {
    margin-bottom: 10px; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: rgba(255,255,255,.58);
  }
  .admin-table td {
    display: grid; grid-template-columns: minmax(82px, 96px) minmax(0, 1fr); gap: 8px; align-items: center;
    border: none; padding: 6px 4px; overflow: hidden;
  }
  .admin-table td::before {
    content: attr(data-label); color: var(--text-muted); font-size: 10px; font-weight: 800;
    text-transform: uppercase; letter-spacing: .6px;
  }
  .admin-email-cell, .admin-email-cell span:first-child { min-width: 0; max-width: 100%; }
  .admin-email-cell span:first-child { word-break: break-word; }
  .admin-table .admin-user-actions { display: grid; grid-template-columns: minmax(82px, 96px) minmax(0, 1fr); }
  .admin-table .admin-user-actions::before { align-self: center; }
  .admin-action-list { position: static; margin-top: 6px; }
  .profile-password-form { grid-template-columns: 1fr; }
  .token-create { grid-template-columns: 1fr; }
  .graph-toolbar { grid-template-columns: 1fr; margin-left: 0; margin-right: 0; }
  .graph-canvas { padding: 10px; }
  #view-graph .graph-board { grid-template-columns: 1fr; }
  .schema-bridges { grid-template-columns: 1fr; }
  .schema-table summary { grid-template-columns: 1fr; }
  .schema-table summary em { text-align: left; }
  .schema-field-grid { grid-template-columns: 1fr; }
  .admin-actions .btn-primary, .admin-actions .btn-ghost { width: 100%; }
  /* El mensaje del periodo deja de ir en una sola línea: si no, estira
     toda la tarjeta y empuja modos y filtros fuera de pantalla. */
  .cmp-period-msg { justify-self: stretch; max-width: 100%; width: auto; text-align: left; }
  .cmp-period-msg .msg { white-space: normal; overflow: visible; text-overflow: clip; }
  .analysis-view .cmp-filter-tools { grid-template-columns: 1fr; }
  .analysis-view .cmp-clear-btn { width: 100%; }
  .analysis-view .cmp-filter-grid { grid-template-columns: 1fr; }
  .product-kpi-grid { grid-template-columns: 1fr; }
  .analysis-view .cmp-mode-tabs { width: 100%; }
  .analysis-view .period-tabs { display: flex; width: 100%; min-width: 0; }
  .analysis-view .period-tabs .ptab { flex: 1 1 0; min-width: 0; padding-left: 5px; padding-right: 5px; font-size: 11px; line-height: 1.15; white-space: normal; }
  .analysis-view .cmp-periodbar,
  .analysis-view .cmp-period-top,
  .analysis-view .cmp-period-details,
  .analysis-view .cmp-chip,
  .analysis-view .cmp-adv-range { min-width: 0; max-width: 100%; }
  .analysis-view .navlbl { min-width: 0; }
  /* Modo Avanzado en vertical: los campos de fecha se apilan a ancho completo
     (Desde / Hasta), sin solaparse. */
  .analysis-view .cmp-adv-range {
    flex-direction: column; align-items: stretch; gap: 8px;
    min-height: 0; border-radius: 16px; padding: 12px 14px; white-space: normal;
  }
  .analysis-view .cmp-adv-range .dot-a,
  .analysis-view .cmp-adv-range .dot-b { display: none; }
  .analysis-view .cmp-adv-a { flex-direction: column; align-items: stretch; gap: 8px; width: 100%; }
  .analysis-view .cmp-adv-field {
    width: 100%; height: auto; padding: 6px 12px; justify-content: space-between; gap: 10px;
  }
  .analysis-view .cmp-adv-field .cal-field { flex: 1 1 auto; min-width: 0; justify-content: flex-end; }
  .analysis-view .cmp-range-arrow { display: none; }
  .analysis-view .cmp-adv-range .vs { align-self: flex-start; }
  #cmp_adv_b, #pr_adv_b { align-self: flex-start; }
  .family-row { grid-template-columns: 1fr; gap: 5px; min-height: 0; }
  .family-label { font-size: 10px; }
  .family-values { display: flex; justify-content: space-between; text-align: left; font-size: 10px; }

  /* (1) Gráfico de días: barras más estrechas para que las 7 columnas quepan sin
     scroll. overflow-x: clip evita que los tooltips ocultos (.dow-tip, absolutos)
     generen una barra de scroll y espacio vacío a la derecha. */
  #cmp_dow { overflow-x: clip; }
  #cmp_dow .dow-chart { gap: 4px; }
  .dow-bar { width: 16px; }
  #cmp_dow .dow-chart > .dow-col > div { gap: 3px !important; }

  /* Contribución: los dos paneles (Impulsan/Frenan) se apilan y la fila
     (etiqueta + barra + valor) se compacta para que quepa sin scroll horizontal. */
  .wf-groups { grid-template-columns: 1fr; gap: 10px; }
  .wf-item { grid-template-columns: minmax(70px, 110px) minmax(0, 1fr) minmax(64px, auto); gap: 8px; }
  .wf-item-name, .wf-item-val { font-size: 11px; }
  .wf-caption { font-size: 12px; }
  .wf-value { font-size: 9px; max-width: 46px; }

  /* (2) Tablas/matriz: caja con scroll propio acotada a la pantalla (70vh). Así la
     barra horizontal queda DENTRO del viewport y se puede llegar a las últimas
     columnas, y a la vez se navega hasta el final de los datos en vertical dentro
     de la caja (con max-height:none la barra horizontal caía al fondo, fuera de
     pantalla, y no se alcanzaban las últimas columnas). */
  .cmp-table-card .scroll, #cmp_top, #pr_table, #ds_table {
    max-height: 70vh; overflow: auto; -webkit-overflow-scrolling: touch;
  }

  /* (3) Tooltips de ayuda: que no se salgan del borde del dispositivo. */
  .has-help::after { left: 8px; right: 8px; width: auto; max-width: none; }
  .has-help::before { left: 16px; right: auto; }
  th.has-help::after { left: 8px; right: 8px; }
  .col-tip { max-width: calc(100vw - 16px); }
}

/* ─────────── Tickets: matriz hora × día + tamaño de cesta ─────────── */
table.matrix.tk-matrix td.tk-cell { vertical-align: top; text-align: right; min-width: 96px; }
.tk-cell-eur { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-primary); }
.tk-cell-sub { font-size: 10.5px; color: var(--text-secondary); font-variant-numeric: tabular-nums; margin-top: 2px; }
.tk-cell-dev { font-size: 10.5px; color: var(--red); margin-top: 2px; }
table.matrix.tk-matrix td.tk-total, table.matrix.tk-matrix .tk-foot td,
table.matrix.tk-matrix .tk-foot th { background: rgba(45,42,38,0.03); font-weight: 700; }
table.matrix.tk-matrix .tk-foot td, table.matrix.tk-matrix .tk-foot th { border-top: 2px solid var(--border); }
table.matrix.tk-matrix th.tk-row-h { text-transform: none; font-size: 11.5px; color: var(--text-primary); }
.tk-empty { color: var(--text-secondary); padding: 18px 4px; font-size: 13px; }

/* Selector de métrica de la matriz (segmented). */
.tk-metric-sel { display: inline-flex; gap: 2px; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px; flex-wrap: wrap; }
.tk-metric { border: none; background: transparent; color: var(--text-secondary); font-family: var(--font);
  font-size: 12px; font-weight: 600; padding: 6px 12px; border-radius: 999px; cursor: pointer; }
.tk-metric:hover { color: var(--text-primary); }
.tk-metric.active { background: var(--accent-a); color: #fff; }

/* Matriz de tickets: altura COMPLETA (sin scroll vertical), solo scroll horizontal si no cabe. */
.tk-mx-wrap { overflow-x: auto; overflow-y: visible; max-width: 100%; min-width: 0; }
/* Crosshair de análisis: al pasar el ratón se resaltan la fila y la columna de la celda. */
table.matrix.tk-matrix td.tk-hi-col, table.matrix.tk-matrix th.tk-hi-col,
table.matrix.tk-matrix tr.tk-hi-row > td, table.matrix.tk-matrix tr.tk-hi-row > th { background: var(--accent-a-soft); }
table.matrix.tk-matrix td.tk-cell { transition: background .08s ease; cursor: default; }
table.matrix.tk-matrix td.tk-cell:hover { box-shadow: inset 0 0 0 2px var(--accent-a); }
/* Heatmap: el fondo de cada celda de datos tiñe según su venta (--hm = 0..~0.55). */
table.matrix.tk-matrix td.tk-cell { position: relative; }
table.matrix.tk-matrix td.tk-cell::before { content: ""; position: absolute; inset: 0;
  background: var(--accent-a); opacity: var(--hm, 0); z-index: 0; pointer-events: none; }
table.matrix.tk-matrix td.tk-cell > * { position: relative; z-index: 1; }
/* Al resaltar fila/columna se oculta el heatmap de esas celdas para que se vea el crosshair. */
table.matrix.tk-matrix td.tk-hi-col::before,
table.matrix.tk-matrix tr.tk-hi-row > td.tk-cell::before { opacity: 0; }
/* Celda punta (mayor venta del periodo). */
/* Celda punta: borde ÁMBAR (contrasta con el heatmap violeta) para que destaque de un vistazo. */
table.matrix.tk-matrix td.tk-peak { outline: 2px solid #e0900a; outline-offset: -2px;
  box-shadow: inset 0 0 0 3px rgba(224,144,10,0.18); }
/* Tooltip flotante con el desglose completo de la celda. */
.tk-tip { position: fixed; z-index: 9999; pointer-events: none; display: none;
  background: var(--text-primary); color: #fff; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md); padding: 10px 12px; font-size: 12px; min-width: 172px; }
.tk-tip-h { font-weight: 700; margin-bottom: 6px; font-size: 12.5px; white-space: nowrap; }
.tk-tip-row { display: flex; justify-content: space-between; gap: 18px; line-height: 1.65; }
.tk-tip-row > span { color: rgba(255,255,255,0.65); }
.tk-tip-row > b { font-variant-numeric: tabular-nums; font-weight: 700; }
.tk-tip-row.tk-tip-dev > b { color: #ff9b9b; }

/* Cesta: gráfico de COLUMNAS verticales (barras por tramo), año actual vs anterior. */
.tk-basket-when { margin-bottom: 12px; }
.tk-basket-when b { color: var(--text-primary); font-weight: 700; }
.tk-basket-v { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px;
  height: 210px; padding: 10px 6px 0; }
.tk-bkt { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%;
  border-radius: 10px; padding: 4px 2px 0; transition: background .1s ease; cursor: default; }
.tk-bkt.tk-bkt-hi { background: var(--accent-a-soft); }
.tk-bkt-plot { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 6px; }
.tk-bkt-bar { width: 24px; max-width: 42%; min-height: 3px; border-radius: 6px 6px 0 0; transition: filter .1s ease; }
.tk-bkt-hi .tk-bkt-bar { filter: brightness(1.06); }
.tk-bkt-a { background: var(--accent-a); }
.tk-bkt-b { background: color-mix(in srgb, var(--accent-a) 28%, transparent); }
.tk-bkt-x { margin-top: 8px; font-size: 11.5px; font-weight: 600; color: var(--text-secondary); white-space: nowrap; }
.tk-basket-legend { display: flex; align-items: center; gap: 6px 18px; flex-wrap: wrap;
  margin-top: 14px; font-size: 12px; color: var(--text-secondary); }
.tk-lg-item { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.tk-lg { display: inline-block; width: 12px; height: 12px; border-radius: 3px; flex: none; }
.tk-lg-a { background: var(--accent-a); }
.tk-lg-b { background: color-mix(in srgb, var(--accent-a) 28%, transparent); }
@media (max-width: 640px) {
  .tk-basket-v { height: 170px; gap: 8px; }
  .tk-bkt-bar { width: 16px; }
  .tk-basket-legend { flex-direction: column; align-items: flex-start; gap: 6px; }
  #tk_kpis .kpi-value { font-size: 22px; letter-spacing: -.5px; }
}

/* Acciones al final del bloque de filtros de Tickets (Exportar + Limpiar, juntos y a la derecha). */
.tk-filter-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 12px; }
.tk-filter-group-title {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  margin: 4px 0 -2px;
  text-transform: uppercase;
}
.tk-filter-group-title + .cmp-filter { margin-left: 0; }
.tk-coverage {
  min-width: 0; margin-right: auto; color: var(--muted); font-size: 12px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tk-coverage.warn {
  color: var(--warning, #9a6500); font-weight: 600;
  overflow: visible; white-space: normal;
}
@media (max-width: 640px) {
  .tk-filter-actions { flex-direction: column; align-items: stretch; }
  .tk-filter-actions .tk-coverage { margin: 0 0 2px; }
  .tk-filter-actions .export-btn, .tk-filter-actions .cmp-clear-btn { width: 100%; }
}

/* Rejilla de 2 tablas (día de la semana / franja) y tablas resumen de Tickets. */
.tk-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.tk-grid2 > * { min-width: 0; }
@media (max-width: 860px) { .tk-grid2 { grid-template-columns: 1fr; } }

/* ── Gráfico de evolución (líneas A vs B), reutilizable Tickets/Comparador ── */
.evo-legend { margin-top: 4px; margin-bottom: 10px; }
.evo-lg { display: inline-block; width: 12px; height: 12px; border-radius: 3px; flex: none; }
.evo-lg-a { background: var(--accent-a); }
.evo-lg-b { background: var(--accent-b); }
.evo-chart-wrap { position: relative; width: 100%; }
.evo-svg { width: 100%; height: auto; display: block; touch-action: none; }
.evo-grid { stroke: var(--border); stroke-width: 1; opacity: .6; }
.evo-axis { stroke: var(--border); stroke-width: 1.2; }
.evo-ylab { fill: var(--text-muted); font-size: 12px; text-anchor: end; }
.evo-xlab { fill: var(--text-muted); font-size: 12px; text-anchor: middle; }
.evo-guide { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 3 3; opacity: .7; }
.evo-dot-a { fill: var(--accent-a); stroke: #fff; stroke-width: 1.5; }
.evo-dot-b { fill: var(--accent-b); stroke: #fff; stroke-width: 1.5; }
.evo-tip { position: absolute; top: 6px; transform: translateX(-50%); z-index: 3;
  background: var(--text-primary); color: #fff; border-radius: 8px; padding: 7px 10px;
  font-size: 11.5px; line-height: 1.5; white-space: nowrap; pointer-events: none;
  box-shadow: 0 6px 20px rgba(0,0,0,.18); }
.evo-tip-h { font-weight: 700; margin-bottom: 2px; }
.evo-tip-row { display: flex; align-items: center; gap: 6px; }
.evo-tip-row .evo-lg { width: 9px; height: 9px; }
@media (max-width: 640px) {
  .evo-svg { min-height: 220px; }
  .evo-ylab, .evo-xlab { font-size: 17px; }
}
table.tk-tbl { width: 100%; min-width: 100%; }
table.tk-tbl th.tk-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
table.tk-tbl th.tk-sortable:hover { color: var(--text-primary); }
table.tk-tbl .tk-rank-n { width: 34px; text-align: right; color: var(--text-secondary);
  font-variant-numeric: tabular-nums; font-weight: 600; }
table.tk-tbl .tk-delta.pos { color: var(--accent-a); }
table.tk-tbl .tk-delta.neg { color: var(--red); }
table.matrix.tk-rank tbody tr:hover td, table.matrix.tk-rank tbody tr:hover th { background: var(--accent-a-soft); }
#tk_stores.scroll { max-height: 520px; }
/* Descuentos: ancho completo para que nombres e importes no compitan por media tarjeta. */
.tk-discount-tables { display: grid; grid-template-columns: minmax(0, 1fr); }
#view-tickets table.tk-tbl .tk-row-h { white-space: normal; overflow-wrap: anywhere;
  text-transform: none; letter-spacing: normal; font-size: 12px; }
#view-tickets table.tk-tbl thead th { position: sticky; top: 0;
  background: var(--bg-card-2); z-index: 3; }
#view-tickets table.tk-tbl thead th:first-child { z-index: 4; }
#tk_dto_top .tk-row-h, #tk_dto_promos .tk-row-h { width: 55%; }
#tk_dto_tramos.scroll { max-height: none; }
.tk-rank-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tk-rank-tools .inp-sm { min-width: 160px; }

/* KPIs de Tickets: fila media compacta de 4 columnas (evita tarjetas enormes con dato pequeño). */
.product-kpi-grid.tk-kpi-mid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.product-kpi-grid.tk-kpi-mid .kpi { min-height: 116px; }
@media (max-width: 980px) { .product-kpi-grid.tk-kpi-mid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .product-kpi-grid.tk-kpi-mid { grid-template-columns: 1fr; } }

/* ─────────── Comparador de tiendas (dos lados) ─────────── */
.cx-sides { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cx-side { border: 1px solid var(--border); border-radius: 14px; padding: 14px; background: var(--bg-card-2); }
.cx-side-head { font-weight: 700; font-size: 13px; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.cx-side-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: end; }
.cx-opts { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.cx-grain { font-size: 12px; color: var(--text-secondary); display: inline-flex; align-items: center; gap: 8px; }
.cx-kpi-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.cx-kpi-head { font-size: 12px; font-weight: 700; color: var(--text-secondary); margin-bottom: 8px;
  display: flex; align-items: center; gap: 8px; }
.cx-tools-btns { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cx-kpi-grid .cx-kpi { display: flex; flex-direction: column; gap: 8px; }
.product-kpi-grid.cx-kpi-grid { grid-template-columns: minmax(0, 1fr); }
.cx-kpi-ab { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.cx-side-label { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-secondary); }
.cx-kpi-val { min-width: 0; flex-wrap: wrap; }
.cx-kpi-head { min-width: 0; overflow-wrap: anywhere; }
.cx-kpi-val { display: flex; align-items: center; gap: 8px; font-size: 20px; font-weight: 700; line-height: 1.15; }
.cx-kpi-val .dot { flex: none; }
.cx-kpi-delta { font-size: 11px; color: var(--text-secondary); display: flex; align-items: center; gap: 4px; }
/* Interruptor de modo (Tienda vs tienda / Periodo vs periodo) */
.cx-mode { display: inline-flex; gap: 4px; padding: 4px; border: 1px solid var(--border);
  border-radius: 12px; background: var(--bg-card-2); margin-bottom: 14px; }
.cx-mode-btn { border: 0; background: transparent; color: var(--text-secondary); font: inherit;
  font-size: 13px; font-weight: 600; padding: 6px 14px; border-radius: 9px; cursor: pointer; }
.cx-mode-btn.active { background: var(--accent-a-grad); color: #fff; }
#view-comparador.cx-period-mode .cx-store-field { display: none; }
#view-comparador.cx-group-mode .cx-b-store-field { display: none; }
/* Aviso de duraciones distintas */
.cx-warn { border: 1px solid #F5C77E; background: #FDF6E9; color: #8a5a00; border-radius: 12px;
  padding: 10px 14px; font-size: 13px; margin-bottom: 16px; }
/* Barras emparejadas A vs B */
.cx-bars { margin-top: 4px; }
.cx-bars-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 24px; }
.cx-bar-metric { display: flex; flex-direction: column; gap: 5px; }
.cx-bar-label { font-size: 12px; font-weight: 700; color: var(--text-secondary); }
.cx-bar-row { display: flex; align-items: center; gap: 8px; }
.cx-bar-track { flex: 1; height: 12px; border-radius: 6px; background: var(--accent-a-soft); overflow: hidden; }
.cx-bar-fill { display: block; height: 100%; border-radius: 6px; }
.cx-bar-fill.dot-a-bg { background: var(--accent-a); }
.cx-bar-fill.dot-b-bg { background: var(--accent-b); }
.cx-bar-val { font-size: 12px; font-weight: 700; min-width: 78px; text-align: right; }
#view-comparador .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }
#view-comparador .dot-a { background: var(--accent-a); }
#view-comparador .dot-b { background: var(--accent-b); }
@media (max-width: 860px) {
  .cx-bars-grid { grid-template-columns: 1fr; }
  .cx-sides { grid-template-columns: 1fr; }
  .cx-kpi-cols { grid-template-columns: 1fr 1fr; }
}
