/* =====================================================================
   componentes.css — Piezas reutilizables: tarjetas, botones, campos,
   insignias, tablas, stepper, pasos, avisos y ventanas modales
   ===================================================================== */
.ico { display: inline-flex; width: 18px; height: 18px; flex: none; }
.ico svg { width: 100%; height: 100%; }

/* ---------- Tarjetas ---------- */
.tarjeta {
  background: linear-gradient(180deg, rgba(21, 33, 58, .92), rgba(14, 22, 40, .96));
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  padding: 18px;
  display: grid; gap: 14px; align-content: start;
  min-width: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .03);
}
.tarjeta-cab { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 14px; }
.tarjeta-titulo { display: flex; align-items: center; gap: 10px; font-size: 1.04rem; }
.tarjeta-titulo::before { content: ""; width: 3px; height: 17px; border-radius: 2px; background: var(--azul); box-shadow: 0 0 10px var(--azul-glow); }
.tarjeta-titulo .num { color: var(--azul-claro); }
.tarjeta-acciones { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.subtitulo { font-family: var(--f-titulo); font-size: .92rem; font-weight: 600; color: var(--texto); }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--radio-s);
  border: 1px solid transparent; font-weight: 600; line-height: 1.2;
  white-space: nowrap; text-decoration: none;
  transition: background .15s, box-shadow .15s, border-color .15s, color .15s, transform .05s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .42; box-shadow: none !important; }
.btn-primario { background: var(--azul); color: #fff; box-shadow: 0 6px 18px rgba(13, 110, 253, .28); }
.btn-primario:hover:not(:disabled) { background: var(--azul-claro); }
.btn-secundario { background: var(--panel-3); border-color: var(--borde-2); color: var(--texto); }
.btn-secundario:hover:not(:disabled) { border-color: var(--azul-claro); background: #22314B; }
.btn-exito { background: var(--verde); color: #03210E; box-shadow: 0 6px 18px rgba(34, 197, 94, .25); }
.btn-exito:hover:not(:disabled) { background: #39D671; }
.btn-peligro { background: var(--rojo); color: #fff; }
.btn-peligro:hover:not(:disabled) { background: #F26161; }
.btn-fantasma { background: transparent; border-color: var(--borde-2); color: var(--texto-2); }
.btn-fantasma:hover:not(:disabled) { color: var(--texto); border-color: var(--texto-3); }
.btn-borrar { background: var(--rojo-bg); border-color: rgba(239, 68, 68, .45); color: #FF9C9C; }
.btn-borrar:hover:not(:disabled) { background: var(--rojo); color: #fff; }
.btn-grande { padding: 14px 22px; font-size: 1.04rem; border-radius: 11px; }
.btn-grande .ico { width: 20px; height: 20px; }
.btn-chico { padding: 6px 10px; font-size: .82rem; }
.btn-icono { padding: 8px; }
.btn-icono.btn-chico { padding: 6px; }
.btn-bloque { width: 100%; }

/* ---------- Campos de formulario ---------- */
.campo { display: grid; gap: 6px; min-width: 0; align-content: start; }
.campo > label, .campo .etiqueta { font-size: .8rem; font-weight: 500; color: var(--texto-2); }
.input, .select {
  width: 100%; min-width: 0;
  background: var(--fondo); border: 1px solid var(--borde-2); border-radius: var(--radio-s);
  padding: 10px 12px; color: var(--texto);
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--texto-3); }
.input:focus, .select:focus { outline: none; border-color: var(--azul); box-shadow: 0 0 0 3px var(--azul-bg); }
.input:disabled, .select:disabled { opacity: .5; }
.select { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 18px; }
.select option { background: var(--panel-3); }
.input-sufijo { position: relative; }
.input-sufijo .input { padding-right: 44px; }
.input-sufijo span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--texto-3); font-size: .82rem; pointer-events: none; }
.campo-ayuda { color: var(--texto-3); font-size: .78rem; }
.campo-error { color: var(--rojo); font-size: .78rem; min-height: 0; }
.campo-error:empty { display: none; }
.campo.con-error .input, .campo.con-error .select { border-color: var(--rojo); }
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--texto-2); cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--azul); }
.rejilla-campos { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }

/* Buscador con icono y botón para limpiar */
.buscador { position: relative; min-width: 0; }
.buscador > .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--texto-2); pointer-events: none; }
.buscador .input { padding-left: 40px; padding-right: 40px; }
.buscador .limpiar { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--texto-2); padding: 6px; border-radius: 6px; display: inline-flex; }
.buscador .limpiar:hover { color: var(--texto); background: var(--panel-3); }
.filtros { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr) minmax(150px, 220px); }

