/* ============================================================
   CUADRES TFF — app.css
   Estilos compartidos de las pantallas del empleado.
   Movil primero: esto se usa DE PIE, al lado del camion, con
   una mano y a veces con guantes. Nada por debajo de 44 px.
   Paleta TFF: blanco · cereza #C8102E · carbon #1F2328 · dorado #C9A227
   ============================================================ */

/* ---------- Fichas de color ---------- */
:root {
  --cereza:      #C8102E;
  --cereza-osc:  #9E0B23;
  --cereza-flojo:#FDECEF;
  --carbon:      #1F2328;
  --dorado:      #C9A227;
  --dorado-flojo:#FBF3DC;

  --fondo:       #F3F4F6;
  --tarjeta:     #FFFFFF;
  --texto:       #1F2328;
  --suave:       #6B7280;
  --borde:       #E2E5EA;
  --sombreado:   #F7F8FA;

  --verde:       #10713F;
  --verde-flojo: #E6F4EC;
  --azul:        #1D4ED8;
  --azul-flojo:  #E8EEFD;
  --ambar:       #9A6206;
  --ambar-flojo: #FDF3DC;
  --gris-flojo:  #ECEEF1;

  --radio:       14px;
  --radio-chico: 10px;
  --sombra:      0 1px 2px rgba(16,20,26,.06), 0 8px 24px rgba(16,20,26,.07);
  --sombra-alta: 0 -2px 18px rgba(16,20,26,.12);
  --barra-alta:  56px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --cereza-flojo:#3A1119;
    --dorado-flojo:#3A3115;
    --fondo:       #14171A;
    --tarjeta:     #1F2328;
    --texto:       #ECEFF3;
    --suave:       #9BA3AE;
    --borde:       #333941;
    --sombreado:   #262B31;
    --verde-flojo: #12301F;
    --azul-flojo:  #182444;
    --ambar-flojo: #3A2E12;
    --gris-flojo:  #2A2F36;
    --sombra:      0 1px 2px rgba(0,0,0,.5), 0 8px 24px rgba(0,0,0,.45);
    --sombra-alta: 0 -2px 18px rgba(0,0,0,.5);
  }
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--fondo);
  color: var(--texto);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

a { color: var(--cereza); }

h1, h2, h3 { margin: 0 0 .4rem; line-height: 1.2; }

.oculto { display: none !important; }

.suave  { color: var(--suave); }
.chico  { font-size: .82rem; }
.fuerte { font-weight: 700; }
.der    { text-align: right; }
.centro { text-align: center; }

/* ---------- Barra superior ---------- */
.barra {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: .6rem;
  min-height: var(--barra-alta);
  padding: .35rem .8rem;
  padding-top: calc(.35rem + env(safe-area-inset-top));
  background: var(--carbon);
  color: #fff;
  box-shadow: 0 2px 10px rgba(16,20,26,.18);
}

.barra .marca {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 800;
  letter-spacing: .3px;
}

.barra .gota {
  width: 26px; height: 26px;
  flex: 0 0 26px;
  border-radius: 8px;
  background: var(--cereza);
  box-shadow: inset 0 0 0 2px var(--dorado);
}

.barra .titulo { font-size: 1.02rem; font-weight: 700; }
.barra .crece  { flex: 1 1 auto; min-width: 0; }

.barra a, .barra button {
  color: #fff;
  background: transparent;
  border: 0;
  font: inherit;
  text-decoration: none;
}

.barra .icono {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  border-radius: 12px;
  font-size: 1.2rem;
}

.barra .icono:active { background: rgba(255,255,255,.14); }

/* ---------- Contenido ---------- */
.contenido {
  max-width: 780px;
  margin: 0 auto;
  padding: .9rem .8rem calc(2.5rem + env(safe-area-inset-bottom));
}

.tarjeta {
  background: var(--tarjeta);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  padding: .9rem;
  margin-bottom: .75rem;
}

.tarjeta.pega { padding: 0; overflow: hidden; }

