/* =====================================================================
   Plataforma MOBLEXUS — piezas comunes (selector de módulos, usuario,
   ventanas, pantalla de ingreso). Mismo estilo del optimizador de cortes.
   Los colores de marca (--mx-primario, --mx-acento) los pone plataforma.js
   según Configuración › Apariencia.
   ===================================================================== */
* { box-sizing: border-box; }
:root {
  --mx-primario: #023C5B; --mx-acento: #FED700; --mx-fondo-inicio: #023C5B;
  --mx-pri-bg: #e3edf3; --mx-pri-t: #035480; --mx-pri-h: #00638B; --mx-on-pri: #fff;
  --mx-bg: #f8f9fa; --mx-surface: #fff; --mx-surface2: #f1f3f4; --mx-surface3: #e8eaed;
  --mx-text: #202124; --mx-text2: #5f6368; --mx-text3: #80868b; --mx-border: #dadce0;
  --mx-danger: #d93025; --mx-danger-bg: #fce8e6; --mx-ok: #188038; --mx-ok-bg: #e6f4ea;
  --mx-shadow: 0 1px 2px rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15);
  --mx-shadow2: 0 1px 3px rgba(60,64,67,.3), 0 4px 8px 3px rgba(60,64,67,.15);
  --mx-r: 8px;
}
html[data-theme="dark"], html.oscuro {
  --mx-bg: #1b1c1f; --mx-surface: #26272b; --mx-surface2: #303136; --mx-surface3: #3c4043;
  --mx-text: #e8eaed; --mx-text2: #bdc1c6; --mx-text3: #9aa0a6; --mx-border: #3c4043;
  --mx-danger: #f28b82; --mx-danger-bg: rgba(242,139,130,.16); --mx-ok: #81c995; --mx-ok-bg: rgba(129,201,149,.14);
  --mx-shadow: 0 1px 2px rgba(0,0,0,.5), 0 1px 3px 1px rgba(0,0,0,.3);
  --mx-shadow2: 0 2px 6px rgba(0,0,0,.5), 0 6px 12px 4px rgba(0,0,0,.3);
}