/* ---------- Insignias ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: .76rem; font-weight: 600; white-space: nowrap;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.con-icono::before { display: none; }
.badge .ico { width: 14px; height: 14px; }
.badge-verde { background: var(--verde-bg); color: var(--verde); }
.badge-amarillo { background: var(--amarillo-bg); color: var(--amarillo); }
.badge-rojo { background: var(--rojo-bg); color: #FF7B7B; }
.badge-azul { background: var(--azul-bg); color: var(--azul-claro); }
.badge-gris { background: rgba(148, 163, 184, .12); color: var(--texto-2); }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--f-mono); font-size: .74rem;
  padding: 2px 8px; border-radius: 6px;
  background: var(--azul-osc); border: 1px solid var(--borde-2); color: #BBD3FF;
  white-space: nowrap;
}

/* ---------- Tablas ---------- */
.tabla-cont { overflow-x: auto; border: 1px solid var(--borde); border-radius: 11px; background: rgba(7, 13, 26, .35); }
.tabla { width: 100%; border-collapse: collapse; min-width: 640px; }
.tabla th {
  text-align: left; font-size: .76rem; font-weight: 600; letter-spacing: .02em;
  color: var(--texto-2); background: var(--panel-2);
  padding: 10px 12px; border-bottom: 1px solid var(--borde); white-space: nowrap;
}
.tabla td { padding: 9px 12px; border-bottom: 1px solid var(--borde); vertical-align: middle; }
.tabla tbody tr:last-child td { border-bottom: 0; }
.tabla tbody tr:hover td { background: rgba(59, 139, 255, .04); }
.tabla .num, .tabla .centro { text-align: center; }
.tabla .der { text-align: right; }
.tabla td.vacio { text-align: center; color: var(--texto-2); padding: 28px 12px; }
.tabla .acciones-fila { display: flex; gap: 6px; }
.tabla-compacta .tabla { min-width: 520px; }
.tabla-compacta .tabla td { padding: 7px 12px; }

