/* ESCEM · Almacenes y Logística · Interfaz del módulo. Minimalista, densa y legible: una sola familia tipográfica,
   neutros fríos, un acento (azul ESCEM) y color solo para estado. Todo bajo .lg para no tocar el resto del portal. */
.lg {
  --lg-fondo: #f6f7f9;
  --lg-panel: #ffffff;
  --lg-linea: #e3e7ed;
  --lg-linea-fuerte: #cfd6df;
  --lg-texto: #16202c;
  --lg-suave: #5b6878;
  --lg-tenue: #8a95a3;
  --lg-marca: #0b2f5b;
  --lg-acento: #0b5cad;
  --lg-acento-suave: #eaf2fb;
  --lg-ok: #0f7a4d;
  --lg-ok-suave: #e7f5ee;
  --lg-aviso: #9a5b00;
  --lg-aviso-suave: #fdf3e1;
  --lg-mal: #b3261e;
  --lg-mal-suave: #fdecea;
  --lg-radio: 8px;
  --lg-foco: 0 0 0 3px rgba(11, 92, 173, 0.22);
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
  background: var(--lg-fondo);
  color: var(--lg-texto);
  font: 400 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
.lg *, .lg *::before, .lg *::after { box-sizing: border-box; }
.lg button, .lg input, .lg select, .lg textarea { font: inherit; color: inherit; }
.lg h1, .lg h2, .lg h3, .lg p { margin: 0; }
.lg :focus-visible { outline: none; box-shadow: var(--lg-foco); border-radius: 6px; }

/* ---------- Navegación lateral ---------- */
.lg-nav { position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; padding: 16px 12px; background: var(--lg-panel); border-right: 1px solid var(--lg-linea); }
.lg-marca { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; }
.lg-marca b { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 7px; background: var(--lg-marca); color: #fff; font-weight: 700; font-size: 13px; letter-spacing: 0.02em; }
.lg-marca span { font-weight: 600; font-size: 14px; line-height: 1.2; }
.lg-marca small { display: block; color: var(--lg-tenue); font-weight: 400; font-size: 12px; }
.lg-grupo { margin: 12px 8px 4px; color: var(--lg-tenue); font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.lg-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-height: 34px; padding: 6px 10px; border: 0; border-radius: 6px; background: none; color: var(--lg-suave); text-align: left; cursor: pointer; }
.lg-item:hover { background: var(--lg-fondo); color: var(--lg-texto); }
.lg-item[aria-current="page"] { background: var(--lg-acento-suave); color: var(--lg-acento); font-weight: 600; }
.lg-item em { min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--lg-aviso-suave); color: var(--lg-aviso); font-style: normal; font-size: 11px; font-weight: 600; text-align: center; }
.lg-nav-pie { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--lg-linea); color: var(--lg-tenue); font-size: 12px; }
.lg-nav-pie select { width: 100%; margin-top: 6px; }

