:root {
  --fondo: #f2f2f0;
  --superficie: #fff;
  --tinta: #141414;
  --suave: #67645e;
  --borde: #e7e5e0;
  --primario: #ff6b3d;
  --primario-tinta: #2a0f05;
  --violeta: #7c5cff;
  --verde: #1f9d6b;
  --rojo: #d2412f;
  --radio: 14px;
  font-family: 'Hanken Grotesk', system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--fondo); color: var(--tinta); -webkit-font-smoothing: antialiased; }
h1, h2, p { margin: 0; }
button, input, select { font: inherit; }
svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 3px solid var(--violeta); outline-offset: 2px; }
.oculto { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.sube { color: var(--verde); } .baja { color: var(--rojo); } .positivo { color: var(--verde); }

.app { display: grid; grid-template-columns: 216px minmax(0, 1fr); min-height: calc(100dvh - var(--muestrario-barra, 0px)); }

/* ---------- Lateral (claro y compacto) ---------- */
.lateral { position: sticky; top: 0; height: calc(100dvh - var(--muestrario-barra, 0px)); display: flex; flex-direction: column; gap: 18px; padding: 22px 14px; background: var(--superficie); border-right: 1px solid var(--borde); }
.logo { display: flex; align-items: center; gap: 9px; padding: 0 6px; font-size: 1.05rem; letter-spacing: -.01em; }
.logo__marca { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--primario); color: var(--primario-tinta); }
.logo__marca svg { width: 18px; height: 18px; stroke-width: 3; }
.menu { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.menu a, .menu button { position: relative; display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: none; color: #45423d; text-decoration: none; font-size: .92rem; font-weight: 500; text-align: left; cursor: pointer; }
.menu svg { width: 17px; height: 17px; stroke-width: 1.8; }
.menu a:hover, .menu button:hover { background: #f4f2ee; color: var(--tinta); }
.menu a[aria-current] { background: #fff1ea; color: var(--tinta); font-weight: 700; }
.menu a[aria-current]::before { content: ''; position: absolute; left: -14px; top: 6px; bottom: 6px; width: 4px; border-radius: 0 4px 4px 0; background: var(--primario); }
.menu__separador { height: 1px; margin: 8px 4px; background: var(--borde); }
.pildora { margin-left: auto; padding: 2px 8px; border-radius: 999px; background: var(--violeta); color: #fff; font-size: .72rem; }
.nivel-mini { margin-top: auto; padding: 12px; border-radius: 12px; background: #f6f4f0; font-size: .88rem; }
.nivel-mini__fila { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.nivel-mini__fila > span:last-child { display: grid; line-height: 1.25; }
.nivel-mini small { color: var(--suave); }
.nivel-mini__badge { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: conic-gradient(var(--violeta), var(--primario), var(--violeta)); color: #fff; font-weight: 800; }
.racha { margin-top: 8px; font-size: .85rem; color: var(--suave); }
.version { color: #9b978f; font-size: .75rem; text-align: center; }

/* ---------- Barra superior ---------- */
.contenido { display: flex; flex-direction: column; min-width: 0; }
.barra-sup { position: sticky; top: 0; z-index: 10; display: flex; justify-content: flex-end; align-items: center; gap: 18px; height: 56px; padding: 0 clamp(20px, 3vw, 36px); background: var(--superficie); border-bottom: 1px solid var(--borde); font-size: .9rem; color: var(--suave); }
.barra-sup__dato { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.barra-sup__dato svg { width: 16px; height: 16px; color: #e0a21b; }
.barra-sup__icono { display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 50%; background: none; color: var(--suave); cursor: pointer; }
.barra-sup__icono:hover { background: #f4f2ee; }
.barra-sup__icono svg { width: 19px; height: 19px; }
.usuaria { display: inline-flex; align-items: center; gap: 9px; padding-left: 16px; border-left: 1px solid var(--borde); color: var(--tinta); font-weight: 700; }
.usuaria__foto { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: #ffd9c9; color: #9a3412; font-weight: 800; }

/* ---------- Botones ---------- */
.boton { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 18px; border: 1.5px solid var(--borde); border-radius: 999px; background: var(--superficie); color: var(--tinta); font-weight: 700; cursor: pointer; transition: transform .15s, box-shadow .15s, background .15s; }
.boton:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgb(0 0 0 / 8%); }
.boton:active { transform: none; box-shadow: none; }
.boton--primario { background: var(--primario); border-color: var(--primario); color: var(--primario-tinta); }
.boton--ancho { width: 100%; }
.boton--chico { min-height: 36px; padding: 0 12px; font-size: .9rem; }
.enlace { border: 0; background: none; padding: 0; color: var(--violeta); font-weight: 700; cursor: pointer; text-decoration: none; }
.enlace:hover { text-decoration: underline; }

/* ---------- Principal ---------- */
.principal { padding: 24px clamp(20px, 3vw, 36px) 120px; display: grid; gap: 16px; align-content: start; max-width: 1320px; width: 100%; outline: none; }
.cabeza { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.cabeza h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: -.025em; margin: 0 0 2px; }
.cabeza__acciones { display: flex; align-items: center; gap: 8px; }
.sobre { color: var(--suave); font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.bajada { color: var(--suave); font-size: .95rem; }
.filtro { display: inline-flex; align-items: center; gap: 18px; height: 36px; padding: 0 12px; border: 1px solid var(--borde); border-radius: 8px; background: var(--superficie); font-size: .88rem; }
.filtro::after { content: ''; width: 7px; height: 7px; border: solid var(--suave); border-width: 0 1.5px 1.5px 0; transform: translateY(-2px) rotate(45deg); }
.dato-chico { color: var(--suave); font-size: .82rem; font-weight: 600; }

/* ---------- Tablero de inicio ---------- */
.tablero { display: grid; grid-template-columns: minmax(0, 1fr) 272px; gap: 16px; align-items: start; }
.tablero__centro, .tablero__lado { display: grid; gap: 16px; }
.tablero__par { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.resumen { display: grid; gap: 12px; }
.resumen .panel__cabeza { margin-bottom: 0; }
.resumen__fila { display: grid; gap: 6px; }
.resumen__fila > div:first-child { display: flex; justify-content: space-between; font-size: .85rem; color: var(--suave); }
.resumen__fila b { color: var(--tinta); }
.barra.barra--verde i { background: var(--verde); } .barra.barra--naranja i { background: var(--primario); } .barra.barra--violeta i { background: var(--violeta); }
.mini { display: grid; gap: 6px; padding: 16px; }
.mini h2 { font-size: .98rem; font-weight: 700; }
.mini small { color: var(--suave); font-size: .82rem; }
.mini__grande { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; }
.mini--fila { grid-template-columns: auto 1fr; align-items: center; column-gap: 12px; }
.mini__icono { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: #fff1ea; color: #c4471f; }
.mini__pildora { grid-column: 1 / -1; display: grid; place-items: center; height: 36px; margin-top: 4px; border-radius: 999px; background: #fff1ea; color: #9a3412; font-size: 1.05rem; font-weight: 800; }
.mini__cab { display: flex; gap: 12px; align-items: center; }
.mini__cab > div { display: grid; gap: 1px; }
.medalla-prod--oro { --m: #e7b416; } .medalla-prod--plata { --m: #a7adb5; } .medalla-prod--bronce { --m: #c0703a; }
.medalla-prod__img { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 10px; background: var(--c); font-weight: 800; color: rgb(0 0 0 / 75%); box-shadow: inset 0 0 0 2px var(--m); }


.panel { padding: 18px; border-radius: var(--radio); background: var(--superficie); border: 1px solid var(--borde); }
.panel__cabeza { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.panel h2 { font-size: 1rem; font-weight: 800; letter-spacing: -.01em; }
.panel--ancho { grid-column: 1 / -1; }
.leyenda { display: flex; align-items: center; gap: 6px; color: var(--suave); font-size: .85rem; }
.leyenda i { width: 10px; height: 10px; border-radius: 3px; margin-left: 8px; }
.l-ing { background: var(--primario); } .l-egr { background: #ffd2c2; }
.grafico { width: 100%; height: auto; overflow: visible; stroke: none; }
.grafico rect, .grafico text { stroke: none; }
.grafico .b-ing { fill: var(--primario); } .grafico .b-egr { fill: #ffd2c2; }
.grafico rect { transition: opacity .15s; } .grafico rect:hover { opacity: .75; }
.grafico text { fill: var(--suave); font-size: 13px; font-family: inherit; }
.grafico .meta { stroke: var(--primario); stroke-width: 2; stroke-dasharray: 6 6; }
.grafico .meta-t { fill: #c4471f; font-weight: 700; }

.barra { height: 8px; border-radius: 999px; background: #efece6; overflow: hidden; }
.barra i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--violeta), var(--primario)); transition: width .6s cubic-bezier(.2, .8, .2, 1); }

.misiones ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.misiones li { display: grid; gap: 8px; }
.mision__fila { display: flex; gap: 10px; align-items: flex-start; }
.mision__fila p { flex: 1; font-weight: 600; line-height: 1.35; }
.check { display: grid; place-items: center; width: 22px; height: 22px; flex: none; border: 2px solid #cfcac0; border-radius: 7px; font-size: .8rem; font-weight: 800; }
.misiones li.hecha .check { background: var(--verde); border-color: var(--verde); color: #fff; }
.misiones li.hecha p { color: var(--suave); text-decoration: line-through; }
.misiones li.hecha .barra i { background: var(--verde); }
.xp { flex: none; padding: 2px 8px; border-radius: 999px; background: #efeaff; color: #5236d6; font-size: .8rem; font-weight: 800; }
.mision__pie { display: flex; justify-content: space-between; color: var(--suave); }


.alertas, .movs { list-style: none; margin: 0; padding: 0; display: grid; }
.alertas li { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--borde); }
.alertas li:first-child { border-top: 0; padding-top: 0; }
.alertas p { flex: 1; line-height: 1.4; }
.punto { width: 10px; height: 10px; flex: none; border-radius: 50%; }
.punto--naranja { background: var(--primario); } .punto--violeta { background: var(--violeta); } .punto--verde { background: var(--verde); }
.movs li { display: grid; grid-template-columns: 52px 1fr auto; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--borde); }
.movs li:first-child { border-top: 0; }
.movs small { color: var(--suave); }

.tabla { width: 100%; border-collapse: collapse; }
.tabla th, .tabla td { padding: 12px 10px; text-align: left; border-bottom: 1px solid var(--borde); }
.tabla thead th { color: var(--suave); font-size: .82rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.tabla tbody th { font-weight: 700; }
.tabla tr:last-child > * { border-bottom: 0; }
.cliente { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; }
.cliente .ini { grid-row: span 2; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: #efeaff; color: #5236d6; font-size: .8rem; }
.cliente small { color: var(--suave); font-weight: 400; }
.estado { padding: 3px 10px; border-radius: 999px; background: #f1eee8; font-size: .85rem; font-weight: 700; }
.estado.sube { background: #dff5ea; } .estado.baja { background: #fbe4df; }


.camino { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.camino li { position: relative; display: grid; justify-items: center; gap: 4px; text-align: center; color: var(--suave); }
.camino li > span { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; border: 2px dashed #cfcac0; font-weight: 800; font-size: 1.1rem; background: var(--superficie); position: relative; z-index: 1; }
.camino li:not(:last-child)::after { content: ''; position: absolute; top: 26px; left: 50%; width: 100%; height: 3px; background: #e6e2da; }
.camino li.pasado > span { border: 0; background: var(--tinta); color: #fff; }
.camino li.pasado::after { background: var(--tinta); }
.camino li.actual > span { border: 0; background: conic-gradient(var(--violeta), var(--primario), var(--violeta)); color: #fff; box-shadow: 0 0 0 6px #efeaff; }
.camino li.actual b { color: var(--tinta); }
.medallas { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.medallas li { display: grid; gap: 4px; justify-items: start; padding: 16px; border-radius: 16px; border: 1.5px dashed #d8d3c9; color: var(--suave); }
.medallas li.ganada { border: 1.5px solid #f0d58a; background: linear-gradient(160deg, #fffaf0, #fff); color: var(--tinta); }
.medalla__icono { font-size: 1.8rem; filter: grayscale(1) opacity(.4); }
.medallas li.ganada .medalla__icono { filter: none; }
.medallas small { color: var(--suave); }
.reiniciar { text-align: center; }

/* ---------- Modal ---------- */
.modal { width: min(440px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: 22px; box-shadow: 0 24px 80px rgb(0 0 0 / 25%); }
.modal::backdrop { background: rgb(20 20 20 / 45%); backdrop-filter: blur(2px); }
.modal form { display: grid; gap: 14px; padding: 24px; }
.modal h2 { font-size: 1.35rem; font-weight: 800; }
.modal label { display: grid; gap: 6px; font-weight: 600; }
.modal input, .modal select { min-height: 46px; padding: 0 12px; border: 1.5px solid var(--borde); border-radius: 12px; background: var(--superficie); color: var(--tinta); }
.modal input:focus, .modal select:focus { outline: 0; border-color: var(--violeta); box-shadow: 0 0 0 3px #e6dfff; }
.dos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal__acciones { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

/* ---------- Asistente ---------- */
.burbuja-asistente { position: fixed; right: 22px; bottom: 22px; z-index: 30; display: grid; place-items: center; width: 58px; height: 58px; border: 0; border-radius: 50%; background: var(--violeta); color: #fff; cursor: pointer; box-shadow: 0 10px 30px rgb(124 92 255 / 45%); }
.burbuja-asistente svg { width: 26px; height: 26px; fill: currentColor; stroke: none; }
.burbuja-asistente[hidden] { display: none; }
.asistente { position: fixed; right: 22px; bottom: 22px; z-index: 31; display: flex; flex-direction: column; width: min(380px, calc(100vw - 24px)); height: min(560px, calc(100dvh - 44px)); border-radius: 22px; background: var(--superficie); box-shadow: 0 24px 80px rgb(0 0 0 / 22%); overflow: hidden; }
.asistente[hidden] { display: none; }
.asistente header { display: grid; grid-template-columns: 1fr auto; padding: 16px 12px 14px 18px; background: linear-gradient(135deg, var(--violeta), #a07bff); color: #fff; }
.asistente header small { grid-row: 2; opacity: .85; }
.asistente header .icono { grid-row: span 2; align-self: center; width: 40px; height: 40px; border: 0; border-radius: 10px; background: #ffffff22; color: #fff; cursor: pointer; display: grid; place-items: center; }
.asistente ol { flex: 1; list-style: none; margin: 0; padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.asistente li { max-width: 88%; padding: 10px 13px; border-radius: 16px; line-height: 1.45; }
.asistente li.bot { align-self: flex-start; background: #f3f0ff; border-bottom-left-radius: 5px; }
.asistente li.yo { align-self: flex-end; background: var(--violeta); color: #fff; border-bottom-right-radius: 5px; }
.asistente .sugerencias { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 10px; }
.asistente .sugerencias button { padding: 7px 12px; border: 1.5px solid #d9cfff; border-radius: 999px; background: #fff; color: #5236d6; font-weight: 600; font-size: .88rem; cursor: pointer; }
.asistente form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--borde); }
.asistente input { flex: 1; min-width: 0; min-height: 44px; padding: 0 14px; border: 1.5px solid var(--borde); border-radius: 999px; }
.asistente form button { width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--violeta); color: #fff; display: grid; place-items: center; cursor: pointer; }

/* ---------- Toast y confeti ---------- */
.toast { position: fixed; left: 50%; top: 20px; z-index: 50; transform: translateX(-50%); padding: 12px 18px; border-radius: 14px; background: var(--tinta); color: #fff; font-weight: 700; box-shadow: 0 12px 30px rgb(0 0 0 / 25%); }
.toast.entra { animation: baja .35s cubic-bezier(.2, .9, .3, 1.3); }
@keyframes baja { from { opacity: 0; transform: translate(-50%, -16px); } }
.confeti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confeti i { position: absolute; top: -12px; left: var(--x); width: 9px; height: 14px; border-radius: 2px; background: var(--c); animation: cae var(--d) ease-in forwards; }
@keyframes cae { to { transform: translateY(105vh) rotate(var(--r)); } }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .tablero, .tablero__par { grid-template-columns: 1fr; }
  .tablero__lado { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }

}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .lateral { position: sticky; top: 0; z-index: 20; height: auto; flex-direction: row; align-items: center; gap: 8px; padding: 8px 12px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--borde); }
  .logo b, .nivel-mini, .lateral > .boton, .version, .menu__separador { display: none; }
  .menu { display: flex; gap: 4px; }
  .menu a, .menu button { white-space: nowrap; padding: 8px 10px; }
  .menu a[aria-current]::before { display: none; }
  .barra-sup { position: static; height: 48px; gap: 12px; }
  .barra-sup__dato:nth-child(2) { display: none; }
  .cabeza__acciones .filtro { display: none; }
  .menu svg { display: none; }
  .principal { padding: 20px 16px 120px; }
  .camino { grid-template-columns: repeat(3, 1fr); row-gap: 20px; }
  .camino li::after { display: none; }
  .tabla { font-size: .9rem; }
  .tabla th, .tabla td { padding: 10px 6px; }
  .panel { overflow-x: auto; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Densidad del tablero, más cerca de un panel de gestión */
.misiones p, .alertas p, .movs p { font-size: .92rem; }
.misiones ul { gap: 12px; }
.grafico text { font-size: 15px; }
.dato-chico.sube { color: var(--verde); } .dato-chico.baja { color: var(--rojo); }

/* ---------- Catálogo en tabla ---------- */
.pestanas { display: flex; gap: 4px; }
.pestanas button { padding: 8px 16px; border: 0; border-radius: 8px 8px 0 0; background: none; color: var(--suave); font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; }
.pestanas button[aria-selected="true"] { color: var(--tinta); border-bottom-color: var(--primario); }
.tabla--catalogo td, .tabla--catalogo th { font-size: .92rem; vertical-align: middle; }
.prod-celda { display: flex; align-items: center; gap: 10px; }
.prod-celda__img { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 8px; background: var(--c); color: #00000070; font-weight: 800; }
.stock { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: 999px; font-size: .82rem; font-weight: 700; }
.stock::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.stock--ok { background: #dff5ea; color: #146c4a; } .stock--bajo { background: #fff1c7; color: #8a5a00; } .stock--critico { background: #fbe4df; color: #b3321f; }
.acciones { text-align: right; }
