/* EREL Soluciones: estilos. El contrato de diseño está en DESIGN.md; los tokens viven aquí en :root. */

@font-face {
  font-family: "Inter";
  src: url("fonts/inter-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: "Rajdhani";
  src: url("fonts/rajdhani-600-latin.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "Rajdhani";
  src: url("fonts/rajdhani-700-latin.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  /* Marca (valores tomados de los vectores del logotipo) */
  --marino: #203368;
  --circuito: #0066B3;

  /* Superficies y texto */
  --ground: #F2F4F8;          /* fondo de página: gris azulado muy claro */
  --sheet: #FFFFFF;           /* tarjetas */
  --field: #FFFFFF;           /* campos, resultados y botones de destino */
  --peg: #FFFFFF;
  --ink: #141D35;             /* texto principal */
  --muted: #56617A;           /* texto secundario */
  --rule: #DFE3EC;            /* divisiones */
  --edge: #B3BCCD;            /* bordes de controles */
  --track: #E1E6EF;           /* riel de medidores */
  --tint: #EAF1FA;            /* realce suave azul (fila activa, banda) */
  --on-ink: #C4CCDD;          /* texto tenue sobre superficies oscuras */

  /* Acción y acentos */
  --primary: var(--marino);
  --primary-press: #172650;
  --on-primary: #FFFFFF;
  --accent: var(--circuito);  /* enlaces, foco, selección */
  --figure: var(--marino);    /* cifras y títulos de tarjeta */

  /* Barra lateral */
  --side: #16244B;            /* un tono más profundo que el marino: el cuadro del logo se distingue */
  --side-ink: #C7D0E6;
  --side-active: rgba(0, 102, 179, .32);
  --side-rule: rgba(255, 255, 255, .1);

  /* Estados (solo como estado, nunca como decoración) */
  --bad: #B42318; --bad-bg: #FCE9E7;
  --warn: #8A5300; --warn-bg: #FBF0D9;
  --ok: var(--circuito); --ok-bg: #E4EFFA;

  --shadow: 0 10px 28px -10px rgba(20, 32, 70, .35);
  --shadow-card: 0 1px 2px rgba(20, 32, 70, .06);

  --font: "Inter", "Helvetica Neue", Arial, sans-serif;
  --font-title: "Rajdhani", "Inter", "Helvetica Neue", Arial, sans-serif;

  --r-tape: 3px;
  --r-control: 6px;
  --r-panel: 10px;

  --s1: 4px; --s2: 8px; --s3: 16px; --s4: 28px; --s5: 44px;
  --tabbar-h: 62px;
  --topbar-h: 56px;
  --side-w: 248px;
  --rail-w: 96px;
  --ease: cubic-bezier(.2, .7, .3, 1);
}

/* ---------------------------------------------------------------------------
   Modo noche "pizarra azul": todas las superficies comparten el matiz azul
   de la marca, poco saturado; la barra lateral es la capa más profunda y
   las tarjetas se separan del fondo. Se aplica con [data-theme="dark"] y,
   si el usuario no ha elegido, sigue al sistema.
   --------------------------------------------------------------------------- */
:root[data-theme="dark"] {
  --ground: #1A2234;
  --sheet:  #232D42;
  --field:  #2B3650;
  --peg:    #2B3650;
  --ink:    #ECF0F7;
  --muted:  #B1BBCF;
  --rule:   #36425C;
  --edge:   #506080;
  --track:  #36425C;
  --tint:   #26395C;
  --on-ink: #9AA6BE;
  --primary: #3277C8;
  --primary-press: #2A66AD;
  --accent: #78B9EF;
  --figure: #E6EDF9;
  --side: #111A2E;
  --side-ink: #C2CCE2;
  --side-active: rgba(120, 185, 239, .18);
  --side-rule: rgba(255, 255, 255, .08);
  --bad:  #FF9C8F; --bad-bg: #40282E;
  --warn: #F2C46D; --warn-bg: #3D3424;
  --ok:   #78B9EF; --ok-bg: #26395C;
  --shadow: 0 12px 30px -10px rgba(0, 0, 0, .55);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, .2);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --ground: #1A2234;
    --sheet:  #232D42;
    --field:  #2B3650;
    --peg:    #2B3650;
    --ink:    #ECF0F7;
    --muted:  #B1BBCF;
    --rule:   #36425C;
    --edge:   #506080;
    --track:  #36425C;
    --tint:   #26395C;
    --on-ink: #9AA6BE;
    --primary: #3277C8;
    --primary-press: #2A66AD;
    --accent: #78B9EF;
    --figure: #E6EDF9;
    --side: #111A2E;
    --side-ink: #C2CCE2;
    --side-active: rgba(120, 185, 239, .18);
    --side-rule: rgba(255, 255, 255, .08);
    --bad:  #FF9C8F; --bad-bg: #40282E;
    --warn: #F2C46D; --warn-bg: #3D3424;
    --ok:   #78B9EF; --ok-bg: #26395C;
    --shadow: 0 12px 30px -10px rgba(0, 0, 0, .55);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, .2);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.5;
  color: var(--ink); background: var(--ground); -webkit-tap-highlight-color: transparent;
  font-variant-numeric: tabular-nums; overflow-x: clip;
}
a { color: var(--ink); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--accent); text-decoration-thickness: 2px; }
/* Enlaces de texto (no filas ni botones): azul circuito */
p a:not(.btn), dd a:not(.btn), .card-head > a, a.small, .lede a:not(.btn), .alert a { color: var(--accent); }
h1, h2, h3 { font-family: var(--font-title); color: var(--figure); line-height: 1.1; margin: 0 0 .5em; text-wrap: balance; letter-spacing: .005em; }
h1 { font-weight: 700; font-size: clamp(1.9rem, 1.55rem + 1.5vw, 2.6rem); }
h2 { font-weight: 600; font-size: 1.5rem; }
h3 { font-weight: 600; font-size: 1.2rem; }
p { text-wrap: pretty; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.nowrap { white-space: nowrap; }
.icon { flex: 0 0 auto; }
[hidden] { display: none !important; }

/* Foco y movimiento: un solo lenguaje para todo lo interactivo */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-control); }
a, button, .btn, input, select, textarea, .dest, .chip {
  transition: background-color .16s var(--ease), border-color .16s var(--ease), color .16s var(--ease), transform .08s var(--ease), text-decoration-color .16s var(--ease), box-shadow .16s var(--ease);
}
/* Cambio de tema (día/noche) sin golpe: las superficies grandes se funden suave */
body, .sidebar, .topbar, .card, .tabbar, .drawer, .dest, .peg, .confirm-bar, input, select, textarea {
  transition: background-color .28s var(--ease), border-color .28s var(--ease), color .28s var(--ease);
}

