* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  font-family: var(--fuente-cuerpo);
  background: var(--bg);
  color: var(--texto);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid var(--acento);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

#app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  touch-action: manipulation;
}

input {
  font-family: inherit;
}

.oculto {
  display: none !important;
}

/* ---------- Layout general ---------- */

.pantalla {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.contenido {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.contenido-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem 1.25rem;
}

/* ---------- Barra de navegación ---------- */

.barra-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  background: var(--bg-elevada);
  border-bottom: 1px solid var(--borde);
  flex-shrink: 0;
}

.barra-nav__marca {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--fuente-display);
  font-weight: 600;
  font-size: 1.2rem;
  letter-spacing: 0.01em;
  margin-right: 0.5rem;
  white-space: nowrap;
}

.barra-nav__logo {
  height: 1.8rem;
  width: 1.8rem;
  object-fit: contain;
  border-radius: 0.3rem;
}

.barra-nav__tabs {
  display: flex;
  gap: 0.4rem;
  flex: 1;
  overflow-x: auto;
}

.barra-nav__tab {
  background: transparent;
  color: var(--texto-tenue);
  padding: 0.6rem 1rem;
  border-radius: 0.6rem;
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
}

.barra-nav__tab.activo {
  background: var(--acento);
  color: var(--acento-texto);
}

.barra-nav__offline {
  background: var(--peligro-bg);
  color: var(--peligro);
  padding: 0.4rem 0.7rem;
  border-radius: 0.5rem;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}

.barra-nav__usuario {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding-left: 0.5rem;
  white-space: nowrap;
}

.barra-nav__usuario-nombre {
  font-weight: 600;
  font-size: 0.9rem;
}

.barra-nav__salir {
  background: var(--bg-hundida);
  color: var(--texto);
  padding: 0.5rem 0.8rem;
  border-radius: 0.5rem;
  font-size: 0.85rem;
}

/* ---------- Botones genéricos ---------- */

.boton {
  padding: 0.9rem 1.4rem;
  border-radius: 0.75rem;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  min-height: 3.2rem;
  transition: transform 0.06s ease, opacity 0.15s ease;
}

.boton:active {
  transform: scale(0.97);
}

.boton:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.boton-primario {
  background: var(--acento);
  color: var(--acento-texto);
}

.boton-exito {
  background: var(--exito);
  color: var(--exito-texto);
}

.boton-peligro {
  background: var(--peligro);
  color: var(--peligro-texto);
}

.boton-secundario {
  background: var(--bg-hundida);
  color: var(--texto);
}

.boton-fantasma {
  background: transparent;
  color: var(--texto-tenue);
  border: 2px solid var(--borde);
}

.boton-grande {
  min-height: 5.5rem;
  font-size: 1.3rem;
  border-radius: 1rem;
}

.boton-ancho {
  width: 100%;
}

/* ---------- Tarjetas ---------- */

.tarjeta {
  background: var(--bg-elevada);
  border: 1px solid var(--borde);
  border-radius: 1rem;
  padding: 1.1rem;
  box-shadow: var(--sombra);
}

.grilla-tarjetas {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.9rem;
}

.estadistica {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.estadistica__valor {
  font-size: 1.8rem;
  font-weight: 800;
}

.estadistica__etiqueta {
  color: var(--texto-tenue);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ---------- Formularios ---------- */

/* Base para CUALQUIER input/select/textarea, esté o no dentro de .campo:
   sin esto, en tema oscuro el navegador pinta texto oscuro por defecto
   (ilegible sobre fondo oscuro) en los que quedan fuera de .campo. */
input, select, textarea {
  color: var(--texto);
  background: var(--bg);
  border: 1px solid var(--borde);
  border-radius: 0.5rem;
  font-family: inherit;
}

.campo {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
}

.campo label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--texto-tenue);
}

.campo input, .campo select {
  padding: 0.75rem 0.9rem;
  border-radius: 0.6rem;
  border: 2px solid var(--borde);
  background: var(--bg);
  color: var(--texto);
  font-size: 1.05rem;
}

.campo input:focus, .campo select:focus {
  outline: none;
  border-color: var(--acento);
}

/* ---------- Modal ---------- */

.fondo-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1rem;
}