hr.raya { border: 0; border-top: 1px solid var(--borde); margin: .8rem 0; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  min-height: 46px;
  padding: .6rem 1rem;
  border: 1px solid var(--borde);
  border-radius: 12px;
  background: var(--tarjeta);
  color: var(--texto);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn:active { transform: translateY(1px); }

.btn[disabled], .btn.apagado {
  opacity: .5;
  pointer-events: none;
}

.btn-cereza {
  background: var(--cereza);
  border-color: var(--cereza);
  color: #fff;
}

.btn-carbon {
  background: var(--carbon);
  border-color: var(--carbon);
  color: #fff;
}

.btn-dorado {
  background: var(--dorado);
  border-color: var(--dorado);
  color: #221B00;
}

.btn-verde {
  background: var(--verde);
  border-color: var(--verde);
  color: #fff;
}

.btn-peligro {
  background: var(--cereza-flojo);
  border-color: var(--cereza);
  color: var(--cereza);
}

.btn-grande {
  width: 100%;
  min-height: 60px;
  font-size: 1.08rem;
  font-weight: 800;
  border-radius: var(--radio);
}

.btn-chico { min-height: 38px; padding: .3rem .7rem; font-size: .85rem; font-weight: 600; }

.botonera { display: flex; gap: .5rem; flex-wrap: wrap; }
.botonera > .btn { flex: 1 1 auto; }

/* ---------- Campos ---------- */
label.campo { display: block; margin-bottom: .75rem; }

label.campo > span {
  display: block;
  font-size: .82rem;
  font-weight: 700;
  color: var(--suave);
  margin-bottom: .3rem;
  text-transform: uppercase;
  letter-spacing: .4px;
}

input[type="text"], input[type="password"], input[type="search"],
input[type="number"], select, textarea {
  width: 100%;
  min-height: 48px;
  padding: .6rem .75rem;
  border: 1px solid var(--borde);
  border-radius: 12px;
  background: var(--tarjeta);
  color: var(--texto);
  font: inherit;
  font-size: 16px;            /* 16px o iOS hace zoom al enfocar */
}

textarea { min-height: 84px; resize: vertical; }

input:focus, select:focus, textarea:focus {
  outline: 3px solid rgba(200,16,46,.25);
  border-color: var(--cereza);
}

/* ---------- Chips de filtro ---------- */
.chips {
  display: flex;
  gap: .4rem;
  overflow-x: auto;
  padding: .1rem .1rem .4rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  min-height: 40px;
  padding: .35rem .8rem;
  border: 1px solid var(--borde);
  border-radius: 999px;
  background: var(--tarjeta);
  color: var(--texto);
  font: inherit;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.chip[aria-pressed="true"] {
  background: var(--carbon);
  border-color: var(--carbon);
  color: #fff;
}

/* ---------- Etiquetas de estado ---------- */
.estado {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .18rem .55rem;
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .4px;
  white-space: nowrap;
}

.estado::before {
  content: "";
  width: .5rem; height: .5rem;
  border-radius: 50%;
  background: currentColor;
}

.e-por_revisar { background: var(--ambar-flojo);  color: var(--ambar); }
.e-en_cuadre   { background: var(--azul-flojo);   color: var(--azul); }
.e-cuadrada    { background: var(--verde-flojo);  color: var(--verde); }
.e-aprobada    { background: var(--verde);        color: #fff; }
.e-reclamada   { background: var(--cereza-flojo); color: var(--cereza); }
.e-cerrada     { background: var(--gris-flojo);   color: var(--suave); }

/* ---------- Lista de facturas ---------- */
.factura {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--tarjeta);
  border: 1px solid var(--borde);
  border-left: 5px solid var(--borde);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  padding: .8rem .85rem;
  margin-bottom: .6rem;
}

.factura:active { background: var(--sombreado); }

.factura.b-por_revisar { border-left-color: var(--ambar); }
.factura.b-en_cuadre   { border-left-color: var(--azul); }
.factura.b-cuadrada    { border-left-color: var(--verde); }
.factura.b-aprobada    { border-left-color: var(--verde); }
.factura.b-reclamada   { border-left-color: var(--cereza); }
.factura.b-cerrada     { border-left-color: var(--suave); }

.factura .fila1 {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .5rem;
}

.factura .suplidor {
  font-weight: 800;
  font-size: 1.02rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.factura .meta { color: var(--suave); font-size: .84rem; margin-top: .1rem; }

/* La rejilla de dinero se usa en la tarjeta de la factura y en el
   resumen de la busqueda: por eso NO va anidada bajo .factura. */
.plata {
  display: flex;
  gap: 1.1rem;
  font-size: .86rem;
}

.plata > div { min-width: 0; }
.plata b { display: block; font-size: 1rem; font-variant-numeric: tabular-nums; }

.factura .plata {
  margin-top: .5rem;
  padding-top: .5rem;
  border-top: 1px dashed var(--borde);
}

.dif-favor  { color: var(--verde); }
.dif-contra { color: var(--cereza); }

/* ---------- Resumen fijo del cuadre ---------- */
.resumen {
  position: sticky;
  top: var(--barra-alta);
  z-index: 30;
  background: var(--carbon);
  color: #fff;
  border-radius: 0 0 var(--radio) var(--radio);
  padding: .6rem .8rem .7rem;
  box-shadow: 0 6px 18px rgba(16,20,26,.22);
}

.resumen .tres {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .4rem;
  text-align: center;
}

.resumen .caja small {
  display: block;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  opacity: .72;
}

.resumen .caja b {
  display: block;
  font-size: 1.15rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  margin-top: .1rem;
}

.resumen .caja.pagar b { color: var(--dorado); }
.resumen .caja.dif b   { color: #FF8FA1; }
.resumen .caja.dif.cero b { color: #fff; opacity: .8; }

.resumen .pie {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-top: .5rem;
  font-size: .78rem;
  opacity: .85;
}

.resumen .pie .guardado.sucio { color: var(--dorado); opacity: 1; font-weight: 700; }

/* ---------- Linea del cuadre ---------- */
.linea {
  background: var(--tarjeta);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  padding: .8rem;
  margin-bottom: .7rem;
}

.linea.sin-contar { border-style: dashed; }
.linea.con-dano   { border-color: var(--cereza); }

.linea .desc { font-weight: 800; font-size: 1.02rem; }

.linea .sub {
  color: var(--suave);
  font-size: .82rem;
  margin-top: .15rem;
  display: flex;
  flex-wrap: wrap;
  gap: .1rem .6rem;
}

.linea .facturado {
  margin-top: .5rem;
  padding: .45rem .6rem;
  background: var(--sombreado);
  border-radius: var(--radio-chico);
  font-size: .88rem;
  display: flex;
  justify-content: space-between;
  gap: .5rem;
  font-variant-numeric: tabular-nums;
}

.contador {
  display: flex;
  align-items: stretch;
  gap: .5rem;
  margin-top: .6rem;
}

.contador .menos, .contador .mas {
  flex: 0 0 62px;
  min-height: 62px;
  font-size: 1.7rem;
  font-weight: 700;
  border-radius: 14px;
  border: 1px solid var(--borde);
  background: var(--sombreado);
  color: var(--texto);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.contador .menos:active, .contador .mas:active { background: var(--borde); }

/* Factura aprobada o sin permiso: que se vea que no se toca */
.contador button:disabled { opacity: .4; cursor: default; }
.contador .valor[readonly] { background: var(--sombreado); color: var(--suave); }

.contador .valor {
  flex: 1 1 auto;
  min-width: 0;
  text-align: center;
  font-size: 1.6rem;
  font-weight: 800;
  min-height: 62px;
  border-radius: 14px;
  font-variant-numeric: tabular-nums;
}

.contador .valor.vacio { color: var(--suave); }

.rotulo-contador {
  margin-top: .55rem;
  font-size: .76rem;
  font-weight: 800;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--suave);
}

/* Dos atajos arriba y el boton rojo del dano a lo ancho: el pulgar
   no falla y las palabras no se parten. */
.atajos {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .4rem;
  margin-top: .5rem;
}

.atajos .btn { min-height: 44px; }
.atajos .btn-peligro { grid-column: 1 / -1; }

.avisos-linea {
  margin-top: .55rem;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: .35rem;
}

.pildora {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .3rem .6rem;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 700;
}

.p-falta { background: var(--ambar-flojo);  color: var(--ambar); }
.p-dano  { background: var(--cereza-flojo); color: var(--cereza); }
.p-ok    { background: var(--verde-flojo);  color: var(--verde); }
.p-mas   { background: var(--azul-flojo);   color: var(--azul); }

/* ---------- Panel de daño ---------- */
.dano {
  margin-top: .6rem;
  padding: .7rem;
  border: 1px solid var(--cereza);
  border-radius: var(--radio-chico);
  background: var(--cereza-flojo);
}

.dano .titulo {
  font-weight: 800;
  color: var(--cereza);
  margin-bottom: .5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ---------- Fotos ---------- */
.fotos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: .45rem;
  margin-top: .5rem;
}

.fotos .foto {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--radio-chico);
  overflow: hidden;
  background: var(--sombreado);
  border: 1px solid var(--borde);
}

.fotos .foto img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* La foto existe pero este usuario no puede verla (foto.php dice que no) */
.fotos .foto.rota {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: .4rem;
  font-size: .72rem;
  font-weight: 600;
  color: var(--suave);
  text-decoration: none;
}

.fotos .foto .quitar {
  position: absolute;
  top: 4px; right: 4px;
  width: 30px; height: 30px;
  border: 0;
  border-radius: 50%;
  background: rgba(31,35,40,.82);
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.fotos .foto .num {
  position: absolute;
  left: 4px; bottom: 4px;
  padding: .1rem .4rem;
  border-radius: 6px;
  background: rgba(31,35,40,.72);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
}

/* ---------- Subida / progreso ---------- */
.progreso {
  height: 12px;
  border-radius: 999px;
  background: var(--gris-flojo);
  overflow: hidden;
  margin-top: .6rem;
}

.progreso i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--cereza), var(--dorado));
  transition: width .2s ease;
}

.leyendo {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-top: .7rem;
  padding: .7rem .8rem;
  border-radius: var(--radio-chico);
  background: var(--dorado-flojo);
  color: var(--ambar);
  font-weight: 700;
}

.giro {
  width: 22px; height: 22px;
  flex: 0 0 22px;
  border-radius: 50%;
  border: 3px solid rgba(154,98,6,.28);
  border-top-color: var(--ambar);
  animation: gira .8s linear infinite;
}

@keyframes gira { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .giro { animation-duration: 2.4s; }
  .btn:active { transform: none; }
}

/* ---------- Avisos ---------- */
.nota {
  padding: .7rem .8rem;
  border-radius: var(--radio-chico);
  font-size: .9rem;
  margin-bottom: .7rem;
}

.n-error  { background: var(--cereza-flojo); color: var(--cereza); border: 1px solid var(--cereza); }
.n-aviso  { background: var(--ambar-flojo);  color: var(--ambar);  border: 1px solid var(--ambar); }
.n-bien   { background: var(--verde-flojo);  color: var(--verde);  border: 1px solid var(--verde); }
.n-info   { background: var(--azul-flojo);   color: var(--azul);   border: 1px solid var(--azul); }

.vacio {
  text-align: center;
  color: var(--suave);
  padding: 2.2rem 1rem;
}

.vacio .grande { font-size: 2.4rem; display: block; margin-bottom: .4rem; }

/* ---------- Barra de accion de abajo ---------- */
.pie-fijo {
  position: sticky;
  bottom: 0;
  z-index: 35;
  display: flex;
  gap: .5rem;
  padding: .6rem .8rem calc(.6rem + env(safe-area-inset-bottom));
  margin: .8rem -0.8rem 0;
  background: var(--tarjeta);
  border-top: 1px solid var(--borde);
  box-shadow: var(--sombra-alta);
}

.pie-fijo .btn { flex: 1 1 0; min-height: 54px; font-weight: 800; }

/* ---------- Avisos flotantes ---------- */
#avisos {
  position: fixed;
  left: 50%;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 90;
  width: min(94vw, 460px);
  display: flex;
  flex-direction: column;
  gap: .4rem;
  pointer-events: none;
}

#avisos .toast {
  padding: .7rem .9rem;
  border-radius: 12px;
  background: var(--carbon);
  color: #fff;
  font-size: .92rem;
  font-weight: 600;
  box-shadow: var(--sombra);
  animation: sube .18s ease-out;
}