/* Switch de modo día/noche (vive en la barra lateral y en la barra superior del celular) */
.tema-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; padding: 0; flex: 0 0 auto;
  border: 1px solid var(--side-rule); border-radius: var(--r-control);
  background: transparent; color: var(--side-ink); cursor: pointer;
}
.tema-toggle:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.tema-toggle svg { display: block; }
.tema-toggle .luna { display: none; }
.tema-toggle .sol { display: block; }
:root[data-theme="dark"] .tema-toggle .sol { display: none; }
:root[data-theme="dark"] .tema-toggle .luna { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .tema-toggle .sol { display: none; }
  :root:not([data-theme]) .tema-toggle .luna { display: block; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

.skip { position: absolute; left: 12px; top: -60px; z-index: 100; padding: 10px 14px; background: var(--primary); color: var(--on-primary); font-weight: 600; border-radius: var(--r-control); }
.skip:focus { top: 12px; }

/* ---------- Códigos de herramienta: placa técnica sobria ---------- */
.code {
  display: inline-block; padding: 0 6px; border-radius: var(--r-tape);
  background: var(--tint); color: var(--figure); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 22%, transparent);
  font-family: var(--font-title); font-weight: 700; font-size: .92em; letter-spacing: .04em; line-height: 1.45;
  white-space: nowrap; vertical-align: .04em;
}

/* Logotipo: siempre el archivo original (texto blanco solo sobre fondos oscuros) */
.logo { display: inline-flex; align-items: center; line-height: 0; text-decoration: none; }
.logo img { display: block; height: 100%; width: auto; }
/* Cada tema muestra su versión del logo (gana sobre cualquier regla de tamaño) */
.logo-noche { display: none !important; }
:root[data-theme="dark"] .logo-dia { display: none !important; }
:root[data-theme="dark"] .logo-noche { display: block !important; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .logo-dia { display: none !important; }
  :root:not([data-theme]) .logo-noche { display: block !important; }
}

/* ---------- Barra lateral (computadora y tableta) ---------- */
.sidebar { display: none; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: var(--s2);
  height: calc(var(--topbar-h) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) max(var(--s3), env(safe-area-inset-right)) 0 max(var(--s3), env(safe-area-inset-left));
  background: var(--side); color: var(--side-ink);
}
.topbar .logo { height: 30px; margin-right: auto; }
.topbar .scan-link { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 10px; color: #fff; font-weight: 600; font-size: .92rem; text-decoration: none; border-radius: var(--r-control); }
.topbar .scan-link:hover { background: rgba(255, 255, 255, .08); }

@media (min-width: 768px) {
  .topbar { display: none; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 30; width: var(--rail-w);
    display: flex; flex-direction: column; gap: var(--s2);
    padding: var(--s3) 8px var(--s3); overflow-y: auto;
    background: var(--side); color: var(--side-ink);
  }
  body.con-nav { padding-left: var(--rail-w); }
  .side-logo { display: flex; justify-content: center; padding: 4px 0 var(--s3); border-bottom: 1px solid var(--side-rule); }
  .side-logo .logo { height: 46px; }
  .side-logo .logo-completo { display: none; }
  .side-cta { display: none; }
  .side-nav { display: grid; gap: 2px; margin: var(--s2) 0 0; padding: 0; list-style: none; }
  .side-nav a {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 10px 4px 9px; border-radius: var(--r-control);
    color: var(--side-ink); font-size: .66rem; font-weight: 600; line-height: 1.15; text-align: center; text-decoration: none;
    white-space: nowrap; letter-spacing: -.01em;
  }
  .side-nav a:hover { color: #fff; background: rgba(255, 255, 255, .06); }
  .side-nav a.active { color: #fff; }
  .side-nav a > .icon, .side-nav a > span:not(.nav-marca) { position: relative; z-index: 1; }
  /* Al pasar el cursor, el ícono avanza un poco (como corriente por el trazo) */
  .side-nav a > .icon { transition: transform .18s var(--ease); }
  .side-nav a:hover > .icon { transform: translateY(-2px); }
  /* Selección: fondo + trazo de circuito con su nodo, como en el isotipo.
     Es un elemento propio para poder deslizarse de una sección a otra. */
  .nav-marca {
    position: absolute; inset: 0; z-index: 0; border-radius: var(--r-control);
    background: var(--side-active); view-transition-name: nav-activo;
  }
  .nav-marca::before {
    content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 3px; border-radius: 2px; background: var(--accent);
  }
  .nav-marca::after {
    content: ""; position: absolute; left: -3px; top: 9px; width: 9px; height: 9px; margin-top: -4px; border-radius: 50%;
    border: 2px solid var(--accent); background: var(--side); box-sizing: border-box;
  }
  .side-foot { margin-top: auto; display: grid; justify-items: center; gap: var(--s2); padding-top: var(--s3); border-top: 1px solid var(--side-rule); }
  .side-user { display: none; }
  .side-foot .logout-icon {
    display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; padding: 0;
    border: 0; border-radius: var(--r-control); background: transparent; color: var(--side-ink); cursor: pointer;
  }
  .side-foot .logout-icon:hover { color: #fff; background: rgba(255, 255, 255, .08); }
  .side-foot .logout-text { display: none; }
  .side-foot form { margin: 0; }
}
@media (min-width: 1180px) {
  .sidebar { width: var(--side-w); padding: 20px var(--s3) var(--s3); }
  body.con-nav { padding-left: var(--side-w); }
  .side-logo { justify-content: flex-start; padding: 2px 4px 18px; }
  .side-logo .logo { height: 50px; }
  .side-logo .logo-iso { display: none; }
  .side-logo .logo-completo { display: block; }
  .side-cta { display: flex; margin-top: var(--s2); }
  .side-cta .btn { width: 100%; padding: 0 12px; white-space: nowrap; background: var(--circuito); border-color: var(--circuito); color: #fff; }
  .side-cta .btn:hover { background: #00599C; border-color: #00599C; }
  .side-nav a { flex-direction: row; gap: 12px; padding: 10px 12px; font-size: .95rem; font-weight: 500; text-align: left; }
  .side-nav a.active { font-weight: 600; }
  .side-nav a:hover > .icon { transform: translateX(3px); }
  .side-foot { justify-items: stretch; grid-template-columns: 1fr auto; align-items: center; gap: 4px var(--s2); }
  .side-user { display: grid; gap: 1px; min-width: 0; grid-column: 1 / -1; padding: 0 4px var(--s2); font-size: .86rem; line-height: 1.3; }
  .side-user strong { color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .side-user span { color: var(--side-ink); font-size: .8rem; }
  .side-foot .logout-icon { width: auto; justify-self: start; gap: 8px; padding: 0 10px; font: inherit; font-size: .88rem; font-weight: 500; }
  .side-foot .logout-text { display: inline; }
}

/* Barra inferior y menú "Más" (celular) */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 35;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right);
  background: var(--sheet); border-top: 1px solid var(--rule);
}
.tabbar a, .tabbar button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: 0; background: none; font: inherit; font-size: .7rem; font-weight: 600;
  color: var(--muted); text-decoration: none; cursor: pointer;
}
.tabbar.tabbar-jefe { grid-template-columns: repeat(4, 1fr); }
.tabbar a { position: relative; }
.tabbar .active { color: var(--accent); }
.tabbar .tab-mover { background: var(--primary); color: var(--on-primary); }
.tabbar .tab-mover.active { color: var(--on-primary); }
.tab-marca {
  position: absolute; top: 0; left: 22%; right: 22%; height: 3px; border-radius: 0 0 3px 3px;
  background: var(--accent); view-transition-name: tab-activo;
}
body.con-nav { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }

.drawer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; max-height: 80dvh; overflow-y: auto;
  padding: var(--s3) var(--s3) calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--s3));
  background: var(--sheet); border-top: 3px solid var(--primary); border-radius: var(--r-panel) var(--r-panel) 0 0;
  transform: translateY(100%); transition: transform .22s var(--ease); visibility: hidden;
}
.drawer.open { transform: none; visibility: visible; }
.drawer ul { list-style: none; margin: 0 0 var(--s3); padding: 0; }
.drawer li a { display: flex; align-items: center; gap: 12px; padding: 13px 4px; border-bottom: 1px solid var(--rule); color: var(--ink); font-size: 1.02rem; font-weight: 500; text-decoration: none; }
.drawer li a .icon { color: var(--muted); }
.drawer li a.active { color: var(--accent); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); padding-left: 14px; }
.drawer li a.active .icon { color: var(--accent); }
.drawer .who { color: var(--muted); font-size: .9rem; }
.nav-backdrop { display: none; position: fixed; inset: 0; z-index: 40; background: rgba(10, 16, 32, .5); }
.nav-backdrop.open { display: block; }

@media (min-width: 768px) {
  .tabbar, .drawer, .nav-backdrop { display: none !important; }
  body.con-nav { padding-bottom: 0; }
}

/* ---------- Página ---------- */
.main { max-width: 1240px; margin: 0 auto; padding: var(--s4) max(var(--s3), env(safe-area-inset-right)) var(--s5) max(var(--s3), env(safe-area-inset-left)); }
.main-solo { max-width: 420px; padding-top: 12vh; }

/* ---------- Acceso (login): panel de marca + formulario ---------- */
.main-solo:has(.acceso) { max-width: none; padding: 0; }
.acceso { min-height: 100dvh; display: grid; }
.acceso-marca { display: none; }
.acceso-form { width: 100%; max-width: 400px; margin: 0 auto; padding: 10vh var(--s3) var(--s5); }
.acceso-form h1 { margin-top: var(--s4); font-size: 2rem; }
.acceso-form .muted { margin: -4px 0 var(--s4); }
.acceso-logo { width: min(280px, 80%); }
.acceso-logo img { display: block; width: 100%; height: auto; }
@media (min-width: 900px) {
  .acceso { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
  .acceso-marca {
    position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end;
    padding: var(--s5); background: var(--side); color: #fff; border-right: 1px solid var(--side-rule);
  }
  /* Los trazos del isotipo, grandes y tenues, como textura del panel */
  .acceso-circuito {
    position: absolute; top: -12%; right: -22%; width: 92%; aspect-ratio: 1;
    background: url("marca/circuito.svg") center / contain no-repeat; opacity: .4;
  }
  .acceso-lema { position: relative; margin: 0 0 6px; max-width: 14ch; font-family: var(--font-title); font-weight: 700; font-size: clamp(2.2rem, 1.4rem + 2vw, 3.2rem); line-height: 1.02; }
  .acceso-sub { position: relative; margin: 0; max-width: 34ch; color: var(--side-ink); }
  .acceso-form { align-self: center; padding: var(--s5) var(--s4); }
}
.crumb { display: inline-block; margin-bottom: 6px; color: var(--muted); font-weight: 600; font-size: .92rem; text-decoration: none; }
.crumb:hover { color: var(--ink); text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s3); }
.page-head h1 { margin: 0; }
.page-actions { display: flex; flex-wrap: wrap; gap: var(--s2); }
.lede { margin: -6px 0 var(--s4); color: var(--muted); max-width: 62ch; }

.card { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r-panel); box-shadow: var(--shadow-card); padding: 18px 20px 20px; margin-bottom: var(--s4); }
.card > h2:first-child, .card-head h2 { margin: 0 0 var(--s3); }
.card-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--s2); }
.card-head .form-actions { flex-wrap: nowrap; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s2); margin: var(--s5) 0 var(--s3); }
.section-title h2 { margin: 0; }
.grid { display: grid; gap: var(--s4); align-items: start; }
.grid > * { min-width: 0; }
.grid .card { margin-bottom: 0; }
.grid > div > .card + .card { margin-top: var(--s4); }
@media (min-width: 960px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border: 1px solid var(--edge); border-radius: var(--r-control);
  background: transparent; color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--tint); border-color: var(--primary); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary, .btn-accent { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover, .btn-accent:hover { background: var(--primary-press); border-color: var(--primary-press); }
.btn-danger { color: var(--bad); border-color: var(--bad); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: .9rem; }
.btn-lg { min-height: 52px; padding: 0 22px; font-size: 1.02rem; }
.btn-block { width: 100%; }

.alert { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--r-control); margin-bottom: var(--s3); font-weight: 500; }
.alert .icon { margin-top: 2px; }
.alert-ok { background: var(--ok-bg); color: var(--ok); }
.alert-error { background: var(--bad-bg); color: var(--bad); }
.alert-info { background: var(--sheet); color: var(--ink); border: 1px solid var(--rule); }

