/* =============================================================
   Directrix · tour-app.css
   Réplica visual de AInventory (React + MUI + AG Grid + Recharts).
   Valores medidos sobre la app real. Todo vive bajo .aiapp para no
   chocar con el sistema de diseño del sitio.
   ============================================================= */

.aiapp {
  --bg: #F1F5F9;
  --fg: #1E293B;
  --mut: #64748B;
  --sub: #94A3B8;
  --line: #E2E8F0;
  --line-2: #F1F5F9;
  --card: #FFFFFF;
  --card-2: #F8FAFC;
  --navy: #1B2A4A;
  --violet: #7C3AED;
  --c-indigo: #6366F1;  --c-amber: #F59E0B;  --c-emerald: #10B981;
  --c-blue: #3B82F6;    --c-violet: #8B5CF6; --c-red: #EF4444;
  --r-card: 36px;
  font-family: 'Inter', 'SF Pro Display', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.43;
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  text-align: left;
}
.aiapp *, .aiapp *::before, .aiapp *::after { box-sizing: border-box; }
.aiapp .mi { width: 1em; height: 1em; fill: currentColor; flex-shrink: 0; display: inline-block; }
.aiapp button { font-family: inherit; }

/* ===================== Lienzo virtual 1280 × 800 ===================== */
.ai-canvas {
  position: absolute; top: 0; left: 0;
  width: 1280px; height: 800px;
  background: var(--bg);
  transform-origin: 0 0;
  overflow: hidden;
}