#avisos .toast.malo  { background: var(--cereza); }
#avisos .toast.bueno { background: var(--verde); }

@keyframes sube { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Velo de espera ---------- */
#velo {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: .8rem;
  background: rgba(31,35,40,.55);
  backdrop-filter: blur(2px);
  color: #fff;
  font-weight: 700;
}

#velo .giro {
  width: 40px; height: 40px;
  flex: 0 0 40px;
  border-width: 4px;
  border-color: rgba(255,255,255,.3);
  border-top-color: #fff;
}

/* ---------- Login ---------- */
.entrada {
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;
  background:
    radial-gradient(1100px 420px at 50% -180px, rgba(200,16,46,.16), transparent 70%),
    var(--fondo);
}

.entrada .caja {
  width: min(100%, 400px);
  background: var(--tarjeta);
  border: 1px solid var(--borde);
  border-radius: 20px;
  box-shadow: var(--sombra);
  padding: 1.4rem 1.2rem 1.2rem;
}

.entrada .logo {
  width: 74px; height: 74px;
  margin: 0 auto .8rem;
  border-radius: 22px;
  background: var(--cereza);
  box-shadow: inset 0 0 0 3px var(--dorado), var(--sombra);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 900;
  font-size: 1.4rem;
  letter-spacing: .5px;
}

.entrada h1 { text-align: center; font-size: 1.35rem; }

.entrada .lema {
  text-align: center;
  color: var(--suave);
  font-size: .9rem;
  margin-bottom: 1.1rem;
}

.entrada .creditos {
  text-align: center;
  color: var(--suave);
  font-size: .75rem;
  margin-top: 1rem;
}

/* ---------- Pantallas anchas: mas aire, nunca mas apretado ---------- */
@media (min-width: 620px) {
  .contenido { padding: 1.2rem 1rem 3rem; }
  .atajos .btn { flex: 0 0 auto; }
}