/* Etiquetas de estado: rectángulo, sentence case, solo si hay un estado real */
.badge { display: inline-block; padding: 1px 7px; border-radius: 3px; font-size: .8rem; font-weight: 600; white-space: nowrap; background: var(--ground); color: var(--muted); vertical-align: .05em; }
.estado-danada, .estado-reparacion { background: var(--warn-bg); color: var(--warn); }
.estado-perdida { background: var(--bad-bg); color: var(--bad); }
.estado-baja { background: var(--ground); color: var(--muted); }
.estado-buena { background: var(--ok-bg); color: var(--ok); }
.tipo-salida, .tipo-entrada, .tipo-traspaso, .tipo-devolucion, .tipo-ajuste, .tipo-alta, .tipo-estado { background: var(--ground); color: var(--ink); }
.pedido-solicitado { background: var(--warn-bg); color: var(--warn); }
.pedido-espera { background: var(--warn-bg); color: var(--warn); border: 1px dashed var(--warn); }
.pedido-alistado { background: var(--ok-bg); color: var(--ok); }
.pedido-entregado { background: var(--ok-bg); color: var(--ok); }
.pedido-cerrado { background: var(--ground); color: var(--muted); }
.loc { font-weight: 600; }
.alerta-dias { color: var(--bad); font-weight: 700; }
.dias { font-weight: 600; color: var(--muted); white-space: nowrap; }
.dias.tarde { color: var(--bad); font-weight: 700; }

/* ---------- Formularios ---------- */
.form { display: grid; gap: var(--s3); }
.form-row { display: grid; gap: var(--s3); }
@media (min-width: 700px) { .form-row { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); align-items: end; } }
label { display: grid; align-content: start; gap: 6px; font-weight: 600; font-size: .9rem; color: var(--ink); }
label .hint { font-weight: 400; color: var(--muted); font-size: .85rem; }
input, select, textarea {
  width: 100%; min-height: 46px; padding: 8px 12px; border: 1px solid var(--edge); border-radius: var(--r-control);
  background: var(--field); color: var(--ink); font: inherit; font-size: 16px;
}
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
textarea { min-height: 84px; resize: vertical; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; cursor: pointer; }
.check input { width: 20px; min-height: 20px; height: 20px; accent-color: var(--accent); }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--s2); }

/* Renglones de un pedido (tipo + cantidad) */
.pedido-lineas { width: 100%; border-collapse: collapse; margin-bottom: var(--s3); }
.pedido-lineas th { text-align: left; font-size: .82rem; color: var(--muted); font-weight: 600; padding: 0 6px 6px 0; }
.pedido-lineas td { padding: 0 6px 8px 0; vertical-align: top; }
.pedido-lineas th:last-child, .pedido-lineas td:last-child { padding-right: 0; }
.btn-quitar { min-height: 46px; padding: 0 14px; font-size: 1.2rem; line-height: 1; }

/* Lista de herramientas para alistar un pedido */
.picklist { list-style: none; margin: 0 0 var(--s3); padding: 0; max-height: 380px; overflow-y: auto; border: 1px solid var(--rule); border-radius: var(--r-control); }
.picklist li { padding: 9px 12px; border-bottom: 1px solid var(--rule); }
.picklist li:last-child { border-bottom: 0; }
.picklist .check { font-weight: 500; }
.picklist + .picklist { margin-top: 0; }
.pick-grupo { margin-bottom: var(--s3); }
.pick-grupo-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s2); flex-wrap: wrap; padding: 4px 2px 6px; border-bottom: 2px solid var(--edge); margin-bottom: 8px; }
.pick-grupo .picklist { max-height: 260px; }
.pick-grupo .empty.small { padding: 6px 2px; }
.pick-otras { margin-bottom: var(--s3); }
.pick-otras summary { cursor: pointer; font-weight: 600; color: var(--muted); padding: 6px 2px; }
.pick-otras summary:hover { color: var(--ink); }
.pick-otras[open] summary { margin-bottom: 8px; }
.pick-tipo { display: block; margin-bottom: var(--s3); font-weight: 600; }
.pick-tipo select { margin-top: 5px; }
.alistar-intro { margin: 0 0 var(--s3); color: var(--muted); font-size: .95rem; }
.alistar-tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin: var(--s3) 0; }
.alistar-tools .btn { min-height: 48px; display: inline-flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.alistar-tools .search { flex: 1 1 14rem; min-width: 0; margin: 0; }
.alistar-tools .search input { min-height: 48px; }
.pick-fuera { margin: 4px 0 var(--s2); }
.pick-fuera summary { cursor: pointer; color: var(--warn); font-weight: 600; font-size: .85rem; padding: 4px 2px; }
.pick-fuera[open] summary { margin-bottom: 6px; }
.fuera-lista { list-style: none; margin: 0; padding: 0; border: 1px solid var(--rule); border-radius: var(--r-control); }
.fuera-lista li { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); flex-wrap: wrap; padding: 8px 12px; border-bottom: 1px solid var(--rule); }
.fuera-lista li:last-child { border-bottom: 0; }
.fuera-pieza { display: flex; flex-direction: column; min-width: 0; }
#disp .picklist li { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
#disp .picklist .check { flex: 1 1 12rem; min-width: 0; }
.pick-caja { display: none; flex: 0 0 8.5rem; max-width: 100%; }
/* El selector de caja solo aparece en las piezas ya marcadas, para no saturar. */
#disp.con-cajas .picklist li.marcada .pick-caja { display: block; }