.modal {
  background: var(--bg-elevada);
  border-radius: 1.2rem;
  padding: 1.5rem;
  max-width: 34rem;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--sombra-flotante);
}

.modal h2 {
  margin-top: 0;
  font-family: var(--fuente-display);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.modal__acciones {
  display: flex;
  gap: 0.7rem;
  margin-top: 1.2rem;
}

.modal__acciones .boton {
  flex: 1;
}

/* ---------- Toast ---------- */

#zona-toast {
  position: fixed;
  bottom: 1.2rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 100;
  width: min(28rem, 92vw);
}

.toast {
  background: var(--bg-elevada);
  border: 1px solid var(--borde);
  border-left: 5px solid var(--acento);
  color: var(--texto);
  padding: 0.9rem 1.1rem;
  border-radius: 0.7rem;
  box-shadow: var(--sombra-flotante);
  font-weight: 600;
  animation: aparecer 0.15s ease;
}

.toast.exito { border-left-color: var(--exito); }
.toast.error { border-left-color: var(--peligro); }
.toast.info { border-left-color: var(--acento); }

@keyframes aparecer {
  from { opacity: 0; transform: translateY(0.5rem); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Insignias ---------- */

.insignia {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.insignia-advertencia { background: var(--advertencia-bg); color: var(--advertencia); }
.insignia-peligro { background: var(--peligro-bg); color: var(--peligro); }
.insignia-exito { background: var(--exito); color: #fff; }

/* ---------- Tablas ---------- */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th, td {
  text-align: left;
  padding: 0.6rem 0.7rem;
  border-bottom: 1px solid var(--borde);
}

th {
  color: var(--texto-tenue);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ---------- Gráfico de barras simple ---------- */

.grafico-barras {
  display: flex;
  align-items: flex-end;
  gap: 0.4rem;
  height: 9rem;
  overflow-x: auto;
  padding-bottom: 0.3rem;
}

.grafico-barras__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 0.3rem;
  min-width: 2.4rem;
  height: 100%;
  flex-shrink: 0;
}

.grafico-barras__barra {
  width: 1.6rem;
  min-height: 2px;
  background: var(--acento);
  border-radius: 0.3rem 0.3rem 0 0;
}

.grafico-barras__etiqueta {
  font-size: 0.7rem;
  color: var(--texto-tenue);
  white-space: nowrap;
}

.barra-horizontal {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.barra-horizontal__fila {
  display: grid;
  grid-template-columns: 8rem 1fr 4rem;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
}

.barra-horizontal__pista {
  background: var(--bg-hundida);
  border-radius: 999px;
  height: 0.9rem;
  overflow: hidden;
}

.barra-horizontal__relleno {
  height: 100%;
  background: var(--acento);
  border-radius: 999px;
}

.selector-periodo {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.2rem;
}

/* ---------- Login por PIN ---------- */

.pantalla-login {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  padding: 1.5rem;
  background: var(--bg);
}

.login__titulo {
  font-size: 2rem;
  font-weight: 800;
  text-align: center;
}

.login__vendedores {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  justify-content: center;
  max-width: 40rem;
}

.login__vendedor {
  background: var(--bg-elevada);
  border: 2px solid var(--borde);
  border-radius: 1rem;
  padding: 1.3rem 1.8rem;
  font-size: 1.2rem;
  font-weight: 700;
  min-width: 9rem;
  box-shadow: var(--sombra);
}

.login__vendedor.activo {
  border-color: var(--acento);
  color: var(--acento);
}

.login__pin-visor {
  display: flex;
  gap: 0.9rem;
}

.login__pin-punto {
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  border: 2px solid var(--texto-tenue);
  background: transparent;
}

.login__pin-punto.lleno {
  background: var(--acento);
  border-color: var(--acento);
}

.login__teclado {
  display: grid;
  grid-template-columns: repeat(3, 5.5rem);
  gap: 0.9rem;
}

.login__tecla {
  background: var(--bg-elevada);
  border: 1px solid var(--borde);
  border-radius: 1rem;
  font-size: 1.6rem;
  font-weight: 700;
  min-height: 5.5rem;
  box-shadow: var(--sombra);
}

.login__tecla:active {
  background: var(--bg-hundida);
}

.login__error {
  color: var(--peligro);
  font-weight: 700;
  min-height: 1.3rem;
}