/* ===================== Riel lateral (MUI Drawer) ===================== */
.ai-rail {
  position: absolute; top: 0; left: 0; bottom: 0; z-index: 30;
  width: 64px;
  background: linear-gradient(#0F172A 0%, #1E293B 100%);
  display: flex; flex-direction: column;
  overflow: hidden;
  transition: width 220ms cubic-bezier(.4,0,.2,1), box-shadow 220ms;
}
.ai-rail:hover { width: 260px; box-shadow: 12px 0 32px -12px rgba(15,23,42,.45); }
.ai-rail .logo {
  height: 65px; display: flex; align-items: center; padding-left: 19px;
  position: relative; flex-shrink: 0;
}
.ai-rail .logo .ic { width: 26px; height: 28px; }
.ai-rail .logo .wm {
  position: absolute; left: 19px; height: 24px; width: auto;
  opacity: 0; transition: opacity 160ms;
}
.ai-rail:hover .logo .ic { opacity: 0; }
.ai-rail:hover .logo .wm { opacity: 1; }
.ai-rail nav { padding: 8px 6px; display: flex; flex-direction: column; gap: 2px; }
.ai-ri {
  height: 33px; border-radius: 24px;
  display: flex; align-items: center; gap: 12px;
  padding: 0 0 0 16px; cursor: pointer;
  color: #64748B; white-space: nowrap;
  transition: background 140ms, color 140ms;
}
.ai-ri:hover { background: rgba(255,255,255,.05); }
.ai-ri .mi { font-size: 20px; }
.ai-ri .lb {
  font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: #CBD5E1; opacity: 0; transition: opacity 160ms;
}
.ai-ri .chev { margin-left: auto; margin-right: 12px; font-size: 16px; opacity: 0; color: #64748B; }
.ai-rail:hover .ai-ri .lb, .ai-rail:hover .ai-ri .chev { opacity: 1; }
.ai-ri.is-on { color: #60A5FA; }
.ai-ri.is-on .lb { color: #fff; }
.ai-rail .subs { display: none; flex-direction: column; gap: 2px; margin: 2px 0 4px; }
.ai-rail:hover .ai-ri.is-on + .subs { display: flex; }
.ai-rs {
  height: 30px; border-radius: 24px; padding-left: 46px;
  display: flex; align-items: center; cursor: pointer;
  font-size: 12.5px; color: #94A3B8; white-space: nowrap; position: relative;
}
.ai-rs:hover { color: #E2E8F0; }
.ai-rs.is-on { background: rgba(96,165,250,.14); color: #fff; font-weight: 600; }
.ai-rs.is-on::before {
  content: ''; position: absolute; left: 32px; top: 50%;
  width: 5px; height: 5px; border-radius: 50%; background: #60A5FA; transform: translateY(-50%);
}
.ai-rail .foot {
  margin-top: auto; padding: 14px 20px; font-size: 10.5px; color: #475569;
  white-space: nowrap; opacity: 0; transition: opacity 160ms;
}
.ai-rail:hover .foot { opacity: 1; }

/* ===================== Barra superior (MUI AppBar) ===================== */
.ai-top {
  position: absolute; top: 0; left: 64px; right: 0; height: 65px; z-index: 20;
  background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px; padding: 0 22px 0 14px;
}
.ai-pin {
  width: 36px; height: 36px; border-radius: 8px; border: 0; background: none;
  color: var(--mut); display: inline-flex; align-items: center; justify-content: center; font-size: 20px;
}
.ai-crumb { display: flex; flex-direction: column; line-height: 1.2; }
.ai-crumb .bc { font-size: 11.2px; font-weight: 500; color: var(--mut); }
.ai-crumb .tt { font-size: 17.6px; font-weight: 700; color: var(--fg); }
.ai-top .sp { flex: 1; }
.ai-tenant {
  height: 37px; border-radius: 24px; padding: 0 12px;
  background: rgba(27,42,74,.06); border: 1px solid rgba(27,42,74,.4);
  display: inline-flex; align-items: center; gap: 9px;
}
.ai-tenant .mi { font-size: 18px; color: var(--navy); }
.ai-tenant .mi.sw { color: var(--sub); }
.ai-tenant .tl { display: flex; flex-direction: column; line-height: 1.15; }
.ai-tenant .tl small { font-size: 9.9px; font-weight: 600; letter-spacing: .5px; text-transform: uppercase; color: var(--mut); }
.ai-tenant .tl b { font-size: 12.5px; font-weight: 700; color: var(--fg); }
.ai-vdiv { width: 1px; height: 28px; background: var(--line); margin: 0 4px; }
.ai-ib {
  width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line); background: #fff;
  color: var(--mut); display: inline-flex; align-items: center; justify-content: center;
  font-size: 19px; position: relative; font-size: 18px;
}
.ai-ib.lang { border-radius: 18px; font-size: 11.5px; font-weight: 700; color: var(--fg); }
.ai-ib .dot { position: absolute; top: 7px; right: 8px; width: 7px; height: 7px; border-radius: 50%; background: #EF4444; border: 1.5px solid #fff; }
.ai-user { display: flex; align-items: center; gap: 10px; margin-left: 8px; }
.ai-user .av {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, #1B2A4A, #3B82F6);
  color: #fff; font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.ai-user .nm { display: flex; flex-direction: column; line-height: 1.2; }
.ai-user .nm b { font-size: 13px; font-weight: 600; color: var(--fg); }
.ai-user .nm small { font-size: 11px; color: var(--mut); }
.ai-user .mi { color: var(--sub); font-size: 18px; }

/* ===================== Contenido principal ===================== */
.ai-main {
  position: absolute; top: 65px; left: 64px; right: 0; bottom: 0;
  overflow-y: auto; overflow-x: hidden;
  padding: 16px 24px 28px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
}
.ai-screen { display: none; }
.ai-screen.is-on { display: block; animation: ai-in 360ms cubic-bezier(.2,.8,.2,1); }
@keyframes ai-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ===================== Piezas comunes ===================== */
.ai-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card);
  position: relative;
}
.ai-pad { padding: 20px 24px; }
.ai-h { font-size: 14px; font-weight: 700; color: var(--fg); display: flex; align-items: center; gap: 8px; }
.ai-h .mi { font-size: 18px; }
.ai-sub { font-size: 11.5px; color: var(--mut); margin-top: 2px; }
.ai-cap {
  font-size: 10.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--mut);
}
.ai-row { display: flex; align-items: center; gap: 8px; }
.ai-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.ai-mt { margin-top: 16px; }

/* Chips (MUI Chip, variante pequeña) */
.ai-chip {
  height: 24px; border-radius: 6px; padding: 0 8px;
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.9px; font-weight: 500; white-space: nowrap;
  border: 1px solid currentColor;
}
.ai-chip .mi { font-size: 13px; }
.ai-chip.sm { height: 20px; font-size: 10.4px; }
.ai-chip.slate  { background: #F1F5F9; color: #64748B; }
.ai-chip.ghost  { background: rgba(148,163,184,.1); color: #64748B; }
.ai-chip.frozen { background: rgba(239,68,68,.12); color: #9F1239; border-color: rgba(239,68,68,.3); }
.ai-chip.violet { background: #EDE9FE; color: #5B21B6; }
.ai-chip.blue   { background: #DBEAFE; color: #1E40AF; }
.ai-chip.green  { background: rgba(16,185,129,.1); color: #047857; border-color: rgba(16,185,129,.35); }
.ai-chip.dark   { background: #F1F5F9; color: #1E293B; }
.ai-chip .dotg { width: 6px; height: 6px; border-radius: 50%; background: #10B981; }

/* Selector tipo pastilla (MUI Select outlined) */
.ai-select {
  height: 34px; border-radius: 24px; border: 1px solid #CBD5E1; background: #fff;
  display: inline-flex; align-items: center; gap: 8px; padding: 0 10px 0 14px;
  font-size: 13px; font-weight: 500; color: var(--fg); white-space: nowrap;
}
.ai-select .mi { font-size: 18px; color: var(--mut); }

/* Botones */
.ai-btn {
  height: 34px; border-radius: 24px; padding: 0 14px;
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap; cursor: pointer;
  border: 1px solid #CBD5E1; background: #fff; color: var(--fg);
}
.ai-btn .mi { font-size: 17px; }
.ai-btn.primary { background: var(--violet); border-color: var(--violet); color: #fff; box-shadow: 0 6px 14px -6px rgba(124,58,237,.6); }
.ai-btn.navy { background: var(--navy); border-color: var(--navy); color: #fff; }
.ai-btn.text { border-color: transparent; background: none; color: var(--mut); }
.ai-btn.white { background: #fff; border-color: #fff; color: var(--navy); }
.ai-btn.outline-w { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.55); color: #fff; }
.ai-circ {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid rgba(255,255,255,.35);
  background: rgba(255,255,255,.08); color: #fff; font-size: 17px;
  display: inline-flex; align-items: center; justify-content: center;
}

/* ===================== Tarjeta KPI ===================== */
.ai-kpis { display: grid; gap: 14px; }
.ai-kpis.c2 { grid-template-columns: 1fr 1fr; }
.ai-kpis.c4 { grid-template-columns: repeat(4, 1fr); }
.ai-kpis.c5 { grid-template-columns: repeat(5, 1fr); }
.ai-kpis.c6 { grid-template-columns: repeat(6, 1fr); }
.ai-kpi {
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-card);
  padding: 18px 20px 16px; position: relative; overflow: hidden; min-height: 128px;
}
.ai-kpi::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, var(--kc), color-mix(in srgb, var(--kc) 35%, #fff));
}
.ai-kpi .hd { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.ai-kpi .lb {
  font-size: 11.2px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--mut); line-height: 1.35;
}
.ai-kpi .ib {
  width: 40px; height: 40px; border-radius: 24px; flex-shrink: 0;
  background: color-mix(in srgb, var(--kc) 9%, #fff); color: var(--kc);
  display: inline-flex; align-items: center; justify-content: center; font-size: 21px;
}
.ai-kpi .v {
  font-size: 22px; font-weight: 800; letter-spacing: -.01em; color: var(--fg);
  margin-top: 6px; font-variant-numeric: tabular-nums; line-height: 1.15;
}
.ai-kpi .v.big { font-size: 30px; }
.ai-kpi .ft { display: flex; align-items: center; gap: 7px; margin-top: 8px; flex-wrap: wrap; }
.ai-kpi .note { font-size: 11px; color: var(--mut); line-height: 1.45; margin-top: 6px; }
.ai-kpi .note b.warn { color: #B45309; }
.ai-kpi .note b.good { color: #059669; }
.ai-delta {
  height: 22px; border-radius: 12px; padding: 0 8px;
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.2px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.ai-delta .mi { font-size: 14px; }
.ai-delta.good { background: rgba(16,185,129,.1); color: #059669; }
.ai-delta.bad  { background: rgba(239,68,68,.1);  color: #EF4444; }
.ai-vs { font-size: 10.5px; font-style: italic; color: var(--sub); }
.ai-kpi[data-c="indigo"]  { --kc: #6366F1; }
.ai-kpi[data-c="amber"]   { --kc: #F59E0B; }
.ai-kpi[data-c="emerald"] { --kc: #10B981; }
.ai-kpi[data-c="blue"]    { --kc: #3B82F6; }
.ai-kpi[data-c="violet"]  { --kc: #8B5CF6; }
.ai-kpi[data-c="red"]     { --kc: #EF4444; }

/* ===================== Gráfico (Recharts) ===================== */
.ai-chart { width: 100%; display: block; overflow: visible; }
.ai-chart text { font-family: 'Inter', sans-serif; }
.ai-legend { display: flex; justify-content: center; gap: 14px; margin-top: 4px; font-size: 11px; color: var(--mut); }
.ai-legend span { display: inline-flex; align-items: center; gap: 5px; }
.ai-legend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.ai-legend .pill {
  border: 1px solid var(--line); border-radius: 12px; padding: 2px 9px; background: #fff;
}
.ai-legend .ln { width: 14px; height: 0; border-top: 2px solid; border-radius: 0; }
.ai-legend .ln.dash { border-top-style: dashed; }

/* ===================== Grilla (AG Grid · Alpine) ===================== */
.ai-gridwrap { position: relative; border-top: 1px solid var(--line); }
.ai-gscroll { overflow-x: auto; overflow-y: hidden; scroll-behavior: smooth; scrollbar-width: thin; }
.ai-g { border-collapse: separate; border-spacing: 0; font-size: 11px; white-space: nowrap; }
.ai-g th {
  height: 39px; padding: 0 12px 0 15px; text-align: left;
  background: #F8FAFC; border-bottom: 1px solid var(--line);
  font-size: 12px; font-weight: 500; color: var(--fg);
  position: relative;
}
.ai-g th .hc { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.ai-g th .mi { font-size: 15px; color: var(--sub); }
.ai-g th + th::before {
  content: ''; position: absolute; left: 0; top: 30%; height: 40%; width: 1px; background: #DDE2EB;
}
.ai-g td {
  height: 36px; padding: 0 12px 0 15px;
  border-bottom: 1px solid #EEF2F6; color: var(--fg);
  font-variant-numeric: tabular-nums;
}
.ai-g td.num, .ai-g th.num { text-align: right; }
.ai-g th.num .hc { justify-content: flex-end; }
.ai-g tbody tr:hover td { filter: brightness(.985); }
.ai-g .cod { color: #3B82F6; font-weight: 600; }
.ai-g .mat { max-width: 250px; overflow: hidden; text-overflow: ellipsis; }
.ai-g tr.tot td { background: #EFF6FF; border-bottom: 2px solid #BFDBFE; color: #1E40AF; font-weight: 700; }
.ai-g tr.tot td.lbl { font-size: 10.5px; letter-spacing: .04em; }
.ai-g tr.tot td.cnt { font-weight: 400; color: var(--mut); }
/* Tipos de columna del forecast */
.ai-g th.hist { background: #F1F5F9; color: #94A3B8; }
.ai-g th.calc { background: #E0F2FE; color: #0C4A6E; font-weight: 700; }
.ai-g td.calc { background: #F0F9FF; color: #0C4A6E; }
.ai-g tr.tot td.calc { background: #E0F2FE; color: #0C4A6E; }
.ai-g th.frz { background: #FFE4E6; color: #9F1239; }
.ai-g td.frz { background: #FFF1F2; color: #9F1239; }
.ai-g tr.tot td.frz { background: #FFE4E6; color: #9F1239; }
.ai-g th.ph-b { background: #EDE9FE; color: #5B21B6; }
.ai-g td.ph-b { background: #F5F3FF; color: #6D28D9; }
.ai-g tr.tot td.ph-b { background: #DDD6FE; color: #5B21B6; }
.ai-g th.ph-c { background: #DBEAFE; color: #1E40AF; }
.ai-g td.ph-c { background: #EFF6FF; color: #1D4ED8; cursor: cell; }
.ai-g tr.tot td.ph-c { background: #BFDBFE; color: #1E40AF; }
.ai-g th .mi { color: currentColor; opacity: .55; }
/* Celda en edición / editada */
.ai-g td.editing {
  background: #fff !important; box-shadow: inset 0 0 0 2px #3B82F6; color: var(--fg) !important;
}
.ai-g td.edited {
  background: #FEF9C3 !important; color: #854D0E !important; font-weight: 700;
  box-shadow: inset 0 0 0 1px #FDE047;
}
.ai-caret { display: inline-block; width: 1.5px; height: 13px; background: #3B82F6; vertical-align: -2px; margin-left: 1px; animation: ai-blink 1s steps(1) infinite; }
@keyframes ai-blink { 50% { opacity: 0; } }

/* Insignias */
.ai-cls {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 26px; height: 18px; padding: 0 6px; border-radius: 6px;
  font-size: 10px; font-weight: 700; letter-spacing: .02em;
}
.ai-cls.AY { background: #FEF3C7; color: #92400E; }
.ai-cls.AZ { background: #FEE2E2; color: #B91C1C; }
.ai-cls.BY { background: #D1FAE5; color: #065F46; }
.ai-cls.BZ { background: #FFEDD5; color: #9A3412; }
.ai-bf {
  display: inline-flex; align-items: center; height: 18px; padding: 0 7px; border-radius: 6px;
  font-size: 10px; font-weight: 700; white-space: nowrap;
}
.ai-bf.sinstock    { background: #FECACA; color: #7F1D1D; }
.ai-bf.agotado     { background: #FEE2E2; color: #B91C1C; }
.ai-bf.reabastecer { background: #FEF3C7; color: #92400E; }
.ai-bf.optimo      { background: #D1FAE5; color: #065F46; }
.ai-bf.demasiado   { background: #DBEAFE; color: #1E40AF; }
.ai-pedir { color: #B91C1C; font-weight: 700; }
.ai-step {
  display: inline-flex; align-items: center; gap: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
}
.ai-step b, .ai-step button { width: 20px; text-align: center; color: var(--mut); font-weight: 600; background: #F8FAFC; }
.ai-step button { border: 0; padding: 0; font: inherit; line-height: inherit; align-self: stretch; }
.ai-step span { padding: 0 8px; font-weight: 700; color: #1D4ED8; background: #EFF6FF; }

/* ===================== Barra de versión / toolbar ===================== */
.ai-vbar { display: flex; align-items: center; gap: 10px; padding: 14px 20px; flex-wrap: wrap; }
.ai-vbar .ph { font-size: 13.5px; font-weight: 700; color: #1E40AF; padding-right: 12px; border-right: 1px solid var(--line); }
.ai-vbar .ph.b { color: #5B21B6; }
.ai-tbar { display: flex; align-items: center; gap: 10px; padding: 10px 20px; border-top: 1px solid var(--line); }
.ai-tbar .ttl { font-size: 14px; font-weight: 700; }
.ai-tbar .sp { flex: 1; }
.ai-tbar .ico { width: 30px; height: 30px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; color: var(--mut); font-size: 18px; }
.ai-tbar .exp { font-size: 12px; font-weight: 600; color: var(--mut); display: inline-flex; align-items: center; gap: 5px; }
.ai-tbar .exp .mi { font-size: 17px; }

/* ===================== Snackbar de autoguardado ===================== */
.ai-snack {
  position: absolute; left: 88px; bottom: 22px; z-index: 40;
  background: #1E293B; color: #fff; border-radius: 10px;
  padding: 10px 16px; display: flex; align-items: center; gap: 10px;
  font-size: 12.5px; box-shadow: 0 12px 28px -8px rgba(15,23,42,.45);
  opacity: 0; transform: translateY(10px); pointer-events: none;
  transition: opacity 260ms, transform 260ms;
}
.ai-snack.show { opacity: 1; transform: none; }
.ai-snack .mi { font-size: 18px; color: #34D399; }
.ai-snack b { font-weight: 700; }

/* ===================== Forecast › Dashboard (Informe Ejecutivo) ===================== */
.ai-hero { border-radius: var(--r-card); overflow: hidden; border: 1px solid var(--line); background: #fff; }
.ai-hero .top {
  background: linear-gradient(118deg, #1B2A4A 0%, #22327A 48%, #4D6DF0 100%);
  color: #fff; padding: 24px 28px 22px; position: relative;
}
.ai-hero h2 { font-size: 21px; font-weight: 700; letter-spacing: -.01em; }
.ai-hero .lead { font-size: 12px; color: rgba(255,255,255,.75); margin-top: 3px; }
.ai-hero .acts { position: absolute; top: 22px; right: 26px; display: flex; gap: 8px; align-items: center; }
.ai-hero .chips { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.ai-hero .hc {
  height: 24px; border-radius: 6px; padding: 0 9px; display: inline-flex; align-items: center;
  font-size: 10.9px; font-weight: 600; background: rgba(255,255,255,.14); color: #fff;
}
.ai-hero .hc.now { background: rgba(52,211,153,.2); color: #A7F3D0; }
.ai-stepper { display: flex; gap: 12px; margin-top: 16px; align-items: center; }
.ai-stp {
  display: inline-flex; align-items: center; gap: 10px; padding: 7px 16px 7px 8px; border-radius: 30px;
  border: 1px solid rgba(255,255,255,.3); color: rgba(255,255,255,.8);
}
.ai-stp .n {
  width: 24px; height: 24px; border-radius: 50%; background: rgba(255,255,255,.18);
  display: inline-flex; align-items: center; justify-content: center; font-size: 11.5px; font-weight: 700;
}
.ai-stp .n .mi { font-size: 16px; }
.ai-stp .t { display: flex; flex-direction: column; line-height: 1.2; }
.ai-stp .t b { font-size: 12px; font-weight: 700; }
.ai-stp .t small { font-size: 10.5px; opacity: .8; }
.ai-stp.done .n { background: #34D399; color: #064E3B; }
.ai-stp.now { background: #fff; color: var(--navy); border-color: #fff; }
.ai-stp.now .n { background: var(--navy); color: #fff; }
.ai-stp-line { width: 26px; height: 2px; background: rgba(255,255,255,.35); border-radius: 2px; }
.ai-hero .body { padding: 16px 28px 18px; }
.ai-hero .body p { font-size: 12.5px; color: #334155; line-height: 1.6; margin-top: 4px; }
.ai-phase-tg { display: flex; align-items: center; gap: 10px; margin: 18px 0 10px; }
.ai-tg {
  height: 26px; border-radius: 8px; padding: 0 10px; font-size: 11.5px; font-weight: 600;
  display: inline-flex; align-items: center; color: var(--fg); background: #fff; border: 1px solid var(--line);
}
.ai-tg.on { background: var(--navy); color: #fff; border-color: var(--navy); }

/* FVA por etapa */
.ai-fva-box { border: 1.5px solid #93C5FD; border-radius: 24px; padding: 14px 16px 12px; margin-top: 12px; }
.ai-fva-box .hd { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.ai-fva-box .hd b { font-size: 13px; }
.ai-fva-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.ai-fva-cell {
  border-radius: 14px; padding: 9px 12px; text-align: center; border: 1px solid;
}
.ai-fva-cell.bad  { background: #FEF2F2; border-color: #FECACA; color: #B91C1C; }
.ai-fva-cell.good { background: #ECFDF5; border-color: #A7F3D0; color: #047857; }
.ai-fva-cell small { display: block; font-size: 9.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; opacity: .8; }
.ai-fva-cell b { display: block; font-size: 20px; font-weight: 800; margin: 2px 0; font-variant-numeric: tabular-nums; }
.ai-fva-cell span { font-size: 10px; font-weight: 600; }
.ai-fva-box .lect { font-size: 11.5px; color: #475569; margin-top: 10px; }
.ai-link { font-size: 12px; font-weight: 700; color: var(--fg); display: inline-flex; align-items: center; gap: 4px; }
.ai-link .mi { font-size: 16px; }

/* Matriz AB–YZ */
.ai-matrix { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.ai-q { border-radius: 20px; border: 1.5px solid; padding: 12px 14px; }
.ai-q .t { display: flex; justify-content: space-between; align-items: baseline; }
.ai-q .t b { font-size: 14px; font-weight: 800; }
.ai-q .t span { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.ai-q .d { font-size: 11px; font-weight: 700; color: #1E293B; margin-top: 4px; }
.ai-q .a { font-size: 10.5px; color: var(--mut); margin-top: 2px; line-height: 1.4; }
.ai-q.AY { background: #F0FDF4; border-color: #86EFAC; color: #15803D; }
.ai-q.AZ { background: #FFF1F2; border-color: #FDA4AF; color: #BE123C; }
.ai-q.BY { background: #EEF2FF; border-color: #A5B4FC; color: #4338CA; }
.ai-q.BZ { background: #F8FAFC; border-color: #CBD5E1; color: #475569; }
.ai-note { font-size: 10.5px; font-style: italic; color: var(--mut); margin-top: 10px; line-height: 1.5; }

/* Listas (Top SKUs, intervención, plan) */
.ai-rank { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.ai-rk {
  display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; align-items: center;
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 14px; background: #fff;
}
.ai-rk .n { font-size: 12px; font-weight: 800; color: #DC2626; text-align: center; }
.ai-rk .l1 { display: flex; align-items: center; gap: 7px; font-size: 11.5px; }
.ai-rk .l1 .cd { color: #3B82F6; font-weight: 700; }
.ai-rk .l1 .sg { color: var(--mut); font-size: 10.5px; }
.ai-rk .l2 { font-size: 10.5px; color: #475569; margin-top: 1px; }
.ai-rk .bar { height: 3px; border-radius: 2px; background: linear-gradient(90deg, #F59E0B, #EF4444); margin-top: 5px; }
.ai-rk .r { text-align: right; }
.ai-rk .r b { font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; }
.ai-rk .r small { display: block; font-size: 10px; color: var(--mut); }
.ai-plan { display: flex; flex-direction: column; gap: 7px; margin-top: 12px; }
.ai-pl {
  display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: start;
  background: #F8FAFC; border-radius: 14px; padding: 9px 12px; font-size: 11.5px; color: #334155; line-height: 1.5;
}
.ai-pl .n {
  width: 20px; height: 20px; border-radius: 50%; background: #DBEAFE; color: #1E40AF;
  font-size: 10.5px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center;
}
.ai-ask {
  margin-top: 10px; border: 1px dashed #A5B4FC; border-radius: 14px; padding: 9px 12px;
  font-size: 11px; color: #4338CA; background: #F5F7FF; display: flex; gap: 8px; align-items: center;
}
.ai-ask .mi { font-size: 16px; }

/* ===================== Inventario ===================== */
.ai-ptitle { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 14px; }
.ai-ptitle h2 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.ai-ptitle .s { font-size: 12.5px; color: var(--mut); margin-top: 2px; }
.ai-star { height: 32px; border-radius: 24px; border: 1px solid #CBD5E1; background: #fff; padding: 0 12px; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; }
.ai-star .mi { color: #F59E0B; font-size: 16px; }
.ai-info {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 22px;
  background: #EEF4FF; border: 1px solid #C7D7FE; font-size: 12.5px; color: #334155; margin-bottom: 14px;
}
.ai-info > .mi { font-size: 19px; color: #3B82F6; }
.ai-info .ai-btn { margin-left: auto; height: 30px; }
.ai-sec { font-size: 13px; font-weight: 700; margin: 18px 0 10px; display: flex; align-items: baseline; gap: 6px; }
.ai-sec small { font-size: 11.5px; font-weight: 500; color: var(--mut); }
.ai-buffers { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.ai-bfc { border-radius: 24px; border: 1px solid; padding: 12px 16px; min-height: 72px; }
.ai-bfc .t { font-size: 12px; font-weight: 700; }
.ai-bfc .v { display: flex; align-items: baseline; justify-content: space-between; margin-top: 4px; }
.ai-bfc .v b { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.ai-bfc .v span { font-size: 12px; font-weight: 600; }
.ai-bfc.sinstock    { background: #FECACA; border-color: rgba(127,29,29,.4); color: #7F1D1D; }
.ai-bfc.agotado     { background: #FEE2E2; border-color: rgba(239,68,68,.4); color: #B91C1C; }
.ai-bfc.reabastecer { background: #FEF3C7; border-color: rgba(245,158,11,.4); color: #92400E; }
.ai-bfc.optimo      { background: #D1FAE5; border-color: rgba(16,185,129,.4); color: #065F46; }
.ai-bfc.demasiado   { background: #DBEAFE; border-color: rgba(59,130,246,.4); color: #1E40AF; }
.ai-days { font-size: 11.5px; color: #475569; margin-top: 10px; }
.ai-days b { color: var(--fg); }
.ai-iv { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.ai-iv div { border: 1px solid #FDE68A; background: #FFFBEB; border-radius: 14px; padding: 8px 12px; }
.ai-iv b { font-size: 11.5px; color: #92400E; }
.ai-iv p { font-size: 11px; color: #475569; margin-top: 2px; }
.ai-cnt { display: inline-flex; min-width: 22px; height: 20px; border-radius: 10px; background: #FEF3C7; color: #92400E; font-size: 11px; font-weight: 800; align-items: center; justify-content: center; padding: 0 6px; }
.ai-foot { font-size: 10.5px; color: var(--sub); text-align: center; margin-top: 16px; }

/* Optimizador */
.ai-optitle { display: flex; align-items: center; gap: 12px; margin: 4px 0 14px; }
.ai-optitle .bx { width: 40px; height: 40px; border-radius: 12px; background: #EDE9FE; color: var(--violet); display: inline-flex; align-items: center; justify-content: center; font-size: 22px; }
.ai-optitle h2 { font-size: 20px; font-weight: 700; }
.ai-optitle p { font-size: 12px; color: var(--mut); }
.ai-params { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.ai-param small { display: block; font-size: 9.8px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--mut); margin-bottom: 5px; }
.ai-param .ai-select { width: 100%; font-size: 11.5px; padding-left: 10px; }
.ai-param .ai-select .mi:first-child { color: var(--violet); font-size: 16px; }
.ai-param .ai-select .x { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.ai-param .ai-select .x small { display: inline; font-size: 10.5px; color: var(--mut); text-transform: none; letter-spacing: 0; font-weight: 500; margin: 0; }
.ai-loaded { font-size: 11.5px; color: #475569; margin-top: 12px; display: flex; align-items: center; gap: 8px; }
.ai-loaded b { color: var(--fg); }
.ai-bfchips { display: flex; gap: 6px; flex-wrap: wrap; }
.ai-bfchips span { height: 24px; border-radius: 12px; padding: 0 10px; display: inline-flex; align-items: center; font-size: 11px; font-weight: 700; }
.ai-g tr.click { cursor: pointer; }
.ai-g tr.sel td { background: #F5F3FF !important; }

/* ===================== Diálogo de detalle de SKU ===================== */
.ai-dlg-bg {
  position: absolute; inset: 0; z-index: 50; background: rgba(15,23,42,.5);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 260ms;
}
.ai-dlg-bg.open { opacity: 1; pointer-events: auto; }
.ai-dlg {
  width: 1100px; max-height: 760px; background: #fff; border-radius: 28px;
  box-shadow: 0 24px 64px rgba(0,0,0,.28);
  display: flex; flex-direction: column; overflow: hidden;
  transform: translateY(14px) scale(.985); transition: transform 300ms cubic-bezier(.2,.8,.2,1);
}
.ai-dlg-bg.open .ai-dlg { transform: none; }
.ai-dlg .hd { padding: 20px 26px 0; display: flex; justify-content: space-between; gap: 16px; }
.ai-dlg .hd h3 { font-size: 19px; font-weight: 700; }
.ai-dlg .hd p { font-size: 12px; color: var(--mut); margin-top: 2px; }
.ai-dlg .hd .r { display: flex; align-items: center; gap: 8px; }
.aiapp .pol-chip { height: 26px; border-radius: 8px; padding: 0 10px; background: #DCFCE7; color: #166534; font-size: 11.5px; font-weight: 700; display: inline-flex; align-items: center; }
.ai-dlg .sofia-btn { background: linear-gradient(135deg, #1B2A4A, #3B82F6); color: #fff; border: 0; }
.ai-tabs { display: flex; gap: 26px; padding: 14px 26px 0; border-bottom: 1px solid var(--line); }
.ai-tabs span { font-size: 12.5px; font-weight: 600; color: var(--mut); padding-bottom: 10px; }
.ai-tabs span.on { color: var(--violet); box-shadow: inset 0 -2px 0 var(--violet); }
.ai-dlg .bd { padding: 16px 26px 20px; overflow-y: auto; scroll-behavior: smooth; scrollbar-width: thin; }
.ai-dlg .ft { padding: 12px 26px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.ai-sbox { border: 1px solid var(--line); border-radius: 22px; padding: 16px 18px; }
.ai-sbox + .ai-sbox, .ai-sbox + .ai-kpis, .ai-kpis + .ai-win, .ai-win + .ai-grid-2, .ai-grid-2 + .ai-sbox { margin-top: 14px; }
.ai-sbox .ai-h { font-size: 13.5px; }

/* Parámetros What-If */
.ai-whatif .ai-h { justify-content: space-between; }
.ai-whatif .ai-h .l { display: flex; align-items: center; gap: 8px; }
.ai-whatif .ai-h .l em { font-style: normal; font-weight: 500; color: var(--sub); font-size: 12px; }
.ai-inputs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 16px; margin-top: 14px; }
.ai-in { position: relative; border: 1px solid #CBD5E1; border-radius: 24px; height: 42px; display: flex; align-items: center; padding: 0 14px; background: #fff; transition: border-color 160ms, box-shadow 160ms; }
.ai-in label { position: absolute; top: -8px; left: 12px; background: #fff; padding: 0 5px; font-size: 10.5px; color: var(--mut); white-space: nowrap; }
.ai-in .pre, .ai-in .suf { font-size: 12.5px; color: var(--sub); }
.ai-in input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: none; text-align: right;
  font: inherit; font-size: 13.5px; color: var(--fg); font-variant-numeric: tabular-nums; padding: 0 6px;
}
.ai-in:focus-within { border-color: var(--violet); box-shadow: 0 0 0 3px rgba(124,58,237,.14); }
.ai-in.ro { background: #F8FAFC; }

/* Política ganadora */
.ai-win {
  display: flex; align-items: center; gap: 22px; padding: 11px 16px; border-radius: 16px;
  background: #F8FAFC; border: 1px solid var(--line); font-size: 12px; color: #475569; flex-wrap: wrap;
}
.ai-win .w { display: inline-flex; align-items: center; gap: 7px; font-weight: 700; color: var(--fg); }
.ai-win .w .mi { color: #F59E0B; font-size: 18px; }
.ai-win b { color: var(--fg); font-weight: 800; font-variant-numeric: tabular-nums; }
.ai-win .lk { margin-left: auto; font-weight: 700; color: var(--violet); font-size: 11.5px; }
.ai-polt { width: 100%; border-collapse: collapse; font-size: 11.5px; margin-top: 10px; }
.ai-polt th, .ai-polt td { padding: 8px 10px; border-bottom: 1px solid var(--line-2); text-align: right; font-variant-numeric: tabular-nums; }
.ai-polt th:first-child, .ai-polt td:first-child { text-align: left; color: var(--mut); }
.ai-polt th { font-size: 11px; font-weight: 700; color: var(--fg); background: #F8FAFC; }
.ai-polt .win { background: #F5F3FF; color: #5B21B6; font-weight: 700; }
.ai-polt th.win small { display: block; font-size: 9px; letter-spacing: .06em; color: #7C3AED; }

/* ===================== SofIA (panel flotante) ===================== */
.ai-fab {
  position: absolute; right: 24px; bottom: 24px; z-index: 45;
  width: 54px; height: 54px; border-radius: 50%; border: 0; cursor: pointer;
  background: linear-gradient(135deg, #1B2A4A 0%, #3B82F6 100%);
  color: #fff; font-size: 25px; display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 0 rgba(59,130,246,.35), 0 10px 24px -8px rgba(27,42,74,.6);
  animation: ai-ring 2.6s ease-out infinite;
}
@keyframes ai-ring { 0% { box-shadow: 0 0 0 0 rgba(59,130,246,.35), 0 10px 24px -8px rgba(27,42,74,.6); } 70%,100% { box-shadow: 0 0 0 14px rgba(59,130,246,0), 0 10px 24px -8px rgba(27,42,74,.6); } }
.ai-sofia {
  position: absolute; right: 39px; bottom: 90px; z-index: 46;
  width: 420px; height: 620px; max-height: calc(100% - 110px);
  background: #fff; border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0,0,0,.18), 0 8px 24px rgba(27,42,74,.14);
  display: flex; flex-direction: column; overflow: hidden;
  opacity: 0; transform: translateY(12px) scale(.98); transform-origin: bottom right; pointer-events: none;
  transition: opacity 240ms, transform 280ms cubic-bezier(.2,.8,.2,1);
}
.ai-sofia.over { z-index: 60; }
.aiapp [data-go], .aiapp [data-dlg] { cursor: pointer; }
.ai-sofia.open { opacity: 1; transform: none; pointer-events: auto; }
.ai-sofia .hd {
  height: 59px; padding: 10px 12px 10px 16px; flex-shrink: 0;
  background: linear-gradient(135deg, #0F172A 0%, #1B2A4A 60%, #2D3A6A 100%);
  color: #fff; display: flex; align-items: center; gap: 10px;
}
.ai-sofia .av {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, #1B2A4A 0%, #3B82F6 100%);
  border: 1.5px solid rgba(255,255,255,.35);
  display: inline-flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 800;
}
.ai-sofia .ttl { flex: 1; min-width: 0; line-height: 1.2; }
.ai-sofia .ttl b { font-size: 14px; display: inline-flex; align-items: center; gap: 6px; }
.ai-sofia .ttl b i { font-style: normal; font-size: 9.5px; font-weight: 700; padding: 1px 6px; border-radius: 6px; background: rgba(96,165,250,.3); }
.ai-sofia .ttl small { display: block; font-size: 9.9px; color: rgba(255,255,255,.7); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-sofia .hi { display: flex; gap: 1px; }
.ai-sofia .hi span { width: 28px; height: 28px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; font-size: 16px; color: rgba(255,255,255,.75); }
.ai-sofia .bd { flex: 1; overflow-y: auto; padding: 16px; scrollbar-width: thin; }
.ai-sofia .wel { text-align: center; padding: 10px 6px 4px; }
.ai-sofia .wel .big {
  width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 10px;
  background: linear-gradient(135deg, #1B2A4A 0%, #3B82F6 100%); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 26px;
}
.ai-sofia .wel b { font-size: 15.2px; font-weight: 700; }
.ai-sofia .wel p { font-size: 11.5px; color: var(--mut); line-height: 1.55; margin-top: 4px; }
.ai-sofia .chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 12px; }
.ai-sofia .chips span {
  height: 26px; border-radius: 6px; padding: 0 9px; display: inline-flex; align-items: center;
  background: rgba(59,130,246,.07); border: 1px solid rgba(59,130,246,.2);
  color: #1B2A4A; font-size: 11.5px; font-weight: 600; cursor: pointer;
}
.ai-msg-u {
  margin: 14px 0 10px auto; max-width: 82%; width: fit-content;
  background: linear-gradient(135deg, #1B2A4A, #2D4A8A); color: #fff;
  border-radius: 14px 14px 4px 14px; padding: 9px 12px; font-size: 12px; line-height: 1.5;
}
.ai-msg-b { font-size: 12px; color: #334155; line-height: 1.55; }
.ai-msg-b .blk { margin-bottom: 9px; opacity: 0; transform: translateY(4px); transition: opacity 300ms, transform 300ms; }
.ai-msg-b .blk.in { opacity: 1; transform: none; }
.ai-msg-b h5 { font-size: 10.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: #1B2A4A; margin-bottom: 2px; }
.ai-msg-b strong { color: #1E40AF; }
.ai-msg-b .src { font-size: 10.5px; color: var(--sub); border-top: 1px solid var(--line); padding-top: 7px; }
.ai-typing { display: inline-flex; gap: 4px; padding: 6px 0; }
.ai-typing i { width: 6px; height: 6px; border-radius: 50%; background: #94A3B8; animation: ai-dot 1.1s infinite ease-in-out; }
.ai-typing i:nth-child(2) { animation-delay: .15s; } .ai-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes ai-dot { 0%,80%,100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.ai-sofia .ip { padding: 10px 12px 12px; border-top: 1px solid var(--line); display: flex; gap: 8px; }
.ai-sofia .ip .f {
  flex: 1; height: 38px; border-radius: 10px; background: #F8FAFC; border: 1px solid var(--line);
  display: flex; align-items: center; padding: 0 12px; font-size: 12.5px; color: var(--sub); overflow: hidden; white-space: nowrap;
}
.ai-sofia .ip .f.typing { color: var(--fg); }
.ai-sofia .ip .s {
  width: 38px; height: 38px; border-radius: 10px; background: #F1F5F9; color: var(--mut);
  display: inline-flex; align-items: center; justify-content: center; font-size: 17px;
}

@media (prefers-reduced-motion: reduce) {
  .aiapp *, .aiapp *::before { animation: none !important; transition-duration: 1ms !important; }
}

/* ===================== Versión resumida del tour ===================== */
.ai-kpis.c3 { grid-template-columns: repeat(3, 1fr); }
.ai-g.cmp th { height: auto; min-height: 39px; padding: 9px 10px 9px 12px; white-space: normal; line-height: 1.25; vertical-align: bottom; }
.ai-g.cmp td { padding: 0 10px 0 12px; }
.ai-g.cmp .mat { max-width: 210px; }
.ai-param-i { display: inline-flex; flex-direction: column; gap: 2px; }
.ai-param-i small { font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--mut); }
.ai-param-i b { font-size: 13px; font-weight: 700; color: var(--fg); }
.ai-step b, .ai-step button { user-select: none; }
.ai-step.mod span { background: #FEF9C3; color: #854D0E; }
.aiapp [data-tab], .aiapp .ai-step button, .aiapp tr.click td { cursor: pointer; }
.aiapp .ai-step button:hover { background: #EEF2FF; color: #1D4ED8; }
/* Plan de pedidos del detalle de SKU */
.ai-plan-t { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 12.5px; }
.ai-plan-t th { text-align: left; font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--mut); padding: 0 12px 8px; border-bottom: 1px solid var(--line); }
.ai-plan-t td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); font-variant-numeric: tabular-nums; vertical-align: middle; }
.ai-plan-t .num { text-align: right; }
.ai-plan-t td b { display: block; font-size: 12.5px; color: var(--fg); }
.ai-plan-t td small { display: block; font-size: 11px; color: var(--mut); margin-top: 1px; }
.ai-plan-t tr.hoy td { background: #F5F3FF; }
.ai-plan-t .bar { display: inline-block; width: 110px; height: 7px; border-radius: 4px; background: #EDE9FE; margin-right: 12px; vertical-align: middle; overflow: hidden; }
.ai-plan-t .bar i { display: block; height: 100%; background: #7C3AED; border-radius: 4px; }