/* Barra de cajas: elige la caja activa y lo que marcas cae en ella. */
.cajas-bar { margin-bottom: var(--s3); padding: var(--s3); background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r-panel); }
.cajas-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.caja-chip { min-height: 42px; padding: 0 16px; border: 1px solid var(--edge); border-radius: 999px; background: var(--ground); color: var(--ink); font-weight: 600; font-size: .95rem; cursor: pointer; }
.caja-chip.active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.caja-chip.caja-add { background: none; border-style: dashed; color: var(--muted); }
.cajas-ayuda { margin-bottom: 10px; font-size: .9rem; color: var(--ink); }
.cajas-ayuda > strong { display: block; margin-bottom: 4px; }
.cajas-ayuda ol { margin: 0; padding-left: 1.3em; color: var(--muted); display: grid; gap: 3px; }
.cajas-ayuda em { font-style: normal; font-weight: 700; color: var(--ink); }
.cajas-llenando { margin: 0 0 8px; font-size: .95rem; color: var(--muted); }
.cajas-llenando strong { background: var(--primary); color: var(--on-primary); padding: 2px 10px; border-radius: 999px; font-weight: 700; }
.cajas-resumen { margin: 10px 0 0; font-weight: 700; color: var(--ink); font-size: .92rem; }

/* Validación suave al alistar: "marcaste M de N" por tipo. */
.pick-marcadas { font-size: .82rem; font-weight: 700; margin-left: auto; }
.pick-marcadas.corta { color: var(--bad); }
.pick-marcadas.ok { color: var(--ok); }
.pick-marcadas.extra { color: var(--warn); }

/* "Aplicar una caja a todo el grupo" (solo cuando el pedido va en cajas/cajón). */
.caja-todas { display: none; gap: 6px; margin: 0 0 8px; flex-wrap: wrap; }
#disp.con-cajas .caja-todas { display: flex; }
.caja-todas-val { flex: 1 1 12rem; min-width: 0; }
.chip-caja { display: inline-block; background: var(--tint); color: var(--figure); font-size: .72rem; font-weight: 700; padding: 0 6px; border-radius: 3px; margin-right: 4px; }
.fuera-aviso { color: var(--warn, var(--ink)); font-weight: 600; }
.inv-item { transition: background .15s; }
.inv-item.encontrada { background: var(--ok-bg); box-shadow: inset 3px 0 0 var(--ok); }
#disp .picklist li.encontrada { background: var(--ok-bg); box-shadow: inset 3px 0 0 var(--ok); }
.scan-alistar { margin-bottom: var(--s3); }

/* Recibir y cerrar: renglón con herramienta + estado al regresar. */
.recibir-item { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.recibir-nombre { flex: 1 1 12rem; min-width: 0; }
.recibir-estado { flex: 0 0 11rem; max-width: 100%; }
.recibir-item.recibida { background: var(--ok-bg); box-shadow: inset 3px 0 0 var(--ok); }
.recibir-item.danada { background: var(--warn-bg); box-shadow: inset 3px 0 0 var(--warn); }
.recibir-item.perdida { background: var(--warn-bg); box-shadow: inset 3px 0 0 var(--bad); }

/* Reportar consumo real: renglón apilado con cantidad + unidad en línea. */
.consumo-lista { display: flex; flex-direction: column; gap: 10px; margin-bottom: var(--s3); }
.consumo-item { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); padding: 10px 0; border-top: 1px solid var(--rule); }
.consumo-item:first-child { border-top: 0; }
.consumo-nombre { flex: 1 1 11rem; min-width: 0; display: grid; gap: 1px; }
.consumo-cant { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; margin-left: auto; }
.consumo-cant > span.small { white-space: nowrap; }
.consumo-cant input { width: 5.5rem; min-width: 5.5rem; text-align: right; -moz-appearance: textfield; }
.consumo-cant input::-webkit-outer-spin-button, .consumo-cant input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.consumo-uni { color: var(--muted); font-weight: 600; min-width: 2.5rem; }
.filters { display: flex; flex-wrap: wrap; gap: var(--s2); margin-bottom: var(--s3); }
.filters > * { flex: 1 1 160px; }
.filters .btn { flex: 0 0 auto; }

.search { position: relative; display: block; }
.search .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { padding-left: 44px; min-height: 52px; font-size: 1.02rem; }

.chips { display: flex; gap: var(--s2); overflow-x: auto; padding: 2px 2px 6px; margin-bottom: var(--s3); scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; display: inline-flex; align-items: baseline; gap: 6px; padding: 8px 13px;
  border: 1px solid var(--edge); border-radius: var(--r-control); color: var(--ink);
  font-size: .92rem; font-weight: 600; text-decoration: none; white-space: nowrap;
}
.chip:hover { border-color: var(--ink); text-decoration: none; }
.chip .n { color: var(--muted); font-weight: 500; }
.chip.active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.chip.active .n { color: var(--on-ink); }

/* ---------- Bitácora: renglones ---------- */
.tools { list-style: none; margin: 0; padding: 0; }
.tools > li + li { border-top: 1px solid var(--rule); }
.tool {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px var(--s3); align-items: center;
  padding: 12px 2px; color: var(--ink); text-decoration: none;
}
.tool:hover { text-decoration: none; }
.tool:hover .tool-name { text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; }
.tool-name { font-weight: 600; }
.tool-name .code { margin-right: 8px; }
.tool-sub { grid-column: 1; font-size: .9rem; color: var(--muted); }
.tool-side { grid-column: 2; grid-row: 1 / span 2; text-align: right; }
.empty { padding: var(--s4) var(--s3); color: var(--muted); }
.empty .icon { display: none; }

/* Tabla de bitácora */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 10px 11px 0; text-align: left; border-bottom: 1px solid var(--rule); vertical-align: baseline; }
th { font-size: .8rem; font-weight: 600; color: var(--muted); letter-spacing: .02em; border-bottom: 1px solid var(--edge); padding-top: 0; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; padding-right: 0; padding-left: 10px; }
td .sub { display: block; font-size: .88rem; color: var(--muted); }
.row-link { font-weight: 600; text-decoration: none; }
/* Nombres que llevan a una ficha dentro de una tabla: sin subrayado hasta pasar el cursor */
td a:not(.btn) { text-decoration: none; }
td a:not(.btn):hover { text-decoration: underline; text-decoration-color: var(--accent); }
.row-link:hover { text-decoration: underline; }
@media (max-width: 699px) {
  .stack thead { display: none; }
  .stack tr { display: block; padding: 10px 0; border-bottom: 1px solid var(--rule); }
  .stack tbody tr:last-child { border-bottom: 0; }
  .stack td { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; border: 0; text-align: right; }
  .stack td::before { content: attr(data-label); color: var(--muted); font-size: .86rem; text-align: left; }
  .stack td.main-cell { display: block; text-align: left; font-size: 1.02rem; padding-bottom: 4px; }
  .stack td.main-cell::before { content: none; }
}

