/* Kardex · bodega tuconstruyes
   Tokens y medidas tomados de docs/DISENO.md y docs/maqueta.html */

:root {
  --fondo: #F6F4F1;
  --tarjeta: #FFFFFF;
  --tinta: #23201F;
  --suave: #6E6865;
  --linea: #ECE7E3;
  --rojo: #E83A3A;
  --azul: #2F6FED;
  --verde: #1F9254;
  --naranjo: #C2410C;
  --ambar: #B7791F;
  --morado: #6B4FD8;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
  font-family: Roboto, sans-serif;
  font-size: 15px;
  background: var(--fondo);
  color: var(--tinta);
  min-width: 1024px;
  min-height: 100vh;
}

button, input { font-family: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--azul); outline-offset: 2px; }
::selection { background: #E3EBFD; color: var(--tinta); }
input { caret-color: var(--azul); }
.num, .disp span, .cant .valor, .prods .q { font-variant-numeric: tabular-nums; }

.cargando { color: var(--suave); font-size: 15px; padding: 18px 0; }

.pantalla-inicio { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.sin-conexion { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; color: var(--suave); max-width: 380px; }

/* ---------- Logo ---------- */
.logo { width: 36px; height: 36px; border-radius: 10px; background: var(--rojo); color: #fff; font: 700 18px Montserrat, sans-serif; display: flex; align-items: center; justify-content: center; flex: none; }
.logo-grande { width: 48px; height: 48px; border-radius: 13px; font-size: 24px; margin: 0 auto 12px; }

/* ---------- Inicio de sesión ---------- */
.login { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 26px; padding: 24px; }
.login-de { line-height: 0; color: var(--tinta); }
.marca-tc { width: 132px; height: auto; }
.login-caja { background: var(--tarjeta); border: 1px solid var(--linea); border-radius: 16px; padding: 36px 32px 28px; width: 380px; }
.login-marca { text-align: center; margin-bottom: 18px; }
.login-marca b { font: 700 24px Montserrat, sans-serif; display: block; line-height: 1.1; }
.login-marca small { font-size: 13px; color: var(--suave); }
.login-error { background: #FDE8E8; color: #A12020; border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-bottom: 4px; }
.login .btn { margin-top: 22px; }
.login-ayuda { margin-top: 16px; font-size: 13px; color: var(--suave); text-align: center; line-height: 1.45; }

/* ---------- Barra superior ---------- */
.barra { background: #fff; border-bottom: 1px solid var(--linea); height: 68px; display: flex; align-items: center; padding: 0 36px; gap: 40px; }
.marca { display: flex; align-items: center; gap: 12px; }
.marca b { font: 700 20px Montserrat, sans-serif; display: block; line-height: 1; }
.marca small { font-size: 12px; color: var(--suave); }
nav { display: flex; gap: 6px; }
nav a { font: 600 15px Montserrat, sans-serif; color: var(--suave); padding: 9px 18px; border-radius: 999px; text-decoration: none; display: flex; gap: 8px; align-items: center; }
nav a:hover { color: var(--tinta); }
nav a.on { background: #FDECEC; color: var(--rojo); }
nav .n { background: var(--rojo); color: #fff; font: 700 11px Roboto, sans-serif; border-radius: 999px; padding: 2px 7px; }
.usuario { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--suave); }
.av { width: 34px; height: 34px; border-radius: 50%; background: #E8EEFD; color: var(--azul); font: 700 13px Montserrat, sans-serif; display: flex; align-items: center; justify-content: center; }
.salir { background: none; border: none; font-size: 13px; color: var(--suave); text-decoration: underline; margin-left: 8px; padding: 4px; }
.salir:hover { color: var(--tinta); }

/* ---------- Estructura de pantalla ---------- */
main { padding: 30px 36px 48px; }
.v { display: none; }
.v.activa { display: block; }
h1 { font: 700 26px Montserrat, sans-serif; margin-bottom: 4px; }
.sub { color: var(--suave); font-size: 15px; margin-bottom: 22px; }
.sub b { color: var(--tinta); }
.encabezado { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; }

.sec { font: 700 16px Montserrat, sans-serif; color: var(--suave); margin-bottom: 12px; }
.seccion + .seccion { margin-top: 28px; }
.plegable { background: none; border: none; font: inherit; color: inherit; display: inline-flex; align-items: center; gap: 8px; padding: 0; }
.plegable:hover { color: var(--tinta); }
.plegable .flecha { display: inline-block; font-size: 12px; transition: transform .15s; }
.plegable[aria-expanded="true"] .flecha { transform: rotate(90deg); }

.vacio { background: var(--tarjeta); border: 1px dashed var(--linea); border-radius: 16px; padding: 22px; color: var(--suave); font-size: 15px; text-align: center; }
.error-carga { color: var(--suave); padding: 18px 0; font-size: 15px; }
.error-carga .link { margin-left: 8px; }

/* ---------- Botones ---------- */
.btn { border: none; border-radius: 12px; padding: 13px 16px; font: 700 15px Montserrat, sans-serif; color: #fff; text-align: center; width: 100%; }
.btn:hover:not(:disabled) { filter: brightness(.94); }
.btn:disabled { opacity: .5; }
.btn-auto { width: auto; padding: 11px 20px; flex: none; }
.b-azul { background: var(--azul); }
.b-verde { background: var(--verde); }
.b-naranjo { background: var(--naranjo); }
.b-ambar { background: var(--ambar); }
.b-morado { background: var(--morado); }
.b-tinta { background: var(--tinta); }
.b-marca { background: var(--rojo); }
.b-claro { background: #fff; color: var(--tinta); border: 1.5px solid var(--linea); }

.link { background: none; border: none; font-size: 13px; color: var(--suave); text-decoration: underline; padding: 2px 0; }
.link:hover:not(:disabled) { color: var(--tinta); }
.link:disabled { opacity: .5; }

/* ---------- Pedidos ---------- */
.grilla { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.ped { background: var(--tarjeta); border-radius: 16px; padding: 20px 22px; border: 1px solid var(--linea); display: flex; flex-direction: column; gap: 12px; }
.ped.quieto { background: #FBFAF8; }
.ped .top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.ped .top > div { flex: 1 1 0; min-width: 0; }
.ped .cod { font: 700 18px Montserrat, sans-serif; }
.ped .cli { color: var(--suave); font-size: 14px; margin-top: 2px; overflow-wrap: anywhere; }
.ped .chip { flex: 0 0 auto; max-width: 65%; white-space: normal; text-align: center; line-height: 1.3; }

.chip { font: 600 12px Roboto, sans-serif; padding: 5px 10px; border-radius: 999px; white-space: nowrap; }
.c-ambar { background: #FFF4DE; color: #8A5A10; }
.c-azul { background: #EEF2FD; color: #2949A8; }
.c-verde { background: #E3F6EA; color: #17683D; }
.c-rojo { background: #FDE8E8; color: #A12020; }
.c-gris { background: #F1EFEC; color: #6E6865; }

.prods { list-style: none; border-top: 1px dashed var(--linea); border-bottom: 1px dashed var(--linea); padding: 10px 0; }
.prods li { display: flex; gap: 12px; font-size: 15px; padding: 4px 0; align-items: baseline; }
.prods .q { font: 700 17px Montserrat, sans-serif; min-width: 34px; }
.prods .fam { display: block; font-size: 12px; color: var(--suave); }
.marca-falta { display: inline-block; margin-left: 8px; background: #FDE8E8; color: #A12020; font: 700 11px Montserrat, sans-serif; padding: 2px 8px; border-radius: 999px; vertical-align: 1px; }

.entrega { font-size: 13px; color: var(--suave); display: flex; gap: 6px; align-items: center; }
.entrega::before {
  content: ""; width: 15px; height: 15px; flex: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236E6865' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 21s-7-6.2-7-11.5a7 7 0 0 1 14 0C19 14.8 12 21 12 21z'/%3E%3Ccircle cx='12' cy='9.5' r='2.5'/%3E%3C/svg%3E") center / contain no-repeat;
}
.hacer { font: 600 14px Montserrat, sans-serif; color: var(--tinta); line-height: 1.4; }
.espera { font-size: 14px; color: var(--suave); background: #F3F1EE; border-radius: 12px; padding: 12px; text-align: center; line-height: 1.4; }
.links { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; }

.panel-falta { border: 1px solid var(--linea); border-radius: 12px; padding: 12px 14px; background: #fff; }
.panel-falta p { font: 600 13px Montserrat, sans-serif; margin-bottom: 6px; }
.interruptor { display: flex; align-items: center; gap: 10px; padding: 6px 0; margin: 0; font: 400 14px Roboto, sans-serif; color: var(--tinta); cursor: pointer; }
.interruptor .nombre { flex: 1; }
.interruptor .nombre b { font: 700 14px Montserrat, sans-serif; margin-right: 6px; }
.interruptor .rotulo { font-size: 12px; color: var(--suave); }
.interruptor input {
  appearance: none; -webkit-appearance: none; flex: none;
  width: 38px; height: 22px; border-radius: 999px; background: #E2DDD8; position: relative; cursor: pointer; transition: background .15s;
}
.interruptor input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; }
.interruptor input:checked { background: var(--rojo); }
.interruptor input:checked::after { left: 19px; }
.interruptor input:disabled { opacity: .5; cursor: default; }

/* ---------- Registrar ---------- */
.dos { display: grid; grid-template-columns: 1.25fr 1fr; gap: 24px; align-items: start; }
.caja { background: #fff; border: 1px solid var(--linea); border-radius: 16px; padding: 24px; }
.opciones { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 22px; }
.op { border: 2px solid var(--linea); border-radius: 14px; padding: 16px; text-align: center; background: #fff; }
.op:hover { border-color: #DCD5CF; }
.op .ic { width: 42px; height: 42px; border-radius: 50%; margin: 0 auto 8px; display: flex; align-items: center; justify-content: center; font: 700 22px Montserrat, sans-serif; color: #fff; }
.op b { font: 700 15px Montserrat, sans-serif; display: block; }
.op small { font-size: 12px; color: var(--suave); }
.ic-verde { background: var(--verde); }
.ic-rojo { background: var(--rojo); }
.ic-morado { background: var(--morado); }
.op.on-entrada { border-color: var(--verde); background: #F1FAF4; }
.op.on-salida { border-color: var(--rojo); background: #FDF1F1; }
.op.on-conteo { border-color: var(--morado); background: #F4F1FD; }

label { font: 600 14px Montserrat, sans-serif; display: block; margin: 14px 0 6px; }
.opcional { font-weight: 400; color: var(--suave); }
.campo { width: 100%; border: 1.5px solid var(--linea); border-radius: 12px; padding: 12px 14px; font-size: 16px; background: #fff; outline: none; }
.campo::placeholder { color: var(--suave); opacity: .8; }
.campo:focus { border-color: var(--azul); box-shadow: 0 0 0 3px #E3EBFD; }

.sug { border: 1px solid var(--linea); border-radius: 12px; margin-top: 6px; overflow: hidden; background: #fff; }
.sug .opcion { padding: 10px 14px; font-size: 14px; border-bottom: 1px solid var(--linea); display: flex; justify-content: space-between; align-items: baseline; gap: 12px; cursor: pointer; }
.sug .opcion:last-child { border-bottom: none; }
.sug .opcion.on { background: #EEF3FE; }
.sug small { color: var(--suave); margin-left: 6px; font-size: 12px; }
.sug .stock-sug { color: var(--suave); font-size: 12px; white-space: nowrap; }
.sug .nada { padding: 10px 14px; font-size: 14px; color: var(--suave); }
.elegido { font-size: 13px; color: var(--suave); margin-top: 6px; }
.error-campo { font-size: 13px; color: #A12020; margin-top: 6px; }

.cant { display: flex; align-items: center; gap: 12px; }
.cant .pm { width: 46px; height: 46px; border-radius: 12px; border: 1.5px solid var(--linea); background: #fff; display: flex; align-items: center; justify-content: center; font: 700 22px Montserrat, sans-serif; color: var(--suave); }
.cant .pm:hover { color: var(--tinta); border-color: #DCD5CF; }
.cant .valor { font: 700 26px Montserrat, sans-serif; width: 90px; text-align: center; border: 1.5px solid transparent; border-radius: 12px; padding: 4px 0; background: transparent; outline: none; }
.cant .valor:focus { border-color: var(--azul); box-shadow: 0 0 0 3px #E3EBFD; }
.btn-registrar { margin-top: 20px; }

.titulo-caja { font: 700 17px Montserrat, sans-serif; margin-bottom: 6px; }
.ultimos { list-style: none; }
.ultimos li { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--linea); align-items: center; font-size: 14px; }
.ultimos li.cargando-li, .ultimos li.vacio-li { color: var(--suave); border-bottom: none; font-size: 15px; }
.ultimos .s { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font: 700 15px Montserrat, sans-serif; flex: none; }
.s-verde { background: var(--verde); }
.s-rojo { background: var(--rojo); }
.s-morado { background: var(--morado); }
.s-azul { background: var(--azul); }
.s-gris { background: #B8B1AC; }
.ultimos .cuerpo { flex: 1; min-width: 0; }
.ultimos .mov-tit { font-weight: 500; }
.ultimos .mov-det { color: var(--suave); font-size: 13px; }
.ultimos small { display: block; color: var(--suave); font-size: 12px; margin-top: 2px; }
.ultimos li.anulado .mov-tit, .ultimos li.anulado .mov-prod, .ultimos li.anulado .mov-det { text-decoration: line-through; color: var(--suave); }
.ultimos li.anulado .s { opacity: .45; }
.ultimos .motivo { color: var(--suave); }
.ultimos .link { flex: none; }
.ver-mas { display: block; margin: 14px auto 0; }

/* ---------- Stock ---------- */
.buscar { background: #fff; border: 1.5px solid var(--linea); border-radius: 14px; padding: 0 18px 0 46px; width: 520px; margin-bottom: 14px; position: relative; }
.buscar::before {
  content: ""; position: absolute; left: 18px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236E6865' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E") center / contain no-repeat;
}
.buscar:focus-within { border-color: var(--azul); box-shadow: 0 0 0 3px #E3EBFD; }
.buscar input { width: 100%; border: none; outline: none; background: transparent; font-size: 16px; padding: 13px 0; }
.buscar input::placeholder { color: var(--suave); }

.filtros { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.filtros button { background: #fff; border: 1px solid var(--linea); border-radius: 999px; padding: 7px 14px; font-size: 14px; color: var(--suave); }
.filtros button:hover { color: var(--tinta); }
.filtros button.on { background: var(--tinta); color: #fff; border-color: var(--tinta); }

.lista { background: #fff; border: 1px solid var(--linea); border-radius: 16px; overflow: hidden; }
.cargando-lista { padding: 18px 22px; }
.fila { display: grid; grid-template-columns: minmax(0, 1fr) 130px 130px 170px 130px; align-items: center; padding: 15px 22px; border-bottom: 1px solid var(--linea); font-size: 15px; }
.fila:last-child { border-bottom: none; }
.fila.cab { font: 600 12px Montserrat, sans-serif; color: var(--suave); text-transform: uppercase; letter-spacing: .05em; background: #FBFAF8; padding: 11px 22px; }
.fila.cab span { text-align: center; }
.fila.cab span:first-child { text-align: left; }
.fila .nom small { display: block; color: var(--suave); font-size: 12px; }
.fila .nom .ayuda-neg { color: #A12020; }
.num { text-align: center; font: 600 17px Montserrat, sans-serif; }
.num.negativo { color: #A12020; }
.disp { text-align: center; }
.disp span { display: inline-block; min-width: 64px; padding: 6px 12px; border-radius: 10px; font: 700 18px Montserrat, sans-serif; background: #E3F6EA; color: #17683D; }
.disp span.cero { background: #F3F1EE; color: var(--suave); }
.falta { text-align: center; color: #A12020; font: 700 15px Montserrat, sans-serif; }
.lista .vacio-lista { padding: 22px; color: var(--suave); text-align: center; }
.pie { margin-top: 14px; font-size: 13px; color: var(--suave); }

/* ---------- Ventana modal ---------- */
.fondo-modal { position: fixed; inset: 0; background: rgba(35, 32, 31, .45); display: flex; align-items: center; justify-content: center; z-index: 40; padding: 24px; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 440px; padding: 24px; }
.modal h2 { font: 700 18px Montserrat, sans-serif; margin-bottom: 8px; }
.modal p { font-size: 15px; color: var(--suave); line-height: 1.45; }
.modal .lista-falta { margin-top: 12px; padding-left: 18px; font-size: 14px; }
.modal .lista-falta li { padding: 3px 0; color: #A12020; }
.modal .lista-falta .fam { display: block; font-size: 12px; color: var(--suave); }
.modal .error-campo { color: #A12020; font-size: 13px; margin-top: 6px; }
.modal-botones { display: flex; justify-content: space-between; gap: 12px; margin-top: 22px; }
.modal-botones .btn { flex: 1; }

/* ---------- Avisos ---------- */
.avisos { position: fixed; right: 24px; bottom: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 50; width: 380px; pointer-events: none; }
.aviso { pointer-events: auto; border-radius: 12px; padding: 12px 16px; font: 500 14px Roboto, sans-serif; line-height: 1.4; display: flex; gap: 12px; align-items: flex-start; border: 1px solid transparent; box-shadow: 0 4px 14px rgba(35, 32, 31, .08); }
.aviso span { flex: 1; }
.aviso-exito { background: #E3F6EA; color: #17683D; border-color: #C6E9D3; }
.aviso-aviso { background: #FFF4DE; color: #8A5A10; border-color: #F3DFB4; }
.aviso-error { background: #FDE8E8; color: #A12020; border-color: #F6CACA; }
.aviso .cerrar { background: none; border: none; color: inherit; font: 700 16px Montserrat, sans-serif; line-height: 1; padding: 0 2px; }