/* ---------- Selector de módulos (tres botones) ---------- */
.mx-mods { padding: 12px 16px 4px 16px; }
.mx-mods-row { display: flex; gap: 8px; }
.mx-mod {
  flex: 1; height: 44px; border-radius: 10px; border: 1px solid var(--mx-border); background: var(--mx-surface);
  color: var(--mx-text2); display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0;
  text-decoration: none; transition: background .15s, border-color .15s, color .15s;
}
.mx-mod svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mx-mod:hover { background: var(--mx-surface2); color: var(--mx-text); }
.mx-mod.on { background: var(--mx-acento); border-color: var(--mx-acento); color: #1f2a33; }
.mx-mod.off { opacity: .35; pointer-events: none; }
.mx-mod { position: relative; }
.mx-badge { position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: #d93025; color: #fff;
  font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; border: 2px solid var(--mx-surface); line-height: 1; }
.mx-badge[hidden] { display: none; }
.mx-mod-name { font-size: 11px; font-weight: 500; letter-spacing: .6px; text-transform: uppercase; color: var(--mx-text3); margin: 8px 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mx-sep { height: 1px; background: var(--mx-border); margin: 10px 0 4px 16px; }

/* ---------- Usuario (al pie del menú) ---------- */
.mx-user-wrap { position: relative; margin-top: 8px; border-top: 1px solid var(--mx-border); padding: 8px 0 0; }
.mx-user {
  display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: none; cursor: pointer;
  padding: 8px 16px 8px 18px; border-radius: 0 22px 22px 0; text-align: left; color: var(--mx-text);
}
.mx-user:hover { background: var(--mx-surface2); }
.mx-av { width: 32px; height: 32px; border-radius: 50%; background: var(--mx-primario); color: var(--mx-on-pri); flex: none;
  display: flex; align-items: center; justify-content: center; font-weight: 500; font-size: 13px; }
.mx-user b { display: block; font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mx-user small { display: block; font-size: 12px; color: var(--mx-text3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mx-user .mx-tx { min-width: 0; flex: 1; }
.mx-menu {
  position: fixed; z-index: 400; min-width: 240px; background: var(--mx-surface); color: var(--mx-text); border-radius: var(--mx-r);
  box-shadow: var(--mx-shadow2); padding: 6px 0; border: 1px solid var(--mx-border);
}
.mx-menu .mx-mh { padding: 10px 16px 8px; border-bottom: 1px solid var(--mx-border); margin-bottom: 4px; }
.mx-menu .mx-mh b { display: block; font-weight: 500; }
.mx-menu .mx-mh small { color: var(--mx-text3); font-size: 12px; }
.mx-menu button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 16px; border: 0; background: none; cursor: pointer; text-align: left; color: var(--mx-text); font-size: 14px; }
.mx-menu button:hover { background: var(--mx-surface2); }
.mx-menu button svg { width: 18px; height: 18px; fill: none; stroke: var(--mx-text2); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.mx-menu hr { border: 0; border-top: 1px solid var(--mx-border); margin: 4px 0; }

/* ---------- Ventanas ---------- */
.mx-ov { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 500; display: flex; align-items: center; justify-content: center; padding: 16px; }
.mx-dlg { background: var(--mx-surface); color: var(--mx-text); border-radius: 12px; box-shadow: var(--mx-shadow2); width: 100%; max-width: 440px; max-height: calc(100vh - 32px); overflow: auto; }
.mx-dlg h2 { margin: 0; padding: 20px 24px 4px; font-size: 20px; font-weight: 400; }
.mx-dlg .mx-db { padding: 12px 24px 8px; }
.mx-dlg .mx-df { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 24px 20px; }
.mx-f { display: block; margin: 0 0 14px; }
.mx-f > span { display: block; font-size: 12px; color: var(--mx-text2); margin-bottom: 5px; font-weight: 500; }
.mx-f input, .mx-f select, .mx-f textarea {
  width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--mx-border); border-radius: var(--mx-r);
  background: var(--mx-surface); color: var(--mx-text); font: inherit; font-size: 15px; outline: none;
}
.mx-f textarea { height: auto; padding: 10px 12px; }
.mx-f input:focus, .mx-f select:focus { border-color: var(--mx-primario); box-shadow: 0 0 0 1px var(--mx-primario); }
.mx-f .mx-hint { display: block; font-size: 12px; color: var(--mx-text3); margin-top: 4px; }
.mx-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 18px; border-radius: 19px;
  border: 1px solid var(--mx-border); background: var(--mx-surface); color: var(--mx-pri-t); font: inherit; font-weight: 500; cursor: pointer;
}
.mx-btn:hover { background: var(--mx-pri-bg); }
.mx-btn.pri { background: var(--mx-primario); border-color: var(--mx-primario); color: var(--mx-on-pri); }
.mx-btn.pri:hover { filter: brightness(1.12); }
.mx-btn:disabled { opacity: .55; cursor: default; }
.mx-err { color: var(--mx-danger); font-size: 13px; min-height: 18px; margin: 4px 0; }
.mx-ok { color: var(--mx-ok); font-size: 13px; }
.mx-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #323232; color: #fff; padding: 12px 20px; border-radius: 6px; z-index: 600; box-shadow: var(--mx-shadow2); font-size: 14px; max-width: calc(100vw - 32px); }
.mx-toast.err { background: #b3261e; }

/* ---------- Barras de desplazamiento finas y discretas (toda la plataforma) ---------- */
* { scrollbar-width: thin; scrollbar-color: rgba(128,134,139,.38) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background-color: rgba(128,134,139,.32); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: rgba(128,134,139,.6); }
::-webkit-scrollbar-corner { background: transparent; }
/* En los menús laterales la barra solo aparece al pasar el mouse */
.subnav, .sidebar, .mxside { scrollbar-color: transparent transparent; }
.subnav:hover, .sidebar:hover, .mxside:hover { scrollbar-color: rgba(128,134,139,.38) transparent; }
.subnav::-webkit-scrollbar-thumb, .sidebar::-webkit-scrollbar-thumb, .mxside::-webkit-scrollbar-thumb { background-color: transparent; }
.subnav:hover::-webkit-scrollbar-thumb, .sidebar:hover::-webkit-scrollbar-thumb, .mxside:hover::-webkit-scrollbar-thumb { background-color: rgba(128,134,139,.38); }

/* =====================================================================
   BARRA SUPERIOR Y MENÚ LATERAL COMUNES (estilo del optimizador de cortes)
   ===================================================================== */
.mx-brand { display: flex; align-items: center; color: var(--mx-primario); text-decoration: none; flex: none; padding: 0 4px; }
html[data-theme="dark"] .mx-brand, html.oscuro .mx-brand { color: #e8eaed; }
.mx-brand .mx-logo-full { display: flex; align-items: center; }
.mx-brand .mx-logo-full svg { height: 22px; width: auto; display: block; }
.mx-brand .mx-logo-full img { max-height: 40px; max-width: 200px; object-fit: contain; display: block; }
.mx-brand .mx-logo-mark { display: none; align-items: center; }
.mx-brand .mx-logo-mark svg, .mx-brand .mx-logo-mark img { height: 30px; width: 30px; object-fit: contain; display: block; }
.mx-brand-mod { font-size: 15px; color: var(--mx-text2); white-space: nowrap; padding-left: 12px; margin-left: 8px; border-left: 1px solid var(--mx-border); }
.mx-ib { width: 40px; height: 40px; border-radius: 50%; border: 0; background: none; color: var(--mx-text2); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: none; }
.mx-ib:hover { color: var(--mx-text); background: rgba(127,127,127,.14); background: color-mix(in srgb, currentColor 13%, transparent); }
.mx-ib svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mx-avbtn { border: 0; background: none; padding: 0 0 0 4px; cursor: pointer; flex: none; display: inline-flex; }
.mx-avbtn .mx-av { width: 34px; height: 34px; }
@media (max-width: 900px) {
  .mx-brand .mx-logo-full { display: none; }
  .mx-brand .mx-logo-mark { display: flex; }
  .mx-brand-mod { display: none; }
}

/* Menú lateral: secciones y opciones iguales en los tres módulos */
.mx-nav { margin-top: 4px; }
.mx-nav-sec { font-size: 11px; font-weight: 500; letter-spacing: .8px; text-transform: uppercase; color: var(--mx-text3); padding: 16px 24px 6px; white-space: nowrap; }
.mx-nav-item { display: flex; align-items: center; gap: 18px; height: 44px; padding: 0 24px; border-radius: 0 22px 22px 0; color: var(--mx-text2);
  font-weight: 500; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap; user-select: none; border: 0; background: none; width: 100%; text-align: left; font-family: inherit; }
.mx-nav-item svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mx-nav-item:hover { background: var(--mx-surface2); color: var(--mx-text); }
.mx-nav-item.on { background: var(--mx-pri-bg); color: var(--mx-pri-t); box-shadow: inset 4px 0 0 var(--mx-acento); }
.mx-nav-item span { overflow: hidden; text-overflow: ellipsis; }

/* =====================================================================
   BARRA SUPERIOR ÚNICA (#mxBarra) — idéntica en todos los módulos
   ===================================================================== */
.mx-top { position: fixed; inset: 0 0 auto 0; height: 64px; z-index: 90; background: var(--mx-surface); color: var(--mx-text);
  display: flex; align-items: center; gap: 8px; padding: 0 12px 0 8px; box-shadow: inset 0 -3px 0 var(--mx-acento);
  font-family: var(--mx-familia, Montserrat, Arial, sans-serif); font-size: 14px; }
.mx-top-l { display: flex; align-items: center; flex: none; min-width: 0; }
.mx-slot-menu { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; flex: none; }
.mx-slot-menu > * { width: 40px !important; height: 40px !important; border-radius: 50% !important; border: 0 !important; background: none !important;
  color: var(--mx-text2) !important; display: inline-flex !important; align-items: center; justify-content: center; cursor: pointer; padding: 0 !important; margin: 0 !important; }
.mx-slot-menu > *:hover { background: var(--mx-surface2) !important; color: var(--mx-text) !important; }
.mx-slot-marca { display: flex; align-items: center; margin-left: 8px; min-width: 0; }
.mx-top-c { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding-left: 16px; }
.mx-top-r { display: flex; align-items: center; gap: 2px; flex: none; }
.mx-slot-extra { display: flex; align-items: center; gap: 2px; }
.mx-slot-extra:empty { display: none; }
.mx-top .mx-ib { width: 40px; height: 40px; }
.mx-top .mx-ib[hidden] { display: none; }
.mx-aprende.on { background: var(--mx-pri-bg); color: var(--mx-pri-t); }
.mx-ia { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; margin-right: 4px; border-radius: 15px; font-size: 12px; font-weight: 500;
  background: var(--mx-surface2); color: var(--mx-text2); border: 1px solid var(--mx-border); white-space: nowrap; cursor: default; }
.mx-ia[hidden] { display: none; }
.mx-ia i { width: 8px; height: 8px; border-radius: 50%; background: #9aa0a6; }
.mx-ia.on i { background: #1e8e3e; box-shadow: 0 0 0 3px rgba(30,142,62,.18); }
.mx-slot-av { display: flex; align-items: center; margin-left: 4px; }
@media (max-width: 900px) {
  .mx-top { padding: 0 6px 0 4px; gap: 4px; }
  .mx-top-c { padding-left: 4px; gap: 6px; }
  .mx-ia { padding: 0 8px; margin-right: 0; }
  .mx-ia span { display: none; }
}
@media (max-width: 480px) {
  .mx-top [data-mx-config] { display: none; }
  .mx-top .mx-ib { width: 36px; height: 36px; }
  .mx-ia { height: 26px; padding: 0 7px; }
}

/* Burbuja del modo aprendizaje */
.mx-tip { position: fixed; z-index: 100000; max-width: 290px; background: #202124; color: #fff; border-radius: 10px; padding: 10px 13px; font-size: 13px; line-height: 1.45;
  box-shadow: 0 10px 28px rgba(0,0,0,.28); pointer-events: none; opacity: 0; transform: translateY(4px); transition: opacity .15s, transform .15s; font-family: var(--mx-familia, Montserrat, Arial, sans-serif); }
.mx-tip.on { opacity: 1; transform: none; }
.mx-tip b { display: block; color: var(--mx-acento); margin-bottom: 3px; font-size: 13.5px; font-weight: 500; }
.mx-tip::before { content: ""; position: absolute; left: var(--ax, 20px); width: 12px; height: 12px; background: #202124; transform: translateX(-50%) rotate(45deg); }
.mx-tip.abajo::before { top: -5px; }
.mx-tip.arriba::before { bottom: -5px; }

/* El espacio de la barra de desplazamiento siempre reservado: la barra superior queda en el mismo sitio en todas las pantallas */
html { scrollbar-gutter: stable; }


/* Herramientas del módulo en la barra: se acomodan sin montarse sobre los botones de la derecha */
.mx-top-c { overflow: hidden; }
.mx-top-c > * { flex-shrink: 1; min-width: 0; }
.mx-top-c > .seg, .mx-top-c > #unitSeg { flex-shrink: 0; }
@media (max-width: 1180px) { .mx-brand-mod { display: none; } }

/* ---------- Tres botones de módulo: juntos, a todo el ancho del menú, con ícono y nombre ---------- */
.mx-mods { padding: 12px 0 2px 12px; }
.mx-mods-row { display: flex; gap: 0; border: 1px solid var(--mx-border); border-radius: 10px; overflow: hidden; background: var(--mx-surface); }
.mx-mod { flex: 1 1 auto; min-width: 0; height: 40px; border: 0 !important; border-radius: 0 !important; gap: 5px; padding: 0 6px; font-size: 11.5px; font-weight: 500;
  font-family: var(--mx-familia, Montserrat, Arial, sans-serif); letter-spacing: -.1px; white-space: nowrap; }
.mx-mod + .mx-mod { border-left: 1px solid var(--mx-border) !important; }
.mx-mod svg { width: 17px; height: 17px; flex: none; }
.mx-mod span { overflow: hidden; text-overflow: ellipsis; }
.mx-mod.on { background: var(--mx-acento); color: #1f2a33; }
.mx-mod .mx-badge { top: 2px; right: 2px; min-width: 18px; height: 18px; font-size: 10px; }
.mx-mod-name { display: none; }

/* ---------- Menú del usuario: primero los módulos ---------- */
.mx-menu .mx-msec { font-size: 11px; font-weight: 500; letter-spacing: .8px; text-transform: uppercase; color: var(--mx-text3); padding: 10px 16px 4px; }
.mx-menu .mx-mitem { display: flex; align-items: center; gap: 12px; padding: 9px 16px; color: var(--mx-text); text-decoration: none; font-size: 14px; }
.mx-menu .mx-mitem:hover { background: var(--mx-surface2); }
.mx-menu .mx-mitem.on { background: var(--mx-pri-bg); color: var(--mx-pri-t); box-shadow: inset 3px 0 0 var(--mx-acento); font-weight: 500; }
.mx-menu .mx-mitem svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- Símbolo de carga (debajo de la barra superior) ---------- */
.mx-carga { position: fixed; inset: 64px 0 0 0; z-index: 85; background: var(--mx-bg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  color: var(--mx-text2); font: 14px Roboto, Arial, sans-serif; transition: opacity .25s; }
.mx-carga.fuera { opacity: 0; pointer-events: none; }
.mx-spin { width: 42px; height: 42px; border-radius: 50%; border: 4px solid var(--mx-pri-bg); border-top-color: var(--mx-primario); border-right-color: var(--mx-acento); animation: mxgira .8s linear infinite; }
@keyframes mxgira { to { transform: rotate(360deg); } }

/* Los tres botones de módulo: nombres completos, sin cortes */
.mx-mods { padding: 12px 0 2px 8px; }
.mx-mod { padding: 0 4px; gap: 3px; font-size: 11px; letter-spacing: -.15px; }
.mx-mod svg { width: 15px; height: 15px; }
.mx-mod span { overflow: visible; text-overflow: clip; }
.mx-mod .mx-badge { top: 1px; right: 1px; min-width: 15px; height: 15px; font-size: 9px; padding: 0 3px; border-width: 1px; }
.mx-mod.on { color: var(--mx-on-acento, #1f2a33); }


/* Botones de módulo en pirámide: Cotizador a todo el ancho; Optimizador y Chatbot debajo, mitad y mitad */
.mx-mods-row { display: grid; grid-template-columns: 1fr 1fr; }
.mx-mod { height: 40px; padding: 0 6px; gap: 6px; font-size: 12.5px; letter-spacing: 0; justify-content: center; min-width: 0; }
.mx-mod svg { width: 18px; height: 18px; }
.mx-mod + .mx-mod { border-left: 0 !important; }
.mx-mod:first-child { grid-column: 1 / -1; height: 44px; font-size: 14px; border-bottom: 1px solid var(--mx-border) !important; }
.mx-mod:first-child svg { width: 20px; height: 20px; }
.mx-mod:last-child { border-left: 1px solid var(--mx-border) !important; }
.mx-mod .mx-badge { top: 3px; right: 4px; min-width: 16px; height: 16px; font-size: 10px; }

/* Sensación de app (no de página de Chrome) en todas las pantallas:
   sin “arrastrar para recargar” ni rebote, sin el recuadro al tocar, sin zoom con doble toque
   (el zoom con dos dedos sigue), y sin seleccionar texto ni menú de Chrome al mantener presionado un botón o menú.
   En los campos donde se escribe y en los textos se puede seleccionar como siempre. */
html, body { overscroll-behavior-y: none; }
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; }
* { -webkit-tap-highlight-color: transparent; }
button, .btn, .ibtn, [role="button"], nav, .nav, .mx-top, .mx-ib, .seg, .chip, .tabs, .subnav, .rail, .mbar, .menu, label.sw, label.dchk, img, svg {
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
input, textarea, select, [contenteditable="true"] { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }

/* Búsqueda global */
.mx-bgg { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--mx-text3); margin: 12px 0 4px; }
.mx-bgi { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 8px; text-decoration: none; color: inherit; }
.mx-bgi:hover, .mx-bgi:focus { background: var(--mx-surface2); outline: 0; }
.mx-bgi b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .mx-bgi small { color: var(--mx-text3); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mx-bgic { width: 32px; height: 32px; border-radius: 8px; background: var(--mx-surface2); display: flex; align-items: center; justify-content: center; flex: none; font-size: 16px; }
/* Opciones (radio / casilla) dentro de las ventanas de la plataforma */
.mx-radio { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.mx-radio input { width: 16px; height: 16px; margin: 0; accent-color: var(--mx-primario); }

/* Barra superior en computadora: logo │ módulo. La línea divisoria la ubica alinearModulo() en el borde del menú lateral */
@media (min-width: 1181px) {
  .mx-top .mx-brand-mod { border-left: 1px solid var(--mx-border) !important; padding-left: 22px !important; height: 34px; transition: margin-left .2s; }
}