/* ---------- Inicio ---------- */
/* Cifras: tarjeta blanca, número en marino con el trazo y nodo de la marca */
.kpis { list-style: none; margin: 0 0 var(--s3); padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 900px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s3); } }
.kpis a {
  position: relative; display: grid; gap: 2px; padding: 14px 16px 16px; height: 100%;
  background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r-panel); box-shadow: var(--shadow-card);
  color: var(--ink); text-decoration: none;
}
.kpis a:hover { border-color: var(--accent); }
.kpis strong { font-family: var(--font-title); font-weight: 700; font-size: 2.3rem; line-height: 1; color: var(--figure); }
.kpis span { font-size: .88rem; font-weight: 500; color: var(--muted); }
.kpis a::after {
  content: ""; position: absolute; right: 16px; top: 18px; width: 22px; height: 2px; background: var(--accent); opacity: .7;
}
.kpis a::before {
  content: ""; position: absolute; right: 12px; top: 15px; width: 8px; height: 8px; border-radius: 50%;
  border: 2px solid var(--accent); background: var(--sheet); box-sizing: border-box; z-index: 1; opacity: .9;
}
.kpis .atencion strong { color: var(--bad); }
.actions-bar { display: flex; flex-wrap: wrap; gap: var(--s2); margin: var(--s3) 0 var(--s4); }
.todo { list-style: none; margin: 0; padding: 0; }
.todo li + li { border-top: 1px solid var(--rule); }
.todo a { display: grid; grid-template-columns: 12px 1fr auto; gap: 2px 14px; align-items: baseline; padding: 13px 2px; text-decoration: none; }
.todo a:hover strong { text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; }
.todo .mark { width: 10px; height: 10px; border-radius: 1px; background: var(--muted); align-self: center; }
.todo .mark.bad { background: var(--bad); }
.todo .mark.warn { background: var(--warn); }
.todo .mark.info { background: var(--edge); }
.todo .todo-text { display: grid; gap: 1px; }
.todo .todo-text span { color: var(--muted); font-size: .9rem; }
.todo .go { color: var(--muted); font-size: .9rem; font-weight: 600; }
.todo-ok { margin: 0; color: var(--ok); font-weight: 600; display: flex; align-items: center; gap: 8px; }

/* Pendientes: lista con más jerarquía para el almacén (ícono + color por urgencia). */
.pend-cuenta { font-size: .85rem; font-weight: 700; color: var(--muted); }
.pend-cuenta.urgente { color: var(--bad); }
.pend-lista { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.pend-item { border: 1px solid var(--rule); border-left: 5px solid var(--edge); border-radius: var(--r-control); }
.pend-item.nivel-bad { border-left-color: var(--bad); }
.pend-item.nivel-warn { border-left-color: var(--warn); }
.pend-item.nivel-info { border-left-color: var(--edge); }
.pend-item a { display: flex; align-items: center; gap: 12px; padding: 13px 14px; text-decoration: none; }
.pend-icono { flex: 0 0 auto; display: inline-flex; color: var(--muted); }
.pend-item.nivel-bad .pend-icono { color: var(--bad); }
.pend-item.nivel-warn .pend-icono { color: var(--warn); }
.pend-text { flex: 1 1 auto; display: grid; gap: 1px; min-width: 0; }
.pend-text strong { font-weight: 700; }
.pend-text > span { color: var(--muted); font-size: .9rem; }
.pend-go { flex: 0 0 auto; color: var(--muted); font-weight: 700; font-size: .88rem; white-space: nowrap; }
.pend-go::after { content: " ›"; }
.pend-item a:hover strong { text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; }
.pend-item a:hover .pend-go { color: var(--ink); }

/* Mis pedidos (inicio del jefe): fila-enlace con estado legible y realce si ya está listo. */
.pedido-estado { list-style: none; margin: 0; padding: 0; }
.pedido-estado li + li { border-top: 1px solid var(--rule); }
.pedido-estado a { display: grid; grid-template-columns: 1fr auto; gap: 2px 14px; align-items: center; padding: 13px 2px; text-decoration: none; }
.pedido-estado a:hover strong { text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; }
.pedido-estado .todo-text { display: grid; gap: 1px; }
.pedido-estado .todo-text span { color: var(--muted); font-size: .9rem; }
.pedido-estado .pedido-estado-badge { font-size: .9rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.pedido-estado li.poratender { box-shadow: inset 3px 0 0 var(--accent); }
.pedido-estado li.poratender a { padding-left: 14px; }
.pedido-estado li.poratender .pedido-estado-badge { background: var(--primary); color: var(--on-primary); padding: 3px 10px; border-radius: 999px; }
.pedido-estado li.listo { background: var(--ok-bg); border-radius: var(--r-input, 6px); }
.pedido-estado li.listo a { padding-inline: 12px; }
.pedido-estado li.listo .todo-text span { color: var(--ok); }
.pedido-estado li.listo .pedido-estado-badge { background: var(--ok); color: var(--sheet); padding: 3px 10px; border-radius: 999px; }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 5.4rem 1fr; gap: 12px; padding: 10px 0; }
.feed li + li { border-top: 1px solid var(--rule); }
.feed time { color: var(--muted); font-size: .85rem; padding-top: 2px; }
.feed p { margin: 0; font-size: .95rem; }

/* ---------- Ficha de herramienta ---------- */
.where { padding: 20px; border: 1px solid var(--rule); border-radius: var(--r-panel); background: var(--sheet); margin-bottom: var(--s3); }
.where small { display: block; color: var(--muted); font-size: .9rem; font-weight: 600; }
.where strong { display: block; font-family: var(--font-title); font-size: clamp(1.6rem, 1.3rem + 1.2vw, 2.1rem); line-height: 1.1; margin: 2px 0 6px; }
.where span { color: var(--muted); }
.where.perdida strong { color: var(--bad); }

.dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; font-weight: 500; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 6.2rem 1fr; gap: 12px; padding: 10px 0; }
.timeline li + li { border-top: 1px solid var(--rule); }
.timeline time { color: var(--muted); font-size: .85rem; padding-top: 2px; }

.qr-box { display: grid; justify-items: center; gap: var(--s2); text-align: center; }
.qr-box img, .qr-box canvas { width: 150px; height: 150px; }

/* ---------- Pasos (Mover / Material) ---------- */
.step-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: var(--s3); }
.step-num { font-family: var(--font-title); font-weight: 800; font-size: 1.3rem; color: var(--muted); }
.step-head h2 { margin: 0; }
.step.locked { opacity: .55; }

.picker { display: flex; gap: var(--s2); }
.picker .search { flex: 1; }
.picker .btn { min-height: 52px; }
.results { list-style: none; margin: var(--s2) 0 0; padding: 0; border: 1px solid var(--edge); border-radius: var(--r-control); overflow: hidden; background: var(--field); }
.results li + li { border-top: 1px solid var(--rule); }
.results button {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; width: 100%; padding: 11px 14px;
  border: 0; background: transparent; font: inherit; text-align: left; cursor: pointer; color: var(--ink);
}
.results button:hover { background: var(--ground); }
.results button:disabled { cursor: not-allowed; opacity: .6; }
.results .r-sub { font-size: .88rem; color: var(--muted); }
.results .r-add { grid-row: 1 / span 2; grid-column: 2; font-weight: 700; font-size: .9rem; }
.results .r-none { padding: 14px; color: var(--muted); }

.quick-add { margin-top: var(--s3); display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: .9rem; color: var(--muted); }
.quick-add button { border: 1px dashed var(--edge); background: none; border-radius: var(--r-control); padding: 6px 11px; font: inherit; font-weight: 600; color: var(--ink); cursor: pointer; }
.quick-add button:hover { border-style: solid; border-color: var(--ink); }

