/* Diseño plano (Flat + Swiss) para uso en bodega: una mano, guantes, luz variable.
   Marca provisional: azul #14365c + naranja #f5a524. Semáforo: verde = hecho, naranja = atención, rojo = error. */
:root {
  --azul: #14365c; --azul-2: #1f4f86; --naranja: #f5a524; --naranja-2: #fff3dc;
  --verde: #157347; --verde-2: #e3f4ea; --rojo: #b3261e;
  --fondo: #f1f4f8; --tarjeta: #fff; --texto: #14202e; --suave: #4d5a6a; --borde: #cfd7e1;
  --radio: 14px; --t: 160ms; font-size: 17px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; line-height: 1.4; background: var(--fondo); color: var(--texto); }
main { max-width: 560px; margin: 0 auto; padding: 0 16px calc(32px + env(safe-area-inset-bottom)); }
svg { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* Barra superior */
header.barra { position: sticky; top: 0; z-index: 2; margin: 0 -16px 14px; padding: calc(10px + env(safe-area-inset-top)) 12px 10px 16px;
  background: var(--azul); color: #fff; display: flex; align-items: center; gap: 8px; border-bottom: 3px solid var(--naranja); }
header.barra:has(.icono) { padding-left: 4px; }
header.barra h1 { font-size: 1.1rem; margin: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: rgba(255,255,255,.18); color: #fff; border-radius: 999px; padding: 6px 12px; font-size: .9rem; font-weight: 700; white-space: nowrap; }
.chip svg { width: 16px; height: 16px; fill: var(--naranja); stroke: var(--naranja); }
.chip:empty, .chip[hidden], #toast[hidden] { display: none; }
.chip.alerta { background: var(--naranja); color: #000; min-height: 44px; }

/* Botones */
button { font: inherit; border: 0; border-radius: var(--radio); min-height: 48px; padding: 0 18px; cursor: pointer; color: inherit;
  transition: transform var(--t), background-color var(--t), opacity var(--t); }
button:active:not(:disabled) { transform: scale(.97); }
:focus-visible { outline: 3px solid var(--azul-2); outline-offset: 2px; }
header.barra :focus-visible { outline-color: #fff; }
.primario { background: var(--naranja); color: #000; font-weight: 800; font-size: 1.1rem; width: 100%; min-height: 56px; margin-top: 16px; }
.primario:disabled { opacity: .5; }
.secundario { background: var(--tarjeta); border: 2px solid var(--azul); color: var(--azul); font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.icono { background: transparent; color: #fff; min-width: 48px; padding: 0; display: inline-flex; align-items: center; justify-content: center; gap: 4px; font-weight: 700; }
.icono.texto { padding: 0 10px; font-size: .95rem; }
#btn-foto { width: 100%; }
#btn-foto::before { content: ""; width: 22px; height: 22px; background: currentColor;
  -webkit-mask: var(--ico-cam) center/contain no-repeat; mask: var(--ico-cam) center/contain no-repeat;
  --ico-cam: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><path d='M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z'/><circle cx='12' cy='13' r='4'/></svg>"); }

/* Formularios */
input, textarea { font: inherit; width: 100%; padding: 14px; border: 2px solid #7d8996; /* >= 3:1 sobre blanco */ border-radius: var(--radio); background: #fff; color: var(--texto); }
input:focus, textarea:focus { outline: none; border-color: var(--azul-2); box-shadow: 0 0 0 3px rgba(31,79,134,.25); }
input[type=search] { min-height: 52px; margin-bottom: 4px; }
label { display: block; font-weight: 700; margin: 16px 0 6px; font-size: .95rem; }
.error { color: var(--rojo); font-weight: 600; min-height: 1.4em; margin: 8px 0 0; }

/* Tarjetas y filas */
.tarjeta { background: var(--tarjeta); border-radius: var(--radio); padding: 16px; margin-bottom: 12px; border: 1px solid var(--borde); }
.sub { color: var(--suave); font-size: .88rem; margin: 2px 0 0; }
.resumen strong { font-size: 1.15rem; }
.fila { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: var(--tarjeta);
  border: 1px solid var(--borde); border-left: 5px solid var(--naranja); border-radius: var(--radio); padding: 14px 16px; margin-bottom: 8px; min-height: 64px; }
.fila:active:not(:disabled) { background: var(--naranja-2); }
.fila .info { flex: 1; min-width: 0; }
.fila .titulo { font-weight: 700; }
.fila.hecha { border-left-color: var(--verde); background: var(--verde-2); }
.fila.hecha:active { background: #cfeadb; }
.ok { display: inline-flex; align-items: center; gap: 4px; color: var(--verde); font-weight: 800; white-space: nowrap; }
.ok svg { width: 20px; height: 20px; stroke-width: 3; }
.con-foto { display: inline-flex; color: var(--azul); }
.con-foto svg { width: 20px; height: 20px; stroke-width: 2; }
.cuenta { font-weight: 800; color: var(--suave); white-space: nowrap; }
.vacio { text-align: center; color: var(--suave); padding: 32px 16px; }
.vacio svg { width: 40px; height: 40px; color: var(--borde); display: block; margin: 0 auto 8px; }
.barra-avance { display: block; height: 10px; border-radius: 99px; background: var(--borde); overflow: hidden; margin-top: 8px; }
.barra-avance > i { display: block; height: 100%; background: var(--verde); border-radius: 99px; transition: width .4s ease; }

/* Login */
.login { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: 24px 0; }
.login .marca { width: 64px; height: 64px; border-radius: 16px; background: var(--azul); color: var(--naranja); display: flex; align-items: center; justify-content: center; margin-bottom: 16px; border-bottom: 4px solid var(--naranja); }
.login .marca svg { width: 36px; height: 36px; }
.login h1 { color: var(--azul); margin: 0 0 4px; font-size: 1.7rem; }

/* Ficha: la cantidad manda */
.ficha-nombre { font-size: 1.25rem; font-weight: 800; margin: 4px 0 2px; line-height: 1.25; }
.cantidad { display: flex; gap: 8px; }
.cantidad input { text-align: center; font-size: 2.6rem; font-weight: 800; padding: 8px; min-height: 84px; border-color: var(--azul); color: var(--azul); }
.cantidad button { min-width: 72px; min-height: 84px; padding: 0; font-size: 2.2rem; font-weight: 700; line-height: 1; background: var(--azul); color: #fff; }
.foto { width: 100%; border-radius: var(--radio); margin-top: 8px; }
.ronda2 { background: var(--naranja); color: #000; border-radius: 6px; padding: 2px 8px; font-size: .8rem; font-weight: 800; }

/* Toast + gamificación */
#toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px); text-align: center;
  background: var(--texto); color: #fff; padding: 14px 22px; border-radius: 999px; z-index: 10; font-weight: 700; animation: sube .25s ease-out; }
#toast.puntos { background: var(--verde); font-size: 1.15rem; animation: pop .45s cubic-bezier(.2,1.4,.4,1); }
#toast.fiesta { background: var(--naranja); color: #000; font-size: 1.15rem; border-radius: var(--radio); padding: 18px 26px; animation: pop .6s cubic-bezier(.2,1.4,.4,1); box-shadow: 0 0 0 6px rgba(245,165,36,.35); }
#toast .estrella { color: inherit; display: inline-block; vertical-align: -4px; margin-right: 4px; }
@keyframes sube { from { opacity: 0; transform: translate(-50%, 12px); } }
@keyframes pop { 0% { opacity: 0; transform: translate(-50%, 20px) scale(.6); } 100% { opacity: 1; transform: translate(-50%, 0) scale(1); } }
.fila.hecha .ok svg { animation: tilda .4s ease-out; }
@keyframes tilda { from { transform: scale(0); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