/* ---------- Imagen de producto ---------- */
.img-prod { display: grid; place-items: center; aspect-ratio: 1; border-radius: 10px; background: radial-gradient(circle at 50% 40%, #1B2A47, #0B1324 72%); overflow: hidden; }
.img-prod > img { width: 100%; height: 100%; object-fit: contain; }
.img-prod > svg { width: 86%; height: 86%; }
.img-prod.mini { width: 44px; height: 44px; border-radius: 8px; }

/* ---------- Stepper de cantidad ---------- */
.stepper { display: inline-flex; align-items: stretch; border: 1px solid var(--borde-2); border-radius: 10px; overflow: hidden; background: var(--fondo); }
.stepper button { width: 44px; border: 0; background: transparent; color: var(--texto); display: grid; place-items: center; }
.stepper button:hover:not(:disabled) { background: var(--panel-3); }
.stepper button:disabled { opacity: .3; }
.stepper input { width: 64px; border: 0; border-inline: 1px solid var(--borde-2); background: transparent; text-align: center; font-size: 1.15rem; font-weight: 600; padding: 9px 0; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* ---------- Control segmentado ---------- */
.segmentado { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; background: var(--fondo); border: 1px solid var(--borde-2); border-radius: 10px; }
.segmentado button { border: 0; background: transparent; color: var(--texto-2); padding: 6px 12px; border-radius: 7px; font-weight: 500; font-size: .85rem; }
.segmentado button:hover { color: var(--texto); }
.segmentado button[aria-pressed="true"] { background: var(--azul); color: #fff; }

/* ---------- KPI ---------- */
.kpis { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.kpi { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: var(--radio); border: 1px solid var(--borde); background: linear-gradient(180deg, rgba(21, 33, 58, .9), rgba(14, 22, 40, .95)); min-width: 0; }
.kpi-ico { width: 44px; height: 44px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.kpi-ico .ico { width: 22px; height: 22px; }
.kpi-titulo { color: var(--texto-2); font-size: .82rem; }
.kpi-valor { font-size: 1.55rem; font-weight: 600; line-height: 1.2; }
.kpi-detalle { color: var(--texto-3); font-size: .76rem; }
.kpi-azul .kpi-ico { background: var(--azul-bg); color: var(--azul-claro); }
.kpi-verde .kpi-ico { background: var(--verde-bg); color: var(--verde); }
.kpi-amarillo .kpi-ico { background: var(--amarillo-bg); color: var(--amarillo); }
.kpi-rojo .kpi-ico { background: var(--rojo-bg); color: var(--rojo); }

/* ---------- Pasos de operación ---------- */
.pasos { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; grid-template-columns: repeat(var(--n, 6), minmax(0, 1fr)); counter-reset: paso; }
.paso { position: relative; display: grid; justify-items: center; gap: 6px; text-align: center; font-size: .78rem; color: var(--texto-3); }
.paso::after { content: ""; position: absolute; top: 15px; left: calc(50% + 18px); right: calc(-50% + 18px); height: 2px; background: var(--borde-2); }
.paso:last-child::after { display: none; }
.paso-circ { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--borde-2); background: var(--fondo); font-weight: 600; font-size: .85rem; color: var(--texto-2); z-index: 1; }
.paso-circ .ico { width: 16px; height: 16px; }
.paso.hecho { color: var(--texto-2); }
.paso.hecho .paso-circ { border-color: var(--verde); background: var(--verde); color: #03210E; }
.paso.hecho::after { background: var(--verde); }
.paso.actual { color: var(--texto); font-weight: 600; }
.paso.actual .paso-circ { border-color: var(--azul); background: var(--azul); color: #fff; box-shadow: 0 0 0 5px var(--azul-bg); animation: latido 1.2s ease-in-out infinite; }
.paso.error .paso-circ { border-color: var(--rojo); background: var(--rojo); color: #fff; }
.paso.error { color: #FF9C9C; }

/* ---------- Avisos y mensajes ---------- */
.aviso { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 11px; border: 1px solid; font-size: .9rem; }
.aviso .ico { width: 20px; height: 20px; margin-top: 1px; }
.aviso-info { border-color: rgba(59, 139, 255, .4); background: var(--azul-bg); color: #CFE0FF; }
.aviso-ok { border-color: rgba(34, 197, 94, .45); background: var(--verde-bg); color: #B9F5CF; }
.aviso-alerta { border-color: rgba(250, 204, 21, .45); background: var(--amarillo-bg); color: #FBE7A1; }
.aviso-error { border-color: rgba(239, 68, 68, .5); background: var(--rojo-bg); color: #FFC4C4; }
.vacio-bloque { display: grid; justify-items: center; gap: 8px; text-align: center; color: var(--texto-2); padding: 26px 12px; }
.vacio-bloque .ico { width: 34px; height: 34px; color: var(--texto-3); }

/* ---------- Valores de posición X Y Z ---------- */
.pos-ejes { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.pos-eje { padding: 10px 12px; border-radius: 10px; background: rgba(7, 13, 26, .5); border: 1px solid var(--borde); min-width: 0; }
.pos-eje span { display: block; font-size: .74rem; color: var(--texto-2); font-weight: 600; letter-spacing: .04em; }
.pos-eje strong { font-family: var(--f-mono); font-size: 1.05rem; font-weight: 500; white-space: nowrap; }
.pos-eje.x span { color: #6EA8FF; }
.pos-eje.y span { color: #5EEAD4; }
.pos-eje.z span { color: #C4B5FD; }
.pos-eje.i span { color: #FCD34D; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 10px; z-index: 100; width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 11px; background: #1A2640; border: 1px solid var(--borde-2); border-left: 4px solid var(--azul); box-shadow: var(--sombra); animation: entra .2s ease-out; }
.toast .ico { width: 20px; height: 20px; margin-top: 1px; }
.toast-ok { border-left-color: var(--verde); } .toast-ok .ico { color: var(--verde); }
.toast-alerta { border-left-color: var(--amarillo); } .toast-alerta .ico { color: var(--amarillo); }
.toast-error { border-left-color: var(--rojo); } .toast-error .ico { color: var(--rojo); }
.toast-info .ico { color: var(--azul-claro); }
.toast.sale { opacity: 0; transform: translateY(6px); transition: .2s; }

/* ---------- Modal ---------- */
.modal-fondo { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 16px; background: rgba(2, 6, 15, .72); backdrop-filter: blur(3px); animation: aparece .15s; }
.modal { width: 100%; max-width: 440px; display: grid; gap: 14px; padding: 22px; border-radius: 16px; background: #131F37; border: 1px solid var(--borde-2); box-shadow: var(--sombra); }
.modal h2 { font-size: 1.15rem; display: flex; align-items: center; gap: 10px; }
.modal h2 .ico { width: 22px; height: 22px; }
.modal p { color: var(--texto-2); }
.modal-acciones { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 4px; }

@keyframes entra { from { opacity: 0; transform: translateY(8px); } }
@keyframes aparece { from { opacity: 0; } }
@keyframes latido { 50% { box-shadow: 0 0 0 9px rgba(13, 110, 253, .05); } }

@media (max-width: 760px) {
  .filtros { grid-template-columns: 1fr; }
  .pos-ejes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pasos { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 14px; }
  .paso:nth-child(3n)::after { display: none; }
}

/* ---------- Inicio de sesión ---------- */
.login { max-width: 400px; }
.login-cab { display: flex; gap: 14px; align-items: center; }
.login-cab p { color: var(--texto-2); font-size: .88rem; }
.login-ico { width: 48px; height: 48px; flex: none; display: grid; place-items: center; border-radius: 12px; background: var(--azul-bg); color: var(--azul-claro); }
.login-ico .ico { width: 26px; height: 26px; }
.clave-caja { position: relative; }
.clave-caja .input { padding-right: 46px; }
.ver-clave { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--texto-2); padding: 7px; border-radius: 6px; display: inline-flex; }
.ver-clave:hover, .ver-clave[aria-pressed="true"] { color: var(--texto); background: var(--panel-3); }
.modal .login-error { color: #FF9C9C; font-size: .86rem; min-height: 1.3em; }
.modal .login-error:empty { min-height: 0; }
.restringido { display: grid; justify-items: center; gap: 12px; text-align: center; padding: 48px 20px; border: 1px dashed var(--borde-2); border-radius: var(--radio); background: rgba(7, 13, 26, .4); }
.restringido h2 { font-size: 1.2rem; }
.restringido p { color: var(--texto-2); max-width: 46ch; }
.restringido-ico { width: 64px; height: 64px; display: grid; place-items: center; border-radius: 50%; background: var(--amarillo-bg); color: var(--amarillo); }
.restringido-ico .ico { width: 32px; height: 32px; }