/* ---------- Cabecera y contenido ---------- */
.lg-main { min-width: 0; padding: 0 28px 48px; }
.lg-barra { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 56px; margin: 0 -28px; padding: 0 28px; background: rgba(246, 247, 249, 0.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--lg-linea); }
.lg-miga { color: var(--lg-tenue); font-size: 13px; }
.lg-miga b { color: var(--lg-texto); font-weight: 600; }
.lg-contexto { display: flex; align-items: center; gap: 8px; color: var(--lg-suave); font-size: 13px; }
.lg-punto { width: 7px; height: 7px; border-radius: 50%; background: var(--lg-ok); }
.lg .lg-btn.lg-menu { display: none; }
.lg-titulo { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 24px 0 16px; }
.lg-titulo h1 { font-size: 22px; font-weight: 650; letter-spacing: -0.01em; }
.lg-titulo p { margin-top: 4px; max-width: 70ch; color: var(--lg-suave); }
.lg-acciones { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Botones ---------- */
.lg-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 34px; padding: 0 12px; border: 1px solid var(--lg-linea-fuerte); border-radius: 6px; background: var(--lg-panel); color: var(--lg-texto); font-weight: 500; cursor: pointer; white-space: nowrap; }
.lg-btn:hover { border-color: var(--lg-tenue); background: #fbfcfd; }
.lg-btn.primario { border-color: var(--lg-acento); background: var(--lg-acento); color: #fff; }
.lg-btn.primario:hover { background: #094f95; }
.lg-btn.chico { min-height: 28px; padding: 0 9px; font-size: 13px; }
.lg-btn.peligro { color: var(--lg-mal); }
.lg-btn:disabled { opacity: 0.55; cursor: default; }

/* ---------- Indicadores ---------- */
.lg-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 20px; }
.lg-kpi { display: block; width: 100%; padding: 14px 16px; border: 1px solid var(--lg-linea); border-radius: var(--lg-radio); background: var(--lg-panel); text-align: left; cursor: pointer; }
.lg-kpi:hover { border-color: var(--lg-linea-fuerte); }
.lg-kpi span { display: block; color: var(--lg-suave); font-size: 12px; }
.lg-kpi strong { display: block; margin-top: 6px; font-size: 24px; font-weight: 650; letter-spacing: -0.02em; }
.lg-kpi small { color: var(--lg-tenue); font-size: 12px; }

/* ---------- Paneles, pestañas y tablas ---------- */
.lg-panel { border: 1px solid var(--lg-linea); border-radius: var(--lg-radio); background: var(--lg-panel); overflow: hidden; }
.lg-panel + .lg-panel { margin-top: 16px; }
.lg-panel-cab { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid var(--lg-linea); }
.lg-panel-cab h2 { font-size: 14px; font-weight: 600; }
.lg-pestanas { display: flex; gap: 2px; }
.lg-pestana { min-height: 30px; padding: 0 10px; border: 0; border-radius: 6px; background: none; color: var(--lg-suave); cursor: pointer; }
.lg-pestana[aria-selected="true"] { background: var(--lg-fondo); color: var(--lg-texto); font-weight: 600; }
.lg-buscar { width: 240px; max-width: 100%; }
.lg-tabla-caja { overflow-x: auto; }
.lg-tabla { width: 100%; border-collapse: collapse; font-size: 13px; }
.lg-tabla th { position: sticky; top: 0; padding: 8px 14px; background: #fafbfc; border-bottom: 1px solid var(--lg-linea); color: var(--lg-suave); font-size: 12px; font-weight: 600; text-align: left; white-space: nowrap; }
.lg-tabla td { padding: 9px 14px; border-bottom: 1px solid var(--lg-linea); vertical-align: middle; }
.lg-tabla tr:last-child td { border-bottom: 0; }
.lg-tabla tbody tr.abre { cursor: pointer; }
.lg-tabla tbody tr.abre:hover { background: #fafbfc; }
.lg-tabla .num { text-align: right; white-space: nowrap; }
.lg-tabla .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; white-space: nowrap; }
.lg-tabla .acc { text-align: right; white-space: nowrap; }
.lg-tabla .acc .lg-btn + .lg-btn { margin-left: 6px; }
.lg-tenue { color: var(--lg-tenue); }
.lg-vacio { padding: 36px 16px; color: var(--lg-suave); text-align: center; }
.lg-vacio b { display: block; margin-bottom: 4px; color: var(--lg-texto); font-weight: 600; }
.lg-pie-tabla { padding: 8px 14px; border-top: 1px solid var(--lg-linea); color: var(--lg-tenue); font-size: 12px; }

/* ---------- Estados (siempre con texto, nunca solo color) ---------- */
.lg-chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 10px; background: #eef1f5; color: var(--lg-suave); font-size: 12px; font-weight: 500; white-space: nowrap; }
.lg-chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.lg-chip.ok { background: var(--lg-ok-suave); color: var(--lg-ok); }
.lg-chip.aviso { background: var(--lg-aviso-suave); color: var(--lg-aviso); }
.lg-chip.mal { background: var(--lg-mal-suave); color: var(--lg-mal); }
.lg-chip.info { background: var(--lg-acento-suave); color: var(--lg-acento); }

/* ---------- Cajón lateral (formularios y detalle) ---------- */
.lg-velo { position: fixed; inset: 0; z-index: 40; background: rgba(15, 23, 34, 0.32); }
.lg-cajon { position: fixed; top: 0; right: 0; bottom: 0; z-index: 41; display: flex; flex-direction: column; width: min(560px, 100vw); background: var(--lg-panel); border-left: 1px solid var(--lg-linea); box-shadow: -12px 0 40px rgba(15, 23, 34, 0.12); animation: lgEntrar 0.18s ease-out; }
.lg-cajon.ancho { width: min(760px, 100vw); }
@keyframes lgEntrar { from { transform: translateX(16px); opacity: 0; } }
.lg-cajon-cab { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 14px; border-bottom: 1px solid var(--lg-linea); }
.lg-cajon-cab h2 { font-size: 17px; font-weight: 650; }
.lg-cajon-cab p { margin-top: 2px; color: var(--lg-suave); font-size: 13px; }
.lg-cajon-cuerpo { flex: 1; overflow-y: auto; padding: 18px 20px; }
.lg-cajon-pie { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--lg-linea); background: #fafbfc; }
.lg-campos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.lg-campo { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.lg-campo.todo { grid-column: 1 / -1; }
.lg-campo label { color: var(--lg-suave); font-size: 12px; font-weight: 500; }
.lg-campo small { color: var(--lg-tenue); font-size: 12px; }
.lg input:not([type="checkbox"]), .lg select, .lg textarea { width: 100%; min-height: 34px; padding: 6px 10px; border: 1px solid var(--lg-linea-fuerte); border-radius: 6px; background: #fff; }
.lg textarea { min-height: 72px; resize: vertical; }
.lg input:focus, .lg select:focus, .lg textarea:focus { outline: none; border-color: var(--lg-acento); box-shadow: var(--lg-foco); }
.lg-lineas { grid-column: 1 / -1; margin-top: 4px; border: 1px solid var(--lg-linea); border-radius: var(--lg-radio); overflow: hidden; }
.lg-lineas-cab { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: #fafbfc; border-bottom: 1px solid var(--lg-linea); font-size: 13px; font-weight: 600; }
.lg-linea { display: grid; gap: 8px; align-items: end; padding: 10px 12px; border-bottom: 1px solid var(--lg-linea); }
.lg-linea:last-child { border-bottom: 0; }
.lg-aviso { margin-bottom: 14px; padding: 10px 12px; border: 1px solid; border-radius: 6px; font-size: 13px; }
.lg-aviso.mal { border-color: #f3c6c2; background: var(--lg-mal-suave); color: var(--lg-mal); }
.lg-aviso.info { border-color: #cfe0f3; background: var(--lg-acento-suave); color: #0a4a8a; }
.lg-aviso code { font-size: 12px; opacity: 0.8; }
.lg-datos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; margin-bottom: 18px; }
.lg-datos div span { display: block; color: var(--lg-tenue); font-size: 12px; }
.lg-datos div b { font-weight: 500; overflow-wrap: anywhere; }
.lg-sub { margin: 18px 0 8px; font-size: 13px; font-weight: 600; }
.lg-historial { margin: 0; padding: 0; list-style: none; }
.lg-historial li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--lg-linea); font-size: 13px; }
.lg-toast { position: fixed; left: 50%; bottom: 24px; z-index: 60; transform: translateX(-50%); max-width: min(520px, 92vw); padding: 10px 14px; border-radius: 8px; background: #16202c; color: #fff; font-size: 13px; box-shadow: 0 10px 30px rgba(15, 23, 34, 0.25); }

/* ---------- Teléfono y tableta ---------- */
@media (max-width: 900px) {
  .lg { grid-template-columns: minmax(0, 1fr); }
  .lg-nav { position: fixed; z-index: 30; inset: 0 auto 0 0; width: 264px; transform: translateX(-100%); transition: transform 0.2s ease; box-shadow: 12px 0 40px rgba(15, 23, 34, 0.14); }
  .lg.nav-abierta .lg-nav { transform: none; }
  .lg .lg-btn.lg-menu { display: inline-flex; }
  .lg-pestanas { max-width: 100%; overflow-x: auto; }
  .lg-pestana { white-space: nowrap; flex: none; }
  .lg-tabla td, .lg-tabla th { white-space: nowrap; }
  .lg-contexto { display: none; }
  .lg-panel-cab { flex-direction: column; align-items: stretch; }
  .lg-main { padding: 0 16px 40px; }
  .lg-barra { margin: 0 -16px; padding: 0 16px; }
  .lg-campos, .lg-datos { grid-template-columns: minmax(0, 1fr); }
  .lg-linea { grid-template-columns: minmax(0, 1fr) !important; }
  .lg-btn { min-height: 40px; }
  .lg-buscar { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { .lg-cajon { animation: none; } .lg-nav { transition: none; } }