.selected { list-style: none; margin: var(--s3) 0 0; padding: 0; border-top: 1px solid var(--edge); }
.selected li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.selected .s-text { flex: 1; display: grid; gap: 1px; min-width: 0; }
.selected .s-text span { font-size: .88rem; color: var(--muted); }
.selected .s-remove { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; border: 0; border-radius: var(--r-control); background: transparent; color: var(--muted); cursor: pointer; flex: 0 0 auto; }
.selected .s-remove:hover { background: var(--bad-bg); color: var(--bad); }
.selected .s-danada { order: 3; flex-basis: 100%; display: flex; align-items: center; gap: 8px; font-size: .9rem; font-weight: 600; color: var(--warn); cursor: pointer; }
.selected .s-danada input { width: 18px; height: 18px; min-height: 18px; accent-color: var(--warn); }
.selected .qty { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.selected .qty input { width: 100px; min-height: 42px; text-align: right; }
.selected .qty span { font-size: .88rem; color: var(--muted); min-width: 34px; }
.selected-empty { margin: var(--s3) 0 0; padding: var(--s3) 0; border-top: 1px solid var(--edge); color: var(--muted); }

.dests { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: var(--s2); }
.dest {
  display: grid; gap: 2px; justify-items: start; align-content: start; min-height: 64px; padding: 12px 14px;
  border: 1px solid var(--edge); border-radius: var(--r-control); background: var(--field);
  font: inherit; text-align: left; cursor: pointer; color: var(--ink);
}
.dest:hover:not(:disabled) { border-color: var(--ink); }
.dest:active:not(:disabled) { transform: translateY(1px); }
.dest .icon { display: none; }
.dest strong { font-size: 1rem; }
.dest span { font-size: .85rem; color: var(--muted); }
.dest[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.dest[aria-pressed="true"] span { color: var(--on-ink); }
.dest:disabled { opacity: .5; cursor: not-allowed; border-style: dashed; }

.confirm-bar {
  position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 10px); z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: 12px 12px 12px 18px;
  border-radius: var(--r-panel); background: var(--side); color: #fff; box-shadow: var(--shadow);
}
.confirm-bar .c-text { display: grid; gap: 1px; }
.confirm-bar .c-text strong { font-size: 1.05rem; }
.confirm-bar .c-text span { font-size: .86rem; color: var(--on-ink); }
.confirm-bar .btn { flex: 0 0 auto; }
@media (min-width: 768px) { .confirm-bar { bottom: 18px; } }

.done { padding: var(--s4) 20px; }
.done-icon { display: none; }
.done .done-tag { display: inline-block; margin-bottom: var(--s2); color: var(--ok); font-weight: 700; }
.done h2 { font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem); max-width: 22ch; }
.done .tools { max-width: 560px; margin: var(--s3) 0 var(--s4); border-top: 1px solid var(--edge); }

#reader { width: 100%; max-width: 480px; border-radius: var(--r-panel); overflow: hidden; }
.scan-panel { margin-top: var(--s3); }
@media (max-width: 420px) { .hide-sm { display: none; } }

/* ---------- Etiquetas QR para imprimir ---------- */
.labels { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.label-qr { display: grid; justify-items: center; gap: 4px; padding: 10px; border: 1px dashed var(--edge); border-radius: var(--r-tape); background: #fff; color: #141D35; text-align: center; break-inside: avoid; }
.label-qr .muted { color: #56617A; }
.label-qr .qr img, .label-qr .qr canvas { width: 120px !important; height: 120px !important; }
.label-qr strong { font-family: var(--font-title); font-size: 1.05rem; letter-spacing: .04em; }
.label-qr small { font-size: .74rem; line-height: 1.2; }

/* ---------- Documento imprimible: vale de pedido (P4) ---------- */
/* El vale siempre se ve como papel (blanco), sin importar el tema de la pantalla. */
.doc {
  --ink: #141D35; --muted: #56617A; --ground: #F2F4F8; --rule: #DFE3EC; --edge: #9AA4B8;
  --tint: #E6EEF8; --figure: #203368;
  max-width: 760px; margin: 0 auto; color: var(--ink); font-size: .95rem;
  background: #fff; padding: 34px 38px; border-radius: 8px;
  box-shadow: 0 10px 34px -14px rgba(0, 0, 0, .45);
}
@media (max-width: 520px) { .doc { padding: 22px 18px; } }
.doc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s3); border-bottom: 2px solid var(--ink); padding-bottom: var(--s2); margin-bottom: var(--s3); }
.doc-brand img { display: block; width: 230px; max-width: 60vw; height: auto; }
.doc-sub { margin-top: 6px; font-family: var(--font-title); font-weight: 700; font-size: 1.1rem; color: var(--figure); }
.doc-folio { text-align: right; white-space: nowrap; }
.doc-folio strong { display: block; font-family: var(--font-title); font-size: 1.5rem; color: var(--figure); }
.doc-folio span { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.doc-meta { width: 100%; border-collapse: collapse; margin-bottom: var(--s3); }
.doc-meta th { text-align: left; width: 6.5rem; font-size: .76rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; padding: 4px 10px 4px 0; vertical-align: top; }
.doc-meta td { padding: 4px 16px 4px 0; vertical-align: top; }
.doc-notas { background: var(--ground); border-left: 3px solid var(--edge); padding: 8px 12px; margin: 0 0 var(--s3); }
.doc-h { font-size: .95rem; margin: var(--s4) 0 6px; padding-bottom: 4px; border-bottom: 1px solid var(--ink); display: flex; justify-content: space-between; align-items: baseline; }
.doc-count { font-size: .78rem; color: var(--muted); font-weight: 600; }
.doc-chip { font-size: .72rem; color: var(--muted); font-weight: 600; border: 1px solid var(--rule); border-radius: 3px; padding: 0 5px; }
.doc-tabla { width: 100%; border-collapse: collapse; margin-bottom: var(--s3); font-size: .9rem; }
.doc-tabla th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); border-bottom: 1px solid var(--ink); padding: 4px 8px; }
.doc-tabla td { padding: 5px 8px; border-bottom: 1px solid var(--rule); }
.doc-tabla .c { text-align: center; }
.doc-box::before { content: ""; display: inline-block; width: 14px; height: 14px; border: 1.5px solid var(--edge); border-radius: 2px; vertical-align: middle; }
.doc-salida thead th { background: var(--figure); color: #fff; border-bottom-color: var(--figure); }
.doc-caja td { background: var(--tint); color: var(--figure); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; font-size: .8rem; text-align: center; border-bottom: 1px solid var(--ink); padding: 5px 8px; }
.doc-serie { font-size: .74rem; color: var(--muted); margin-top: 2px; }
.doc-vacio { color: var(--muted); font-style: italic; }
.doc-firmas { display: flex; gap: var(--s4); margin-top: var(--s5); }
.doc-firmas > div { flex: 1; text-align: center; font-size: .82rem; color: var(--muted); }
.doc-linea { display: block; border-top: 1px solid var(--ink); margin-bottom: 6px; height: 2.6rem; }
.doc-pie { margin-top: var(--s4); font-size: .72rem; color: var(--muted); text-align: center; }

@media print {
  body { background: #fff; padding: 0 !important; }
  .sidebar, .topbar, .tabbar, .drawer, .nav-backdrop, .page-head, .crumb, .no-print, .alert, .skip { display: none !important; }
  .main { margin: 0; padding: 0; max-width: none; }
  .card { padding: 0; background: none; }
  .labels { grid-template-columns: repeat(4, 1fr); gap: 4mm; }
  /* El vale se imprime en tinta negra aunque el usuario esté en modo noche */
  .doc { color: #000; max-width: none; background: #fff; box-shadow: none; padding: 0; }
  .doc-head, .doc-linea, .doc-tabla th { border-color: #000; }
  .doc-tabla td, .doc-h { border-color: #bbb; }
  .doc-sub, .doc-h, .doc-folio strong { color: #000; }
  .doc-meta th, .doc-folio span, .doc-count, .doc-chip, .doc-vacio, .doc-firmas > div, .doc-pie, .doc-tabla th { color: #555; }
  .doc-box::before { border-color: #000; }
  .doc-notas { background: #f1f1f1; border-color: #000; }
  /* Documento en un solo color (logo monocromo): bandas en gris, tinta negra */
  .doc-salida thead th, .doc-caja td { background: #E4E4E4 !important; color: #000; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .doc-caja td { border-color: #000; }
  .doc-serie { color: #555; }
}

.hide-mobile { display: none; }
@media (min-width: 768px) { .hide-mobile { display: inline-flex; } }

/* Ajustes de columnas y acciones */
th.num, td.num { padding-right: 22px; }
th:last-child, td:last-child { padding-right: 0; }
@media (max-width: 699px) {
  .stack td, .stack td.num { padding-right: 0; padding-left: 0; }
  .actions-bar .btn { flex: 1 1 auto; }
}
@media (min-width: 700px) {
  .selected .s-danada { order: 2; flex-basis: auto; }
}

.dl.lede { margin-bottom: var(--s4); }

/* =====================================================================
   Capa visual: tablero de etiquetas y medidores
   (ver la sección "Visual" de DESIGN.md). Color solo para estados.
   ===================================================================== */
:root {
  --track: #D3D8DB;
}

/* Tooltip simple (hover y foco de teclado) */
[data-tip] { position: relative; }
[data-tip]:hover::after, [data-tip]:focus-visible::after {
  content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%); z-index: 25;
  padding: 6px 9px; border-radius: var(--r-control); background: var(--ink); color: var(--sheet);
  font-size: .82rem; font-weight: 600; line-height: 1.3; white-space: nowrap; pointer-events: none;
}

/* Tablero de sombras: lo que tiene cada lugar, herramienta por herramienta */
.board { list-style: none; margin: 0; padding: 0; }
.board > li { padding: 14px 0; border-top: 1px solid var(--rule); }
.board > li:first-child { border-top: 1px solid var(--edge); }
.board-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 10px; }
.board-head a { font-weight: 700; font-size: 1.05rem; text-decoration: none; }
.board-head a:hover { text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; }
.board-head .meta { color: var(--muted); font-size: .9rem; }
.board-head .late { color: var(--bad); font-weight: 700; font-size: .9rem; }
.pegs { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 6px; }
.peg {
  display: grid; align-content: start; gap: 2px; min-height: 58px; padding: 7px 9px 6px; border-radius: var(--r-control);
  background: var(--peg); color: var(--ink); text-decoration: none; border: 1px solid var(--rule);
}
.peg:hover { border-color: var(--ink); text-decoration: none; }
.peg-code { font-weight: 600; font-size: .76rem; letter-spacing: .03em; color: var(--muted); }
.peg-name { font-size: .9rem; font-weight: 600; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.peg-flag { font-size: .76rem; font-weight: 700; line-height: 1.2; }
.peg.tarde .peg-flag { color: var(--bad); }
.peg.danada .peg-flag { color: var(--warn); }
.peg.tarde.danada .peg-flag { color: var(--bad); }
.peg.mas { place-items: center; align-content: center; font-weight: 600; font-size: .9rem; color: var(--muted); background: transparent; border-style: dashed; border-color: var(--edge); }
.pegs-empty { padding: 10px 4px; color: var(--muted); font-size: .92rem; }
.board-key { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; margin-top: var(--s3); padding-top: var(--s3); border-top: 1px dashed var(--rule); font-size: .86rem; color: var(--muted); }
.board-key-lbl { font-weight: 700; color: var(--ink); }
.board-key span { display: inline-flex; align-items: center; gap: 6px; }
.board-key b { font-weight: 700; }
.board-key b.tarde { color: var(--bad); }
.board-key b.danada { color: var(--warn); }

/* Medidor: un valor contra un límite (stock contra mínimo, carga de cuadrilla) */
.meter { position: relative; height: 8px; border-radius: 4px; background: var(--track); min-width: 90px; }
.meter > b { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: var(--muted); }
.meter.bajo > b { background: var(--bad); }
.meter.aviso > b { background: var(--warn); }
.meter > i { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); }
.meter > i.aviso { background: var(--warn); opacity: .75; }
.meter-cell { display: grid; gap: 4px; min-width: 140px; }
.meter-cell .meter-txt { font-size: .88rem; color: var(--muted); }
.meter-cell .meter-txt strong { color: var(--ink); }
.meter-cell .meter-txt .bajo { color: var(--bad); }
.meter-cell .meter-txt .aviso { color: var(--warn); }

@media (max-width: 699px) {
  .stack td.meter-td { display: block; width: auto !important; text-align: left; padding-top: 4px; }
  .stack td.meter-td::before { content: none; }
  .stack td.meter-td .meter-cell { min-width: 0; }
}
.meter-td .meter-cell { width: 100%; }
@media (max-width: 480px) {
  .pegs { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 5px; }
  /* Fichas de datos: etiqueta encima del valor, más legible en pantallas angostas */
  .dl { grid-template-columns: 1fr; gap: 0; }
  .dl dt { font-size: .85rem; }
  .dl dd { margin: 0 0 10px; }
  .dl dd:last-child { margin-bottom: 0; }
  /* Que una nota o código largo nunca empuje el ancho de la página */
  .tool-name, .s-text, td, .board-head a { overflow-wrap: anywhere; }
}

/* =====================================================================
   Intro: animación del logo al abrir la app (una vez por sesión).
   Se activa con html.splash-on (lo pone el script del <head> antes de
   pintar). Respeta el tema y se salta con prefers-reduced-motion.
   ===================================================================== */
.splash { display: none; }
html.splash-on .splash {
  display: grid; place-content: center; justify-items: center; gap: 18px;
  position: fixed; inset: 0; z-index: 9999; background: var(--ground);
  opacity: 1; transition: opacity .35s var(--ease);
}
html.splash-on.splash-off .splash { opacity: 0; pointer-events: none; }
.splash-mark {
  width: min(300px, 72vw);
  animation: splash-mark .62s var(--ease) both;
}
.splash-mark img { width: 100%; height: auto; }
.splash-bar {
  position: relative; width: 150px; height: 3px; border-radius: 3px;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}
/* El trazo con nodos de la línea bajo "SOLUCIONES" se dibuja de izquierda a derecha */
.splash-bar::before, .splash-bar > i {
  content: ""; position: absolute; top: 50%; width: 9px; height: 9px; margin-top: -4.5px; border-radius: 50%;
  border: 2px solid var(--accent); background: var(--ground); box-sizing: border-box; z-index: 1;
}
.splash-bar::before { left: -4px; }
.splash-bar > i { right: -4px; animation: splash-node .2s var(--ease) 1.4s both; }
.splash-bar::after {
  content: ""; display: block; height: 100%; width: 100%; border-radius: 3px;
  background: var(--accent); transform-origin: left;
  animation: splash-bar 1s var(--ease) .45s both;
}
@keyframes splash-node { from { opacity: 0; } to { opacity: 1; } }
@keyframes splash-mark {
  from { opacity: 0; transform: scale(.72) translateY(6px); }
  to   { opacity: 1; transform: none; }
}
@keyframes splash-word {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
@keyframes splash-bar {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}
@media (prefers-reduced-motion: reduce) {
  /* Sin animación: no mostramos la intro para no entorpecer */
  html.splash-on .splash { display: none; }
}

/* ---------- Autocompletado propio (reemplaza el desplegable nativo del datalist) ---------- */
.ac-list {
  position: absolute;
  z-index: 200;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--sheet);
  border: 1px solid var(--edge);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow);
  max-height: min(46vh, 340px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.ac-item {
  padding: 11px 12px;
  border-radius: 5px;
  cursor: pointer;
  color: var(--ink);
  font-size: .95rem;
  line-height: 1.25;
}
.ac-item + .ac-item { margin-top: 1px; }
.ac-item:hover, .ac-item.active { background: var(--ground); }
.ac-item.active { box-shadow: inset 3px 0 0 var(--accent); }
.ac-item mark {
  background: none;
  color: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
}

/* ---------- Renglones de pedido: tarjeta apilada con stepper (móvil-primero) ---------- */
.lineas { display: flex; flex-direction: column; gap: 10px; margin-bottom: var(--s3); }
.linea { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.linea-nombre { flex: 1 1 60%; min-width: 11rem; }
.linea-cant { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; margin-left: auto; }
.step-btn {
  min-width: 48px; min-height: 48px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.5rem; font-weight: 600; line-height: 1;
  background: var(--sheet); color: var(--ink);
  border: 1px solid var(--edge); border-radius: var(--r-control);
  cursor: pointer; -webkit-user-select: none; user-select: none;
}
.step-btn:hover { border-color: var(--ink); }
.step-btn:active { background: var(--ground); }
.linea-n {
  width: 3.4rem; min-width: 3.4rem; text-align: center; padding: 8px 4px;
  font-variant-numeric: tabular-nums; -moz-appearance: textfield;
}
.linea-n::-webkit-outer-spin-button, .linea-n::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.linea .btn-quitar {
  min-width: 48px; min-height: 48px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.25rem; line-height: 1; background: none; color: var(--muted);
  border: 1px solid var(--edge); border-radius: var(--r-control); cursor: pointer;
}
.linea .btn-quitar:hover { border-color: var(--bad); color: var(--bad); }

/* Nombre de la cuadrilla del jefe, resaltado como etiqueta de cinta para identificarlo rápido. */
.cuad-destacada {
  font-weight: 800; font-family: var(--font-title);
  background: var(--primary); color: var(--on-primary);
  padding: .05em .45em; border-radius: var(--r-tape); white-space: nowrap;
}

/* =====================================================================
   Movimiento: "el circuito se energiza" al entrar a cada página.
   Solo transform y opacity (los procesa la tarjeta gráfica). Todo usa
   "backwards" o termina en su estado normal, para no dejar transform
   aplicado. "Reducir movimiento" del sistema apaga todo (regla global).
   ===================================================================== */

/* 1) Entrada en cascada: título, cifras y tarjetas, una tras otra */
.main > * { animation: entra-bloque 420ms cubic-bezier(.2, .8, .2, 1) backwards; }
.main > :nth-child(1) { animation-delay: 0ms; }
.main > :nth-child(2) { animation-delay: 50ms; }
.main > :nth-child(3) { animation-delay: 100ms; }
.main > :nth-child(4) { animation-delay: 150ms; }
.main > :nth-child(5) { animation-delay: 200ms; }
.main > :nth-child(6) { animation-delay: 250ms; }
.main > :nth-child(n+7) { animation-delay: 300ms; }
@keyframes entra-bloque { from { opacity: 0; transform: translateY(16px) scale(.985); } }
/* Las cifras del inicio también entran una por una */
.kpis > li { animation: entra-bloque 420ms cubic-bezier(.2, .8, .2, 1) backwards; }
.kpis > li:nth-child(2) { animation-delay: 140ms; }
.kpis > li:nth-child(3) { animation-delay: 200ms; }
.kpis > li:nth-child(4) { animation-delay: 260ms; }
.kpis > li:nth-child(1) { animation-delay: 80ms; }
/* El trazo con nodo de cada cifra se "conecta" */
.kpis a::after { transform-origin: right; animation: traza-x 380ms var(--ease) 420ms backwards; }
.kpis a::before { animation: nodo-on 300ms var(--ease) 700ms backwards; }
@keyframes traza-x { from { transform: scaleX(0); } }
@keyframes nodo-on { from { opacity: 0; transform: scale(.3); } }

/* 2) El menú se energiza: el trazo se dibuja y el nodo emite un pulso */
.nav-marca::before { transform-origin: top; animation: traza-y 320ms var(--ease) 220ms backwards; }
.nav-marca::after { animation: pulso-nodo 900ms ease-out 300ms 1 both; }
@keyframes traza-y { from { transform: scaleY(0); } }
@keyframes pulso-nodo {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 70%, transparent); }
  100% { box-shadow: 0 0 0 9px transparent; }
}

/* 3) Corriente en el botón principal: un destello lo recorre al pasar el cursor */
.btn-primary, .side-cta .btn { position: relative; overflow: hidden; isolation: isolate; }
.btn-primary::after, .side-cta .btn::after {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, .28) 50%, transparent 70%);
  transform: translateX(-120%);
}
.btn-primary:hover::after, .side-cta .btn:hover::after { transform: translateX(120%); transition: transform 650ms var(--ease); }
.btn-primary .icon, .side-cta .btn .icon { transition: transform .25s var(--ease); }
.btn-primary:hover .icon, .side-cta .btn:hover .icon { transform: translateX(2px); }

/* 4) Lo que se puede tocar se eleva un poco */
.kpis a, .pend-item, .peg, .dest:not(:disabled), .caja-chip {
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .16s var(--ease), background-color .16s var(--ease);
}
@media (hover: hover) {
  .kpis a:hover, .pend-item:hover, .peg:hover, .dest:not(:disabled):hover {
    transform: translateY(-2px); box-shadow: 0 8px 20px -10px rgba(20, 32, 70, .45);
  }
}

/* 5) Celular: el ícono de la pestaña activa da un pequeño rebote */
.tabbar .active .icon { animation: rebote 420ms cubic-bezier(.3, 1.6, .5, 1) 120ms backwards; }
@keyframes rebote { from { transform: scale(.7) translateY(3px); opacity: .4; } }

/* 6) Entre páginas (Chrome, Edge, Safari 18.2+): la selección del menú y la
      marca de la pestaña se deslizan a su nuevo lugar; las barras no se animan. */
@view-transition { navigation: auto; }
.sidebar { view-transition-name: barra-lateral; }
.topbar { view-transition-name: barra-superior; }
.tabbar { view-transition-name: pestanas; }
/* Página y barras: sin animación de la transición (el contenido ya anima solo) */
::view-transition-old(root), ::view-transition-new(root),
::view-transition-group(barra-lateral), ::view-transition-group(barra-superior), ::view-transition-group(pestanas),
::view-transition-new(barra-lateral), ::view-transition-new(barra-superior), ::view-transition-new(pestanas) { animation: none; }
::view-transition-old(root),
::view-transition-old(barra-lateral), ::view-transition-old(barra-superior), ::view-transition-old(pestanas) { display: none; }
/* La selección del menú viaja a la nueva sección */
::view-transition-group(nav-activo), ::view-transition-group(tab-activo) { animation-duration: 340ms; animation-timing-function: cubic-bezier(.3, .7, .2, 1); }
::view-transition-old(nav-activo), ::view-transition-new(nav-activo),
::view-transition-old(tab-activo), ::view-transition-new(tab-activo) { animation: none; }
::view-transition-old(nav-activo), ::view-transition-old(tab-activo) { display: none; }
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
}

/* ---------- Kits: botones para pedir un kit y bloque de sus renglones en el pedido ---------- */
.kit-opciones { display: flex; flex-wrap: wrap; gap: var(--s2); margin-bottom: var(--s3); }
.kit-opcion {
  display: inline-flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 10px 14px; min-height: 48px; text-align: left; cursor: pointer;
  background: var(--sheet); color: var(--ink);
  border: 1px solid var(--edge); border-radius: var(--r-control); font: inherit; font-weight: 700;
}
.kit-opcion:hover { border-color: var(--primary); }
.kit-opcion .n { font-size: .8rem; font-weight: 500; color: var(--muted); }
.kit-opcion.agregado { border-color: var(--primary); background: var(--tint); }
.kit-bloque { border: 1px solid var(--edge); border-left: 4px solid var(--primary); border-radius: var(--r-control); padding: 10px 12px 2px; margin-bottom: var(--s3); }
.kit-bloque-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s2); margin-bottom: 10px; }
.kit-bloque-head .btn { min-height: 40px; }
.kit-grupo-head { display: flex; align-items: center; gap: 8px; margin: var(--s3) 0 var(--s2); font-family: var(--font-title); font-weight: 800; }
